Room variation types (#517)

* Global.gd now has an extra variable for current room type

* ResourceSetterNew.gd now has variation category for room types

The state variable also had to include the room type, since it wouldn't update properly when entering a bonus room from a level that's already underground

* LevelClass.gd sets room type on update_theme

A new function, get_room_type() allows for the level's room type to be detected, which can easily be overwritten by other level classes. Bonus Rooms are detected by comparing the level's scene path to a pre-defined list of bonus rooms.

* Added get_room_type() to CoinHeaven.gd

* Added get_room_type() to PipeCutscene.gd

Also updates the room type in _enter_tree() since update_theme() isn't called here.

* Added get_room_type() to TitleScreen.gd
This commit is contained in:
Tsank35
2025-10-06 14:05:43 -07:00
committed by GitHub
parent 6a48a5b32f
commit 27ae3d5612
6 changed files with 41 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ static var property_cache := {}
var current_json_path := ""
static var state := [0, 0]
static var state := [0, 0, 0]
static var pack_configs := {}
@@ -53,7 +53,7 @@ func update_resource() -> void:
randomize()
if is_inside_tree() == false or is_queued_for_deletion() or resource_json == null or node_to_affect == null:
return
if state != [Global.level_theme, Global.theme_time]:
if state != [Global.level_theme, Global.theme_time, Global.current_room]:
cache.clear()
property_cache.clear()
if node_to_affect != null:
@@ -61,7 +61,7 @@ func update_resource() -> void:
node_to_affect.set(property_name, resource)
if node_to_affect is AnimatedSprite2D:
node_to_affect.play()
state = [Global.level_theme, Global.theme_time]
state = [Global.level_theme, Global.theme_time, Global.current_room]
updated.emit()
func get_resource(json_file: JSON) -> Resource:
@@ -245,6 +245,15 @@ func get_variation_json(json := {}) -> Dictionary:
else:
json = get_variation_json(json[level_string])
var room = Global.room_strings[Global.current_room]
if json.has(room) == false:
room = Global.room_strings[0]
if json.has(room):
if json.get(room).has("link"):
json = get_variation_json(json[json.get(room).get("link")])
else:
json = get_variation_json(json[room])
var game_mode = "GameMode:" + Global.game_mode_strings[Global.current_game_mode]
if json.has(game_mode) == false:
game_mode = "GameMode:" + Global.game_mode_strings[0]