-
Notifications
You must be signed in to change notification settings - Fork 0
/
stateItem.cpp
4612 lines (3982 loc) · 158 KB
/
stateItem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-----------------------------------------------------------------------------
// Torque 3D
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "T3D/StateItem.h"
#include "core/stream/bitStream.h"
#include "math/mMath.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "sim/netConnection.h"
#include "collision/boxConvex.h"
#include "collision/earlyOutPolyList.h"
#include "collision/extrudedPolyList.h"
#include "math/mPolyhedron.h"
#include "math/mathIO.h"
#include "lighting/lightInfo.h"
#include "lighting/lightManager.h"
#include "T3D/physics/physicsPlugin.h"
#include "T3D/physics/physicsBody.h"
#include "T3D/physics/physicsCollision.h"
#include "ts/tsShapeInstance.h"
#include "console/engineAPI.h"
//-JR
#include "core/resourceManager.h"
#include "console/consoleInternal.h"
#include "console/engineAPI.h"
#include "T3D/fx/particleEmitter.h"
#include "T3D/projectile.h"
#include "T3D/gameBase/gameConnection.h"
#include "T3D/debris.h"
#include "math/mathUtils.h"
#include "sim/netObject.h"
#include "sfx/sfxTrack.h"
#include "sfx/sfxSource.h"
#include "sfx/sfxSystem.h"
#include "sfx/sfxTypes.h"
#include "scene/sceneManager.h"
#include "scene/sceneRenderState.h"
#include "core/stream/fileStream.h"
//-JR
const F32 sRotationSpeed = 6.0f; // Secs/Rotation
const F32 sAtRestVelocity = 0.15f; // Min speed after collision
const S32 sCollisionTimeout = 15; // Timout value in ticks
// Client prediction
static F32 sMinWarpTicks = 0.5 ; // Fraction of tick at which instant warp occures
static S32 sMaxWarpTicks = 3; // Max warp duration in ticks
F32 StateItem::mGravity = -20.0f;
const U32 sClientCollisionMask = (TerrainObjectType |
InteriorObjectType | StaticShapeObjectType |
VehicleObjectType | PlayerObjectType |
StaticObjectType);
const U32 sServerCollisionMask = (sClientCollisionMask |
TriggerObjectType); //-JR this was added back in, because I want it to track in triggers. may be useful
const S32 StateItem::csmAtRestTimer = 64;
static const U32 sgAllowedDynamicTypes = DynamicShapeObjectType;//DamagableStateItemObjectType; ?? -JR
//-JR
//Advanced StateItem Support
StateItemData* InvalidImagePtr = (StateItemData*) 1;
ImplementEnumType( StateItemLoadedState,
"The loaded state of this ShapeBase\n"
"@ingroup gameObjects\n\n")
{ StateItemData::StateData::IgnoreLoaded, "Ignore", "Ignore the loaded state.\n" },
{ StateItemData::StateData::Loaded, "Loaded", "ShapeBaseImage is loaded.\n" },
{ StateItemData::StateData::NotLoaded, "Empty", "ShapeBaseImage is not loaded.\n" },
EndImplementEnumType;
ImplementEnumType( StateItemSpinState,
"How the spin animation should be played.\n"
"@ingroup gameobjects\n\n")
{ StateItemData::StateData::IgnoreSpin,"Ignore", "No changes to the spin sequence.\n" },
{ StateItemData::StateData::NoSpin, "Stop", "Stops the spin sequence at its current position\n" },
{ StateItemData::StateData::SpinUp, "SpinUp", "Increase spin sequence timeScale from 0 (on state entry) to 1 (after stateTimeoutValue seconds).\n" },
{ StateItemData::StateData::SpinDown, "SpinDown", "Decrease spin sequence timeScale from 1 (on state entry) to 0 (after stateTimeoutValue seconds).\n" },
{ StateItemData::StateData::FullSpin, "FullSpeed", "Resume the spin sequence playback at its current position with timeScale = 1.\n"},
EndImplementEnumType;
ImplementEnumType( StateItemRecoilState,
"What kind of recoil this ShapeBaseImage should emit when fired.\n"
"@ingroup gameobjects\n\n")
{ StateItemData::StateData::NoRecoil, "NoRecoil", "No recoil occurs.\n" },
{ StateItemData::StateData::LightRecoil, "LightRecoil", "A light recoil occurs.\n" },
{ StateItemData::StateData::MediumRecoil, "MediumRecoil", "A medium recoil occurs.\n" },
{ StateItemData::StateData::HeavyRecoil, "HeavyRecoil", "A heavy recoil occurs.\n" },
EndImplementEnumType;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
IMPLEMENT_CALLBACK( StateItemData, onMount, void, ( ShapeBase* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
"Called when the Image is first mounted to the object.\n"
"@param obj object that this Image has been mounted to\n"
"@param slot Image mount slot\n"
"@param dt time remaining in this Image update\n" );
IMPLEMENT_CALLBACK( StateItemData, onUnmount, void, ( ShapeBase* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
"Called when the Image is unmounted from the object.\n"
"@param obj object that this Image has been unmounted from\n"
"@param slot Image mount slot\n"
"@param dt time remaining in this Image update\n" );
StateItemData::StateData::StateData()
{
name = 0;
transition.loaded[0] = transition.loaded[1] = -1;
transition.ammo[0] = transition.ammo[1] = -1;
transition.target[0] = transition.target[1] = -1;
transition.trigger[0] = transition.trigger[1] = -1;
transition.altTrigger[0] = transition.altTrigger[1] = -1;
transition.wet[0] = transition.wet[1] = -1;
transition.motion[0] = transition.motion[1] = -1;
transition.timeout = -1;
waitForTimeout = false; //set to false for better weapon states support -JR
timeoutValue = 0;
fire = false;
altFire = false;
reload = false;
energyDrain = 0;
allowImageChange = true;
loaded = IgnoreLoaded;
spin = IgnoreSpin;
recoil = NoRecoil;
sound = 0;
emitter = NULL;
script = 0;
ignoreLoadedForReady = false;
ejectShell = false;
scaleAnimation = false;
sequenceTransitionIn = false;
sequenceTransitionOut = false;
sequenceNeverTransition = false;
sequenceTransitionTime = 0;
direction = false;
emitterTime = 0.0f;
sequence = -1;
sequenceVis = -1;
flashSequence = false;
emitterNode = -1;
}
static StateItemData::StateData gDefaultStateData;
//-JR
//----------------------------------------------------------------------------
IMPLEMENT_CO_DATABLOCK_V1(StateItemData);
ConsoleDocClass( StateItemData,
"@brief Stores properties for an individual StateItem type.\n\n"
"Critical references include a DTS that represents the mesh of the StateItem and the physics data for its movement.\n"
"The rest of the datablock refers to any lights that we wish for this StateItem object to emit.\n\n"
"@tsexample\n"
"datablock StateItemData(HealthKitSmall)\n"
" {\n"
" category =\"Health\";\n"
" className = \"HealthPatch\";\n"
" shapeFile = \"art/shapes/StateItems/kit/healthkit.dts\";\n"
" gravityMod = \"1.0\";\n"
" mass = 2;\n"
" friction = 1;\n"
" elasticity = 0.3;\n"
" density = 2;\n"
" drag = 0.5;\n"
" maxVelocity = \"10.0\";\n"
" emap = true;\n"
" sticky = false;\n"
" dynamicType = \"0\"\n;"
" lightOnlyStatic = false;\n"
" lightType = \"NoLight\";\n"
" lightColor = \"1.0 1.0 1.0 1.0\";\n"
" lightTime = 1000;\n"
" lightRadius = 10.0;\n"
" simpleServerCollision = true;"
" // Dynamic properties used by the scripts\n\n"
" pickupName = \"a small health kit\";\n"
" repairAmount = 50;\n"
" };\n"
"@endtsexample\n"
"@ingroup gameObjects\n"
);
StateItemData::StateItemData()
{
shadowEnable = true;
friction = 0;
elasticity = 0;
sticky = false;
gravityMod = 1.0;
maxVelocity = -1;
density = 2;
drag = 0.5;
dynamicTypeField = 0;
lightOnlyStatic = false;
lightType = StateItem::NoLight;
lightColor.set(1.f,1.f,1.f,1.f);
lightTime = 1000;
lightRadius = 10.f;
simpleServerCollision = true;
//-JR
//advanced StateItem support
emap = false;
mountPoint = 0;
mountOffset.identity();
eyeOffset.identity();
correctMuzzleVector = true;
correctMuzzleVectorTP = true;
firstPerson = true;
useEyeOffset = false;
useEyeNode = false;
mass = 0;
usesEnergy = false;
minEnergy = 2;
accuFire = false;
projectile = NULL;
cloakable = true;
lightDuration = 1000;
lightBrightness = 1.0f;
mountTransform.identity();
shapeName = "";
itemAnimPrefix = "";
fireState = -1;
altFireState = -1;
reloadState = -1;
computeCRC = false;
animateOnServer = false;
scriptAnimTransitionTime = 0.25f;
//
for (int i = 0; i < MaxStates; i++) {
stateName[i] = 0;
stateTransitionLoaded[i] = 0;
stateTransitionNotLoaded[i] = 0;
stateTransitionAmmo[i] = 0;
stateTransitionNoAmmo[i] = 0;
stateTransitionTarget[i] = 0;
stateTransitionNoTarget[i] = 0;
stateTransitionWet[i] = 0;
stateTransitionNotWet[i] = 0;
stateTransitionMotion[i] = 0;
stateTransitionNoMotion[i] = 0;
stateTransitionTriggerUp[i] = 0;
stateTransitionTriggerDown[i] = 0;
stateTransitionAltTriggerUp[i] = 0;
stateTransitionAltTriggerDown[i] = 0;
stateTransitionTimeout[i] = 0;
stateTransitionGeneric0In[i] = 0;
stateTransitionGeneric0Out[i] = 0;
stateTransitionGeneric1In[i] = 0;
stateTransitionGeneric1Out[i] = 0;
stateTransitionGeneric2In[i] = 0;
stateTransitionGeneric2Out[i] = 0;
stateTransitionGeneric3In[i] = 0;
stateTransitionGeneric3Out[i] = 0;
stateWaitForTimeout[i] = false;
stateTimeoutValue[i] = 0;
stateFire[i] = false;
stateAlternateFire[i] = false;
stateReload[i] = false;
stateEjectShell[i] = false;
stateEnergyDrain[i] = 0;
stateAllowImageChange[i] = true;
stateScaleAnimation[i] = true;
stateSequenceTransitionIn[i] = false;
stateSequenceTransitionOut[i] = false;
stateSequenceNeverTransition[i] = false;
stateSequenceTransitionTime[i] = 0.25f;
stateDirection[i] = true;
stateLoaded[i] = StateData::IgnoreLoaded;
stateSpin[i] = StateData::IgnoreSpin;
stateRecoil[i] = StateData::NoRecoil;
stateSequence[i] = 0;
stateSequenceRandomFlash[i] = false;
stateShapeSequence[i] = 0;
stateScaleShapeSequence[i] = false;
stateSound[i] = 0;
stateScript[i] = 0;
stateEmitter[i] = 0;
stateEmitterTime[i] = 0;
stateEmitterNode[i] = 0;
stateIgnoreLoadedForReady[i] = false;
}
statesLoaded = false;
maxConcurrentSounds = 0;
useRemainderDT = false;
casing = NULL;
casingID = 0;
shellExitDir.set( 1.0, 0.0, 1.0 );
shellExitDir.normalize();
shellExitVariance = 20.0;
shellVelocity = 1.0;
fireStateName = NULL;
mCRC = U32_MAX;
retractNode = -1;
muzzleNode = -1;
ejectNode = -1;
emitterNode = -1;
eyeMountNode = -1;
eyeNode = -1;
spinSequence = -1;
ambientSequence = -1;
isAnimated = false;
hasFlash = false;
shakeCamera = false;
camShakeFreq = Point3F::Zero;
camShakeAmp = Point3F::Zero;
//-JR
}
//-JR
//advanced StateItem support
bool StateItemData::onAdd()
{
if (!Parent::onAdd())
return false;
// Copy state data from the scripting arrays into the
// state structure array. If we have state data already,
// we are on the client and need to leave it alone.
for (U32 i = 0; i < MaxStates; i++) {
StateData& s = state[i];
if (statesLoaded == false) {
s.name = stateName[i];
s.transition.loaded[0] = lookupState(stateTransitionNotLoaded[i]);
s.transition.loaded[1] = lookupState(stateTransitionLoaded[i]);
s.transition.ammo[0] = lookupState(stateTransitionNoAmmo[i]);
s.transition.ammo[1] = lookupState(stateTransitionAmmo[i]);
s.transition.target[0] = lookupState(stateTransitionNoTarget[i]);
s.transition.target[1] = lookupState(stateTransitionTarget[i]);
s.transition.wet[0] = lookupState(stateTransitionNotWet[i]);
s.transition.wet[1] = lookupState(stateTransitionWet[i]);
s.transition.motion[0] = lookupState(stateTransitionNoMotion[i]);
s.transition.motion[1] = lookupState(stateTransitionMotion[i]);
s.transition.trigger[0] = lookupState(stateTransitionTriggerUp[i]);
s.transition.trigger[1] = lookupState(stateTransitionTriggerDown[i]);
s.transition.genericTrigger[0][0] = lookupState(stateTransitionGeneric0Out[i]);
s.transition.genericTrigger[0][1] = lookupState(stateTransitionGeneric0In[i]);
s.transition.genericTrigger[1][0] = lookupState(stateTransitionGeneric1Out[i]);
s.transition.genericTrigger[1][1] = lookupState(stateTransitionGeneric1In[i]);
s.transition.genericTrigger[2][0] = lookupState(stateTransitionGeneric2Out[i]);
s.transition.genericTrigger[2][1] = lookupState(stateTransitionGeneric2In[i]);
s.transition.genericTrigger[3][0] = lookupState(stateTransitionGeneric3Out[i]);
s.transition.genericTrigger[3][1] = lookupState(stateTransitionGeneric3In[i]);
s.transition.altTrigger[0] = lookupState(stateTransitionAltTriggerUp[i]);
s.transition.altTrigger[1] = lookupState(stateTransitionAltTriggerDown[i]);
s.transition.timeout = lookupState(stateTransitionTimeout[i]);
s.waitForTimeout = stateWaitForTimeout[i];
s.timeoutValue = stateTimeoutValue[i];
s.fire = stateFire[i];
s.altFire = stateAlternateFire[i];
s.reload = stateReload[i];
s.ejectShell = stateEjectShell[i];
s.energyDrain = stateEnergyDrain[i];
s.allowImageChange = stateAllowImageChange[i];
s.scaleAnimation = stateScaleAnimation[i];
s.sequenceTransitionIn = stateSequenceTransitionIn[i];
s.sequenceTransitionOut = stateSequenceTransitionOut[i];
s.sequenceNeverTransition = stateSequenceNeverTransition[i];
s.sequenceTransitionTime = stateSequenceTransitionTime[i];
s.direction = stateDirection[i];
s.loaded = stateLoaded[i];
s.spin = stateSpin[i];
s.recoil = stateRecoil[i];
s.sequence = -1; // Sequence is resolved in load
s.shapeSequence = stateShapeSequence[i];
s.shapeSequenceScale = stateScaleShapeSequence[i];
s.sequenceVis = -1; // Vis Sequence is resolved in load
s.sound = stateSound[i];
s.script = stateScript[i];
s.emitter = stateEmitter[i];
s.emitterTime = stateEmitterTime[i];
s.emitterNode = -1; // Sequnce is resolved in load
}
// The first state marked as "fire" is the state entered on the
// client when it recieves a fire event.
if (s.fire && fireState == -1)
fireState = i;
// The first state marked as "alternateFire" is the state entered on the
// client when it recieves an alternate fire event.
if (s.altFire && altFireState == -1)
altFireState = i;
// The first state marked as "reload" is the state entered on the
// client when it recieves a reload event.
if (s.reload && reloadState == -1)
reloadState = i;
}
// Always preload images, this is needed to avoid problems with
// resolving sequences before transmission to a client.
return true;
}
bool StateItemData::preload(bool server, String &errorStr)
{
if (!Parent::preload(server, errorStr))
return false;
// Resolve objects transmitted from server
if (!server) {
if (projectile)
if (Sim::findObject(SimObjectId(projectile), projectile) == false)
Con::errorf(ConsoleLogEntry::General, "Error, unable to load projectile for StateItemData");
for (U32 i = 0; i < MaxStates; i++) {
if (state[i].emitter)
if (!Sim::findObject(SimObjectId(state[i].emitter), state[i].emitter))
Con::errorf(ConsoleLogEntry::General, "Error, unable to load emitter for image datablock");
String str;
if( !sfxResolve( &state[ i ].sound, str ) )
Con::errorf( ConsoleLogEntry::General, str.c_str() );
}
}
// Use the first person eye offset if it's set.
useEyeOffset = !eyeOffset.isIdentity();
if (shapeName && shapeName[0]) {
// Resolve shapename
mShape = ResourceManager::get().load(shapeName);
if (!bool(mShape)) {
errorStr = String::ToString("Unable to load shape: %s", shapeName);
return false;
}
if(computeCRC)
{
Con::printf("Validation required for shape: %s", shapeName);
Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(mShape.getPath());
if (!fileRef)
return false;
if(server)
mCRC = fileRef->getChecksum();
else if(mCRC != fileRef->getChecksum())
{
errorStr = String::ToString("Shape \"%s\" does not match version on server.",shapeName);
return false;
}
}
// Resolve nodes & build mount transform
eyeMountNode = mShape->findNode("eyeMount");
eyeNode = mShape->findNode("eye");
ejectNode = mShape->findNode("ejectPoint");
muzzleNode = mShape->findNode("muzzlePoint");
retractNode = mShape->findNode("retractionPoint");
mountTransform = mountOffset;
S32 node = mShape->findNode("mountPoint");
if (node != -1) {
MatrixF total(1);
do {
MatrixF nmat;
QuatF q;
TSTransform::setMatrix(mShape->defaultRotations[node].getQuatF(&q),mShape->defaultTranslations[node],&nmat);
total.mul(nmat);
node = mShape->nodes[node].parentIndex;
}
while(node != -1);
total.inverse();
mountTransform.mul(total);
}
// Resolve state sequence names & emitter nodes
isAnimated = false;
hasFlash = false;
for (U32 i = 0; i < MaxStates; i++) {
StateData& s = state[i];
if (stateSequence[i] && stateSequence[i][0])
s.sequence = mShape->findSequence(stateSequence[i]);
if (s.sequence != -1)
{
isAnimated = true;
}
if (stateSequence[i] && stateSequence[i][0] && stateSequenceRandomFlash[i]) {
char bufferVis[128];
dStrncpy(bufferVis, stateSequence[i], 100);
dStrcat(bufferVis, "_vis");
s.sequenceVis = mShape->findSequence(bufferVis);
}
if (s.sequenceVis != -1)
{
s.flashSequence = true;
hasFlash = true;
}
s.ignoreLoadedForReady = stateIgnoreLoadedForReady[i];
if (stateEmitterNode[i] && stateEmitterNode[i][0])
s.emitterNode = mShape->findNode(stateEmitterNode[i]);
if (s.emitterNode == -1)
s.emitterNode = muzzleNode;
}
ambientSequence = mShape->findSequence("ambient");
spinSequence = mShape->findSequence("spin");
}
else {
errorStr = "Bad Datablock from server";
return false;
}
if( !casing && casingID != 0 )
{
if( !Sim::findObject( SimObjectId( casingID ), casing ) )
{
Con::errorf( ConsoleLogEntry::General, "StateItemData::preload: Invalid packet, bad datablockId(casing): 0x%x", casingID );
}
}
/*TSShapeInstance* pDummy = new TSShapeInstance(shape, !server);
delete pDummy;*/
return true;
}
S32 StateItemData::lookupState(const char* name)
{
if (!name || !name[0])
return -1;
for (U32 i = 0; i < MaxStates; i++)
if (stateName[i] && !dStricmp(name,stateName[i]))
return i;
Con::errorf(ConsoleLogEntry::General,"StateItemData:: Could not resolve state \"%s\" for image \"%s\"",name,getName());
return 0;
}
ImplementEnumType( StateItemLightType,
"The type of light to attach to this ShapeBase\n"
"@ingroup gameObjects\n\n")
{ StateItem::NoLight, "NoLight", "No light is attached.\n" },
{ StateItem::ConstantLight, "ConstantLight", "A constant emitting light is attached.\n" },
{ StateItem::SpotLight, "SpotLight", "A spotlight is attached.\n" },
{ StateItem::PulsingLight, "PulsingLight", "A pusling light is attached.\n" },
{ StateItem::WeaponFireLight, "WeaponFireLight", "Light emits when the weapon is fired the dissipates.\n" }
EndImplementEnumType;
/*ImplementEnumType( StateItemLightType,
"The type of light that this StateItem has\n"
"@ingroup gameobjects\n\n")
{ StateItem::NoLight, "NoLight", "The StateItem has no light attached.\n" },
{ StateItem::ConstantLight, "ConstantLight", "The StateItem has a constantly emitting light attached.\n" },
{ StateItem::PulsingLight, "PulsingLight", "The StateItem has a pulsing light attached.\n" }
EndImplementEnumType;*/
//-JR
void StateItemData::initPersistFields()
{
addField("friction", TypeF32, Offset(friction, StateItemData), "A floating-point value specifying how much velocity is lost to impact and sliding friction.");
addField("elasticity", TypeF32, Offset(elasticity, StateItemData), "A floating-point value specifying how 'bouncy' this StateItemData is.");
addField("sticky", TypeBool, Offset(sticky, StateItemData), "If true, StateItemData will 'stick' to any surface it collides with.");
addField("gravityMod", TypeF32, Offset(gravityMod, StateItemData), "Floating point value to multiply the existing gravity with for just this StateItemData.");
addField("maxVelocity", TypeF32, Offset(maxVelocity, StateItemData), "Maximum velocity that this StateItemData is able to move.");
addField("dynamicType", TypeS32, Offset(dynamicTypeField, StateItemData), "An integer value which, if speficied, is added to the value retured by getType().");
addField("lightType", TYPEID< StateItem::LightType >(), Offset(lightType, StateItemData), "Type of light to apply to this StateItemData. Options are NoLight, ConstantLight, PulsingLight. Default is NoLight." );
addField("lightColor", TypeColorF, Offset(lightColor, StateItemData), "Color value to make this light. Example: \"1.0,1.0,1.0\"");
addField("lightTime", TypeS32, Offset(lightTime, StateItemData), "Time value for the light of this StateItemData, used to control the pulse speed of the PulsingLight LightType.");
addField("lightRadius", TypeF32, Offset(lightRadius, StateItemData), "Distance from the center point of this StateItemData for the light to affect");
addField("lightOnlyStatic", TypeBool, Offset(lightOnlyStatic, StateItemData), "If true, this StateItemData will only cast a light if the StateItem for this StateItemData has a Static value of true.");
addField("simpleServerCollision", TypeBool, Offset(simpleServerCollision, StateItemData),
"@brief Determines if only simple server-side collision will be used (for pick ups).\n\n"
"If set to true then only simple, server-side collision detection will be used. This is often the case "
"if the StateItem is used for a pick up object, such as ammo. If set to false then a full collision volume "
"will be used as defined by the shape. The default is true.\n"
"@note Only applies when using a physics library.\n"
"@see TurretShape and ProximityMine for examples that should set this to false to allow them to be "
"shot by projectiles.\n");
//-JR
//advanced StateItem support
addField( "emap", TypeBool, Offset(emap, StateItemData),
"Whether to enable environment mapping on this " );
addField( "shapeFile", TypeShapeFilename, Offset(shapeName, StateItemData),
"The DTS or DAE model to use for this Image." );
addField( "itemAnimPrefix", TypeCaseString, Offset(itemAnimPrefix, StateItemData),
"@brief Passed along to the mounting shape to modify animation sequences played in third person. [optional]\n\n" );
addField( "animateOnServer", TypeBool, Offset(animateOnServer, StateItemData),
"@brief Indicates that the image should be animated on the server.\n\n"
"In most cases you'll want this set if you're using useEyeNode. You may also want to "
"set this if the muzzlePoint is animated while it shoots. You can set this "
"to false even if these previous cases are true if the image's shape is set "
"up in the correct position and orientation in the 'root' pose and none of "
"the nodes are animated at key times, such as the muzzlePoint essentially "
"remaining at the same position at the start of the fire state (it could "
"animate just fine after the projectile is away as the muzzle vector is only "
"calculated at the start of the state).\n\n"
"You'll also want to set this to true if you're animating the camera using the "
"image's 'eye' node -- unless the movement is very subtle and doesn't need to "
"be reflected on the server.\n\n"
"@note Setting this to true causes up to four animation threads to be advanced on the server "
"for each instance in use, although for most images only one or two are actually defined.\n\n"
"@see useEyeNode\n");
addField( "scriptAnimTransitionTime", TypeF32, Offset(scriptAnimTransitionTime, StateItemData),
"@brief The amount of time to transition between the previous sequence and new sequence when the script prefix has changed.\n\n"
"When setImageScriptAnimPrefix() is used on a ShapeBase that has this image mounted, the image "
"will attempt to switch to the new animation sequence based on the given script prefix. This is "
"the amount of time it takes to transition from the previously playing animation sequence to"
"the new script prefix-based animation sequence.\n"
"@see ShapeBase::setImageScriptAnimPrefix()");
addField( "projectile", TYPEID< ProjectileData >(), Offset(projectile, StateItemData),
"The projectile fired by this Image" );
addField( "cloakable", TypeBool, Offset(cloakable, StateItemData),
"Whether this Image can be cloaked.\nCurrently unused." );
addField( "mountPoint", TypeS32, Offset(mountPoint, StateItemData),
"Mount node # to mount this Image to.\nThis should correspond to a mount# "
"node on the ShapeBase derived object we are mounting to." );
addField( "offset", TypeMatrixPosition, Offset(mountOffset, StateItemData),
"\"X Y Z\" translation offset from this Image's <i>mountPoint</i> node to "
"attach to.\nDefaults to \"0 0 0\". ie. attach this Image's "
"<i>mountPoint</i> node to the ShapeBase model's mount# node." );
addField( "rotation", TypeMatrixRotation, Offset(mountOffset, StateItemData),
"\"X Y Z ANGLE\" rotation offset from this Image's <i>mountPoint</i> node "
"to attach to.\nDefaults to \"0 0 0\". ie. attach this Image's "
"<i>mountPoint</i> node to the ShapeBase model's mount# node." );
addField( "eyeOffset", TypeMatrixPosition, Offset(eyeOffset, StateItemData),
"\"X Y Z\" translation offset from the ShapeBase model's eye node.\n"
"Only affects 1st person POV." );
addField( "eyeRotation", TypeMatrixRotation, Offset(eyeOffset, StateItemData),
"\"X Y Z ANGLE\" rotation offset from the ShapeBase model's eye node.\n"
"Only affects 1st person POV." );
addField( "useEyeNode", TypeBool, Offset(useEyeNode, StateItemData),
"@brief Mount image using image's eyeMount node and place the camera at the image's eye node (or "
"at the eyeMount node if the eye node is missing).\n\n"
"When in first person view, if an 'eyeMount' node is present in the image's shape, this indicates "
"that the image should mount eyeMount node to Player eye node for image placement. The "
"Player's camera should also mount to the image's eye node to inherit any animation (or the eyeMount "
"node if the image doesn't have an eye node).\n\n"
"@note Used instead of eyeOffset.\n\n"
"@note Read about the animateOnServer field as you may want to set it to true if you're using useEyeNode.\n\n"
"@see eyeOffset\n\n"
"@see animateOnServer\n\n");
addField( "correctMuzzleVector", TypeBool, Offset(correctMuzzleVector, StateItemData),
"Flag to adjust the aiming vector to the eye's LOS point.\n\n"
"@see getMuzzleVector" );
addField( "correctMuzzleVectorTP", TypeBool, Offset(correctMuzzleVectorTP, StateItemData),
"@brief Flag to adjust the aiming vector to the camera's LOS point when in 3rd person view.\n\n"
"@see ShapeBase::getMuzzleVector()" );
addField( "firstPerson", TypeBool, Offset(firstPerson, StateItemData),
"This flag must be set for the adjusted LOS muzzle vector to be computed.\n\n"
"@see getMuzzleVector" );
addField( "mass", TypeF32, Offset(mass, StateItemData),
"Mass of this \nThis is added to the total mass of the ShapeBase "
"object." );
addField( "usesEnergy", TypeBool, Offset(usesEnergy,StateItemData),
"Flag indicating whether this Image uses energy instead of ammo." );
addField( "minEnergy", TypeF32, Offset(minEnergy, StateItemData),
"Minimum Image energy for it to be operable." );
addField( "accuFire", TypeBool, Offset(accuFire, StateItemData),
"Flag to control whether the Image's aim is automatically converged with "
"the crosshair.\nCurrently unused." );
addField( "lightColor", TypeColorF, Offset(lightColor, StateItemData),
"The color of light this Image emits." );
addField( "lightDuration", TypeS32, Offset(lightDuration, StateItemData),
"Duration in SimTime of Pulsing and WeaponFire type lights." );
addField( "lightRadius", TypeF32, Offset(lightRadius, StateItemData),
"Radius of the light this Image emits." );
addField( "lightBrightness", TypeF32, Offset(lightBrightness, StateItemData),
"Brightness of the light this Image emits.\nOnly valid for WeaponFireLight." );
addField( "shakeCamera", TypeBool, Offset(shakeCamera, StateItemData),
"Flag indicating whether the camera should shake when this Image fires.\n"
"@note Camera shake only works properly if the player is in control of "
"the one and only shapeBase object in the scene which fires an Image that "
"uses camera shake." );
addField( "camShakeFreq", TypePoint3F, Offset(camShakeFreq, StateItemData),
"Frequency of the camera shaking effect.\n\n@see shakeCamera" );
addField( "camShakeAmp", TypePoint3F, Offset(camShakeAmp, StateItemData),
"Amplitude of the camera shaking effect.\n\n@see shakeCamera" );
addField( "casing", TYPEID< DebrisData >(), Offset(casing, StateItemData),
"DebrisData datablock to use for ejected casings.\n\n@see stateEjectShell" );
addField( "shellExitDir", TypePoint3F, Offset(shellExitDir, StateItemData),
"Vector direction to eject shell casings." );
addField( "shellExitVariance", TypeF32, Offset(shellExitVariance, StateItemData),
"Variance (in degrees) from the shellExitDir vector." );
addField( "shellVelocity", TypeF32, Offset(shellVelocity, StateItemData),
"Speed at which to eject casings." );
// State arrays
addArray( "States", MaxStates );
addField( "stateName", TypeCaseString, Offset(stateName, StateItemData), MaxStates,
"Name of this state." );
addField( "stateTransitionOnLoaded", TypeString, Offset(stateTransitionLoaded, StateItemData), MaxStates,
"Name of the state to transition to when the loaded state of the Image "
"changes to 'Loaded'." );
addField( "stateTransitionOnNotLoaded", TypeString, Offset(stateTransitionNotLoaded, StateItemData), MaxStates,
"Name of the state to transition to when the loaded state of the Image "
"changes to 'Empty'." );
addField( "stateTransitionOnAmmo", TypeString, Offset(stateTransitionAmmo, StateItemData), MaxStates,
"Name of the state to transition to when the ammo state of the Image "
"changes to true." );
addField( "stateTransitionOnNoAmmo", TypeString, Offset(stateTransitionNoAmmo, StateItemData), MaxStates,
"Name of the state to transition to when the ammo state of the Image "
"changes to false." );
addField( "stateTransitionOnTarget", TypeString, Offset(stateTransitionTarget, StateItemData), MaxStates,
"Name of the state to transition to when the Image gains a target." );
addField( "stateTransitionOnNoTarget", TypeString, Offset(stateTransitionNoTarget, StateItemData), MaxStates,
"Name of the state to transition to when the Image loses a target." );
addField( "stateTransitionOnWet", TypeString, Offset(stateTransitionWet, StateItemData), MaxStates,
"Name of the state to transition to when the Image enters the water." );
addField( "stateTransitionOnNotWet", TypeString, Offset(stateTransitionNotWet, StateItemData), MaxStates,
"Name of the state to transition to when the Image exits the water." );
addField( "stateTransitionOnMotion", TypeString, Offset(stateTransitionMotion, StateItemData), MaxStates,
"Name of the state to transition to when the Player moves." );
addField( "stateTransitionOnNoMotion", TypeString, Offset(stateTransitionNoMotion, StateItemData), MaxStates,
"Name of the state to transition to when the Player stops moving." );
addField( "stateTransitionOnTriggerUp", TypeString, Offset(stateTransitionTriggerUp, StateItemData), MaxStates,
"Name of the state to transition to when the trigger state of the Image "
"changes to true (fire button down)." );
addField( "stateTransitionOnTriggerDown", TypeString, Offset(stateTransitionTriggerDown, StateItemData), MaxStates,
"Name of the state to transition to when the trigger state of the Image "
"changes to false (fire button released)." );
addField( "stateTransitionOnAltTriggerUp", TypeString, Offset(stateTransitionAltTriggerUp, StateItemData), MaxStates,
"Name of the state to transition to when the alt trigger state of the "
"Image changes to true (alt fire button down)." );
addField( "stateTransitionOnAltTriggerDown", TypeString, Offset(stateTransitionAltTriggerDown, StateItemData), MaxStates,
"Name of the state to transition to when the alt trigger state of the "
"Image changes to false (alt fire button up)." );
addField( "stateTransitionOnTimeout", TypeString, Offset(stateTransitionTimeout, StateItemData), MaxStates,
"Name of the state to transition to when we have been in this state "
"for stateTimeoutValue seconds." );
addField( "stateTransitionGeneric0In", TypeString, Offset(stateTransitionGeneric0In, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 0 state "
"changes to true." );
addField( "stateTransitionGeneric0Out", TypeString, Offset(stateTransitionGeneric0Out, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 0 state "
"changes to false." );
addField( "stateTransitionGeneric1In", TypeString, Offset(stateTransitionGeneric1In, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 1 state "
"changes to true." );
addField( "stateTransitionGeneric1Out", TypeString, Offset(stateTransitionGeneric1Out, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 1 state "
"changes to false." );
addField( "stateTransitionGeneric2In", TypeString, Offset(stateTransitionGeneric2In, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 2 state "
"changes to true." );
addField( "stateTransitionGeneric2Out", TypeString, Offset(stateTransitionGeneric2Out, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 2 state "
"changes to false." );
addField( "stateTransitionGeneric3In", TypeString, Offset(stateTransitionGeneric3In, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 3 state "
"changes to true." );
addField( "stateTransitionGeneric3Out", TypeString, Offset(stateTransitionGeneric3Out, StateItemData), MaxStates,
"Name of the state to transition to when the generic trigger 3 state "
"changes to false." );
addField( "stateTimeoutValue", TypeF32, Offset(stateTimeoutValue, StateItemData), MaxStates,
"Time in seconds to wait before transitioning to stateTransitionOnTimeout." );
addField( "stateWaitForTimeout", TypeBool, Offset(stateWaitForTimeout, StateItemData), MaxStates,
"If false, this state ignores stateTimeoutValue and transitions "
"immediately if other transition conditions are met." );
addField( "stateFire", TypeBool, Offset(stateFire, StateItemData), MaxStates,
"The first state with this set to true is the state entered by the "
"client when it receives the 'fire' event." );
addField( "stateAlternateFire", TypeBool, Offset(stateAlternateFire, StateItemData), MaxStates,
"The first state with this set to true is the state entered by the "
"client when it receives the 'altFire' event." );
addField( "stateReload", TypeBool, Offset(stateReload, StateItemData), MaxStates,
"The first state with this set to true is the state entered by the "
"client when it receives the 'reload' event." );
addField( "stateEjectShell", TypeBool, Offset(stateEjectShell, StateItemData), MaxStates,
"If true, a shell casing will be ejected in this state." );
addField( "stateEnergyDrain", TypeF32, Offset(stateEnergyDrain, StateItemData), MaxStates,
"Amount of energy to subtract from the Image in this state.\n"
"Energy is drained at stateEnergyDrain units/sec as long as we are in "
"this state." );
addField( "stateAllowImageChange", TypeBool, Offset(stateAllowImageChange, StateItemData), MaxStates,
"If false, other Images will temporarily be blocked from mounting "
"while the state machine is executing the tasks in this state.\n"
"For instance, if we have a rocket launcher, the player shouldn't "
"be able to switch out <i>while</i> firing. So, you'd set "
"stateAllowImageChange to false in firing states, and true the rest "
"of the time." );
addField( "stateDirection", TypeBool, Offset(stateDirection, StateItemData), MaxStates,
"Direction of the animation to play in this state.\nTrue is forward, "
"false is backward." );
addField( "stateLoadedFlag", TYPEID< StateItemData::StateData::LoadedState >(), Offset(stateLoaded, StateItemData), MaxStates,
"Set the loaded state of the \n"
"<ul><li>IgnoreLoaded: Don't change Image loaded state.</li>"
"<li>Loaded: Set Image loaded state to true.</li>"
"<li>NotLoaded: Set Image loaded state to false.</li></ul>" );
addField( "stateSpinThread", TYPEID< StateItemData::StateData::SpinState >(), Offset(stateSpin, StateItemData), MaxStates,
"Controls how fast the 'spin' animation sequence will be played in "
"this state.\n"
"<ul><li>Ignore: No change to the spin sequence.</li>"
"<li>Stop: Stops the spin sequence at its current position.</li>"
"<li>SpinUp: Increase spin sequence timeScale from 0 (on state entry) "
"to 1 (after stateTimeoutValue seconds).</li>"
"<li>SpinDown: Decrease spin sequence timeScale from 1 (on state entry) "
"to 0 (after stateTimeoutValue seconds).</li>"
"<li>FullSpeed: Resume the spin sequence playback at its current "
"position with timeScale=1.</li></ul>" );
addField( "stateRecoil", TYPEID< StateItemData::StateData::RecoilState >(), Offset(stateRecoil, StateItemData), MaxStates,
"Type of recoil sequence to play on the ShapeBase object on entry to "
"this state.\n"
"<ul><li>NoRecoil: Do not play a recoil sequence.</li>"
"<li>LightRecoil: Play the light_recoil sequence.</li>"
"<li>MediumRecoil: Play the medium_recoil sequence.</li>"
"<li>HeavyRecoil: Play the heavy_recoil sequence.</li></ul>" );
addField( "stateSequence", TypeString, Offset(stateSequence, StateItemData), MaxStates,
"Name of the sequence to play on entry to this state." );
addField( "stateSequenceRandomFlash", TypeBool, Offset(stateSequenceRandomFlash, StateItemData), MaxStates,
"If true, a random frame from the muzzle flash sequence will be "
"displayed each frame.\n"
"The name of the muzzle flash sequence is the same as stateSequence, "
"with \"_vis\" at the end." );
addField( "stateScaleAnimation", TypeBool, Offset(stateScaleAnimation, StateItemData), MaxStates,
"If true, the timeScale of the stateSequence animation will be adjusted "
"such that the sequence plays for stateTimeoutValue seconds. " );
addField( "stateSequenceTransitionIn", TypeBool, Offset(stateSequenceTransitionIn, StateItemData), MaxStates,
"Do we transition to the state's sequence when we enter the state?" );
addField( "stateSequenceTransitionOut", TypeBool, Offset(stateSequenceTransitionOut, StateItemData), MaxStates,
"Do we transition to the new state's sequence when we leave the state?" );
addField( "stateSequenceNeverTransition", TypeBool, Offset(stateSequenceNeverTransition, StateItemData), MaxStates,
"Never allow a transition to this sequence. Often used for a fire sequence." );
addField( "stateSequenceTransitionTime", TypeF32, Offset(stateSequenceTransitionTime, StateItemData), MaxStates,
"The time to transition in or out of a sequence." );
addField( "stateShapeSequence", TypeString, Offset(stateShapeSequence, StateItemData), MaxStates,
"Name of the sequence that is played on the mounting shape." );
addField( "stateScaleShapeSequence", TypeBool, Offset(stateScaleShapeSequence, StateItemData), MaxStates,
"Indicates if the sequence to be played on the mounting shape should be scaled to the length of the state." );
addField( "stateSound", TypeSFXTrackName, Offset(stateSound, StateItemData), MaxStates,
"Sound to play on entry to this state." );
addField( "stateScript", TypeCaseString, Offset(stateScript, StateItemData), MaxStates,
"Method to execute on entering this state.\n"
"Scoped to this image class name, then StateItemData. The script "
"callback function takes the same arguments as the onMount callback." );
addField( "stateEmitter", TYPEID< ParticleEmitterData >(), Offset(stateEmitter, StateItemData), MaxStates,
"Emitter to generate particles in this state (from muzzle point or "
"specified node).\n\n@see stateEmitterNode" );
addField( "stateEmitterTime", TypeF32, Offset(stateEmitterTime, StateItemData), MaxStates,
"How long (in seconds) to emit particles on entry to this state." );
addField( "stateEmitterNode", TypeString, Offset(stateEmitterNode, StateItemData), MaxStates,
"Name of the node to emit particles from.\n\n@see stateEmitter" );
addField( "stateIgnoreLoadedForReady", TypeBool, Offset(stateIgnoreLoadedForReady, StateItemData), MaxStates,
"If set to true, and both ready and loaded transitions are true, the "
"ready transition will be taken instead of the loaded transition.\n"
"A state is 'ready' if pressing the fire trigger in that state would "
"transition to the fire state." );
endArray( "States" );
addField( "computeCRC", TypeBool, Offset(computeCRC, StateItemData),
"If true, verify that the CRC of the client's Image matches the server's "
"CRC for the Image when loaded by the client." );
addField( "maxConcurrentSounds", TypeS32, Offset(maxConcurrentSounds, StateItemData),
"Maximum number of sounds this Image can play at a time.\n"
"Any value <= 0 indicates that it can play an infinite number of sounds." );
addField( "useRemainderDT", TypeBool, Offset(useRemainderDT, StateItemData),
"If true, allow multiple timeout transitions to occur within a single "
"tick (useful if states have a very small timeout)." );
//-JR
Parent::initPersistFields();
}
void StateItemData::packData(BitStream* stream)
{
Parent::packData(stream);
stream->writeFloat(friction, 10);
stream->writeFloat(elasticity, 10);
stream->writeFlag(sticky);
if(stream->writeFlag(gravityMod != 1.0))
stream->writeFloat(gravityMod, 10);
if(stream->writeFlag(maxVelocity != -1))
stream->write(maxVelocity);
if(stream->writeFlag(lightType != StateItem::NoLight))
{
AssertFatal(StateItem::NumLightTypes < (1 << 2), "StateItemData: light type needs more bits");
stream->writeInt(lightType, 2);
stream->writeFloat(lightColor.red, 7);
stream->writeFloat(lightColor.green, 7);
stream->writeFloat(lightColor.blue, 7);
stream->writeFloat(lightColor.alpha, 7);
stream->write(lightTime);
stream->write(lightRadius);
stream->writeFlag(lightOnlyStatic);
}
stream->writeFlag(simpleServerCollision);
//-JR
//advanced StateItem support
if(stream->writeFlag(computeCRC))
stream->write(mCRC);
stream->writeString(itemAnimPrefix);
stream->writeString(shapeName);
stream->write(mountPoint);
if (!stream->writeFlag(mountOffset.isIdentity()))
stream->writeAffineTransform(mountOffset);
if (!stream->writeFlag(eyeOffset.isIdentity()))
stream->writeAffineTransform(eyeOffset);
stream->writeFlag(animateOnServer);
stream->write(scriptAnimTransitionTime);
stream->writeFlag(useEyeNode);
stream->writeFlag(correctMuzzleVector);
stream->writeFlag(correctMuzzleVectorTP);
stream->writeFlag(firstPerson);
stream->write(mass);
stream->writeFlag(usesEnergy);
stream->write(minEnergy);
stream->writeFlag(hasFlash);
// Client doesn't need accuFire
// Write the projectile datablock
if (stream->writeFlag(projectile))
stream->writeRangedU32(packed? SimObjectId(projectile):
projectile->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
stream->writeFlag(cloakable);
if ( stream->writeFlag( shakeCamera ) )
{
mathWrite( *stream, camShakeFreq );
mathWrite( *stream, camShakeAmp );
}
mathWrite( *stream, shellExitDir );
stream->write(shellExitVariance);
stream->write(shellVelocity);
if( stream->writeFlag( casing ) )
{