public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Write string ms.WriteUEString((string)data); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Write int ms.WriteInt((int)data); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Write the byte ms.ms.WriteByte((byte)data); }
/// <summary> /// Loads from a GameObject /// </summary> /// <returns></returns> public static ArkInventory LoadFromAsset(ArkWorld world, DotArkGameObject r) { //Get a list of all items List <ObjectProperty> inventoryItems; if (!r.PropExistsName("InventoryItems")) { inventoryItems = new List <ObjectProperty>(); } else { inventoryItems = ((ArrayProperty <ObjectProperty>)r.GetPropsByName("InventoryItems")[0]).items; } //Now, loop through and create items ArkInventory inventory = new ArkInventory(); inventory.items = new List <ArkPrimalItem>(); foreach (var o in inventoryItems) { ArkPrimalItem item = new ArkPrimalItem(world, o.gameObjectRef); if (item.isEngram) { continue; } inventory.items.Add(item); } //Return return(inventory); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //If the length is four, just write the objectID //TODO: Track the referenced GameObject so changing the index doesn't break this. if (size == 4) { ms.WriteInt(objectId); } else if (size >= 8) { //Write the type ms.WriteInt((int)objectRefType); //Depending on the type, write it if (objectRefType == ObjectPropertyType.TypeID) { ms.WriteInt(objectId); } else if (objectRefType == ObjectPropertyType.TypePath) { ms.WriteArkClassname(className, s); } else { throw new Exception("Unknown type of ObjectProperty."); } } else { throw new Exception($"Unknown ObjectProperty length, {size}. Cannot write."); } }
public override void WriteStruct(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { ms.WriteFloat(r); ms.WriteFloat(g); ms.WriteFloat(b); ms.WriteFloat(a); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Get name table entry ms.WriteArkClassname((ArkClassName)data, s); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Write the UInt64 ms.WriteULong((ulong)data); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { //For now, fake this and pretend this is an empty array //TODO: Add ArrayProperty to saveable properties. size = 4; base.WriteProp(s, go, f, ms); ms.WriteArkClassname(arrayType, s); ms.WriteInt(0); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Write the struct type ms.WriteArkClassname(structType, s); //Write the struct data. structData.WriteStruct(s, go, f, ms); }
void ReadGameObjectTable() { int gameObjectCount = ms.ReadInt(); gameObjects = new List <DotArkGameObject>(); for (int i = 0; i < gameObjectCount; i++) { gameObjects.Add(DotArkGameObject.ReadBaseFromFile(this)); } }
public HighLevelArkGameObjectRef(ArkWorld world, DotArkGameObject source) { this.source = source; this.world = world; this.guid = source.guid; this.classname = source.classname; this.classnameString = source.classname.classname; this.isItem = source.isItem; this.altNames = source.names; this.location = source.locationData; }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); byte value = 0; if ((bool)data) { value = 1; } //Write ms.WriteByte(value); }
static void WriteSingleGameObjectBody(IOMemoryStream ms, DotArkFile f, DotArkGameObject o, DotArkSerializerInstance si) { //Just start writing properties foreach (var prop in o.props) { prop.WriteProp(si, o, f, ms); } //Finally, write a None name to tell Ark that this is the end of the list of props. ms.WriteArkClassname(new ArkClassName { classname = "None", index = 0 }, si); }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Convert from Base64 string byte[] buf = Convert.FromBase64String((string)data); //If this does not match the length, die if (size != buf.Length) { throw new Exception("The size of the TextProperty did not match the real size, in bytes."); } //Write ms.ms.Write(buf, 0, size); }
public override void WriteStruct(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { //Write all of the props in the dict foreach (var p in props) { //Write property p.Value.WriteProp(s, go, f, ms); } //Finally, write a None type to stop Ark ms.WriteArkClassname(new ArkClassName { classname = "None", index = 0 }, s); }
public DotArkGameObject gameObjectRef; //Only exists if the above is ObjectPropertyType.TypeID public ObjectProperty(DotArkDeserializer d, int index, int length) { var ms = d.ms; //If the length is four (only seems to happen on version 5), this is an integer. if (length == 4) { objectRefType = ObjectPropertyType.TypeID; dataFilePosition = ms.position; objectId = ms.ReadInt(); } else if (length >= 8) { //Read type int type = ms.ReadInt(); if (type > 1 || type < 0) { throw new Exception($"Unknown ref type! Expected 0 or 1, but got {type} instead!"); } //Convert this to our enum objectRefType = (ObjectPropertyType)type; dataFilePosition = ms.position; //Depending on the type, read it in. if (objectRefType == ObjectPropertyType.TypeID) { objectId = ms.ReadInt(); } if (objectRefType == ObjectPropertyType.TypePath) { className = ms.ReadArkClassname(d); } } else { dataFilePosition = ms.position; throw new Exception($"Unknown object ref length! Expected 4 or >= 8, but got {length} instead."); } //If this is a type ID, I **THINK** this is a refrence to a GameObject if (objectRefType == ObjectPropertyType.TypeID) { if (objectId != -1) { gameObjectRef = d.gameObjects[objectId]; } } }
public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { base.WriteProp(s, go, f, ms); //Write enum name ms.WriteArkClassname(enumName, s); //If this is a normal byte, write the byte value. Else, write the classname if (isNormalByte) { ms.ms.WriteByte(byteValue); } else { ms.WriteArkClassname(enumValue, s); } }
public ArkPlayer(ArkWorld world, DotArkGameObject orig) : base(world, orig) { playerName = GetStringProperty("PlayerName"); steamName = GetStringProperty("PlatformProfileName"); arkId = GetUInt64Property("LinkedPlayerDataID"); //Read the struct containing Steam ID StructProperty sprop = (StructProperty)GetSingleProperty("PlatformProfileID"); ArkStructUniqueNetId nsprop = (ArkStructUniqueNetId)sprop.structData; steamId = nsprop.netId; //Tribe stuff if (HasProperty("TribeName")) { tribeName = GetStringProperty("TribeName"); tribeId = GetInt32Property("TargetingTeam"); isInTribe = true; } else { tribeName = "No Tribe"; tribeId = -1; isInTribe = false; } //Check if alive try { HighLevelArkGameObjectRef statusComponent = GetGameObjectRef("MyCharacterStatusComponent"); currentStats = ArkDinosaurStats.ReadStats(statusComponent, "CurrentStatusValues", false); isAlive = currentStats.health > 0.1f; } catch { isAlive = false; } }
public ArkStructure(ArkWorld world, DotArkGameObject orig, StructureDisplayMetadata displayMetadata) : base(world, orig) { tribeId = GetInt32Property("TargetingTeam"); isInTribe = true; hasInventory = HasProperty("MyInventoryComponent"); this.displayMetadata = displayMetadata; if (HasProperty("CurrentItemCount")) { currentItemCount = GetInt32Property("CurrentItemCount"); } if (HasProperty("MaxItemCount")) { currentItemCount = GetInt32Property("MaxItemCount"); } if (HasProperty("Health")) { currentHealth = GetFloatProperty("Health"); } if (HasProperty("MaxHealth")) { maxHealth = GetFloatProperty("MaxHealth"); } }
static void WriteHead(IOMemoryStream ms, DotArkFile f, DotArkSerializerInstance si, DotArkGameObject go, long propertyOffset) { //Write data according to https://us-central.assets-static-2.romanport.com/ark/#gameobject+base_header ms.WriteBytes(go.guid.ToByteArray()); //Write the GUID ms.WriteArkClassname(go.classname, si); //Write classname ms.WriteIntBool(go.isItem); //Write classname array ms.WriteInt(go.names.Count); foreach (var n in go.names) { ms.WriteArkClassname(n, si); } //Write unknowns ms.WriteIntBool(go.unknownData1); ms.WriteInt(go.unknownData2); //Write position data if it exists. ms.WriteIntBool(go.locationData != null); if (go.locationData != null) { ms.WriteLocationData(go.locationData); } //Write the offset to the properties data ms.WriteInt((int)propertyOffset); //Write last unknown data ms.WriteInt(go.unknownData3); }
public override void WriteStruct(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms) { ms.WriteInt(unk); ms.WriteUEString(netId); }
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; } }
public ArkDinosaur(ArkWorld world, DotArkGameObject orig) : base(world, orig) { //Grab the data and save it here. //Get the other components of this dinosaur. HighLevelArkGameObjectRef statusComponent = GetGameObjectRef("MyCharacterStatusComponent"); //Check if this dinosaur is tamed. isTamed = CheckIfValueExists("TamedName") && CheckIfValueExists("TribeName") && CheckIfValueExists("TargetingTeam"); //Grab the values that will exist on both tamed and untamed dinosaurs. isFemale = GetBooleanProperty("bIsFemale"); //Convert the colors into a byte array and hex. var colorAttrib = GetPropertiesByName("ColorSetIndices"); //Get all of the color properties from the dinosaur. These are indexes in the color table. colors = new byte[colorAttrib.Length]; //Initialize the array for storing the indexes. These will be saved to the file. colors_hex = new string[colorAttrib.Length]; //Initialize the array for reading nice HTML color values. for (int i = 0; i < colors.Length; i++) //For each color region this dinosaur has. Each "ColorSetIndices" value is a color region. { colors[i] = ((ByteProperty)colorAttrib[i]).byteValue; //Get the index in the color table by getting the byte value out of the property //Validate that the color is in range byte color = colors[i]; if (color <= 0 || color > ArkColorIds.ARK_COLOR_IDS.Length) { colors_hex[i] = "#FFF"; } else { colors_hex[i] = ArkColorIds.ARK_COLOR_IDS[colors[i] - 1]; //Look this up in the color table to get the nice HTML value. } } //Read the dinosaur ID by combining the the bytes of the two UInt32 values. byte[] buf = new byte[8]; BitConverter.GetBytes(GetUInt32Property("DinoID1")).CopyTo(buf, 0); BitConverter.GetBytes(GetUInt32Property("DinoID2")).CopyTo(buf, 4); //Convert this to a ulong dinosaurId = BitConverter.ToUInt64(buf, 0); //Read in levels currentStats = ArkDinosaurStats.ReadStats(statusComponent, "CurrentStatusValues", false); baseLevelupsApplied = ArkDinosaurStats.ReadStats(statusComponent, "NumberOfLevelUpPointsApplied", true); baseLevel = 1; if (statusComponent.CheckIfValueExists("BaseCharacterLevel")) { baseLevel = statusComponent.GetInt32Property("BaseCharacterLevel"); } level = baseLevel; //Now, convert attributes that only exist on tamed dinosaurs. isInTribe = isTamed; if (isTamed) { tamedName = GetStringProperty("TamedName"); tribeId = GetInt32Property("TargetingTeam"); tamerName = GetStringProperty("TribeName"); tamedLevelupsApplied = ArkDinosaurStats.ReadStats(statusComponent, "NumberOfLevelUpPointsAppliedTamed", true); if (statusComponent.CheckIfValueExists("ExtraCharacterLevel")) { level += statusComponent.GetUInt16Property("ExtraCharacterLevel"); } if (statusComponent.HasProperty("ExperiencePoints")) { experience = statusComponent.GetFloatProperty("ExperiencePoints"); } else { experience = 0; } isBaby = GetBooleanProperty("bIsBaby"); if (isBaby) { babyAge = GetFloatProperty("BabyAge"); nextImprintTime = -1; if (HasProperty("BabyNextCuddleTime")) { nextImprintTime = GetDoubleProperty("BabyNextCuddleTime"); } if (statusComponent.HasProperty("DinoImprintingQuality")) { imprintQuality = statusComponent.GetFloatProperty("DinoImprintingQuality"); } else { imprintQuality = 0; } } } //Get the dino entry data dino_entry = ArkImports.GetDinoDataByClassname(classname.classname); isInit = true; }
public ArkCharacter(ArkWorld world, DotArkGameObject orig) : base(world, orig) { }