Skip to content

Commit

Permalink
handle unclaimed creatures in cryopods if the cryopod has no owner ne…
Browse files Browse the repository at this point in the history
…ither
  • Loading branch information
cadon committed Apr 21, 2023
1 parent 62b3ea9 commit 3f60040
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions SavegameToolkit/ArkSavegame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,20 @@ private void extractBinaryObjectCryopods(ReadingOptions options)
{
// if a creature is cryoed and unclaimed, determine the owner of the container the cryopod is in and set that as the owner
var ownerInventoryProperty = cryo.GetPropertyValue<ObjectReference>("OwnerInventory");
if (!soulTrapContainer.TryGetValue(ownerInventoryProperty.ObjectId, out var ownerString))
if (ownerInventoryProperty != null)
{
var inventoryObject = Objects.FirstOrDefault(o => o.Id == ownerInventoryProperty.ObjectId);
ownerString = inventoryObject?.Parent?.GetPropertyValue<string>("OwnerName");
soulTrapContainer[ownerInventoryProperty.ObjectId] = ownerString;
}

if (!string.IsNullOrEmpty(ownerString))
{
storedGameObjects[0].Properties.Add(new PropertyString("TribeName", ownerString));
if (!soulTrapContainer.TryGetValue(ownerInventoryProperty.ObjectId, out var ownerString))
{
var inventoryObject =
Objects.FirstOrDefault(o => o.Id == ownerInventoryProperty.ObjectId);
ownerString = inventoryObject?.Parent?.GetPropertyValue<string>("OwnerName");
soulTrapContainer[ownerInventoryProperty.ObjectId] = ownerString;
}

if (!string.IsNullOrEmpty(ownerString))
{
storedGameObjects[0].Properties.Add(new PropertyString("TribeName", ownerString));
}
}
}
}
Expand Down

0 comments on commit 3f60040

Please sign in to comment.