Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomChar
- {
- public XboxClasses.IO.IO IO;
- public System.Collections.Generic.List<Property> Properties { get; set; }
- public CustomChar(XboxClasses.IO.IO _IO) { IO = _IO; Read(); }
- public void Read()
- {
- IO.BaseStream.Position = 0;
- if (IO.Reader.ReadInt32() != -1)//I think this is magic, may not be. always -1 that ive seen
- {
- IO.BaseStream.Close();
- throw new System.Exception("Invalid save");
- }
- Properties = new System.Collections.Generic.List<Property>();
- while (IO.BaseStream.Position != IO.BaseStream.Length)
- {
- Property Property = new Property();
- Property.Read(IO);
- Properties.Add(Property);
- }
- }
- public void Write()
- {
- IO.BaseStream.Position = 0;
- IO.Writer.WriteInt32(-1);
- for (System.Int32 i = 0; i < Properties.Count; i++)
- Properties[i].Write(IO);
- IO.BaseStream.SetLength(IO.BaseStream.Position);
- IO.BaseStream.Flush();
- }
- public class Property
- {
- public System.String Name { get; set; }
- public System.String Type { get; set; }
- public System.Int32 Length { get; set; }
- public System.Object Value { get; set; }
- public void Read(XboxClasses.IO.IO IO)
- {
- Name = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- IO.Reader.ReadInt32();//null
- if (Name != "None")
- {
- Type = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- IO.Reader.ReadInt32();//null
- Length = IO.Reader.ReadInt32();
- IO.Reader.ReadInt32();//null
- if (Type == "ArrayProperty")
- {
- switch (Name)//diffrent array types
- {
- case "Characters"://array of propertys
- {
- //Value = "Sub Settings: " + IO.Reader.ReadInt32();//shoule make value an array, but cba
- Value = new Property[IO.Reader.ReadInt32()];
- for (System.Int32 i = 0; i < ((Property[])Value).Length; i++)
- {
- ((Property[])Value)[i] = new Property();
- ((Property[])Value)[i].Read(IO);
- }
- break;
- }
- case "Factions"://string + int[]
- {
- Value = new System.Collections.Generic.Dictionary<System.String, System.Int32>();
- System.Int32 Count = IO.Reader.ReadInt32();
- for (System.Int32 i = 0; i < Count; i++)
- {//am thinking the int is always null, so just store an string[]
- ((System.Collections.Generic.Dictionary<System.String, System.Int32>)Value).Add(IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", ""), IO.Reader.ReadInt32());
- }
- break;
- }
- default://string[]
- {
- Value = new System.String[IO.Reader.ReadInt32()];
- for (System.Int32 i = 0; i < ((System.String[])Value).Length; i++)
- ((System.String[])Value)[i] = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- break;
- }
- }
- System.Console.WriteLine(ToString());
- }
- else if (Type == "StrProperty")
- Value = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- else if (Type == "ByteProperty")
- Value = IO.Reader.ReadBytes(Length);
- else if (Type == "FloatProperty")
- Value = IO.Reader.ReadSingle();
- else if (Type == "IntProperty")
- Value = IO.Reader.ReadInt32();
- else
- IO.BaseStream.Position += Length;//unk type, add handles for it
- }
- }
- public void Write(XboxClasses.IO.IO IO)
- {
- IO.Writer.WriteInt32(Name.Length + 1);
- IO.Writer.WriteASCIIString(Name + "\0");
- IO.Writer.WriteInt32(0);
- if (Name != "None")
- {
- IO.Writer.WriteInt32(Type.Length + 1);
- IO.Writer.WriteASCIIString(Type + "\0");
- IO.Writer.WriteInt32(0);
- IO.Writer.WriteInt32(Length);
- IO.Writer.WriteInt32(0);
- if (Type == "ArrayProperty")
- {
- switch (Name)
- {
- case "Characters":
- {
- IO.Writer.WriteInt32((System.Int32)((Property[])Value).Length);
- for (System.Int32 i = 0; i < ((Property[])Value).Length; i++)
- ((Property[])Value)[i].Write(IO);
- break;
- }
- case "Factions":
- {
- IO.Writer.WriteInt32(((System.Collections.Generic.Dictionary<System.String, System.Int32>)Value).Count);
- foreach (System.Collections.Generic.KeyValuePair<System.String, System.Int32> a in ((System.Collections.Generic.Dictionary<System.String, System.Int32>)Value))
- {
- IO.Writer.WriteInt32(a.Key.Length + 1);
- IO.Writer.WriteASCIIString(a.Key + "\0");
- IO.Writer.WriteInt32(a.Value);
- }
- break;
- }
- default:
- {
- IO.Writer.WriteInt32((System.Int32)((System.String[])Value).Length);
- for (System.Int32 i = 0; i < ((System.String[])Value).Length; i++)
- {
- IO.Writer.WriteInt32(((System.String[])Value)[i].Length + 1);
- IO.Writer.WriteASCIIString(((System.String[])Value)[i] + "\0");
- }
- break;
- }
- }
- }
- else if (Type == "StrProperty")
- {
- IO.Writer.WriteInt32(((System.String)Value).Length + 1);
- IO.Writer.WriteASCIIString(((System.String)Value) + "\0");
- }
- else if (Type == "ByteProperty")
- IO.Writer.WriteBytes((System.Byte[])Value);
- else if (Type == "FloatProperty")
- IO.Writer.WriteSingle((System.Single)Value);
- else if (Type == "IntProperty")
- IO.Writer.WriteInt32((System.Int32)Value);
- else
- throw new System.Exception("Unknown Type: " + Type);
- }
- }
- public override System.String ToString()
- {
- if (Name == "None")
- return Name;//"None"
- else if (Type == "ArrayProperty")
- return Name + ": Array";
- else if (Type == "StrProperty")
- return Name + ": " + Value;
- else if (Type == "ByteProperty")
- return Name + ": Binary";
- else if (Type == "FloatProperty")
- return Name + ": " + Value;
- else if (Type == "IntProperty")
- return Name + ": " + Value;
- return Name + ": " + Type;
- }
- }
- }
- public class CheckPoint
- {
- public XboxClasses.IO.IO IO;
- public System.String Map { get; set; }
- public System.String MapName { get; set; }
- public System.String Info { get; set; }
- public System.Collections.Generic.Dictionary<System.String, Property> Properties { get; set; }
- public CheckPoint(XboxClasses.IO.IO _IO) { IO = _IO; Read(); }
- public void Read()
- {
- IO.BaseStream.Position = 0;
- if (IO.Reader.ReadInt32() != 1)
- {
- IO.BaseStream.Close();
- throw new System.Exception("Invalid save");
- }
- Map = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- MapName = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- Info = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- Properties = new System.Collections.Generic.Dictionary<System.String, Property>();
- while (IO.BaseStream.Position != IO.BaseStream.Length)
- {
- Property Property = new Property();
- Property.Read(IO);
- Properties.Add(Property.Name, Property);
- }
- }
- public void Write()
- {
- IO.BaseStream.Position = 0;
- IO.Writer.WriteInt32(1);
- IO.Writer.WriteInt32(Map.Length + 1);
- IO.Writer.WriteASCIIString(Map + "\0");
- IO.Writer.WriteInt32(MapName.Length + 1);
- IO.Writer.WriteASCIIString(MapName + "\0");
- IO.Writer.WriteInt32(Info.Length + 1);
- IO.Writer.WriteASCIIString(Info + "\0");
- foreach (System.Collections.Generic.KeyValuePair<System.String, Property> Property in Properties)
- Property.Value.Write(IO);
- IO.BaseStream.SetLength(IO.BaseStream.Position);
- IO.BaseStream.Flush();
- }
- public class Property
- {
- public System.String Name { get; set; }
- public System.String Type { get; set; }
- public System.Object Value { get; set; }
- public void Read(XboxClasses.IO.IO IO)
- {
- Name = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- Type = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- if (Type == "INT")
- Value = IO.Reader.ReadInt32();
- else if (Type == "TArray")
- {
- Value = new System.Collections.Generic.List<Transformer>();
- System.Int32 Count = IO.Reader.ReadInt32();
- for (System.Int32 i = 0; i < Count; i++)
- {
- Transformer Transformer = new Transformer();
- Transformer.Read(IO);
- ((System.Collections.Generic.List<Transformer>)Value).Add(Transformer);
- }
- }
- else
- throw new System.Exception("Unknown Type: " + Type + IO.BaseStream.Position);
- }
- public void Write(XboxClasses.IO.IO IO)
- {
- IO.Writer.WriteInt32(Name.Length + 1);
- IO.Writer.WriteASCIIString(Name + "\0");
- IO.Writer.WriteInt32(Type.Length + 1);
- IO.Writer.WriteASCIIString(Type + "\0");
- if (Type == "INT")
- IO.Writer.WriteInt32((System.Int32)Value);
- else if (Type == "TArray")
- {
- IO.Writer.WriteInt32(((System.Collections.Generic.List<Transformer>)Value).Count);
- for (System.Int32 i = 0; i < ((System.Collections.Generic.List<Transformer>)Value).Count; i++)
- ((System.Collections.Generic.List<Transformer>)Value)[i].Write(IO);
- }
- else
- throw new System.Exception("Unknown Type: " + Type);
- }
- }
- public class Transformer
- {
- public System.Collections.Generic.Dictionary<System.Int32, Property> Properties { get; set; }
- public System.String GamerTag
- {
- get
- {
- return (System.String)Properties[4495].Value;
- }
- set
- {
- Properties[4495].Length = value.Length + 4;
- Properties[4495].Value = value;
- }
- }
- public System.String Name
- {
- get
- {
- return (System.String)Properties[42091].Value;
- }
- set
- {
- Properties[42091].Length = value.Length + 4;
- Properties[42091].Value = value;
- }
- }
- public System.Single Score
- {
- get
- {
- return (System.Single)Properties[2932].Value;
- }
- set
- {
- Properties[2932].Length = 4;
- Properties[2932].Value = value;
- }
- }
- //public System.Single Unk
- //{
- // get
- // {
- // return (System.Single)Properties[48802].Value;
- // }
- // set
- // {
- // Properties[48802].Length = 4;
- // Properties[48802].Value = value;
- // }
- //}
- //public System.Single Unk2
- //{
- // get
- // {
- // return (System.Single)Properties[51991].Value;
- // }
- // set
- // {
- // Properties[51991].Length = 4;
- // Properties[51991].Value = value;
- // }
- //}
- public System.String[] Weapons
- {
- get
- {
- return (System.String[])Properties[73703].Value;
- }
- set
- {
- System.Int32 Length = 4;
- for (System.Int32 i = 0; i < value.Length; i++)
- Length += value[i].Length;
- Properties[73703].Length = Length;
- Properties[73703].Value = value;
- }
- }
- //TransContent.TnWeaponHeavyPistol//Path Blaster
- //TransContent.TnWeaponHeavyMG//X18 Scrapmaker
- //TransContent.TnWeaponBurstRifle//Photon Burst Rifle
- //TransContent.TnWeaponShotgun//Scatter Blaster
- //
- public System.Int32[] WeaponsAmmo
- {
- get
- {
- return (System.Int32[])Properties[73685].Value;
- }
- set
- {
- Properties[73685].Length = (value.Length * 4) + 4;
- Properties[73685].Value = value;
- }
- }
- public System.String[] VehicleWeapons
- {
- get
- {
- return (System.String[])Properties[73474].Value;
- }
- set
- {
- System.Int32 Length = 4;
- for (System.Int32 i = 0; i < value.Length; i++)
- Length += value[i].Length;
- Properties[73474].Length = Length;
- Properties[73474].Value = value;
- }
- }
- //TransContent.TnWeaponRocketVehicle
- public System.Int32[] VehicleAmmo
- {
- get
- {
- return (System.Int32[])Properties[73471].Value;
- }
- set
- {
- Properties[73471].Length = (value.Length * 4) + 4;
- Properties[73471].Value = value;
- }
- }
- public System.String[] Abilities
- {
- get
- {
- return (System.String[])Properties[48817].Value;
- }
- set
- {
- System.Int32 Length = 4;
- for (System.Int32 i = 0; i < value.Length; i++)
- Length += value[i].Length;
- Properties[48817].Length = Length;
- Properties[48817].Value = value;
- }
- }
- //TransContent.TnAbilityRollerSphereGravityAura//Dimensional Decimator
- //TransGame.TnAbilityBarrier//Diffaction Barrier
- //public System.Single Unk3
- //{
- // get
- // {
- // return (System.Single)Properties[67426].Value;
- // }
- // set
- // {
- // Properties[67426].Length = 4;
- // Properties[67426].Value = value;
- // }
- //}
- public void Read(XboxClasses.IO.IO IO)
- {
- Properties = new System.Collections.Generic.Dictionary<System.Int32, Property>();
- while (true)
- {
- Property Property = new Property();
- Property.ID = IO.Reader.ReadInt32();
- IO.Reader.ReadInt32();//null
- if (Property.ID == 0)
- break;
- Property.Type = IO.Reader.ReadInt32();
- IO.Reader.ReadInt32();//null
- Property.Length = IO.Reader.ReadInt32();
- IO.Reader.ReadInt32();//null
- switch (Property.Type)
- {
- case 4:
- {
- Property.Value = IO.Reader.ReadSingle();
- break;
- }
- case 9:
- {
- if (Property.ID == 73474 || Property.ID == 73703 || Property.ID == 48817)
- {
- Property.Value = new System.String[IO.Reader.ReadInt32()];
- for (System.Int32 i = 0; i < ((System.String[])Property.Value).Length; i++)
- ((System.String[])Property.Value)[i] = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- }
- else
- {
- Property.Value = new System.Int32[IO.Reader.ReadInt32()];
- for (System.Int32 i = 0; i < ((System.Int32[])Property.Value).Length; i++)
- ((System.Int32[])Property.Value)[i] = IO.Reader.ReadInt32();
- }
- break;
- }
- case 13:
- {
- Property.Value = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
- break;
- }
- default:
- {
- throw new System.Exception("Unknown Type\nPlease report this.");
- //IO.BaseStream.Position += Length;
- //break;
- }
- }
- Properties.Add(Property.ID, Property);
- }
- }
- public void Write(XboxClasses.IO.IO IO)
- {
- foreach (System.Collections.Generic.KeyValuePair<System.Int32, Property> Property in Properties)
- {
- IO.Writer.WriteInt32(Property.Value.ID);
- IO.Writer.WriteInt32(0);
- IO.Writer.WriteInt32(Property.Value.Type);
- IO.Writer.WriteInt32(0);
- IO.Writer.WriteInt32(Property.Value.Length);
- IO.Writer.WriteInt32(0);
- switch (Property.Value.Type)
- {
- case 4:
- {
- IO.Writer.WriteSingle((System.Single)Property.Value.Value);
- break;
- }
- case 9:
- {
- if (Property.Value.ID == 73474 || Property.Value.ID == 73703 || Property.Value.ID == 48817)
- {
- IO.Writer.WriteInt32(((System.String[])Property.Value.Value).Length);
- for (System.Int32 ii = 0; ii < ((System.String[])Property.Value.Value).Length; ii++)
- {
- if (((System.String[])Property.Value.Value)[ii].Length == 0)
- IO.Writer.WriteInt32(0);
- else
- {
- IO.Writer.WriteInt32(((System.String[])Property.Value.Value)[ii].Length + 1);
- IO.Writer.WriteASCIIString(((System.String[])Property.Value.Value)[ii] + "\0");
- }
- }
- }
- else
- {
- IO.Writer.WriteInt32(((System.Int32[])Property.Value.Value).Length);
- for (System.Int32 ii = 0; ii < ((System.Int32[])Property.Value.Value).Length; ii++)
- IO.Writer.WriteInt32(((System.Int32[])Property.Value.Value)[ii]);
- }
- break;
- }
- case 13:
- {
- IO.Writer.WriteInt32(((System.String)Property.Value.Value).Length + 1);
- IO.Writer.WriteASCIIString((System.String)Property.Value.Value + "\0");
- break;
- }
- default:
- {
- throw new System.Exception("Unknown Type\nPlease report this.");
- }
- }
- }
- IO.Writer.WriteInt32(0);//null property?
- IO.Writer.WriteInt32(0);
- }
- public class Property
- {
- public System.Int32 ID { get; set; }
- public System.Int32 Type { get; set; }
- public System.Int32 Length { get; set; }
- public System.Object Value { get; set; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment