Saves.ChocoboWorld.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. using System.IO;
  3. namespace OpenVIII
  4. {
  5. public static partial class Saves
  6. {
  7. /// <see cref="https://github.com/myst6re/hyne/blob/master/SaveData.h"/>
  8. /// <summary>
  9. /// ChocoboWorld Save Data
  10. /// </summary>
  11. public class ChocoboWorld //64
  12. {
  13. [Flags]
  14. public enum EnabledFlags : byte
  15. {
  16. Disabled = 0x0,
  17. Enabled = 0x1,
  18. In_world = 0x2,
  19. MiniMog_found = 0x4,
  20. Demon_King_defeated = 0x8,
  21. Koko_kidnapped = 0x10,
  22. Hurry = 0x20,
  23. Koko_met = 0x40,
  24. Event_Wait_off = 0x80,
  25. }
  26. [Flags]
  27. public enum BokuAttackFlags : byte {
  28. chocobraise = 0x1,
  29. chocoflammes = 0x2,
  30. chocométéore = 0x4,
  31. grochocobo = 0x8,
  32. }
  33. public EnabledFlags enabled;// Enabled|In world|MiniMog found|Demon King defeated|Koko kidnapped|Hurry!|Koko met|Event Wait off
  34. public byte level;
  35. public byte current_hp;
  36. public byte max_hp;
  37. public byte[] weapon;// 4 bit = 1 weapon
  38. public byte rank;
  39. public byte move;
  40. public ulong saveCount;
  41. public ushort id_related;
  42. public byte[] u1;
  43. public byte itemClassACount;
  44. public byte itemClassBCount;
  45. public byte itemClassCCount;
  46. public byte itemClassDCount;
  47. public byte[] u2;
  48. public ulong associatedSaveID;
  49. public byte u3;
  50. public BokuAttackFlags boko_attack;// star count (chocobraise | chocoflammes | chocométéore | grochocobo)
  51. public byte u4;
  52. public byte home_walking;
  53. public byte[] u5;
  54. public ChocoboWorld(){}
  55. public ChocoboWorld(BinaryReader br) => Read(br);
  56. /// <summary>
  57. /// Shadow copy
  58. /// </summary>
  59. /// <returns></returns>
  60. public ChocoboWorld Clone() => (ChocoboWorld) MemberwiseClone();
  61. public void Read(BinaryReader br)
  62. {
  63. enabled = (EnabledFlags)br.ReadByte();// Enabled|In world|MiniMog found|Demon King defeated|Koko kidnapped|Hurry!|Koko met|Event Wait off
  64. level = br.ReadByte();
  65. current_hp = br.ReadByte();
  66. max_hp = br.ReadByte();
  67. ushort tmp = br.ReadUInt16();// 4 bit = 1 weapon
  68. weapon = new byte[4];
  69. weapon[0] = (byte)(tmp & 0x000F);
  70. weapon[1] = (byte)((tmp & 0x00F0)>>4);
  71. weapon[2] = (byte)((tmp & 0x0F00)>>8);
  72. weapon[3] = (byte)((tmp & 0xF000)>>12);
  73. rank = br.ReadByte();
  74. move = br.ReadByte();
  75. saveCount = br.ReadUInt32();
  76. id_related = br.ReadUInt16();
  77. u1 = br.ReadBytes(6);
  78. itemClassACount = br.ReadByte();
  79. itemClassBCount = br.ReadByte();
  80. itemClassCCount = br.ReadByte();
  81. itemClassDCount = br.ReadByte();
  82. u2 = br.ReadBytes(16);
  83. associatedSaveID = br.ReadUInt32();
  84. u3 = br.ReadByte();
  85. boko_attack = (BokuAttackFlags)br.ReadByte();// star count (chocobraise | chocoflammes | chocométéore | grochocobo)
  86. u4 = br.ReadByte();
  87. home_walking = br.ReadByte();
  88. u5 = br.ReadBytes(16);
  89. }
  90. }
  91. }
  92. }