Skip to content

Commit

Permalink
Custom doors wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Nov 27, 2023
1 parent 4e300bb commit 75c8e73
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Autoload/Cube.gd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const rngCube = {
"Wall" : [72,73,74],
#"EarthPathUnderneath" : [25,26,27,28,29], # This is apparently unnecessary, it'll just flood the column indexes
}
# "Lava" : [546,547], # This one is a FloorTexture (find out if it even needs to be randomized)

const stoneRatio = 0.15

enum {
Expand Down
11 changes: 10 additions & 1 deletion Autoload/Slabs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ enum {
}

var rooms_that_have_walls = {14:null,16:null,18:null,20:null,22:null,24:null,26:null,28:null,30:null,32:null,34:null,36:null,38:null,40:null}
var doors = {42:null,43:null,44:null,45:null,46:null,47:null,48:null,49:null}
########################################################################
# These are just to make it easier to read
const NOT_OWNABLE = false
Expand Down Expand Up @@ -285,3 +284,13 @@ PURPLE_PATH,
# IRON_DOOR_1
# MAGIC_DOOR_1
]

func is_door(slabID):
if data.has(slabID) == false:
var oMessage = Nodelist.list["oMessage"]
oMessage.quick("Door ID missing from structure")
return false

if data[slabID][BITMASK_TYPE] == BITMASK_DOOR1 or data[slabID][BITMASK_TYPE] == BITMASK_DOOR2:
return true
return false
8 changes: 8 additions & 0 deletions Scenes/AddCustomSlabWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ func _on_AddCustomSlabButton_pressed():
}
oCustomSlabSystem.add_custom_slab(slab_dict)

if oSlabBitmaskOptionButton.get_selected_id() == Slabs.BITMASK_DOOR1:
var second_slab_dict = slab_dict.duplicate(true)
var IdOfDoor2 = int(oCustomSlabID.value+1)
second_slab_dict.header_id = newID+1
second_slab_dict.recognized_as = IdOfDoor2
oCustomSlabSystem.add_custom_slab(second_slab_dict)
oMessage.big("Note", "ID: " + str(IdOfDoor2) + " was also added, it's assumed to be the other door direction.")

oPickSlabWindow.add_slabs()
oSlabTabs.current_tab = Slabs.TAB_CUSTOM
oPickSlabWindow.set_selection(newID)
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func on_slab_delete_stray_door_thing_and_key(id, slabID):
if id.is_in_group("Thing"):
# Kill doors and keys that aren't on door slabIDs
if id.is_in_group("Door") or id.is_in_group("Key"):
if Slabs.doors.has(slabID) == false:
if Slabs.is_door(slabID) == false:
id.queue_free()

func on_slab_set_gold_owner_to_slab_owner(id, slabID, ownership):
Expand Down
3 changes: 1 addition & 2 deletions Scenes/PickSlabWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ func set_selection(setID):
oSelection.paintSlab = setID

oSlabTabs.set_current_tab(tabIndex)

if Slabs.doors.has(oSelection.paintSlab):
if Slabs.is_door(oSelection.paintSlab):
oPlaceLockedCheckBox.visible = true
else:
oPlaceLockedCheckBox.visible = false
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func some_manual_placements_dont_update_nearby():
# Fake Slabs don't update the surroundings (! HAD TO COMMENT THIS OUT BECAUSE IT BREAKS CUSTOM SLABSET SLABS)
# if oCustomSlabsTab.visible == true and oPickSlabWindow.oSelectedRect.visible == true:
# return false
if Slabs.doors.has(paintSlab): # Doors don't update the surroundings
if Slabs.is_door(paintSlab): # Doors don't update the surroundings
return false
return true

Expand Down
2 changes: 1 addition & 1 deletion Scenes/SlabDisplay.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func set_visual(columnArray):
$AspectRatioContainer/Icon.texture = null
if Slabs.icons.has(slabID):
$AspectRatioContainer/Icon.texture = Slabs.icons[slabID]
if Slabs.doors.has(slabID) == false:
if Slabs.is_door(slabID) == false:
$AspectRatioContainer.anchor_top -= 0.05
$AspectRatioContainer.anchor_bottom -= 0.05
$AspectRatioContainer.anchor_left += 0.01
Expand Down
17 changes: 11 additions & 6 deletions Scenes/SlabPlacement.gd
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,12 @@ func generate_slabs_based_on_id(shapePositionArray, updateNearby):

for pos in shapePositionArray:
var slabID = oDataSlab.get_cell(pos.x, pos.y)

var ownership = oDataOwnership.get_cell(pos.x, pos.y)
do_slab(pos.x, pos.y, slabID, ownership)

oInstances.manage_things_on_slab(pos.x, pos.y, slabID, ownership)
if Slabs.data.has(slabID):
do_slab(pos.x, pos.y, slabID, ownership)
oInstances.manage_things_on_slab(pos.x, pos.y, slabID, ownership)

currentLoad += 1

Expand Down Expand Up @@ -524,6 +526,9 @@ func place_general(xSlab, ySlab, slabID, ownership, surrID, surrOwner, bitmaskTy

if slabID == Slabs.EARTH_WITH_TORCH:
adjust_torch_cubes(xSlab, ySlab, constructedColumns, surrID)
elif slabID == Slabs.LAVA: # Just hardcode the random FloorTexture for lava. I think it only looks different in the editor.
for i in constructedFloor.size():
constructedFloor[i] = Random.choose([546,547])

set_columns(xSlab, ySlab, constructedColumns, constructedFloor)
oPlaceThingWithSlab.place_slab_objects(xSlab, ySlab, slabID, ownership, clmIndexGroup, bitmask, surrID, surrOwner)
Expand Down Expand Up @@ -769,10 +774,10 @@ func get_wall_bitmask(xSlab, ySlab, surrID, ownership):

func get_claimed_bitmask(slabID, ownership, surrID, surrOwner):
var bitmask = 0
if (slabID != surrID[dir.s] and Slabs.doors.has(surrID[dir.s]) == false) or ownership != surrOwner[dir.s]: bitmask += 1
if (slabID != surrID[dir.w] and Slabs.doors.has(surrID[dir.w]) == false) or ownership != surrOwner[dir.w]: bitmask += 2
if (slabID != surrID[dir.n] and Slabs.doors.has(surrID[dir.n]) == false) or ownership != surrOwner[dir.n]: bitmask += 4
if (slabID != surrID[dir.e] and Slabs.doors.has(surrID[dir.e]) == false) or ownership != surrOwner[dir.e]: bitmask += 8
if (slabID != surrID[dir.s] and Slabs.is_door(surrID[dir.s]) == false) or ownership != surrOwner[dir.s]: bitmask += 1
if (slabID != surrID[dir.w] and Slabs.is_door(surrID[dir.w]) == false) or ownership != surrOwner[dir.w]: bitmask += 2
if (slabID != surrID[dir.n] and Slabs.is_door(surrID[dir.n]) == false) or ownership != surrOwner[dir.n]: bitmask += 4
if (slabID != surrID[dir.e] and Slabs.is_door(surrID[dir.e]) == false) or ownership != surrOwner[dir.e]: bitmask += 8
return bitmask

func get_general_bitmask(slabID, ownership, surrID, surrOwner):
Expand Down

0 comments on commit 75c8e73

Please sign in to comment.