Adds a modifier system allowing dynamic modification of weapon stats and behavior. This includes: - Creating ModifierLibrary to manage available modifiers. - Adds ModifierManager to handle equipping and unequipping modifiers - Adds a new RangedWeaponComponent to handle firing projectiles and managing modifiers. - Introduces a DebugUI for in-game modifier management. - Introduces an "Unlimited Power" modifier that changes the projectile scene. - Modifies stats components to work with the new modifier system. This system allows for more flexible and customizable weapon functionality.
80 lines
3 KiB
GDScript
80 lines
3 KiB
GDScript
extends Node
|
|
|
|
class_name MapBuilderClass
|
|
|
|
# Function to copy a TileMap layer from one scene to a target TileMap at a specific grid position
|
|
func copy_tilemap_to_target(source_scene, target_tilemap: TileMapLayer, target_layer: String, grid_position: Vector2i):
|
|
# First, load and instantiate the source scene if it's a resource path
|
|
var source_instance
|
|
if source_scene is String:
|
|
source_instance = load(source_scene).instantiate()
|
|
elif source_scene is PackedScene:
|
|
source_instance = source_scene.instantiate()
|
|
else:
|
|
source_instance = source_scene
|
|
|
|
# Find the source TileMap in the loaded scene
|
|
var source_tilemap = find_tilemap_by_name(source_instance, target_layer)
|
|
if not source_tilemap:
|
|
push_error("Could not find TileMapLayer in source scene", source_tilemap)
|
|
if source_instance is Node and source_instance.is_inside_tree():
|
|
source_instance.queue_free()
|
|
return
|
|
|
|
# Get the size of the source room in tiles
|
|
var source_used_cells = source_tilemap.get_used_cells() # 0 is the layer index
|
|
if source_used_cells.size() == 0:
|
|
push_warning("Source TileMapLayer has no cells")
|
|
if source_instance is Node and source_instance.is_inside_tree():
|
|
source_instance.queue_free()
|
|
return
|
|
|
|
# Calculate the offset for placement in the target grid
|
|
var offset_x = grid_position.x * Global.ROOM_WIDTH
|
|
var offset_y = grid_position.y * Global.ROOM_HEIGHT
|
|
|
|
# Copy cells from source to target with proper offset
|
|
for cell in source_used_cells:
|
|
var target_cell = Vector2i(cell.x + offset_x, cell.y + offset_y)
|
|
|
|
# Get the tile data from source
|
|
#var source_tile_data = source_tilemap.get_cell_tile_data(cell)
|
|
var source_atlas_coords = source_tilemap.get_cell_atlas_coords(cell)
|
|
var source_alternative_tile = source_tilemap.get_cell_alternative_tile(cell)
|
|
|
|
# Set the same tile in the target TileMap
|
|
target_tilemap.set_cell(target_cell, source_tilemap.get_cell_source_id(cell), source_atlas_coords, source_alternative_tile)
|
|
|
|
|
|
# Clean up the source instance if we instantiated it
|
|
if source_instance is Node and source_instance.is_inside_tree():
|
|
source_instance.queue_free()
|
|
|
|
|
|
# Helper function to find a TileMap by name in a scene
|
|
func find_tilemap_by_name(root_node: Node, tilemap_name: String) -> TileMapLayer:
|
|
if root_node is TileMapLayer and root_node.name == tilemap_name:
|
|
return root_node
|
|
|
|
for child in root_node.get_children():
|
|
var result = find_tilemap_by_name(child, tilemap_name)
|
|
if result:
|
|
return result
|
|
|
|
return null
|
|
|
|
|
|
func redraw_terrain(positions: Array, layer: TileMapLayer, terrain_set: int, terrain: int) -> void:
|
|
# Filter positions to only include cells with terrainset 0 and terrain 0
|
|
var filtered_positions: Array = []
|
|
for cell in positions:
|
|
var tile_data = layer.get_cell_tile_data(cell)
|
|
|
|
if tile_data and tile_data.get_terrain_set() == terrain_set and tile_data.get_terrain() == terrain:
|
|
filtered_positions.append(cell)
|
|
|
|
# Only redraw if we have filtered cells
|
|
if filtered_positions.size() > 0:
|
|
layer.set_cells_terrain_connect(filtered_positions, terrain_set, terrain)
|
|
else:
|
|
Log.pr("No tiles to redraw after filtering")
|