@@ -12,112 +12,104 @@ type SandBox3dPlugin () =
1212
1313 let WallColor = Palette.BaseColorValues.[ 0 ]
1414
15- let wallSlice ( center : Vector3i ) chunk =
16- match chunk.Blocks.TryGetValue center with
17- | ( true , middleBlock) when middleBlock.Color = WallColor ->
18- match chunk.Blocks.TryGetValue ( center + v3iUp) with
19- | ( true , topBlock) when topBlock.Color = WallColor ->
20- match chunk.Blocks.TryGetValue ( v3iOne + v3iDown) with
21- | ( true , bottomBlock) when bottomBlock.Color = WallColor -> Some ( bottomBlock, middleBlock, topBlock)
22- | (_, _) -> None
23- | (_, _) -> None
24- | (_, _) -> None
25-
26- let createWallModel horizonal halfDirectionOpt ( affine : Affine ) ( parent : Entity ) world =
15+ let createWallModel lateral halfDirectionOpt ( affine : Affine ) ( parent : Entity ) world =
2716 let name = " Wall" + string Gen.id64
2817 let surnames = Array.add name parent.Surnames
2918 let entity = World.createEntity< RigidModelDispatcher> ( Some Address.parent) NoOverlay ( Some surnames) parent.Group world
3019 let ( translation , scale ) =
31- if horizonal then
20+ if lateral then
3221 match halfDirectionOpt with
3322 | Some false -> ( v3 - 0.25 f 0.0 f 0.0 f, v3 0.5 f 3.0 f 0.5 f)
3423 | Some true -> ( v3 0.25 f 0.0 f 0.0 f, v3 0.5 f 3.0 f 0.5 f)
3524 | None -> ( v3Zero, v3 1.0 f 3.0 f 0.5 f)
3625 else
3726 match halfDirectionOpt with
38- | Some false -> ( v3 0.0 f 0.0 f - 0.25 f, v3 1.0 f 3.0 f 0.5 f)
39- | Some true -> ( v3 0.0 f 0.0 f 0.25 f, v3 1.0 f 3.0 f 0.5 f)
27+ | Some false -> ( v3 0.0 f 0.0 f - 0.25 f, v3 0.5 f 3.0 f 0.5 f)
28+ | Some true -> ( v3 0.0 f 0.0 f 0.25 f, v3 0.5 f 3.0 f 0.5 f)
4029 | None -> ( v3Zero, v3 0.5 f 3.0 f 1.0 f)
41-
42- entity.SetStaticModel Assets.Default.StaticModel world
4330 entity.SetPositionLocal ( translation + affine.Translation) world
4431 entity.SetRotationLocal affine.Rotation world
4532 entity.SetScaleLocal ( scale * affine.Scale) world
33+ entity.SetStaticModel Assets.Default.StaticModel world
4634
47- let wall volume affine params chunk =
35+ let wallSlice ( center : Vector3i ) chunk =
36+ match chunk.Blocks.TryGetValue center with
37+ | ( true , middleBlock) when middleBlock.Color = WallColor ->
38+ match chunk.Blocks.TryGetValue ( center + v3iUp) with
39+ | ( true , topBlock) when topBlock.Color = WallColor ->
40+ match chunk.Blocks.TryGetValue ( v3iOne + v3iDown) with
41+ | ( true , bottomBlock) when bottomBlock.Color = WallColor -> Some ( bottomBlock, middleBlock, topBlock)
42+ | (_, _) -> None
43+ | (_, _) -> None
44+ | (_, _) -> None
45+
46+ let wall _ affine _ chunk =
4847 let center = v3iOne
49- match wallSlice center chunk with
50- | Some ( bottomBlock , middleBlock , topBlock ) ->
48+ let centerWallOpt = wallSlice center chunk
49+ if centerWallOpt.IsSome then
5150 let forwardWallOpt = wallSlice ( center + v3iForward) chunk
5251 let rightWallOpt = wallSlice ( center + v3iRight) chunk
5352 let backWallOpt = wallSlice ( center + v3iBack) chunk
5453 let leftWallOpt = wallSlice ( center + v3iLeft) chunk
5554 if forwardWallOpt.IsSome && rightWallOpt.IsSome && backWallOpt.IsSome && leftWallOpt.IsSome then
56- let effect ( parent : Entity ) world =
55+ let effect parent world =
5756 createWallModel false None affine parent world
5857 createWallModel true None affine parent world
59- chunk
60- Some effect
58+ Some ( effect, chunk)
6159 elif forwardWallOpt.IsSome && backWallOpt.IsSome && rightWallOpt.IsSome then
62- let effect ( parent : Entity ) world =
60+ let effect parent world =
6361 createWallModel false None affine parent world
6462 createWallModel true ( Some true ) affine parent world
65- chunk
66- Some effect
63+ Some ( effect, chunk)
6764 elif forwardWallOpt.IsSome && backWallOpt.IsSome && leftWallOpt.IsSome then
68- let effect ( parent : Entity ) world =
65+ let effect parent world =
6966 createWallModel false None affine parent world
7067 createWallModel true ( Some false ) affine parent world
71- chunk
72- Some effect
68+ Some ( effect, chunk)
7369 elif leftWallOpt.IsSome && rightWallOpt.IsSome && forwardWallOpt.IsSome then
74- let effect ( parent : Entity ) world =
70+ let effect parent world =
7571 createWallModel true None affine parent world
7672 createWallModel false ( Some false ) affine parent world
77- chunk
78- Some effect
73+ Some ( effect, chunk)
7974 elif leftWallOpt.IsSome && rightWallOpt.IsSome && backWallOpt.IsSome then
80- let effect ( parent : Entity ) world =
75+ let effect parent world =
8176 createWallModel true None affine parent world
8277 createWallModel false ( Some true ) affine parent world
83- chunk
84- Some effect
78+ Some ( effect, chunk)
8579 elif forwardWallOpt.IsSome && backWallOpt.IsSome then
86- let effect ( parent : Entity ) world =
87- createWallModel false None affine parent world
88- chunk
89- Some effect
80+ let effect parent world = createWallModel false None affine parent world
81+ Some ( effect, chunk)
9082 elif leftWallOpt.IsSome && rightWallOpt.IsSome then
91- let effect ( parent : Entity ) world =
92- createWallModel true None affine parent world
93- chunk
94- Some effect
83+ let effect parent world = createWallModel true None affine parent world
84+ Some ( effect, chunk)
9585 elif forwardWallOpt.IsSome && rightWallOpt.IsSome then
96- let effect ( parent : Entity ) world =
86+ let effect parent world =
9787 createWallModel false ( Some false ) affine parent world
9888 createWallModel true ( Some true ) affine parent world
99- chunk
100- Some effect
89+ Some ( effect, chunk)
10190 elif forwardWallOpt.IsSome && leftWallOpt.IsSome then
102- let effect ( parent : Entity ) world =
91+ let effect parent world =
10392 createWallModel false ( Some false ) affine parent world
10493 createWallModel true ( Some false ) affine parent world
105- chunk
106- Some effect
94+ Some ( effect, chunk)
10795 elif backWallOpt.IsSome && rightWallOpt.IsSome then
108- let effect ( parent : Entity ) world =
96+ let effect parent world =
10997 createWallModel false ( Some true ) affine parent world
11098 createWallModel true ( Some true ) affine parent world
111- chunk
112- Some effect
99+ Some ( effect, chunk)
113100 elif backWallOpt.IsSome && leftWallOpt.IsSome then
114- let effect ( parent : Entity ) world =
101+ let effect parent world =
115102 createWallModel false ( Some true ) affine parent world
116103 createWallModel true ( Some false ) affine parent world
117- chunk
118- Some effect
104+ Some ( effect, chunk)
105+ elif forwardWallOpt.IsSome || backWallOpt.IsSome then
106+ let effect parent world = createWallModel false None affine parent world
107+ Some ( effect, chunk)
108+ elif rightWallOpt.IsSome || leftWallOpt.IsSome then
109+ let effect parent world = createWallModel true None affine parent world
110+ Some ( effect, chunk)
119111 else None
120- | None -> None
112+ else None
121113
122114 // this exposes different editing modes in the editor.
123115 override this.EditModes =
0 commit comments