Files
tekton/scripts/managers/obstacle_manager.gd
T

57 lines
1.5 KiB
GDScript

extends Node
# ObstacleManager - Handles obstacle placement and management
enum ObstacleOrientation {
NORTH = 0,
EAST = 1,
SOUTH = 2,
WEST = 3
}
var current_obstacle_orientation = ObstacleOrientation.NORTH
var current_obstacle_item = 12
var gridmap_ref # Reference to EnhancedGridMap
func initialize(gridmap):
gridmap_ref = gridmap
func place_obstacle(grid_position: Vector2i, local_player) -> bool:
if not local_player or local_player.action_points < 1:
return false
var floor_index = 3 # Always place on floor 3
var success = gridmap_ref.place_obstacle(
Vector3i(grid_position.x, floor_index, grid_position.y),
current_obstacle_item,
current_obstacle_orientation
)
if success:
local_player.action_points -= 1
return true
return false
func cycle_obstacle_orientation() -> String:
var orientations = [
ObstacleOrientation.NORTH,
ObstacleOrientation.EAST,
ObstacleOrientation.SOUTH,
ObstacleOrientation.WEST
]
var current_index = orientations.find(current_obstacle_orientation)
current_index = (current_index + 1) % orientations.size()
current_obstacle_orientation = orientations[current_index]
var direction_names = ["North", "East", "South", "West"]
return "Direction: " + direction_names[current_index]
func cycle_obstacle_type() -> String:
var obstacle_types = [12, 13, 14, 15]
var current_index = obstacle_types.find(current_obstacle_item)
current_index = (current_index + 1) % obstacle_types.size()
current_obstacle_item = obstacle_types[current_index]
return "Type: " + str(current_index + 1)