private static void AddSerializableLootContainer(SerializableLootContainer serializableObject) { if (Instance.serializableLootContainers.ContainsKey(serializableObject.LoadID)) { string message = string.Format(duplicateLoadIDErrorText, "AddSerializableLootContainer()", serializableObject.LoadID); DaggerfallUnity.LogMessage(message); return; } Instance.serializableLootContainers.Add(serializableObject.LoadID, serializableObject); }
public void RestoreLootContainerData(LootContainerData_v1[] lootContainers) { if (lootContainers == null || lootContainers.Length == 0) { return; } for (int i = 0; i < lootContainers.Length; i++) { // Skip null containers if (lootContainers[i] == null) { continue; } // Restore loot containers ulong key = lootContainers[i].loadID; if (SerializableLootContainers.ContainsKey(key)) { // Apply to known loot container that is part of scene build SerializableLootContainers[key].RestoreSaveData(lootContainers[i]); } else { // Add custom drop containers back to scene (e.g. dropped loot, slain foes) if (lootContainers[i].customDrop) { DaggerfallLoot customLootContainer = GameObjectHelper.CreateDroppedLootContainer(GameManager.Instance.PlayerObject, key, lootContainers[i].textureArchive, lootContainers[i].textureRecord); SerializableLootContainer serializableLootContainer = customLootContainer.GetComponent <SerializableLootContainer>(); if (serializableLootContainer) { serializableLootContainer.RestoreSaveData(lootContainers[i]); } //Debug.LogFormat("created loot container {0} containing {1} parent {2}", key, customLootContainer.Items.GetItem(0).shortName, customLootContainer.transform.parent.name); } } } }
void RestoreLootContainerData(LootContainerData_v1[] lootContainers) { if (lootContainers == null || lootContainers.Length == 0) { return; } for (int i = 0; i < lootContainers.Length; i++) { // Skip null containers if (lootContainers[i] == null) { continue; } // Restore loot containers ulong key = lootContainers[i].loadID; if (serializableLootContainers.ContainsKey(key)) { // Apply to known loot container that is part of scene build serializableLootContainers[key].RestoreSaveData(lootContainers[i]); } else { // Add custom drop containers back to scene (e.g. dropped loot, slain foes) if (lootContainers[i].customDrop) { DaggerfallLoot customLootContainer = GameObjectHelper.CreateDroppedLootContainer(GameManager.Instance.PlayerObject, key); SerializableLootContainer serializableLootContainer = customLootContainer.GetComponent <SerializableLootContainer>(); if (serializableLootContainer) { serializableLootContainer.RestoreSaveData(lootContainers[i]); } } } } }