blob: 0be478602115e3b4eb6e1ea9ea8a2c55b9836039 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
namespace LivingVillage.Desktop
open LivingVillage.Kernel.Sim
open LivingVillage.Desktop.VillagePresentation
module VillageArt =
type PropKind =
| WhiteWallDarkTileHouse
| StoneBridge
| Bamboo
| VegetableGarden
type TileKind =
| RiverWater
| StonePaving
type ArtProp =
{ Kind: PropKind
Position: TilePosition }
type ArtTile =
{ Kind: TileKind
Position: TilePosition }
type JiangnanArtPlan =
{ Props: ArtProp list
Tiles: ArtTile list }
type NpcVisualVariant =
| IndigoRobe
| OchreVest
| JadeSash
type FacingDirection =
| NorthFacing
| SouthFacing
| WestFacing
| EastFacing
type AnimationFrame =
| FrameOne
| FrameTwo
type NpcSpriteSpec =
{ Variant: NpcVisualVariant
Direction: FacingDirection
Frame: AnimationFrame }
let private position x y : TilePosition =
{ X = x
Y = y }
let private prop kind x y : ArtProp =
{ Kind = kind
Position = position x y }
let private tile kind x y : ArtTile =
{ Kind = kind
Position = position x y }
let samplePlan () : JiangnanArtPlan =
{ Props =
[ prop WhiteWallDarkTileHouse 6 4
prop StoneBridge 10 4
prop Bamboo 3 2
prop VegetableGarden 8 7 ]
Tiles =
[ tile RiverWater 10 2
tile RiverWater 10 3
tile StonePaving 4 5
tile StonePaving 5 5
tile StonePaving 6 5 ] }
let private positiveModulo divisor value =
let remainder = value % divisor
if remainder < 0 then remainder + divisor else remainder
let npcVisualVariant (NpcId npcId) : NpcVisualVariant =
match positiveModulo 3 npcId with
| 0 -> IndigoRobe
| 1 -> OchreVest
| _ -> JadeSash
let private positiveModulo64 divisor value =
let remainder = value % divisor
if remainder < 0L then remainder + divisor else remainder
let animationFrame (tick: int64) : AnimationFrame =
if positiveModulo64 8L tick < 4L then FrameOne else FrameTwo
let npcSpriteSpec (npcId: NpcId) (direction: FacingDirection) (tick: int64) : NpcSpriteSpec =
{ Variant = npcVisualVariant npcId
Direction = direction
Frame = animationFrame tick }
|