/// <summary> /// Add a new object property to an object type. /// </summary> /// <param name="typeName"></param> /// <param name="propertyName">Name of the new property to add. /// This name needs to be a valid identifier, which is no longer /// than 32 characters, starting with a letter (a-z) and consisting /// of only small letters (a-z), numbers (0-9) and/or underscores.</param> /// <param name="propertyType">Type of the new property.</param> public void DefineObjectProperty(string typeName, string propertyName, ObjectPropertyType propertyType) { if (String.IsNullOrEmpty(typeName)) { throw new ArgumentNullException("typeName"); } if (String.IsNullOrEmpty(propertyName)) { throw new ArgumentNullException("propertyName"); } CheckDataName(ref typeName); CheckDataName(ref propertyName); var query = new Dictionary <string, string>(4) { { "method", "facebook.data.defineObjectProperty" }, { "obj_type", typeName }, { "prop_name", propertyName }, { "prop_type", ((int)propertyType).ToString() } }; ExecuteApiCall(query, true); }
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 Read(IOMemoryStream ms, UAssetFile f) { source = f; //If this is an array, assume 4 if (isArray) { length = 4; } //If the length is four (only seems to happen on version 5), this is an integer. if (length == 4) { objectRefType = ObjectPropertyType.TypeID; objectIndex = 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; //Depending on the type, read it in. if (objectRefType == ObjectPropertyType.TypeID) { objectIndex = ms.ReadInt(); } if (objectRefType == ObjectPropertyType.TypePath) { className = ms.ReadNameTableEntry(f); } } else { throw new Exception($"Unknown object ref length! Expected 4 or >= 8, but got {length} instead."); } }
/// <summary> /// Add a new object property to an object type. /// </summary> /// <param name="typeName"></param> /// <param name="propertyName">Name of the new property to add. /// This name needs to be a valid identifier, which is no longer /// than 32 characters, starting with a letter (a-z) and consisting /// of only small letters (a-z), numbers (0-9) and/or underscores.</param> /// <param name="propertyType">Type of the new property.</param> public void DefineObjectProperty(string typeName, string propertyName, ObjectPropertyType propertyType) { if (String.IsNullOrEmpty(typeName)) { throw new ArgumentNullException("typeName"); } if (String.IsNullOrEmpty(propertyName)) { throw new ArgumentNullException("propertyName"); } CheckDataName(ref typeName); CheckDataName(ref propertyName); var query = new Dictionary<string, string>(4) { {"method", "facebook.data.defineObjectProperty"}, {"obj_type", typeName}, {"prop_name", propertyName}, {"prop_type", ((int) propertyType).ToString()} }; ExecuteApiCall(query, true); }
/// <summary> /// Write out one object reference (owning or real reference). /// </summary> internal static void WriteObjectReference(XmlWriter writer, Guid propertyGuid, ObjectPropertyType propertyType) { writer.WriteStartElement("objsur"); writer.WriteAttributeString("guid", propertyGuid.ToString().ToLowerInvariant()); var val = "o"; if (propertyType == ObjectPropertyType.Reference) { val = "r"; } writer.WriteAttributeString("t", val); writer.WriteEndElement(); }
/// <summary> /// Write out an atomic object property. /// </summary> internal static void WriteAtomicObjectProperty(XmlWriter writer, string elementName, ObjectPropertyType propertyType, ICmObject propertyData) { if (writer == null) { throw new ArgumentNullException("writer"); } if (string.IsNullOrEmpty(elementName)) { throw new ArgumentNullException("elementName"); } if (propertyData == null) { return; } writer.WriteStartElement(elementName); // Open prop. element. WriteObjectReference(writer, propertyData, propertyType); writer.WriteEndElement(); // Close prop. element. }
protected ObjectProperty(ObjectPropertyType propertyType) { PropertyType = propertyType; }