Compare commits
No commits in common. "eab885b9d3027ca020eccdbd5e9984ee2a040130" and "c566936cfc8950a7b4f3dc3667b039349d85ad17" have entirely different histories.
eab885b9d3
...
c566936cfc
11 changed files with 7 additions and 23 deletions
|
@ -20,7 +20,7 @@ config/icon="res://icon.svg"
|
|||
GuiEventBus="*res://scripts/gui/gui_event_bus.gd"
|
||||
RuntimePlayerData="*res://scripts/autoloads/runtime_player_data.gd"
|
||||
Registry="*res://scripts/autoloads/registry.gd"
|
||||
BeltManager="*res://scripts/autoloads/belt_manager.gd"
|
||||
ConveyorManager="*res://scripts/autoloads/conveyor_manager.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
[ext_resource type="Texture2D" uid="uid://gfkhedfdi7ug" path="res://sprites/atlasses/Popekko.png" id="1_kqxj7"]
|
||||
[ext_resource type="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/structure.gd" id="1_y326v"]
|
||||
[ext_resource type="Script" uid="uid://bd4ojfqrl8idm" path="res://scripts/inventory/inventory_slot.gd" id="2_54w8r"]
|
||||
[ext_resource type="Script" uid="uid://v0hkuo3gda1b" path="res://scripts/inventory/belt_inventory.gd" id="3_ruvuk"]
|
||||
[ext_resource type="Script" uid="uid://bp341eiwvfvyl" path="res://scripts/structures/belt.gd" id="5_54w8r"]
|
||||
[ext_resource type="Script" uid="uid://v0hkuo3gda1b" path="res://scripts/inventory/conveyor_inventory.gd" id="3_ruvuk"]
|
||||
[ext_resource type="Script" uid="uid://bp341eiwvfvyl" path="res://scripts/structures/conveyor.gd" id="5_54w8r"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_t4je2"]
|
||||
resource_local_to_scene = true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@tool
|
||||
extends Inventory
|
||||
|
||||
class_name BeltInventory
|
||||
class_name ConveyorInventory
|
||||
|
||||
## Amount of stacks that can be held in storage
|
||||
@export var capacity : int:
|
|
@ -13,14 +13,10 @@ func _init() -> void:
|
|||
## Tries to add an item into inventory. Returns not stored stack of item.
|
||||
@abstract
|
||||
func add(stack : Stack) -> Stack
|
||||
@abstract
|
||||
func add_from_side(stack : Stack, ang_diff : float) -> Stack
|
||||
|
||||
## Returns if conditions of adding are met
|
||||
@abstract
|
||||
func can_add() -> bool
|
||||
@abstract
|
||||
func can_add_from_side(ang_diff : float) -> bool
|
||||
|
||||
## Tries to take first item. Returns null if no items in inventory
|
||||
@abstract
|
||||
|
|
|
@ -44,18 +44,12 @@ func add(stack: Stack) -> Stack:
|
|||
return null
|
||||
return stack
|
||||
|
||||
func add_from_side(stack : Stack, _ang_diff : float) -> Stack:
|
||||
return add(stack)
|
||||
|
||||
func can_add() -> bool:
|
||||
for i in range(capacity):
|
||||
if internal_array[i].amount == 0:
|
||||
return true
|
||||
return false
|
||||
|
||||
func can_add_from_side(_ang_diff : float) -> bool:
|
||||
return can_add()
|
||||
|
||||
## Tries to take first item. Returns null if no items in inventory
|
||||
func pop() -> Stack:
|
||||
if internal_array[0].held_item == null:
|
||||
|
|
|
@ -48,18 +48,12 @@ func add(stack: Stack) -> Stack:
|
|||
return null
|
||||
return stack
|
||||
|
||||
func add_from_side(stack : Stack, _ang_diff : float) -> Stack:
|
||||
return add(stack)
|
||||
|
||||
func can_add() -> bool:
|
||||
for i in range(capacity):
|
||||
if internal_array[i].amount == 0:
|
||||
return true
|
||||
return false
|
||||
|
||||
func can_add_from_side(_ang_diff : float) -> bool:
|
||||
return can_add()
|
||||
|
||||
## Tries to take first item. Returns null if no items in inventory
|
||||
func pop() -> Stack:
|
||||
for i in range(len(internal_array)):
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
extends Node2D
|
||||
|
||||
@onready var parent_structure : Structure = get_parent()
|
||||
@onready var inventory : BeltInventory = parent_structure.inventory
|
||||
@onready var inventory : ConveyorInventory = parent_structure.inventory
|
||||
@onready var animator : AnimationPlayer = $"../AnimationPlayer"
|
||||
|
||||
func _ready() -> void:
|
||||
sync_animations.call_deferred()
|
||||
|
||||
func sync_animations() -> void:
|
||||
animator.seek(BeltManager.sync_time,true)
|
||||
animator.seek(ConveyorManager.sync_time,true)
|
||||
|
||||
func _draw() -> void:
|
||||
for i in range(inventory.capacity):
|
||||
|
@ -20,7 +20,7 @@ func _process(delta: float) -> void:
|
|||
inventory.advance(delta)
|
||||
queue_redraw()
|
||||
var next : Structure = get_next()
|
||||
if next == null or next.inventory == null or next.inventory.can_add_from_side(Globals.facing_difference(next.facing,parent_structure.facing)) == false:
|
||||
if next == null or next.inventory.can_add_from_side(Globals.facing_difference(next.facing,parent_structure.facing)) == false:
|
||||
return
|
||||
var popped = inventory.pop()
|
||||
if popped == null:
|
Loading…
Add table
Add a link
Reference in a new issue