rotation rework, deletion of complex objects

This commit is contained in:
Rendo 2025-10-16 19:47:52 +05:00
commit 8dcd7725a9
15 changed files with 103 additions and 147 deletions

View file

@ -1,7 +1,6 @@
extends StructureBehaviour
@export var selected_recipe : Recipe
@onready var inventory : InOutInventory = get_parent().inventory
func _ready() -> void:
inventory.stack_added.connect(check_for_recipe)
@ -23,13 +22,12 @@ func _process(_delta: float) -> void:
var output : Structure = get_output_structure()
if output == null:
return
var ang_diff = Globals.facing_difference(output.facing,structure_parent.facing)
var ang_diff = output.direction_difference(structure_parent)
if output.inventory.can_add_from_side(ang_diff):
inventory.output_slot.merge_stack(output.inventory.add_from_side(inventory.output_slot.extract(),ang_diff))
func get_output_structure() -> Structure:
var facing_direction = Structure.facing_to_vector(structure_parent.facing)
var rotated = Vector2(0.5,1.5).rotated(-Vector2.DOWN.angle_to(facing_direction))
var rotated = Vector2(1.5,-0.5).rotated(structure_parent.direction)
return structure_parent.get_relative(rotated+Vector2(0.5,0.5))
func check_for_recipe(_stack : Stack, _position : int) -> void: