Stupid length exceeded I cba to write anything
This commit is contained in:
parent
49e344f109
commit
1d04d27969
10 changed files with 235 additions and 58 deletions
|
|
@ -3,7 +3,6 @@ class_name CustomTileMap
|
|||
|
||||
var astar : AStarGrid2D = AStarGrid2D.new()
|
||||
@onready var fog_overlay : ColorRect = $FogOverlay
|
||||
@onready var mushroom_glow_container : Node2D = $MushroomGlowContainer
|
||||
|
||||
@onready var tilemap_size : Vector2i = get_used_rect().end - get_used_rect().position
|
||||
@onready var map_rect : Rect2i = Rect2i(Vector2i.ZERO, tilemap_size)
|
||||
|
|
@ -12,6 +11,9 @@ var mushroom_glow : PackedScene = load("res://entities/mushroom_glow.tscn")
|
|||
|
||||
var highlighted_tiles : Array = []
|
||||
|
||||
# Has a signal to indicate the tilemap has been updated
|
||||
signal tilemap_updated
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
var tile_size : Vector2i = get_tileset().tile_size
|
||||
|
|
@ -20,7 +22,8 @@ func _ready() -> void:
|
|||
|
||||
|
||||
setup_pathing()
|
||||
check_for_visible_gatherables()
|
||||
# check_for_visible_gatherables()
|
||||
emit_signal('tilemap_updated')
|
||||
pass
|
||||
|
||||
func setup_pathing() -> void:
|
||||
|
|
@ -71,8 +74,6 @@ func _unhandled_input(event : InputEvent) -> void:
|
|||
var click_position : Vector2 = get_global_mouse_position()
|
||||
var tile_position : Vector2i = local_to_map(click_position)
|
||||
|
||||
Log.pr(tile_position)
|
||||
|
||||
## Check if the clicked tile is a wall
|
||||
|
||||
## Get the surrounding wall tiles and redraw them
|
||||
|
|
@ -88,7 +89,8 @@ func _unhandled_input(event : InputEvent) -> void:
|
|||
redraw_surrounding_tiles(surrounding_cells)
|
||||
|
||||
update_passable()
|
||||
check_for_visible_gatherables()
|
||||
## Emit event to update the mushroom glowies
|
||||
emit_signal('tilemap_updated')
|
||||
|
||||
|
||||
func redraw_surrounding_tiles(positions : Array) -> void:
|
||||
|
|
@ -108,34 +110,8 @@ func filter_indestructible_tiles(coords : Array) -> Array:
|
|||
if tile_data and tile_data.get_custom_data('indestructible') != true:
|
||||
filtered_coords.append(coord)
|
||||
|
||||
Log.pr(filtered_coords)
|
||||
return filtered_coords
|
||||
|
||||
func check_for_visible_gatherables() -> void:
|
||||
return
|
||||
# Remove all existing glowing lights
|
||||
for child in mushroom_glow_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
## Loop through the tiles on the gatherables layer and check if the thing on
|
||||
# the layer below them is a wall, we don't add a glow - if it is visible then we do
|
||||
for i in tilemap_size.x:
|
||||
for j in tilemap_size.y:
|
||||
var coords : Vector2i = Vector2i(i, j)
|
||||
var tile_data : TileData = get_cell_tile_data(1, coords)
|
||||
if tile_data:
|
||||
# Get the tile data from the base layer
|
||||
var below_tile_data : TileData = get_cell_tile_data(0, coords)
|
||||
if below_tile_data and below_tile_data.get_custom_data('navtype') == 'wall':
|
||||
Log.pr("This is behind a wall...")
|
||||
else:
|
||||
if tile_data.get_custom_data('glowcolour'):
|
||||
var glow_colour : String = tile_data.get_custom_data('glowcolour')
|
||||
var glow : MushroomGlow = mushroom_glow.instantiate()
|
||||
glow.set_position(coords * get_tileset().tile_size + get_tileset().tile_size / 2)
|
||||
glow.colour_name = glow_colour
|
||||
mushroom_glow_container.add_child.call_deferred(glow)
|
||||
|
||||
func get_layer_id_by_name(level_name : String) -> int:
|
||||
var layers : int = get_layers_count()
|
||||
for i in layers:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue