added a small storage contianer, fixed the damn item slot (i relly think they are done now)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user