From f774f8e8a44d9fd2c3aefee393c6455a4346ee17 Mon Sep 17 00:00:00 2001 From: Lilith Schier Date: Fri, 19 Jun 2026 00:35:46 +0200 Subject: [PATCH] new player art --- addons/TileMapDual/atlas_watcher.gd | 74 ++++ addons/TileMapDual/atlas_watcher.gd.uid | 1 + addons/TileMapDual/cursor_dual.gd | 41 ++ addons/TileMapDual/cursor_dual.gd.uid | 1 + addons/TileMapDual/cursor_dual.svg | 49 +++ addons/TileMapDual/cursor_dual.svg.import | 44 ++ addons/TileMapDual/display.gd | 164 +++++++ addons/TileMapDual/display.gd.uid | 1 + addons/TileMapDual/display_layer.gd | 104 +++++ addons/TileMapDual/display_layer.gd.uid | 1 + addons/TileMapDual/ghost.gdshader | 6 + addons/TileMapDual/ghost.gdshader.uid | 1 + addons/TileMapDual/ghost_material.tres | 6 + addons/TileMapDual/plugin.cfg | 7 + addons/TileMapDual/plugin.gd | 78 ++++ addons/TileMapDual/plugin.gd.uid | 1 + addons/TileMapDual/set.gd | 78 ++++ addons/TileMapDual/set.gd.uid | 1 + addons/TileMapDual/terrain_dual.gd | 196 +++++++++ addons/TileMapDual/terrain_dual.gd.uid | 1 + addons/TileMapDual/terrain_layer.gd | 126 ++++++ addons/TileMapDual/terrain_layer.gd.uid | 1 + addons/TileMapDual/terrain_preset.gd | 375 ++++++++++++++++ addons/TileMapDual/terrain_preset.gd.uid | 1 + addons/TileMapDual/tile_cache.gd | 76 ++++ addons/TileMapDual/tile_cache.gd.uid | 1 + addons/TileMapDual/tile_map_dual.gd | 170 ++++++++ addons/TileMapDual/tile_map_dual.gd.uid | 1 + addons/TileMapDual/tile_map_dual.svg | 38 ++ addons/TileMapDual/tile_map_dual.svg.import | 44 ++ addons/TileMapDual/tile_map_dual_legacy.gd | 408 ++++++++++++++++++ .../TileMapDual/tile_map_dual_legacy.gd.uid | 1 + addons/TileMapDual/tile_set_watcher.gd | 175 ++++++++ addons/TileMapDual/tile_set_watcher.gd.uid | 1 + addons/TileMapDual/util.gd | 61 +++ addons/TileMapDual/util.gd.uid | 1 + project.godot | 8 +- src/combat/Hitbox.cs | 20 +- src/combat/hitbox.tscn | 12 + src/creatures/birb/birb.aseprite | Bin 1697 -> 129 bytes src/creatures/birb/birb.tscn | 63 ++- src/game.tscn | 236 ++++++---- src/level/background.aseprite | 3 + src/level/background.aseprite.import | 21 + src/level/neon_box.aseprite | 3 + src/level/neon_box.aseprite.import | 21 + src/level/neon_box_selector.aseprite | 3 + src/level/neon_box_selector.aseprite.import | 21 + src/level/tiles.aseprite | 3 + src/level/tiles.aseprite.import | 21 + src/level/tiles.gdshader | 19 + src/level/tiles.gdshader.uid | 1 + src/level/tiles_0.aseprite | Bin 651 -> 0 bytes src/level/tiles_0.aseprite.import | 21 - src/player/Player.cs | 65 ++- src/player/light.aseprite | 3 + src/player/light.aseprite.import | 21 + src/player/player.aseprite | Bin 15676 -> 129 bytes src/player/player.aseprite.import | 4 +- src/player/player.tscn | 210 ++++++--- src/player/player_old.aseprite | 3 + src/player/player_old.aseprite.import | 21 + src/player/player_tiny.aseprite | 3 + src/player/player_tiny.aseprite.import | 21 + src/player/slash_projectile.tscn | 67 +-- 65 files changed, 2953 insertions(+), 276 deletions(-) create mode 100644 addons/TileMapDual/atlas_watcher.gd create mode 100644 addons/TileMapDual/atlas_watcher.gd.uid create mode 100644 addons/TileMapDual/cursor_dual.gd create mode 100644 addons/TileMapDual/cursor_dual.gd.uid create mode 100644 addons/TileMapDual/cursor_dual.svg create mode 100644 addons/TileMapDual/cursor_dual.svg.import create mode 100644 addons/TileMapDual/display.gd create mode 100644 addons/TileMapDual/display.gd.uid create mode 100644 addons/TileMapDual/display_layer.gd create mode 100644 addons/TileMapDual/display_layer.gd.uid create mode 100644 addons/TileMapDual/ghost.gdshader create mode 100644 addons/TileMapDual/ghost.gdshader.uid create mode 100644 addons/TileMapDual/ghost_material.tres create mode 100644 addons/TileMapDual/plugin.cfg create mode 100644 addons/TileMapDual/plugin.gd create mode 100644 addons/TileMapDual/plugin.gd.uid create mode 100644 addons/TileMapDual/set.gd create mode 100644 addons/TileMapDual/set.gd.uid create mode 100644 addons/TileMapDual/terrain_dual.gd create mode 100644 addons/TileMapDual/terrain_dual.gd.uid create mode 100644 addons/TileMapDual/terrain_layer.gd create mode 100644 addons/TileMapDual/terrain_layer.gd.uid create mode 100644 addons/TileMapDual/terrain_preset.gd create mode 100644 addons/TileMapDual/terrain_preset.gd.uid create mode 100644 addons/TileMapDual/tile_cache.gd create mode 100644 addons/TileMapDual/tile_cache.gd.uid create mode 100644 addons/TileMapDual/tile_map_dual.gd create mode 100644 addons/TileMapDual/tile_map_dual.gd.uid create mode 100644 addons/TileMapDual/tile_map_dual.svg create mode 100644 addons/TileMapDual/tile_map_dual.svg.import create mode 100644 addons/TileMapDual/tile_map_dual_legacy.gd create mode 100644 addons/TileMapDual/tile_map_dual_legacy.gd.uid create mode 100644 addons/TileMapDual/tile_set_watcher.gd create mode 100644 addons/TileMapDual/tile_set_watcher.gd.uid create mode 100644 addons/TileMapDual/util.gd create mode 100644 addons/TileMapDual/util.gd.uid create mode 100644 src/combat/hitbox.tscn create mode 100644 src/level/background.aseprite create mode 100644 src/level/background.aseprite.import create mode 100644 src/level/neon_box.aseprite create mode 100644 src/level/neon_box.aseprite.import create mode 100644 src/level/neon_box_selector.aseprite create mode 100644 src/level/neon_box_selector.aseprite.import create mode 100644 src/level/tiles.aseprite create mode 100644 src/level/tiles.aseprite.import create mode 100644 src/level/tiles.gdshader create mode 100644 src/level/tiles.gdshader.uid delete mode 100644 src/level/tiles_0.aseprite delete mode 100644 src/level/tiles_0.aseprite.import create mode 100644 src/player/light.aseprite create mode 100644 src/player/light.aseprite.import create mode 100644 src/player/player_old.aseprite create mode 100644 src/player/player_old.aseprite.import create mode 100644 src/player/player_tiny.aseprite create mode 100644 src/player/player_tiny.aseprite.import diff --git a/addons/TileMapDual/atlas_watcher.gd b/addons/TileMapDual/atlas_watcher.gd new file mode 100644 index 0000000..2fc120e --- /dev/null +++ b/addons/TileMapDual/atlas_watcher.gd @@ -0,0 +1,74 @@ +class_name AtlasWatcher +##[br] Watches a TileSetAtlasSource for changes. +##[br] Causes its 'parent' TileSetWatcher to emit terrains_changed when the atlas changes. +##[br] Also emits parent.atlas_autotiled when it thinks the user auto-generated atlas tiles. + +## Prevents the number of seen atlases from extending to infinity. +const UNDO_LIMIT = 1024 + +## Stores all of the atlas instance id's that have been seen before, to prevent autogen on redo. +static var _registered_atlases: Array[int] = [] + +## The TileSetWatcher that created this AtlasWatcher. Used to send signals back. +var parent: TileSetWatcher +## The Source ID of `self.atlas`. +var sid: int +## The atlas to be watched for changes. +var atlas: TileSetAtlasSource + + +func _init(parent: TileSetWatcher, sid: int, atlas: TileSetAtlasSource) -> void: + self.parent = parent + self.sid = sid + self.atlas = atlas + atlas.changed.connect(_atlas_changed, ConnectFlags.CONNECT_DEFERRED) + var id: int = atlas.get_instance_id() + # should not autogen if atlas was created through redo, i.e. its instance id already existed + if _atlas_is_empty() and id not in _registered_atlases: + _registered_atlases.push_back(id) + if _registered_atlases.size() > UNDO_LIMIT: + _registered_atlases.pop_front() + atlas.changed.connect( + _detect_autogen, + ConnectFlags.CONNECT_DEFERRED | ConnectFlags.CONNECT_ONE_SHOT, + ) + + +func _atlas_is_empty() -> bool: + return atlas.get_tiles_count() == 0 + + +## Returns true if the texture has any opaque pixels in the specified tile coordinates. +func _is_opaque_tile(image: Image, tile: Vector2i, p_threshold: float = 0.1) -> bool: + # We cannot use atlas.get_tile_texture_region(tile) as it fails on unregistered tiles. + var region := Rect2i(tile * atlas.texture_region_size, atlas.texture_region_size) + var sprite: Image = image.get_region(region) + if sprite.is_invisible(): + return false + # We're still not sure if the tile is empty or not. + # Godot's auto-gen considers 0.1 opacity as "transparent" but not "invisible". + for y in range(region.position.y, region.end.y): + for x in range(region.position.x, region.end.x): + if image.get_pixel(x, y).a > p_threshold: + return true + return false + + +##[br] HACK: literally just tries to guess which tiles the terrain autogen system would make +##[br] Called once, and only once, at the end of the first frame that a texture is created. +func _detect_autogen() -> void: + var size := Vector2i(atlas.texture.get_size()) / atlas.texture_region_size + var image: Image = atlas.texture.get_image() + # NOTE: Literally useless + # var expected_tiles := [] + for y in size.y: + for x in size.x: + var tile := Vector2i(x, y) + if atlas.has_tile(tile) != _is_opaque_tile(image, tile): + return + parent.atlas_autotiled.emit(sid, atlas) + + +## Called every time the atlas changes. Simply flags that terrains have changed. +func _atlas_changed() -> void: + parent._flag_terrains_changed = true diff --git a/addons/TileMapDual/atlas_watcher.gd.uid b/addons/TileMapDual/atlas_watcher.gd.uid new file mode 100644 index 0000000..72dd5d9 --- /dev/null +++ b/addons/TileMapDual/atlas_watcher.gd.uid @@ -0,0 +1 @@ +uid://cfhiw77a85x8w diff --git a/addons/TileMapDual/cursor_dual.gd b/addons/TileMapDual/cursor_dual.gd new file mode 100644 index 0000000..e7dce79 --- /dev/null +++ b/addons/TileMapDual/cursor_dual.gd @@ -0,0 +1,41 @@ +@icon('cursor_dual.svg') +class_name CursorDual +extends Sprite2D + +# TODO: instead of setting the target tilemap manually, +# just add the CursorDual as a child of the target tilemap +@export var tilemap_dual: TileMapDual = null + +var cell: Vector2i +var tile_size: Vector2 +var sprite_size: Vector2 +var terrain: int = 1 + + +func _ready() -> void: + if tilemap_dual != null: + tile_size = tilemap_dual.tile_set.tile_size + sprite_size = self.texture.get_size() + scale = Vector2(tile_size.y, tile_size.y) / sprite_size + self.set_scale(scale) + + +func _process(_delta: float) -> void: + if tilemap_dual == null: + return + cell = tilemap_dual.local_to_map(tilemap_dual.get_local_mouse_position()) + global_position = tilemap_dual.to_global(tilemap_dual.map_to_local(cell)) + # Clicking the 1 key activates the first terrain + if Input.is_action_pressed("quick_action_1"): + terrain = 1 + # Clicking the 2 key activates the second terrain + if Input.is_action_pressed("quick_action_2"): + terrain = 2 + # Clicking the 0 key activates the background terrain + if Input.is_action_pressed("quick_action_0"): + terrain = 0 + + if Input.is_action_pressed("left_click"): + tilemap_dual.draw_cell(cell, terrain) + elif Input.is_action_pressed("right_click"): + tilemap_dual.draw_cell(cell, 0) diff --git a/addons/TileMapDual/cursor_dual.gd.uid b/addons/TileMapDual/cursor_dual.gd.uid new file mode 100644 index 0000000..5e04ecf --- /dev/null +++ b/addons/TileMapDual/cursor_dual.gd.uid @@ -0,0 +1 @@ +uid://c6m630v880okx diff --git a/addons/TileMapDual/cursor_dual.svg b/addons/TileMapDual/cursor_dual.svg new file mode 100644 index 0000000..c69dd53 --- /dev/null +++ b/addons/TileMapDual/cursor_dual.svg @@ -0,0 +1,49 @@ + + + + + + + + + diff --git a/addons/TileMapDual/cursor_dual.svg.import b/addons/TileMapDual/cursor_dual.svg.import new file mode 100644 index 0000000..d33ca0e --- /dev/null +++ b/addons/TileMapDual/cursor_dual.svg.import @@ -0,0 +1,44 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bth8306ui4dcx" +path="res://.godot/imported/cursor_dual.svg-5d3e91639de0bb1f1616a3d17dccb9e5.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/TileMapDual/cursor_dual.svg" +dest_files=["res://.godot/imported/cursor_dual.svg-5d3e91639de0bb1f1616a3d17dccb9e5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/TileMapDual/display.gd b/addons/TileMapDual/display.gd new file mode 100644 index 0000000..51f3aa1 --- /dev/null +++ b/addons/TileMapDual/display.gd @@ -0,0 +1,164 @@ +class_name Display +extends Node2D +##[br] A Node designed to hold and manage up to 2 DisplayLayer children. +##[br] See [DisplayLayer] for details. + +## Emitted when the tiles in the map have been edited. +signal world_tiles_changed(changed: Array) + +## Every meaningfully different TileSet.tile_shape * TileSet.tile_offset_axis combination. +enum GridShape { + SQUARE, + ISO, + HALF_OFF_HORI, + HALF_OFF_VERT, + HEX_HORI, + HEX_VERT, +} + +##[br] How to deal with every available GridShape. +##[br] See [DisplayLayer] for more information about these fields. +const GRIDS: Dictionary[GridShape, Array] = { + GridShape.SQUARE: [ + { + # [] + 'offset': Vector2(-0.5, -0.5), + }, + ], + GridShape.ISO: [ + { + # <> + 'offset': Vector2(0, -0.5), + }, + ], + GridShape.HALF_OFF_HORI: [ + { + # v + 'offset': Vector2(0.0, -0.5), + }, + { + # ^ + 'offset': Vector2(-0.5, -0.5), + }, + ], + GridShape.HALF_OFF_VERT: [ + { + # > + 'offset': Vector2(-0.5, 0.0), + }, + { + # < + 'offset': Vector2(-0.5, -0.5), + }, + ], + GridShape.HEX_HORI: [ + { + # v + 'offset': Vector2(0.0, -3.0 / 8.0), + }, + { + # ^ + 'offset': Vector2(-0.5, -3.0 / 8.0), + }, + ], + GridShape.HEX_VERT: [ + { + # > + 'offset': Vector2(-3.0 / 8.0, 0.0), + }, + { + # < + 'offset': Vector2(-3.0 / 8.0, -0.5), + }, + ], +} + +## The parent TileMapDual to base the terrains off of. +@export var world: TileMapDual + +## See [TerrainDual] +var terrain: TerrainDual +## The TileCache computed from the last time update() was called. +var cached_cells := TileCache.new() +## See [TileSetWatcher] +var _tileset_watcher: TileSetWatcher + + +# TODO: phase out GridShape and simply transpose everything when the offset axis is vertical +##[br] Returns what kind of grid a TileSet is. +##[br] Will default to SQUARE if Godot decides to add a new TileShape. +static func tileset_gridshape(tile_set: TileSet) -> GridShape: + var hori: bool = tile_set.tile_offset_axis == TileSet.TILE_OFFSET_AXIS_HORIZONTAL + match tile_set.tile_shape: + TileSet.TileShape.TILE_SHAPE_SQUARE: + return GridShape.SQUARE + TileSet.TileShape.TILE_SHAPE_ISOMETRIC: + return GridShape.ISO + TileSet.TileShape.TILE_SHAPE_HALF_OFFSET_SQUARE: + return GridShape.HALF_OFF_HORI if hori else GridShape.HALF_OFF_VERT + TileSet.TileShape.TILE_SHAPE_HEXAGON: + return GridShape.HEX_HORI if hori else GridShape.HEX_VERT + _: + return GridShape.SQUARE + + +## Creates a new Display that updates when the TileSet updates. +func _init(world: TileMapDual, tileset_watcher: TileSetWatcher) -> void: + #print('initializing Display...') + self.world = world + _tileset_watcher = tileset_watcher + terrain = TerrainDual.new(tileset_watcher) + terrain.changed.connect(_terrain_changed, 1) + world_tiles_changed.connect(_world_tiles_changed, 1) + # let parent materal through to the displaylayers + use_parent_material = true + # Enable Y sorting + y_sort_enabled = true + + +## Updates the display based on the cells changed in the world TileMapDual. +func update(updated: Array) -> void: + if _tileset_watcher.tile_set == null: + return + _update_properties() + if not updated.is_empty(): + cached_cells.update(world, updated) + world_tiles_changed.emit(updated) + + +## Activates when the TerrainDual changes. +func _terrain_changed() -> void: + cached_cells.update(world) + _delete_layers() + if _tileset_watcher.tile_set != null: + _create_layers() + + +func _world_tiles_changed(changed: Array) -> void: + #print('SIGNAL EMITTED: world_tiles_changed(%s)' % {'changed': changed}) + for child in get_children(true): + child.update_tiles(cached_cells, changed) + + +## Initializes and configures new DisplayLayers according to the grid shape. +func _create_layers() -> void: + #print('GRID SHAPE: %s' % _tileset_watcher.grid_shape) + var grid: Array = GRIDS[_tileset_watcher.grid_shape] + for i: int in grid.size(): + var layer_config: Dictionary = grid[i] + #print('layer_config: %s' % layer_config) + var layer := DisplayLayer.new(world, _tileset_watcher, layer_config, terrain.layers[i]) + add_child(layer) + layer.update_tiles_all(cached_cells) + + +## Deletes all of the DisplayLayers. +func _delete_layers() -> void: + for child in get_children(true): + child.queue_free() + + +## Activates when the properties of the parent TileMapDual have been edited. +func _update_properties() -> void: + for child in get_children(true): + child.update_properties(world) diff --git a/addons/TileMapDual/display.gd.uid b/addons/TileMapDual/display.gd.uid new file mode 100644 index 0000000..4aeea62 --- /dev/null +++ b/addons/TileMapDual/display.gd.uid @@ -0,0 +1 @@ +uid://cacp8xe0jaxln diff --git a/addons/TileMapDual/display_layer.gd b/addons/TileMapDual/display_layer.gd new file mode 100644 index 0000000..d801601 --- /dev/null +++ b/addons/TileMapDual/display_layer.gd @@ -0,0 +1,104 @@ +class_name DisplayLayer +extends TileMapLayer +##[br] A single TileMapLayer whose purpose is to display tiles to maintain the Dual Grid illusion. +##[br] Its contents are automatically computed and updated based on: +##[br] - the contents of the parent TileMapDual +##[br] - the rules set in its assigned TerrainLayer + +##[br] How much to offset this DisplayLayer relative to the main TileMapDual grid. +##[br] This is independent of tile size. +var offset: Vector2 +## See [TileSetWatcher] +var _tileset_watcher: TileSetWatcher +## See [TerrainDual] +var _terrain: TerrainLayer + + +func _init( + world: TileMapDual, + tileset_watcher: TileSetWatcher, + fields: Dictionary, + layer: TerrainLayer, +) -> void: + #print('initializing Layer...') + update_properties(world) + offset = fields.offset + _tileset_watcher = tileset_watcher + _terrain = layer + tile_set = tileset_watcher.tile_set + tileset_watcher.tileset_resized.connect(reposition, 1) + reposition() + + +## Adjusts the position of this DisplayLayer based on the tile set's tile_size +func reposition() -> void: + position = offset * Vector2(_tileset_watcher.tile_size) + + +## Copies properties from parent TileMapDual to child display tilemap +func update_properties(parent: TileMapDual) -> void: + # Both tilemaps must be the same, so we copy all relevant properties + # Tilemap + # already covered by parent._tileset_watcher + # Rendering + self.y_sort_origin = parent.y_sort_origin + self.x_draw_order_reversed = parent.x_draw_order_reversed + self.rendering_quadrant_size = parent.rendering_quadrant_size + # Physics + self.collision_enabled = parent.collision_enabled + self.use_kinematic_bodies = parent.use_kinematic_bodies + self.collision_visibility_mode = parent.collision_visibility_mode + # Navigation + self.navigation_enabled = parent.navigation_enabled + self.navigation_visibility_mode = parent.navigation_visibility_mode + # Canvas item properties + self.show_behind_parent = parent.show_behind_parent + self.top_level = parent.top_level + self.light_mask = parent.light_mask + self.visibility_layer = parent.visibility_layer + self.y_sort_enabled = parent.y_sort_enabled + self.modulate = parent.modulate + self.self_modulate = parent.self_modulate + # NOTE: parent material takes priority over the current shaders, + # causing the world tiles to show up + self.use_parent_material = parent.use_parent_material + + # Save any manually introduced Material change: + self.material = parent.display_material + + +## Updates all display tiles to reflect the current changes. +func update_tiles_all(cache: TileCache) -> void: + update_tiles(cache, cache.cells.keys()) + + +## Update all display tiles affected by the world cells +func update_tiles(cache: TileCache, updated_world_cells: Array) -> void: + #push_warning('updating tiles') + var already_updated := Set.new() + for path: Array in _terrain.display_to_world_neighborhood: + path = path.map(Util.reverse_neighbor) + for world_cell: Vector2i in updated_world_cells: + var display_cell: Vector2i = follow_path(world_cell, path) + if already_updated.insert(display_cell): + update_tile(cache, display_cell) + + +## Updates a specific world cell. +func update_tile(cache: TileCache, cell: Vector2i) -> void: + var get_cell_at_path: Callable = func( + path, + ): + return cache.get_terrain_at(follow_path(cell, path)) + var terrain_neighbors: Array = _terrain.display_to_world_neighborhood.map(get_cell_at_path) + var mapping: Dictionary = _terrain.apply_rule(terrain_neighbors, cell) + var sid: int = mapping.sid + var tile: Vector2i = mapping.tile + set_cell(cell, sid, tile) + + +## Finds the neighbor of a given cell by following a path of CellNeighbors +func follow_path(cell: Vector2i, path: Array) -> Vector2i: + for neighbor: TileSet.CellNeighbor in path: + cell = get_neighbor_cell(cell, neighbor) + return cell diff --git a/addons/TileMapDual/display_layer.gd.uid b/addons/TileMapDual/display_layer.gd.uid new file mode 100644 index 0000000..8a994ac --- /dev/null +++ b/addons/TileMapDual/display_layer.gd.uid @@ -0,0 +1 @@ +uid://bon5inags0mqy diff --git a/addons/TileMapDual/ghost.gdshader b/addons/TileMapDual/ghost.gdshader new file mode 100644 index 0000000..103a708 --- /dev/null +++ b/addons/TileMapDual/ghost.gdshader @@ -0,0 +1,6 @@ +// A shader that sets all pixels to 0 alpha, making the object invisible. + +shader_type canvas_item; +void fragment() { + COLOR = vec4(0); +} \ No newline at end of file diff --git a/addons/TileMapDual/ghost.gdshader.uid b/addons/TileMapDual/ghost.gdshader.uid new file mode 100644 index 0000000..de92f1a --- /dev/null +++ b/addons/TileMapDual/ghost.gdshader.uid @@ -0,0 +1 @@ +uid://44652e0wv1ve diff --git a/addons/TileMapDual/ghost_material.tres b/addons/TileMapDual/ghost_material.tres new file mode 100644 index 0000000..5efd897 --- /dev/null +++ b/addons/TileMapDual/ghost_material.tres @@ -0,0 +1,6 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://cmbcfxlkxxnwq"] + +[ext_resource type="Shader" uid="uid://44652e0wv1ve" path="res://addons/TileMapDual/ghost.gdshader" id="1_gvngp"] + +[resource] +shader = ExtResource("1_gvngp") diff --git a/addons/TileMapDual/plugin.cfg b/addons/TileMapDual/plugin.cfg new file mode 100644 index 0000000..9b5babd --- /dev/null +++ b/addons/TileMapDual/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="TileMapDual" +description="An automatic, real-time dual-grid tileset system for Godot!" +author="@GilaPixel" +version="v5.0.2" +script="plugin.gd" diff --git a/addons/TileMapDual/plugin.gd b/addons/TileMapDual/plugin.gd new file mode 100644 index 0000000..ed874d9 --- /dev/null +++ b/addons/TileMapDual/plugin.gd @@ -0,0 +1,78 @@ +@tool +class_name TileMapDualEditorPlugin +extends EditorPlugin + + +# TODO: create a message queue that groups warnings, errors, and messages into categories +# so that we don't get 300 lines of the same warnings pushed to console every time we undo/redo +func _enter_tree() -> void: + # register custom nodes + const TILE_MAP_DUAL_ICON: Texture2D = preload("tile_map_dual.svg") + add_custom_type( + "TileMapDual", + "TileMapLayer", + preload("tile_map_dual.gd"), + TILE_MAP_DUAL_ICON, + ) + add_custom_type( + "TileMapDualLegacy", + "TileMapLayer", + preload("tile_map_dual_legacy.gd"), + TILE_MAP_DUAL_ICON, + ) + add_custom_type( + "CursorDual", + "Sprite2D", + preload("cursor_dual.gd"), + preload("cursor_dual.svg"), + ) + # load editor-only functions + TileMapDual.autotile = autotile + TileMapDual.popup = popup + # finish + # print("plugin TileMapDual loaded") + + +func _exit_tree() -> void: + # disable editor-only functions + TileMapDual.popup = TileMapDual._editor_only.bind('popup').unbind(2) + TileMapDual.autotile = TileMapDual._editor_only.bind('autotile').unbind(3) + # remove custom nodes + remove_custom_type("TileMapDualLegacy") + remove_custom_type("CursorDual") + remove_custom_type("TileMapDual") + # finish + # print("plugin TileMapDual unloaded") + + +# HACK: functions that reference EditorPlugin, directly or indirectly, +# cannot be in the publicly exported scripts +# or else they simply won't work when exported +## Shows a popup with a title bar, a message, +## and an "Ok" button in the middle of the screen. +func popup(title: String, message: String) -> void: + var popup := AcceptDialog.new() + get_editor_interface().get_base_control().add_child(popup) + popup.name = 'TileMapDualPopup' + popup.title = title + popup.dialog_text = message + popup.popup_centered() + await popup.confirmed + popup.queue_free() + + +## Automatically generate terrains when the atlas is initialized. +func autotile(_source_id: int, atlas: TileSetAtlasSource, tile_set: TileSet): + print_stack() + var urm: EditorUndoRedoManager = get_undo_redo() + urm.create_action( + "Create tiles in non-transparent texture regions", + UndoRedo.MergeMode.MERGE_ALL, + self, + true, + ) + # NOTE: commit_action() is called immediately after. + # NOTE: Atlas is guaranteed to have only been auto-generated + # with no extra peering bit information. + TerrainPreset.write_default_preset(urm, tile_set, atlas) + urm.commit_action() diff --git a/addons/TileMapDual/plugin.gd.uid b/addons/TileMapDual/plugin.gd.uid new file mode 100644 index 0000000..7f676f0 --- /dev/null +++ b/addons/TileMapDual/plugin.gd.uid @@ -0,0 +1 @@ +uid://xq472thciwj0 diff --git a/addons/TileMapDual/set.gd b/addons/TileMapDual/set.gd new file mode 100644 index 0000000..45171c1 --- /dev/null +++ b/addons/TileMapDual/set.gd @@ -0,0 +1,78 @@ +class_name Set +extends Resource +##[br] Real sets don't exist yet. +##[br] https://github.com/godotengine/godot/pull/94399 + +## A dummy value to put in a slot. +const DUMMY = null + +## The internal Dictionary that holds this Set's items as keys. +var data: Dictionary = { } + + +func _init(initial_data: Variant = []) -> void: + union_in_place(initial_data) + + +## Returns true if the item exists in this Set. +func has(item: Variant) -> bool: + return item in data + + +## Returns true if the item was not previously in the Set. +func insert(item: Variant) -> bool: + var out := not has(item) + data[item] = DUMMY + return out + + +## Returns true if the item was previously in the Set. +func remove(item: Variant) -> bool: + return data.erase(item) + + +## Deletes all items in this Set. +func clear() -> void: + data = { } + + +## Merges an Array's items or Dict's keys into the Set. +func union_in_place(other: Variant): + for item in other: + insert(item) + + +## Returns a new Set with the items of both self and other. +func union(other: Set) -> Set: + var out = self.duplicate() + out.union_in_place(other.data) + return out + + +## Removes an Array's items or Dict's keys from the Set. +func diff_in_place(other: Variant): + for item in other: + remove(item) + + +## Returns a new Set with all items in self that are not present in other. +func diff(other: Set) -> Set: + var out = self.duplicate() + out.diff_in_place(other.data) + return out + + +## Inserts elements that are in other but not in self, and removes elements found in both. +func xor_in_place(other: Variant): + for item in other: + if has(item): + remove(item) + else: + insert(item) + + +## Returns a new Set where each item is either in self or other, but not both. +func xor(other: Set) -> Set: + var out = self.duplicate() + out.xor_in_place(other.data) + return out diff --git a/addons/TileMapDual/set.gd.uid b/addons/TileMapDual/set.gd.uid new file mode 100644 index 0000000..904dc7c --- /dev/null +++ b/addons/TileMapDual/set.gd.uid @@ -0,0 +1 @@ +uid://ds8j47h4vi6gx diff --git a/addons/TileMapDual/terrain_dual.gd b/addons/TileMapDual/terrain_dual.gd new file mode 100644 index 0000000..4f79c15 --- /dev/null +++ b/addons/TileMapDual/terrain_dual.gd @@ -0,0 +1,196 @@ +class_name TerrainDual +extends Resource +##[br] Reads a TileSet and dictates which tiles in the display map +##[br] match up with its neighbors in the world map + +## A specific neighborhood that the Display tiles will look at. +enum Neighborhood { + SQUARE, + ISOMETRIC, + TRIANGLE_HORIZONTAL, + TRIANGLE_VERTICAL, +} + +## Maps a GridShape to a Neighborhood. +const GRID_NEIGHBORHOODS: Dictionary[Display.GridShape, Neighborhood] = { + Display.GridShape.SQUARE: Neighborhood.SQUARE, + Display.GridShape.ISO: Neighborhood.ISOMETRIC, + Display.GridShape.HALF_OFF_HORI: Neighborhood.TRIANGLE_HORIZONTAL, + Display.GridShape.HALF_OFF_VERT: Neighborhood.TRIANGLE_VERTICAL, + Display.GridShape.HEX_HORI: Neighborhood.TRIANGLE_HORIZONTAL, + Display.GridShape.HEX_VERT: Neighborhood.TRIANGLE_VERTICAL, +} +## Maps a Neighborhood to a set of atlas terrain neighbors. +const NEIGHBORHOOD_LAYERS: Dictionary[Neighborhood, Array] = { + Neighborhood.SQUARE: [ + { + # [] + 'terrain_neighborhood': [ + TileSet.CELL_NEIGHBOR_TOP_LEFT_CORNER, + TileSet.CELL_NEIGHBOR_TOP_RIGHT_CORNER, + TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, + TileSet.CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, + ], + 'display_to_world_neighborhood': [ + [TileSet.CELL_NEIGHBOR_TOP_LEFT_CORNER], + [TileSet.CELL_NEIGHBOR_TOP_SIDE], + [TileSet.CELL_NEIGHBOR_LEFT_SIDE], + [], + ], + }, + ], + Neighborhood.ISOMETRIC: [ + { + # <> + 'terrain_neighborhood': [ + TileSet.CELL_NEIGHBOR_TOP_CORNER, + TileSet.CELL_NEIGHBOR_RIGHT_CORNER, + TileSet.CELL_NEIGHBOR_LEFT_CORNER, + TileSet.CELL_NEIGHBOR_BOTTOM_CORNER, + ], + 'display_to_world_neighborhood': [ + [TileSet.CELL_NEIGHBOR_TOP_CORNER], + [TileSet.CELL_NEIGHBOR_TOP_RIGHT_SIDE], + [TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE], + [], + ], + }, + ], + Neighborhood.TRIANGLE_HORIZONTAL: [ + { + # v + 'terrain_neighborhood': [ + TileSet.CELL_NEIGHBOR_BOTTOM_CORNER, + TileSet.CELL_NEIGHBOR_TOP_LEFT_CORNER, + TileSet.CELL_NEIGHBOR_TOP_RIGHT_CORNER, + ], + 'display_to_world_neighborhood': [ + [], + [TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE], + [TileSet.CELL_NEIGHBOR_TOP_RIGHT_SIDE], + ], + }, + { + # ^ + 'terrain_neighborhood': [ + TileSet.CELL_NEIGHBOR_TOP_CORNER, + TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, + TileSet.CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, + ], + 'display_to_world_neighborhood': [ + [TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE], + [TileSet.CELL_NEIGHBOR_LEFT_SIDE], + [], + ], + }, + ], + # TODO: this is just TRIANGLE_HORIZONTAL but transposed. this can be refactored. + Neighborhood.TRIANGLE_VERTICAL: [ + { + # > + 'terrain_neighborhood': [ + TileSet.CELL_NEIGHBOR_RIGHT_CORNER, + TileSet.CELL_NEIGHBOR_TOP_LEFT_CORNER, + TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, + ], + 'display_to_world_neighborhood': [ + [], + [TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE], + [TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_SIDE], + ], + }, + { + # < + 'terrain_neighborhood': [ + TileSet.CELL_NEIGHBOR_LEFT_CORNER, + TileSet.CELL_NEIGHBOR_TOP_RIGHT_CORNER, + TileSet.CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, + ], + 'display_to_world_neighborhood': [ + [TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE], + [TileSet.CELL_NEIGHBOR_TOP_SIDE], + [], + ], + }, + ], +} + +## The Neighborhood type of this TerrainDual. +var neighborhood: Neighborhood +## Maps a terrain type to its sprite as registered in the TerrainDual. +var terrains: Dictionary[int, Dictionary] +## The TerrainLayers for this TerrainDual. +var layers: Array +var _tileset_watcher: TileSetWatcher + + +# Functions are ordered top to bottom in the transformation pipeline +## Maps a TileSet to a Neighborhood. +static func tileset_neighborhood(tile_set: TileSet) -> Neighborhood: + return GRID_NEIGHBORHOODS[Display.tileset_gridshape(tile_set)] + + +func _init(tileset_watcher: TileSetWatcher) -> void: + _tileset_watcher = tileset_watcher + _tileset_watcher.terrains_changed.connect(_changed, 1) + _changed() + + +## Create rules for every atlas in a TileSet. +func read_tileset(tile_set: TileSet) -> void: + terrains = { } + layers = [] + neighborhood = Neighborhood.SQUARE # default + if tile_set == null: + return + neighborhood = tileset_neighborhood(tile_set) + layers = NEIGHBORHOOD_LAYERS[neighborhood].map(TerrainLayer.new) + for i in tile_set.get_source_count(): + var sid: int = tile_set.get_source_id(i) + var src: TileSetSource = tile_set.get_source(sid) + if src is not TileSetAtlasSource: + continue + read_atlas(src, sid) + + +## Create rules for every tile in an atlas. +func read_atlas(atlas: TileSetAtlasSource, sid: int) -> void: + var size = atlas.get_atlas_grid_size() + for y in size.y: + for x in size.x: + var tile := Vector2i(x, y) + # Take only existing tiles + if not atlas.has_tile(tile): + continue + read_tile(atlas, sid, tile) + + +## Add a new rule for a specific tile in an atlas. +func read_tile(atlas: TileSetAtlasSource, sid: int, tile: Vector2i) -> void: + var data: TileData = atlas.get_tile_data(tile, 0) + var mapping: Dictionary[String, Variant] = { 'sid': sid, 'tile': tile } + var terrain_set: int = data.terrain_set + if terrain_set != 0: + push_warning( + "The tile at %s has a terrain set of %d. \ + Only terrain set 0 is supported." % [mapping, terrain_set], + ) + return + var terrain: int = data.terrain + if terrain != -1: + if not terrain in terrains: + terrains[terrain] = mapping + + var filters = NEIGHBORHOOD_LAYERS[neighborhood] + for i in layers.size(): + var layer: TerrainLayer = layers[i] + layer._register_tile(data, mapping) + + +##[br] Emitted when any of the terrains change. +##[br] NOTE: Prefer connecting to TerrainDual.changed +## instead of TileSetWatcher.terrains_changed. +func _changed() -> void: + #print('SIGNAL EMITTED: changed(%s)' % {}) + read_tileset(_tileset_watcher.tile_set) + emit_changed() diff --git a/addons/TileMapDual/terrain_dual.gd.uid b/addons/TileMapDual/terrain_dual.gd.uid new file mode 100644 index 0000000..1657e80 --- /dev/null +++ b/addons/TileMapDual/terrain_dual.gd.uid @@ -0,0 +1 @@ +uid://qa8xnqphuk68 diff --git a/addons/TileMapDual/terrain_layer.gd b/addons/TileMapDual/terrain_layer.gd new file mode 100644 index 0000000..381fb0e --- /dev/null +++ b/addons/TileMapDual/terrain_layer.gd @@ -0,0 +1,126 @@ +class_name TerrainLayer +extends Resource +## A set of _rules usable by a single DisplayLayer. + +const TILE_EMPTY: Dictionary[String, Variant] = { 'sid': -1, 'tile': Vector2i(-1, -1) } + +## A list of which CellNeighbors to care about during terrain checking. +var terrain_neighborhood: Array = [] +##[br] When a cell in a DisplayLayer needs to be recomputed, +## the TerrainLayer needs to know which tiles surround it. +##[br] This Array stores the paths from the affected cell to the neighboring world cells. +var display_to_world_neighborhood: Array +## Generator for random placement of tiles +var rand: RandomNumberGenerator +## Random seed used to generate tiles deterministically +var global_seed: int = 707 +# TODO: change Mapping to support https://github.com/pablogila/TileMapDual/issues/13 +##[br] The rules that dictate which tile matches a given set of neighbors. +##[br] Used by register_rule() and apply_rule() +##[codeblock] +## _rules: TrieNode = # The actual type of _rules +## +## TrieNode: Dictionary{ +## key: int = # The terrain value of this neighbor +## value: TrieNode | TrieLeaf = # The next branch of this trie +## } +## +## TrieLeaf: Dictionary{ +## 'mapping': Mapping = # The tile that this should now become +## } +## +## Mapping: Dictionary{ +## 'sid': int = # The source_id of this tile +## 'tile': Vector2i = # The Atlas Coordinates of this tile +## } +##[/codeblock] +##[br] Internally a decision "trie": +##[br] - each node branch represents a terrain neighbor +##[br] - each leaf node represents the terrain that a tile +## with the given terrain neighborhood should become +##[br] +##[br] How the trie is searched: +##[br] - check the next neighbor in terrain_neighbors +##[br] - check if there is a branch corresponding to the terrain of that neighbor +##[br] - if there is a branch, search again under that branch +##[br] - else pretend that neighbor is empty and try again +##[br] - if there really isn't a branch, no rules exist so just return empty +##[br] - once at a leaf node, its mapping should tell us what terrain to become +##[br] +##[br] See apply_rule() for more details. +var _rules: Dictionary = { } + + +## Coerces all empty tiles to have a terrain of 0. +static func normalize_terrain(terrain): + return terrain if terrain != -1 else 0 + + +func _init(fields: Dictionary) -> void: + self.terrain_neighborhood = fields.terrain_neighborhood + self.display_to_world_neighborhood = fields.display_to_world_neighborhood + self.rand = RandomNumberGenerator.new() + + +## Returns the tile that should be used based on the surrounding terrain neighbors +func apply_rule(terrain_neighbors: Array, cell: Vector2i) -> Dictionary: + var is_empty: bool = terrain_neighbors.all(func(terrain): return terrain == -1) + if is_empty: + return TILE_EMPTY + var normalized_neighbors = terrain_neighbors.map(normalize_terrain) + + var node := _rules + for terrain in normalized_neighbors: + if terrain not in node: + terrain = 0 + if terrain not in node: + return TILE_EMPTY + node = node[terrain] + if 'mappings' not in node: + return TILE_EMPTY + + #random tile selection + var weights: Array = [] + var index: int = 0 + for mapping in node.mappings: + weights.append(mapping.prob) + rand.seed = hash(str(cell) + str(global_seed)) + index = rand.rand_weighted(weights) + return node.mappings[index] + + +## Register a new rule for a specific tile in an atlas. +func _register_tile(data: TileData, mapping: Dictionary) -> void: + if data.terrain_set != 0: + # This was already handled as an error in the parent TerrainDual + return + var terrain_neighbors := terrain_neighborhood.map(data.get_terrain_peering_bit) + # Skip tiles with no peering bits in this filter + # They might be used for a different layer, + # or may have no peering bits at all, which will just be ignored by all layers + if terrain_neighbors.any(func(neighbor): return neighbor == -1): + if terrain_neighbors.any(func(neighbor): return neighbor != -1): + push_warning( + "Invalid Tile Neighborhood at %s.\n" % [mapping] + + "Expected neighborhood: %s" % [terrain_neighborhood.map(Util.neighbor_name)], + ) + return + mapping["prob"] = data.probability + _register_rule(terrain_neighbors, mapping) + + +## Register a new rule for a set of surrounding terrain neighbors +func _register_rule(terrain_neighbors: Array, mapping: Dictionary) -> void: + var node: Dictionary = _rules + for terrain in terrain_neighbors: + if terrain not in node: + node[terrain] = { } + node = node[terrain] + if not 'mappings' in node: + node.mappings = [] + node.mappings.append(mapping) + + +## Utility function for easier printing +func _neighbors_to_dict(terrain_neighbors: Array) -> Dictionary: + return Util.arrays_to_dict(terrain_neighborhood.map(Util.neighbor_name), terrain_neighbors) diff --git a/addons/TileMapDual/terrain_layer.gd.uid b/addons/TileMapDual/terrain_layer.gd.uid new file mode 100644 index 0000000..a3e4752 --- /dev/null +++ b/addons/TileMapDual/terrain_layer.gd.uid @@ -0,0 +1 @@ +uid://ks3fxwahkm6j diff --git a/addons/TileMapDual/terrain_preset.gd b/addons/TileMapDual/terrain_preset.gd new file mode 100644 index 0000000..aac864c --- /dev/null +++ b/addons/TileMapDual/terrain_preset.gd @@ -0,0 +1,375 @@ +class_name TerrainPreset +## Functions for automatically generating terrains for an atlas. + +## Determines the available Terrain presets for a certain Atlas. +enum Topology { + SQUARE, + TRIANGLE, +} + +## Maps a Neighborhood to a Topology. +const NEIGHBORHOOD_TOPOLOGIES: Dictionary[TerrainDual.Neighborhood, Topology] = { + TerrainDual.Neighborhood.SQUARE: Topology.SQUARE, + TerrainDual.Neighborhood.ISOMETRIC: Topology.SQUARE, + TerrainDual.Neighborhood.TRIANGLE_HORIZONTAL: Topology.TRIANGLE, + TerrainDual.Neighborhood.TRIANGLE_VERTICAL: Topology.TRIANGLE, +} +## Contains all of the builtin Terrain presets for each topology +const PRESETS: Dictionary[Topology, Dictionary] = { + Topology.SQUARE: { + 'Standard': { + 'size': Vector2i(4, 4), + 'bg': Vector2i(0, 3), + 'fg': Vector2i(2, 1), + 'layers': [ + [ + # [] + Vector2i(0, 3), + Vector2i(3, 3), + Vector2i(0, 2), + Vector2i(1, 2), + Vector2i(0, 0), + Vector2i(3, 2), + Vector2i(2, 3), + Vector2i(3, 1), + Vector2i(1, 3), + Vector2i(0, 1), + Vector2i(1, 0), + Vector2i(2, 2), + Vector2i(3, 0), + Vector2i(2, 0), + Vector2i(1, 1), + Vector2i(2, 1), + ], + ], + }, + }, + Topology.TRIANGLE: { + 'Standard': { + 'size': Vector2i(4, 4), + 'bg': Vector2i(0, 0), + 'fg': Vector2i(0, 2), + 'layers': [ + [ + # v + Vector2i(0, 1), + Vector2i(2, 3), + Vector2i(3, 1), + Vector2i(1, 3), + Vector2i(1, 1), + Vector2i(3, 3), + Vector2i(2, 1), + Vector2i(0, 3), + ], + [ + # ^ + Vector2i(0, 0), + Vector2i(2, 2), + Vector2i(3, 0), + Vector2i(1, 2), + Vector2i(1, 0), + Vector2i(3, 2), + Vector2i(2, 0), + Vector2i(0, 2), + ], + ], + }, + # Old template. + # a bit inconvenient to use for Brick (Half-Off Square) tilesets. + 'Winged': { + 'size': Vector2i(4, 4), + 'bg': Vector2i(0, 0), + 'fg': Vector2i(0, 2), + 'layers': [ + [ + # v + Vector2i(0, 1), + Vector2i(2, 1), + Vector2i(3, 1), + Vector2i(1, 3), + Vector2i(1, 1), + Vector2i(3, 3), + Vector2i(2, 3), + Vector2i(0, 3), + ], + [ + # ^ + Vector2i(0, 0), + Vector2i(2, 0), + Vector2i(3, 0), + Vector2i(1, 2), + Vector2i(1, 0), + Vector2i(3, 2), + Vector2i(2, 2), + Vector2i(0, 2), + ], + ], + }, + # Old template. + # The gaps between triangles made them harder to align. + 'Alternating': { + 'size': Vector2i(4, 4), + 'bg': Vector2i(0, 0), + 'fg': Vector2i(0, 2), + 'layers': [ + [ + # v + Vector2i(0, 0), + Vector2i(2, 0), + Vector2i(3, 1), + Vector2i(1, 3), + Vector2i(1, 1), + Vector2i(3, 3), + Vector2i(2, 2), + Vector2i(0, 2), + ], + [ + # ^ + Vector2i(0, 1), + Vector2i(2, 1), + Vector2i(3, 0), + Vector2i(1, 2), + Vector2i(1, 0), + Vector2i(3, 2), + Vector2i(2, 3), + Vector2i(0, 3), + ], + ], + }, + }, +} + + +## Maps a Neighborhood to a preset of the specified name. +static func neighborhood_preset( + neighborhood: TerrainDual.Neighborhood, + preset_name: String = 'Standard', +) -> Dictionary: + var topology: Topology = NEIGHBORHOOD_TOPOLOGIES[neighborhood] + # TODO: test when the preset doesn't exist + var available_presets: Dictionary = PRESETS[topology] + if preset_name not in available_presets: + return { 'size': Vector2i.ONE, 'layers': [] } + var out: Dictionary = available_presets[preset_name].duplicate(true) + # All Horizontal neighborhoods can be transposed to Vertical + if neighborhood == TerrainDual.Neighborhood.TRIANGLE_VERTICAL: + out.size = Util.transpose_vec(out.size) + out.fg = Util.transpose_vec(out.fg) + out.bg = Util.transpose_vec(out.bg) + for seq in out.layers: + for i in seq.size(): + seq[i] = Util.transpose_vec(seq[i]) + return out + + +##[br] Would you like to automatically create tiles in the atlas? +##[br] +##[br] NOTE: Assumes urm.create_action() was called. +##Does not actually do anything until urm.commit_action() is called. +##[br] NOTE: Assumes atlas only has auto-generated tiles. +##Does not save peering bit information or anything else for undo/redo. +static func write_default_preset( + urm: EditorUndoRedoManager, + tile_set: TileSet, + atlas: TileSetAtlasSource, +) -> void: + #print('writing default') + var neighborhood := TerrainDual.tileset_neighborhood(tile_set) + var terrain: int = new_terrain( + urm, + tile_set, + atlas.texture.resource_path.get_file(), + ) + write_preset( + urm, + atlas, + neighborhood, + terrain, + ) + + +##[br] Creates terrain set 0 (the primary terrain set) and terrain 0 (the 'any' terrain) +##[br] +##[br] NOTE: Assumes urm.create_action() was called. +##Does not actually do anything until urm.commit_action() is called. +static func init_terrains(urm: EditorUndoRedoManager, tile_set: TileSet) -> void: + urm.add_do_method(TerrainPreset, "_do_init_terrains", tile_set) + urm.add_undo_method(TerrainPreset, "_undo_init_terrains", tile_set) + + +static func _do_init_terrains(tile_set: TileSet) -> void: + tile_set.add_terrain_set() + tile_set.set_terrain_set_mode(0, TileSet.TERRAIN_MODE_MATCH_CORNERS) + tile_set.add_terrain(0) + tile_set.set_terrain_name(0, 0, "") + tile_set.set_terrain_color(0, 0, Color.VIOLET) + + +static func _undo_init_terrains(tile_set: TileSet) -> void: + tile_set.remove_terrain_set(0) + + +##[br] Adds a new terrain type to terrain set 0 for the sprites to use. +##[br] +##[br] NOTE: Assumes urm.create_action() was called. +## Does not actually do anything until urm.commit_action() is called. +static func new_terrain(urm: EditorUndoRedoManager, tile_set: TileSet, terrain_name: String) -> int: + var terrain: int + if tile_set.get_terrain_sets_count() == 0: + init_terrains(urm, tile_set) + terrain = 1 + else: + terrain = tile_set.get_terrains_count(0) + urm.add_do_method(TerrainPreset, "_do_new_terrain", tile_set, terrain_name) + urm.add_undo_method(TerrainPreset, "_undo_new_terrain", tile_set) + return terrain + + +static func _do_new_terrain(tile_set: TileSet, terrain_name: String) -> void: + tile_set.add_terrain(0) + var terrain: int = tile_set.get_terrains_count(0) - 1 + tile_set.set_terrain_name(0, terrain, "FG -%s" % terrain_name) + + +static func _undo_new_terrain(tile_set: TileSet) -> void: + var terrain: int = tile_set.get_terrains_count(0) - 1 + tile_set.remove_terrain(0, terrain) + + +##[br] Takes a preset and writes it onto the given atlas, replacing the previous configuration. +##[br] ARGUMENTS: +##[br] - atlas: the atlas source to apply the preset to. +##[br] - filters: the neighborhood filter +##[br] +##[br] NOTE: Assumes urm.create_action() was called. +## Does not actually do anything until urm.commit_action() is called. +##[br] NOTE: Assumes atlas only has auto-generated tiles. +## Does not save peering bit information or anything else for undo/redo. +static func write_preset( + urm: EditorUndoRedoManager, + atlas: TileSetAtlasSource, + neighborhood: TerrainDual.Neighborhood, + terrain_foreground: int, + terrain_background: int = 0, + preset: Dictionary = neighborhood_preset(neighborhood), +) -> void: + clear_and_divide_atlas(urm, atlas, preset.size) + urm.add_do_method( + TerrainPreset, + '_do_write_preset', + atlas, + neighborhood, + terrain_foreground, + terrain_background, + preset, + ) + + +static func _do_write_preset( + atlas: TileSetAtlasSource, + neighborhood: TerrainDual.Neighborhood, + terrain_foreground: int, + terrain_background: int, + preset: Dictionary, +) -> void: + var layers: Array = TerrainDual.NEIGHBORHOOD_LAYERS[neighborhood] + # Set peering bits + var sequences: Array = preset.layers + for j in layers.size(): + var terrain_neighborhood = layers[j].terrain_neighborhood + var sequence: Array = sequences[j] + for i in sequence.size(): + var tile: Vector2i = sequence[i] + atlas.create_tile(tile) + var data: TileData = atlas.get_tile_data(tile, 0) + data.terrain_set = 0 + for neighbor in terrain_neighborhood: + data.set_terrain_peering_bit( + neighbor, + [terrain_background, terrain_foreground][i & 1], + ) + i >>= 1 + # Set terrains + atlas.get_tile_data(preset.bg, 0).terrain = terrain_background + atlas.get_tile_data(preset.fg, 0).terrain = terrain_foreground + + +##[br] Unregisters all the tiles in an atlas and changes the size of the individual sprites. +##[br] +##[br] NOTE: Assumes urm.create_action() was called. +## Does not actually do anything until urm.commit_action() is called. +##[br] NOTE: Assumes atlas only has auto-generated tiles. +## Does not save peering bit information or anything else for undo/redo. +static func clear_and_resize_atlas( + urm: EditorUndoRedoManager, + atlas: TileSetAtlasSource, + size: Vector2, +) -> void: + var atlas_data: Dictionary[String, Variant] = _save_atlas_data(atlas) + urm.add_do_method(TerrainPreset, '_do_clear_and_resize_atlas', atlas, size) + urm.add_undo_method(TerrainPreset, '_undo_clear_and_resize_atlas', atlas, atlas_data) + + +static func _do_clear_and_resize_atlas(atlas: TileSetAtlasSource, size: Vector2) -> void: + # Clear all tiles + atlas.texture_region_size = atlas.texture.get_size() + Vector2.ONE + atlas.clear_tiles_outside_texture() + # Resize the tiles + atlas.texture_region_size = size + + +static func _undo_clear_and_resize_atlas( + atlas: TileSetAtlasSource, + atlas_data: Dictionary[String, Variant], +) -> void: + _load_atlas_data(atlas, atlas_data) + + +## NOTE: Assumes atlas only has auto-generated tiles. +## Does not save peering bit information or anything else. +static func _save_atlas_data( + atlas: TileSetAtlasSource, +) -> Dictionary[String, Variant]: + var size_img: Vector2 = atlas.texture.get_size() + var size_sprite: Vector2i = atlas.texture_region_size + var size_dims := Vector2i(size_img) / size_sprite + var tiles: Array[Array] = [] + for y in size_dims.y: + var row: Array[bool] = [] + for x in size_dims.x: + var tile := Vector2i(x, y) + var exists: bool = atlas.has_tile(tile) + row.push_back(exists) + tiles.push_back(row) + return { + 'size_sprite': size_sprite, + 'size_dims': size_dims, + 'tiles': tiles, + } + + +static func _load_atlas_data( + atlas: TileSetAtlasSource, + atlas_data: Dictionary[String, Variant], +) -> void: + _do_clear_and_resize_atlas(atlas, atlas_data.size_sprite) + for y in atlas_data.size_dims.y: + for x in atlas_data.size_dims.x: + if atlas_data.tiles[y][x]: + var tile := Vector2i(x, y) + atlas.create_tile(tile) + + +##[br] Unregisters all the tiles in an atlas and changes the size of the +## individual sprites to accomodate a divisions.x by divisions.y grid of sprites. +##[br] +##[br] NOTE: Assumes urm.create_action() was called. +## Does not actually do anything until urm.commit_action() is called. +##[br] NOTE: Assumes atlas only has auto-generated tiles. +## Does not save peering bit information or anything else for undo/redo. +static func clear_and_divide_atlas( + urm: EditorUndoRedoManager, + atlas: TileSetAtlasSource, + divisions: Vector2i, +) -> void: + clear_and_resize_atlas(urm, atlas, atlas.texture.get_size() / Vector2(divisions)) diff --git a/addons/TileMapDual/terrain_preset.gd.uid b/addons/TileMapDual/terrain_preset.gd.uid new file mode 100644 index 0000000..de8ff19 --- /dev/null +++ b/addons/TileMapDual/terrain_preset.gd.uid @@ -0,0 +1 @@ +uid://cdsxbtu57wews diff --git a/addons/TileMapDual/tile_cache.gd b/addons/TileMapDual/tile_cache.gd new file mode 100644 index 0000000..8b0028b --- /dev/null +++ b/addons/TileMapDual/tile_cache.gd @@ -0,0 +1,76 @@ +class_name TileCache +extends Resource +## Caches the sprite location and terrains of each tile in the TileMapDual world grid. + +##[br] Maps a cell coordinate to the stored tile data. +##[codeblock] +## Dictionary{ +## key: Vector2i = # The coordinates of this tile in the world grid. +## value: Dictionary{ +## 'sid': int = # The Source ID of this tile. +## 'tile': Vector2i = # The coordinates of this tile in its Atlas. +## 'terrain': int = # The terrain assigned to this tile. +## } = # The data stored at this tile. +## } +##[/codeblock] +var cells: Dictionary[Vector2i, Dictionary] = { } + + +func _init() -> void: + pass + + +##[br] Updates specific cells of the TileCache based on the current layer data at those points. +##[br] Makes corrections in case the user accidentally places invalid tiles. +func update(world: TileMapLayer, edited: Array[Vector2i] = cells.keys()) -> void: + var tile_set: TileSet = world.tile_set + if tile_set == null: + push_error('Attempted to update TileCache while tile set was null') + return + for cell: Vector2i in edited: + # Invalid cells will be treated as empty and ignored + var sid: int = world.get_cell_source_id(cell) + if sid == -1: + cells.erase(cell) + continue + if not tile_set.has_source(sid): + continue + var src = tile_set.get_source(sid) + var tile: Vector2i = world.get_cell_atlas_coords(cell) + if not src.has_tile(tile): + continue + var data: TileData = world.get_cell_tile_data(cell) + if data == null: + continue + # Accidental cells should be reset to their previous value + # They will be treated as unchanged + if data.terrain == -1 or data.terrain_set != 0: + if cell not in cells: + world.erase_cell(cell) + continue + var cached: Dictionary = cells[cell] + sid = cached.sid + tile = cached.tile + world.set_cell(cell, sid, tile) + data = world.get_cell_tile_data(cell) + cells[cell] = { 'sid': sid, 'tile': tile, 'terrain': data.terrain } + + +## Returns the symmetric difference (xor) of two tile caches. +func xor(other: TileCache) -> Array[Vector2i]: + var out: Array[Vector2i] = [] + for key in cells: + if key not in other.cells or cells[key].terrain != other.cells[key].terrain: + out.push_back(key) + for key in other.cells: + if key not in cells: + out.push_back(key) + return out + + +##[br] Returns the terrain value of the tile at the given cell coordinates. +##[br] Empty cells have a terrain of -1. +func get_terrain_at(cell: Vector2i) -> int: + if cell not in cells: + return -1 + return cells[cell].terrain diff --git a/addons/TileMapDual/tile_cache.gd.uid b/addons/TileMapDual/tile_cache.gd.uid new file mode 100644 index 0000000..d488b17 --- /dev/null +++ b/addons/TileMapDual/tile_cache.gd.uid @@ -0,0 +1 @@ +uid://dpuc70ypq7wf8 diff --git a/addons/TileMapDual/tile_map_dual.gd b/addons/TileMapDual/tile_map_dual.gd new file mode 100644 index 0000000..26ad0b9 --- /dev/null +++ b/addons/TileMapDual/tile_map_dual.gd @@ -0,0 +1,170 @@ +@tool +@icon('tile_map_dual.svg') +class_name TileMapDual +extends TileMapLayer + +static var autotile: Callable = _editor_only.bind('autotile').unbind(3) +static var popup: Callable = _editor_only.bind('popup').unbind(2) + +## HACK: How long to wait before processing another "frame". +## Mainly matters when [godot_4_3_compatibility] is active. +@export_range(0.0, 0.1) var refresh_time: float = 0.02 +## When toggled on, double-checks ALL cells in the grid every change. +## Only use this when running Godot 4.3 and below, +## where TileMapLayer could not detect changes properly. +@export var godot_4_3_compatibility: bool = _godot_is_below_4_4() + +## Material for the display tilemap. +@export_custom(PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial, CanvasItemMaterial") +var display_material: Material: + get: + return display_material + set(new_material): # Custom setter so that it gets copied + display_material = new_material + changed.emit() +## An invisible material used to hide the world grid so only the display layers show up. +## Currently implemented as a shader that sets all pixels to 0 alpha. +var _ghost_material: Material = preload("res://addons/TileMapDual/ghost_material.tres") +var _tileset_watcher: TileSetWatcher +var _display: Display +## Keeps track of use_parent_material to see when it turns on or off. +var _cached_use_parent_material = null +var _timer: float = 0.0 + + +# === External functions that don't exist once exported === +# HACK: this uses some sort of "Dynamic Linking" technique +# because these features don't exist right now +# - conditional compilation +# - static signals +static func _editor_only(name: String): + push_error('Attempt to call Editor-Only function "' + name + '"') + + +func _ready() -> void: + _tileset_watcher = TileSetWatcher.new(tile_set) + _display = Display.new(self, _tileset_watcher) + add_child(_display) + _make_self_invisible(true) + if Engine.is_editor_hint(): + _tileset_watcher.atlas_autotiled.connect(_atlas_autotiled) + set_process(true) + else: # Run in-game using signals for better performance + changed.connect(_changed, 1) + set_process(false) + # Update full tileset on first instance + await get_tree().process_frame + _changed() + + +func _process(delta: float) -> void: # Only used inside the editor + if refresh_time < 0.0: + return + if _timer > 0: + _timer -= delta + return + _timer = refresh_time + _changed.call_deferred() + + +##[br] Public method to add and remove tiles. +##[br] +##[br] - 'cell' is a vector with the cell position. +##[br] - 'terrain' is which terrain type to draw. +##[br] - terrain -1 completely removes the tile, +##[br] - and by default, terrain 0 is the empty tile. +func draw_cell(cell: Vector2i, terrain: int = 1) -> void: + var terrains: Dictionary[int, Dictionary] = _display.terrain.terrains + if terrain not in terrains: + erase_cell(cell) + changed.emit() + return + var tile_to_use: Dictionary = terrains[terrain] + var sid: int = tile_to_use.sid + var tile: Vector2i = tile_to_use.tile + set_cell(cell, sid, tile) + changed.emit() + + +## Public method to get the terrain at a specific coordinate. +func get_cell(cell: Vector2i) -> int: + return get_cell_tile_data(cell).terrain + + +## Automatically generate terrains when the atlas is initialized. +func _atlas_autotiled(source_id: int, atlas: TileSetAtlasSource): + autotile.call(source_id, atlas, tile_set) + + +##[br] Makes the main world grid invisible. +##[br] The main tiles don't need to be seen. Only the DisplayLayers should be visible. +##[br] Called every frame, and functions a lot like TileSetWatcher. +func _make_self_invisible(startup: bool = false) -> void: + # If user has set a material in the original slot, inform the user + if material != _ghost_material: + if not startup and Engine.is_editor_hint(): + popup.call( + "Warning! Direct material edit detected.", + "Don't manually edit the real material in the editor! \ + Instead edit the custom 'Display Material' property.\n" + + "(Resetting the material to an invisible shader material... \ + this is to keep the 'World Layer' invisible)\n" + + "* This warning is only given when the material is set in the Godot editor.\n" + + "* In-game scripts may set the material directly. \ + It will be copied over to display_material automatically.", + ) + else: + # copy over the material if it was edited by script + display_material = material + material = _ghost_material # Force TileMapDual's material to become invisible + + # check if use_parent_material is set + if ( + Engine.is_editor_hint() + and use_parent_material != _cached_use_parent_material + and _cached_use_parent_material == false # cache may be null + ): + popup.call( + "Warning: Using Parent Material.", + "The parent material will override any other materials \ + used by the TileMapDual,\n" + + "including the 'ghost shader' that the world tiles \ + use to hide themselves.\n" + + "This will cause the world tiles to show themselves in-game.\n" + + "\n" + + "* Recommendation: Turn this setting off. Don't use parent material.\n" + + "* Workaround: Set your world tiles to custom sprites \ + that are entirely transparent.\n" + + "(see 'res://addons/TileMapDual/docs/custom_drawing_sprites.mp4' \ + for a non-transparent example)", + ) + _cached_use_parent_material = use_parent_material + + +## Detects if godot is below v4.4. +## Only used to detect whether the _update_cells() function is usable. +func _godot_is_below_4_4(): + var version: Dictionary = Engine.get_version_info() + return (version.major < 4) or (version.major == 4 and version.minor < 4) + + +## Called by signals when the tileset changes, +## or by _process inside the editor. +func _changed() -> void: + _tileset_watcher.update(tile_set) + + var updated_cells: Array[Vector2i] = [] + # HACK: double check all tiles every refresh + if godot_4_3_compatibility and tile_set != null: + var current_cells := TileCache.new() + current_cells.update(self, get_used_cells()) + updated_cells = current_cells.xor(_display.cached_cells) + + _display.update(updated_cells) + _make_self_invisible() + + +## Called when the user draws on the map or presses undo/redo. +func _update_cells(coords: Array[Vector2i], _forced_cleanup: bool) -> void: + if is_instance_valid(_display): + _display.update(coords) diff --git a/addons/TileMapDual/tile_map_dual.gd.uid b/addons/TileMapDual/tile_map_dual.gd.uid new file mode 100644 index 0000000..34a6b7f --- /dev/null +++ b/addons/TileMapDual/tile_map_dual.gd.uid @@ -0,0 +1 @@ +uid://cjk8nronimk5r diff --git a/addons/TileMapDual/tile_map_dual.svg b/addons/TileMapDual/tile_map_dual.svg new file mode 100644 index 0000000..0c387e4 --- /dev/null +++ b/addons/TileMapDual/tile_map_dual.svg @@ -0,0 +1,38 @@ + + + + + + diff --git a/addons/TileMapDual/tile_map_dual.svg.import b/addons/TileMapDual/tile_map_dual.svg.import new file mode 100644 index 0000000..12ea7a1 --- /dev/null +++ b/addons/TileMapDual/tile_map_dual.svg.import @@ -0,0 +1,44 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bqu55yxko3ofm" +path="res://.godot/imported/tile_map_dual.svg-53ffd5e7e4d2fa588a55e62f35fec36c.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/TileMapDual/tile_map_dual.svg" +dest_files=["res://.godot/imported/tile_map_dual.svg-53ffd5e7e4d2fa588a55e62f35fec36c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/TileMapDual/tile_map_dual_legacy.gd b/addons/TileMapDual/tile_map_dual_legacy.gd new file mode 100644 index 0000000..26fc22a --- /dev/null +++ b/addons/TileMapDual/tile_map_dual_legacy.gd @@ -0,0 +1,408 @@ +@tool +@icon('tile_map_dual.svg') +class_name TileMapDualLegacy +extends TileMapLayer +## Material for the display tilemap. +## @deprecated: Use [TileMapDual] instead. + +## We will use a bit-wise logic, so that a summation over all sketched +## neighbours provides a unique key, assigned to the corresponding +## tile from the Atlas through the NEIGHBOURS_TO_ATLAS dictionary. +enum Location { + TOP_LEFT = 1, + LOW_LEFT = 2, + TOP_RIGHT = 4, + LOW_RIGHT = 8, +} +enum Direction { + TOP, + LEFT, + BOTTOM, + RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + TOP_LEFT, + TOP_RIGHT, +} + +## Overlapping tiles from the World grid +## that a tile from the Dual grid has. +const _NEIGHBORS: Dictionary[Direction, TileSet.CellNeighbor] = { + Direction.TOP: TileSet.CellNeighbor.CELL_NEIGHBOR_TOP_SIDE, + Direction.LEFT: TileSet.CellNeighbor.CELL_NEIGHBOR_LEFT_SIDE, + Direction.RIGHT: TileSet.CellNeighbor.CELL_NEIGHBOR_RIGHT_SIDE, + Direction.BOTTOM: TileSet.CellNeighbor.CELL_NEIGHBOR_BOTTOM_SIDE, + Direction.TOP_LEFT: TileSet.CellNeighbor.CELL_NEIGHBOR_TOP_LEFT_CORNER, + Direction.TOP_RIGHT: TileSet.CellNeighbor.CELL_NEIGHBOR_TOP_RIGHT_CORNER, + Direction.BOTTOM_LEFT: TileSet.CellNeighbor.CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, + Direction.BOTTOM_RIGHT: TileSet.CellNeighbor.CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, +} +## Overlapping tiles from the World grid +## that a tile from the Dual grid has. +## To be used ONLY with isometric tilesets. +## CellNighbors are literal, even for Isometric +const _NEIGHBORS_ISOMETRIC: Dictionary[Direction, TileSet.CellNeighbor] = { + Direction.TOP: TileSet.CellNeighbor.CELL_NEIGHBOR_TOP_RIGHT_SIDE, + Direction.LEFT: TileSet.CellNeighbor.CELL_NEIGHBOR_TOP_LEFT_SIDE, + Direction.RIGHT: TileSet.CellNeighbor.CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE, + Direction.BOTTOM: TileSet.CellNeighbor.CELL_NEIGHBOR_BOTTOM_LEFT_SIDE, + Direction.TOP_LEFT: TileSet.CellNeighbor.CELL_NEIGHBOR_TOP_CORNER, + Direction.TOP_RIGHT: TileSet.CellNeighbor.CELL_NEIGHBOR_RIGHT_CORNER, + Direction.BOTTOM_LEFT: TileSet.CellNeighbor.CELL_NEIGHBOR_LEFT_CORNER, + Direction.BOTTOM_RIGHT: TileSet.CellNeighbor.CELL_NEIGHBOR_BOTTOM_CORNER, +} +## Dict to assign the Atlas coordinates from the +## summation over all sketched NEIGHBOURS. +## Follows the official 2x2 template. +## Works for isometric as well. +const _NEIGHBORS_TO_ATLAS: Dictionary[Direction, Vector2i] = { + 0: Vector2i(0, 3), + 1: Vector2i(3, 3), + 2: Vector2i(0, 0), + 3: Vector2i(3, 2), + 4: Vector2i(0, 2), + 5: Vector2i(1, 2), + 6: Vector2i(2, 3), + 7: Vector2i(3, 1), + 8: Vector2i(1, 3), + 9: Vector2i(0, 1), + 10: Vector2i(3, 0), + 11: Vector2i(2, 0), + 12: Vector2i(1, 0), + 13: Vector2i(2, 2), + 14: Vector2i(1, 1), + 15: Vector2i(2, 1), +} + +@export_custom(PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial") +var display_material: Material: + get: + return display_material + set(new_material): # Custom setter so that it gets copied + display_material = new_material + if display_tilemap: # Copy over, only if display tilemap is initiated + display_tilemap.material = display_material +var display_tilemap: TileMapLayer = null +## Coordinates for the fully-filled tile in the Atlas that +## will be used to sketch in the World grid. +## Only this tile will be considered for autotiling. +var full_tile: Vector2i = Vector2i(2, 1) +## The opposed of full_tile. Used to erase sketched tiles. +var empty_tile: Vector2i = Vector2i(0, 3) +var is_isometric: bool = false +var _filled_cells: Dictionary = { } +var _emptied_cells: Dictionary = { } +var _tile_shape: TileSet.TileShape = TileSet.TileShape.TILE_SHAPE_SQUARE +var _tile_size: Vector2i = Vector2i(16, 16) +var _should_check_cells: bool = false +## Prevents checking the cells more than once when the entire tileset +## is being updated, which is indicated by `_should_check_cells`. +var _checked_cells: Dictionary = { } +var _atlas_id: int + + +func _ready() -> void: + if Engine.is_editor_hint(): + set_process(true) + else: # Run in-game using signals for better performance + set_process(false) + self.changed.connect(_update_tileset, 1) + update_full_tileset() + # Fire copy upon any property change. More specific than _update_tileset + self.changed.connect(copy_properties, 1) + + +func _process(_delta): # Only used inside the editor + if not self.tile_set: + return + _update_tileset.call_deferred() + + +## Copies properties from parent TileMapDual to child display tilemap +func copy_properties() -> void: + # Both tilemaps must be the same, so we copy all relevant properties + # Tilemap + display_tilemap.tile_set = self.tile_set + # Rendering + display_tilemap.y_sort_origin = self.y_sort_origin + display_tilemap.x_draw_order_reversed = self.x_draw_order_reversed + display_tilemap.rendering_quadrant_size = self.rendering_quadrant_size + # Physics + display_tilemap.collision_enabled = self.collision_enabled + display_tilemap.use_kinematic_bodies = self.use_kinematic_bodies + display_tilemap.collision_visibility_mode = self.collision_visibility_mode + # Navigation + display_tilemap.navigation_enabled = self.navigation_enabled + display_tilemap.navigation_visibility_mode = self.navigation_visibility_mode + # Canvas item properties + display_tilemap.show_behind_parent = self.show_behind_parent + display_tilemap.top_level = self.top_level + display_tilemap.light_mask = self.light_mask + display_tilemap.visibility_layer = self.visibility_layer + display_tilemap.y_sort_enabled = self.y_sort_enabled + display_tilemap.modulate = self.modulate + + # If user has set a material in the original slot, copy it over for redundancy + # Helps both migration to new version, and prevents user mistakes + if self.material: + display_material = self.material + + # Set material for first time + display_tilemap.material = display_material + + # Save any manually introduced alpha modulation: + if self.self_modulate.a != 0.0: + display_tilemap.self_modulate = self.self_modulate + self.self_modulate.a = 0.0 # Override modulation to prevent render bugs with certain shaders + + self.material = null # Unset TileMapDual's material, to prevent render of it + + +## Update the size and shape of the tileset, displacing the display TileMapLayer accordingly. +func update_geometry() -> void: + is_isometric = self.tile_set.tile_shape == TileSet.TileShape.TILE_SHAPE_ISOMETRIC + var offset := Vector2(self.tile_set.tile_size) * -0.5 + if is_isometric: + offset.x = 0 + display_tilemap.position = offset + _tile_size = self.tile_set.tile_size + _tile_shape = self.tile_set.tile_shape + + +## Update the entire tileset, processing all the cells in the map. +func update_full_tileset() -> void: + if display_tilemap == null: + _set_display_tilemap() + elif display_tilemap.tile_set != self.tile_set: # TO-DO: merge with the above + _set_display_tilemap() + _should_check_cells = true + for cell in self.get_used_cells(): + if _is_world_tile_sketched(cell) == 1 or _is_world_tile_sketched(cell) == 0: + update_tile(cell) + _should_check_cells = false + _checked_cells = { } + # _checked_cells is only used when updating + # the whole tilemap to avoid repeating checks. + # This is skipped when updating tiles individually. + + +func array_to_dict(array: Array) -> Dictionary: + var dict: Dictionary = { } + for item in array: + dict[item] = true + return dict + + +## Return the values that are not shared between the arrays +func exclude_dicts(a: Dictionary, b: Dictionary) -> Dictionary: + var result = a.duplicate() + for item in b: + if result.has(item): + result.erase(item) + else: + result[item] = true + return result + + +## Takes a cell, and updates the overlapping tiles from the dual grid accordingly. +func update_tile(world_cell: Vector2i, recurse: bool = true) -> void: + _atlas_id = self.get_cell_source_id(world_cell) + + # to not fall in a recursive loop because of a large space of emptiness in the map + if (!recurse and _atlas_id == -1): + return + + var _actual_neighbors = _NEIGHBORS_ISOMETRIC if is_isometric else _NEIGHBORS + var _top_left = world_cell + var _low_left = display_tilemap.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.BOTTOM], + ) + var _top_right = display_tilemap.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.RIGHT], + ) + var _low_right = display_tilemap.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.BOTTOM_RIGHT], + ) + _update_displayed_tile(_top_left) + _update_displayed_tile(_low_left) + _update_displayed_tile(_top_right) + _update_displayed_tile(_low_right) + + # if atlas id is -1 the tile is empty, so to have a good rendering + # we need to update surroundings + if (_atlas_id == -1): + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.LEFT], + ), + false, + ) + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.TOP_LEFT], + ), + false, + ) + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.TOP], + ), + false, + ) + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.TOP_RIGHT], + ), + false, + ) + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.RIGHT], + ), + false, + ) + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.BOTTOM_RIGHT], + ), + false, + ) + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.BOTTOM], + ), + false, + ) + update_tile( + self.get_neighbor_cell( + world_cell, + _actual_neighbors[Direction.BOTTOM_LEFT], + ), + false, + ) + + +## Public method to add and remove tiles, as +## TileMapDual.draw(cell, tile, atlas_id). +## 'cell' is a vector with the cell position. +## 'tile' is 1 to draw the full tile (default), 0 to draw the empty tile, +## and -1 to completely remove the tile. +## 'atlas_id' is the atlas id of the tileset to modify, 0 by default. +## This method replaces the deprecated 'fill_tile' and 'erase_tile' methods. +func draw(cell: Vector2i, tile: int = 1, atlas_id: int = 0) -> void: + # Prevents a crash if this is called on the first frame + if display_tilemap == null: + update_full_tileset() + var tile_to_use: Vector2i + if tile == 1: + tile_to_use = full_tile + if tile == 0: + tile_to_use = empty_tile + if tile == -1: + tile_to_use = Vector2i(-1, -1) + atlas_id = -1 + set_cell(cell, atlas_id, tile_to_use) + update_tile(cell) + + +## Set the dual grid as a child of TileMapDual. +func _set_display_tilemap() -> void: + if not self.tile_set: + return + + # Add the display TileMapLayer, if it doesn't already exist + if not get_node_or_null("WorldTileMap"): + display_tilemap = TileMapLayer.new() + display_tilemap.name = "WorldTileMap" + add_child(display_tilemap) + + copy_properties() # Copy properties from TileMapDual to displayed tilemap + + update_geometry() + display_tilemap.clear() + + +## Update only the very specific tiles that have changed. +## Much more efficient than update_full_tileset. +## Called by signals when the tileset changes, +## or by _process inside the editor. +func _update_tileset() -> void: + if display_tilemap == null: + update_full_tileset() + return + if display_tilemap.tile_set != self.tile_set: # TO-DO: merge with the above + update_full_tileset() + return + if _tile_size != self.tile_set.tile_size or _tile_shape != self.tile_set.tile_shape: + update_geometry() + return + + var _new_emptied_cells: Dictionary = array_to_dict(get_used_cells_by_id(-1, empty_tile)) + var _new_filled_cells: Dictionary = array_to_dict(get_used_cells_by_id(-1, full_tile)) + var _changed_cells: Dictionary = exclude_dicts( + _emptied_cells, + _new_emptied_cells, + ).merged(exclude_dicts(_filled_cells, _new_filled_cells)) + + _emptied_cells = _new_emptied_cells + _filled_cells = _new_filled_cells + for cell in _changed_cells: + update_tile(cell) + + +func _update_displayed_tile(_display_cell: Vector2i) -> void: + # Avoid updating cells more than necessary + if _should_check_cells: + if _display_cell in _checked_cells: + return + _checked_cells[_display_cell] = true + + var _actual_neighbors = _NEIGHBORS_ISOMETRIC if is_isometric else _NEIGHBORS + var _top_left = display_tilemap.get_neighbor_cell( + _display_cell, + _actual_neighbors[Direction.TOP_LEFT], + ) + var _low_left = display_tilemap.get_neighbor_cell( + _display_cell, + _actual_neighbors[Direction.LEFT], + ) + var _top_right = display_tilemap.get_neighbor_cell( + _display_cell, + _actual_neighbors[Direction.TOP], + ) + var _low_right = _display_cell + + # We perform a bitwise summation over the sketched neighbours + var _tile_key: int = 0 + if _is_world_tile_sketched(_top_left) == 1: + _tile_key += Location.TOP_LEFT + if _is_world_tile_sketched(_low_left) == 1: + _tile_key += Location.LOW_LEFT + if _is_world_tile_sketched(_top_right) == 1: + _tile_key += Location.TOP_RIGHT + if _is_world_tile_sketched(_low_right) == 1: + _tile_key += Location.LOW_RIGHT + + var _coords_atlas: Vector2i = _NEIGHBORS_TO_ATLAS[_tile_key] + display_tilemap.set_cell(_display_cell, _atlas_id, _coords_atlas) + + +## Return -1 if the cell is empty, 0 if sketched with the empty tile, +## and 1 if it is sketched with the fully-filled tile. +func _is_world_tile_sketched(_world_cell: Vector2i): + var _atlas_coords = get_cell_atlas_coords(_world_cell) + if _atlas_coords == full_tile: + return 1 + if _atlas_coords == empty_tile: + return 0 + return -1 diff --git a/addons/TileMapDual/tile_map_dual_legacy.gd.uid b/addons/TileMapDual/tile_map_dual_legacy.gd.uid new file mode 100644 index 0000000..af1118d --- /dev/null +++ b/addons/TileMapDual/tile_map_dual_legacy.gd.uid @@ -0,0 +1 @@ +uid://dlyqj0u8ckhb0 diff --git a/addons/TileMapDual/tile_set_watcher.gd b/addons/TileMapDual/tile_set_watcher.gd new file mode 100644 index 0000000..7f84e9e --- /dev/null +++ b/addons/TileMapDual/tile_set_watcher.gd @@ -0,0 +1,175 @@ +class_name TileSetWatcher +extends Resource +## Provides information about a TileSet and sends signals when it changes. + +## Emitted when the parent TileMapDual's tile_set is cleared or replaced. +signal tileset_deleted +## Emitted when the parent TileMapDual's tile_set is created or replaced. +signal tileset_created +## Emitted when tile_set.tile_size is changed. +signal tileset_resized +## Emitted when the GridShape of the TileSet would be different. +signal tileset_reshaped +## Emitted when a new Atlas is added to this TileSet. +## Does not react to Scenes being added to the TileSet. +signal atlas_added(source_id: int, atlas: TileSetAtlasSource) +## Emitted when the watcher thinks that "Yes" was clicked for: +## 'Would you like to automatically create tiles in the atlas?' +signal atlas_autotiled(source_id: int, atlas: TileSetAtlasSource) +## Emitted when an atlas is added or removed, +## or when the terrains change in one of the Atlases. +## NOTE: Prefer connecting to TerrainDual.changed instead of TileSetWatcher.terrains_changed. +signal terrains_changed + +## Caches the previous tile_set to see when it changes. +var tile_set: TileSet +## Caches the previous tile_size to see when it changes. +var tile_size: Vector2i +## caches the previous result of display.tileset_grid_shape(tile_set) to see when it changes. +var grid_shape: Display.GridShape +var _flag_tileset_deleted: bool = false +var _flag_tileset_created: bool = false +var _flag_tileset_resized: bool = false +var _flag_tileset_reshaped: bool = false +var _flag_atlas_added: bool = false +var _flag_terrains_changed: bool = false +var _flag_tileset_changed: bool = false +# Cached variables from the previous frame +# These are used to compare what changed between frames +var _cached_source_count: int = 0 +var _cached_sids: Dictionary[int, AtlasWatcher] = { } + + +func _init(tile_set: TileSet) -> void: + # tileset_deleted.connect(func(): print('tileset_deleted'), 1) + # tileset_created.connect(func(): print('tileset_created'), 1) + # tileset_resized.connect(func(): print('tileset_resized'), 1) + # tileset_reshaped.connect(func(): print('tileset_reshaped'), 1) + atlas_added.connect(_atlas_added, 1) + update(tile_set) + + +## Checks if anything about the concerned TileMapDual's tile_set changed. +## Must be called by the TileMapDual every frame. +func update(tile_set: TileSet) -> void: + check_tile_set(tile_set) + check_flags() + + +## Emit update signals if the corresponding flags were set. +## Must only be run once per frame. +func check_flags() -> void: + if _flag_tileset_changed: + _flag_tileset_changed = false + _update_tileset() + if _flag_tileset_deleted: + _flag_tileset_deleted = false + _flag_tileset_reshaped = true + tileset_deleted.emit() + if _flag_tileset_created: + _flag_tileset_created = false + _flag_tileset_reshaped = true + tileset_created.emit() + if _flag_tileset_resized: + _flag_tileset_resized = false + tileset_resized.emit() + if _flag_tileset_reshaped: + _flag_tileset_reshaped = false + _flag_terrains_changed = true + tileset_reshaped.emit() + if _flag_atlas_added: + _flag_atlas_added = false + _flag_terrains_changed = true + if _flag_terrains_changed: + _flag_terrains_changed = false + terrains_changed.emit() + + +## Check if tile_set has been added, replaced, or deleted. +func check_tile_set(tile_set: TileSet) -> void: + if tile_set == self.tile_set: + return + if self.tile_set != null: + self.tile_set.changed.disconnect(_set_tileset_changed) + _cached_source_count = 0 + _cached_sids.clear() + _flag_tileset_deleted = true + self.tile_set = tile_set + if self.tile_set != null: + self.tile_set.changed.connect(_set_tileset_changed, 1) + self.tile_set.emit_changed() + _flag_tileset_created = true + emit_changed() + + +func _atlas_added(_source_id: int, _atlas: TileSetAtlasSource) -> void: + _flag_atlas_added = true + # print('SIGNAL EMITTED: atlas_added(%s)' % {'source_id': _source_id, 'atlas': _atlas}) + + +## Helper method to be called when the tile_set detects a change. +## Must be disconnected when the tile_set is changed. +func _set_tileset_changed() -> void: + _flag_tileset_changed = true + + +## Called when _flag_tileset_changed. +## Provides more detail about what changed. +func _update_tileset() -> void: + var tile_size = tile_set.tile_size + if self.tile_size != tile_size: + self.tile_size = tile_size + _flag_tileset_resized = true + var grid_shape = Display.tileset_gridshape(tile_set) + if self.grid_shape != grid_shape: + self.grid_shape = grid_shape + _flag_tileset_reshaped = true + _update_tileset_atlases() + + +# TODO: detect automatic tile creation +## Checks if new atlases have been added. +## Does not check which ones were deleted. +func _update_tileset_atlases() -> void: + # Update all tileset sources + var source_count: int = tile_set.get_source_count() + + # Only if an asset was added or removed + # FIXME?: may break on add+remove in 1 frame + if _cached_source_count == source_count: + return + _cached_source_count = source_count + + # Process the new atlases in the TileSet + var sids: Dictionary[int, AtlasWatcher] = { } + for i in source_count: + var sid: int = tile_set.get_source_id(i) + if sid in _cached_sids: + sids[sid] = _cached_sids[sid] + continue + var source: TileSetSource = tile_set.get_source(sid) + if source is not TileSetAtlasSource: + push_warning( + "Non-Atlas TileSet found at index %i, source id %i.\n" % [i, source] + + "Dual Grids only support Atlas TileSets.", + ) + sids[sid] = null + continue + var atlas: TileSetAtlasSource = source + # FIXME?: check if this needs to be disconnected + # SETUP: + # - add logging to check which Watcher's flag was changed + # - add a TileSet with an atlas to 2 TileMapDuals + # - remove the TileSet + # - modify the terrains on one of the atlases + # - check how many watchers were flagged: + # - if 2 watchers were flagged, this is bad. + # try to repeatedly add and remove the tileset. + # this could either cause the flag to happen multiple times, + # or it could stay at 2 watchers. + # - if 1 watcher was flagged, that is ok + sids[sid] = AtlasWatcher.new(self, sid, atlas) + atlas_added.emit(sid, atlas) + _flag_terrains_changed = true + # FIXME?: find which sid's were deleted + _cached_sids = sids diff --git a/addons/TileMapDual/tile_set_watcher.gd.uid b/addons/TileMapDual/tile_set_watcher.gd.uid new file mode 100644 index 0000000..34b0195 --- /dev/null +++ b/addons/TileMapDual/tile_set_watcher.gd.uid @@ -0,0 +1 @@ +uid://bjmo6oy8a4k2k diff --git a/addons/TileMapDual/util.gd b/addons/TileMapDual/util.gd new file mode 100644 index 0000000..4b468c1 --- /dev/null +++ b/addons/TileMapDual/util.gd @@ -0,0 +1,61 @@ +class_name Util +## Utility functions. + + +## Merges an Array of keys and an Array of values into a Dictionary. +static func arrays_to_dict(keys: Array, values: Array) -> Dictionary: + var out := { } + for i in keys.size(): + out[keys[i]] = values[i] + return out + + +## Swaps the X and Y axes of a Vector2i. +static func transpose_vec(v: Vector2i) -> Vector2i: + return Vector2i(v.y, v.x) + + +# TODO: transposed(TileSet.CellNeighbor) -> Tileset.CellNeighbor +## Reverses the direction of a CellNeighbor. +static func reverse_neighbor(neighbor: TileSet.CellNeighbor) -> TileSet.CellNeighbor: + return (neighbor + 8) % 16 + + +## Returns a shorthand name for a CellNeighbor. +static func neighbor_name(neighbor: TileSet.CellNeighbor) -> String: + const DIRECTIONS := ['E', 'SE', 'S', 'SW', 'W', 'NW', 'N', 'NE'] + return DIRECTIONS[neighbor >> 1] + + +## Returns a pretty-printable neighborhood. +static func neighborhood_str(neighborhood: Array) -> String: + var neighbors := array_of(-1, 16) + for i in neighborhood.size(): + neighbors[neighborhood[i]] = i + + var get := func(neighbor: TileSet.CellNeighbor) -> String: + var terrain = neighbors[neighbor] + return '-' if terrain == -1 else str(terrain) + + var nw = get.call(TileSet.CELL_NEIGHBOR_TOP_LEFT_CORNER) + var n = get.call(TileSet.CELL_NEIGHBOR_TOP_CORNER) + var ne = get.call(TileSet.CELL_NEIGHBOR_TOP_RIGHT_CORNER) + var w = get.call(TileSet.CELL_NEIGHBOR_LEFT_CORNER) + var e = get.call(TileSet.CELL_NEIGHBOR_RIGHT_CORNER) + var sw = get.call(TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_CORNER) + var s = get.call(TileSet.CELL_NEIGHBOR_BOTTOM_CORNER) + var se = get.call(TileSet.CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER) + + return ( + "%2s %2s %2s\n" % [nw, n, ne] + + "%2s C %2s\n" % [w, e] + + "%2s %2s %2s\n" % [sw, s, se] + ) + + +## Returns an Array of the given size, all filled with the given value. +static func array_of(value: Variant, size: int) -> Array[Variant]: + var out := [] + out.resize(size) + out.fill(value) + return out diff --git a/addons/TileMapDual/util.gd.uid b/addons/TileMapDual/util.gd.uid new file mode 100644 index 0000000..400f1ff --- /dev/null +++ b/addons/TileMapDual/util.gd.uid @@ -0,0 +1 @@ +uid://bfbksxcjuwdjt diff --git a/project.godot b/project.godot index e1187d5..9f1023d 100644 --- a/project.godot +++ b/project.godot @@ -21,12 +21,11 @@ import/import_plugin/default_automatic_importer="Static Texture" [display] -window/size/viewport_width=450 +window/size/viewport_width=640 window/size/viewport_height=360 -window/size/window_width_override=900 +window/size/window_width_override=1280 window/size/window_height_override=720 window/stretch/mode="viewport" -window/stretch/aspect="keep_height" window/vsync/vsync_mode=3 [dotnet] @@ -35,7 +34,7 @@ project/assembly_name="Dancer" [editor_plugins] -enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg") +enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg", "res://addons/TileMapDual/plugin.cfg") [input] @@ -100,4 +99,5 @@ textures/canvas_textures/default_texture_filter=0 rendering_device/driver.windows="d3d12" renderer/rendering_method="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility" +environment/defaults/default_clear_color=Color(0.063487835, 0.09127209, 0.12370577, 1) 2d/snap/snap_2d_transforms_to_pixel=true diff --git a/src/combat/Hitbox.cs b/src/combat/Hitbox.cs index ec4d750..1846ebc 100644 --- a/src/combat/Hitbox.cs +++ b/src/combat/Hitbox.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; namespace Dancer; -[Meta(typeof(IAutoNode))] +[Meta(typeof(IAutoNode)), Tool] public sealed partial class Hitbox : Area2D { public override void _Notification(int what) => this.Notify(what); @@ -12,7 +12,8 @@ public sealed partial class Hitbox : Area2D [Export(PropertyHint.None, "suffix:s")] private float LocalImmunity { get; set; } - private int LocalCountLimit { get; set; } = 1000; + [Export] + private int LocalCountLimit { get; set; } = 1; [Signal] public delegate void BodyHitEventHandler(Hitbox hitbox, Node2D body); @@ -22,6 +23,7 @@ public sealed partial class Hitbox : Area2D public void OnResolved() { + ProcessMode = ProcessModeEnum.Disabled; BodyEntered += OnEntered; HitboxOwner.OnHitboxAdded(this); } @@ -59,6 +61,20 @@ public sealed partial class Hitbox : Area2D entry.Immunity = Mathf.Max(0f, entry.Immunity); } + public void StartAttack() + { + if (Engine.IsEditorHint()) Visible = true; + ProcessMode = ProcessModeEnum.Inherit; + foreach (var immunityEntry in _immunityEntries.Values) + immunityEntry.HitCount = 0; + } + + public void StopAttack() + { + if (Engine.IsEditorHint()) Visible = false; + ProcessMode = ProcessModeEnum.Disabled; + } + private sealed class ImmunityEntry { public float Immunity { get; set; } diff --git a/src/combat/hitbox.tscn b/src/combat/hitbox.tscn new file mode 100644 index 0000000..6252316 --- /dev/null +++ b/src/combat/hitbox.tscn @@ -0,0 +1,12 @@ +[gd_scene format=3 uid="uid://cva3ecq7vp3a4"] + +[ext_resource type="Script" uid="uid://b4k42r866lkut" path="res://src/combat/Hitbox.cs" id="1_cask4"] + +[node name="Hitbox" type="Area2D" unique_id=1918418417] +collision_layer = 8 +collision_mask = 4 +script = ExtResource("1_cask4") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2048987579] +disabled = true +debug_color = Color(0.99430805, 0, 0.2314094, 0.41960785) diff --git a/src/creatures/birb/birb.aseprite b/src/creatures/birb/birb.aseprite index b4f99589bce8a5e1eb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s| zd&DMH2r_dtGjzmHxq6V{kiu639)_2bKh7DxG4~rS=3YZ%jsYbf%E8hkYf}u<|A~go zy^S{WdD`Z__y)>|H#BE8Z*+7LmI>ziaI^bOdCBg~)by6@PxT9I4SdY2C%!qdVSZ3` z;ZglvwFY0WY!RP*cYy(0B7ZGEo4`6hU#7>h+P@F{czruIWTQBX$HwpWA_2GKQtre? z_g$_3f01G3w?~_WC7ItI>+EEG@ojOtKF{LaoYU()KWdxRCv6s&Y&ay{qS+bkRQB!5 z`rr0jm-DXP`{bE&PO9PwxtKEL+wN;WNwPVVskDh3HW+M@=y2QCFI3H_az3OU0I;Jc Ac>n+a diff --git a/src/creatures/birb/birb.tscn b/src/creatures/birb/birb.tscn index fd8952c..86c90a0 100644 --- a/src/creatures/birb/birb.tscn +++ b/src/creatures/birb/birb.tscn @@ -5,11 +5,9 @@ [ext_resource type="Script" uid="uid://b4k42r866lkut" path="res://src/combat/Hitbox.cs" id="3_bu42x"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_8bh2b"] -size = Vector2(22, 4) +size = Vector2(34, 2) [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_feb5d"] -radius = 5.0 -height = 14.0 [sub_resource type="CircleShape2D" id="CircleShape2D_lyo8d"] radius = 60.0 @@ -50,18 +48,6 @@ tracks/1/keys = { "update": 1, "values": [0] } -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Body/StabHitbox/CollisionShape2D:disabled") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [true] -} [sub_resource type="Animation" id="Animation_ba6cv"] resource_name = "idle" @@ -122,8 +108,8 @@ tracks/1/keys = { [sub_resource type="Animation" id="Animation_3ly8m"] resource_name = "stab" -length = 0.9 -step = 0.1 +length = 0.8333333 +step = 0.016666668 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -143,10 +129,10 @@ tracks/1/path = NodePath("Body:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0, 0.1, 0.5), -"transitions": PackedFloat32Array(1, 1, 1), +"times": PackedFloat32Array(0, 0.1, 0.5, 0.55, 0.6333333), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), "update": 1, -"values": [0, 1, 2] +"values": [0, 1, 2, 3, 4] } tracks/2/type = "method" tracks/2/imported = false @@ -155,24 +141,29 @@ tracks/2/path = NodePath(".") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { -"times": PackedFloat32Array(0.9), +"times": PackedFloat32Array(0.8333333), "transitions": PackedFloat32Array(1), "values": [{ "args": [], "method": &"OnAttackFinished" }] } -tracks/3/type = "value" +tracks/3/type = "method" tracks/3/imported = false tracks/3/enabled = true -tracks/3/path = NodePath("Body/StabHitbox/CollisionShape2D:disabled") +tracks/3/path = NodePath("Body/StabHitbox") tracks/3/interp = 1 tracks/3/loop_wrap = true tracks/3/keys = { -"times": PackedFloat32Array(0, 0.5, 0.7), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 1, -"values": [true, false, true] +"times": PackedFloat32Array(0.5, 0.6333333), +"transitions": PackedFloat32Array(1, 1), +"values": [{ +"args": [], +"method": &"StartAttack" +}, { +"args": [], +"method": &"StopAttack" +}] } [sub_resource type="AnimationLibrary" id="AnimationLibrary_1i6dk"] @@ -186,10 +177,12 @@ _data = { [node name="Birb" type="CharacterBody2D" unique_id=428810294] collision_layer = 4 script = ExtResource("1_lyo8d") +AttackDistance = 45.0 metadata/_edit_group_ = true [node name="Body" type="AnimatedSprite2D" parent="." unique_id=581143480] unique_name_in_owner = true +position = Vector2(7, -20) sprite_frames = ExtResource("2_ba6cv") animation = &"idle" offset = Vector2(9, -4) @@ -201,16 +194,17 @@ collision_mask = 2 script = ExtResource("3_bu42x") [node name="CollisionShape2D" type="CollisionShape2D" parent="Body/StabHitbox" unique_id=1331922714] -position = Vector2(11, 2) +position = Vector2(19, 9) shape = SubResource("RectangleShape2D_8bh2b") -disabled = true -debug_color = Color(0.8758822, 0.3187781, 0.34832907, 0.41960785) +debug_color = Color(0.99607843, 0, 0.23137255, 0.41960785) [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1744954023] -position = Vector2(0, 1) +position = Vector2(0, -15) shape = SubResource("CapsuleShape2D_feb5d") [node name="Detection" type="Area2D" parent="." unique_id=151830843] +visible = false +position = Vector2(0, -22) collision_layer = 0 collision_mask = 2 monitorable = false @@ -220,12 +214,13 @@ shape = SubResource("CircleShape2D_lyo8d") debug_color = Color(0, 0.6, 0.69803923, 0.16862746) [node name="Chase" type="Area2D" parent="." unique_id=172000915] +visible = false +position = Vector2(0, -22) collision_layer = 0 collision_mask = 2 monitorable = false [node name="CollisionShape2D" type="CollisionShape2D" parent="Chase" unique_id=567870323] -position = Vector2(-1, 0) shape = SubResource("CircleShape2D_ba6cv") debug_color = Color(0, 0.6, 0.69803923, 0) @@ -235,9 +230,9 @@ anchors_preset = 5 anchor_left = 0.5 anchor_right = 0.5 offset_left = -10.0 -offset_top = -12.0 +offset_top = -35.0 offset_right = 10.0 -offset_bottom = -10.0 +offset_bottom = -33.0 grow_horizontal = 2 theme_override_styles/background = SubResource("StyleBoxFlat_lyo8d") theme_override_styles/fill = SubResource("StyleBoxFlat_ba6cv") diff --git a/src/game.tscn b/src/game.tscn index e386aeb..a4333d2 100644 --- a/src/game.tscn +++ b/src/game.tscn @@ -1,97 +1,145 @@ [gd_scene format=4 uid="uid://cujd7ltkrnxpt"] -[ext_resource type="Texture2D" uid="uid://dkxcdqm8dgdq7" path="res://src/level/tiles_0.aseprite" id="1_80nbo"] [ext_resource type="Script" uid="uid://cjnisd5qmc15u" path="res://src/Game.cs" id="1_kc8ui"] [ext_resource type="PackedScene" uid="uid://bosbrhc3oprau" path="res://src/creatures/birb/birb.tscn" id="2_fc0e3"] [ext_resource type="PackedScene" uid="uid://ce2k04khaub8n" path="res://src/player/player.tscn" id="2_feb5d"] +[ext_resource type="Material" uid="uid://cmbcfxlkxxnwq" path="res://addons/TileMapDual/ghost_material.tres" id="3_4bcji"] +[ext_resource type="Texture2D" uid="uid://d2m74vkdtcimf" path="res://src/level/tiles.aseprite" id="4_cdx1q"] +[ext_resource type="Script" uid="uid://cjk8nronimk5r" path="res://addons/TileMapDual/tile_map_dual.gd" id="4_uktfx"] +[ext_resource type="Texture2D" uid="uid://b0grslwquoxek" path="res://src/level/neon_box.aseprite" id="4_y2hwx"] [ext_resource type="Theme" uid="uid://bybov1cpwtf7p" path="res://src/base_theme.tres" id="5_bs6l1"] +[ext_resource type="Texture2D" uid="uid://cbjps58vfmyeb" path="res://src/level/background.aseprite" id="5_wqvko"] +[ext_resource type="Texture2D" uid="uid://dg5wulm2tav4t" path="res://src/level/neon_box_selector.aseprite" id="5_y2hwx"] [ext_resource type="Script" uid="uid://i5v0sfow12sr" path="res://src/player/PlayerHealthBar.cs" id="6_pk08u"] -[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_e2o6t"] -texture = ExtResource("1_80nbo") -0:0/0 = 0 -1:0/0 = 0 -1:0/0/terrain_set = 0 -1:0/0/terrain = 0 -1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -1:0/0/terrains_peering_bit/right_side = 0 -1:0/0/terrains_peering_bit/bottom_right_corner = 0 -1:0/0/terrains_peering_bit/bottom_side = 0 -1:1/0 = 0 -1:1/0/terrain_set = 0 -1:1/0/terrain = 0 -1:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -1:1/0/terrains_peering_bit/right_side = 0 -1:1/0/terrains_peering_bit/bottom_right_corner = 0 -1:1/0/terrains_peering_bit/bottom_side = 0 -1:1/0/terrains_peering_bit/top_side = 0 -1:1/0/terrains_peering_bit/top_right_corner = 0 +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_qiocs"] +texture = ExtResource("4_y2hwx") +0:3/0 = 0 +0:3/0/terrain_set = 0 +0:3/0/terrains_peering_bit/bottom_right_corner = 0 +0:3/0/terrains_peering_bit/bottom_left_corner = 0 +0:3/0/terrains_peering_bit/top_left_corner = 0 +0:3/0/terrains_peering_bit/top_right_corner = 0 +3:3/0 = 0 +3:3/0/terrain_set = 0 +3:3/0/terrains_peering_bit/bottom_right_corner = 0 +3:3/0/terrains_peering_bit/bottom_left_corner = 0 +3:3/0/terrains_peering_bit/top_left_corner = 1 +3:3/0/terrains_peering_bit/top_right_corner = 0 +0:2/0 = 0 +0:2/0/terrain_set = 0 +0:2/0/terrains_peering_bit/bottom_right_corner = 0 +0:2/0/terrains_peering_bit/bottom_left_corner = 0 +0:2/0/terrains_peering_bit/top_left_corner = 0 +0:2/0/terrains_peering_bit/top_right_corner = 1 1:2/0 = 0 1:2/0/terrain_set = 0 -1:2/0/terrain = 0 -1:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -1:2/0/terrains_peering_bit/right_side = 0 -1:2/0/terrains_peering_bit/top_side = 0 -1:2/0/terrains_peering_bit/top_right_corner = 0 -2:0/0 = 0 -2:0/0/terrain_set = 0 -2:0/0/terrain = 0 -2:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -2:0/0/terrains_peering_bit/right_side = 0 -2:0/0/terrains_peering_bit/bottom_right_corner = 0 -2:0/0/terrains_peering_bit/bottom_side = 0 -2:0/0/terrains_peering_bit/bottom_left_corner = 0 -2:0/0/terrains_peering_bit/left_side = 0 -2:1/0 = 0 -2:1/0/terrain_set = 0 -2:1/0/terrain = 0 -2:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -2:1/0/terrains_peering_bit/right_side = 0 -2:1/0/terrains_peering_bit/bottom_right_corner = 0 -2:1/0/terrains_peering_bit/bottom_side = 0 -2:1/0/terrains_peering_bit/bottom_left_corner = 0 -2:1/0/terrains_peering_bit/left_side = 0 -2:1/0/terrains_peering_bit/top_left_corner = 0 -2:1/0/terrains_peering_bit/top_side = 0 -2:1/0/terrains_peering_bit/top_right_corner = 0 -2:2/0 = 0 -2:2/0/terrain_set = 0 -2:2/0/terrain = 0 -2:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -2:2/0/terrains_peering_bit/right_side = 0 -2:2/0/terrains_peering_bit/left_side = 0 -2:2/0/terrains_peering_bit/top_left_corner = 0 -2:2/0/terrains_peering_bit/top_side = 0 -2:2/0/terrains_peering_bit/top_right_corner = 0 -3:0/0 = 0 -3:0/0/terrain_set = 0 -3:0/0/terrain = 0 -3:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -3:0/0/terrains_peering_bit/bottom_side = 0 -3:0/0/terrains_peering_bit/bottom_left_corner = 0 -3:0/0/terrains_peering_bit/left_side = 0 -3:1/0 = 0 -3:1/0/terrain_set = 0 -3:1/0/terrain = 0 -3:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -3:1/0/terrains_peering_bit/bottom_side = 0 -3:1/0/terrains_peering_bit/bottom_left_corner = 0 -3:1/0/terrains_peering_bit/left_side = 0 -3:1/0/terrains_peering_bit/top_left_corner = 0 -3:1/0/terrains_peering_bit/top_side = 0 +1:2/0/terrains_peering_bit/bottom_right_corner = 0 +1:2/0/terrains_peering_bit/bottom_left_corner = 0 +1:2/0/terrains_peering_bit/top_left_corner = 1 +1:2/0/terrains_peering_bit/top_right_corner = 1 +0:0/0 = 0 +0:0/0/terrain_set = 0 +0:0/0/terrains_peering_bit/bottom_right_corner = 0 +0:0/0/terrains_peering_bit/bottom_left_corner = 1 +0:0/0/terrains_peering_bit/top_left_corner = 0 +0:0/0/terrains_peering_bit/top_right_corner = 0 3:2/0 = 0 3:2/0/terrain_set = 0 -3:2/0/terrain = 0 -3:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) -3:2/0/terrains_peering_bit/left_side = 0 -3:2/0/terrains_peering_bit/top_left_corner = 0 -3:2/0/terrains_peering_bit/top_side = 0 +3:2/0/terrains_peering_bit/bottom_right_corner = 0 +3:2/0/terrains_peering_bit/bottom_left_corner = 1 +3:2/0/terrains_peering_bit/top_left_corner = 1 +3:2/0/terrains_peering_bit/top_right_corner = 0 +2:3/0 = 0 +2:3/0/terrain_set = 0 +2:3/0/terrains_peering_bit/bottom_right_corner = 0 +2:3/0/terrains_peering_bit/bottom_left_corner = 1 +2:3/0/terrains_peering_bit/top_left_corner = 0 +2:3/0/terrains_peering_bit/top_right_corner = 1 +3:1/0 = 0 +3:1/0/terrain_set = 0 +3:1/0/terrains_peering_bit/bottom_right_corner = 0 +3:1/0/terrains_peering_bit/bottom_left_corner = 1 +3:1/0/terrains_peering_bit/top_left_corner = 1 +3:1/0/terrains_peering_bit/top_right_corner = 1 +1:3/0 = 0 +1:3/0/terrain_set = 0 +1:3/0/terrains_peering_bit/bottom_right_corner = 1 +1:3/0/terrains_peering_bit/bottom_left_corner = 0 +1:3/0/terrains_peering_bit/top_left_corner = 0 +1:3/0/terrains_peering_bit/top_right_corner = 0 +0:1/0 = 0 +0:1/0/terrain_set = 0 +0:1/0/terrains_peering_bit/bottom_right_corner = 1 +0:1/0/terrains_peering_bit/bottom_left_corner = 0 +0:1/0/terrains_peering_bit/top_left_corner = 1 +0:1/0/terrains_peering_bit/top_right_corner = 0 +1:0/0 = 0 +1:0/0/terrain_set = 0 +1:0/0/terrains_peering_bit/bottom_right_corner = 1 +1:0/0/terrains_peering_bit/bottom_left_corner = 0 +1:0/0/terrains_peering_bit/top_left_corner = 0 +1:0/0/terrains_peering_bit/top_right_corner = 1 +2:2/0 = 0 +2:2/0/terrain_set = 0 +2:2/0/terrains_peering_bit/bottom_right_corner = 1 +2:2/0/terrains_peering_bit/bottom_left_corner = 0 +2:2/0/terrains_peering_bit/top_left_corner = 1 +2:2/0/terrains_peering_bit/top_right_corner = 1 +3:0/0 = 0 +3:0/0/terrain_set = 0 +3:0/0/terrains_peering_bit/bottom_right_corner = 1 +3:0/0/terrains_peering_bit/bottom_left_corner = 1 +3:0/0/terrains_peering_bit/top_left_corner = 0 +3:0/0/terrains_peering_bit/top_right_corner = 0 +2:0/0 = 0 +2:0/0/terrain_set = 0 +2:0/0/terrains_peering_bit/bottom_right_corner = 1 +2:0/0/terrains_peering_bit/bottom_left_corner = 1 +2:0/0/terrains_peering_bit/top_left_corner = 1 +2:0/0/terrains_peering_bit/top_right_corner = 0 +1:1/0 = 0 +1:1/0/terrain_set = 0 +1:1/0/terrains_peering_bit/bottom_right_corner = 1 +1:1/0/terrains_peering_bit/bottom_left_corner = 1 +1:1/0/terrains_peering_bit/top_left_corner = 0 +1:1/0/terrains_peering_bit/top_right_corner = 1 +2:1/0 = 0 +2:1/0/terrain_set = 0 +2:1/0/terrains_peering_bit/bottom_right_corner = 1 +2:1/0/terrains_peering_bit/bottom_left_corner = 1 +2:1/0/terrains_peering_bit/top_left_corner = 1 +2:1/0/terrains_peering_bit/top_right_corner = 1 + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_xdrfk"] +texture = ExtResource("5_y2hwx") +0:0/0 = 0 +0:0/0/terrain_set = 0 +0:0/0/terrain = 0 +1:0/0 = 0 +1:0/0/terrain_set = 0 +1:0/0/terrain = 1 +1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) + +[sub_resource type="TileSet" id="TileSet_xdrfk"] +physics_layer_0/collision_layer = 1 +terrain_set_0/mode = 1 +terrain_set_0/terrain_0/name = "" +terrain_set_0/terrain_0/color = Color(0.93333334, 0.50980395, 0.93333334, 1) +terrain_set_0/terrain_1/name = "neon_box" +terrain_set_0/terrain_1/color = Color(0.5, 0.4375, 0.25, 1) +sources/0 = SubResource("TileSetAtlasSource_qiocs") +sources/2 = SubResource("TileSetAtlasSource_xdrfk") + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_e2o6t"] +texture = ExtResource("4_cdx1q") 4:0/0 = 0 4:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) 4:0/0/physics_layer_0/polygon_0/one_way = true -0:1/0 = 0 [sub_resource type="TileSet" id="TileSet_mwb40"] +occlusion_layer_0/light_mask = 1 +occlusion_layer_0/sdf_collision = true physics_layer_0/collision_layer = 1 terrain_set_0/mode = 0 terrain_set_0/terrain_0/name = "Terrain 0" @@ -105,16 +153,39 @@ script = ExtResource("1_kc8ui") layer = 0 follow_viewport_enabled = true -[node name="TileMapLayer" type="TileMapLayer" parent="World" unique_id=462402070] -z_index = -100 -tile_map_data = PackedByteArray("AADv//b/AgAAAAAAAADv//f/AgAAAAAAAADv//j/AgAAAAAAAADv//n/AgAAAAAAAADv//r/AgAAAAAAAADv//v/AgAAAAAAAADv//z/AgAAAAAAAADv//3/AgAAAAAAAADv//7/AgAAAAAAAADv////AgAAAAAAAADv/wAAAgAAAAAAAADv/wEAAgAAAAAAAADv/wIAAgAAAAAAAADv/wMAAgAAAAAAAADv/wQAAgAAAAAAAADv/wUAAgAAAAAAAADv/wYAAgAAAAAAAADv/wcAAgAAAAAAAADv/wgAAgAAAAAAAADv/wkAAgAAAAAAAADv/woAAgAAAAAAAADw//b/AgAAAAAAAADw//f/AgAAAAAAAADw//j/AgAAAAAAAADw//n/AgAAAAAAAADw//r/AgAAAAAAAADw//v/AgAAAAAAAADw//z/AgAAAAAAAADw//3/AgAAAAAAAADw//7/AgAAAAAAAADw////AgAAAAAAAADw/wAAAgAAAAAAAADw/wEAAgAAAAAAAADw/wIAAgAAAAAAAADw/wMAAgAAAAAAAADw/wQAAgAAAAAAAADw/wUAAgAAAAAAAADw/wYAAgAAAAAAAADw/wcAAgAAAAAAAADw/wgAAgAAAAAAAADw/wkAAgAAAAAAAADw/woAAgAAAAAAAADx//b/AgAAAAAAAADx//f/AgAAAAAAAADx//j/AgAAAAAAAADx//n/AgAAAAAAAADx//r/AgAAAAAAAADx//v/AgAAAAAAAADx//z/AgAAAAAAAADx//3/AgAAAAAAAADx//7/AgAAAAAAAADx////AgAAAAAAAADx/wAAAgAAAAAAAADx/wEAAgAAAAAAAADx/wIAAgAAAAAAAADx/wMAAgAAAAAAAADx/wQAAgAAAAAAAADx/wUAAgAAAAAAAADx/wYAAgAAAAAAAADx/wcAAgAAAAAAAADx/wgAAgAAAAAAAADx/wkAAgAAAAAAAADx/woAAgAAAAAAAADy//b/AgAAAAAAAADy//f/AgAAAAAAAADy//j/AgAAAAAAAADy//n/AgAAAAAAAADy//r/AgAAAAAAAADy//v/AgAAAAAAAADy//z/AgAAAAAAAADy//3/AgAAAAAAAADy//7/AgAAAAAAAADy////AgAAAAAAAADy/wAAAgAAAAAAAADy/wEAAgAAAAAAAADy/wIAAgAAAAAAAADy/wMAAgAAAAAAAADy/wQAAgAAAAAAAADy/wUAAgAAAAAAAADy/wYAAgAAAAAAAADy/wcAAgAAAAAAAADy/wgAAgAAAAAAAADy/wkAAgAAAAAAAADy/woAAgAAAAAAAADz//b/AgAAAAAAAADz//f/AgAAAAAAAADz//j/AgAAAAAAAADz//n/AgAAAAAAAADz//r/AgABAAAAAADz//v/AgABAAEAAADz//z/AgABAAEAAADz//3/AgABAAIAAADz//7/AgAAAAAAAADz////AgAAAAAAAADz/wAAAgAAAAAAAADz/wEAAgAAAAAAAADz/wIAAgAAAAAAAADz/wMAAgAAAAAAAADz/wQAAgABAAAAAADz/wUAAgABAAEAAADz/wYAAgABAAEAAADz/wcAAgABAAIAAADz/wgAAgAAAAAAAADz/wkAAgAAAAAAAADz/woAAgAAAAAAAAD0//b/AgAAAAAAAAD0//f/AgAAAAAAAAD0//j/AgAAAAAAAAD0//n/AgAAAAAAAAD0//r/AgACAAAAAAD0//v/AgACAAEAAAD0//z/AgACAAEAAAD0//3/AgACAAIAAAD0//7/AgAAAAA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/AgADAAEAAAAOAP7/AgADAAEAAAAOAP//AgADAAEAAAAOAAAAAgADAAEAAAAOAAEAAgADAAEAAAAOAAIAAgADAAIAAAAOAAMAAgAAAAAAAAAOAAQAAgAAAAAAAAAOAAUAAgAAAAAAAAAOAAYAAgAAAAAAAAAOAAcAAgAAAAAAAAAOAAgAAgAAAAAAAAAOAAkAAgAAAAAAAAAOAAoAAgAAAAAAAAAPAPb/AgAAAAAAAAAPAPf/AgAAAAAAAAAPAPj/AgAAAAAAAAAPAPn/AgAAAAAAAAAPAPr/AgAAAAAAAAAPAPv/AgAAAAAAAAAPAPz/AgAAAAAAAAAPAP3/AgAAAAAAAAAPAP7/AgAAAAAAAAAPAP//AgAAAAAAAAAPAAAAAgAAAAAAAAAPAAEAAgAAAAAAAAAPAAIAAgAAAAAAAAAPAAMAAgAAAAAAAAAPAAQAAgAAAAAAAAAPAAUAAgAAAAAAAAAPAAYAAgAAAAAAAAAPAAcAAgAAAAAAAAAPAAgAAgAAAAAAAAAPAAkAAgAAAAAAAAAPAAoAAgAAAAAAAAAQAPb/AgAAAAAAAAAQAPf/AgAAAAAAAAAQAPj/AgAAAAAAAAAQAPn/AgAAAAAAAAAQAPr/AgAAAAAAAAAQAPv/AgAAAAAAAAAQAPz/AgAAAAAAAAAQAP3/AgAAAAAAAAAQAP7/AgAAAAAAAAAQAP//AgAAAAAAAAAQAAAAAgAAAAAAAAAQAAEAAgAAAAAAAAAQAAIAAgAAAAAAAAAQAAMAAgAAAAAAAAAQAAQAAgAAAAAAAAAQAAUAAgAAAAAAAAAQAAYAAgAAAAAAAAAQAAcAAgAAAAAAAAAQAAgAAgAAAAAAAAAQAAkAAgAAAAAAAAAQAAoAAgAAAAAAAAA=") +[node name="GlobalLight" type="DirectionalLight2D" parent="World" unique_id=207170317] +position = Vector2(0, 1) +energy = 0.9 + +[node name="Background" type="Sprite2D" parent="World" unique_id=1511807768] +texture_repeat = 2 +texture = ExtResource("5_wqvko") +region_enabled = true +region_rect = Rect2(0, 0, 10000, 10000) + +[node name="Level" type="Node2D" parent="World" unique_id=1470134692] + +[node name="NeonBox" type="TileMapLayer" parent="World/Level" unique_id=1807454266] +material = ExtResource("3_4bcji") +tile_map_data = PackedByteArray("AADy/wIAAgABAAAAAADy/wMAAgABAAAAAADz/wIAAgABAAAAAADz/wMAAgABAAAAAAD0/wIAAgABAAAAAAD0/wMAAgABAAAAAAD1/wIAAgABAAAAAAD1/wMAAgABAAAAAAD4/wIAAgABAAAAAAD4/wMAAgABAAAAAAD5/wIAAgABAAAAAAD5/wMAAgABAAAAAAD6/wIAAgABAAAAAAD6/wMAAgABAAAAAAD7/wIAAgABAAAAAAD7/wMAAgABAAAAAAD8/wIAAgABAAAAAAD8/wMAAgABAAAAAAD9/wIAAgABAAAAAAD9/wMAAgABAAAAAAD+/wIAAgABAAAAAAD+/wMAAgABAAAAAAD//wIAAgABAAAAAAD//wMAAgABAAAAAAAAAAIAAgABAAAAAAAAAAMAAgABAAAAAAABAAIAAgABAAAAAAABAAMAAgABAAAAAAACAAIAAgABAAAAAAACAAMAAgABAAAAAAADAAIAAgABAAAAAAADAAMAAgABAAAAAAAGAAIAAgABAAAAAAAGAAMAAgABAAAAAAAHAAIAAgABAAAAAAAHAAMAAgABAAAAAAAIAAIAAgABAAAAAAAIAAMAAgABAAAAAAAJAAIAAgABAAAAAAAJAAMAAgABAAAAAAAKAAIAAgABAAAAAAAKAAMAAgABAAAAAAALAAIAAgABAAAAAAALAAMAAgABAAAAAAAMAAIAAgABAAAAAAAMAAMAAgABAAAAAAD//wEAAgABAAAAAAAAAAEAAgABAAAAAAABAAEAAgABAAAAAADz//r/AgABAAAAAADz//v/AgABAAAAAADz//z/AgABAAAAAADz//3/AgABAAAAAADz//7/AgABAAAAAADz////AgABAAAAAADz/wAAAgABAAAAAADz/wEAAgABAAAAAAD0//r/AgABAAAAAAD0//v/AgABAAAAAAD0//z/AgABAAAAAAD0//3/AgABAAAAAAD0//7/AgABAAAAAAD0////AgABAAAAAAD0/wAAAgABAAAAAAD0/wEAAgABAAAAAAAHAPr/AgABAAAAAAAHAPv/AgABAAAAAAAHAPz/AgABAAAAAAAHAP3/AgABAAAAAAAHAP7/AgABAAAAAAAHAP//AgABAAAAAAAHAAAAAgABAAAAAAAHAAEAAgABAAAAAAAIAPr/AgABAAAAAAAIAPv/AgABAAAAAAAIAPz/AgABAAAAAAAIAP3/AgABAAAAAAAIAP7/AgABAAAAAAAIAP//AgABAAAAAAAIAAAAAgABAAAAAAAIAAEAAgABAAAAAAAJAPr/AgABAAAAAAAJAPv/AgABAAAAAAAJAPz/AgABAAAAAAAJAP3/AgABAAAAAAAJAP7/AgABAAAAAAAJAP//AgABAAAAAAAJAAAAAgABAAAAAAAJAAEAAgABAAAAAADx/wQAAgABAAAAAADx/wUAAgABAAAAAADx/wYAAgABAAAAAADx/wcAAgABAAAAAADx/wgAAgABAAAAAADx/wkAAgABAAAAAADx/woAAgABAAAAAADx/wsAAgABAAAAAADy/wQAAgABAAAAAADy/wUAAgABAAAAAADy/wYAAgABAAAAAADy/wcAAgABAAAAAADy/wgAAgABAAAAAADy/wkAAgABAAAAAADy/woAAgABAAAAAADy/wsAAgABAAAAAADz/wQAAgABAAAAAADz/wUAAgABAAAAAADz/wYAAgABAAAAAADz/wcAAgABAAAAAADz/wgAAgABAAAAAADz/wkAAgABAAAAAADz/woAAgABAAAAAADz/wsAAgABAAAAAAD0/wQAAgABAAAAAAD0/wUAAgABAAAAAAD0/wYAAgABAAAAAAD0/wcAAgABAAAAAAD0/wgAAgABAAAAAAD0/wkAAgABAAAAAAD0/woAAgABAAAAAAD0/wsAAgABAAAAAAD1/wQAAgABAAAAAAD1/wUAAgABAAAAAAD1/wYAAgABAAAAAAD1/wcAAgABAAAAAAD1/wgAAgABAAAAAAD1/wkAAgABAAAAAAD1/woAAgABAAAAAAD1/wsAAgABAAAAAAD2/wYAAgABAAAAAAD2/wcAAgABAAAAAAD2/wgAAgABAAAAAAD2/wkAAgABAAAAAAD2/woAA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AFAPr/AgABAAAAAAAGAPr/AgABAAAAAADz//n/AgABAAAAAAD0//n/AgABAAAAAAD7//f/AgABAAAAAAD8//f/AgABAAAAAAD9//f/AgABAAAAAAD+//f/AgABAAAAAAD///f/AgABAAAAAAAAAPf/AgABAAAAAAABAPf/AgABAAAAAAAAAPj/AgABAAAAAAAAAPn/AgABAAAAAAABAPj/AgABAAAAAAABAPn/AgABAAAAAAACAPf/AgABAAAAAAACAPj/AgABAAAAAAACAPn/AgABAAAAAADz//b/AgABAAAAAADz//f/AgABAAAAAADz//j/AgABAAAAAADy//X/AgABAAAAAAA=") +tile_set = SubResource("TileSet_xdrfk") +script = ExtResource("4_uktfx") +godot_4_3_compatibility = false +metadata/_custom_type_script = "uid://cjk8nronimk5r" + +[node name="TileMapLayer" type="TileMapLayer" parent="World/Level" unique_id=462402070] +modulate = Color(0, 1, 1, 1) +tile_map_data = PackedByteArray("AAD4////AgAEAAAAAAD5////AgAEAAAAAAD6////AgAEAAAAAAD7//v/AgAEAAAAAAD8//v/AgAEAAAAAAD9//v/AgAEAAAAAAD2//r/AgAEAAAAAAD3//r/AgAEAAAAAAD4//r/AgAEAAAAAAA=") tile_set = SubResource("TileSet_mwb40") [node name="Player" parent="World" unique_id=500011307 instance=ExtResource("2_feb5d")] -position = Vector2(-107, -26) +position = Vector2(-111, -16) [node name="Birb" parent="World" unique_id=428810294 instance=ExtResource("2_fc0e3")] -position = Vector2(11, 8) +position = Vector2(14, 8) + +[node name="CanvasModulate" type="CanvasModulate" parent="World" unique_id=1975411321] +color = Color(0, 0, 0, 1) [node name="UI" type="CanvasLayer" parent="." unique_id=884024747] layer = 20 @@ -128,6 +199,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 1 theme = ExtResource("5_bs6l1") +metadata/_edit_lock_ = true [node name="PlayerHealthBar" type="ProgressBar" parent="UI/Control" unique_id=1470557052 node_paths=PackedStringArray("Player")] layout_mode = 1 diff --git a/src/level/background.aseprite b/src/level/background.aseprite new file mode 100644 index 0000000..9b20421 --- /dev/null +++ b/src/level/background.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d121ea31cd02c7636ba7136bd1c00c9eec30e631a11edbc654790dc8a59b4c2c +size 477 diff --git a/src/level/background.aseprite.import b/src/level/background.aseprite.import new file mode 100644 index 0000000..4b2b040 --- /dev/null +++ b/src/level/background.aseprite.import @@ -0,0 +1,21 @@ +[remap] + +importer="aseprite_wizard.plugin.static-texture" +type="PortableCompressedTexture2D" +uid="uid://cbjps58vfmyeb" +path="res://.godot/imported/background.aseprite-16e00d362c23a39a421f665d96ce4601.res" + +[deps] + +source_file="res://src/level/background.aseprite" +dest_files=["res://.godot/imported/background.aseprite-16e00d362c23a39a421f665d96ce4601.res"] + +[params] + +layer/exclude_layers_pattern="" +layer/only_visible_layers=false +layer/split_layers=false +first_frame_only=true +sheet/sheet_type="packed" +sheet/sheet_columns=12 +sheet/scale=1 diff --git a/src/level/neon_box.aseprite b/src/level/neon_box.aseprite new file mode 100644 index 0000000..c3ae884 --- /dev/null +++ b/src/level/neon_box.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc24a434d2c9db2560f8e81b3be7e3311ffa55e81c013690aeeefb6ef77805c4 +size 522 diff --git a/src/level/neon_box.aseprite.import b/src/level/neon_box.aseprite.import new file mode 100644 index 0000000..1cd6b35 --- /dev/null +++ b/src/level/neon_box.aseprite.import @@ -0,0 +1,21 @@ +[remap] + +importer="aseprite_wizard.plugin.static-texture" +type="PortableCompressedTexture2D" +uid="uid://b0grslwquoxek" +path="res://.godot/imported/neon_box.aseprite-fb78d07d04f567fce9d25f6697873e5a.res" + +[deps] + +source_file="res://src/level/neon_box.aseprite" +dest_files=["res://.godot/imported/neon_box.aseprite-fb78d07d04f567fce9d25f6697873e5a.res"] + +[params] + +layer/exclude_layers_pattern="" +layer/only_visible_layers=false +layer/split_layers=false +first_frame_only=true +sheet/sheet_type="packed" +sheet/sheet_columns=12 +sheet/scale=1 diff --git a/src/level/neon_box_selector.aseprite b/src/level/neon_box_selector.aseprite new file mode 100644 index 0000000..9f084e9 --- /dev/null +++ b/src/level/neon_box_selector.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6fbd53b93e9742755caea349c2adb18c0647bda4f03d80c22032bd590f0ef1b +size 377 diff --git a/src/level/neon_box_selector.aseprite.import b/src/level/neon_box_selector.aseprite.import new file mode 100644 index 0000000..d19735f --- /dev/null +++ b/src/level/neon_box_selector.aseprite.import @@ -0,0 +1,21 @@ +[remap] + +importer="aseprite_wizard.plugin.static-texture" +type="PortableCompressedTexture2D" +uid="uid://dg5wulm2tav4t" +path="res://.godot/imported/neon_box_selector.aseprite-715dec900389455a0fc3afc6a5726980.res" + +[deps] + +source_file="res://src/level/neon_box_selector.aseprite" +dest_files=["res://.godot/imported/neon_box_selector.aseprite-715dec900389455a0fc3afc6a5726980.res"] + +[params] + +layer/exclude_layers_pattern="" +layer/only_visible_layers=false +layer/split_layers=false +first_frame_only=true +sheet/sheet_type="packed" +sheet/sheet_columns=12 +sheet/scale=1 diff --git a/src/level/tiles.aseprite b/src/level/tiles.aseprite new file mode 100644 index 0000000..6dbe06c --- /dev/null +++ b/src/level/tiles.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e1e2c97374fe87dadc104ebd179e18aafd1d8e04a39b2b86f570f8ef15900d5 +size 318 diff --git a/src/level/tiles.aseprite.import b/src/level/tiles.aseprite.import new file mode 100644 index 0000000..9dcedf4 --- /dev/null +++ b/src/level/tiles.aseprite.import @@ -0,0 +1,21 @@ +[remap] + +importer="aseprite_wizard.plugin.static-texture" +type="PortableCompressedTexture2D" +uid="uid://d2m74vkdtcimf" +path="res://.godot/imported/tiles.aseprite-310a34210037ec686e073a30d5adba8f.res" + +[deps] + +source_file="res://src/level/tiles.aseprite" +dest_files=["res://.godot/imported/tiles.aseprite-310a34210037ec686e073a30d5adba8f.res"] + +[params] + +layer/exclude_layers_pattern="" +layer/only_visible_layers=false +layer/split_layers=false +first_frame_only=true +sheet/sheet_type="packed" +sheet/sheet_columns=12 +sheet/scale=1 diff --git a/src/level/tiles.gdshader b/src/level/tiles.gdshader new file mode 100644 index 0000000..115c3c6 --- /dev/null +++ b/src/level/tiles.gdshader @@ -0,0 +1,19 @@ +shader_type canvas_item; + +uniform sampler2D emissive : + hint_default_transparent, source_color, filter_nearest; + +void vertex() {} + +void fragment() { + COLOR.rgb = vec3(texture_sdf(screen_uv_to_sdf(SCREEN_UV))/10.0); +} + +void light() { + // Called for every pixel for every light affecting the CanvasItem. + // Uncomment to replace the default light processing function with this one. + LIGHT = vec4(LIGHT_COLOR.rgb * COLOR.rgb * LIGHT_ENERGY, LIGHT_COLOR.a); + LIGHT = vec4(0.1); + //LIGHT = vec4(1, 1, 1, 1); + //SHADOW_MODULATE = vec4(1, 1, 1, 1); +} diff --git a/src/level/tiles.gdshader.uid b/src/level/tiles.gdshader.uid new file mode 100644 index 0000000..296065c --- /dev/null +++ b/src/level/tiles.gdshader.uid @@ -0,0 +1 @@ +uid://cv1vyt3ex306g diff --git a/src/level/tiles_0.aseprite b/src/level/tiles_0.aseprite deleted file mode 100644 index 9211081a51a584c70f03ee91139e953627096239..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmeBXVqkc%l#!tU2o)F@85kH+fEWP;7#Kl<3<5w%3&0Ju|JO$ru&pdW3&en!T>)$* zl66)0cM&nrx?NJ}cSd`s~^#Q>+dgcTA}@nQLHuDW$N$yuR+p zL6g?G;?CakAe{=#NM`*9ve_AY5-U@S6byQRX0j?kWd8%50s)}FsF?Hij;+@b2Z@G< z(iKdJANiW*COnjV^Hu7e!v{6F1E9@?rAaLRE(5({(Ih|#+(y}((awSulMHV zqfgIEE_}cKd%~&o`pR1CCogXFuIqXH_UhRQuVgB!_Wip(|7Fp~kCoT&EPG}9Z*S_0 zc%SRnum3v!!v3xG`>1KJWg=z^N4ma@|9vic`?af<7pvd=Z|3-$eR=7>wU6&?lwbY- z*2g=$uDzCDUjKT={O$LO{7z_i{a^Zbb@Ab^c6t9*-+eCn?q2@|g#P=;y_5gy@AH3; zSM}e=tLJ{dWWR6e=Z1flYhu~I^!xw6^QAxc_1?Jb=)cF!>d!^*zMgF>{7U}xwDh{a zk1yGq|1G}xdG7r$wZD#EwGuz`yzyV*&%f+{FUliO@nw)ID6#!l{H?vw?=si_uY7(W UqpDvT7M=v?0=fNcZQI@e0OL*XbpQYW diff --git a/src/level/tiles_0.aseprite.import b/src/level/tiles_0.aseprite.import deleted file mode 100644 index 56970af..0000000 --- a/src/level/tiles_0.aseprite.import +++ /dev/null @@ -1,21 +0,0 @@ -[remap] - -importer="aseprite_wizard.plugin.static-texture" -type="PortableCompressedTexture2D" -uid="uid://dkxcdqm8dgdq7" -path="res://.godot/imported/tiles_0.aseprite-88b641c9e3407952b30dd9ebb5ab058f.res" - -[deps] - -source_file="res://src/level/tiles_0.aseprite" -dest_files=["res://.godot/imported/tiles_0.aseprite-88b641c9e3407952b30dd9ebb5ab058f.res"] - -[params] - -layer/exclude_layers_pattern="" -layer/only_visible_layers=false -layer/split_layers=false -first_frame_only=true -sheet/sheet_type="packed" -sheet/sheet_columns=16 -sheet/scale=1 diff --git a/src/player/Player.cs b/src/player/Player.cs index df7bd7d..56390aa 100644 --- a/src/player/Player.cs +++ b/src/player/Player.cs @@ -1,10 +1,9 @@ using System.Collections.Generic; -using System.Text; namespace Dancer; [Meta(typeof(IAutoNode))] -public sealed partial class Player : CharacterBody2D, IAttackable +public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, IProvide { public override void _Notification(int what) => this.Notify(what); @@ -21,13 +20,13 @@ public sealed partial class Player : CharacterBody2D, IAttackable public float GroundedSpeedStopDecay { get; set; } = 0.005f; [Export(PropertyHint.None, "suffix:px/s")] - public float WalkMaxSpeed { get; set; } = 110.0f; + public float WalkMaxSpeed { get; set; } = 130.0f; [Export(PropertyHint.None, "suffix:px/s²")] - public float WalkAccel { get; set; } = 600.0f; + public float WalkAccel { get; set; } = 900.0f; [Export(PropertyHint.None, "suffix:px/s²")] - public float AirAccel { get; set; } = 180.0f; + public float AirAccel { get; set; } = 210.0f; [Export(PropertyHint.None, "suffix:s")] public float JumpAscentMaxTime { get; set; } = 0.2f; @@ -50,23 +49,24 @@ public sealed partial class Player : CharacterBody2D, IAttackable public float DownInputAngle { get; set; } = Mathf.Pi / 4; [Export] public float MaxHealth { get; set; } = 5f; - public float Health { get; set; } + [Export] public float Health { get; set; } + [Export] public bool CanTurn { get; set; } = true; private ulong MaxInputBufferTimeMicroseconds => (ulong)(MaxInputBufferTime * 1_000_000); - private float _jumpAscentRemainingTime; private bool _isJumping; private float _jumpAllowedTime; private Vector2 _currentDirection = Vector2.Zero; private bool _isFacingRight = true; - private AnimationNodeStateMachinePlayback _playback = null!; private List _inputBuffer = []; [Node] private AnimationTree AnimationTree { get; set; } = null!; - public override void _Ready() + public void OnReady() { + this.Provide(); + SetPhysicsProcess(true); Health = MaxHealth; _playback = AnimationTree.Get("parameters/playback").As(); } @@ -101,16 +101,13 @@ public sealed partial class Player : CharacterBody2D, IAttackable } } - public override void _PhysicsProcess(double delta) + public void OnPhysicsProcess(double delta) { var deltaF = (float)delta; // Temporary copy of the velocity for easier editing. var velocity = Velocity; - if (_currentDirection.X < 0) - _isFacingRight = false; - else if (_currentDirection.X > 0) - _isFacingRight = true; + if (CanTurn) AdjustFacing(); // Walking on the floor if (IsOnFloor()) @@ -171,6 +168,14 @@ public sealed partial class Player : CharacterBody2D, IAttackable } } + private void AdjustFacing() + { + if (_currentDirection.X < 0) + _isFacingRight = false; + else if (_currentDirection.X > 0) + _isFacingRight = true; + } + private bool IsHoldingWall() { return @@ -199,15 +204,6 @@ public sealed partial class Player : CharacterBody2D, IAttackable _inputBuffer.RemoveAt(0); } - { - var inputBuffer = new StringBuilder(); - foreach (var bufferedInput in _inputBuffer) - { - inputBuffer.Append($"{bufferedInput}, "); - } - - GD.Print(inputBuffer); - } // Check new commands for (var i = 0; i < _inputBuffer.Count; i++) { @@ -236,7 +232,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable else if (input.Event.IsActionPressed("attack")) { inputFound = true; - Slash(); + Attack(); } if (inputFound) @@ -249,6 +245,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable private void GroundJump() { + AdjustFacing(); _jumpAllowedTime = 0.0f; _jumpAscentRemainingTime = JumpAscentMaxTime; _isJumping = true; @@ -256,6 +253,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable private void WallJump() { + AdjustFacing(); _jumpAllowedTime = 0.0f; Velocity += GetWallNormal() * 200.0f; Velocity = Velocity with { Y = Mathf.Min(0, Velocity.Y) }; @@ -270,16 +268,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable Velocity = Velocity with { Y = Velocity.Y * 0.1f }; } - private void Slash() + private void Attack() { + AdjustFacing(); Velocity += (_isFacingRight ? Vector2.Right : Vector2.Left) * SlashSpeedBoost; - _playback.Travel("attack"); - - var instance = GD.Load("res://src/player/slash_projectile.tscn") - .Instantiate(); - AddChild(instance); - instance.GlobalTransform = GetNode("%HandAttachment").GlobalTransform; - instance.HitboxEntered += OnEnemyHit; + _playback.Travel("front_kick"); } private bool IsInputVecDown(Vector2 vec) @@ -287,14 +280,14 @@ public sealed partial class Player : CharacterBody2D, IAttackable return Mathf.Abs(vec.AngleTo(Vector2.Down)) < DownInputAngle && vec.Length() > 0.1f; } - private void OnEnemyHit(Node2D enemy) + private void OnEnemyHit(Hitbox hitbox, Node2D enemy) { if (enemy is not IAttackable attackable) return; attackable.GetAttacked(new() { Attacker = this, Damage = 1.0f, - Impulse = Vector2.Down * 1000.0f + (enemy.Position - Position).Normalized() * 1000.0f, + Impulse = Vector2.Up * 1000.0f + (enemy.Position - Position).Normalized() * 1000.0f, }); } @@ -309,4 +302,8 @@ public sealed partial class Player : CharacterBody2D, IAttackable public required InputEvent Event { get; init; } public ulong Time { get; init; } } + + public void OnHitboxAdded(Hitbox hitbox) => hitbox.BodyHit += OnEnemyHit; + public void OnHitboxRemoved(Hitbox hitbox) => hitbox.BodyHit -= OnEnemyHit; + IHitboxOwner IProvide.Value() => this; } diff --git a/src/player/light.aseprite b/src/player/light.aseprite new file mode 100644 index 0000000..0569682 --- /dev/null +++ b/src/player/light.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bd5fe08e9a6085e2a85e6925f9c3429317e02acbe502f7d3a5baa5602f96094 +size 1133 diff --git a/src/player/light.aseprite.import b/src/player/light.aseprite.import new file mode 100644 index 0000000..86b5779 --- /dev/null +++ b/src/player/light.aseprite.import @@ -0,0 +1,21 @@ +[remap] + +importer="aseprite_wizard.plugin.static-texture" +type="PortableCompressedTexture2D" +uid="uid://i6xi16yki1r5" +path="res://.godot/imported/light.aseprite-43635fe79226150b3143726afd3c6190.res" + +[deps] + +source_file="res://src/player/light.aseprite" +dest_files=["res://.godot/imported/light.aseprite-43635fe79226150b3143726afd3c6190.res"] + +[params] + +layer/exclude_layers_pattern="" +layer/only_visible_layers=false +layer/split_layers=false +first_frame_only=true +sheet/sheet_type="packed" +sheet/sheet_columns=12 +sheet/scale=1 diff --git a/src/player/player.aseprite b/src/player/player.aseprite index efdf7f8a17367e1753af90825a38bf38d6881176..bbc8b0857683d0a6b70aca6b361d058dae44a443 100644 GIT binary patch literal 129 zcmWN@$q~aK3;@7CRnR~T*j#cq98zE=37!c1k?P~u?uB3O<0IRg2k%Nf`+U5Jm)myc zrHr@Y1B<$h7`;kvX?1=NDT4(HXu%j4k}+}9Thv9{dY62v1Uc10Izp!65(LahVKwAX Md%^vO(z{^AAH3fur2qf` literal 15676 zcmeHu4OA0n+BQ@zT9s(GpIQZ@>$=ug1(gbh0MW9oKU8UDtCk>e3seS+u7OunfU&+%(t_j+G#hF`1~uDT|~FY z=$xmc&LIX^KztpRJst9A!(|ZbZ!VkvVoA$HOiEBrkP3X~(_>jhe^_S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$DDwDw!rF>t-x1ln~Mgv}j5 zvr4+#$Bm z$ddZB+(=H+Rz52?I#GOV&acajuK9@}L2A!}fnjKPqOhAxuWQptKcc+ao+HvO;s-+= z9K&ALT%UfMW|S#59&}!5^bK?+ybf)U@&g^tn^2xj>>F37y(w@1JBV45>2lXys{eXi ziz3+@>yjvea7$~L9)A==bRU(MuXS}+KcxK|km6rBL|IsJjJjlFVpiSZ)HE!2HigTl z^KvA;-@It`9$l?#P0Oy|OIW?@Qi7+f-b*}AK6BaCLLr39E-_`Yuj{jvE@Ww}SQRq+ z$?j|8jI=r1QSK5h-N;&NfCZz>aT1UZGc)o{gv-tZq9@n>WvdtZ-0s;g9%St zM17UWF+~q9I%BFOF7^h(a!0D>+emLB4`6eeed?3YEiu*&&&rLUUzQuiugrMu{{lWa B`-}hp diff --git a/src/player/player.aseprite.import b/src/player/player.aseprite.import index 62aab65..e019aba 100644 --- a/src/player/player.aseprite.import +++ b/src/player/player.aseprite.import @@ -16,6 +16,6 @@ layer/exclude_layers_pattern="" layer/only_visible_layers=true layer/split_layers=false first_frame_only=false -sheet/sheet_type="horizontal" -sheet/sheet_columns=12 +sheet/sheet_type="columns" +sheet/sheet_columns=8 sheet/scale=1 diff --git a/src/player/player.tscn b/src/player/player.tscn index cece49c..1a8236f 100644 --- a/src/player/player.tscn +++ b/src/player/player.tscn @@ -1,13 +1,18 @@ [gd_scene format=3 uid="uid://ce2k04khaub8n"] [ext_resource type="Script" uid="uid://b5iey2typf2tb" path="res://src/player/Player.cs" id="1_244u8"] -[ext_resource type="Script" uid="uid://bhijvek6js88u" path="res://src/spring/Spring2D.cs" id="2_mf2ua"] [ext_resource type="Texture2D" uid="uid://d0dy3j0qdycqf" path="res://src/player/player.aseprite" id="2_yw30f"] -[ext_resource type="Texture2D" uid="uid://blw6f2ktsrcmg" path="res://src/player/hair.aseprite" id="3_qjkh3"] +[ext_resource type="Texture2D" uid="uid://i6xi16yki1r5" path="res://src/player/light.aseprite" id="3_mf2ua"] +[ext_resource type="Script" uid="uid://b4k42r866lkut" path="res://src/combat/Hitbox.cs" id="4_244u8"] -[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_e2o6t"] -radius = 4.0 -height = 14.0 +[sub_resource type="RectangleShape2D" id="RectangleShape2D_jiejy"] +size = Vector2(10, 28) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_244u8"] +size = Vector2(27.5, 20) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5f2sf"] +size = Vector2(13.59375, 20) [sub_resource type="Animation" id="Animation_yw30f"] resource_name = "RESET" @@ -25,6 +30,112 @@ tracks/0/keys = { "update": 1, "values": [0] } +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:CanTurn") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Body/FrontKick/CollisionShape2D:disabled") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Body/FrontKick/CollisionShape2D2:disabled") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} + +[sub_resource type="Animation" id="Animation_g6k8r"] +resource_name = "front_kick" +length = 0.55 +step = 0.016666668 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Body:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.050000004, 0.116666675, 0.2, 0.28333333, 0.36666667, 0.45), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [9, 10, 11, 12, 13, 14, 9] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:CanTurn") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.45), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [false, true] +} +tracks/2/type = "method" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Body/FrontKick") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0.05, 0.36666667), +"transitions": PackedFloat32Array(1, 1), +"values": [{ +"args": [], +"method": &"StartAttack" +}, { +"args": [], +"method": &"StopAttack" +}] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Body/FrontKick/CollisionShape2D:disabled") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0.050000004, 0.28333336), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [false, true] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Body/FrontKick/CollisionShape2D2:disabled") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.050000004, 0.20000002), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, false] +} [sub_resource type="Animation" id="Animation_qjkh3"] resource_name = "idle" @@ -44,26 +155,9 @@ tracks/0/keys = { "values": [0] } -[sub_resource type="Animation" id="Animation_g6k8r"] -resource_name = "slash" -length = 0.20000167 -step = 0.05 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Body:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [6] -} - [sub_resource type="Animation" id="Animation_boad6"] -resource_name = "walk" -length = 0.400005 +resource_name = "run" +length = 0.8 loop_mode = 1 step = 0.1 tracks/0/type = "value" @@ -73,10 +167,10 @@ tracks/0/path = NodePath("Body:frame") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2, 0.3), -"transitions": PackedFloat32Array(1, 1, 1, 1), +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1), "update": 1, -"values": [0, 1, 2, 3] +"values": [1, 2, 3, 4, 5, 6, 7, 8] } [sub_resource type="Animation" id="Animation_rgyib"] @@ -100,20 +194,20 @@ tracks/0/keys = { [sub_resource type="AnimationLibrary" id="AnimationLibrary_rgyib"] _data = { &"RESET": SubResource("Animation_yw30f"), +&"front_kick": SubResource("Animation_g6k8r"), &"idle": SubResource("Animation_qjkh3"), -&"slash": SubResource("Animation_g6k8r"), -&"walk": SubResource("Animation_boad6"), +&"run": SubResource("Animation_boad6"), &"wall_hold": SubResource("Animation_rgyib") } [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_qjkh3"] -animation = &"slash" +animation = &"front_kick" [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_yw30f"] animation = &"idle" [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_g6k8r"] -animation = &"walk" +animation = &"run" [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_boad6"] animation = &"wall_hold" @@ -150,15 +244,15 @@ advance_expression = "not IsHoldingWall()" [sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_yllr7"] allow_transition_to_self = true -states/attack/node = SubResource("AnimationNodeAnimation_qjkh3") -states/attack/position = Vector2(604.5, 41.5) +states/front_kick/node = SubResource("AnimationNodeAnimation_qjkh3") +states/front_kick/position = Vector2(604.5, 41.5) states/idle/node = SubResource("AnimationNodeAnimation_yw30f") states/idle/position = Vector2(428.5, 88.5) -states/walk/node = SubResource("AnimationNodeAnimation_g6k8r") -states/walk/position = Vector2(628.5, 203.5) +states/run/node = SubResource("AnimationNodeAnimation_g6k8r") +states/run/position = Vector2(628.5, 203.5) states/wall_hold/node = SubResource("AnimationNodeAnimation_boad6") states/wall_hold/position = Vector2(362.82965, 231.5) -transitions = ["attack", "idle", SubResource("AnimationNodeStateMachineTransition_boad6"), "idle", "attack", SubResource("AnimationNodeStateMachineTransition_rgyib"), "Start", "idle", SubResource("AnimationNodeStateMachineTransition_hg6s5"), "idle", "walk", SubResource("AnimationNodeStateMachineTransition_8t03j"), "walk", "idle", SubResource("AnimationNodeStateMachineTransition_2ieo8"), "walk", "attack", SubResource("AnimationNodeStateMachineTransition_ebec5"), "idle", "wall_hold", SubResource("AnimationNodeStateMachineTransition_yllr7"), "wall_hold", "idle", SubResource("AnimationNodeStateMachineTransition_kb6p2")] +transitions = ["front_kick", "idle", SubResource("AnimationNodeStateMachineTransition_boad6"), "idle", "front_kick", SubResource("AnimationNodeStateMachineTransition_rgyib"), "Start", "idle", SubResource("AnimationNodeStateMachineTransition_hg6s5"), "idle", "run", SubResource("AnimationNodeStateMachineTransition_8t03j"), "run", "idle", SubResource("AnimationNodeStateMachineTransition_2ieo8"), "run", "front_kick", SubResource("AnimationNodeStateMachineTransition_ebec5"), "idle", "wall_hold", SubResource("AnimationNodeStateMachineTransition_yllr7"), "wall_hold", "idle", SubResource("AnimationNodeStateMachineTransition_kb6p2")] graph_offset = Vector2(-59.670364, -27) [node name="Player" type="CharacterBody2D" unique_id=500011307] @@ -170,17 +264,26 @@ floor_max_angle = 0.24783675 script = ExtResource("1_244u8") [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=84142517] -position = Vector2(0, 1) -shape = SubResource("CapsuleShape2D_e2o6t") +position = Vector2(0, -14) +shape = SubResource("RectangleShape2D_jiejy") [node name="Camera2D" type="Camera2D" parent="." unique_id=1975474809] +position = Vector2(0, -16) process_callback = 0 limit_enabled = false +[node name="PointLight2D" type="PointLight2D" parent="." unique_id=1795955896] +position = Vector2(0, -16) +energy = 0.1 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("3_mf2ua") + [node name="Body" type="Sprite2D" parent="." unique_id=567060128] unique_name_in_owner = true texture = ExtResource("2_yw30f") -hframes = 7 +offset = Vector2(0, -24) +hframes = 8 +vframes = 2 metadata/_aseprite_wizard_interface_config_ = { "animation_section": false, "layer_section": false, @@ -211,23 +314,34 @@ metadata/_aseprite_wizard_config_ = { } metadata/_aseprite_wizard_source_file_hash_ = "61168df4a163c039cfaab97f4fccb905" -[node name="Spring2D" type="Node2D" parent="Body" unique_id=1050714188] -show_behind_parent = true -script = ExtResource("2_mf2ua") - -[node name="Hair" type="Sprite2D" parent="Body/Spring2D" unique_id=796557000] -position = Vector2(-2, 2) -texture = ExtResource("3_qjkh3") - [node name="HandAttachment" type="Node2D" parent="Body" unique_id=1002134601] unique_name_in_owner = true -position = Vector2(3, 2) +position = Vector2(0, -14) + +[node name="FrontKick" type="Area2D" parent="Body" unique_id=1918418417] +process_mode = 4 +visible = false +position = Vector2(0, -16) +collision_layer = 8 +collision_mask = 4 +script = ExtResource("4_244u8") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Body/FrontKick" unique_id=2048987579] +position = Vector2(5, 7) +shape = SubResource("RectangleShape2D_244u8") +debug_color = Color(0.99430805, 0, 0.2314094, 0.41960785) + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="Body/FrontKick" unique_id=734742131] +position = Vector2(16, -2) +shape = SubResource("RectangleShape2D_5f2sf") +debug_color = Color(0.99430805, 0, 0.2314094, 0.41960785) [node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1251324400] libraries/ = SubResource("AnimationLibrary_rgyib") [node name="AnimationTree" type="AnimationTree" parent="AnimationPlayer" unique_id=1839424284] unique_name_in_owner = true +deterministic = false root_node = NodePath("%AnimationTree/../..") tree_root = SubResource("AnimationNodeStateMachine_yllr7") advance_expression_base_node = NodePath("../..") diff --git a/src/player/player_old.aseprite b/src/player/player_old.aseprite new file mode 100644 index 0000000..3393b65 --- /dev/null +++ b/src/player/player_old.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e44967ae7bf1a0921096dea9fb0a3a6e202fce71cc41fb0b7d5aed52def4d64d +size 15676 diff --git a/src/player/player_old.aseprite.import b/src/player/player_old.aseprite.import new file mode 100644 index 0000000..79afe62 --- /dev/null +++ b/src/player/player_old.aseprite.import @@ -0,0 +1,21 @@ +[remap] + +importer="aseprite_wizard.plugin.static-texture" +type="PortableCompressedTexture2D" +uid="uid://ddaoshqpfh1t4" +path="res://.godot/imported/player_old.aseprite-47ad749bdb952bbe0ea8d9f38e3427b5.res" + +[deps] + +source_file="res://src/player/player_old.aseprite" +dest_files=["res://.godot/imported/player_old.aseprite-47ad749bdb952bbe0ea8d9f38e3427b5.res"] + +[params] + +layer/exclude_layers_pattern="" +layer/only_visible_layers=false +layer/split_layers=false +first_frame_only=true +sheet/sheet_type="packed" +sheet/sheet_columns=12 +sheet/scale=1 diff --git a/src/player/player_tiny.aseprite b/src/player/player_tiny.aseprite new file mode 100644 index 0000000..cd76a6e --- /dev/null +++ b/src/player/player_tiny.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb044b2cf07460386d50f48cfdb2653a4ae31a4ba9861f7099c01aedc26d3a49 +size 518 diff --git a/src/player/player_tiny.aseprite.import b/src/player/player_tiny.aseprite.import new file mode 100644 index 0000000..387022b --- /dev/null +++ b/src/player/player_tiny.aseprite.import @@ -0,0 +1,21 @@ +[remap] + +importer="aseprite_wizard.plugin.static-texture" +type="PortableCompressedTexture2D" +uid="uid://nwgwml48hdv" +path="res://.godot/imported/player_tiny.aseprite-d334ea88c331655ae2e03f376620970f.res" + +[deps] + +source_file="res://src/player/player_tiny.aseprite" +dest_files=["res://.godot/imported/player_tiny.aseprite-d334ea88c331655ae2e03f376620970f.res"] + +[params] + +layer/exclude_layers_pattern="" +layer/only_visible_layers=false +layer/split_layers=false +first_frame_only=true +sheet/sheet_type="packed" +sheet/sheet_columns=12 +sheet/scale=1 diff --git a/src/player/slash_projectile.tscn b/src/player/slash_projectile.tscn index 2a69b67..2ecc896 100644 --- a/src/player/slash_projectile.tscn +++ b/src/player/slash_projectile.tscn @@ -1,32 +1,20 @@ [gd_scene format=3 uid="uid://bikcpm0fyl4pd"] -[ext_resource type="Texture2D" uid="uid://jdmsv25yp25v" path="res://src/player/attack.aseprite" id="1_3il12"] [ext_resource type="Script" uid="uid://0n1gv56pcc74" path="res://src/player/SlashProjectile.cs" id="1_bi0sp"] +[ext_resource type="PackedScene" uid="uid://cva3ecq7vp3a4" path="res://src/combat/hitbox.tscn" id="2_bi0sp"] [sub_resource type="Animation" id="Animation_3il12"] length = 0.001 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("Attack:frame") +tracks/0/path = NodePath("Hitbox/CollisionShape2D:disabled") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [0] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Hitbox/CollisionShape2D:disabled") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, "values": [true] } @@ -34,25 +22,13 @@ tracks/1/keys = { resource_name = "attack" length = 0.4 step = 0.1 -tracks/0/type = "value" +tracks/0/type = "method" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("Attack:frame") +tracks/0/path = NodePath(".") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 1, -"values": [0, 1, 2] -} -tracks/1/type = "method" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath(".") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { "times": PackedFloat32Array(0.4), "transitions": PackedFloat32Array(1), "values": [{ @@ -60,13 +36,13 @@ tracks/1/keys = { "method": &"OnAttackFinished" }] } -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Hitbox/CollisionShape2D:disabled") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Hitbox/CollisionShape2D:disabled") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { "times": PackedFloat32Array(0, 0.1, 0.3), "transitions": PackedFloat32Array(1, 1, 1), "update": 1, @@ -79,30 +55,23 @@ _data = { &"attack": SubResource("Animation_eb3da") } -[sub_resource type="RectangleShape2D" id="RectangleShape2D_u7cw4"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_qydbd"] size = Vector2(32, 10) [node name="SlashProjectile" type="Node2D" unique_id=541992074] script = ExtResource("1_bi0sp") -[node name="Attack" type="Sprite2D" parent="." unique_id=30274790] -position = Vector2(16, -3) -texture = ExtResource("1_3il12") -hframes = 3 - [node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1896907748] unique_name_in_owner = true libraries/ = SubResource("AnimationLibrary_12t1i") autoplay = &"attack" -[node name="Hitbox" type="Area2D" parent="." unique_id=133086557] -collision_layer = 8 -collision_mask = 4 +[node name="Hitbox" parent="." unique_id=1918418417 instance=ExtResource("2_bi0sp")] -[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" unique_id=1668475985] -position = Vector2(21, -5) -shape = SubResource("RectangleShape2D_u7cw4") -disabled = true -debug_color = Color(0.99430805, 0, 0.2314094, 0.41960785) +[node name="CollisionShape2D" parent="Hitbox" index="0" unique_id=2048987579] +position = Vector2(23, -7) +shape = SubResource("RectangleShape2D_qydbd") [connection signal="body_entered" from="Hitbox" to="." method="OnHitboxBodyEntered"] + +[editable path="Hitbox"]