blob: 612931b4b7f119e180b7a1ef265049500e3ce93d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
namespace LivingVillage.Desktop
open LivingVillage.Kernel
open LivingVillage.Kernel.Sim
module WorldBootstrap =
let private tileCenter (x: int) (y: int) : Vec2 =
{ X = float32 (x * Sim.tilePixels + Sim.tilePixels / 2)
Y = float32 (y * Sim.tilePixels + Sim.tilePixels / 2) }
let private npcSpawnTiles : (int * int) array =
[| for y in [ 14; 18; 28; 32; 36; 40 ] do
for x in [ 24; 28; 32; 36; 40 ] do
yield x, y |]
let private avatarSpawnPosition = tileCenter 31 25
let initialWorld (seed: uint64) (count: int) : World =
if count < 0 || count > npcSpawnTiles.Length then
invalidArg (nameof count) "Desktop bootstrap supports at most 30 NPCs."
let baseWorld = Sim.initialWorldN seed count
let avatar =
{ baseWorld.Avatar with
Pos = avatarSpawnPosition
Mind = { baseWorld.Avatar.Mind with Target = avatarSpawnPosition } }
let npcs =
baseWorld.Npcs
|> Array.mapi (fun index npc ->
let x, y = npcSpawnTiles.[index]
{ npc with Pos = tileCenter x y })
{ baseWorld with
Avatar = avatar
Npcs = npcs }
|