Skip to content

Commit b9ba5ba

Browse files
committed
.
1 parent ccfbe63 commit b9ba5ba

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

Scenes/PlaceThingWithSlab.gd

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ onready var dir = oSlabPlacement.dir
1616
func place_slab_objects(xSlab, ySlab, slabID, ownership, clmIndexGroup, bitmask, surrID, bitmaskType):
1717
oInstances.delete_attached_instances_on_slab(xSlab, ySlab)
1818

19-
if slabID == Slabs.PRISON:
20-
bitmask = prison_bar_bitmask(slabID, surrID)
21-
elif slabID == Slabs.WATER:
19+
if slabID == Slabs.WATER:
2220
if Random.rng.randf_range(0.0, 100.0) < oWaterEffectPercent.value:
2321
var xSubtile = (xSlab*3) + Random.randi_range(0,2) + 0.5
2422
var ySubtile = (ySlab*3) + Random.randi_range(0,2) + 0.5
@@ -36,12 +34,25 @@ func place_slab_objects(xSlab, ySlab, slabID, ownership, clmIndexGroup, bitmask,
3634
if Slabs.is_door(slabID):
3735
create_door_thing(xSlab, ySlab, ownership)
3836

39-
for i in range(9): # iterate over the range of 0-8, assuming 9 subtiles per variation
40-
var variation = int(clmIndexGroup[i] / 9) # Convert to int for safety, as division of ints in GDScript results in float
41-
var convertedSubtile = clmIndexGroup[i] % 9
42-
var objectStuff = get_object(variation, convertedSubtile) # Pass slabVar and datSubtile to the get_object function
43-
if objectStuff.size() > 0:
44-
oInstances.spawn_attached(xSlab, ySlab, slabID, ownership, i, objectStuff)
37+
if slabID == Slabs.PRISON:
38+
var subtiles_with_bars = prison_bar_bitmask(slabID, surrID)
39+
40+
for i in range(9):
41+
var variation = int(clmIndexGroup[i] / 9)
42+
var convertedSubtile = clmIndexGroup[i] % 9
43+
var objectStuff = get_object(variation, convertedSubtile)
44+
45+
if objectStuff.size() > 0 and subtiles_with_bars.has(i):
46+
oInstances.spawn_attached(xSlab, ySlab, slabID, ownership, i, objectStuff)
47+
48+
else:
49+
50+
for i in range(9): # iterate over the range of 0-8, assuming 9 subtiles per variation
51+
var variation = int(clmIndexGroup[i] / 9) # Convert to int for safety, as division of ints in GDScript results in float
52+
var convertedSubtile = clmIndexGroup[i] % 9
53+
var objectStuff = get_object(variation, convertedSubtile) # Pass slabVar and datSubtile to the get_object function
54+
if objectStuff.size() > 0:
55+
oInstances.spawn_attached(xSlab, ySlab, slabID, ownership, i, objectStuff)
4556

4657
func get_object(variation, subtile):
4758
if variation < Slabset.tng.size():
@@ -81,9 +92,13 @@ func create_door_thing(xSlab, ySlab, ownership):
8192
id.update_spinning_key()
8293

8394
func prison_bar_bitmask(slabID, surrID):
84-
var bitmask = 0
85-
if Slabs.data[ surrID[dir.s] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.s]: bitmask += 1
86-
if Slabs.data[ surrID[dir.w] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.w]: bitmask += 2
87-
if Slabs.data[ surrID[dir.n] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.n]: bitmask += 4
88-
if Slabs.data[ surrID[dir.e] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.e]: bitmask += 8
89-
return bitmask
95+
var subtiles_with_bars = []
96+
if Slabs.data[ surrID[dir.s] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.s]:
97+
subtiles_with_bars.append_array([6, 7, 8])
98+
if Slabs.data[ surrID[dir.w] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.w]:
99+
subtiles_with_bars.append_array([0, 3, 6])
100+
if Slabs.data[ surrID[dir.n] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.n]:
101+
subtiles_with_bars.append_array([0, 1, 2])
102+
if Slabs.data[ surrID[dir.e] ][Slabs.IS_SOLID] == false and slabID != surrID[dir.e]:
103+
subtiles_with_bars.append_array([2, 5, 8])
104+
return subtiles_with_bars

0 commit comments

Comments
 (0)