source: OniSplit/Metadata/InstanceMetadata.cs@ 1142

Last change on this file since 1142 was 1114, checked in by iritscen, 5 years ago

Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File size: 122.2 KB
RevLine 
[1114]1using System;
2using System.Collections.Generic;
3using System.IO;
4
5namespace Oni.Metadata
6{
7 internal abstract class InstanceMetadata
8 {
9 private static readonly MetaStruct aiSoundConstants = new MetaStruct("AISoundConstants",
10 new Field(MetaType.Byte, "TauntProbability"),
11 new Field(MetaType.Byte, "AlertProbability"),
12 new Field(MetaType.Byte, "StartleProbability"),
13 new Field(MetaType.Byte, "CheckBodyProbability"),
14 new Field(MetaType.Byte, "PursueProbability"),
15 new Field(MetaType.Byte, "CoverProbability"),
16 new Field(MetaType.Byte, "SuperPunchProbability"),
17 new Field(MetaType.Byte, "SuperKickProbability"),
18 new Field(MetaType.Byte, "Super3Probability"),
19 new Field(MetaType.Byte, "Super4Probability"),
20 new Field(MetaType.Padding(2)),
21 new Field(MetaType.String32, "TauntSound"),
22 new Field(MetaType.String32, "AlertSound"),
23 new Field(MetaType.String32, "StartleSound"),
24 new Field(MetaType.String32, "CheckBodySound"),
25 new Field(MetaType.String32, "PursueSound"),
26 new Field(MetaType.String32, "CoverSound"),
27 new Field(MetaType.String32, "SuperPunchSound"),
28 new Field(MetaType.String32, "SuperKickSound"),
29 new Field(MetaType.String32, "Super3Sound"),
30 new Field(MetaType.String32, "Super4Sound"));
31
32 private static readonly MetaStruct aiVisionConstants = new MetaStruct("AIVisionConstants",
33 new Field(MetaType.Float, "CentralDistance"),
34 new Field(MetaType.Float, "PeripheralDistance"),
35 new Field(MetaType.Float, "VerticalRange"),
36 new Field(MetaType.Float, "CentralRange"),
37 new Field(MetaType.Float, "CentralMax"),
38 new Field(MetaType.Float, "PeripheralRange"),
39 new Field(MetaType.Float, "PeripheralMax"));
40
41 private static readonly MetaStruct aiTargeting = new MetaStruct("AITargeting",
42 // parameters for how we shoot if startled
43 new Field(MetaType.Float, "StartleMissAngle"),
44 new Field(MetaType.Float, "StartleMissDistance"),
45 // target prediction
46 new Field(MetaType.Float, "PredictAmount"),
47 new Field(MetaType.Int32, "PredictPositionDelayFrames"),
48 new Field(MetaType.Int32, "PredictDelayFrames"),
49 new Field(MetaType.Int32, "PredictVelocityFrames"),
50 new Field(MetaType.Int32, "PredictTrendFrames"));
51
52 private static readonly MetaType aiWeaponSkill = new MetaStruct("AIWeaponSkill",
53 new Field(MetaType.Float, "RecoilCompensation"),
54 new Field(MetaType.Float, "BestAimingAngle"),
55 new Field(MetaType.Float, "ShotGroupError"),
56 new Field(MetaType.Float, "ShotGroupDecay"),
57 new Field(MetaType.Float, "ShootingInaccuracyMultiplier"),
58 new Field(MetaType.Int16, "MinShotDelay"),
59 new Field(MetaType.Int16, "MaxShotDelay"));
60
61 [Flags]
62 public enum AIFiringModeFlags : uint
63 {
64 None = 0,
65 NoWildShots = 1,
66 }
67
68 private static readonly MetaStruct aiFiringMode = new MetaStruct("AIFiringMode",
69 new Field(MetaType.Enum<AIFiringModeFlags>(), "Flags"),
70 new Field(MetaType.Matrix4x3, "InverseDirection"),
71 new Field(MetaType.Vector3, "Direction"),
72 new Field(MetaType.Vector3, "Origin"),
73 new Field(MetaType.Float, "PredictionSpeed"),
74 new Field(MetaType.Float, "MaxInaccuracyAngle"),
75 new Field(MetaType.Float, "AimRadius"),
76 new Field(MetaType.Float, "AISoundRadius"),
77 new Field(MetaType.Float, "MinShootingDistance"),
78 new Field(MetaType.Float, "MaxShootingDistance"),
79 new Field(MetaType.Int16, "MaxStartleMisses"),
80 new Field(MetaType.Int16, "SkillIndex"),
81 new Field(MetaType.Int32, "FightTimer"),
82 new Field(MetaType.Float, "ProjectileSpeed"),
83 new Field(MetaType.Float, "ProjectileGravity"),
84 new Field(MetaType.Float, "FireSpreadLength"),
85 new Field(MetaType.Float, "FireSpreadWidth"),
86 new Field(MetaType.Float, "FireSpreadSkew")
87 );
88
89 //
90 // AI Character Setup Array template
91 //
92
93 public enum AISACharacterTeam : ushort
94 {
95 Konoko = 0,
96 TCTF = 1,
97 Syndicate = 2,
98 Neutral = 3,
99 SecurityGuard = 4,
100 RogueKonoko = 5,
101 Switzerland = 6,
102 SyndicateAccessory = 7
103 }
104
105 [Flags]
106 public enum AISACharacterFlags : ushort
107 {
108 None = 0,
109 AI = 0x0001,
110 AutoFreeze = 0x0002,
111 Neutral = 0x0004,
112 TurnGuard = 0x0008
113 }
114
115 private static readonly MetaStruct aisa = new MetaStruct("AISAInstance",
116 new Field(MetaType.Padding(22)),
117 new Field(MetaType.ShortVarArray(new MetaStruct("AISACharacter",
118 new Field(MetaType.String32, "Name"),
119 new Field(MetaType.Int16, "ScriptId"),
120 new Field(MetaType.Int16, "FlagId"),
121 new Field(MetaType.Enum<AISACharacterFlags>(), "Flags"),
122 new Field(MetaType.Enum<AISACharacterTeam>(), "Team"),
123 new Field(MetaType.Pointer(TemplateTag.ONCC), "Class"),
124 new Field(MetaType.Padding(36)),
125 new Field(new MetaStruct("CharacterScripts",
126 new Field(MetaType.String32, "Spawn"),
127 new Field(MetaType.String32, "Die"),
128 new Field(MetaType.String32, "Combat"),
129 new Field(MetaType.String32, "Alarm"),
130 new Field(MetaType.String32, "Hurt"),
131 new Field(MetaType.String32, "Defeated"),
132 new Field(MetaType.String32, "OutOfAmmo"),
133 new Field(MetaType.String32, "NoPath")), "Scripts"),
134 new Field(MetaType.Pointer(TemplateTag.ONWC), "WeaponClass"),
135 new Field(MetaType.Int16, "Ammo"),
136 new Field(MetaType.Padding(10))
137 )), "Characters")
138 );
139
140 //
141 // Adjacency Array template
142 //
143
144 private static readonly MetaStruct akaa = new MetaStruct("AKAAInstance",
145 new Field(MetaType.Padding(20)),
146 new Field(MetaType.VarArray(new MetaStruct("AKAAElement",
147 new Field(MetaType.Int32, "Bnv"),
148 new Field(MetaType.Int32, "Quad"),
149 new Field(MetaType.Padding(4))
150 )), "Elements")
151 );
152
153 //
154 // BSP Tree Node Array template
155 //
156
157 private static readonly MetaStruct abna = new MetaStruct("ABNAInstance",
158 new Field(MetaType.Padding(20)),
159 new Field(MetaType.VarArray(new MetaStruct("ABNAElement",
160 new Field(MetaType.Int32, "Quad"),
161 new Field(MetaType.Int32, "Plane"),
162 new Field(MetaType.Int32, "Front"),
163 new Field(MetaType.Int32, "Back")
164 )), "Elements")
165 );
166
167 //
168 // BNV Node Array template
169 //
170
171 private static readonly MetaStruct akva = new MetaStruct("AKVAInstance",
172 new Field(MetaType.Padding(20)),
173 new Field(MetaType.VarArray(new MetaStruct("AKVANode",
174 new Field(MetaType.Int32, "BspTree"),
175 new Field(MetaType.Int32, "Id"),
176 new Field(MetaType.Int32, "FirstSide"),
177 new Field(MetaType.Int32, "LastSide"),
178 new Field(MetaType.Int32, "ChildBnv"),
179 new Field(MetaType.Int32, "SiblingBnv"),
180 new Field(MetaType.Padding(4, 0xff)),
181 new Field(MetaType.Int32, "GridXTiles"),
182 new Field(MetaType.Int32, "GridZTiles"),
183 new BinaryPartField(MetaType.RawOffset, "DataOffset", "DataSize"),
184 new Field(MetaType.Int32, "DataSize"),
185 new Field(MetaType.Float, "TileSize"),
186 new Field(MetaType.BoundingBox, "BoundingBox"),
187 new Field(MetaType.Int16, "GridXOffset"),
188 new Field(MetaType.Int16, "GridZOffset"),
189 new Field(MetaType.Int32, "NodeId"),
190 new Field(MetaType.Padding(12)),
191 new Field(MetaType.Int32, "Flags"),
192 new Field(MetaType.Plane, "Floor"),
193 new Field(MetaType.Float, "Height")
194 )), "Nodes")
195 );
196
197 //
198 // Side Array template
199 //
200
201 private static readonly MetaStruct akba = new MetaStruct("AKBAInstance",
202 new Field(MetaType.Padding(20)),
203 new Field(MetaType.VarArray(new MetaStruct("AKBASide",
204 new Field(MetaType.Int32, "Plane"),
205 //new Field(MetaType.Padding(4, 0x7f)),
206 new Field(MetaType.Int32, "FirstAdjacency"),
207 new Field(MetaType.Int32, "LastAdjacency"),
208 new Field(MetaType.Padding(16))
209 )), "Sides")
210 );
211
212 //
213 // BSP Node Array template
214 //
215
216 private static readonly MetaStruct akbp = new MetaStruct("AKBPInstance",
217 new Field(MetaType.Padding(22)),
218 new Field(MetaType.ShortVarArray(new MetaStruct("AKBPNode",
219 new Field(MetaType.Int32, "Plane"),
220 new Field(MetaType.Int32, "Back"),
221 new Field(MetaType.Int32, "Front")
222 )), "Nodes")
223 );
224
225 //
226 // Akira Environment template
227 //
228
229 private static readonly MetaStruct akev = new MetaStruct("AKEVInstance",
230 new Field(MetaType.Pointer(TemplateTag.PNTA), "Points"),
231 new Field(MetaType.Pointer(TemplateTag.PLEA), "Planes"),
232 new Field(MetaType.Pointer(TemplateTag.TXCA), "TextureCoordinates"),
233 new Field(MetaType.Pointer(TemplateTag.AGQG), "Quads"),
234 new Field(MetaType.Pointer(TemplateTag.AGQR), "QuadTextures"),
235 new Field(MetaType.Pointer(TemplateTag.AGQC), "QuadCollision"),
236 new Field(MetaType.Pointer(TemplateTag.AGDB), "Debug"),
237 new Field(MetaType.Pointer(TemplateTag.TXMA), "Textures"),
238 new Field(MetaType.Pointer(TemplateTag.AKVA), "BnvNodes"),
239 new Field(MetaType.Pointer(TemplateTag.AKBA), "BnvSides"),
240 new Field(MetaType.Pointer(TemplateTag.IDXA), "QuadGroupList"),
241 new Field(MetaType.Pointer(TemplateTag.IDXA), "QuadGroupId"),
242 new Field(MetaType.Pointer(TemplateTag.AKBP), "BnvBspTree"),
243 new Field(MetaType.Pointer(TemplateTag.ABNA), "TransparencyBspTree"),
244 new Field(MetaType.Pointer(TemplateTag.AKOT), "Octtree"),
245 new Field(MetaType.Pointer(TemplateTag.AKAA), "BnvAdjacency"),
246 new Field(MetaType.Pointer(TemplateTag.AKDA), "DoorFrames"),
247 new Field(MetaType.BoundingBox, "BoundingBox"),
248 new Field(MetaType.Padding(24)),
249 new Field(MetaType.Float, "")
250 );
251
252 //
253 // Gunk Quad Collision Array template
254 //
255
256 private static readonly MetaStruct agqc = new MetaStruct("AGQCInstance",
257 new Field(MetaType.Padding(20)),
258 new Field(MetaType.VarArray(new MetaStruct("AGQCElement",
259 new Field(MetaType.Int32, "Plane"),
260 new Field(MetaType.BoundingBox, "BoundingBox")
261 )), "Elements")
262 );
263
264 //
265 // Gunk Quad General Array template
266 //
267
268 [Flags]
269 private enum AGQGFlags : uint
270 {
271 None = 0,
272
273 DoorFrame = 0x01,
274 Ghost = 0x02,
275 StairsUp = 0x04,
276 StairsDown = 0x08,
277
278 Stairs = 0x10,
279 Transparent = 0x80,
280 TwoSided = 0x0200,
281 NoCollision = 0x0800,
282 Invisible = 0x00002000,
283 NoObjectCollision = 0x4000,
284 NoCharacterCollision = 0x8000,
285 NoOcclusion = 0x010000,
286 Danger = 0x020000,
287 GridIgnore = 0x400000,
288 NoDecals = 0x800000,
289 Furniture = 0x01000000,
290
291 SoundTransparent = 0x08000000,
292 Impassable = 0x10000000,
293
294 Triangle = 0x00000040,
295 Horizontal = 0x00080000,
296 Vertical = 0x00100000,
297
298 ProjectionBit0 = 0x02000000,
299 ProjectionBit1 = 0x04000000,
300 }
301
302 private static readonly MetaStruct agqg = new MetaStruct("AGQGInstance",
303 new Field(MetaType.Padding(20)),
304 new Field(MetaType.VarArray(new MetaStruct("AGQGQuad",
305 new Field(MetaType.Array(4, MetaType.Int32), "Points"),
306 new Field(MetaType.Array(4, MetaType.Int32), "TextureCoordinates"),
307 new Field(MetaType.Array(4, MetaType.Color), "Colors"),
308 new Field(MetaType.Enum<AGQGFlags>(), "Flags"),
309 new Field(MetaType.Int32, "ObjectId")
310 )), "Quads")
311 );
312
313 //
314 // Gunk Quad Render Array template
315 //
316
317 private static readonly MetaStruct agqr = new MetaStruct("AGQRInstance",
318 new Field(MetaType.Padding(20)),
319 new Field(MetaType.VarArray(new MetaStruct("AGQRElement",
320 new Field(MetaType.UInt16, "Texture"),
321 new Field(MetaType.Padding(2))
322 )), "Elements")
323 );
324
325 //
326 // Oct tree template
327 //
328
329 private static readonly MetaStruct akot = new MetaStruct("AKOTInstance",
330 new Field(MetaType.Pointer(TemplateTag.OTIT), "Nodes"),
331 new Field(MetaType.Pointer(TemplateTag.OTLF), "Leafs"),
332 new Field(MetaType.Pointer(TemplateTag.QTNA), "QuadTree"),
333 new Field(MetaType.Pointer(TemplateTag.IDXA), "GunkQuad"),
334 new Field(MetaType.Pointer(TemplateTag.IDXA), "Bnv")
335 );
336
337 //
338 // Oct tree interior node Array template
339 //
340
341 private static readonly MetaStruct otit = new MetaStruct("OTITInstance",
342 new Field(MetaType.Padding(20)),
343 new Field(MetaType.VarArray(new MetaStruct("OTITNode",
344 new Field(MetaType.Array(8, MetaType.Int32), "Children")
345 )), "Nodes")
346 );
347
348 //
349 // Oct tree leaf node Array template
350 //
351
352 private static readonly MetaStruct otlf = new MetaStruct("OTLFInstance",
353 new Field(MetaType.Padding(20)),
354 new Field(MetaType.VarArray(new MetaStruct("OTLFNode",
355 new Field(MetaType.Int32, "PackedGunkQuadList"),
356 new Field(MetaType.Array(6, MetaType.Int32), "Neighbours"),
357 new Field(MetaType.Int32, "PackedPositionAndSize"),
358 new Field(MetaType.Int32, "PackedBnvList")
359 )), "Nodes")
360 );
361
362 //
363 // Quad tree node Array template
364 //
365
366 private static readonly MetaStruct qtna = new MetaStruct("QTNAInstance",
367 new Field(MetaType.Padding(20)),
368 new Field(MetaType.VarArray(new MetaStruct("QTNANode",
369 new Field(MetaType.Array(4, MetaType.Int32), "Children")
370 )), "Nodes")
371 );
372
373 //
374 // Env Particle Array template
375 //
376
377 [Flags]
378 internal enum ENVPFlags : ushort
379 {
380 None = 0x00,
381 NotInitiallyCreated = 0x02,
382 }
383
384 private static readonly MetaStruct envp = new MetaStruct("ENVPInstance",
385 new Field(MetaType.Padding(22)),
386 new Field(MetaType.ShortVarArray(new MetaStruct("ENVPParticle",
387 new Field(MetaType.String64, "Class"),
388 new Field(MetaType.String48, "Tag"),
389 new Field(MetaType.Matrix4x3, "Transform"),
390 new Field(MetaType.Vector2, "DecalScale"),
391 new Field(MetaType.Enum<ENVPFlags>(), "Flags"),
392 new Field(MetaType.Padding(38))
393 )), "Particles")
394 );
395
396 //
397 // Geometry template
398 //
399
400 private static readonly MetaStruct m3gm = new MetaStruct("M3GMInstance",
401 new Field(MetaType.Padding(4)),
402 new Field(MetaType.Pointer(TemplateTag.PNTA), "Points"),
403 new Field(MetaType.Pointer(TemplateTag.VCRA), "VertexNormals"),
404 new Field(MetaType.Pointer(TemplateTag.VCRA), "FaceNormals"),
405 new Field(MetaType.Pointer(TemplateTag.TXCA), "TextureCoordinates"),
406 new Field(MetaType.Pointer(TemplateTag.IDXA), "TriangleStrips"),
407 new Field(MetaType.Pointer(TemplateTag.IDXA), "FaceNormalIndices"),
408 new Field(MetaType.Pointer(TemplateTag.TXMP), "Texture"),
409 new Field(MetaType.Padding(4))
410 );
411
412 //
413 // GeometryArray template
414 //
415
416 private static readonly MetaStruct m3ga = new MetaStruct("M3GAInstance",
417 new Field(MetaType.Padding(20)),
418 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.M3GM)), "Geometries")
419 );
420
421 //
422 // Plane Equation Array template
423 //
424
425 private static readonly MetaStruct plea = new MetaStruct("PLEAInstance",
426 new Field(MetaType.Padding(20)),
427 new Field(MetaType.VarArray(MetaType.Plane), "Planes")
428 );
429
430 //
431 // 3D Point Array template
432 //
433
434 private static readonly MetaStruct pnta = new MetaStruct("PNTAInstance",
435 new Field(MetaType.Padding(12)),
436 new Field(MetaType.BoundingBox, "BoundingBox"),
437 new Field(MetaType.BoundingSphere, "BoundingSphere"),
438 new Field(MetaType.VarArray(MetaType.Vector3), "Positions")
439 );
440
441 //
442 // Texture Coordinate Array template
443 //
444
445 private static readonly MetaStruct txca = new MetaStruct("TXCAInstance",
446 new Field(MetaType.Padding(20)),
447 new Field(MetaType.VarArray(MetaType.Vector2), "TexCoords")
448 );
449
450 //
451 // Texture Map Animation template
452 //
453
454 private static readonly MetaStruct txan = new MetaStruct("TXANInstance",
455 new Field(MetaType.Padding(12)),
456 new Field(MetaType.Int16, "Speed"),
457 new Field(MetaType.Int16, ""),
458 new Field(MetaType.Padding(4)),
459 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.TXMP)), "Textures")
460 );
461
462 //
463 // Texture map array template
464 //
465
466 private static readonly MetaStruct txma = new MetaStruct("TXMAInstance",
467 new Field(MetaType.Padding(20)),
468 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.TXMP)), "Textures")
469 );
470
471 //
472 // Texture Map Big template
473 //
474
475 private static readonly MetaStruct txmb = new MetaStruct("TXMBInstance",
476 new Field(MetaType.Padding(8)),
477 new Field(MetaType.Int16, "Width"),
478 new Field(MetaType.Int16, "Height"),
479 new Field(MetaType.Padding(8)),
480 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.TXMP)), "Textures")
481 );
482
483 //
484 // 3D Vector Array template
485 //
486
487 private static readonly MetaStruct vcra = new MetaStruct("VCRAInstance",
488 new Field(MetaType.Padding(20)),
489 new Field(MetaType.VarArray(MetaType.Vector3), "Normals")
490 );
491
492 //
493 // Impact template
494 //
495
496 private static readonly MetaStruct impt = new MetaStruct("ImptInstance",
497 new Field(MetaType.Padding(2, 0xff)),
498 new Field(MetaType.Padding(6)),
499 new Field(MetaType.Pointer(TemplateTag.Impt), "ParentImpact")
500 );
501
502 //
503 // Material template
504 //
505
506 private static readonly MetaStruct mtrl = new MetaStruct("MtrlInstance",
507 new Field(MetaType.Padding(2, 0xff)),
508 new Field(MetaType.Padding(6)),
509 new Field(MetaType.Pointer(TemplateTag.Mtrl), "ParentMaterial")
510 );
511
512 //
513 // Console template
514 //
515
516 [Flags]
517 public enum CONSFlags : uint
518 {
519 None = 0x00,
520 AlarmConsole = 0x01
521 }
522
523 private static readonly MetaStruct cons = new MetaStruct("CONSInstance",
524 new Field(MetaType.Enum<CONSFlags>(), "Flags"),
525 new Field(MetaType.Vector3, "Position"),
526 new Field(MetaType.Vector3, "Orientation"),
527 new Field(MetaType.Pointer(TemplateTag.OFGA), "ConsoleGeometry"),
528 new Field(MetaType.Pointer(TemplateTag.M3GM), "ScreenGeometry"),
529 new Field(MetaType.Enum<AGQGFlags>(), "ScreenGunkFlags"),
530 new Field(MetaType.String32, "InactiveTexture"),
531 new Field(MetaType.String32, "ActiveTexture"),
532 new Field(MetaType.String32, "UsedTexture")
533 );
534
535 //
536 // Door template
537 //
538
539 public enum DOORSoundType
540 {
541 None = -1,
542 Unimportant = 0,
543 Interesting = 1,
544 Danger = 2,
545 Melee = 3,
546 Gunfire = 4,
547 }
548
549 public enum DOORSoundAllow : uint
550 {
551 All = 0,
552 Combat = 1,
553 Gunfire = 2,
554 None = 3
555 }
556
557 private static readonly MetaStruct door = new MetaStruct("DOORInstance",
558 new Field(MetaType.Array(2, MetaType.Pointer(TemplateTag.OFGA)), "Geometries"),
559 new Field(MetaType.Pointer(TemplateTag.OBAN), "Animation"),
560 new Field(MetaType.Float, "AISoundAttenuation"),
561 new Field(MetaType.Enum<DOORSoundAllow>(), "AISoundAllow"),
562 new Field(MetaType.Enum<DOORSoundType>(), "AISoundType"),
563 new Field(MetaType.Float, "AISoundDistance"),
564 new Field(MetaType.String32, "OpenSound"),
565 new Field(MetaType.String32, "CloseSound"),
566 new Field(MetaType.Padding(8))
567 );
568
569 //
570 // Object Furn Geom Array template
571 //
572
573 private static readonly MetaStruct ofga = new MetaStruct("OFGAInstance",
574 new Field(MetaType.Padding(16)),
575 new Field(MetaType.Pointer(TemplateTag.ENVP), "EnvParticle"),
576 new Field(MetaType.VarArray(new MetaStruct("OFGAElement",
577 new Field(MetaType.Enum<AGQGFlags>(), "GunkFlags"),
578 new Field(MetaType.Pointer(TemplateTag.M3GM), "Geometry"),
579 new Field(MetaType.Padding(4))
580 //new Field(MetaType.InstanceLink(TemplateTag.OBLS), "LightSource")
581 )), "Elements")
582 );
583
584 private static readonly MetaStruct obls = new MetaStruct("OBLSInstance",
585 new Field(MetaType.Int32, "Type"),
586 new Field(MetaType.Int32, "Flags"),
587 new Field(MetaType.Vector3, "Color"),
588 new Field(MetaType.Float, "Intensity"),
589 new Field(MetaType.Float, "BeamAngle"),
590 new Field(MetaType.Float, "FieldAngle")
591 );
592
593 //
594 // Trigger template
595 //
596
597 private static readonly MetaStruct trig = new MetaStruct("TRIGInstance",
598 new Field(MetaType.Color, "Color"), // ignored
599 new Field(MetaType.UInt16, "TimeOn"),
600 new Field(MetaType.UInt16, "TimeOff"),
601 new Field(MetaType.Float, "StartOffset"),
602 new Field(MetaType.Float, "AnimScale"),
603 new Field(MetaType.Pointer(TemplateTag.M3GM), "BaseGeometry"),
604 new Field(MetaType.Padding(4)), // ls data
605 new Field(MetaType.Enum<AGQGFlags>(), "BaseGunkFlags"),
606 new Field(MetaType.Pointer(TemplateTag.TRGE), "Emitter"),
607 new Field(MetaType.Pointer(TemplateTag.OBAN), "Animation"),
608 new Field(MetaType.String32, "ActiveSound"),
609 new Field(MetaType.String32, "TriggerSound"),
610 new Field(MetaType.Padding(8))
611 );
612
613 //
614 // Trigger Emitter template
615 //
616
617 private static readonly MetaStruct trge = new MetaStruct("TRGEInstance",
618 new Field(MetaType.Vector3, "Position"),
619 new Field(MetaType.Vector3, "Direction"),
620 new Field(MetaType.Pointer(TemplateTag.M3GM), "Geometry"),
621 new Field(MetaType.Enum<AGQGFlags>(), "GunkFlags")
622 );
623
624 //
625 // Turret template
626 //
627
628 private static readonly MetaStruct turr = new MetaStruct("TURRInstance",
629 new Field(MetaType.String32, "Name"),
630 new Field(MetaType.Padding(32)), // base name
631 new Field(MetaType.Padding(14)), // flags, free time, reload time, barrel count, recoil anim type, reload anim type, max ammo
632 new Field(MetaType.Int16, "ParticleCount"), // attachment count
633 new Field(MetaType.Int16, ""), // shooter count
634 new Field(MetaType.Padding(6)), // pad, aiming speed
635 new Field(MetaType.Pointer(TemplateTag.M3GM), "BaseGeometry"),
636 new Field(MetaType.Padding(4)), // ls data
637 new Field(MetaType.Enum<AGQGFlags>(), "BaseGunkFlags"),
638 new Field(MetaType.Pointer(TemplateTag.M3GM), "ArmGeometry"),
639 new Field(MetaType.Enum<AGQGFlags>(), "ArmGunkFlags"),
640 new Field(MetaType.Pointer(TemplateTag.M3GM), "WeaponGeometry"),
641 new Field(MetaType.Enum<AGQGFlags>(), "WeaponGunkFlags"),
642 new Field(MetaType.Vector3, "ArmTranslation"),
643 new Field(MetaType.Vector3, "WeaponTranslation"),
644 new Field(MetaType.Array(16, new MetaStruct("TURRParticle",
645 new Field(MetaType.String16, "ParticleClass"),
646 new Field(MetaType.Padding(4)),
647 new Field(MetaType.Int16, "ShotFrequency"),
648 new Field(MetaType.Int16, "FiringModeOwner"),
649 new Field(MetaType.Matrix4x3, "Transform"),
650 new Field(MetaType.Padding(4))
651 )), "Particles"),
652 new Field(aiFiringMode, "FiringMode"),
653 new Field(aiTargeting, "Targeting"),
654 new Field(aiWeaponSkill, "WeaponSkill"),
655 new Field(MetaType.Int32, "Timeout"),
656 new Field(MetaType.Float, "MinElevation"),
657 new Field(MetaType.Float, "MaxElevation"),
658 new Field(MetaType.Float, "MinAzimuth"),
659 new Field(MetaType.Float, "MaxAzimuth"),
660 new Field(MetaType.Float, "MaxVerticalSpeed"),
661 new Field(MetaType.Float, "MaxHorizontalSpeed"),
662 new Field(MetaType.String32, "ActiveSound"),
663 new Field(MetaType.Padding(4))
664 );
665
666 //
667 // Object animation template
668 //
669
670 [Flags]
671 private enum OBANFlags : uint
672 {
673 None = 0x00,
674 NormalLoop = 0x01,
675 BackToBackLoop = 0x02,
676 RandomStartFrame = 0x04,
677 Autostart = 0x08,
678 ZAxisUp = 0x10
679 }
680
681 private static readonly MetaStruct oban = new MetaStruct("OBANInstance",
682 new Field(MetaType.Padding(12)),
683 new Field(MetaType.Enum<OBANFlags>(), "Flags"),
684 new Field(MetaType.Matrix4x3, "InitialTransform"),
685 new Field(MetaType.Matrix4x3, "BaseTransform"),
686 new Field(MetaType.Int16, "FrameLength"),
687 new Field(MetaType.Int16, "FrameCount"),
688 new Field(MetaType.Int16, "HalfStopFrame"),
689 new Field(MetaType.ShortVarArray(new MetaStruct("OBANKeyFrame",
690 new Field(MetaType.Quaternion, "Rotation"),
691 new Field(MetaType.Vector3, "Translation"),
692 new Field(MetaType.Int32, "Time")
693 )), "KeyFrames")
694 );
695
696 [Flags]
697 public enum OBOAFlags : uint
698 {
699 None = 0,
700 InUse = 0x0200,
701 NoCollision = 0x0400,
702 NoGravity = 0x0800,
703 FaceCollision = 0x1000,
704 }
705
706 public enum OBOAPhysics : uint
707 {
708 None = 0,
709 Static = 1,
710 Linear = 2,
711 Animated = 3,
712 Newton = 4
713 }
714
715 //
716 // Starting Object Array template
717 //
718
719 private static readonly MetaStruct oboa = new MetaStruct("OBOAInstance",
720 new Field(MetaType.Padding(22)),
721 new Field(MetaType.ShortVarArray(new MetaStruct("OBOAObject",
722 new Field(MetaType.Pointer(TemplateTag.M3GA), "Geometry"),
723 new Field(MetaType.Pointer(TemplateTag.OBAN), "Animation"),
724 new Field(MetaType.Pointer(TemplateTag.ENVP), "Particle"),
725 new Field(MetaType.Enum<OBOAFlags>(), "Flags"),
726 new Field(MetaType.Int32, "DoorGunkId"),
727 new Field(MetaType.Int32, "DoorId"),
728 new Field(MetaType.Enum<OBOAPhysics>(), "PhysicsType"),
729 new Field(MetaType.Int32, "ScriptId"),
730 new Field(MetaType.Vector3, "Position"),
731 new Field(MetaType.Quaternion, "Rotation"),
732 new Field(MetaType.Float, "Scale"),
733 new Field(MetaType.Matrix4x3, "Transform"),
734 new Field(MetaType.String64, "Name"),
735 new Field(MetaType.Padding(64))
736 )), "Objects")
737 );
738
739 //
740 // Character Body Part Impacts template
741 //
742
743 private static readonly MetaStruct cbpi = new MetaStruct("CBPIInstance",
744 new Field(MetaType.Array(19, MetaType.Pointer(TemplateTag.Impt)), "HitImpacts"),
745 new Field(MetaType.Array(19, MetaType.Pointer(TemplateTag.Impt)), "BlockedImpacts"),
746 new Field(MetaType.Array(19, MetaType.Pointer(TemplateTag.Impt)), "KilledImpacts")
747 );
748
749 //
750 // Character Body Part Material template
751 //
752
753 private static readonly MetaStruct cbpm = new MetaStruct("CBPMInstance",
754 new Field(MetaType.Array(19, MetaType.Pointer(TemplateTag.Mtrl)), "Materials")
755 );
756
757 //
758 // Oni Character Class template
759 //
760
761 [Flags]
762 public enum AICharacterFlags : uint
763 {
764 None = 0x00,
765 NoStartleAnim = 0x01,
766 EnableMeleeFireDodge = 0x02,
767 ShootDodge = 0x04,
768 RunAwayDodge = 0x08,
769 NotUsed = 0x10
770 }
771
772 private static readonly MetaStruct oncc = new MetaStruct("ONCCInstance",
773 new Field(new MetaStruct("ONCCAirConstants",
774 new Field(MetaType.Float, "FallGravity"),
775 new Field(MetaType.Float, "JumpGravity"),
776 new Field(MetaType.Float, "JumpStartVelocity"),
777 new Field(MetaType.Float, "MaxVelocity"),
778 new Field(MetaType.Float, "JetpackAcceleration"),
779 new Field(MetaType.UInt16, "FramesFallGravity"),
780 new Field(MetaType.UInt16, "JetpackTimer"),
781 new Field(MetaType.Float, "MaxNoDamageFallingHeight"),
782 new Field(MetaType.Float, "MaxDamageFallingHeight")),
783 "AirConstants"),
784
785 new Field(new MetaStruct("ONCCShadowConstants",
786 new Field(MetaType.Pointer(TemplateTag.TXMP), "Texture"),
787 new Field(MetaType.Float, "MaxHeight"),
788 new Field(MetaType.Float, "FadeHeight"),
789 new Field(MetaType.Float, "SizeMax"),
790 new Field(MetaType.Float, "SizeFade"),
791 new Field(MetaType.Float, "SizeMin"),
792 new Field(MetaType.Int16, "AlphaMax"),
793 new Field(MetaType.Int16, "AlphaFade")),
794 "ShadowConstants"),
795
796 new Field(new MetaStruct("ONCCJumpConstants",
797 new Field(MetaType.Float, "JumpDistance"),
798 new Field(MetaType.Byte, "JumpHeight"),
799 new Field(MetaType.Byte, "JumpDistanceSquares"),
800 new Field(MetaType.Padding(2))),
801 "JumpConstants"),
802
803 new Field(new MetaStruct("ONCCCoverConstants",
804 new Field(MetaType.Float, "RayIncrement"),
805 new Field(MetaType.Float, "RayMax"),
806 new Field(MetaType.Float, "RayAngle"),
807 new Field(MetaType.Float, "RayAngleMax")),
808 "CoverConstants"),
809
810 new Field(new MetaStruct("ONCCAutoFreezeConstants",
811 new Field(MetaType.Float, "DistanceXZ"),
812 new Field(MetaType.Float, "DistanceY")),
813 "AutoFreezeConstants"),
814
815 new Field(new MetaStruct("ONCCInventoryConstants",
816 new Field(MetaType.Int16, "HypoRegenerationRate"),
817 new Field(MetaType.Padding(2))),
818 "InventoryConstants"),
819
820 new Field(MetaType.Array(5, MetaType.Float), "LODConstants"),
821
822 new Field(new MetaStruct("ONCCHurtSoundConstants",
823 new Field(MetaType.Int16, "BasePercentage"),
824 new Field(MetaType.Int16, "MaxPercentage"),
825 new Field(MetaType.Int16, "PercentageThreshold"),
826 new Field(MetaType.Int16, "Timer"),
827 new Field(MetaType.Int16, "MinTimer"),
828 new Field(MetaType.Int16, "MaxLight"),
829 new Field(MetaType.Int16, "MaxMedium"),
830 new Field(MetaType.Int16, "DeathChance"),
831 new Field(MetaType.Int16, "VolumeTreshold"),
832 new Field(MetaType.Int16, "MediumTreshold"),
833 new Field(MetaType.Int16, "HeavyTreshold"),
834 new Field(MetaType.Padding(2)),
835 new Field(MetaType.Float, "MinVolume"),
836 new Field(MetaType.String32, "LightSound"),
837 new Field(MetaType.String32, "MediumSound"),
838 new Field(MetaType.String32, "HeavySound"),
839 new Field(MetaType.String32, "DeathSound"),
840 new Field(MetaType.Padding(16))),
841 "HurtSoundConstants"),
842
843 new Field(new MetaStruct("ONCCAIConstants",
844 new Field(MetaType.Enum<AICharacterFlags>(), "Flags"),
845 new Field(MetaType.Float, "RotationSpeed"), // turning_nimbleness
846 new Field(MetaType.UInt16, "DazedMinFrames"),
847 new Field(MetaType.UInt16, "DazedMaxFrames"),
848 new Field(MetaType.Int32, "DodgeReactFrames"),
849 new Field(MetaType.Float, "DodgeTimeScale"),
850 new Field(MetaType.Float, "DodgeWeightScale"),
851 new Field(aiTargeting, "Targeting"),
852 new Field(MetaType.Array(13, aiWeaponSkill), "WeaponSkills"),
853 new Field(MetaType.Int32, "DeadMakeSureDelay"),
854 new Field(MetaType.Int32, "InvestigateBodyDelay"),
855 new Field(MetaType.Int32, "LostContactDelay"),
856 new Field(MetaType.Int32, "DeadTauntChance"),
857 new Field(MetaType.Int32, "GoForGunChance"),
858 new Field(MetaType.Int32, "RunPickupChance"),
859 new Field(MetaType.Int16, "CombatId"),
860 new Field(MetaType.Int16, "MeleeId"),
861 new Field(aiSoundConstants, "SoundConstants"),
862 new Field(aiVisionConstants, "VisionConstants"),
863 new Field(MetaType.Int32, "HostileThreatDefiniteTimer"),
864 new Field(MetaType.Int32, "HostileThreatStrongTimer"),
865 new Field(MetaType.Int32, "HostileThreatWeakTimer"),
866 new Field(MetaType.Int32, "FriendlyThreatDefiniteTimer"),
867 new Field(MetaType.Int32, "FriendlyThreatStrongTimer"),
868 new Field(MetaType.Int32, "FriendlyThreatWeakTimer"),
869 new Field(MetaType.Float, "EarshotRadius")),
870 "AIConstants"),
871
872 new Field(MetaType.Pointer(TemplateTag.ONCV), "Variant"),
873 new Field(MetaType.Pointer(TemplateTag.ONCP), "Particles"),
874 new Field(MetaType.Pointer(TemplateTag.ONIA), "Impacts"),
875 new Field(MetaType.Padding(4)),
876 new Field(MetaType.String16, "ImpactModifierName"),
877
878 new Field(MetaType.Array(15, new MetaStruct("ONCCImpact",
879 new Field(MetaType.String128, "Name"),
880 new Field(MetaType.Padding(2, 0xff))
881 )), "Impacts"),
882
883 new Field(MetaType.Padding(2)),
884 new Field(MetaType.String64, "DeathParticle"),
885
886 new Field(MetaType.Padding(8)),
887 new Field(MetaType.Pointer(TemplateTag.TRBS), "BodySet"),
888 new Field(MetaType.Pointer(TemplateTag.TRMA), "BodyTextures"),
889 new Field(MetaType.Pointer(TemplateTag.CBPM), "BodyMaterials"),
890 new Field(MetaType.Pointer(TemplateTag.CBPI), "BodyImpacts"),
891 new Field(MetaType.Int32, "FightModeTimer"),
892 new Field(MetaType.Int32, "IdleAnimation1Timer"),
893 new Field(MetaType.Int32, "IdleAnimation2Timer"),
894 new Field(MetaType.Int32, "Health"),
895 new Field(MetaType.Enum<TRAMBoneFlags>(), "FeetBones"),
896
897 new Field(MetaType.Float, "MinBodySizeFactor"),
898 new Field(MetaType.Float, "MaxBodySizeFactor"),
899 new Field(MetaType.Array(7, MetaType.Float), "DamageFactors"),
900 new Field(MetaType.Float, "BossShieldProtectAmount"),
901
902 new Field(MetaType.Pointer(TemplateTag.TRAC), "Animations"),
903 new Field(MetaType.Pointer(TemplateTag.TRSC), "AimingScreens"),
904
905 new Field(MetaType.UInt16, "AIRateOfFire"),
906 new Field(MetaType.UInt16, "DeathDeleteDelay"),
907 new Field(MetaType.Byte, "WeaponHand"),
908 new Field(MetaType.Byte, "HasDaodanPowers"),
909 new Field(MetaType.Byte, "HasSupershield"),
910 new Field(MetaType.Byte, "CantTouchThis")
911 );
912
913 //
914 // Oni Character Impact Array template
915 //
916
917 private static readonly MetaStruct onia = new MetaStruct("ONIAInstance",
918 new Field(MetaType.Padding(20)),
919 new Field(MetaType.VarArray(new MetaStruct("ONIAImpact",
920 new Field(MetaType.String16, "Name"),
921 new Field(MetaType.String128, "Type"),
922 new Field(MetaType.String16, "Modifier"),
923 new Field(MetaType.Padding(2, 0xff)),
924 new Field(MetaType.Padding(2))
925 )), "Impacts")
926 );
927
928 //
929 // Oni Character Particle Array template
930 //
931
932 public enum ONCPBodyPart : ushort
933 {
934 Pelvis,
935 LeftThigh,
936 LeftCalf,
937 LeftFoot,
938 RightThigh,
939 RightCalf,
940 RightFoot,
941 Mid,
942 Chest,
943 Neck,
944 Head,
945 LeftShoulder,
946 LeftArm,
947 LeftWrist,
948 LeftFist,
949 RightShoulder,
950 RightArm,
951 RightWrist,
952 RightFist,
953 KillImpact = 0x8000,
954 None = 0xffff
955 }
956
957 private static readonly MetaStruct oncp = new MetaStruct("ONCPInstance",
958 new Field(MetaType.Padding(20)),
959 new Field(MetaType.VarArray(new MetaStruct("ONCPParticle",
960 new Field(MetaType.String16, "Name"),
961 new Field(MetaType.String64, "Type"),
962 new Field(MetaType.Enum<ONCPBodyPart>(), "BodyPart"),
963 new Field(MetaType.Padding(1, 0x5f)),
964 new Field(MetaType.Padding(5))
965 )), "Particles")
966 );
967
968 //
969 // Oni Character Variant template
970 //
971
972 private static readonly MetaStruct oncv = new MetaStruct("ONCVInstance",
973 new Field(MetaType.Pointer(TemplateTag.ONCV), "ParentVariant"),
974 new Field(MetaType.String32, "CharacterClass"),
975 new Field(MetaType.String32, "CharacterClassHard")
976 );
977
978 //
979 // Corpse Array template
980 //
981
982 private static readonly MetaStruct crsa = new MetaStruct("CRSAInstance",
983 new Field(MetaType.Padding(12)),
984 new Field(MetaType.Int32, "FixedCount"),
985 new Field(MetaType.Int32, "UsedCount"),
986 new Field(MetaType.VarArray(new MetaStruct("CRSACorpse",
987 new Field(MetaType.Padding(160)),
988 new Field(MetaType.Pointer(TemplateTag.ONCC), "CharacterClass"),
989 new Field(MetaType.Array(19, MetaType.Matrix4x3), "Transforms"),
990 new Field(MetaType.BoundingBox, "BoundingBox")
991 )), "Corpses")
992 );
993
994 //
995 // Diary Page template
996 //
997
998 private static readonly MetaStruct dpge = new MetaStruct("DPgeInstance",
999 new Field(MetaType.Int16, "LevelNumber"),
1000 new Field(MetaType.Int16, "PageNumber"),
1001 new Field(MetaType.Byte, "IsLearnedMove"),
1002 new Field(MetaType.Padding(3)),
1003 new Field(MetaType.Padding(48)),
1004 new Field(MetaType.Pointer(TemplateTag.IGPG), "Page")
1005 );
1006
1007 //
1008 // Film template
1009 //
1010
1011 [Flags]
1012 public enum FILMKeys : ulong
1013 {
1014 None = 0x00,
1015 Escape = 0x01,
1016 Console = 0x02,
1017 Pause = 0x04,
1018 Cutscene1 = 0x08,
1019 Cutscene2 = 0x10,
1020 F4 = 0x20,
1021 F5 = 0x40,
1022 F6 = 0x80,
1023 F7 = 0x0100,
1024 F8 = 0x0200,
1025 StartRecord = 0x0400,
1026 StopRecord = 0x0800,
1027 PlayRecord = 0x1000,
1028 F12 = 0x2000,
1029 LookMode = 0x8000,
1030 Screenshot = 0x010000,
1031 Forward = 0x200000,
1032 Backward = 0x400000,
1033 TurnLeft = 0x800000,
1034 TurnRight = 0x01000000,
1035 StepLeft = 0x02000000,
1036 StepRight = 0x04000000,
1037 Jump = 0x08000000,
1038 Crouch = 0x10000000,
1039 Punch = 0x20000000,
1040 Kick = 0x40000000,
1041 Block = 0x80000000,
1042 Walk = 0x0100000000,
1043 Action = 0x0200000000,
1044 Hypo = 0x0400000000,
1045 Reload = 0x0800000000,
1046 Swap = 0x1000000000,
1047 Drop = 0x2000000000,
1048 Fire1 = 0x4000000000,
1049 Fire2 = 0x8000000000,
1050 Fire3 = 0x010000000000
1051 }
1052
1053 private static readonly MetaStruct film = new MetaStruct("FILMInstance",
1054 new Field(MetaType.Vector3, "Position"),
1055 new Field(MetaType.Float, "Facing"),
1056 new Field(MetaType.Float, "DesiredFacing"),
1057 new Field(MetaType.Float, "HeadFacing"),
1058 new Field(MetaType.Float, "HeadPitch"),
1059 new Field(MetaType.Int32, "FrameCount"),
1060 new Field(MetaType.Array(2, MetaType.Pointer(TemplateTag.TRAM)), "Animations"),
1061 new Field(MetaType.Padding(12)),
1062 new Field(MetaType.VarArray(new MetaStruct("Frame",
1063 new Field(MetaType.Vector2, "MouseDelta"),
1064 new Field(MetaType.Enum<FILMKeys>(), "Keys"),
1065 new Field(MetaType.Int32, "Frame"),
1066 new Field(MetaType.Padding(4))
1067 )), "Frames")
1068 );
1069
1070 //
1071 // Oni Game Settings template
1072 //
1073
1074 private static readonly MetaStruct ongs = new MetaStruct("ONGSInstance",
1075 new Field(MetaType.Float, "MaxOverhealthFactor"),
1076 new Field(MetaType.Float, "NormalHypoStrength"),
1077 new Field(MetaType.Float, "OverhealthHypoStrength"),
1078 new Field(MetaType.Float, "OverhealthMinDamage"),
1079 new Field(MetaType.Float, "OverhealthMaxDamage"),
1080
1081 new Field(MetaType.Int32, "UsedHealthElements"),
1082 new Field(MetaType.Array(16, MetaType.Float), "HealthPercent"),
1083 new Field(MetaType.Array(16, MetaType.Color), "HealthColor"),
1084
1085 new Field(MetaType.Array(6, MetaType.String128), "PowerupModels"),
1086 new Field(MetaType.Padding(128)),
1087 new Field(MetaType.Array(6, MetaType.String128), "PowerupGlowTextures"),
1088 new Field(MetaType.Padding(128)),
1089 new Field(MetaType.Array(6, MetaType.Vector2), "PowerupGlowSizes"),
1090 new Field(MetaType.Padding(8)),
1091
1092 new Field(MetaType.Array(23, MetaType.String32), "Sounds"),
1093
1094 new Field(MetaType.Array(3, MetaType.Float), "NoticeFactors"),
1095 new Field(MetaType.Array(3, MetaType.Float), "BlockChanceFactors"),
1096 new Field(MetaType.Array(3, MetaType.Float), "DodgeFactors"),
1097 new Field(MetaType.Array(3, MetaType.Float), "WeaponAccuracyFactors"),
1098 new Field(MetaType.Array(3, MetaType.Float), "EnemyHealthFactors"),
1099 new Field(MetaType.Array(3, MetaType.Float), "PlayerHealthFactors"),
1100
1101 new Field(MetaType.Int32, "UsedAutoPrompts"),
1102 new Field(MetaType.Array(16, new MetaStruct("ONGSAutoPrompt",
1103 new Field(MetaType.String32, "Notes"),
1104 new Field(MetaType.Int16, "FirstAutopromptLevel"),
1105 new Field(MetaType.Int16, "LastAutopromptLevel"),
1106 new Field(MetaType.String32, "SubtitleName")
1107 )), "AutoPrompts")
1108 );
1109
1110 //
1111 // Help Page template
1112 //
1113
1114 private static readonly MetaStruct hpge = new MetaStruct("HPgeInstance",
1115 new Field(MetaType.Padding(4)),
1116 new Field(MetaType.Pointer(TemplateTag.IGPG), "Page")
1117 );
1118
1119 //
1120 // IGUI HUD Help template
1121 //
1122
1123 private static readonly MetaStruct ighh = new MetaStruct("IGHHInstance",
1124 new Field(MetaType.Padding(28)),
1125 new Field(MetaType.Pointer(TemplateTag.TXMP), "LeftTexture"),
1126 new Field(MetaType.Pointer(TemplateTag.TXMP), "RightTexture"),
1127 new Field(MetaType.Int16, "LeftX"),
1128 new Field(MetaType.Int16, "LeftY"),
1129 new Field(MetaType.Int16, "RightX"),
1130 new Field(MetaType.Int16, "RightY"),
1131 new Field(MetaType.Int32, "LeftCount"),
1132 new Field(MetaType.Int32, "RightCount"),
1133 new Field(MetaType.VarArray(new MetaStruct("IGHHLabels",
1134 new Field(MetaType.String64, "Text"),
1135 new Field(MetaType.Int16, "X"),
1136 new Field(MetaType.Int16, "Y")
1137 )), "Labels")
1138 );
1139
1140 //
1141 // IGUI Page template
1142 //
1143
1144 private enum IGPGFontStyle : uint
1145 {
1146 Normal = 0,
1147 Bold = 1,
1148 Italic = 2
1149 }
1150
1151 [Flags]
1152 private enum IGPGFlags : ushort
1153 {
1154 None = 0x00,
1155 Family = 0x01,
1156 Style = 0x02,
1157 Color = 0x04,
1158 Size = 0x08
1159 }
1160
1161 private static readonly MetaStruct igpg = new MetaStruct("IGPGInstance",
1162 new Field(new MetaStruct("IGPGFont",
1163 new Field(MetaType.Pointer(TemplateTag.TSFF), "Family"),
1164 new Field(MetaType.Enum<IGPGFontStyle>(), "Style"),
1165 new Field(MetaType.Color, "Color"),
1166 new Field(MetaType.UInt16, "Size"),
1167 new Field(MetaType.Enum<IGPGFlags>(), "Flags")),
1168 "Font"),
1169 new Field(MetaType.Pointer(TemplateTag.NONE), "Image"),
1170 new Field(MetaType.Pointer(TemplateTag.IGSA), "Text1"),
1171 new Field(MetaType.Pointer(TemplateTag.IGSA), "Text2")
1172 );
1173
1174 //
1175 // IGUI Page Array template
1176 //
1177
1178 private static readonly MetaStruct igpa = new MetaStruct("IGPAInstance",
1179 new Field(MetaType.Padding(20)),
1180 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.IGPG)), "Pages")
1181 );
1182
1183 //
1184 // IGUI String template
1185 //
1186
1187 private enum IGStFontStyle : uint
1188 {
1189 Normal = 0,
1190 Bold = 1,
1191 Italic = 2
1192 }
1193
1194 [Flags]
1195 private enum IGStFlags : ushort
1196 {
1197 None = 0x00,
1198 Family = 0x01,
1199 Style = 0x02,
1200 Color = 0x04,
1201 Size = 0x08
1202 }
1203
1204 private static readonly MetaStruct igst = new MetaStruct("IGStInstance",
1205 new Field(new MetaStruct("IGStFont",
1206 new Field(MetaType.Pointer(TemplateTag.TSFF), "Family"),
1207 new Field(MetaType.Enum<IGStFontStyle>(), "Style"),
1208 new Field(MetaType.Color, "Color"),
1209 new Field(MetaType.Int16, "Size"),
1210 new Field(MetaType.Enum<IGStFlags>(), "Flags")),
1211 "Font"),
1212 new Field(MetaType.String(384), "Text")
1213 );
1214
1215 //
1216 // IGUI String Array template
1217 //
1218
1219 private static readonly MetaStruct igsa = new MetaStruct("IGSAInstance",
1220 new Field(MetaType.Padding(20)),
1221 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.IGSt)), "Strings")
1222 );
1223
1224 //
1225 // Item Page template
1226 //
1227
1228 private static readonly MetaStruct ipge = new MetaStruct("IPgeInstance",
1229 new Field(MetaType.Int32, "PageNumber"),
1230 new Field(MetaType.Pointer(TemplateTag.IGPG), "Page")
1231 );
1232
1233 //
1234 // Key Icons template
1235 //
1236
1237 private static readonly MetaStruct keyi = new MetaStruct("KeyIInstance",
1238 new Field(MetaType.Pointer(TemplateTag.TXMP), "Punch"),
1239 new Field(MetaType.Pointer(TemplateTag.TXMP), "Kick"),
1240 new Field(MetaType.Pointer(TemplateTag.TXMP), "Forward"),
1241 new Field(MetaType.Pointer(TemplateTag.TXMP), "Backward"),
1242 new Field(MetaType.Pointer(TemplateTag.TXMP), "Left"),
1243 new Field(MetaType.Pointer(TemplateTag.TXMP), "Right"),
1244 new Field(MetaType.Pointer(TemplateTag.TXMP), "Crouch"),
1245 new Field(MetaType.Pointer(TemplateTag.TXMP), "Jump"),
1246 new Field(MetaType.Pointer(TemplateTag.TXMP), "Hold"),
1247 new Field(MetaType.Pointer(TemplateTag.TXMP), "Plus")
1248 );
1249
1250 //
1251 // Oni Game Level template
1252 //
1253
1254 private static readonly MetaStruct onlv = new MetaStruct("ONLVInstance",
1255 new Field(MetaType.String64, "Name"),
1256 new Field(MetaType.Pointer(TemplateTag.AKEV), "Environment"),
1257 new Field(MetaType.Pointer(TemplateTag.OBOA), "Objects"),
1258 new Field(MetaType.Padding(12)),
1259 new Field(MetaType.Pointer(TemplateTag.ONSK), "SkyBox"),
1260 new Field(MetaType.Padding(4)),
1261 new Field(MetaType.Pointer(TemplateTag.AISA), "Characters"),
1262 new Field(MetaType.Padding(12)),
1263 new Field(MetaType.Pointer(TemplateTag.ONOA), "ObjectQuadMap"),
1264 new Field(MetaType.Pointer(TemplateTag.ENVP), "Particles"),
1265 new Field(MetaType.Padding(644)),
1266 new Field(MetaType.Pointer(TemplateTag.CRSA), "Corpses")
1267 );
1268
1269 //
1270 // Oni Game Level Descriptor template
1271 //
1272
1273 private static readonly MetaStruct onld = new MetaStruct("ONLDInstance",
1274 new Field(MetaType.Int16, "LevelNumber"),
1275 new Field(MetaType.Int16, "NextLevelNumber"),
1276 new Field(MetaType.String64, "DisplayName")
1277 );
1278
1279 //
1280 // Object Gunk Array template
1281 //
1282
1283 private static readonly MetaStruct onoa = new MetaStruct("ONOAInstance",
1284 new Field(MetaType.Padding(20)),
1285 new Field(MetaType.VarArray(new MetaStruct("ONOAElement",
1286 new Field(MetaType.Int32, "ObjectId"),
1287 new Field(MetaType.Pointer(TemplateTag.IDXA), "QuadList")
1288 )), "Elements")
1289 );
1290
1291 //
1292 // Objective Page template
1293 //
1294
1295 private static readonly MetaStruct opge = new MetaStruct("OPgeInstance",
1296 new Field(MetaType.Padding(2)),
1297 new Field(MetaType.UInt16, "LevelNumber"),
1298 new Field(MetaType.Pointer(TemplateTag.IGPA), "Pages")
1299 );
1300
1301 //
1302 // Oni Sky class template
1303 //
1304
1305 private static readonly MetaStruct onsk = new MetaStruct("ONSKInstance",
1306 new Field(MetaType.Array(6, MetaType.Pointer(TemplateTag.TXMP)), "SkyboxTextures"),
1307 new Field(MetaType.Array(8, MetaType.Pointer(TemplateTag.TXMP)), "Planets"),
1308 new Field(MetaType.Pointer(TemplateTag.TXMP), "SunFlare"),
1309 new Field(MetaType.Array(5, MetaType.Pointer(TemplateTag.TXMP)), "Stars"),
1310 new Field(MetaType.Int32, "PlanetCount"),
1311 new Field(MetaType.Int32, "NoSunFlare"),
1312 new Field(MetaType.Array(8, MetaType.Float), "PlanetWidths"),
1313 new Field(MetaType.Array(8, MetaType.Float), "PlanetHeights"),
1314 new Field(MetaType.Array(8, MetaType.Float), "PlanetElevations"),
1315 new Field(MetaType.Array(8, MetaType.Float), "PlanetAzimuths"),
1316 new Field(MetaType.Float, "SunFlareSize"),
1317 new Field(MetaType.Float, "SunFlareIntensity"),
1318 new Field(MetaType.Int32, "StarCount"),
1319 new Field(MetaType.Int32, "RandomSeed"),
1320 new Field(MetaType.Int32, "")
1321 );
1322
1323 //
1324 // Text Console template
1325 //
1326
1327 private static readonly MetaStruct txtc = new MetaStruct("TxtCInstance",
1328 new Field(MetaType.Pointer(TemplateTag.IGPA), "Pages")
1329 );
1330
1331 //
1332 // Oni Variant List template
1333 //
1334
1335 private static readonly MetaStruct onvl = new MetaStruct("ONVLInstance",
1336 new Field(MetaType.Padding(20)),
1337 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.ONCV)), "Variants")
1338 );
1339
1340 //
1341 // Weapon Page template
1342 //
1343
1344 private static readonly MetaStruct wpge = new MetaStruct("WPgeInstance",
1345 new Field(MetaType.Pointer(TemplateTag.ONWC), "WeaponClass"),
1346 new Field(MetaType.Pointer(TemplateTag.IGPG), "Page")
1347 );
1348
1349 //
1350 // Part Specification template
1351 //
1352
1353 private static readonly MetaStruct pspc = new MetaStruct("PSpcInstance",
1354 new Field(MetaType.Array(9, new MetaStruct("PSpcPoint",
1355 new Field(MetaType.Int16, "X"),
1356 new Field(MetaType.Int16, "Y")
1357 )), "LeftTop"),
1358 new Field(MetaType.Array(9, new MetaStruct("PSpcPoint",
1359 new Field(MetaType.Int16, "X"),
1360 new Field(MetaType.Int16, "Y")
1361 )), "RightBottom"),
1362 new Field(MetaType.Pointer(TemplateTag.TXMP), "Texture")
1363 );
1364
1365 //
1366 // Part Specification List template
1367 //
1368
1369 private enum PSpLType : uint
1370 {
1371 OutOfGameBackground = 0,
1372 InGameBackground = 1,
1373 SoundDebugPanelBackground = 5
1374 }
1375
1376 private static readonly MetaStruct pspl = new MetaStruct("PSpLInstance",
1377 new Field(MetaType.Padding(20)),
1378 new Field(MetaType.VarArray(new MetaStruct("PSpLElement",
1379 new Field(MetaType.Enum<PSpLType>(), "Type"),
1380 new Field(MetaType.Pointer(TemplateTag.PSpc), "Part")
1381 )), "Elements")
1382 );
1383
1384 //
1385 // Part Specifications UI template
1386 //
1387
1388 private static readonly MetaStruct psui = new MetaStruct("PSUIInstance",
1389 new Field(MetaType.Pointer(TemplateTag.PSpc), "Background"),
1390 new Field(MetaType.Pointer(TemplateTag.PSpc), "Border"),
1391 new Field(MetaType.Pointer(TemplateTag.PSpc), "Title"),
1392 new Field(MetaType.Pointer(TemplateTag.PSpc), "Grow"),
1393 new Field(MetaType.Pointer(TemplateTag.PSpc), "CloseIdle"),
1394 new Field(MetaType.Pointer(TemplateTag.PSpc), "ClosePressed"),
1395 new Field(MetaType.Pointer(TemplateTag.PSpc), "ZoomIdle"),
1396 new Field(MetaType.Pointer(TemplateTag.PSpc), "ZoomPressed"),
1397 new Field(MetaType.Pointer(TemplateTag.PSpc), "FlattenIdle"),
1398 new Field(MetaType.Pointer(TemplateTag.PSpc), "FlattenPressed"),
1399 new Field(MetaType.Pointer(TemplateTag.PSpc), "TextCaret"),
1400 new Field(MetaType.Pointer(TemplateTag.PSpc), "Outline"),
1401 new Field(MetaType.Pointer(TemplateTag.PSpc), "Button"),
1402 new Field(MetaType.Pointer(TemplateTag.PSpc), "ButtonOff"),
1403 new Field(MetaType.Pointer(TemplateTag.PSpc), "ButtonOn"),
1404 new Field(MetaType.Pointer(TemplateTag.PSpc), "CheckBoxOn"),
1405 new Field(MetaType.Pointer(TemplateTag.PSpc), "CheckBoxOff"),
1406 new Field(MetaType.Pointer(TemplateTag.PSpc), "EditField"),
1407 new Field(MetaType.Pointer(TemplateTag.PSpc), "EditFieldFocused"),
1408 new Field(MetaType.Pointer(TemplateTag.PSpc), "EditFieldHighlighted"),
1409 new Field(MetaType.Pointer(TemplateTag.PSpc), "Divider"),
1410 new Field(MetaType.Pointer(TemplateTag.PSpc), "Check"),
1411 new Field(MetaType.Pointer(TemplateTag.PSpc), "PopupMenu"),
1412 new Field(MetaType.Pointer(TemplateTag.PSpc), "ProgressBarTrack"),
1413 new Field(MetaType.Pointer(TemplateTag.PSpc), "ProgressBarFill"),
1414 new Field(MetaType.Pointer(TemplateTag.PSpc), "RadioButtonOn"),
1415 new Field(MetaType.Pointer(TemplateTag.PSpc), "RadioButtonOff"),
1416 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrowUpIdle"),
1417 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrowUpPressed"),
1418 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrowDownIdle"),
1419 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrowDownPressed"),
1420 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarVerticalTrack"),
1421 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrowLeftIdle"),
1422 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrowLeftPressed"),
1423 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrowRightIdle"),
1424 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarArrorRightPressed"),
1425 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarHorizontalTrack"),
1426 new Field(MetaType.Pointer(TemplateTag.PSpc), "ScrollBarThumb"),
1427 new Field(MetaType.Pointer(TemplateTag.PSpc), "SliderThumb"),
1428 new Field(MetaType.Pointer(TemplateTag.PSpc), "SliderTrack"),
1429 new Field(MetaType.Pointer(TemplateTag.PSpc), "Background2"),
1430 new Field(MetaType.Pointer(TemplateTag.PSpc), "Background3"),
1431 new Field(MetaType.Pointer(TemplateTag.PSpc), "File"),
1432 new Field(MetaType.Pointer(TemplateTag.PSpc), "Folder")
1433 );
1434
1435 //
1436 // Subtitle Array template
1437 //
1438
1439 private static readonly MetaStruct subt = new MetaStruct("SUBTInstance",
1440 new Field(MetaType.Padding(16)),
1441 new BinaryPartField(MetaType.RawOffset, "DataOffset"),
1442 new Field(MetaType.VarArray(MetaType.Int32), "Elements")
1443 );
1444
1445 //
1446 // Index Array template
1447 //
1448
1449 private static readonly MetaStruct idxa = new MetaStruct("IDXAInstance",
1450 new Field(MetaType.Padding(20)),
1451 new Field(MetaType.VarArray(MetaType.Int32), "Indices")
1452 );
1453
1454 //
1455 // Totoro Aiming Screen template
1456 //
1457
1458 private static readonly MetaStruct tras = new MetaStruct("TRASInstance",
1459 new Field(MetaType.Pointer(TemplateTag.TRAM), "Animation"),
1460 new Field(MetaType.Float, "LeftStep"),
1461 new Field(MetaType.Float, "RightStep"),
1462 new Field(MetaType.UInt16, "LeftFrames"),
1463 new Field(MetaType.UInt16, "RightFrames"),
1464 new Field(MetaType.Float, "DownStep"),
1465 new Field(MetaType.Float, "UpStep"),
1466 new Field(MetaType.UInt16, "DownFrames"),
1467 new Field(MetaType.UInt16, "UpFrames")
1468 );
1469
1470 //
1471 // Totoro Animation Sequence template
1472 //
1473
1474 public enum TRAMType : ushort
1475 {
1476 None,
1477 Anything,
1478 Walk,
1479 Run,
1480 Slide,
1481 Jump,
1482 Stand,
1483 StandingTurnLeft,
1484 StandingTurnRight,
1485 RunBackwards,
1486 RunSidestepLeft,
1487 RunSidestepRight,
1488 Kick,
1489 WalkSidestepLeft,
1490 WalkSidestepRight,
1491 WalkBackwards,
1492 Stance,
1493 Crouch,
1494 JumpForward,
1495 JumpBackward,
1496 JumpLeft,
1497 JumpRight,
1498 Punch,
1499 Block,
1500 Land,
1501 Fly,
1502 KickForward,
1503 KickLeft,
1504 KickRight,
1505 KickBack,
1506 KickLow,
1507 PunchForward,
1508 PunchLeft,
1509 PunchRight,
1510 PunchBack,
1511 PunchLow,
1512 Kick2,
1513 Kick3,
1514 Punch2,
1515 Punch3,
1516 LandForward,
1517 LandRight,
1518 LandLeft,
1519 LandBack,
1520 PPK,
1521 PKK,
1522 PKP,
1523 KPK,
1524 KPP,
1525 KKP,
1526 PK,
1527 KP,
1528 PunchHeavy,
1529 KickHeavy,
1530 PunchForwardHeavy,
1531 KickForwardHeavy,
1532 AimingOverlay,
1533 HitOverlay,
1534 CrouchRun,
1535 CrouchWalk,
1536 CrouchRunBackwards,
1537 CrouchWalkBackwards,
1538 CrouchRunSidestepLeft,
1539 CrouchRunSidestepRight,
1540 CrouchWalkSidestepLeft,
1541 CrouchWalkSidestepRight,
1542 RunKick,
1543 RunPunch,
1544 RunBackPunch,
1545 RunBackKick,
1546 SidestepLeftKick,
1547 SidestepLeftPunch,
1548 SidestepRightKick,
1549 SidestepRightPunch,
1550 Prone,
1551 Flip,
1552 HitHead,
1553 HitBody,
1554 HitFoot,
1555 KnockdownHead,
1556 KnockdownBody,
1557 KnockdownFoot,
1558 HitCrouch,
1559 KnockdownCrouch,
1560 HitFallen,
1561 HitHeadBehind,
1562 HitBodyBehind,
1563 HitFootBehind,
1564 KnockdownHeadBehind,
1565 KnockdownBodyBehind,
1566 KnockdownFootBehind,
1567 HitCrouchBehind,
1568 KnockdownCrouchBehind,
1569 Idle,
1570 Taunt,
1571 Throw,
1572 Thrown1,
1573 Thrown2,
1574 Thrown3,
1575 Thrown4,
1576 Thrown5,
1577 Thrown6,
1578 Special1,
1579 Special2,
1580 Special3,
1581 Special4,
1582 ThrowForwardPunch,
1583 ThrowForwardKick,
1584 ThrowBackwardPunch,
1585 ThrowBackwardKick,
1586 RunThrowForwardPunch,
1587 RunThrowBackwardPunch,
1588 RunThrowForwardKick,
1589 RunThrowBackwardKick,
1590 Thrown7,
1591 Thrown8,
1592 Thrown9,
1593 Thrown10,
1594 Thrown11,
1595 Thrown12,
1596 StartleLeft,
1597 StartleRight,
1598 Sit,
1599 StandSpecial,
1600 Act,
1601 Kick3Fw,
1602 HitFootOuch,
1603 HitJewels,
1604 Thrown13,
1605 Thrown14,
1606 Thrown15,
1607 Thrown16,
1608 Thrown17,
1609 PPKK,
1610 PPKKK,
1611 PPKKKK,
1612 LandHard,
1613 LandHardForward,
1614 LandHardRight,
1615 LandHardLeft,
1616 LandHardBack,
1617 LandDead,
1618 CrouchTurnLeft,
1619 CrouchTurnRight,
1620 CrouchForward,
1621 CrouchBack,
1622 CrouchLeft,
1623 CrouchRight,
1624 GetupKickBack,
1625 AutopistolRecoil,
1626 PhaseRifleRecoil,
1627 PhaseStreamRecoil,
1628 SuperballRecoil,
1629 VandegrafRecoil,
1630 ScramCannonRecoil,
1631 MercuryBowRecoil,
1632 ScreamerRecoil,
1633 PickupObject,
1634 PickupPistol,
1635 PickupRifle,
1636 Holster,
1637 DrawPistol,
1638 DrawRifle,
1639 Punch4,
1640 ReloadPistol,
1641 ReloadPhaseRifle,
1642 ReloadPhaseStream,
1643 ReloadSuperball,
1644 ReloadVandegraf,
1645 ReloadScramCannon,
1646 ReloadMercuryBow,
1647 ReloadScreamer,
1648 PfPf,
1649 PfPfPf,
1650 PlPl,
1651 PlPlPl,
1652 PrPr,
1653 PrPrPr,
1654 PbPb,
1655 PbPbPb,
1656 PdPd,
1657 PdPdPd,
1658 KfKf,
1659 KfKfKf,
1660 KlKl,
1661 KlKlKl,
1662 KrKr,
1663 KrKrKr,
1664 KbKb,
1665 KbKbKb,
1666 KdKd,
1667 KdKdKd,
1668 StartleLt,
1669 StartleRt,
1670 StartleBk,
1671 StartleFw,
1672 Console,
1673 ConsoleWalk,
1674 Stagger,
1675 Watch,
1676 ActNo,
1677 ActYes,
1678 ActTalk,
1679 ActShrug,
1680 ActShout,
1681 ActGive,
1682 RunStop,
1683 WalkStop,
1684 RunStart,
1685 WalkStart,
1686 RunBackwardsStart,
1687 WalkBackwardsStart,
1688 Stun,
1689 StaggerBehind,
1690 Blownup,
1691 BlownupBehind,
1692 OneStepStop,
1693 RunSidestepLeftStart,
1694 RunSidestepRightStart,
1695 Powerup,
1696 FallingFlail,
1697 ConsolePunch,
1698 TeleportIn,
1699 TeleportOut,
1700 NinjaFireball,
1701 NinjaInvisible,
1702 PunchRifle,
1703 PickupObjectMid,
1704 PickupPistolMid,
1705 PickupRifleMid,
1706 Hail,
1707 MuroThunderbolt,
1708 HitOverlayAI
1709 }
1710
1711 [Flags]
1712 public enum TRAMFootstepType
1713 {
1714 None = 0,
1715 Left = 1,
1716 Right = 2
1717 }
1718
1719 [Flags]
1720 public enum TRAMAttackFlags
1721 {
1722 None = 0,
1723 Unblockable = 1,
1724 High = 2,
1725 Low = 4,
1726 HalfDamage = 8
1727 }
1728
1729 [Flags]
1730 public enum TRAMVarient
1731 {
1732 None = 0x0000,
1733 Sprint = 0x0100,
1734 Combat = 0x0200,
1735 RightPistol = 0x0800,
1736 LeftPistol = 0x1000,
1737 RightRifle = 0x2000,
1738 LeftRifle = 0x4000,
1739 Panic = 0x8000
1740 }
1741
1742 [Flags]
1743 public enum TRAMBoneFlags : uint
1744 {
1745 None = 0x0000,
1746 Pelvis = 0x0001,
1747 LeftThigh = 0x0002,
1748 LeftCalf = 0x0004,
1749 LeftFoot = 0x0008,
1750 RightThigh = 0x0010,
1751 RightCalf = 0x0020,
1752 RightFoot = 0x0040,
1753 Mid = 0x0080,
1754 Chest = 0x0100,
1755 Neck = 0x0200,
1756 Head = 0x0400,
1757 LeftShoulder = 0x0800,
1758 LeftArm = 0x1000,
1759 LeftWrist = 0x2000,
1760 LeftFist = 0x4000,
1761 RightShoulder = 0x8000,
1762 RightArm = 0x10000,
1763 RightWrist = 0x20000,
1764 RightFist = 0x40000
1765 }
1766
1767 public enum TRAMBone
1768 {
1769 Pelvis,
1770 LeftThigh,
1771 LeftCalf,
1772 LeftFoot,
1773 RightThigh,
1774 RightCalf,
1775 RightFoot,
1776 Mid,
1777 Chest,
1778 Neck,
1779 Head,
1780 LeftShoulder,
1781 LeftArm,
1782 LeftWrist,
1783 LeftFist,
1784 RightShoulder,
1785 RightArm,
1786 RightWrist,
1787 RightFist
1788 }
1789
1790 public enum TRAMDirection
1791 {
1792 None,
1793 Forward,
1794 Backward,
1795 Left,
1796 Right
1797 }
1798
1799 [Flags]
1800 public enum TRAMFlags
1801 {
1802 RuntimeLoaded = 0x00000001,
1803 Invulnerable = 0x00000002,
1804 BlockHigh = 0x00000004,
1805 BlockLow = 0x00000008,
1806 Attack = 0x00000010,
1807 DropWeapon = 0x00000020,
1808 InAir = 0x00000040,
1809 Atomic = 0x00000080,
1810
1811 NoTurn = 0x00000100,
1812 AttackForward = 0x00000200,
1813 AttackLeft = 0x00000400,
1814 AttackRight = 0x00000800,
1815 AttackBackward = 0x00001000,
1816 Overlay = 0x00002000,
1817 DontInterpolateVelocity = 0x00004000,
1818 ThrowSource = 0x00008000,
1819
1820 ThrowTarget = 0x00010000,
1821 RealWorld = 0x00020000,
1822 DoAim = 0x00040000,
1823 DontAim = 0x00080000,
1824 CanPickup = 0x00100000,
1825 Aim360 = 0x00200000,
1826 DisableShield = 0x00400000,
1827 NoAIPickup = 0x00800000
1828 }
1829
1830 public enum TRAMState
1831 {
1832 None,
1833 Anything,
1834 RunningLeftDown,
1835 RunningRightDown,
1836 Sliding,
1837 WalkingLeftDown,
1838 WalkingRightDown,
1839 Standing,
1840 RunStart,
1841 RunAccel,
1842 RunSidestepLeft,
1843 RunSidestepRight,
1844 RunSlide,
1845 RunJump,
1846 RunJumpLand,
1847 RunBackStart,
1848 RunningBackRightDown,
1849 RunningBackLeftDown,
1850 FallenBack,
1851 Crouch,
1852 RunningUpstairRightDown,
1853 RunningUpstairLeftDown,
1854 SidestepLeftLeftDown,
1855 SidestepLeftRightDown,
1856 SidestepRightLeftDown,
1857 SidestepRightRightDown,
1858 SidestepRightJump,
1859 SidestepLeftJump,
1860 JumpForward,
1861 JumpUp,
1862 RunBackSlide,
1863 LieBack,
1864 SsLtStart,
1865 SsRtStart,
1866 WalkingSidestepLeft,
1867 CrouchWalk,
1868 WalkingSidestepRight,
1869 Flying,
1870 Falling,
1871 FlyingForward,
1872 FallingForward,
1873 FlyingBack,
1874 FallingBack,
1875 FlyingLeft,
1876 FallingLeft,
1877 FlyingRight,
1878 FallingRight,
1879 CrouchStart,
1880 WalkingBackLeftDown,
1881 WalkingBackRightDown,
1882 FallenFront,
1883 SidestepLeftStart,
1884 SidestepRightStart,
1885 Sit,
1886 PunchLow,
1887 StandSpecial,
1888 Acting,
1889 CrouchRunLeft,
1890 CrouchRunRight,
1891 CrouchRunBackLeft,
1892 CrouchRunBackRight,
1893 Blocking1,
1894 Blocking2,
1895 Blocking3,
1896 CrouchBlocking1,
1897 Gliding,
1898 WatchIdle,
1899 Stunned,
1900 Powerup,
1901 Thunderbolt
1902 }
1903
1904 private static readonly MetaStruct tram = new MetaStruct("TRAMInstance",
1905 new Field(MetaType.Padding(4)),
1906 new BinaryPartField(MetaType.RawOffset, "Height", "FrameCount", 4,
1907 MetaType.Float),
1908
1909 new BinaryPartField(MetaType.RawOffset, "Velocity", "FrameCount", 8,
1910 MetaType.Vector2),
1911
1912 new BinaryPartField(MetaType.RawOffset, "Attack", "AttackCount", 32, new MetaStruct("TRAMAttack",
1913 new Field(MetaType.Int32, "Bones"),
1914 new Field(MetaType.Float, "Unknown1"),
1915 new Field(MetaType.Int32, "Flags"),
1916 new Field(MetaType.Int16, "HitPoints"),
1917 new Field(MetaType.Int16, "StartFrame"),
1918 new Field(MetaType.Int16, "EndFrame"),
1919 new Field(MetaType.Int16, "AnimationType"),
1920 new Field(MetaType.Int16, "Unknown2"),
1921 new Field(MetaType.Int16, "BlockStun"),
1922 new Field(MetaType.Int16, "Stagger"),
1923 new Field(MetaType.Padding(6)))),
1924
1925 new BinaryPartField(MetaType.RawOffset, "Damage", "DamageCount", 4, new MetaStruct("TRAMDamage",
1926 new Field(MetaType.Int16, "Damage"),
1927 new Field(MetaType.Int16, "Frame"))),
1928
1929 new BinaryPartField(MetaType.RawOffset, "MotionBlur", "MotionBlurCount", 12, new MetaStruct("TRAMMotionBlur",
1930 new Field(MetaType.Int32, "Bones"),
1931 new Field(MetaType.Int16, "StartFrame"),
1932 new Field(MetaType.Int16, "EndFrame"),
1933 new Field(MetaType.Byte, "Lifetime"),
1934 new Field(MetaType.Byte, "Alpha"),
1935 new Field(MetaType.Byte, "Interval"),
1936 new Field(MetaType.Padding(1)))),
1937
1938 new BinaryPartField(MetaType.RawOffset, "Shortcut", "ShortcutCount", 8, new MetaStruct("TRAMShortcut",
1939 new Field(MetaType.Int16, "FromState"),
1940 new Field(MetaType.Byte, "Length"),
1941 new Field(MetaType.Padding(1)),
1942 new Field(MetaType.Int32, "Flags"))),
1943
1944 new BinaryPartField(MetaType.RawOffset, "Throw", 22, new MetaStruct("TRAMThrow",
1945 new Field(MetaType.Vector3, "PositionAdjustment"),
1946 new Field(MetaType.Float, "AngleAdjustment"),
1947 new Field(MetaType.Float, "Distance"),
1948 new Field(MetaType.Int16, "Type"))),
1949
1950 new BinaryPartField(MetaType.RawOffset, "Footstep", "FootstepCount", 4, new MetaStruct("TRAMFootstep",
1951 new Field(MetaType.Int16, "Frame"),
1952 new Field(MetaType.Int16, "Type"))),
1953
1954 new BinaryPartField(MetaType.RawOffset, "Particle", "ParticleCount", 24, new MetaStruct("TRAMParticle",
1955 new Field(MetaType.Int16, "StartFrame"),
1956 new Field(MetaType.Int16, "EndFrame"),
1957 new Field(MetaType.Int32, "Bone"),
1958 new Field(MetaType.String16, "Name"))),
1959
1960 new BinaryPartField(MetaType.RawOffset, "Position", "FrameCount", 8, new MetaStruct("TRAMPosition",
1961 new Field(MetaType.Int16, "X"),
1962 new Field(MetaType.Int16, "Z"),
1963 new Field(MetaType.Int16, "Height"),
1964 new Field(MetaType.Int16, "Y"))),
1965
1966 new BinaryPartField(MetaType.RawOffset, "Rotation"),
1967
1968 new BinaryPartField(MetaType.RawOffset, "Sound", "SoundDataCount", 34, new MetaStruct("TRAMSound",
1969 new Field(MetaType.String32, "SoundName"),
1970 new Field(MetaType.Int16, "StartFrame"))),
1971
1972 new Field(MetaType.Int32, "Flags"),
1973 new Field(MetaType.Array(2, MetaType.Pointer(TemplateTag.TRAM)), "DirectAnimations"),
1974 new Field(MetaType.Int32, "OverlayUsedParts"),
1975 new Field(MetaType.Int32, "OverlayReplacedParts"),
1976 new Field(MetaType.Float, "FinalRotation"),
1977 new Field(MetaType.Int16, "MoveDirection"),
1978 new Field(MetaType.Int16, "AttackSoundIndex"),
1979 new Field(new MetaStruct("TRAMExtentInfo",
1980 new Field(MetaType.Float, "MaxHorizontal"),
1981 new Field(MetaType.Float, "MinY"),
1982 new Field(MetaType.Float, "MaxY"),
1983 new Field(MetaType.Array(36, MetaType.Float), "Horizontal"),
1984 new Field(new MetaStruct("TRAMExtent",
1985 new Field(MetaType.Int16, "Frame"),
1986 new Field(MetaType.Byte, "Attack"),
1987 new Field(MetaType.Byte, "FrameOffset"),
1988 new Field(MetaType.Vector3, "Location"),
1989 new Field(MetaType.Float, "Length"),
1990 new Field(MetaType.Float, "MinY"),
1991 new Field(MetaType.Float, "MaxY"),
1992 new Field(MetaType.Float, "Angle")),
1993 "FirstExtent"),
1994 new Field(new MetaStruct("TRAMExtent",
1995 new Field(MetaType.Int16, "Frame"),
1996 new Field(MetaType.Byte, "Attack"),
1997 new Field(MetaType.Byte, "FrameOffset"),
1998 new Field(MetaType.Vector3, "Location"),
1999 new Field(MetaType.Float, "Length"),
2000 new Field(MetaType.Float, "MinY"),
2001 new Field(MetaType.Float, "MaxY"),
2002 new Field(MetaType.Float, "Angle")),
2003 "MaxExtent"),
2004 new Field(MetaType.Int32, "AlternateMoveDirection"),
2005 new Field(MetaType.Int32, "ExtentCount"),
2006 new BinaryPartField(MetaType.RawOffset, "Extents", "ExtentCount", 12, new MetaStruct("TRAMExtent",
2007 new Field(MetaType.Int16, "Frame"),
2008 new Field(MetaType.Int16, "Angle"),
2009 new Field(MetaType.Int16, "Length"),
2010 new Field(MetaType.Int16, "Offset"),
2011 new Field(MetaType.Int16, "MinY"),
2012 new Field(MetaType.Int16, "MaxY")))),
2013 "ExtentInfo"),
2014 new Field(MetaType.String16, "ImpactParticle"),
2015 new Field(MetaType.Int16, "HardPause"),
2016 new Field(MetaType.Int16, "SoftPause"),
2017 new Field(MetaType.Int32, "SoundDataCount"),
2018 new Field(MetaType.Padding(6)),
2019 new Field(MetaType.Int16, "FramesPerSecond"),
2020 new Field(MetaType.Int16, "CompressionSize"),
2021 new Field(MetaType.Int16, "Type"),
2022 new Field(MetaType.Int16, "AimingType"),
2023 new Field(MetaType.Int16, "FromState"),
2024 new Field(MetaType.Int16, "ToState"),
2025 new Field(MetaType.Int16, "BodyPartCount"),
2026 new Field(MetaType.Int16, "FrameCount"),
2027 new Field(MetaType.Int16, "Duration"),
2028 new Field(MetaType.Int16, "Varient"),
2029 new Field(MetaType.Padding(2)),
2030 new Field(MetaType.Int16, "AtomicStart"),
2031 new Field(MetaType.Int16, "AtomicEnd"),
2032 new Field(MetaType.Int16, "EndInterpolation"),
2033 new Field(MetaType.Int16, "MaxInterpolation"),
2034 new Field(MetaType.Int16, "ActionFrame"),
2035 new Field(MetaType.Int16, "FirstLevelAvailable"),
2036 new Field(MetaType.Byte, "InvulnerableStart"),
2037 new Field(MetaType.Byte, "InvulnerableEnd"),
2038
2039 new Field(MetaType.Byte, "AttackCount"),
2040 new Field(MetaType.Byte, "DamageCount"),
2041 new Field(MetaType.Byte, "MotionBlurCount"),
2042 new Field(MetaType.Byte, "ShortcutCount"),
2043 new Field(MetaType.Byte, "FootstepCount"),
2044 new Field(MetaType.Byte, "ParticleCount")
2045 );
2046
2047 //
2048 // Animation Collection template
2049 //
2050
2051 private static readonly MetaStruct trac = new MetaStruct("TRACInstance",
2052 new Field(MetaType.Padding(16)),
2053 new Field(MetaType.Pointer(TemplateTag.TRAC), "ParentCollection"),
2054 new Field(MetaType.Padding(2)),
2055 new Field(MetaType.ShortVarArray(new MetaStruct("TRACAnimation",
2056 new Field(MetaType.Int16, "Weight"),
2057 new Field(MetaType.Padding(6)),
2058 new Field(MetaType.Pointer(TemplateTag.TRAM), "Animation")
2059 )), "Animations")
2060 );
2061
2062 //
2063 // Totoro Quaternion Body template
2064 //
2065
2066 private static readonly MetaStruct trcm = new MetaStruct("TRCMInstance",
2067 new Field(MetaType.Padding(4)),
2068 new Field(MetaType.UInt16, "BodyPartCount"),
2069 new Field(MetaType.Padding(78)),
2070 new Field(MetaType.Pointer(TemplateTag.TRGA), "Geometry"),
2071 new Field(MetaType.Pointer(TemplateTag.TRTA), "Position"),
2072 new Field(MetaType.Pointer(TemplateTag.TRIA), "Hierarchy")
2073 );
2074
2075 //
2076 // Totoro Body Set template
2077 //
2078
2079 private static readonly MetaStruct trbs = new MetaStruct("TRBSInstance",
2080 new Field(MetaType.Array(5, MetaType.Pointer(TemplateTag.TRCM)), "Elements")
2081 );
2082
2083 //
2084 // Texture Map Array template
2085 //
2086
2087 private static readonly MetaStruct trma = new MetaStruct("TRMAInstance",
2088 new Field(MetaType.Padding(22)),
2089 new Field(MetaType.ShortVarArray(MetaType.Pointer(TemplateTag.TXMP)), "Textures")
2090 );
2091
2092 //
2093 // Totoro Quaternion Body Geometry Array template
2094 //
2095
2096 private static readonly MetaStruct trga = new MetaStruct("TRGAInstance",
2097 new Field(MetaType.Padding(22)),
2098 new Field(MetaType.ShortVarArray(MetaType.Pointer(TemplateTag.M3GM)), "Geometries")
2099 );
2100
2101 //
2102 // Totoro Quaternion Body Index Array template
2103 //
2104
2105 private static readonly MetaStruct tria = new MetaStruct("TRIAInstance",
2106 new Field(MetaType.Padding(22)),
2107 new Field(MetaType.ShortVarArray(new MetaStruct("TRIAElement",
2108 new Field(MetaType.Byte, "Parent"),
2109 new Field(MetaType.Byte, "Child"),
2110 new Field(MetaType.Byte, "Sibling"),
2111 new Field(MetaType.Padding(1))
2112 )), "Elements")
2113 );
2114
2115 //
2116 // Screen (aiming) Collection template
2117 //
2118
2119 private static readonly MetaStruct trsc = new MetaStruct("TRSCInstance",
2120 new Field(MetaType.Padding(22)),
2121 new Field(MetaType.ShortVarArray(MetaType.Pointer(TemplateTag.TRAS)), "AimingScreens")
2122 );
2123
2124 //
2125 // Totoro Quaternion Body Translation Array template
2126 //
2127
2128 private static readonly MetaStruct trta = new MetaStruct("TRTAInstance",
2129 new Field(MetaType.Padding(22)),
2130 new Field(MetaType.ShortVarArray(MetaType.Vector3), "Translations")
2131 );
2132
2133 //
2134 // Font template
2135 //
2136
2137 private static readonly MetaStruct tsft = new MetaStruct("TSFTInstance",
2138 new Field(MetaType.Padding(6)),
2139 new Field(MetaType.Int16, "FontSize"),
2140 new Field(MetaType.Int32, "FontStyle"),
2141 new Field(MetaType.Int16, "AscenderHeight"),
2142 new Field(MetaType.Int16, "DescenderHeight"),
2143 new Field(MetaType.Int16, "LeadingHeight"),
2144 new Field(MetaType.Int16, ""),
2145 new Field(MetaType.Array(256, MetaType.Pointer(TemplateTag.TSGA)), "Glyphs"),
2146 new Field(MetaType.VarArray(MetaType.Int32), "GlyphBitmaps")
2147 );
2148
2149 //
2150 // Font Family template
2151 //
2152
2153 private static readonly MetaStruct tsff = new MetaStruct("TSFFInstance",
2154 new Field(MetaType.Padding(16)),
2155 new Field(MetaType.Pointer(TemplateTag.TSFL), "Language"),
2156 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.TSFT)), "Fonts")
2157 );
2158
2159 //
2160 // Font Language template
2161 //
2162
2163 private static readonly MetaStruct tsfl = new MetaStruct("TSFLInstance",
2164 new Field(MetaType.String64, ""),
2165 new Field(MetaType.String64, "Breaking"),
2166 new Field(MetaType.String64, ""),
2167 new Field(MetaType.String64, ""),
2168 new Field(MetaType.String64, "")
2169 );
2170
2171 //
2172 // Glyph Array template
2173 //
2174
2175 private static readonly MetaStruct tsga = new MetaStruct("TSGAInstance",
2176 new Field(MetaType.Array(256, new MetaStruct("TSGAGlyph",
2177 new Field(MetaType.Int16, "Index"),
2178 new Field(MetaType.Int16, "Width"),
2179 new Field(MetaType.Int16, "GlyphWidth"),
2180 new Field(MetaType.Int16, "GlyphHeight"),
2181 new Field(MetaType.Int16, "GlyphXOrigin"),
2182 new Field(MetaType.Int16, "GlyphYOrigin"),
2183 new Field(MetaType.Int32, "GlyphBitmapOffset"),
2184 new Field(MetaType.Padding(4))
2185 )), "Glyphs")
2186 );
2187
2188 //
2189 // WM Cursor List template
2190 //
2191
2192 private static readonly MetaStruct wmcl = new MetaStruct("WMCLInstance",
2193 new Field(MetaType.Padding(20)),
2194 new Field(MetaType.VarArray(new MetaStruct("WMCLCursor",
2195 new Field(MetaType.Int32, "Id"),
2196 new Field(MetaType.Pointer(TemplateTag.PSpc), "Part")
2197 )), "Cursors")
2198 );
2199
2200 //
2201 // WM Dialog Data template
2202 //
2203
2204 [Flags]
2205 private enum WMDDState
2206 {
2207 None = 0x00,
2208 Visible = 0x01,
2209 Disabled = 0x02,
2210 State04 = 0x04
2211 }
2212
2213 [Flags]
2214 private enum WMDDStyle : uint
2215 {
2216 None = 0x00,
2217 ThinBorder = 0x01,
2218 ThickBorder = 0x02,
2219 TitleBar = 0x04,
2220 Title = 0x08,
2221 CloseButton = 0x10,
2222 RestoreButton = 0x20,
2223 MinimizeButton = 0x40,
2224 Center = 0x00010000
2225 }
2226
2227 private enum WMDDControlFontStyle : uint
2228 {
2229 Normal = 0,
2230 Bold = 1,
2231 Italic = 2
2232 }
2233
2234 private enum WMDDControlClass : ushort
2235 {
2236 Desktop = 1,
2237 Title = 3,
2238 Button = 4,
2239 Checkbox = 5,
2240 Dialog = 6,
2241 Textbox = 7,
2242 Listbox = 8,
2243 MenuBar = 9,
2244 Menu = 10,
2245 Image = 11,
2246 Dropdown = 12,
2247 ProgressBar = 13,
2248 RadioButton = 14,
2249 Slider = 17,
2250 Label = 20
2251 }
2252
2253 private static readonly MetaStruct wmdd = new MetaStruct("WMDDInstance",
2254 new Field(MetaType.String256, "Caption"),
2255 new Field(MetaType.Int16, "Id"),
2256 new Field(MetaType.Padding(2)),
2257 new Field(MetaType.Enum<WMDDState>(), "State"),
2258 new Field(MetaType.Enum<WMDDStyle>(), "Style"),
2259 new Field(MetaType.Int16, "X"),
2260 new Field(MetaType.Int16, "Y"),
2261 new Field(MetaType.Int16, "Width"),
2262 new Field(MetaType.Int16, "Height"),
2263 new Field(MetaType.VarArray(new MetaStruct("WMDDControl",
2264 new Field(MetaType.String256, "Text"),
2265 new Field(MetaType.Enum<WMDDControlClass>(), "Class"),
2266 new Field(MetaType.Int16, "Id"),
2267 new Field(MetaType.Int32, "State"),
2268 new Field(MetaType.Int32, "Style"),
2269 new Field(MetaType.Int16, "X"),
2270 new Field(MetaType.Int16, "Y"),
2271 new Field(MetaType.Int16, "Width"),
2272 new Field(MetaType.Int16, "Height"),
2273 new Field(new MetaStruct("WMDDFont",
2274 new Field(MetaType.Pointer(TemplateTag.TSFF), "Family"),
2275 new Field(MetaType.Enum<WMDDControlFontStyle>(), "Style"),
2276 new Field(MetaType.Color, "Color"),
2277 new Field(MetaType.Padding(1, 1)),
2278 new Field(MetaType.Padding(1, 0)),
2279 new Field(MetaType.Int16, "Size")),
2280 "Font")
2281 )), "Controls")
2282 );
2283
2284 //
2285 // WM Menu Bar template
2286 //
2287
2288 private static readonly MetaStruct wmmb = new MetaStruct("WMMBInstance",
2289 new Field(MetaType.Padding(18)),
2290 new Field(MetaType.Int16, "Id"),
2291 new Field(MetaType.VarArray(MetaType.Pointer(TemplateTag.WMM_)), "Items")
2292 );
2293
2294 //
2295 // WM Menu template
2296 //
2297
2298 private enum WMM_MenuItemType : ushort
2299 {
2300 Separator = 1,
2301 Option = 2
2302 }
2303
2304 private static readonly MetaStruct wmm_ = new MetaStruct("WMM_Instance",
2305 new Field(MetaType.Padding(18)),
2306 new Field(MetaType.Int16, "Id"),
2307 new Field(MetaType.String64, "Text"),
2308 new Field(MetaType.VarArray(new MetaStruct("WMM_MenuItem",
2309 new Field(MetaType.Enum<WMM_MenuItemType>(), "Type"),
2310 new Field(MetaType.Int16, "Id"),
2311 new Field(MetaType.String64, "Text")
2312 )), "Items")
2313 );
2314
2315 //
2316 // Oni Weapon Class template
2317 //
2318
2319 [Flags]
2320 public enum ONWCFlags : uint
2321 {
2322 None = 0x00000000,
2323 NoHolster = 0x00000002,
2324 UsesCells = 0x00000004,
2325 TwoHanded = 0x00000008,
2326
2327 RecoilAffectsAiming = 0x00000010,
2328 Automatic = 0x00000020,
2329 StunSwitcher = 0x00000080,
2330
2331 KnockdownSwitcher = 0x00000100,
2332 Explosive = 0x00000200,
2333 SecondaryFire = 0x00000400,
2334 BarabbasWeapon = 0x00000800,
2335
2336 Heavy = 0x00001000,
2337 AutoRelease = 0x00002000,
2338 HasReleaseDelay = 0x00004000,
2339 HasLaserSight = 0x00008000,
2340
2341 ScaleCrosshair = 0x00020000,
2342 NoFade = 0x00080000,
2343 DrainAmmo = 0x00100000
2344 }
2345
2346 private static readonly MetaStruct onwc = new MetaStruct("ONWCInstance",
2347 new Field(new MetaStruct("ONWCLaserSight",
2348 new Field(MetaType.Vector3, "Origin"),
2349 new Field(MetaType.Float, "Stiffness"),
2350 new Field(MetaType.Float, "AdditionalAzimuth"),
2351 new Field(MetaType.Float, "AdditionalElevation"),
2352 new Field(MetaType.Float, "LaserMaxLength"),
2353 new Field(MetaType.Color, "LaserColor"),
2354 new Field(MetaType.Pointer(TemplateTag.TXMP), "NormalTexture"),
2355 new Field(MetaType.Color, "NormalColor"),
2356 new Field(MetaType.Float, "NormalScale"),
2357 new Field(MetaType.Pointer(TemplateTag.TXMP), "LockedTexture"),
2358 new Field(MetaType.Color, "LockedColor"),
2359 new Field(MetaType.Float, "LockedScale"),
2360 new Field(MetaType.Pointer(TemplateTag.TXMP), "TunnelTexture"),
2361 new Field(MetaType.Color, "TunnelColor"),
2362 new Field(MetaType.Float, "TunnelScale"),
2363 new Field(MetaType.Int32, "TunnelCount"),
2364 new Field(MetaType.Float, "TunnelSpacing")),
2365 "LaserSight"),
2366 new Field(new MetaStruct("ONWCAmmoMeter",
2367 new Field(MetaType.Pointer(TemplateTag.TXMP), "Icon"),
2368 new Field(MetaType.Pointer(TemplateTag.TXMP), "Empty"),
2369 new Field(MetaType.Pointer(TemplateTag.TXMP), "Fill")),
2370 "AmmoMeter"),
2371 new Field(MetaType.Pointer(TemplateTag.M3GM), "Geometry"),
2372 new Field(MetaType.String32, "Name"),
2373 new Field(MetaType.Float, "MouseSensitivity"),
2374 new Field(new MetaStruct("ONWCRecoil",
2375 new Field(MetaType.Float, "Base"),
2376 new Field(MetaType.Float, "Max"),
2377 new Field(MetaType.Float, "Factor"),
2378 new Field(MetaType.Float, "ReturnSpeed"),
2379 new Field(MetaType.Float, "FiringReturnSpeed")),
2380 "Recoil"),
2381 new Field(MetaType.Padding(36)),
2382 new Field(MetaType.Padding(2)),
2383 new Field(MetaType.Enum<TRAMType>(), "RecoilAnimationType"),
2384 new Field(MetaType.Enum<TRAMType>(), "ReloadAnimationType"),
2385 new Field(MetaType.Int16, "PauseAfterReload"),
2386 new Field(MetaType.Int16, "MaxShots"),
2387 new Field(MetaType.Int16, "ParticleCount"),
2388 new Field(MetaType.Int16, "FiringModeCount"),
2389 new Field(MetaType.Int16, "PauseBeforeReload"),
2390 new Field(MetaType.Int16, "ReleaseDelay"),
2391 new Field(MetaType.Padding(2)),
2392 new Field(MetaType.Enum<ONWCFlags>(), "Flags"),
2393
2394 new Field(MetaType.Array(2, aiFiringMode), "FiringModes"),
2395
2396 new Field(MetaType.Array(16, new MetaStruct("ONWCParticle",
2397 new Field(MetaType.Matrix4x3, "Transform"),
2398 new Field(MetaType.String16, "ParticleClass"),
2399 new Field(MetaType.Padding(4)),
2400 new Field(MetaType.Int16, "UsedAmmo"),
2401 new Field(MetaType.Int16, "ShotDelay"),
2402 new Field(MetaType.Int16, "RoughJusticeShotDelay"),
2403 new Field(MetaType.Int16, "ActiveFrames"),
2404 new Field(MetaType.Int16, "TriggeredBy"),
2405 new Field(MetaType.Int16, "DelayBeforeFiring")
2406 )), "Particles"),
2407
2408 new Field(MetaType.String32, "EmptyWeaponSound"),
2409 new Field(MetaType.Padding(4)),
2410 new Field(MetaType.Pointer(TemplateTag.TXMP), "Glow"),
2411 new Field(MetaType.Pointer(TemplateTag.TXMP), "GlowAmmo"),
2412 new Field(MetaType.Vector2, "GlowTextureScale"),
2413 new Field(MetaType.Vector3, "PickupHandleOffset"),
2414 new Field(MetaType.Float, "HoveringHeight")
2415 );
2416
2417 public enum TXMPFormat : uint
2418 {
2419 BGRA4444 = 0,
2420 BGR555 = 1,
2421 BGRA5551 = 2,
2422 RGBA = 7,
2423 BGR = 8,
2424 DXT1 = 9
2425 }
2426
2427 [Flags]
2428 public enum TXMPFlags : uint
2429 {
2430 None = 0x0000,
2431 HasMipMaps = 0x0001,
2432 DisableUWrap = 0x0004,
2433 DisableVWrap = 0x0008,
2434 Unknown0010 = 0x0010,
2435 AnimBackToBack = 0x0040,
2436 AnimRandom = 0x0080,
2437 AnimUseLocalTime = 0x0100,
2438 HasEnvMap = 0x0200,
2439 AdditiveBlend = 0x0400,
2440 SwapBytes = 0x1000,
2441 AnimIgnoreGlobalTime = 0x4000,
2442 ShieldEffect = 0x8000,
2443 InvisibilityEffect = 0x10000,
2444 DaodanEffect = 0x20000,
2445 }
2446
2447 //
2448 // Obsolete instances
2449 //
2450
2451 //
2452 // AI script trigger array template
2453 //
2454
2455 private static readonly MetaStruct aitr = new MetaStruct("AITRInstance",
2456 new Field(MetaType.Padding(22)),
2457 new Field(MetaType.ShortVarArray(new MetaStruct("AITRElement",
2458 new Field(MetaType.Int16, ""),
2459 new Field(MetaType.Int16, ""),
2460 new Field(MetaType.Int16, ""),
2461 new Field(MetaType.Int16, ""),
2462 new Field(MetaType.Int16, ""),
2463 new Field(MetaType.Int16, ""),
2464 new Field(MetaType.Int32, ""),
2465 new Field(MetaType.Int32, ""),
2466 new Field(MetaType.String64, "")
2467 )), "Elements")
2468 );
2469
2470 //
2471 // Gunk Quad Debug Array template
2472 //
2473
2474 private static readonly MetaStruct agdb = new MetaStruct("AGDBInstance",
2475 new Field(MetaType.Padding(20)),
2476 new Field(MetaType.VarArray(new MetaStruct("AGDBElement",
2477 new BinaryPartField(MetaType.RawOffset, "ObjectNameDataOffset"),
2478 new BinaryPartField(MetaType.RawOffset, "FileNameDataOffset")
2479 )), "Elements")
2480 );
2481
2482 //
2483 // Door Frame Array template
2484 //
2485
2486 private static readonly MetaStruct akda = new MetaStruct("AKDAInstance",
2487 new Field(MetaType.Padding(20)),
2488 new Field(MetaType.Padding(4))
2489 //new Field(MetaType.LongVarArray(new MetaStruct("AKDADoorFrame",
2490 // new Field(MetaType.Int32, "QuadId"),
2491 // new Field(MetaType.BoundingBox, "BoundingBox"),
2492 // new Field(MetaType.Vector3, "Center"),
2493 // new Field(MetaType.Vector3, "Size")
2494 //)), "DoorFrames")
2495 );
2496
2497 //
2498 // Door class array template
2499 //
2500
2501 private static readonly MetaStruct obdc = new MetaStruct("OBDCInstance",
2502 new Field(MetaType.Padding(22)),
2503 new Field(MetaType.ShortVarArray(new MetaStruct("OBDCElement",
2504 new Field(MetaType.Int16, ""),
2505 new Field(MetaType.Int16, ""),
2506 new Field(MetaType.Pointer(TemplateTag.OBAN), "Animation"),
2507 new Field(MetaType.Padding(4)),
2508 new Field(MetaType.Int32, ""),
2509 new Field(MetaType.Padding(8))
2510 )), "Elements")
2511 );
2512
2513 //
2514 // Imported Flag Node Array template
2515 //
2516
2517 private static readonly MetaStruct onfa = new MetaStruct("ONFAInstance",
2518 new Field(MetaType.Padding(20)),
2519 new Field(MetaType.Int16, "UsedElements"),
2520 new Field(MetaType.ShortVarArray(new MetaStruct("ONFAElement",
2521 new Field(MetaType.Matrix4x3, "Transform"),
2522 new Field(MetaType.Vector3, "Position"),
2523 new Field(MetaType.Int32, ""),
2524 new Field(MetaType.Int16, "FlagId"),
2525 new Field(MetaType.Byte, ""),
2526 new Field(MetaType.Byte, "")
2527 )), "Elements")
2528 );
2529
2530 //
2531 // Imported Marker Node Array template
2532 //
2533
2534 private static readonly MetaStruct onma = new MetaStruct("ONMAInstance",
2535 new Field(MetaType.Padding(22)),
2536 new Field(MetaType.ShortVarArray(new MetaStruct("ONMAElement",
2537 new Field(MetaType.String64, "Name"),
2538 new Field(MetaType.Vector3, "Position"),
2539 new Field(MetaType.Vector3, "Direction")
2540 )), "Markers")
2541 );
2542
2543 //
2544 // Imported Spawn Array template
2545 //
2546
2547 private static readonly MetaStruct onsa = new MetaStruct("ONSAInstance",
2548 new Field(MetaType.Padding(22)),
2549 new Field(MetaType.ShortVarArray(MetaType.Int16), "Elements")
2550 );
2551
2552 //
2553 // Trigger Array template
2554 //
2555
2556 private static readonly MetaStruct onta = new MetaStruct("ONTAInstance",
2557 new Field(MetaType.Padding(16)),
2558 new Field(MetaType.Int32, ""),
2559 new Field(MetaType.VarArray(new MetaStruct(
2560 new Field(MetaType.Array(8, new MetaStruct(
2561 new Field(MetaType.Int32, ""),
2562 new Field(MetaType.Int32, ""),
2563 new Field(MetaType.Int32, "")
2564 )), ""),
2565 new Field(MetaType.Array(6, new MetaStruct(
2566 new Field(MetaType.Array(4, MetaType.Int32), "")
2567 )), ""),
2568 new Field(MetaType.Array(6, new MetaStruct(
2569 new Field(MetaType.Int32, ""),
2570 new Field(MetaType.Int32, ""),
2571 new Field(MetaType.Int32, "")
2572 )), ""),
2573 new Field(MetaType.Array(6, new MetaStruct(
2574 new Field(MetaType.Int32, ""),
2575 new Field(MetaType.Int32, ""),
2576 new Field(MetaType.Int32, ""),
2577 new Field(MetaType.Int32, "")
2578 )), ""),
2579 new Field(MetaType.Array(6, MetaType.Int16), ""),
2580 new Field(MetaType.Int32, ""),
2581 new Field(MetaType.Int32, ""),
2582 new Field(MetaType.Int32, ""),
2583 new Field(MetaType.Int32, ""),
2584 new Field(MetaType.Int32, ""),
2585 new Field(MetaType.Int32, ""),
2586 new Field(MetaType.Int32, ""),
2587 new Field(MetaType.Int32, ""),
2588 new Field(MetaType.Int32, ""),
2589 new Field(MetaType.Int32, ""),
2590 new Field(MetaType.Int32, "")
2591 )), "")
2592 );
2593
2594 //
2595 // String Array template
2596 //
2597
2598 private static readonly MetaStruct stna = new MetaStruct("StNAInstance",
2599 new Field(MetaType.Padding(22)),
2600 new Field(MetaType.ShortVarArray(MetaType.Pointer(TemplateTag.TStr)), "Names")
2601 );
2602
2603 //
2604 // String template
2605 //
2606
2607 private static readonly MetaStruct tstr = new MetaStruct("TStrInstance",
2608 new Field(MetaType.String128, "Text")
2609 );
2610
2611 protected virtual void InitializeTemplates(IList<Template> templates)
2612 {
2613 templates.Add(new Template(TemplateTag.AISA, aisa, 0x2a224c6be9, "AI Character Setup Array"));
2614 templates.Add(new Template(TemplateTag.AITR, aitr, 0x1aea55, "AI Script Trigger Array"));
2615 templates.Add(new Template(TemplateTag.AKAA, akaa, 0x11de77, "Adjacency Array"));
2616 templates.Add(new Template(TemplateTag.ABNA, abna, 0x126da0, "BSP Tree Node Array"));
2617 templates.Add(new Template(TemplateTag.AKVA, akva, 0xdf05e0, "BNV Node Array"));
2618 templates.Add(new Template(TemplateTag.AKBA, akba, 0x3a2884, "Side Array"));
2619 templates.Add(new Template(TemplateTag.AKBP, akbp, 0xcf449, "BSP Node Array"));
2620 templates.Add(new Template(TemplateTag.AKDA, akda, 0x2e5464, "Door Frame Array"));
2621 templates.Add(new Template(TemplateTag.AKEV, akev, 0x883014de75, "Akira Environment"));
2622 templates.Add(new Template(TemplateTag.AGQC, agqc, 0x1ccb91, "Gunk Quad Collision Array"));
2623 templates.Add(new Template(TemplateTag.AGDB, agdb, 0x72e17, "Gunk Quad Debug Array"));
2624 templates.Add(new Template(TemplateTag.AGQG, agqg, 0x1c03d2, "Gunk Quad General Array"));
2625 templates.Add(new Template(TemplateTag.AGQR, agqr, 0x83a3b, "Gunk Quad Render Array"));
2626 templates.Add(new Template(TemplateTag.AKOT, akot, 0x11e7b8da08, "Oct tree"));
2627 templates.Add(new Template(TemplateTag.OTIT, otit, 0xa51d2, "Oct Tree Interior Node Array"));
2628 templates.Add(new Template(TemplateTag.OTLF, otlf, 0x1eac0b, "Oct Tree Leaf Node Array"));
2629 templates.Add(new Template(TemplateTag.QTNA, qtna, 0x66ecc, "Quad Tree Node Array"));
2630 templates.Add(new Template(TemplateTag.ENVP, envp, 0x67c1c3, "Env Particle Array"));
2631 templates.Add(new Template(TemplateTag.M3GM, m3gm, 0x27a078e436, "Geometry"));
2632 templates.Add(new Template(TemplateTag.M3GA, m3ga, 0x5206b20b2, "GeometryArray"));
2633 templates.Add(new Template(TemplateTag.PLEA, plea, 0x7bc38, "Plane Equation Array"));
2634 templates.Add(new Template(TemplateTag.PNTA, pnta, 0x37676c, "3D Point Array"));
2635 templates.Add(new Template(TemplateTag.TXCA, txca, 0x9141a, "Texture Coordinate Array"));
2636 templates.Add(new Template(TemplateTag.TXAN, txan, 0xa8b134387, "Texture Map Animation"));
2637 templates.Add(new Template(TemplateTag.TXMA, txma, 0x599de7f90, "Texture map array"));
2638 templates.Add(new Template(TemplateTag.TXMB, txmb, 0xa8b166a52, "Texture Map Big"));
2639 templates.Add(new Template(TemplateTag.VCRA, vcra, 0x54739, "3D Vector Array"));
2640 templates.Add(new Template(TemplateTag.Impt, impt, 0x44f16, "Impact"));
2641 templates.Add(new Template(TemplateTag.Mtrl, mtrl, 0x28e0d, "Material"));
2642 templates.Add(new Template(TemplateTag.CONS, cons, 0x13da8b0bdd, "Console"));
2643 templates.Add(new Template(TemplateTag.DOOR, door, 0x63172fd67, "Door"));
2644 templates.Add(new Template(TemplateTag.OBLS, obls, 0xb703d, "Object LS Data"));
2645 templates.Add(new Template(TemplateTag.OFGA, ofga, 0x1374fac362, "Object Furn Geom Array"));
2646 templates.Add(new Template(TemplateTag.TRIG, trig, 0x21dcd0cd2c, "Trigger"));
2647 templates.Add(new Template(TemplateTag.TRGE, trge, 0x871a6b93c, "Trigger Emitter"));
2648 templates.Add(new Template(TemplateTag.TURR, turr, 0x49c85805be, "Turret"));
2649 templates.Add(new Template(TemplateTag.OBAN, oban, 0x4e0c24, "Object animation"));
2650 templates.Add(new Template(TemplateTag.OBDC, obdc, 0x7bd9eca0b, "Door Class Array"));
2651 templates.Add(new Template(TemplateTag.OBOA, oboa, 0x134f8986e1, "Starting Object Array"));
2652 templates.Add(new Template(TemplateTag.CBPI, cbpi, 0xc0bf9d6c2, "Character Body Part Impacts"));
2653 templates.Add(new Template(TemplateTag.CBPM, cbpm, 0x26ba4351f, "Character Body Part Material"));
2654 templates.Add(new Template(TemplateTag.ONCC, oncc, 0x4a5aac759ef, "Oni Character Class"));
2655 templates.Add(new Template(TemplateTag.ONIA, onia, 0x2b2f9a, "Oni Character Impact Array"));
2656 templates.Add(new Template(TemplateTag.ONCP, oncp, 0x2f7321, "Oni Character Particle Array"));
2657 templates.Add(new Template(TemplateTag.ONCV, oncv, 0x299f5, "Oni Character Variant"));
2658 templates.Add(new Template(TemplateTag.CRSA, crsa, 0xc1543d4cc, "Corpse Array"));
2659 templates.Add(new Template(TemplateTag.DPge, dpge, 0x7ba8a686b, "Diary Page"));
2660 templates.Add(new Template(TemplateTag.FILM, film, 0xb331b62ad, "Film"));
2661 templates.Add(new Template(TemplateTag.ONFA, onfa, 0x1b0ce7, "Imported Flag Node Array"));
2662 templates.Add(new Template(TemplateTag.ONGS, ongs, 0x226ebb6, "Oni Game Settings"));
2663 templates.Add(new Template(TemplateTag.HPge, hpge, 0x44b2f713b, "Help Page"));
2664 templates.Add(new Template(TemplateTag.IGHH, ighh, 0x8e58e58de, "IGUI HUD Help"));
2665 templates.Add(new Template(TemplateTag.IGPG, igpg, 0x11ce67887d, "IGUI Page"));
2666 templates.Add(new Template(TemplateTag.IGPA, igpa, 0x4ddbe0905, "IGUI Page Array"));
2667 templates.Add(new Template(TemplateTag.IGSt, igst, 0x2a2a47725, "IGUI String"));
2668 templates.Add(new Template(TemplateTag.IGSA, igsa, 0x4ddbea408, "IGUI String Array"));
2669 templates.Add(new Template(TemplateTag.IPge, ipge, 0x2938369ba, "Item Page"));
2670 templates.Add(new Template(TemplateTag.KeyI, keyi, 0x403f4757ad, "Key Icons"));
2671 templates.Add(new Template(TemplateTag.ONLV, onlv, 0x7db79a2ea3, "Oni Game Level"));
2672 templates.Add(new Template(TemplateTag.ONLD, onld, 0x412a1, "Oni Game Level Descriptor"));
2673 templates.Add(new Template(TemplateTag.ONMA, onma, 0x124779, "Imported Marker Node Array"));
2674 templates.Add(new Template(TemplateTag.ONOA, onoa, 0x64be75c7c, "Object Gunk Array"));
2675 templates.Add(new Template(TemplateTag.OPge, opge, 0x44b30bbfb, "Objective Page"));
2676 templates.Add(new Template(TemplateTag.ONSK, onsk, 0x14c2261067, "Oni Sky class"));
2677 templates.Add(new Template(TemplateTag.ONSA, onsa, 0x44634, "Imported Spawn Array"));
2678 templates.Add(new Template(TemplateTag.TxtC, txtc, 0x1b7ac8b27, "Text Console"));
2679 templates.Add(new Template(TemplateTag.ONTA, onta, 0xa0fcc0, "Trigger Array"));
2680 templates.Add(new Template(TemplateTag.ONVL, onvl, 0x54434c58a, "Oni Variant List"));
2681 templates.Add(new Template(TemplateTag.WPge, wpge, 0x46f5889b5, "Weapon Page"));
2682 templates.Add(new Template(TemplateTag.PSpc, pspc, 0x82648, "Part Specification"));
2683 templates.Add(new Template(TemplateTag.PSpL, pspl, 0xccc05, "Part Specification List"));
2684 templates.Add(new Template(TemplateTag.PSUI, psui, 0x3cd544e96fb, "Part Specifications UI"));
2685 templates.Add(new Template(TemplateTag.SUBT, subt, 0x46c68, "Subtitle Array"));
2686 templates.Add(new Template(TemplateTag.IDXA, idxa, 0x2708f, "Index Array"));
2687 templates.Add(new Template(TemplateTag.TStr, tstr, 0x64a0, "String"));
2688 templates.Add(new Template(TemplateTag.StNA, stna, 0x5998cb520, "String Array"));
2689 templates.Add(new Template(TemplateTag.TRAS, tras, 0x1fa21a930, "Totoro Aiming Screen"));
2690 templates.Add(new Template(TemplateTag.TRAM, tram, 0x107e3cc918, "Totoro Animation Sequence"));
2691 templates.Add(new Template(TemplateTag.TRAC, trac, 0xf26e9fb2f, "Animation Collection"));
2692 templates.Add(new Template(TemplateTag.TRCM, trcm, 0x2392de054e, "Totoro Quaternion Body"));
2693 templates.Add(new Template(TemplateTag.TRBS, trbs, 0x2a2924239, "Totoro Body Set"));
2694 templates.Add(new Template(TemplateTag.TRMA, trma, 0x599de6d57, "Texture Map Array"));
2695 templates.Add(new Template(TemplateTag.TRGA, trga, 0x5206b20f8, "Totoro Quaternion Body Geometry Array"));
2696 templates.Add(new Template(TemplateTag.TRIA, tria, 0xac482, "Totoro Quaternion Body Index Array"));
2697 templates.Add(new Template(TemplateTag.TRSC, trsc, 0x599786b17, "Screen (aiming) Collection"));
2698 templates.Add(new Template(TemplateTag.TRTA, trta, 0x759e8, "Totoro Quaternion Body Translation Array"));
2699 templates.Add(new Template(TemplateTag.TSFT, tsft, 0x16ba91deea, "Font"));
2700 templates.Add(new Template(TemplateTag.TSFF, tsff, 0xa8a6c488a, "Font Family"));
2701 templates.Add(new Template(TemplateTag.TSFL, tsfl, 0x8de29, "Font Language"));
2702 templates.Add(new Template(TemplateTag.TSGA, tsga, 0x2a4e98, "Glyph Array"));
2703 templates.Add(new Template(TemplateTag.WMCL, wmcl, 0x9d076, "WM Cursor List"));
2704 templates.Add(new Template(TemplateTag.WMDD, wmdd, 0x1c001df3c4, "WM Dialog Data"));
2705 templates.Add(new Template(TemplateTag.WMMB, wmmb, 0x6d20c6737, "WM Menu Bar"));
2706 templates.Add(new Template(TemplateTag.WMM_, wmm_, 0xc1a38, "WM Menu"));
2707 templates.Add(new Template(TemplateTag.ONWC, onwc, 0x193a3e0eeb5, "Oni Weapon Class"));
2708 }
2709
2710 private static void GetRawAndSepPartsV32(InstanceFile file, Dictionary<int, int> rawParts, Dictionary<int, int> sepParts)
2711 {
2712 List<int> rawOffsets = new List<int>();
2713
2714 using (BinaryReader reader = new BinaryReader(file.FilePath))
2715 {
2716 foreach (InstanceDescriptor descriptor in file.Descriptors)
2717 {
2718 if (!descriptor.HasRawParts())
2719 continue;
2720
2721 reader.Position = descriptor.DataOffset;
2722
2723 descriptor.Template.Type.Copy(reader, null, state =>
2724 {
2725 BinaryPartField field = state.Field as BinaryPartField;
2726
2727 if (field != null)
2728 {
2729 int offset = state.GetInt32();
2730
2731 if (offset != 0)
2732 rawOffsets.Add(offset);
2733 }
2734 });
2735 }
2736 }
2737
2738 rawOffsets.Sort();
2739
2740 for (int i = 0; i < rawOffsets.Count; i++)
2741 {
2742 int offset = rawOffsets[i];
2743 int size;
2744
2745 if (i + 1 < rawOffsets.Count)
2746 size = rawOffsets[i + 1] - offset;
2747 else
2748 size = file.Header.RawTableSize - offset;
2749
2750 if (size > 0)
2751 rawParts.Add(offset, size);
2752 }
2753 }
2754
2755 public static void GetRawAndSepParts(InstanceFile file, Dictionary<int, int> rawParts, Dictionary<int, int> sepParts)
2756 {
2757 //if (file.Header.Version == InstanceFileHeader.Version32)
2758 //{
2759 // GetRawAndSepPartsV32(file, rawParts, sepParts);
2760 // return;
2761 //}
2762
2763 Dictionary<string, int> values = new Dictionary<string, int>();
2764
2765 using (BinaryReader reader = new BinaryReader(file.FilePath))
2766 {
2767 foreach (InstanceDescriptor descriptor in file.Descriptors)
2768 {
2769 if (!descriptor.HasRawParts())
2770 continue;
2771
2772 values.Clear();
2773 reader.Position = descriptor.DataOffset;
2774
2775 descriptor.Template.Type.Copy(reader, null, state =>
2776 {
2777 string name = state.GetCurrentFieldName();
2778
2779 if (!string.IsNullOrEmpty(name))
2780 {
2781 if (state.Type == MetaType.Int32)
2782 values[name] = state.GetInt32();
2783 else if (state.Type == MetaType.UInt32)
2784 values[name] = (int)state.GetUInt32();
2785 else if (state.Type == MetaType.Int16)
2786 values[name] = state.GetInt16();
2787 else if (state.Type == MetaType.UInt16)
2788 values[name] = state.GetUInt16();
2789 else if (state.Type == MetaType.Byte)
2790 values[name] = state.GetByte();
2791 }
2792 });
2793
2794 reader.Position = descriptor.DataOffset;
2795
2796 descriptor.Template.Type.Copy(reader, null, state =>
2797 {
2798 BinaryPartField field = state.Field as BinaryPartField;
2799
2800 if (field != null)
2801 {
2802 int offset = state.GetInt32();
2803
2804 if (offset != 0)
2805 {
2806 if (field.Type == MetaType.RawOffset)
2807 {
2808 if (!rawParts.ContainsKey(offset))
2809 rawParts.Add(offset, GetBinaryPartSize(descriptor, state, values));
2810 }
2811 else
2812 {
2813 if (!sepParts.ContainsKey(offset))
2814 sepParts.Add(offset, GetBinaryPartSize(descriptor, state, values));
2815 }
2816 }
2817 }
2818 });
2819 }
2820 }
2821 }
2822
2823 private static int GetBinaryPartSize(InstanceDescriptor descriptor, CopyVisitor state, Dictionary<string, int> values)
2824 {
2825 BinaryPartField field = (BinaryPartField)state.Field;
2826
2827 if (field.SizeFieldName != null)
2828 return values[state.GetParentFieldName() + "." + field.SizeFieldName] * field.SizeMultiplier;
2829
2830 if (field.SizeMultiplier != 0)
2831 return field.SizeMultiplier;
2832
2833 return GetSpecialBinaryPartSize(descriptor, state, values);
2834 }
2835
2836 private static int GetSpecialBinaryPartSize(InstanceDescriptor descriptor, CopyVisitor state, Dictionary<string, int> values)
2837 {
2838 switch (descriptor.Template.Tag)
2839 {
2840 case TemplateTag.AGDB:
2841 return GetAGDBRawDataSize(descriptor, state.GetInt32(), values);
2842
2843 case TemplateTag.TRAM:
2844 return GetTRAMRotationsRawDataSize(descriptor, state.GetInt32(), values);
2845
2846 case TemplateTag.SUBT:
2847 return GetSUBTRawDataSize(descriptor, state.GetInt32(), values);
2848
2849 case TemplateTag.TXMP:
2850 return GetTXMPRawDataSize(descriptor, state.GetInt32(), values);
2851
2852 default:
2853 throw new NotSupportedException(string.Format("Cannot get the raw data part size of type {0}", state.TopLevelType.Name));
2854 }
2855 }
2856
2857 private static int GetAGDBRawDataSize(InstanceDescriptor descriptor, int rawOffset, Dictionary<string, int> values)
2858 {
2859 using (var rawReader = descriptor.GetRawReader(rawOffset))
2860 {
2861 var startOffset = rawReader.Position;
2862 rawReader.SkipCString();
2863 return (int)(rawReader.Position - startOffset);
2864 }
2865 }
2866
2867 private static int GetSUBTRawDataSize(InstanceDescriptor descriptor, int rawOffset, Dictionary<string, int> values)
2868 {
2869 int lastEntry = 0;
2870
2871 using (var datReader = descriptor.OpenRead(20))
2872 {
2873 var entries = datReader.ReadInt32Array(datReader.ReadInt32());
2874
2875 foreach (int entry in entries)
2876 {
2877 if (entry > lastEntry)
2878 lastEntry = entry;
2879 }
2880 }
2881
2882 using (var rawReader = descriptor.GetRawReader(rawOffset))
2883 {
2884 int startOffset = rawReader.Position;
2885 rawReader.Position += lastEntry;
2886 rawReader.SkipCString();
2887 rawReader.SkipCString();
2888 return rawReader.Position - startOffset;
2889 }
2890 }
2891
2892 private static int GetTRAMRotationsRawDataSize(InstanceDescriptor descriptor, int rawOffset, Dictionary<string, int> values)
2893 {
2894 int numParts = values["TRAMInstance.BodyPartCount"];
2895 int compressionSize = values["TRAMInstance.CompressionSize"];
2896 int numFrames = values["TRAMInstance.FrameCount"];
2897
2898 using (var rawReader = descriptor.GetRawReader(rawOffset))
2899 {
2900 int startOffset = rawReader.Position;
2901
2902 rawReader.Skip((numParts - 1) * 2);
2903 int lastBoneOffset = rawReader.ReadInt16();
2904 rawReader.Skip(lastBoneOffset - numParts * 2);
2905
2906 int time = 1;
2907
2908 for (int totalTime = 0; time > 0; totalTime += time)
2909 {
2910 rawReader.Skip(compressionSize);
2911
2912 if (totalTime < numFrames - 1)
2913 time = rawReader.ReadByte();
2914 else
2915 time = 0;
2916 }
2917
2918 return rawReader.Position - startOffset;
2919 }
2920 }
2921
2922 private static int GetTXMPRawDataSize(InstanceDescriptor descriptor, int rawOffset, Dictionary<string, int> values)
2923 {
2924 int width = values["TXMPInstance.Width"];
2925 int height = values["TXMPInstance.Height"];
2926 Motoko.TextureFlags flags = (Motoko.TextureFlags)values["TXMPInstance.Flags"];
2927 TXMPFormat format = (TXMPFormat)values["TXMPInstance.Format"];
2928 int length;
2929
2930 switch (format)
2931 {
2932 case TXMPFormat.BGRA4444:
2933 case TXMPFormat.BGR555:
2934 case TXMPFormat.BGRA5551:
2935 length = width * height * 2;
2936 break;
2937
2938 case TXMPFormat.BGR:
2939 case TXMPFormat.RGBA:
2940 length = width * height * 4;
2941 break;
2942
2943 case TXMPFormat.DXT1:
2944 length = width * height / 2;
2945 break;
2946
2947 default:
2948 throw new NotSupportedException("Unsupported texture format");
2949 }
2950
2951 int totalLength = length;
2952
2953 if ((flags & Motoko.TextureFlags.HasMipMaps) != 0)
2954 {
2955 if (format == TXMPFormat.DXT1)
2956 {
2957 do
2958 {
2959 if (width > 1)
2960 width >>= 1;
2961
2962 if (height > 1)
2963 height >>= 1;
2964
2965 totalLength += Math.Max(1, width / 4) * Math.Max(1, height / 4) * 8;
2966 }
2967 while (height > 1 || width > 1);
2968 }
2969 else
2970 {
2971 do
2972 {
2973 if (width > 1)
2974 {
2975 width >>= 1;
2976 length >>= 1;
2977 }
2978
2979 if (height > 1)
2980 {
2981 height >>= 1;
2982 length >>= 1;
2983 }
2984
2985 totalLength += length;
2986 }
2987 while (height > 1 || width > 1);
2988 }
2989 }
2990
2991 return totalLength;
2992 }
2993
2994 #region Private data
2995 private static InstanceMetadata pcMetadata;
2996 private static InstanceMetadata macMetadata;
2997 private Dictionary<TemplateTag, Template> templateIndex;
2998 #endregion
2999
3000 public static InstanceMetadata GetMetadata(InstanceFile instanceFile)
3001 {
3002 return GetMetadata(instanceFile.Header.TemplateChecksum);
3003 }
3004
3005 public static InstanceMetadata GetMetadata(long templateChecksum)
3006 {
3007 if (templateChecksum == InstanceFileHeader.OniPCTemplateChecksum)
3008 {
3009 if (pcMetadata == null)
3010 pcMetadata = new OniPcMetadata();
3011
3012 return pcMetadata;
3013 }
3014
3015 if (templateChecksum == InstanceFileHeader.OniMacTemplateChecksum)
3016 {
3017 if (macMetadata == null)
3018 macMetadata = new OniMacMetadata();
3019
3020 return macMetadata;
3021 }
3022
3023 throw new NotSupportedException();
3024 }
3025
3026 public Template GetTemplate(TemplateTag tag)
3027 {
3028 if (templateIndex == null)
3029 {
3030 templateIndex = new Dictionary<TemplateTag, Template>();
3031
3032 List<Template> templates = new List<Template>();
3033 InitializeTemplates(templates);
3034
3035 foreach (Template template in templates)
3036 templateIndex.Add(template.Tag, template);
3037 }
3038
3039 Template result;
3040 templateIndex.TryGetValue(tag, out result);
3041 return result;
3042 }
3043
3044 public static void DumpCStructs(TextWriter writer)
3045 {
3046 OniPcMetadata metadata = new OniPcMetadata();
3047 DumpVisitor visitor = new DumpVisitor(writer, metadata);
3048
3049 foreach (TemplateTag tag in Enum.GetValues(typeof(TemplateTag)))
3050 {
3051 Template template = metadata.GetTemplate(tag);
3052
3053 if (template == null)
3054 continue;
3055
3056 visitor.VisitStruct(template.Type);
3057 DumpCStruct(writer, template.Type);
3058 }
3059 }
3060
3061 private static void DumpCStruct(TextWriter writer, MetaStruct type)
3062 {
3063 writer.WriteLine();
3064 writer.WriteLine("struct {0} {{", type.Name);
3065 string indent = "\t";
3066
3067 foreach (Field field in type.Fields)
3068 {
3069 if (field.Type is MetaPointer)
3070 {
3071 MetaPointer ptr = field.Type as MetaPointer;
3072
3073 writer.WriteLine("{0}{1} *{2};", indent, new OniPcMetadata().GetTemplate(ptr.Tag).Type.Name, field.Name);
3074 }
3075 else if (field.Type is MetaVarArray)
3076 {
3077 MetaVarArray varArray = field.Type as MetaVarArray;
3078
3079 writer.WriteLine("{0}{1} {2}[1];", indent, varArray.ElementType, field.Name);
3080 }
3081 else
3082 {
3083 writer.WriteLine("{0}{1} {2};", indent, field.Type.Name, field.Name);
3084 }
3085 }
3086
3087 indent = indent.Substring(0, indent.Length - 1);
3088 writer.WriteLine("};");
3089 }
3090 }
3091}
Note: See TracBrowser for help on using the repository browser.