added a small storage contianer, fixed the damn item slot (i relly think they are done now)

This commit is contained in:
2026-06-05 22:42:20 -05:00
parent 0d39c2dfb4
commit 726f5052ac
11 changed files with 1721 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ extends StaticBody3D
@export var isFirstPlace = true
func _ready() -> void:
# Defers execution slightly to guarantee MeshInstance3D has finished mounting
initialize_material.call_deferred()
func initialize_material() -> void:
@@ -10,8 +11,13 @@ func initialize_material() -> void:
$MeshInstance3D.material_override.albedo_color = Color("00000041")
if isFirstPlace:
# Freshly placed machine in the world defaults to air
placeItem("base:air")
isFirstPlace = false
else:
# The machine was loaded from a save! Restore the data that was saved on the parent
if $"..".ItemID != "" and $"..".ItemID != "base:air":
placeItem($"..".ItemID)
func startHighlight():
$MeshInstance3D.material_override.albedo_color = Color("00FF0041")
@@ -30,6 +36,7 @@ func placeItem(ItemID: String):
$"..".ItemTexture = itemResource.texture
$"..".ItemID = itemResource.ID
# Mark initialized so it saves its state properly
isFirstPlace = false
func removeItem():
@@ -42,6 +49,6 @@ func _interact_press(isRight):
placeItem(MainGame.currentHeldItemID)
InventoryBus.removeHeldItem.emit()
elif isRight:
if $"..".ItemID != "base:air":
if $"..".ItemID != "base:air" and $"..".ItemID != "":
InventoryBus.givePlayerItem.emit($"..".ItemID)
removeItem()