diff options
Diffstat (limited to 'src/LivingVillage.Desktop/WorldBootstrap.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/WorldBootstrap.fs | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/LivingVillage.Desktop/WorldBootstrap.fs b/src/LivingVillage.Desktop/WorldBootstrap.fs index f8ba775..bf0ef65 100644 --- a/src/LivingVillage.Desktop/WorldBootstrap.fs +++ b/src/LivingVillage.Desktop/WorldBootstrap.fs @@ -35,17 +35,26 @@ module WorldBootstrap = nowTick state.Today } - let initialWorldWithOccupation (startAtDaylight: bool) (seed: uint64) (count: int) (occupation: Occupation.State option) : World = - if count < 0 || count > npcSpawnTiles.Length then + /// 以显式站位建世界:avatarTile 为玩家出生瓦片,npcTiles 为 NPC 出生瓦片序列。 + /// 64x48 旧档与世界走 `avatarSpawnPosition` + `npcSpawnTiles` 的等价调用,字节口径不变。 + let initialWorldWithPlacement + (startAtDaylight: bool) + (seed: uint64) + (count: int) + (avatarTile: int * int) + (npcTiles: (int * int) list) + (occupation: Occupation.State option) : World = + if count < 0 || count > npcTiles.Length then invalidArg (nameof count) "Desktop bootstrap supports at most 30 NPCs." + let avatarPosition = tileCenter (fst avatarTile) (snd avatarTile) let startTick = if startAtDaylight then daylightStartTick else 0L let baseWorld = Sim.initialWorldN seed count let avatar = let baseAvatar = { baseWorld.Avatar with - Pos = avatarSpawnPosition - Mind = { baseWorld.Avatar.Mind with Target = avatarSpawnPosition } } + Pos = avatarPosition + Mind = { baseWorld.Avatar.Mind with Target = avatarPosition } } match occupation with | None -> baseAvatar | Some state -> @@ -56,11 +65,11 @@ module WorldBootstrap = Needs = { needs with Money = float32 state.Profile.InitialMoney - Energy = state.Profile.InitialEnergy } } } + Energy = float32 state.Profile.InitialEnergy } } } let npcs = baseWorld.Npcs |> Array.mapi (fun index npc -> - let x, y = npcSpawnTiles.[index] + let x, y = List.item index npcTiles { npc with Pos = tileCenter x y }) { baseWorld with @@ -69,6 +78,20 @@ module WorldBootstrap = Avatar = avatar Npcs = npcs } + let initialWorldWithOccupation (startAtDaylight: bool) (seed: uint64) (count: int) (occupation: Occupation.State option) : World = + initialWorldWithPlacement + startAtDaylight + seed + count + (31, 25) + (List.ofArray npcSpawnTiles) + occupation + + /// P20 第三步:默认可玩世界。生成器的核心可达区作为站位,30 个 spawn 全部落核心可达域。 + let initialWorldInMap (startAtDaylight: bool) (seed: uint64) (count: int) (map: MapGen.Result) : World = + let avatarTile = ((map.Core.MinX + map.Core.MaxX) / 2, (map.Core.MinY + map.Core.MaxY) / 2) + initialWorldWithPlacement startAtDaylight seed count avatarTile map.Spawns None + let initialWorldForDaylight (startAtDaylight: bool) (seed: uint64) (count: int) : World = initialWorldWithOccupation startAtDaylight seed count None |
