Skip to content

Commit

Permalink
Collectibles have their ownership automatically set when placing them
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Apr 9, 2024
1 parent afa3ce3 commit ce427b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Autoload/Things.gd
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ enum SPELLBOOK {
DESTROY_WALLS = 47
}

var genre_belonging = {
var collectible_belonging = {
TAB_GOLD : Slabs.TREASURE_ROOM,
TAB_SPELL : Slabs.LIBRARY,
TAB_SPECIAL : Slabs.LIBRARY,
Expand Down
13 changes: 8 additions & 5 deletions Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ onready var oMirrorPlacementCheckBox = Nodelist.list["oMirrorPlacementCheckBox"]
onready var oSelector = Nodelist.list["oSelector"]
onready var oPlaceThingsAnywhere = Nodelist.list["oPlaceThingsAnywhere"]
onready var oOnlyOwnership = Nodelist.list["oOnlyOwnership"]
onready var oDataOwnership = Nodelist.list["oDataOwnership"]


var thingScn = preload("res://Scenes/ThingInstance.tscn")
Expand Down Expand Up @@ -248,6 +249,8 @@ func place_new_thing(newThingType, newSubtype, newPosition, newOwnership): # Pla
id.subtype = newSubtype
id.ownership = newOwnership

set_collectibles_ownership(id, slabID, oDataOwnership.get_cell(xSlab, ySlab))

match id.thingType:
Things.TYPE.OBJECT:
id.parentTile = 65535 # "None"
Expand Down Expand Up @@ -431,15 +434,15 @@ func manage_things_on_slab(xSlab, ySlab, slabID, ownership):
for id in get_tree().get_nodes_in_group(checkSlabLocationGroup):
on_slab_update_thing_height(id)
on_slab_delete_stray_door_thing_and_key(id, slabID)
on_slab_set_belongings_ownership(id, slabID, ownership)
set_collectibles_ownership(id, slabID, ownership)


func on_slab_set_belongings_ownership(id, slabID, ownership):
func set_collectibles_ownership(id, slabID, slabOwnership):
if id.thingType == Things.TYPE.OBJECT:
var genre = Things.DATA_OBJECT[id.subtype][Things.EDITOR_TAB]
if Things.genre_belonging.has(genre):
if slabID == Things.genre_belonging[genre]:
id.ownership = ownership
if Things.collectible_belonging.has(genre):
if slabID == Things.collectible_belonging[genre]:
id.ownership = slabOwnership
else:
id.ownership = 5

Expand Down
2 changes: 1 addition & 1 deletion Scenes/Selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func newPaintSubtype(value):
oOwnerSelection.collectible_ownership_mode(false)
if paintThingType == Things.TYPE.OBJECT:
var genre = Things.DATA_OBJECT[paintSubtype][Things.EDITOR_TAB]
if Things.genre_belonging.has(genre):
if Things.collectible_belonging.has(genre):
oOwnerSelection.collectible_ownership_mode(true)


Expand Down

0 comments on commit ce427b2

Please sign in to comment.