wand-of-trans/scenes/gender_reactive_tilemap.gd

50 lines
1.1 KiB
GDScript3
Raw Normal View History

2024-10-26 10:31:17 -04:00
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
2024-11-08 09:28:28 -05:00
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
2024-10-26 10:31:17 -04:00
2024-11-08 09:28:28 -05:00
func _on_main_character_gender_changed(new_gender: String) -> void:
2024-10-26 10:31:17 -04:00
for coord in get_used_cells():
2024-11-08 09:28:28 -05:00
if get_cell_source_id(coord) != 0:
2024-10-26 10:31:17 -04:00
continue
2024-11-08 09:28:28 -05:00
var atlas_coord = get_cell_atlas_coords(coord)
var index = floor(atlas_coord.y / 4)
2024-10-26 10:31:17 -04:00
if new_gender == "female":
2024-11-08 09:28:28 -05:00
atlas_coord.y += female_tiles_y_offset[index]
2024-10-26 10:31:17 -04:00
if new_gender == "male":
2024-11-08 09:28:28 -05:00
atlas_coord.y += male_tiles_y_offset[index]
2024-10-26 10:31:17 -04:00
2024-11-08 09:28:28 -05:00
set_cell(coord, 0, atlas_coord)