Abilities.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Runtime.InteropServices;
  2. namespace OpenVIII.Battle.Dat
  3. {
  4. [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 4)]
  5. public struct Abilities
  6. {
  7. #region Fields
  8. [FieldOffset(2)]
  9. public ushort AbilityID;
  10. [FieldOffset(1)]
  11. public byte Animation;
  12. /// <summary>
  13. /// Type of ability
  14. /// </summary>
  15. /// <remarks>0x2 magic, 0x4 item, 0x8 monsterAbility;</remarks>
  16. [FieldOffset(0)]
  17. public KernelFlag KernelID;
  18. // ifrit states one of theses is an animation ID.
  19. private const string Unk = "Unknown";
  20. #endregion Fields
  21. #region Properties
  22. public ItemInMenu? Item =>
  23. (KernelID & KernelFlag.Item) != 0 && Memory.MItems != null && Memory.MItems.Items.Count > AbilityID
  24. ? Memory.MItems?.Items[AbilityID]
  25. : null;
  26. public Kernel.MagicData Magic =>
  27. (KernelID & KernelFlag.Magic) != 0 && Memory.KernelBin.MagicData.Count > AbilityID
  28. ? Memory.KernelBin.MagicData[AbilityID]
  29. : null;
  30. public Kernel.EnemyAttacksData Monster =>
  31. (KernelID & KernelFlag.Monster) != 0 && Memory.KernelBin.EnemyAttacksData.Count > AbilityID
  32. ? Memory.KernelBin.EnemyAttacksData[AbilityID]
  33. : null;
  34. #endregion Properties
  35. #region Methods
  36. public override string ToString() => Magic?.Name ?? Monster?.Name ?? Item?.Name ?? Unk;
  37. #endregion Methods
  38. }
  39. }