Hi there, currently i have some problems to access the inventory from each chest.
To be honest, i dont see my problem. May anyone else?
Here you see looking for ZDO's and check for chest (Thats working, finding all chests which a person has build).
Then try "List < ItemDrop . ItemData >" and access the inventory of each chest. There its crashing.
Would be so great if someone knows or see my problem^^
List<ZDO> ZDOs = ZDOMan.instance.GetSaveClone();
foreach (var obj in ZDOs)
{
var pref1 = obj.GetPrefab();
if (pref1 != 0)
{
GameObject prefab2 = global::ZNetScene.instance.GetPrefab(pref1);
if ((bool)(UnityEngine.Object)prefab2)
{
if (prefab2.name.Contains("chest"))
{
global::Container spawnedObject = prefab2.GetComponent<global::Container>();
GameObject prefab = ZNetScene.instance.GetPrefab(spawnedObject.name);
if ((bool)(UnityEngine.Object)prefab)
{
global::Container comp = prefab.GetComponent<global::Container>();
// found all my chest's
// Unitil here all working...
List<ItemDrop.ItemData> items = comp.GetInventory().GetAllItems();
foreach(ItemDrop.ItemData item in items)
{
var itemname = item.m_shared.m_name;
}
}
}
}
}
}
Nice regards.