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