Just curious about our Structs?

Can someone please explain why we have two structs?

        public struct InventorySlot
        {
            public InventoryItem item;
            public int number;
        }

And almost exact duplicate

        private struct InventorySlotRecord
        {
            public string itemID;
            public int number;
        }

Why were we unable to use the same struct?

Thanks

1 Like

The InventorySlot is used during game play, and contains a direct reference to the InventoryItem that is in the slot. Our saving system, however, cannot serialize that reference, it’s far too complex. (In fact, even if you saved a memory pointer to where the item is located, there is no guarantee that the next run the item would be in the same memory location).

Our saving system needs something a bit simpler, so for this, we’re using the itemID of the Inventory item. CaptureState gets the ItemID, and RestoreState uses the ItemID to load the correct Inventory Item.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms