Stupid length exceeded I cba to write anything

This commit is contained in:
Dan 2024-06-05 15:49:58 +01:00
parent 49e344f109
commit 1d04d27969
10 changed files with 235 additions and 58 deletions

View file

@ -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:

View file

@ -12,7 +12,8 @@
[ext_resource type="Texture2D" uid="uid://yryvsvyxc5d3" path="res://resources/water_tileset.png" id="8_47btp"]
[ext_resource type="PackedScene" uid="uid://ddwnkcnncxmjv" path="res://entities/glowing.tscn" id="8_gmlkg"]
[ext_resource type="PackedScene" uid="uid://qgxsbmcv0nqh" path="res://components/CrystalGlowComponent.tscn" id="10_8n1hc"]
[ext_resource type="Texture2D" uid="uid://cfrgsucpgwsc0" path="res://resources/particles/smoke_01.png" id="10_pyntn"]
[ext_resource type="PackedScene" uid="uid://c87qvtq8ho3bb" path="res://components/MushroomGlowComponent.tscn" id="13_uwl47"]
[ext_resource type="PackedScene" uid="uid://mawos5ss1cod" path="res://components/WaterEffectComponent.tscn" id="14_x3ue3"]
[sub_resource type="Environment" id="Environment_ct14l"]
background_mode = 3
@ -3747,6 +3748,7 @@ texture = ExtResource("8_47btp")
2:6/0/terrains_peering_bit/top_side = 3
2:6/0/terrains_peering_bit/top_right_corner = 3
2:6/0/custom_data_0 = "water"
2:6/0/custom_data_1 = "water"
2:6/0/custom_data_2 = true
3:6/0 = 0
3:6/0/material = ExtResource("1_iph1s")
@ -3761,6 +3763,7 @@ texture = ExtResource("8_47btp")
3:6/0/terrains_peering_bit/top_side = 3
3:6/0/terrains_peering_bit/top_right_corner = 3
3:6/0/custom_data_0 = "water"
3:6/0/custom_data_1 = "water"
3:6/0/custom_data_2 = true
4:6/animation_columns = 2
4:6/animation_separation = Vector2i(5, 0)
@ -3813,6 +3816,7 @@ texture = ExtResource("8_47btp")
2:7/0/terrains_peering_bit/top_side = 3
2:7/0/terrains_peering_bit/top_right_corner = 3
2:7/0/custom_data_0 = "water"
2:7/0/custom_data_1 = "water"
2:7/0/custom_data_2 = true
3:7/0 = 0
3:7/0/material = ExtResource("1_iph1s")
@ -3827,6 +3831,7 @@ texture = ExtResource("8_47btp")
3:7/0/terrains_peering_bit/top_side = 3
3:7/0/terrains_peering_bit/top_right_corner = 3
3:7/0/custom_data_0 = "water"
3:7/0/custom_data_1 = "water"
3:7/0/custom_data_2 = true
4:7/animation_columns = 2
4:7/animation_separation = Vector2i(5, 0)
@ -3989,10 +3994,6 @@ shader_parameter/fog_direction = Vector2(1, 1)
shader_parameter/scroll_noise_tex = false
shader_parameter/noise_scroll_direction = Vector2(1, 0)
[sub_resource type="Gradient" id="Gradient_2c8cw"]
offsets = PackedFloat32Array(0, 0.32646, 0.705674, 1)
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 0.482353, 1, 1, 1, 1, 1, 1, 1, 0)
[node name="TestLevel" type="Node2D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
@ -4007,7 +4008,7 @@ layer_1/name = "Water"
layer_1/tile_data = PackedInt32Array(655511, 6, 5, 721047, 6, 6, 786583, 262150, 2, 852119, 262150, 3, 589976, 65542, 4, 655512, 65542, 5, 721048, 65542, 6, 786584, 327686, 2, 852120, 131078, 0, 917656, 131078, 1, 589977, 131078, 4, 655513, 131078, 5, 721049, 131078, 6, 786585, 131078, 7, 852121, 196614, 0, 917657, 196614, 1, 589978, 196614, 4, 655514, 196614, 5, 721050, 196614, 6, 786586, 196614, 7, 852122, 196614, 8, 917658, 196614, 9, 589979, 262150, 4, 655515, 262150, 5, 721051, 262150, 6, 786587, 262150, 7, 852123, 262150, 8, 917659, 262150, 9, 655516, 327686, 5, 721052, 327686, 6, 786588, 327686, 7, 852124, 327686, 8, 786581, 131078, 4, 852117, 131078, 5, 786582, 196614, 4, 852118, 196614, 5, 786579, 196614, 2, 852115, 196614, 3, 786580, 196614, 4, 852116, 196614, 5, 983192, 262150, 6, 1048728, 262150, 7, 983191, 327686, 1, 1048727, 327686, 2, 983193, 327686, 6, 1048729, 327686, 7, 917654, 262150, 0, 983190, 262150, 1, 917655, 327686, 0, 917652, 131078, 0, 983188, 131078, 1, 917653, 196614, 0, 983189, 196614, 1, 1048724, 131078, 2, 1114260, 131078, 3, 1048725, 196614, 2, 1114261, 196614, 3, 1048726, 262150, 2, 1114262, 262150, 3, 1114263, 327686, 3, 1179796, 131078, 6, 1245332, 196614, 6, 1179797, 131078, 6, 1245333, 196614, 6, 1179798, 196614, 6, 1245334, 262150, 6, 1114264, 262150, 8, 1179800, 327686, 8, 1114265, 327686, 8, 1179799, 262150, 8, 1245335, 327686, 6, 1310868, 196614, 7, 1310869, 196614, 7, 1376402, 196614, 6, 1441938, 196614, 6, 1376403, 131078, 6, 1441939, 131078, 6, 1376404, 196614, 6, 1441940, 196614, 6, 1376405, 131078, 6, 721040, 196614, 5, 786576, 196614, 6, 721041, 196614, 5, 786577, 196614, 6, 786578, 131078, 2, 721042, 262150, 5, 721039, 131078, 5, 655503, 131078, 4, 721037, 131078, 5, 786573, 262150, 0, 655502, 196614, 4, 721038, 196614, 5, 786574, 327686, 0, 786575, 131078, 6, 655504, 196614, 4, 655505, 196614, 4, 852111, 131078, 7, 655506, 262150, 4, 721043, 327686, 5, 852114, 131078, 3, 917648, 131078, 0, 983184, 131078, 1, 917649, 196614, 0, 983185, 196614, 1, 917650, 262150, 0, 983186, 262150, 1, 917651, 327686, 0, 983187, 327686, 1, 1048722, 6, 6, 1114258, 6, 6, 1048723, 65542, 6, 1114259, 65542, 6, 1048719, 196614, 7, 1114255, 196614, 8, 1179791, 196614, 9, 1048720, 262150, 7, 1114256, 262150, 8, 1179792, 262150, 9, 1048721, 327686, 7, 1114257, 327686, 8, 1048716, 65542, 8, 1114252, 6, 8, 1048717, 196614, 6, 1114253, 65542, 8, 1179789, 65542, 9, 1048718, 131078, 7, 1114254, 131078, 8, 1179790, 131078, 9, 983180, 65542, 5, 917645, 262150, 2, 983181, 262150, 3, 852108, 65542, 9, 852109, 262150, 1, 852110, 327686, 1, 917646, 327686, 2, 721036, 65542, 5, 786572, 65542, 8, 655501, 131078, 4, 983182, 327686, 3, 983183, 131078, 7, 917647, 131078, 7, 852112, 131078, 7, 852113, 131078, 7, 721035, 6, 5, 655500, 65542, 4, 852106, 6, 0, 917642, 6, 1, 852107, 65542, 0, 917643, 65542, 1, 983179, 6, 5, 917644, 65542, 4, 786571, 6, 8, 1048715, 6, 8, 1179794, 131078, 4, 1245330, 131078, 5, 1179795, 65542, 7, 1245331, 131078, 6, 1245329, 65542, 5, 1310865, 131078, 6, 1310866, 131078, 7, 1179793, 65542, 4, 1310862, 131078, 4, 1376398, 131078, 5, 1245327, 65542, 4, 1310863, 65542, 5, 1376399, 131078, 6, 1245328, 131078, 4, 1310864, 131078, 5, 1376400, 196614, 6, 1310867, 131078, 7, 1376396, 6, 5, 1310861, 65542, 4, 1376397, 65542, 5, 1441932, 6, 6, 1441933, 65542, 6, 1441934, 131078, 6, 1507468, 6, 7, 1573004, 6, 6, 1507469, 65542, 7, 1573005, 65542, 6, 1507470, 131078, 7, 1573006, 131078, 6, 1638541, 65542, 8, 1704077, 65542, 9, 1638542, 131078, 8, 1704078, 131078, 9, 1638543, 196614, 8, 1704079, 196614, 9, 1638544, 131078, 8, 1704080, 131078, 9, 1638545, 196614, 8, 1573008, 196614, 7, 1573009, 196614, 7, 1704081, 196614, 9, 1573010, 131078, 7, 1638546, 131078, 8, 1704082, 131078, 9, 1573011, 196614, 7, 1638547, 196614, 8, 1704083, 196614, 9, 1573012, 131078, 6, 1638548, 262150, 8, 1704084, 262150, 9, 1573013, 262150, 8, 1638549, 262150, 9, 1507477, 131078, 6, 1507478, 262150, 8, 1573014, 262150, 9, 1441942, 262150, 7, 1441943, 327686, 7, 1507479, 327686, 8, 1310870, 262150, 7, 1376406, 262150, 6, 1310871, 327686, 7, 1376407, 327686, 6, 1507471, 131078, 6, 1573007, 131078, 7, 1507472, 196614, 6, 1441935, 131078, 7, 1441936, 196614, 7, 1376401, 131078, 6, 1441937, 131078, 6, 1441941, 131078, 7, 1507473, 131078, 7, 1507474, 196614, 7, 1507475, 131078, 7, 1507476, 196614, 7, 1638540, 6, 8, 1245337, 6, 2, 1310873, 6, 3, 1245338, 65542, 2, 1310874, 65542, 3)
layer_2/name = "Crystals"
layer_2/tile_data = PackedInt32Array(720916, 5, 0, 851990, 65541, 0, 917522, 131077, 0, 196628, 196613, 0, 655363, 5, 1, 786436, 65541, 2, 655366, 196613, 0, 786439, 5, 1, 589835, 131077, 2, 327691, 131077, 2, 196609, 131077, 2, 262148, 65541, 0, 196614, 196613, 1, 393225, 196613, 1, 393218, 196613, 1, 458753, 65541, 2, 196619, 131077, 0, 524299, 131077, 1, 458758, 5, 2, 327687, 131077, 2, 589825, 65541, 1, 720897, 65541, 0)
layer_3/name = "Gatherables"
layer_3/name = "Mushrooms"
layer_3/tile_data = PackedInt32Array(983085, 393218, 3, 327729, 262146, 2, 393254, 196610, 4, 327707, 458754, 1, 589857, 131074, 2, 720943, 3, 0, 786479, 3, 1, 720944, 65539, 0, 786480, 65539, 1, 852001, 3, 0, 917537, 3, 1, 852002, 65539, 0, 917538, 65539, 1)
script = ExtResource("3_apfs6")
@ -4018,31 +4019,17 @@ offset_bottom = 1000.0
mouse_filter = 1
metadata/_edit_lock_ = true
[node name="MushroomGlowContainer" type="Node2D" parent="TileMap"]
[node name="CPUParticles2D" type="CPUParticles2D" parent="TileMap"]
visible = false
position = Vector2(413, 183)
amount = 4
lifetime = 15.0
explosiveness = 0.18
randomness = 0.1
texture = ExtResource("10_pyntn")
emission_shape = 1
emission_sphere_radius = 50.0
spread = 180.0
gravity = Vector2(0, 0)
initial_velocity_min = 1.0
initial_velocity_max = 2.0
scale_amount_min = 0.1
scale_amount_max = 0.8
color_ramp = SubResource("Gradient_2c8cw")
[node name="CrystalGlowComponent" parent="." node_paths=PackedStringArray("tile_map") instance=ExtResource("10_8n1hc")]
tile_map = NodePath("../TileMap")
[node name="MushroomGlowComponent" parent="." node_paths=PackedStringArray("tile_map") instance=ExtResource("13_uwl47")]
tile_map = NodePath("../TileMap")
[node name="WaterEffectComponent" parent="." node_paths=PackedStringArray("tile_map") instance=ExtResource("14_x3ue3")]
tile_map = NodePath("../TileMap")
[node name="Glowing" parent="." instance=ExtResource("8_gmlkg")]
position = Vector2(2415, 156)
position = Vector2(2167, 319)
[node name="CanvasModulate" type="CanvasModulate" parent="."]
color = Color(0.301961, 0.45098, 1, 1)