Skip to content

Commit

Permalink
5.0.0.17
Browse files Browse the repository at this point in the history
  • Loading branch information
miragedmuk committed Feb 4, 2024
1 parent bd03951 commit 8d6d603
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 74 deletions.
7 changes: 6 additions & 1 deletion ASVPack/Extensions/AsaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ public static long GetDinoId(this AsaGameObject gameObject)

public static long CreateDinoId(int id1, int id2)
{
return (long)id1 << 32 | (id2 & 0xFFFFFFFFL);
string newDinoId = string.Concat(id1, id2);
long.TryParse(newDinoId, out long dinoId);

return dinoId;

//return (long)id1 << 32 | (id2 & 0xFFFFFFFFL);
}
public static ContentTribe AsTribe(this AsaObject tribeObject)
{
Expand Down
65 changes: 34 additions & 31 deletions ASVPack/Models/ContentContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,52 +2403,55 @@ private void LoadArkAscendedData(string saveFilename)
List<dynamic>? equippedItemsArray = inventoryComponent.GetPropertyValue<dynamic>("EquippedItems");
if (equippedItemsArray != null)
{
}
if (x.ClassString == "TekStrider_Character_BP_C")
{
AsaGameObject rig1Object = equippedItemsArray[0];
if (rig1Object != null)
{
var itemRig1 = rig1Object.AsItem();
creature.Rig1 = itemRig1?.ClassName??"";
}
List<dynamic>? equippedItemsArray = inventoryComponent.GetPropertyValue<dynamic>("EquippedItems");
if (equippedItemsArray.Count > 1)
{
AsaGameObject rig2Object = equippedItemsArray[1];
var itemRig2 = rig2Object.AsItem();
creature.Rig2 = itemRig2?.ClassName??"";
}
if (equippedItemsArray != null)
{
if (x.ClassString == "TekStrider_Character_BP_C")
{
AsaGameObject rig1Object = equippedItemsArray[0];
if (rig1Object != null)
{
var itemRig1 = rig1Object.AsItem();
creature.Rig1 = itemRig1?.ClassName ?? "";
}
else
if (equippedItemsArray.Count > 1)
{
//Parallel.ForEach(equippedItemsArray, objectReference =>
foreach (var objectReference in equippedItemsArray)
AsaGameObject rig2Object = equippedItemsArray[1];
var itemRig2 = rig2Object.AsItem();
creature.Rig2 = itemRig2?.ClassName ?? "";
}
}
else
{
//Parallel.ForEach(equippedItemsArray, objectReference =>
foreach (var objectReference in equippedItemsArray)
{
Guid itemId = Guid.Parse(objectReference.Value);
AsaGameObject itemObject = arkSavegame.GetObjectByGuid(itemId);
if (itemObject != null)
{
Guid itemId = Guid.Parse(objectReference.Value);
AsaGameObject itemObject = arkSavegame.GetObjectByGuid(itemId);
if (itemObject != null)
var item = itemObject.AsItem();
if (!item.IsEngram)
{
var item = itemObject.AsItem();
if (!item.IsEngram)
{
inventoryItems.Add(item);
}
inventoryItems.Add(item);
}
}
//);
}
//);
}
}
creature.Inventory = new ContentInventory() { Items = inventoryItems.ToList() };
creature.Inventory = new ContentInventory() { Items = inventoryItems.ToList() };
}
}
}
inventoryItems.Clear();
Expand Down
7 changes: 7 additions & 0 deletions ASVPack/Models/ContentPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,13 @@ public void ExportJsonTamed(string exportFilename)
jw.WriteValue(creature.TamedOnServerName);


jw.WritePropertyName("uploadedServer");
jw.WriteValue(creature.UploadedServerName??"");

jw.WritePropertyName("maturation");
jw.WriteValue(creature.Maturation.ToString());


if (creature.UploadedTimeInGame != 0)
{
jw.WritePropertyName("uploadedTime");
Expand Down
7 changes: 4 additions & 3 deletions ASVPack/Models/ContentTamedCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class ContentTamedCreature : ContentCreature
[DataMember] public int RandomMutationsFemale { get; set; } = 0;
[DataMember] public int RandomMutationsMale { get; set; } = 0;
[DataMember] public string TamedOnServerName { get; set; } = "";
[DataMember] public string UploadedServerName { get; set; } = "";

[DataMember] public byte[] TamedStats { get; set; }
[DataMember] public byte[] TamedMutations { get; set; }

Expand Down Expand Up @@ -131,9 +133,6 @@ public ContentTamedCreature(double uploadTime, GameObject creatureObject, GameOb
}





//ancestors
var parents = creatureObject.GetTypedProperty<PropertyArray>("DinoAncestors");
if (parents != null)
Expand Down Expand Up @@ -320,6 +319,8 @@ public ContentTamedCreature(AsaGameObject creatureObject, AsaGameObject statusOb


TamedOnServerName = creatureObject.GetPropertyValue<string>("TamedOnServerName", 0, "") ?? "";
UploadedServerName = creatureObject.GetPropertyValue<string>("UploadedFromServerName", 0, "") ?? "";

TamerName = creatureObject.GetPropertyValue<string>("TamerString", 0, "") ?? "";

ImprintedPlayerId = (long)creatureObject.GetPropertyValue<ulong>("ImprinterPlayerDataID", 0, 0);
Expand Down
33 changes: 31 additions & 2 deletions AsaSavegameToolkit/AsaSavegameToolkit/AsaGameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,42 @@ public AsaGameObject(AsaArchive archive)
//readProperties(archive);
}


private dynamic? GetPropertyValue<T>(string name, int index = 0, dynamic? defaultValue = null)
{
foreach (var prop in Properties)
{
if (prop.Position == index && prop.Name == name)
{
return prop.Value;
}
}

return defaultValue;
}



public AsaGameObject(List<AsaProperty<dynamic>> properties)
{
Guid = Guid.NewGuid();
Properties = properties;

AsaObjectReference? classRef = GetPropertyValue<AsaObjectReference?>("ItemArchetype", 0, null);
if (classRef != null)
{
ClassName = AsaName.From(classRef.Value);
}

IsItem = true;
}

public AsaGameObject(Guid objectId, AsaArchive archive)
{
Guid = objectId;

ClassName = archive.ReadName();

IsItem = archive.ReadBool();
IsItem = archive.ReadBool();//? not isitem - always false?

int nameCount = archive.ReadInt();
Names.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private static object ReadSoftObjectPropertyValue(AsaArchive archive)
var objectName = archive.ReadName();
var objectValue = Convert.ToHexString(archive.ReadBytes(4));

return new AsaProperty<dynamic>(objectName.ToString(), "PropertyStr", 0, 0, objectValue);
return new AsaProperty<dynamic>(objectName?.ToString(), "PropertyStr", 0, 0, objectValue);
}


Expand Down
93 changes: 57 additions & 36 deletions AsaSavegameToolkit/AsaSavegameToolkit/AsaSavegame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -230,6 +231,8 @@ private void parseStoredCreatures()
AsaProperty<dynamic> customContainer = customProperties[0];
var byteListContainer = customContainer.Value;
AsaGameObject creatureObject = null;
for (int i = 0; i < byteListContainer.Count; i++)
{
Expand All @@ -250,41 +253,6 @@ private void parseStoredCreatures()
{
var dataStore = new AsaDataStore(dataBytes);
/*
if (dataStore.Objects.Count > 0)
{
AsaGameObject? statusComponent = dataStore.Objects.FirstOrDefault(o => o.Value.ClassString.ToLower().Contains("status")).Value;
AsaGameObject? creatureComponent = dataStore.Objects.FirstOrDefault(o => o.Value.ClassString.ToLower().Contains("character")).Value;
if (creatureComponent != null)
{
if (objectBag.ContainsKey(creatureComponent.Guid))
{
creatureComponent.Guid = Guid.NewGuid();
}
}
if (statusComponent != null)
{
if (objectBag.ContainsKey(statusComponent.Guid))
{
//already added, give it a new guid
statusComponent.Guid = Guid.NewGuid();
//then assign this to the creature
if (creatureComponent != null)
{
creatureComponent.Properties.RemoveAll(p => p.Name == "MyCharacterStatusComponent");
creatureComponent.Properties.Add(new Propertys.AsaProperty<dynamic>("MyCharacterStatusComponent", "ObjectProperty", 0, 0, new AsaObjectReference(statusComponent.Guid)));
}
}
}
}
*/
foreach (var o in dataStore.Objects)
{
Expand All @@ -301,7 +269,7 @@ private void parseStoredCreatures()
var podContainerInventory = GetObjectByGuid(Guid.Parse(containerId.Value));
if (podContainerInventory != null)
{
var podContainer = Objects.FirstOrDefault(o => o.Names[0] == podContainerInventory.Names[1]);
var podContainer = Objects.FirstOrDefault(o => o.Names!=null && o.Names.Count > 0 && o.Names[0] == podContainerInventory.Names[1]);
if (podContainer != null)
{
o.Value.Location = podContainer.Location;
Expand All @@ -311,10 +279,63 @@ private void parseStoredCreatures()
}
}
creatureObject = o.Value;
objectBag.TryAdd(o.Value.Guid, o.Value);
}
}
else
{
List<AsaProperty<dynamic>> properties = new List<AsaProperty<dynamic>>();
//skins/costumes/inventory
using(Stream stream = new MemoryStream(dataBytes))
{
using(AsaArchive dataArchive = new AsaArchive(stream))
{
var archiveVersion = dataArchive.ReadInt();
AsaProperty<dynamic>? prop = null;
try
{
prop = AsaPropertyRegistry.ReadProperty(dataArchive);
}catch
{
}
while(prop!=null)
{
properties.Add(prop);
try
{
prop = AsaPropertyRegistry.ReadProperty(dataArchive);
}
catch
{
break;
}
}
}
}
if(properties.Count > 0 && creatureObject!=null)
{
//DinoCharacterInventoryComponent_BP_Creature_C
//MyInventoryComponent
//add ownerinvnetory and equippeditem properties
//properties.Add(new AsaProperty<dynamic>("bEquippedItem", "BoolProperty", 0, 0, true));
//properties.Add(new AsaProperty<dynamic>("OwnerInventory", "ObjectProperty", 0, 0, new AsaObjectReference(inventoryGuid)));
AsaGameObject asaObject = new AsaGameObject(properties);
objectBag.TryAdd(asaObject.Guid, asaObject);
}
}
}
catch
Expand Down

0 comments on commit 8d6d603

Please sign in to comment.