Conveyor sideloading

This commit is contained in:
Rendo 2025-10-14 23:54:09 +05:00
commit 81451bd356
14 changed files with 243 additions and 17 deletions

View file

@ -4,6 +4,16 @@ extends Node2D
## Game object that interact with other structures in its grid space
class_name Structure
enum Facing {
UNDIRECTIONAL = 0,
RIGHT = 1,
DOWN = 2,
LEFT = 3,
UP = 4
}
signal switched_facing(to: Facing)
## Dimensions of structure in grid tiles
@export var dimensions : Rect2i = Rect2i(0,0,1,1):
set(value):
@ -15,6 +25,20 @@ class_name Structure
## Inventory of this structure
@export var inventory : Inventory
@export var facing : Facing
static func facing_to_vector(face : Facing) -> Vector2:
match face:
Facing.RIGHT:
return Vector2.RIGHT
Facing.LEFT:
return Vector2.LEFT
Facing.UP:
return Vector2.UP
Facing.DOWN:
return Vector2.DOWN
_:
return Vector2.ZERO
## Debug draw of points
func _draw() -> void:
@ -58,3 +82,9 @@ func get_dimension_points() -> Array[Vector2]:
for y in range(dimensions.size.y):
result[x + y * dimensions.size.x] = (Vector2(x,y)*Globals.GRID_SIZE + Vector2(dimensions.position))
return result
func cycle_up_facing() -> void:
if facing == Facing.UNDIRECTIONAL:
return
facing = wrapi(facing+1,1,5) as Facing
switched_facing.emit(facing)