feat: Introduce SpecialTilesManager to manage special tile effects, including powerup inventory, leveling, cooldowns, and targeted abilities.

This commit is contained in:
Yogi Wiguna
2026-02-05 10:30:27 +08:00
parent 08b0493c06
commit 18128288d2
5 changed files with 103 additions and 44 deletions
+24 -39
View File
@@ -26,6 +26,8 @@ const FREEZE_SLOW_DURATION = 3.0
signal cooldown_updated(effect: int, time_left: float, max_time: float)
signal powerup_unlocked(effect: int, level: int)
var wall_orientation_horizontal: bool = false # False = Vertical, True = Horizontal
# New Helper functions for Targeting and Preview
func get_skill_affected_area(effect: int, center_pos: Vector2i) -> Array[Vector2i]:
@@ -46,13 +48,8 @@ func get_skill_affected_area(effect: int, center_pos: Vector2i) -> Array[Vector2
area.append(pos)
SpecialEffect.BLOCK_FLOOR:
# Logic: Perpendicular to player direction or based on major axis difference
var diff = center_pos - player.current_position
var is_horizontal = false
if abs(diff.x) > abs(diff.y):
is_horizontal = false # Vertical Column
else:
is_horizontal = true # Horizontal Row
# Logic: Based on toggled orientation state
var is_horizontal = wall_orientation_horizontal
if is_horizontal:
for x in range(enhanced_gridmap.columns):
@@ -226,9 +223,22 @@ func activate_effect(effect: int, target_player: Node3D = null):
if not (player.is_bot or player.is_in_group("Bots")):
var main = player.get_tree().get_root().get_node_or_null("Main")
if main and main.ui_manager:
# Toggle Logic for Wall Block
if main.ui_manager.current_action_state == main.ui_manager.ActionState.TARGETING and main.ui_manager.pending_skill_id == effect:
if effect == SpecialEffect.BLOCK_FLOOR:
toggle_wall_orientation()
powerup_cooldowns[effect] = 0.0 # Revert cooldown
emit_signal("cooldown_updated", effect, 0.0, 0.0)
return
main.ui_manager.current_action_state = main.ui_manager.ActionState.TARGETING
main.ui_manager.pending_skill_id = effect
NotificationManager.send_message(player, "Select a target area...", NotificationManager.MessageType.NORMAL)
var msg = "Select a target area..."
if effect == SpecialEffect.BLOCK_FLOOR:
msg = "Click again to toggle Vertical/Horizontal"
NotificationManager.send_message(player, msg, NotificationManager.MessageType.NORMAL)
# Do NOT set cooldown yet. Cooldown sets on execution.
# Revert the cooldown set above (hacky but handles the split flow)
powerup_cooldowns[effect] = 0.0
@@ -316,40 +326,15 @@ func _execute_area_freeze(center_pos: Vector2i = Vector2i.ZERO):
if main: main.rpc("sync_grid_item", pos.x, 0, pos.y, 0)
)
func toggle_wall_orientation():
wall_orientation_horizontal = !wall_orientation_horizontal
var mode_str = "HORIZONTAL" if wall_orientation_horizontal else "VERTICAL"
NotificationManager.send_message(player, "Wall Mode: " + mode_str, NotificationManager.MessageType.NORMAL)
func _execute_block_floor(target_pos: Vector2i):
# "Wall Block"
# Determine Row or Column based on click?
# Or let's imply orientation (North/South = Row, East/West = Column) relative to Player?
# Or just Row vs Column based on closest axis?
# Let's use simple logic: If click is further along X than Z from player, use Column(X), else Row(Z).
var is_horizontal = wall_orientation_horizontal
var diff = target_pos - player.current_position
var is_horizontal = false
if abs(diff.x) > abs(diff.y):
is_horizontal = false # Aligned with X axis roughly? Logic check:
# If I am at (0,0) and click (5,0), diff is (5,0). X is dominant.
# I want to block the vertical column at X=5? Or the horizontal row?
# Original logic "is_horizontal" meant blocking the Row (all X at fixed Z).
# If I click (5,0), I likely want to block that column or row?
# Let's default to blocking the axis perpendicular to where I'm looking/clicking?
pass
# Actually, simpler: Let's block the line that passes through the target point
# perpendicular to the direction from player to target.
# If I shoot North (change in Y/Z), I want a wall ACROSS (Row/X).
# If I shoot East (change in X), I want a wall ACROSS (Column/Z).
if abs(diff.x) > abs(diff.y):
# Target is East/West. I want a wall perpendicular -> Vertical (Fixed X, varying Z)
# Wait, "Column" in grid usually means Fixed X. "Row" means Fixed Z.
# So if X diff is big, I am shooting along X. I want a wall AT that X? No, I want a wall BLOCKING that X?
# Let's stick to the visual preview logic we will implement:
# If abs(diff.x) > abs(diff.y) -> Show Column (Vertical strip at target.x)
is_horizontal = false
else:
# Target is North/South. Show Row (Horizontal strip at target.y)
is_horizontal = true
var neighbors = []
if is_horizontal: