godzcheater

TRANSFORMERS_FoC

Nov 11th, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 24.06 KB | None | 0 0
  1.     public class CustomChar
  2.     {
  3.         public XboxClasses.IO.IO IO;
  4.  
  5.         public System.Collections.Generic.List<Property> Properties { get; set; }
  6.  
  7.         public CustomChar(XboxClasses.IO.IO _IO) { IO = _IO; Read(); }
  8.  
  9.         public void Read()
  10.         {
  11.             IO.BaseStream.Position = 0;
  12.             if (IO.Reader.ReadInt32() != -1)//I think this is magic, may not be. always -1 that ive seen
  13.             {
  14.                 IO.BaseStream.Close();
  15.                 throw new System.Exception("Invalid save");
  16.             }
  17.             Properties = new System.Collections.Generic.List<Property>();
  18.             while (IO.BaseStream.Position != IO.BaseStream.Length)
  19.             {
  20.                 Property Property = new Property();
  21.                 Property.Read(IO);
  22.                 Properties.Add(Property);
  23.             }
  24.         }
  25.         public void Write()
  26.         {
  27.             IO.BaseStream.Position = 0;
  28.             IO.Writer.WriteInt32(-1);
  29.             for (System.Int32 i = 0; i < Properties.Count; i++)
  30.                 Properties[i].Write(IO);
  31.             IO.BaseStream.SetLength(IO.BaseStream.Position);
  32.             IO.BaseStream.Flush();
  33.         }
  34.  
  35.         public class Property
  36.         {
  37.             public System.String Name { get; set; }
  38.             public System.String Type { get; set; }
  39.             public System.Int32 Length { get; set; }
  40.             public System.Object Value { get; set; }
  41.  
  42.             public void Read(XboxClasses.IO.IO IO)
  43.             {
  44.                 Name = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  45.                 IO.Reader.ReadInt32();//null
  46.                 if (Name != "None")
  47.                 {
  48.                     Type = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  49.                     IO.Reader.ReadInt32();//null
  50.                     Length = IO.Reader.ReadInt32();
  51.                     IO.Reader.ReadInt32();//null
  52.                     if (Type == "ArrayProperty")
  53.                     {
  54.                         switch (Name)//diffrent array types
  55.                         {
  56.                             case "Characters"://array of propertys
  57.                                 {
  58.                                     //Value = "Sub Settings: " + IO.Reader.ReadInt32();//shoule make value an array, but cba
  59.                                     Value = new Property[IO.Reader.ReadInt32()];
  60.                                     for (System.Int32 i = 0; i < ((Property[])Value).Length; i++)
  61.                                     {
  62.                                         ((Property[])Value)[i] = new Property();
  63.                                         ((Property[])Value)[i].Read(IO);
  64.                                     }
  65.                                     break;
  66.                                 }
  67.                             case "Factions"://string + int[]
  68.                                 {
  69.                                     Value = new System.Collections.Generic.Dictionary<System.String, System.Int32>();
  70.                                     System.Int32 Count = IO.Reader.ReadInt32();
  71.                                     for (System.Int32 i = 0; i < Count; i++)
  72.                                     {//am thinking the int is always null, so just store an string[]
  73.                                         ((System.Collections.Generic.Dictionary<System.String, System.Int32>)Value).Add(IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", ""), IO.Reader.ReadInt32());
  74.                                     }
  75.                                     break;
  76.                                 }
  77.                             default://string[]
  78.                                 {
  79.                                     Value = new System.String[IO.Reader.ReadInt32()];
  80.                                     for (System.Int32 i = 0; i < ((System.String[])Value).Length; i++)
  81.                                         ((System.String[])Value)[i] = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  82.                                     break;
  83.                                 }
  84.                         }
  85.                         System.Console.WriteLine(ToString());
  86.                     }
  87.                     else if (Type == "StrProperty")
  88.                         Value = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  89.                     else if (Type == "ByteProperty")
  90.                         Value = IO.Reader.ReadBytes(Length);
  91.                     else if (Type == "FloatProperty")
  92.                         Value = IO.Reader.ReadSingle();
  93.                     else if (Type == "IntProperty")
  94.                         Value = IO.Reader.ReadInt32();
  95.                     else
  96.                         IO.BaseStream.Position += Length;//unk type, add handles for it
  97.                 }
  98.             }
  99.             public void Write(XboxClasses.IO.IO IO)
  100.             {
  101.                 IO.Writer.WriteInt32(Name.Length + 1);
  102.                 IO.Writer.WriteASCIIString(Name + "\0");
  103.                 IO.Writer.WriteInt32(0);
  104.                 if (Name != "None")
  105.                 {
  106.                     IO.Writer.WriteInt32(Type.Length + 1);
  107.                     IO.Writer.WriteASCIIString(Type + "\0");
  108.                     IO.Writer.WriteInt32(0);
  109.                     IO.Writer.WriteInt32(Length);
  110.                     IO.Writer.WriteInt32(0);
  111.                     if (Type == "ArrayProperty")
  112.                     {
  113.                         switch (Name)
  114.                         {
  115.                             case "Characters":
  116.                                 {
  117.                                     IO.Writer.WriteInt32((System.Int32)((Property[])Value).Length);
  118.                                     for (System.Int32 i = 0; i < ((Property[])Value).Length; i++)
  119.                                         ((Property[])Value)[i].Write(IO);
  120.                                     break;
  121.                                 }
  122.                             case "Factions":
  123.                                 {
  124.                                     IO.Writer.WriteInt32(((System.Collections.Generic.Dictionary<System.String, System.Int32>)Value).Count);
  125.                                     foreach (System.Collections.Generic.KeyValuePair<System.String, System.Int32> a in ((System.Collections.Generic.Dictionary<System.String, System.Int32>)Value))
  126.                                     {
  127.                                         IO.Writer.WriteInt32(a.Key.Length + 1);
  128.                                         IO.Writer.WriteASCIIString(a.Key + "\0");
  129.                                         IO.Writer.WriteInt32(a.Value);
  130.                                     }
  131.                                     break;
  132.                                 }
  133.                             default:
  134.                                 {
  135.                                     IO.Writer.WriteInt32((System.Int32)((System.String[])Value).Length);
  136.                                     for (System.Int32 i = 0; i < ((System.String[])Value).Length; i++)
  137.                                     {
  138.                                         IO.Writer.WriteInt32(((System.String[])Value)[i].Length + 1);
  139.                                         IO.Writer.WriteASCIIString(((System.String[])Value)[i] + "\0");
  140.                                     }
  141.                                     break;
  142.                                 }
  143.                         }
  144.                     }
  145.                     else if (Type == "StrProperty")
  146.                     {
  147.                         IO.Writer.WriteInt32(((System.String)Value).Length + 1);
  148.                         IO.Writer.WriteASCIIString(((System.String)Value) + "\0");
  149.                     }
  150.                     else if (Type == "ByteProperty")
  151.                         IO.Writer.WriteBytes((System.Byte[])Value);
  152.                     else if (Type == "FloatProperty")
  153.                         IO.Writer.WriteSingle((System.Single)Value);
  154.                     else if (Type == "IntProperty")
  155.                         IO.Writer.WriteInt32((System.Int32)Value);
  156.                     else
  157.                         throw new System.Exception("Unknown Type: " + Type);
  158.                 }
  159.             }
  160.  
  161.             public override System.String ToString()
  162.             {
  163.                 if (Name == "None")
  164.                     return Name;//"None"
  165.                 else if (Type == "ArrayProperty")
  166.                     return Name + ": Array";
  167.                 else if (Type == "StrProperty")
  168.                     return Name + ": " + Value;
  169.                 else if (Type == "ByteProperty")
  170.                     return Name + ": Binary";
  171.                 else if (Type == "FloatProperty")
  172.                     return Name + ": " + Value;
  173.                 else if (Type == "IntProperty")
  174.                     return Name + ": " + Value;
  175.                 return Name + ": " + Type;
  176.             }
  177.         }
  178.     }
  179.     public class CheckPoint
  180.     {
  181.         public XboxClasses.IO.IO IO;
  182.  
  183.         public System.String Map { get; set; }
  184.         public System.String MapName { get; set; }
  185.         public System.String Info { get; set; }
  186.         public System.Collections.Generic.Dictionary<System.String, Property> Properties { get; set; }
  187.  
  188.         public CheckPoint(XboxClasses.IO.IO _IO) { IO = _IO; Read(); }
  189.  
  190.         public void Read()
  191.         {
  192.             IO.BaseStream.Position = 0;
  193.             if (IO.Reader.ReadInt32() != 1)
  194.             {
  195.                 IO.BaseStream.Close();
  196.                 throw new System.Exception("Invalid save");
  197.             }
  198.  
  199.             Map = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  200.             MapName = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  201.             Info = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  202.  
  203.             Properties = new System.Collections.Generic.Dictionary<System.String, Property>();
  204.             while (IO.BaseStream.Position != IO.BaseStream.Length)
  205.             {
  206.                 Property Property = new Property();
  207.                 Property.Read(IO);
  208.                 Properties.Add(Property.Name, Property);
  209.             }
  210.         }
  211.         public void Write()
  212.         {
  213.             IO.BaseStream.Position = 0;
  214.             IO.Writer.WriteInt32(1);
  215.  
  216.             IO.Writer.WriteInt32(Map.Length + 1);
  217.             IO.Writer.WriteASCIIString(Map + "\0");
  218.             IO.Writer.WriteInt32(MapName.Length + 1);
  219.             IO.Writer.WriteASCIIString(MapName + "\0");
  220.             IO.Writer.WriteInt32(Info.Length + 1);
  221.             IO.Writer.WriteASCIIString(Info + "\0");
  222.             foreach (System.Collections.Generic.KeyValuePair<System.String, Property> Property in Properties)
  223.                 Property.Value.Write(IO);
  224.             IO.BaseStream.SetLength(IO.BaseStream.Position);
  225.             IO.BaseStream.Flush();
  226.         }
  227.  
  228.         public class Property
  229.         {
  230.             public System.String Name { get; set; }
  231.             public System.String Type { get; set; }
  232.             public System.Object Value { get; set; }
  233.  
  234.             public void Read(XboxClasses.IO.IO IO)
  235.             {
  236.                 Name = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  237.                 Type = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  238.                 if (Type == "INT")
  239.                     Value = IO.Reader.ReadInt32();
  240.                 else if (Type == "TArray")
  241.                 {
  242.                     Value = new System.Collections.Generic.List<Transformer>();
  243.                     System.Int32 Count = IO.Reader.ReadInt32();
  244.                     for (System.Int32 i = 0; i < Count; i++)
  245.                     {
  246.                         Transformer Transformer = new Transformer();
  247.                         Transformer.Read(IO);
  248.  
  249.                         ((System.Collections.Generic.List<Transformer>)Value).Add(Transformer);
  250.                     }
  251.                 }
  252.                 else
  253.                     throw new System.Exception("Unknown Type: " + Type + IO.BaseStream.Position);
  254.             }
  255.             public void Write(XboxClasses.IO.IO IO)
  256.             {
  257.                 IO.Writer.WriteInt32(Name.Length + 1);
  258.                 IO.Writer.WriteASCIIString(Name + "\0");
  259.                 IO.Writer.WriteInt32(Type.Length + 1);
  260.                 IO.Writer.WriteASCIIString(Type + "\0");
  261.                 if (Type == "INT")
  262.                     IO.Writer.WriteInt32((System.Int32)Value);
  263.                 else if (Type == "TArray")
  264.                 {
  265.                     IO.Writer.WriteInt32(((System.Collections.Generic.List<Transformer>)Value).Count);
  266.                     for (System.Int32 i = 0; i < ((System.Collections.Generic.List<Transformer>)Value).Count; i++)
  267.                         ((System.Collections.Generic.List<Transformer>)Value)[i].Write(IO);
  268.                 }
  269.                 else
  270.                     throw new System.Exception("Unknown Type: " + Type);
  271.             }
  272.         }
  273.         public class Transformer
  274.         {
  275.             public System.Collections.Generic.Dictionary<System.Int32, Property> Properties { get; set; }
  276.  
  277.             public System.String GamerTag
  278.             {
  279.                 get
  280.                 {
  281.                     return (System.String)Properties[4495].Value;
  282.                 }
  283.                 set
  284.                 {
  285.                     Properties[4495].Length = value.Length + 4;
  286.                     Properties[4495].Value = value;
  287.                 }
  288.             }
  289.             public System.String Name
  290.             {
  291.                 get
  292.                 {
  293.                     return (System.String)Properties[42091].Value;
  294.                 }
  295.                 set
  296.                 {
  297.                     Properties[42091].Length = value.Length + 4;
  298.                     Properties[42091].Value = value;
  299.                 }
  300.             }
  301.             public System.Single Score
  302.             {
  303.                 get
  304.                 {
  305.                     return (System.Single)Properties[2932].Value;
  306.                 }
  307.                 set
  308.                 {
  309.                     Properties[2932].Length = 4;
  310.                     Properties[2932].Value = value;
  311.                 }
  312.             }
  313.             //public System.Single Unk
  314.             //{
  315.             //    get
  316.             //    {
  317.             //        return (System.Single)Properties[48802].Value;
  318.             //    }
  319.             //    set
  320.             //    {
  321.             //        Properties[48802].Length = 4;
  322.             //        Properties[48802].Value = value;
  323.             //    }
  324.             //}
  325.             //public System.Single Unk2
  326.             //{
  327.             //    get
  328.             //    {
  329.             //        return (System.Single)Properties[51991].Value;
  330.             //    }
  331.             //    set
  332.             //    {
  333.             //        Properties[51991].Length = 4;
  334.             //        Properties[51991].Value = value;
  335.             //    }
  336.             //}
  337.             public System.String[] Weapons
  338.             {
  339.                 get
  340.                 {
  341.                     return (System.String[])Properties[73703].Value;
  342.                 }
  343.                 set
  344.                 {
  345.                     System.Int32 Length = 4;
  346.                     for (System.Int32 i = 0; i < value.Length; i++)
  347.                         Length += value[i].Length;
  348.                     Properties[73703].Length = Length;
  349.                     Properties[73703].Value = value;
  350.                 }
  351.             }
  352.             //TransContent.TnWeaponHeavyPistol//Path Blaster
  353.             //TransContent.TnWeaponHeavyMG//X18 Scrapmaker
  354.             //TransContent.TnWeaponBurstRifle//Photon Burst Rifle
  355.             //TransContent.TnWeaponShotgun//Scatter Blaster
  356.             //
  357.             public System.Int32[] WeaponsAmmo
  358.             {
  359.                 get
  360.                 {
  361.                     return (System.Int32[])Properties[73685].Value;
  362.                 }
  363.                 set
  364.                 {
  365.                     Properties[73685].Length = (value.Length * 4) + 4;
  366.                     Properties[73685].Value = value;
  367.                 }
  368.             }
  369.             public System.String[] VehicleWeapons
  370.             {
  371.                 get
  372.                 {
  373.                     return (System.String[])Properties[73474].Value;
  374.                 }
  375.                 set
  376.                 {
  377.                     System.Int32 Length = 4;
  378.                     for (System.Int32 i = 0; i < value.Length; i++)
  379.                         Length += value[i].Length;
  380.                     Properties[73474].Length = Length;
  381.                     Properties[73474].Value = value;
  382.                 }
  383.             }
  384.             //TransContent.TnWeaponRocketVehicle
  385.             public System.Int32[] VehicleAmmo
  386.             {
  387.                 get
  388.                 {
  389.                     return (System.Int32[])Properties[73471].Value;
  390.                 }
  391.                 set
  392.                 {
  393.                     Properties[73471].Length = (value.Length * 4) + 4;
  394.                     Properties[73471].Value = value;
  395.                 }
  396.             }
  397.             public System.String[] Abilities
  398.             {
  399.                 get
  400.                 {
  401.                     return (System.String[])Properties[48817].Value;
  402.                 }
  403.                 set
  404.                 {
  405.                     System.Int32 Length = 4;
  406.                     for (System.Int32 i = 0; i < value.Length; i++)
  407.                         Length += value[i].Length;
  408.                     Properties[48817].Length = Length;
  409.                     Properties[48817].Value = value;
  410.                 }
  411.             }
  412.             //TransContent.TnAbilityRollerSphereGravityAura//Dimensional Decimator
  413.             //TransGame.TnAbilityBarrier//Diffaction Barrier
  414.             //public System.Single Unk3
  415.             //{
  416.             //    get
  417.             //    {
  418.             //        return (System.Single)Properties[67426].Value;
  419.             //    }
  420.             //    set
  421.             //    {
  422.             //        Properties[67426].Length = 4;
  423.             //        Properties[67426].Value = value;
  424.             //    }
  425.             //}
  426.  
  427.             public void Read(XboxClasses.IO.IO IO)
  428.             {
  429.                 Properties = new System.Collections.Generic.Dictionary<System.Int32, Property>();
  430.                 while (true)
  431.                 {
  432.                     Property Property = new Property();
  433.                     Property.ID = IO.Reader.ReadInt32();
  434.                     IO.Reader.ReadInt32();//null
  435.                     if (Property.ID == 0)
  436.                         break;
  437.                     Property.Type = IO.Reader.ReadInt32();
  438.                     IO.Reader.ReadInt32();//null
  439.                     Property.Length = IO.Reader.ReadInt32();
  440.                     IO.Reader.ReadInt32();//null
  441.                     switch (Property.Type)
  442.                     {
  443.                         case 4:
  444.                             {
  445.                                 Property.Value = IO.Reader.ReadSingle();
  446.                                 break;
  447.                             }
  448.                         case 9:
  449.                             {
  450.                                 if (Property.ID == 73474 || Property.ID == 73703 || Property.ID == 48817)
  451.                                 {
  452.                                     Property.Value = new System.String[IO.Reader.ReadInt32()];
  453.                                     for (System.Int32 i = 0; i < ((System.String[])Property.Value).Length; i++)
  454.                                         ((System.String[])Property.Value)[i] = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  455.                                 }
  456.                                 else
  457.                                 {
  458.                                     Property.Value = new System.Int32[IO.Reader.ReadInt32()];
  459.                                     for (System.Int32 i = 0; i < ((System.Int32[])Property.Value).Length; i++)
  460.                                         ((System.Int32[])Property.Value)[i] = IO.Reader.ReadInt32();
  461.                                 }
  462.                                 break;
  463.                             }
  464.                         case 13:
  465.                             {
  466.                                 Property.Value = IO.Reader.ReadASCIIString(IO.Reader.ReadInt32()).Replace("\0", "");
  467.                                 break;
  468.                             }
  469.  
  470.                         default:
  471.                             {
  472.                                 throw new System.Exception("Unknown Type\nPlease report this.");
  473.                                 //IO.BaseStream.Position += Length;
  474.                                 //break;
  475.                             }
  476.                     }
  477.                     Properties.Add(Property.ID, Property);
  478.                 }
  479.             }
  480.             public void Write(XboxClasses.IO.IO IO)
  481.             {
  482.                 foreach (System.Collections.Generic.KeyValuePair<System.Int32, Property> Property in Properties)
  483.                 {
  484.                     IO.Writer.WriteInt32(Property.Value.ID);
  485.                     IO.Writer.WriteInt32(0);
  486.                     IO.Writer.WriteInt32(Property.Value.Type);
  487.                     IO.Writer.WriteInt32(0);
  488.                     IO.Writer.WriteInt32(Property.Value.Length);
  489.                     IO.Writer.WriteInt32(0);
  490.                     switch (Property.Value.Type)
  491.                     {
  492.                         case 4:
  493.                             {
  494.                                 IO.Writer.WriteSingle((System.Single)Property.Value.Value);
  495.                                 break;
  496.                             }
  497.                         case 9:
  498.                             {
  499.                                 if (Property.Value.ID == 73474 || Property.Value.ID == 73703 || Property.Value.ID == 48817)
  500.                                 {
  501.                                     IO.Writer.WriteInt32(((System.String[])Property.Value.Value).Length);
  502.                                     for (System.Int32 ii = 0; ii < ((System.String[])Property.Value.Value).Length; ii++)
  503.                                     {
  504.                                         if (((System.String[])Property.Value.Value)[ii].Length == 0)
  505.                                             IO.Writer.WriteInt32(0);
  506.                                         else
  507.                                         {
  508.                                             IO.Writer.WriteInt32(((System.String[])Property.Value.Value)[ii].Length + 1);
  509.                                             IO.Writer.WriteASCIIString(((System.String[])Property.Value.Value)[ii] + "\0");
  510.                                         }
  511.                                     }
  512.                                 }
  513.                                 else
  514.                                 {
  515.                                     IO.Writer.WriteInt32(((System.Int32[])Property.Value.Value).Length);
  516.                                     for (System.Int32 ii = 0; ii < ((System.Int32[])Property.Value.Value).Length; ii++)
  517.                                         IO.Writer.WriteInt32(((System.Int32[])Property.Value.Value)[ii]);
  518.                                 }
  519.                                 break;
  520.                             }
  521.                         case 13:
  522.                             {
  523.                                 IO.Writer.WriteInt32(((System.String)Property.Value.Value).Length + 1);
  524.                                 IO.Writer.WriteASCIIString((System.String)Property.Value.Value + "\0");
  525.                                 break;
  526.                             }
  527.  
  528.                         default:
  529.                             {
  530.                                 throw new System.Exception("Unknown Type\nPlease report this.");
  531.                             }
  532.                     }
  533.                 }
  534.                 IO.Writer.WriteInt32(0);//null property?
  535.                 IO.Writer.WriteInt32(0);
  536.             }
  537.  
  538.             public class Property
  539.             {
  540.                 public System.Int32 ID { get; set; }
  541.                 public System.Int32 Type { get; set; }
  542.                 public System.Int32 Length { get; set; }
  543.                 public System.Object Value { get; set; }
  544.             }
  545.         }
  546.     }
Advertisement
Add Comment
Please, Sign In to add comment