feat: Establish initial game structure including lobby, UI, and core gameplay managers.

This commit is contained in:
Yogi Wiguna
2026-02-02 15:01:30 +08:00
parent 9201c99d42
commit 66d34d0d29
21 changed files with 1688 additions and 1475 deletions
+80 -3
View File
@@ -130,6 +130,13 @@ func _run_ai_tick():
print("[BotController] Action Taken: Put (Priority)")
return
# Priority 0: Attack Mode (Aggressive Chase)
if actor.get("is_attack_mode"):
print("[BotController] Attack Mode Active! Hunting targets...")
if await _try_attack_chase():
print("[BotController] Action Taken: Attack Pursuit")
return
# Priority 1: Use power-up sabotage if conditions are met
if await _try_use_powerup():
print("[BotController] Action Taken: PowerUp")
@@ -175,6 +182,10 @@ func _try_use_powerup() -> bool:
var powerup_manager = actor.get_node_or_null("PowerUpManager")
if not powerup_manager or not powerup_manager.can_use_special():
return false
# PREVENT LOOP: If already in Attack Mode, do not try to use it again
if actor.get("is_attack_mode"):
return false
# Evaluate sabotage opportunity
var eval = strategic_planner.evaluate_sabotage_opportunity()
@@ -185,7 +196,21 @@ func _try_use_powerup() -> bool:
_is_processing_action = true
_current_action = "sabotaging"
var success = powerup_manager.use_special_effect()
# 50/50 Chance: Attack Mode vs Spawn Item
var success = false
if rng.randf() > 0.5:
# Attack Mode
success = powerup_manager.use_special_effect()
print("[BotController] %s chose ATTACK MODE." % actor.name)
else:
# Spawn Item (if supported)
if powerup_manager.has_method("spawn_boost_reward"):
success = powerup_manager.spawn_boost_reward()
print("[BotController] %s chose SPAWN ITEM." % actor.name)
else:
# Fallback to attack mode if method missing
success = powerup_manager.use_special_effect()
if success:
print("[BotController] %s used power-up (reason: %s)" % [actor.name, eval.reason])
NotificationManager.send_message(actor, NotificationManager.MESSAGES.USED_SPECIAL_POWER, NotificationManager.MessageType.POWERUP)
@@ -197,6 +222,58 @@ func _try_use_powerup() -> bool:
_current_action = "idle"
return success
# =============================================================================
# Attack Mode Logic (Aggressive Chase)
# =============================================================================
func _try_attack_chase() -> bool:
"""Find nearest player and move towards them to RAM them."""
var victim = _find_nearest_victim()
if not victim:
# No victim found? Just behave normally (grab tiles etc)
return false
# Pathfind to victim
var path = enhanced_gridmap.find_path(
Vector2(actor.current_position),
Vector2(victim.current_position),
0,
false,
false
)
if path.size() >= 2:
var next_step = Vector2i(path[1].x, path[1].y)
# Move to next step (If occupied by victim, movement_manager will trigger PUSH)
if actor.movement_manager.simple_move_to(next_step):
_is_processing_action = true
_current_action = "attacking"
await _wait_with_variance(action_delay) # Shorter delay for attacks? perhaos
if not is_instance_valid(self): return true
_is_processing_action = false
_current_action = "idle"
return true
return false
func _find_nearest_victim() -> Node3D:
var best_dist = 9999.0
var best_victim = null
var players = get_tree().get_nodes_in_group("Players")
for p in players:
if p == actor or p.is_in_group("Spectators"):
continue
# Dist check
var dist = abs(p.current_position.x - actor.current_position.x) + abs(p.current_position.y - actor.current_position.y)
if dist < best_dist:
best_dist = dist
best_victim = p
return best_victim
# =============================================================================
# Grab Tiles
# =============================================================================
@@ -550,8 +627,8 @@ func _handle_goal_completion():
goals_cycle_manager.on_goal_completed(actor, time_remaining)
var powerup_manager = actor.get_node_or_null("PowerUpManager")
if powerup_manager:
powerup_manager.add_goal_completion_reward()
# if powerup_manager:
# powerup_manager.add_goal_completion_reward()
print("[BotController] %s COMPLETED GOAL!" % actor.name)