diff options
Diffstat (limited to 'src/LivingVillage.Desktop')
| -rw-r--r-- | src/LivingVillage.Desktop/WorldBootstrap.fs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/LivingVillage.Desktop/WorldBootstrap.fs b/src/LivingVillage.Desktop/WorldBootstrap.fs index d6b906d..0e8ea30 100644 --- a/src/LivingVillage.Desktop/WorldBootstrap.fs +++ b/src/LivingVillage.Desktop/WorldBootstrap.fs @@ -18,16 +18,28 @@ module WorldBootstrap = let private daylightStartTick = 6L * Sim.ticksPerDay / 24L - let initialWorldForDaylight (startAtDaylight: bool) (seed: uint64) (count: int) : World = + let initialWorldWithOccupation (startAtDaylight: bool) (seed: uint64) (count: int) (occupation: Occupation.State option) : World = if count < 0 || count > npcSpawnTiles.Length then invalidArg (nameof count) "Desktop bootstrap supports at most 30 NPCs." let startTick = if startAtDaylight then daylightStartTick else 0L let baseWorld = Sim.initialWorldN seed count let avatar = - { baseWorld.Avatar with - Pos = avatarSpawnPosition - Mind = { baseWorld.Avatar.Mind with Target = avatarSpawnPosition } } + let baseAvatar = + { baseWorld.Avatar with + Pos = avatarSpawnPosition + Mind = { baseWorld.Avatar.Mind with Target = avatarSpawnPosition } } + match occupation with + | None -> baseAvatar + | Some state -> + let needs = baseAvatar.Mind.Needs + { baseAvatar with + Mind = + { baseAvatar.Mind with + Needs = + { needs with + Money = float32 state.Profile.InitialMoney + Energy = state.Profile.InitialEnergy } } } let npcs = baseWorld.Npcs |> Array.mapi (fun index npc -> @@ -40,5 +52,8 @@ module WorldBootstrap = Avatar = avatar Npcs = npcs } + let initialWorldForDaylight (startAtDaylight: bool) (seed: uint64) (count: int) : World = + initialWorldWithOccupation startAtDaylight seed count None + let initialWorld (seed: uint64) (count: int) : World = - initialWorldForDaylight false seed count + initialWorldWithOccupation false seed count None |
