The container icons on top of furniture stays grey even if there are items in the container after a map is loaded.
Steps to reproduce:
start a new game, walk to the kitchen of a house and observe items in the cabinets. The container icon will be green
Use the overmap to travel to another location and then travel back to 0,0
Go to the same kitchen and observe grey icons for containers even when items are in them.
When a furniturestatic is loaded, it will deserialize the container inventory:
# It will deserialize the container data if the furniture is not new.
func deserialize_container_data():
if "items" in furnitureJSON["Function"]["container"]:
container.get_inventory().deserialize(furnitureJSON["Function"]["container"]["items"])
else:
print_debug("No items to deserialize in container for furniture ID: " + str(furnitureJSON.id))
Summary of Item Spawning in Containers
When a piece of furniture with container functionality is added to the scene, the following process occurs to manage item spawning:
Adding a Container Node:
The add_container(pos: Vector3) function checks if the furniture has a container functionality based on its JSON data.
If the furniture is confirmed to have a container function, a new ContainerItem node is created, initialized, and added as a child to the furniture.
Handling Container Population:
The handle_container_population() function determines whether the furniture is new or previously saved.
If the furniture is new, it populates the container with items from an assigned item group using the populate_container_from_itemgroup() function.
If the furniture is not new, it deserializes the existing container data using the deserialize_container_data() function.
Populating from Item Group:
The populate_container_from_itemgroup() function checks if an item group is assigned to the container in the furniture's data.
If an item group is found, it assigns this group to the container, which will use it to fill up with items.
If no item group is found, a debug message is printed.
Deserializing Container Data:
The deserialize_container_data() function checks for existing items in the container's data.
If items are found, they are deserialized and loaded into the container's inventory.
If no items are found, a debug message is printed.
The container icons on top of furniture stays grey even if there are items in the container after a map is loaded.
Steps to reproduce:
When a furniturestatic is loaded, it will deserialize the container inventory:
Summary of Item Spawning in Containers
When a piece of furniture with container functionality is added to the scene, the following process occurs to manage item spawning:
Adding a Container Node:
add_container(pos: Vector3)
function checks if the furniture has a container functionality based on its JSON data.ContainerItem
node is created, initialized, and added as a child to the furniture.Handling Container Population:
handle_container_population()
function determines whether the furniture is new or previously saved.populate_container_from_itemgroup()
function.deserialize_container_data()
function.Populating from Item Group:
populate_container_from_itemgroup()
function checks if an item group is assigned to the container in the furniture's data.Deserializing Container Data:
deserialize_container_data()
function checks for existing items in the container's data.