Kernel_bin.Character_abilities.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. namespace FF8
  5. {
  6. public partial class Kernel_bin
  7. {
  8. /// <summary>
  9. /// Characters Abilities Data
  10. /// </summary>
  11. /// <see cref="https://github.com/alexfilth/doomtrain/wiki/Character-abilities"/>
  12. public class Character_abilities : Equipable_Ability
  13. {
  14. public new const int count = 20;
  15. public new const int id = 14;
  16. public CharacterAbilityFlags Flags { get; private set; }
  17. public Battle_Commands BattleCommand { get; set; } = null;
  18. public override void Read(BinaryReader br, int i)
  19. {
  20. Icon = Icons.ID.Ability_Character2;
  21. Name = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2);
  22. //0x0000 2 bytes Offset to name
  23. Description = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2 + 1);
  24. //0x0002 2 bytes Offset to description
  25. br.BaseStream.Seek(4, SeekOrigin.Current);
  26. AP = br.ReadByte();
  27. //0x0004 1 byte AP Required to learn ability
  28. byte[] tmp = br.ReadBytes(3);
  29. int shift =0;
  30. Flags = (CharacterAbilityFlags)(tmp[2] << (16+ shift) | tmp[1] << (8+ shift) | tmp[0]<<(shift));
  31. //Flags = new BitArray(br.ReadBytes(3));
  32. //0x0005 3 byte Flags
  33. }
  34. public static Dictionary<Abilities,Character_abilities> Read(BinaryReader br)
  35. {
  36. Dictionary<Abilities, Character_abilities> ret = new Dictionary<Abilities, Character_abilities>(count);
  37. for (int i = 0; i < count; i++)
  38. {
  39. var tmp = new Character_abilities();
  40. tmp.Read(br, i);
  41. ret[(Abilities)(i+(int)Abilities.Mug)] = tmp;
  42. }
  43. return ret;
  44. }
  45. }
  46. }
  47. }