public static DotArkStruct ReadFromFile(DotArkDeserializer d, ArkClassName structType) { //Based on the type, open it. string typeName = structType.classname; DotArkStruct st; //First, we check known types for the struct property list. There could be other data, but it could fail. if (typeName == "ItemNetID" || typeName == "ItemNetInfo" || typeName == "Transform" || typeName == "PrimalPlayerDataStruct" || typeName == "PrimalPlayerCharacterConfigStruct" || typeName == "PrimalPersistentCharacterStatsStruct" || typeName == "TribeData" || typeName == "TribeGovernment" || typeName == "TerrainInfo" || typeName == "ArkInventoryData" || typeName == "DinoOrderGroup" || typeName == "ARKDinoData") { //Open this as a struct property list. st = new ArkStructProps(d, structType); } else if (typeName == "Vector" || typeName == "Rotator") { //3d vector or rotor st = new ArkStructVector3(d.ms, structType); } else if (typeName == "Vector2D") { //2d vector st = new ArkStructVector2(d.ms, structType); } else if (typeName == "Quat") { //Quat st = new ArkStructQuat(d.ms, structType); } else if (typeName == "Color") { //Color st = new ArkStructColor(d.ms, structType); } else if (typeName == "LinearColor") { //Linear color st = new ArkStructLinearColor(d.ms, structType); } else if (typeName == "UniqueNetIdRepl") { //Some net stuff st = new ArkStructUniqueNetId(d.ms, structType); } else { //Interpet this as a struct property list. Maybe raise a warning later? //Console.WriteLine($"Unknown struct type '{typeName}'. Interpeting as struct property list."); st = new ArkStructProps(d, structType); } return(st); }
public ArkPrimalItem(ArkWorld world, DotArkGameObject orig) : base(world, orig) { //Check if this is claimed not to be an item if (!isItem) { throw new Exception("Cannot read ArkPrimalItem when property 'isItem' is false!"); } //Read in values. Start with values that will never be null classname = orig.classname.classname; stackSize = 1; if (orig.PropExistsName("ItemQuantity")) { stackSize = (int)orig.GetPropByName("ItemQuantity").data; } owner = new HighLevelArkGameObjectRef(world, (orig.GetPropsByName <ObjectProperty>("OwnerInventory")[0]).gameObjectRef); //Convert ItemID ArkStructProps itemIdStruct = (ArkStructProps)orig.GetPropsByName <StructProperty>("ItemId")[0].structData; byte[] buf = new byte[8]; BitConverter.GetBytes((UInt32)itemIdStruct.props_string["ItemID1"].data).CopyTo(buf, 0); BitConverter.GetBytes((UInt32)itemIdStruct.props_string["ItemID2"].data).CopyTo(buf, 4); itemId = BitConverter.ToUInt64(buf, 0); //Read booleans isBlueprint = GetBooleanProperty("bIsBlueprint"); isEngram = GetBooleanProperty("bIsEngram"); //Read props that may not exist if (CheckIfValueExists("SavedDurability")) { savedDurability = GetFloatProperty("SavedDurability"); } else { savedDurability = 1; } if (CheckIfValueExists("CrafterCharacterName")) { crafterName = GetStringProperty("CrafterCharacterName"); } else { crafterName = null; } if (CheckIfValueExists("CrafterTribeName")) { crafterTribe = GetStringProperty("CrafterTribeName"); } else { crafterTribe = null; } if (CheckIfValueExists("LastAutoDurabilityDecreaseTime")) { lastDurabilityDecreaseTime = (double)orig.GetPropsByName <DoubleProperty>("LastAutoDurabilityDecreaseTime")[0].data; } else { lastDurabilityDecreaseTime = -1; } }