@@ -167,8 +167,17 @@ await Task.Run(() =>
167
167
/// <param name="item"></param>
168
168
/// <param name="modelInfo"></param>
169
169
/// <returns>The ImcData data</returns>
170
- public async Task < ImcData > GetFullImcInfo ( IItemModel item , XivModelInfo modelInfo )
170
+ public async Task < FullImcInfo > GetFullImcInfo ( IItemModel item , XivModelInfo modelInfo = null )
171
171
{
172
+ if ( modelInfo == null )
173
+ {
174
+ modelInfo = item . ModelInfo ;
175
+ }
176
+ if ( modelInfo == null )
177
+ {
178
+ throw new NotSupportedException ( "Attempted to get IMC info for invalid item." ) ;
179
+ }
180
+
172
181
var index = new Index ( _gameDirectory ) ;
173
182
var dat = new Dat ( _gameDirectory ) ;
174
183
@@ -188,67 +197,66 @@ public async Task<ImcData> GetFullImcInfo(IItemModel item, XivModelInfo modelInf
188
197
{
189
198
using ( var br = new BinaryReader ( new MemoryStream ( imcByteData ) ) )
190
199
{
191
- var imcData = new ImcData ( )
200
+ var subsetCount = br . ReadInt16 ( ) ;
201
+ var imcData = new FullImcInfo ( )
192
202
{
193
- VariantCount = br . ReadInt16 ( ) ,
194
203
Unknown = br . ReadInt16 ( ) ,
195
- GearVariantList = new List < VariantSet > ( )
204
+ DefaultSubset = new List < XivImc > ( ) ,
205
+ SubsetList = new List < List < XivImc > > ( subsetCount )
196
206
} ;
197
207
198
208
//weapons and monsters do not have variant sets
199
209
if ( itemType == XivItemType . weapon || itemType == XivItemType . monster )
200
210
{
201
- imcData . OtherVariantList = new List < XivImc > ( ) ;
202
211
203
- imcData . DefaultVariant = new XivImc
212
+ imcData . DefaultSubset . Add ( new XivImc
204
213
{
205
214
Variant = br . ReadUInt16 ( ) ,
206
215
Mask = br . ReadUInt16 ( ) ,
207
216
Vfx = br . ReadUInt16 ( )
208
- } ;
217
+ } ) ;
209
218
210
- for ( var i = 0 ; i < imcData . VariantCount ; i ++ )
219
+ for ( var i = 0 ; i < subsetCount ; i ++ )
211
220
{
212
- imcData . OtherVariantList . Add ( new XivImc
213
- { Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ) ;
221
+ var subset = new List < XivImc > ( ) {
222
+ new XivImc { Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) }
223
+ } ;
214
224
}
215
225
}
216
226
else
217
227
{
218
- imcData . GearVariantList = new List < VariantSet > ( ) ;
219
-
220
- imcData . DefaultVariantSet = new VariantSet
228
+ imcData . DefaultSubset = new List < XivImc > ( )
221
229
{
222
- Slot1 = new XivImc
230
+ new XivImc
223
231
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
224
- Slot2 = new XivImc
232
+ new XivImc
225
233
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
226
- Slot3 = new XivImc
234
+ new XivImc
227
235
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
228
- Slot4 = new XivImc
236
+ new XivImc
229
237
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
230
- Slot5 = new XivImc
238
+ new XivImc
231
239
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
232
240
} ;
233
241
234
- for ( var i = 0 ; i < imcData . VariantCount ; i ++ )
242
+ for ( var i = 0 ; i < subsetCount ; i ++ )
235
243
{
236
244
// gets the data for each slot in the current variant set
237
- var imcGear = new VariantSet
245
+ var imcGear = new List < XivImc > ( )
238
246
{
239
- Slot1 = new XivImc
247
+ new XivImc
240
248
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
241
- Slot2 = new XivImc
249
+ new XivImc
242
250
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
243
- Slot3 = new XivImc
251
+ new XivImc
244
252
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
245
- Slot4 = new XivImc
253
+ new XivImc
246
254
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
247
- Slot5 = new XivImc
255
+ new XivImc
248
256
{ Variant = br . ReadUInt16 ( ) , Mask = br . ReadUInt16 ( ) , Vfx = br . ReadUInt16 ( ) } ,
249
257
} ;
250
258
251
- imcData . GearVariantList . Add ( imcGear ) ;
259
+ imcData . SubsetList . Add ( imcGear ) ;
252
260
}
253
261
}
254
262
@@ -305,7 +313,7 @@ private static (string Folder, string File) GetImcPath(XivModelInfo modelInfo, X
305
313
/// <summary>
306
314
/// A dictionary containing slot offset data in format [Slot Name, Offset within variant set]
307
315
/// </summary>
308
- private readonly Dictionary < string , int > _slotOffsetDictionary = new Dictionary < string , int >
316
+ private static readonly Dictionary < string , int > _slotOffsetDictionary = new Dictionary < string , int >
309
317
{
310
318
{ XivStrings . Main_Hand , 0 } ,
311
319
{ XivStrings . Off_Hand , 0 } ,
@@ -338,83 +346,88 @@ private static (string Folder, string File) GetImcPath(XivModelInfo modelInfo, X
338
346
/// <summary>
339
347
/// Class containing the information for and IMC file
340
348
/// </summary>
341
- public class ImcData
349
+ public class FullImcInfo
342
350
{
343
351
/// <summary>
344
- /// The amount of Variants contained in the IMC file
352
+ /// Get the number of subsets.
353
+ /// -NOT- the same as number of material variants.
345
354
/// </summary>
346
- public int VariantCount { get ; set ; }
347
-
348
- /// <summary>
349
- /// Unknown Value
350
- /// </summary>
351
- public int Unknown { get ; set ; }
355
+ public int SubsetCount { get
356
+ {
357
+ return SubsetList . Count ;
358
+ }
359
+ set {
360
+ throw new NotSupportedException ( "Attempted to directly set SubsetCount." ) ;
361
+ }
362
+ }
352
363
353
364
/// <summary>
354
- /// Variant List for Gear which contains variant sets
365
+ /// Get the size of each subset (Either 1 or 5)
355
366
/// </summary>
356
- public List < VariantSet > GearVariantList { get ; set ; }
367
+ public int SubsetSize
368
+ {
369
+ get
370
+ {
371
+ return DefaultSubset . Count ;
372
+ }
373
+ set
374
+ {
375
+ throw new NotSupportedException ( "Attempted to directly set SubsetSize." ) ;
376
+ }
377
+ }
357
378
358
379
/// <summary>
359
- /// Variant List for other items that do not contain varian sets
380
+ /// Unknown Value
360
381
/// </summary>
361
- public List < XivImc > OtherVariantList { get ; set ; }
382
+ public int Unknown { get ; set ; }
362
383
363
384
/// <summary>
364
- /// The default variant for the item, always the variant immediatly following the header
385
+ /// Total # of Gear Subsets.
386
+ /// NOT the same as number of material variants.
387
+ /// IItemModel->ImcSubsetID can be used as an index accessory in this list.
365
388
/// </summary>
366
- public XivImc DefaultVariant { get ; set ; }
389
+ public List < List < XivImc > > SubsetList { get ; set ; }
367
390
368
391
/// <summary>
369
392
/// The default variant set for the item, always the variant immediatly following the header
370
393
/// </summary>
371
- public VariantSet DefaultVariantSet { get ; set ; }
372
- }
394
+ public List < XivImc > DefaultSubset { get ; set ; }
373
395
374
- /// <summary>
375
- /// A class that contains the information for a variant set
376
- /// </summary>
377
- public class VariantSet
378
- {
379
- /// <summary>
380
- /// Slot 1 of the variant set
381
- /// </summary>
382
- /// <remarks>
383
- /// Head for Gear, Ears for Accessories
384
- /// </remarks>
385
- public XivImc Slot1 { get ; set ; }
386
396
387
397
/// <summary>
388
- /// Slot 2 of the variant set
398
+ /// Retrieve a given IMC info. Negative values retrieve the default set.
389
399
/// </summary>
390
- /// <remarks>
391
- /// Body for Gear, Neck for Accessories
392
- /// </remarks>
393
- public XivImc Slot2 { get ; set ; }
400
+ /// <param name="index"></param>
401
+ /// <param name="slot"></param>
402
+ /// <returns></returns>
403
+ public XivImc GetImcInfo ( int subsetID = - 1 , string fullSlotName = "" )
404
+ {
405
+ // Variant IDs are 1 based, not 0 based.
406
+ var index = subsetID - 1 ;
394
407
395
- /// <summary>
396
- /// Slot 3 of the variant set
397
- /// </summary>
398
- /// <remarks>
399
- /// Hands for Gear, Wrists for Accessories
400
- /// </remarks>
401
- public XivImc Slot3 { get ; set ; }
408
+ // Invalid Index, return default.
409
+ if ( index >= SubsetCount )
410
+ {
411
+ index = - 1 ;
412
+ }
402
413
403
- /// <summary>
404
- /// Slot 4 of the variant set
405
- /// </summary>
406
- /// <remarks>
407
- /// Legs for Gear, Left Ring for Accessories
408
- /// </remarks>
409
- public XivImc Slot4 { get ; set ; }
414
+ // Test for getting default set.
415
+ var subset = DefaultSubset ;
416
+ if ( index > 0 )
417
+ {
418
+ subset = SubsetList [ index ] ;
419
+ }
410
420
411
- /// <summary>
412
- /// Slot 5 of the variant set
413
- /// </summary>
414
- /// <remarks>
415
- /// Feet for Gear, Right Ring for Accessories
416
- /// </remarks>
417
- public XivImc Slot5 { get ; set ; }
421
+ // Get which offset the slot uses.
422
+ var idx = 0 ;
423
+ if ( _slotOffsetDictionary . ContainsKey ( fullSlotName ) )
424
+ {
425
+ idx = _slotOffsetDictionary [ fullSlotName ] ;
426
+ }
427
+
428
+ return subset [ idx ] ;
429
+ }
418
430
}
431
+
419
432
}
420
433
}
0 commit comments