wand-of-trans/scenes/gender_reactive_tilemap.gd

68 lines
2.3 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
func _on_main_character_gender_changed(new_gender: String) -> void:
for coord in get_used_cells():
var tile_data = get_cell_tile_data(coord)
if not tile_data:
continue
var tile_type = tile_data.get_custom_data("gender")
var arr = tile_type.split(".")
if arr.size() != 3:
continue
var tile_gender = arr[0]
var tile_party = arr[1]
var tile_on = arr[2]
var atlas_coords = get_cell_atlas_coords(coord)
if new_gender == "female":
if tile_gender == "girl" and tile_on == "off":
if tile_party == "pillow":
atlas_coords.y -= 4 + 4 + 4
set_cell(coord, 6, atlas_coords)
if tile_party == "disco":
atlas_coords.y -= 4
set_cell(coord, 6, atlas_coords)
if tile_gender == "boy" and tile_on == "on":
if tile_party == "pillow":
atlas_coords.y += 4
set_cell(coord, 6, atlas_coords)
if tile_party == "disco":
atlas_coords.y += 4
set_cell(coord, 6, atlas_coords)
if new_gender == "male":
if tile_gender == "girl" and tile_on == "on":
if tile_party == "pillow":
atlas_coords.y += 4 + 4 + 4
set_cell(coord, 6, atlas_coords)
if tile_party == "disco":
atlas_coords.y += 4
set_cell(coord, 6, atlas_coords)
if tile_gender == "boy" and tile_on == "off":
if tile_party == "pillow":
atlas_coords.y -= 4
set_cell(coord, 6, atlas_coords)
if tile_party == "disco":
atlas_coords.y -= 4
set_cell(coord, 6, atlas_coords)
var female_active_cells = get_used_cells_by_id(-1, Vector2i(0,0))
var female_inactive_cells = get_used_cells_by_id(-1, Vector2i(0,3))
var male_active_cells = get_used_cells_by_id(-1, Vector2i(0,1))
var male_inactive_cells = get_used_cells_by_id(-1, Vector2i(0,4))
if new_gender == "female":
for coord in female_inactive_cells: set_cell(coord, 2, Vector2i(0,0))
for coord in male_active_cells: set_cell(coord, 2, Vector2i(0,4))
if new_gender == "male":
for coord in female_active_cells: set_cell(coord, 2, Vector2i(0,3))
for coord in male_inactive_cells: set_cell(coord, 2, Vector2i(0,1))