From ce427b2c6da4e56e043206305c7fc9ec2df7cc11 Mon Sep 17 00:00:00 2001 From: rainlizard <15337628+rainlizard@users.noreply.github.com> Date: Tue, 9 Apr 2024 10:36:46 +1000 Subject: [PATCH] Collectibles have their ownership automatically set when placing them --- Autoload/Things.gd | 2 +- Scenes/Instances.gd | 13 ++++++++----- Scenes/Selection.gd | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Autoload/Things.gd b/Autoload/Things.gd index bd252b88..bfa4eeb8 100644 --- a/Autoload/Things.gd +++ b/Autoload/Things.gd @@ -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, diff --git a/Scenes/Instances.gd b/Scenes/Instances.gd index 6c84c917..31f574b5 100644 --- a/Scenes/Instances.gd +++ b/Scenes/Instances.gd @@ -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") @@ -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" @@ -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 diff --git a/Scenes/Selection.gd b/Scenes/Selection.gd index c2842d9f..95332407 100644 --- a/Scenes/Selection.gd +++ b/Scenes/Selection.gd @@ -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)