wand-of-trans/scenes/gender_reactive_tilemap.gd
2024-11-08 09:28:28 -05:00

50 lines
1.1 KiB
GDScript

extends TileMapLayer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
pass
var female_tiles_y_offset = \
[0, # girl on
8, # boy on
-8, # girl off
0, # boy off
0, # city
0, # disco
16, # boy pillow on
0, # girl pillow on
0, # neutral pillow
-8, # girl pillow off
0] # boy pillow off
var male_tiles_y_offset = \
[8, # girl on
0, # boy on
0, # girl off
-8, # boy off
0, # city
0, # disco
0, # boy pillow on
8, # girl pillow on
0, # neutral pillow
0, # girl pillow off
-16] # boy pillow off
func _on_main_character_gender_changed(new_gender: String) -> void:
for coord in get_used_cells():
if get_cell_source_id(coord) != 0:
continue
var atlas_coord = get_cell_atlas_coords(coord)
var index = floor(atlas_coord.y / 4)
if new_gender == "female":
atlas_coord.y += female_tiles_y_offset[index]
if new_gender == "male":
atlas_coord.y += male_tiles_y_offset[index]
set_cell(coord, 0, atlas_coord)