1111
1212namespace LlamaLibrary . RemoteAgents
1313{
14+ /// <summary>
15+ /// Remote agent for the Materia Melding interface.
16+ /// Manages the process of affixing materia to equipment, including tracking eligible items and current materia status.
17+ /// </summary>
1418 public class AgentMeld : AgentInterface < AgentMeld > , IAgent
1519 {
20+ /// <inheritdoc/>
1621 public IntPtr RegisteredVtable => AgentMeldOffsets . VTable ;
1722
18-
19-
23+ /// <summary>
24+ /// Initializes a new instance of the <see cref="AgentMeld"/> class.
25+ /// </summary>
26+ /// <param name="pointer">The memory address of the agent.</param>
2027 protected AgentMeld ( IntPtr pointer ) : base ( pointer )
2128 {
2229 }
2330
31+ /// <summary>
32+ /// Gets a value indicating whether the player is currently able to meld (e.g., has the required level/quest).
33+ /// </summary>
2434 public bool CanMeld => Core . Memory . NoCacheRead < byte > ( Pointer + AgentMeldOffsets . CanMeld ) == 1 ;
2535
36+ /// <summary>
37+ /// Gets a value indicating whether the meld interface is ready for the next action.
38+ /// </summary>
2639 public bool Ready => Core . Memory . NoCacheRead < byte > ( Offsets . Conditions + 7 ) == 0 ;
2740
41+ /// <summary>
42+ /// Gets the total number of items eligible for melding in the currently selected inventory category.
43+ /// </summary>
2844 public byte ItemsToMeldCount => Core . Memory . NoCacheRead < byte > ( Pointer + AgentMeldOffsets . ItemsToMeldCount ) ;
2945
46+ /// <summary>
47+ /// Gets the index of the currently selected item within the melding list.
48+ /// </summary>
3049 public byte IndexOfSelectedItem => Core . Memory . NoCacheRead < byte > ( Pointer + AgentMeldOffsets . IndexOfSelectedItem ) ;
3150
51+ /// <summary>
52+ /// Gets the number of materia pieces affixed to the currently selected item.
53+ /// </summary>
3254 public byte MateriaCount => Core . Memory . NoCacheRead < byte > ( Pointer + AgentMeldOffsets . MateriaCount ) ;
3355
56+ /// <summary>
57+ /// Gets the memory pointer to the start of the melding data structure.
58+ /// </summary>
3459 public IntPtr StructStart => Core . Memory . Read < IntPtr > ( Pointer + AgentMeldOffsets . StructStart ) ;
3560
61+ /// <summary>
62+ /// Gets the memory pointer to the list of items available for melding.
63+ /// </summary>
3664 public IntPtr ListPtr => Core . Memory . Read < IntPtr > ( StructStart + AgentMeldOffsets . ListPtr ) ;
3765
66+ /// <summary>
67+ /// Gets an array of memory pointers to the individual items in the melding list.
68+ /// </summary>
3869 public IntPtr [ ] MeldList => Core . Memory . ReadArray < IntPtr > ( ListPtr , ItemsToMeldCount ) . Select ( i => Core . Memory . Read < IntPtr > ( i ) ) . ToArray ( ) ;
3970
71+ /// <summary>
72+ /// Gets an array of <see cref="MeldItem"/> structures for all items currently in the melding list.
73+ /// </summary>
4074 public MeldItem [ ] MeldItems => MeldList . Select ( i => Core . Memory . Read < MeldItem > ( i ) ) . ToArray ( ) ;
4175
76+ /// <summary>
77+ /// Gets the identifier for the currently selected inventory category (e.g., Equipment, Armoury Chest).
78+ /// </summary>
4279 public byte SelectedCategory => Core . Memory . NoCacheRead < byte > ( Pointer + AgentMeldOffsets . SelectedCategory ) ;
4380
81+ /// <summary>
82+ /// Finds the index of a specific <see cref="BagSlot"/> within the melding list.
83+ /// </summary>
84+ /// <param name="slot">The bag slot to find.</param>
85+ /// <returns>The zero-based index of the item, or -1 if not found.</returns>
4486 public int ItemIndex ( BagSlot slot )
4587 {
4688 return MeldItems . ToList ( ) . FindIndex ( i => i . BagId == slot . BagId && i . BagSlot == slot . Slot ) ;
4789 }
4890 }
4991}
5092
93+ /// <summary>
94+ /// Represents an item and its current materia state within the melding interface.
95+ /// </summary>
5196[ StructLayout ( LayoutKind . Explicit , Size = 0x48 ) ]
5297public struct MeldItem
5398{
99+ /// <summary>The memory address of this item's data.</summary>
54100 [ FieldOffset ( 0x0 ) ]
55101 public IntPtr Pointer ;
56102
103+ /// <summary>The inventory bag containing this item.</summary>
57104 [ FieldOffset ( 0x8 ) ]
58105 public InventoryBagId BagId ;
59106
107+ /// <summary>The slot index within the inventory bag.</summary>
60108 [ FieldOffset ( 0xC ) ]
61109 public ushort BagSlot ;
62110
111+ /// <summary>The unique item identifier.</summary>
63112 [ FieldOffset ( 0x10 ) ]
64113 public uint ItemId ;
65114
66115 [ FieldOffset ( 0x1C ) ]
67116 private byte _CanOvermeld ;
68117
118+ /// <summary>Gets a value indicating whether this item can have more materia affixed than it has slots for (Advanced Melding).</summary>
69119 public bool CanOvermeld => _CanOvermeld == 1 ;
70120
121+ /// <summary>The type identifier for the first materia slot.</summary>
71122 [ FieldOffset ( 0x28 ) ]
72123 public ushort MateriaType1 ;
73124
125+ /// <summary>The type identifier for the second materia slot.</summary>
74126 [ FieldOffset ( 0x2A ) ]
75127 public ushort MateriaType2 ;
76128
129+ /// <summary>The type identifier for the third materia slot.</summary>
77130 [ FieldOffset ( 0x2C ) ]
78131 public ushort MateriaType3 ;
79132
133+ /// <summary>The type identifier for the fourth materia slot.</summary>
80134 [ FieldOffset ( 0x2E ) ]
81135 public ushort MateriaType4 ;
82136
137+ /// <summary>The type identifier for the fifth materia slot.</summary>
83138 [ FieldOffset ( 0x30 ) ]
84139 public ushort MateriaType5 ;
85140
141+ /// <summary>The grade (tier) of the materia in the first slot.</summary>
86142 [ FieldOffset ( 0x32 ) ]
87143 public byte MateriaGrade1 ;
88144
145+ /// <summary>The grade (tier) of the materia in the second slot.</summary>
89146 [ FieldOffset ( 0x33 ) ]
90147 public byte MateriaGrade2 ;
91148
149+ /// <summary>The grade (tier) of the materia in the third slot.</summary>
92150 [ FieldOffset ( 0x34 ) ]
93151 public byte MateriaGrade3 ;
94152
153+ /// <summary>The grade (tier) of the materia in the fourth slot.</summary>
95154 [ FieldOffset ( 0x35 ) ]
96155 public byte MateriaGrade4 ;
97156
157+ /// <summary>The grade (tier) of the materia in the fifth slot.</summary>
98158 [ FieldOffset ( 0x36 ) ]
99159 public byte MateriaGrade5 ;
100160
161+ /// <summary>Gets the item metadata from the game's data manager.</summary>
101162 public Item ? Item => DataManager . GetItem ( ItemId ) ;
102163
164+ /// <summary>Gets the total number of materia pieces currently affixed to this item.</summary>
103165 public int MateriaCount => new [ ] { MateriaType1 , MateriaType2 , MateriaType3 , MateriaType4 , MateriaType5 } . Count ( i => i != 0 ) ;
104166
167+ /// <summary>Gets an array of <see cref="MateriaItem"/> objects representing the materia currently affixed to this item.</summary>
105168 public MateriaItem [ ] Materia
106169 {
107170 get
@@ -118,9 +181,11 @@ public MateriaItem[] Materia
118181 }
119182 }
120183
184+ /// <summary>Gets a value indicating whether more materia can be affixed to this item.</summary>
121185 public bool CanMeld => CanOvermeld ? MateriaCount < 5 : Item ? . MateriaSlots > MateriaCount ;
122186
123- //ToString() method
187+ /// <summary>Returns a string representation of the item and its materia state.</summary>
188+ /// <returns>A string containing the item name, materia count, and details of each affixed materia.</returns>
124189 public override string ToString ( )
125190 {
126191 return $ "{ Item ? . CurrentLocaleName } { MateriaCount } { CanMeld } { string . Join ( ',' , Materia . Select ( i => i . ToString ( ) ) ) } ";
0 commit comments