1. How do you loop through the game items and change their properties.

    For example I'd like to loop through all the Ceiling Lights, refuel them and turn them on or off.

    I'd like to iterate through boxes as well.
     
  2. Code:
    var containers = GameObject.FindObjectsOfType<StorageContainer>();
                    for (int i = 0; i < containers.Length; i++)
                    {
                        var storage = containers[i];
                    }
    This will find all objects that are of the type StorageContainer. This includes large boxes, small boxes, lanterns, ceiling lights, etc. You can check the prefab name to see exactly what they are.


    Another way of finding these objects that is much much faster (but only allows for containers that are going to be saved, so if loot containers were caught in the above code, they won't be here I believe) and I don't think I've ever seen used aside from myself is:

    Code:
    foreach (var entry in BaseEntity.saveList)
                {
                    if (entry == null || entry.isDestroyed) continue;
                    var storage = entry?.GetComponent<StorageContainer>() ?? null;
                    if (storage == null ||  storage.inventory.itemList.Count <= 0) continue;
                    for (int i = 0; i < storage.inventory.itemList.Count; i++)
                    {
                        var item = storage.inventory.itemList[i];
                    }
                }
    Just don't modify the actual saveList directly, though I don't think you planned on doing that anyway. ;)
     
  3. Thank you!.