public void RestoreSaveData(object dataIn) { if (!loot) { return; } LootContainerData_v1 data = (LootContainerData_v1)dataIn; if (data.loadID != LoadID) { return; } DaggerfallBillboard billboard = loot.GetComponent <DaggerfallBillboard>(); // Restore position loot.transform.position = data.currentPosition; // Restore appearance if (MeshReplacement.ImportCustomFlatGameobject(data.textureArchive, data.textureRecord, Vector3.zero, loot.transform)) { // Use imported model instead of billboard if (billboard) { Destroy(billboard); } Destroy(GetComponent <MeshRenderer>()); } else if (billboard) { // Restore billboard appearance if present billboard.SetMaterial(data.textureArchive, data.textureRecord); } // Restore items loot.Items.DeserializeItems(data.items); // Restore other data loot.ContainerType = data.containerType; loot.ContainerImage = data.containerImage; loot.LootTableKey = data.lootTableKey; loot.TextureArchive = data.textureArchive; loot.TextureRecord = data.textureRecord; loot.playerOwned = data.playerOwned; loot.customDrop = data.customDrop; loot.name = loot.ContainerType.ToString(); loot.entityName = data.entityName; loot.isEnemyClass = data.isEnemyClass; // Remove loot container if empty if (loot.Items.Count == 0) { GameObjectHelper.RemoveLootContainer(loot); } }
public void RestoreSaveData(object dataIn) { if (!loot) { return; } LootContainerData_v1 data = (LootContainerData_v1)dataIn; if (data.loadID != LoadID) { return; } DaggerfallBillboard billboard = loot.GetComponent <DaggerfallBillboard>(); // Restore position loot.transform.position = data.currentPosition; // Restore billboard appearance if present if (billboard) { billboard.SetMaterial(data.textureArchive, data.textureRecord); // Setup custom material if available if (TextureReplacement.CustomTextureExist(data.textureArchive, data.textureRecord)) { TextureReplacement.SetBillboardCustomMaterial(billboard.gameObject, data.textureArchive, data.textureRecord); } } // Restore items loot.Items.DeserializeItems(data.items); // Restore other data loot.ContainerType = data.containerType; loot.ContainerImage = data.containerImage; loot.LootTableKey = data.lootTableKey; loot.TextureArchive = data.textureArchive; loot.TextureRecord = data.textureRecord; loot.playerOwned = data.playerOwned; loot.customDrop = data.customDrop; loot.name = loot.ContainerType.ToString(); // Remove loot container if empty if (loot.Items.Count == 0) { GameObjectHelper.RemoveLootContainer(loot); } }
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]); } } } } }
public void RestoreSaveData(object dataIn) { if (!loot) { return; } LootContainerData_v1 data = (LootContainerData_v1)dataIn; if (data.loadID != LoadID) { return; } // Restore billboard only if this is a billboard-based loot container if (loot.ContainerType == LootContainerTypes.RandomTreasure || loot.ContainerType == LootContainerTypes.CorpseMarker || loot.ContainerType == LootContainerTypes.DroppedLoot) { DaggerfallBillboard billboard = loot.GetComponent <DaggerfallBillboard>(); // Interiors and exteriors need special handling to ensure loot is always placed correctly for pre and post floating y saves // Dungeons are not involved with floating y and don't need any changes WorldContext lootContext = GetLootWorldContext(loot); if (lootContext == WorldContext.Interior) { RestoreInteriorPositionHandler(loot, data, lootContext); } else if (lootContext == WorldContext.Exterior) { RestoreExteriorPositionHandler(loot, data, lootContext); } else { loot.transform.position = data.currentPosition; } // Restore appearance if (MeshReplacement.SwapCustomFlatGameobject(data.textureArchive, data.textureRecord, loot.transform, Vector3.zero, lootContext == WorldContext.Dungeon)) { // Use imported model instead of billboard if (billboard) { Destroy(billboard); } Destroy(GetComponent <MeshRenderer>()); } else if (billboard) { // Restore billboard appearance if present billboard.SetMaterial(data.textureArchive, data.textureRecord); } } // Restore items loot.Items.DeserializeItems(data.items); // Restore other data loot.ContainerType = data.containerType; loot.ContainerImage = data.containerImage; loot.TextureArchive = data.textureArchive; loot.TextureRecord = data.textureRecord; loot.stockedDate = data.stockedDate; loot.playerOwned = data.playerOwned; loot.customDrop = data.customDrop; loot.entityName = data.entityName; loot.isEnemyClass = data.isEnemyClass; // Remove loot container if empty if (loot.Items.Count == 0) { GameObjectHelper.RemoveLootContainer(loot); } }