OSDN Git Service

イニシャルコミット。
[marathon/ShapeFusion.git] / Physics / PhysicsElements.h
1 /*
2  * This file is part of ShapeFusion (Copyright 2000 Tito Dal Canton)
3  *
4  * ShapeFusion is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * ShapeFusion is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with ShapeFusion; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19 #ifndef PHYSICSELEMENTS_H
20 #define PHYSICSELEMENTS_H
21
22 #include "../BigEndianBuffer.h"
23 #include <iostream>
24
25 class PhysicsElement
26 {
27 private:
28         bool mVerboseLoading;
29
30 protected:
31         // So that subclasses can change their status
32         bool mGoodData;
33
34 public:
35         PhysicsElement(bool verbose) : mVerboseLoading(verbose), mGoodData(false) {}
36         ~PhysicsElement() { }
37
38         bool IsGood() const { return mGoodData; }
39         bool IsVerbose() const { return mVerboseLoading; }
40 };
41
42 class PhysicsConstants : public PhysicsElement
43 {
44         friend std::ostream& operator<<(std::ostream&, const PhysicsConstants&);
45 private:
46         double mMaximumForwardVelocity;
47         double mMaximumBackwardVelocity;
48         double mMaximumPerpendicularVelocity;
49
50         double mAcceleration;
51         double mDeceleration;
52         double mAirborneDeceleration;
53         
54         double mGravitationalAcceleration;
55         double mClimbingAcceleration;
56         double mTerminalVelocity;
57
58         double mExternalDeceleration;
59
60         double mAngularAcceleration;
61         double mAngularDeceleration;
62         double mMaximumAngularVelocity;
63         double mAngularRecenteringVelocity;
64
65         double mFastAngularVelocity;
66         double mFastAngularMaximum;
67
68         double mMaximumElevation;
69         double mExternalAngularDeceleration;
70
71         double mStepDelta;
72         double mStepAmplitude;
73         
74         double mRadius;
75         double mHeight;
76         double mDeadHeight;
77         double mCameraHeight;
78         double mSplashHeight;
79
80         double mHalfCameraSeparation;
81 public:
82         // accessors
83         double GetMaximumForwardVelocity() const { return mMaximumForwardVelocity; }
84         double GetMaximumBackwardVelocity() const { return mMaximumBackwardVelocity; }
85         double GetMaximumPerpendicularVelocity() const { return mMaximumPerpendicularVelocity; }
86
87         double GetAcceleration() const { return mAcceleration; }
88         double GetDeceleration() const { return mDeceleration; }
89         double GetAirborneDeceleration() const { return mAirborneDeceleration; }
90
91         double GetGravitationalAcceleration() const { return mGravitationalAcceleration; }
92         double GetClimbingAcceleration() const { return mClimbingAcceleration; }
93         double GetTerminalVelocity() const { return mTerminalVelocity; }
94
95         double GetExternalDeceleration() const { return mExternalDeceleration; }
96
97         double GetAngularAcceleration() const { return mAngularAcceleration; }
98         double GetAngularDeceleration() const { return mAngularDeceleration; }
99         double GetMaximumAngularVelocity() const { return mMaximumAngularVelocity; }
100         double GetAngularRecenteringVelocity() const { return mAngularRecenteringVelocity; }
101
102
103         double GetFastAngularVelocity() const { return mFastAngularVelocity; }
104         double GetFastAngularMaximum() const { return mFastAngularMaximum; }
105
106         double GetMaximumElevation() const { return mMaximumElevation; }
107         double GetExternalAngularDeceleration() const { return mExternalAngularDeceleration; }
108
109         double GetStepDelta() const { return mStepDelta; }
110         double GetStepAmplitude() const { return mStepAmplitude; }
111         
112         double GetRadius() const { return mRadius; }
113         double GetHeight() const { return mHeight; }
114         double GetDeadHeight() const { return mDeadHeight; }
115         double GetCameraHeight() const { return mCameraHeight; }
116         double GetSplashHeight() const { return mSplashHeight; }
117
118         double GetHalfCameraSeparation() const { return mHalfCameraSeparation; }
119
120         // mutators
121         void SetMaximumForwardVelocity(double v) { mMaximumForwardVelocity = v; }
122         void SetMaximumBackwardVelocity(double v) { mMaximumBackwardVelocity = v; }
123         void SetMaximumPerpendicularVelocity(double v) { mMaximumPerpendicularVelocity = v; }
124
125         void SetAcceleration(double v) { mAcceleration = v; }
126         void SetDeceleration(double v) { mDeceleration = v; }
127         void SetAirborneDeceleration(double v) { mAirborneDeceleration = v; }
128         
129         void SetGravitationalAcceleration(double v) { mGravitationalAcceleration = v; }
130         void SetClimbingAcceleration(double v) { mClimbingAcceleration = v; }
131         void SetTerminalVelocity(double v) { mTerminalVelocity = v; }
132
133         void SetExternalDeceleration(double v) { mExternalDeceleration = v; }
134
135         void SetAngularAcceleration(double v) { mAngularAcceleration = v; }
136         void SetAngularDeceleration(double v) { mAngularDeceleration = v; }
137         void SetMaximumAngularVelocity(double v) { mMaximumAngularVelocity = v; }
138         void SetAngularRecenteringVelocity(double v) { mAngularRecenteringVelocity = v; }
139
140         void SetFastAngularVelocity(double v) { mFastAngularVelocity = v; }
141         void SetFastAngularMaximum(double v) { mFastAngularMaximum = v; }
142
143         void SetMaximumElevation(double v) { mMaximumElevation = v; }
144         void SetExternalAngularDeceleration(double v) { mExternalAngularDeceleration = v; }
145
146         void SetStepDelta(double v) { mStepDelta = v; }
147         void SetStepAmplitude(double v) { mStepAmplitude = v; }
148         
149         void SetRadius(double v) { mRadius = v; }
150         void SetHeight(double v) { mHeight = v; }
151         void SetDeadHeight(double v) { mDeadHeight = v; }
152         void SetCameraHeight(double v) { mCameraHeight = v; }
153         void SetSplashHeight(double v) { mSplashHeight = v; }
154
155         void SetHalfCameraSeparation(double v) { mHalfCameraSeparation = v; }
156
157
158         PhysicsConstants(bool verbose = false) : PhysicsElement(verbose) { }
159         ~PhysicsConstants() { }
160
161         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
162         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
163
164         static const int kSize = 104;
165 };
166
167 class AttackDefinition : public PhysicsElement
168 {
169         friend std::ostream& operator<<(std::ostream&, const AttackDefinition&);
170 private:
171         short mType;
172         short mRepetitions;
173         double mError;
174         short mRange;
175         short mAttackShape;
176         short mDx, mDy, mDz;
177
178 public:
179         // accessors
180         short GetType() { return mType; }
181         short GetRepetitions() { return mRepetitions; }
182         double GetError() { return mError; }
183         short GetRange() { return mRange; }
184         short GetShape() { return mAttackShape; }
185         short GetDx() { return mDx; }
186         short GetDy() { return mDy; }
187         short GetDz() { return mDz; }
188
189         // mutators
190         void SetType(short v) { mType = v; }
191         void SetRepetitions(short v) { mRepetitions = v; }
192         void SetError(double d) { mError = d; }
193         void SetRange(short v) { mRange = v; }
194         void SetShape(short v) { mAttackShape = v; }
195         void SetDx(short v) { mDx = v; }
196         void SetDy(short v) { mDy = v; }
197         void SetDz(short v) { mDz = v; }
198         
199         AttackDefinition(bool verbose = false) : PhysicsElement(verbose) { }
200         ~AttackDefinition() { }
201
202         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
203         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
204 };
205
206 class DamageDefinition : public PhysicsElement
207 {
208         friend std::ostream& operator<<(std::ostream&, const DamageDefinition&);
209 private:
210         short mType;
211         short mFlags;
212         short mBase;
213         short mRandom;
214         double mScale;
215
216         enum {
217                 kAlienDamage = 0x01
218         };
219
220 public:
221         // accessors
222         short GetType() { return mType; }
223         short GetBase() { return mBase; }
224         bool GetAlien() { return mFlags & kAlienDamage; }
225         short GetRandom() { return mRandom; }
226         double GetScale() { return mScale; }
227
228         // mutators
229         void SetType(short v) { mType = v; }
230         void SetAlien(bool b) { 
231                 if (b) mFlags |= kAlienDamage;
232                 else mFlags &= ~kAlienDamage; 
233         }
234
235         void SetBase(short v) { mBase = v; }
236         void SetRandom(short v) { mRandom = v; }
237         void SetScale(double d) { mScale = d; }
238
239         DamageDefinition(bool verbose = false) : PhysicsElement(verbose) { }
240         ~DamageDefinition() { }
241
242         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
243         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
244 };
245
246 class EffectDefinition : public PhysicsElement
247 {
248         friend std::ostream& operator<<(std::ostream&, const EffectDefinition&);
249 private:
250         unsigned short mCollection;
251         unsigned short mColorTable;
252         short mShape;
253         double mSoundPitch;
254         unsigned short mFlags;
255         short mDelay;
256         short mDelaySound;
257
258         enum {
259                 kEndWhenAnimationLoops = 0x0001,
260                 kEndWhenTransferAnimationLoops = 0x0002,
261                 kSoundOnly = 0x0004,
262                 kMakeTwinVisible = 0x0008,
263                 kMediaEffect = 0x0010
264         };
265
266 public:
267         // accessors
268         unsigned short GetCollection() { return mCollection; }
269         unsigned short GetColorTable() { return mColorTable; }
270         short GetShape() { return mShape; }
271         double GetSoundPitch() { return mSoundPitch; }
272         short GetDelay() { return mDelay; }
273         short GetDelaySound() { return mDelaySound; }
274
275         bool GetEndWhenAnimationLoops() { return mFlags & kEndWhenAnimationLoops; }
276         bool GetEndWhenTransferAnimationLoops() { return mFlags & kEndWhenTransferAnimationLoops; }
277         bool GetSoundOnly() { return mFlags & kSoundOnly; }
278         bool GetMediaEffect() { return mFlags & kMediaEffect; }
279
280         // mutators
281         void SetCollection(unsigned short v) { mCollection = v; }
282         void SetColorTable(unsigned short v) { mColorTable = v; }
283         void SetShape(short v) { mShape = v; }
284         void SetSoundPitch(double v) { mSoundPitch = v; }
285         void SetDelay(short v) { mDelay = v; }
286         void SetDelaySound(short v) { mDelaySound = v; }
287
288         void SetEndWhenAnimationLoops(bool v) { 
289                 if (v) mFlags |= kEndWhenAnimationLoops;
290                 else mFlags &= ~kEndWhenAnimationLoops;
291         }
292
293         void SetEndWhenTransferAnimationLoops(bool v) { 
294                 if (v) mFlags |= kEndWhenTransferAnimationLoops;
295                 else mFlags &= ~kEndWhenTransferAnimationLoops;
296         }
297         
298         void SetSoundOnly(bool v) { 
299                 if (v) mFlags |= kSoundOnly;
300                 else mFlags &= ~kSoundOnly;
301         }
302
303         void SetMediaEffect(bool v) { 
304                 if (v) mFlags |= kMediaEffect;
305                 else mFlags &= ~kMediaEffect;
306         }
307
308         EffectDefinition(bool verbose = false) : PhysicsElement(verbose) { }
309         ~EffectDefinition() { }
310
311         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
312         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
313
314         static const int kSize = 14;
315 };      
316
317 class MonsterDefinition : public PhysicsElement
318 {
319         friend std::ostream& operator<<(std::ostream&, const MonsterDefinition&);
320 private:
321         unsigned short mCollection;
322         unsigned short mColorTable;
323
324         short mVitality;
325         unsigned long mImmunities;
326         unsigned long mWeaknesses;
327         unsigned long mFlags;
328
329         long mClass;
330         long mFriends;
331         long mEnemies;
332         
333         double mSoundPitch;
334         
335         short mActivationSound;
336         short mFriendlyActivationSound;
337         short mClearSound;
338         short mKillSound;
339         short mApologySound;
340         short mFriendlyFireSound;
341         short mFlamingSound;
342         short mRandomSound;
343         short mRandomSoundMask;
344
345         short mCarryingItemType;
346         
347         short mRadius;
348         short mHeight;
349         short mPreferredHoverHeight;
350         short mMinimumLedgeDelta;
351         short mMaximumLedgeDelta;
352         double mExternalVelocityScale;
353         short mImpactEffect;
354         short mMeleeImpactEffect;
355         short mContrailEffect;
356
357         short mHalfVisualArc;
358         short mHalfVerticalVisualArc;
359         short mVisualRange;
360         short mDarkVisualRange;
361         short mIntelligence;
362         short mSpeed;
363         short mGravity;
364         short mTerminalVelocity;
365         short mDoorRetryMask;
366         short mShrapnelRadius;
367         
368         DamageDefinition mShrapnelDamage;
369
370         // sequence IDs
371         short mHitShapes;
372         short mHardDyingShape;
373         short mSoftDyingShape;
374         short mHardDeadShapes;
375         short mSoftDeadShapes;
376         short mStationaryShape;
377         short mMovingShape;
378         short mTeleportInShape;
379         short mTeleportOutShape;
380
381         short mAttackFrequency;
382         AttackDefinition mMeleeAttack;
383         AttackDefinition mRangedAttack;
384
385 public:
386         // accessors
387         unsigned short GetCollection() { return mCollection; }
388         unsigned short GetColorTable() { return mColorTable; }
389
390         short GetVitality() { return mVitality; }
391         bool GetImmunity(int index) { return mImmunities & (1 << index); }
392         bool GetWeakness(int index) { return mWeaknesses & (1 << index); }
393         bool GetFlag(int index) { return mFlags & (1 << index); }
394
395         long GetClass() { return mClass; }
396         bool GetFriend(int index) { return mFriends & (1 << index); }
397         bool GetEnemy(int index) { return mEnemies & (1 << index); }
398
399         double GetSoundPitch() { return  mSoundPitch; }
400
401         short GetActivationSound() { return  mActivationSound; }
402         short GetFriendlyActivationSound() { return  mFriendlyActivationSound; }
403         short GetClearSound() { return  mClearSound; }
404         short GetKillSound() { return  mKillSound; }
405         short GetApologySound() { return  mApologySound; }
406         short GetFriendlyFireSound() { return  mFriendlyFireSound; }
407         short GetFlamingSound() { return  mFlamingSound; }
408         short GetRandomSound() { return  mRandomSound; }
409         short GetRandomSoundMask() { return  mRandomSoundMask; }
410
411         short GetCarryingItemType() { return mCarryingItemType; }
412
413         short GetRadius() { return mRadius; }
414         short GetHeight() { return mHeight; }
415         short GetPreferredHoverHeight() { return mPreferredHoverHeight; }
416         short GetMinimumLedgeDelta() { return mMinimumLedgeDelta; }
417         short GetMaximumLedgeDelta() { return mMaximumLedgeDelta; }
418         double GetExternalVelocityScale() { return mExternalVelocityScale; }
419         short GetImpactEffect() { return mImpactEffect; }
420         short GetMeleeImpactEffect() { return mMeleeImpactEffect; }
421         short GetContrailEffect() { return mContrailEffect; }
422
423         short GetVisualRange() { return mVisualRange; }
424         short GetDarkVisualRange() { return mDarkVisualRange; }
425         short GetIntelligence() { return mIntelligence; }
426         short GetSpeed() { return mSpeed; }
427         short GetGravity() { return mGravity; }
428         short GetTerminalVelocity() { return mTerminalVelocity; }
429         short GetDoorRetryMask() { return mDoorRetryMask; }
430         short GetShrapnelRadius() { return mShrapnelRadius; }
431
432         DamageDefinition* GetShrapnelDamage() { return &mShrapnelDamage; }
433
434         short GetHitShapes() { return  mHitShapes; }
435         short GetHardDyingShape() { return  mHardDyingShape; }
436         short GetSoftDyingShape() { return  mSoftDyingShape; }
437         short GetHardDeadShapes() { return  mHardDeadShapes; }
438         short GetSoftDeadShapes() { return  mSoftDeadShapes; }
439         short GetStationaryShape() { return  mStationaryShape; }
440         short GetMovingShape() { return  mMovingShape; }
441         short GetTeleportInShape() { return  mTeleportInShape; }
442         short GetTeleportOutShape() { return  mTeleportOutShape; }
443
444         short GetAttackFrequency() { return mAttackFrequency; }
445         AttackDefinition* GetMeleeAttack() { return &mMeleeAttack; }
446         AttackDefinition* GetRangedAttack() { return &mRangedAttack; }
447
448         // mutators
449         void SetCollection(unsigned short v) { mCollection = v; }
450         void SetColorTable(unsigned short v) { mColorTable = v; }
451
452         void SetVitality(short v) { mVitality = v; }
453         void SetImmunity(int index, bool b) { 
454                 if (b) mImmunities |= (1 << index);
455                 else mImmunities &= ~(1 << index);
456         }
457
458         void SetWeakness(int index, bool b) { 
459                 if (b) mWeaknesses |= (1 << index);
460                 else mWeaknesses &= ~(1 << index);
461         }
462
463         void SetFlag(int index, bool b) { 
464                 if (b) mFlags |= (1 << index);
465                 else mFlags &= ~(1 << index);
466         }
467
468         void SetClass(long v) { mClass = v; }
469
470         void SetFriend(int index, bool b) { 
471                 if (b) mFriends |= (1 << index);
472                 else mFriends &= ~(1 << index);
473         }
474
475         void SetEnemy(int index, bool b) { 
476                 if (b) mEnemies |= (1 << index);
477                 else mEnemies &= ~(1 << index);
478         }
479
480         void SetSoundPitch(double d) { mSoundPitch = d; }
481
482         void SetRadius(short v) { mRadius = v; }
483         void SetHeight(short v) { mHeight = v; }
484         void SetPreferredHoverHeight(short v) { mPreferredHoverHeight = v; }
485         void SetMinimumLedgeDelta(short v) { mMinimumLedgeDelta = v; }
486         void SetMaximumLedgeDelta(short v) { mMaximumLedgeDelta = v; }
487         void SetExternalVelocityScale(double d) { mExternalVelocityScale = d; }
488         void SetImpactEffect(short v) { mImpactEffect = v; }
489         void SetMeleeImpactEffect(short v) { mMeleeImpactEffect = v; }
490         void SetContrailEffect(short v) { mContrailEffect = v; }
491
492         void SetVisualRange(short v) { mVisualRange = v; }
493         void SetDarkVisualRange(short v) { mDarkVisualRange = v; }
494         void SetIntelligence(short v) { mIntelligence = v; }
495         void SetSpeed(short v) { mSpeed = v; }
496         void SetGravity(short v) { mGravity = v; }
497         void SetTerminalVelocity(short v) { mTerminalVelocity = v; }
498         void SetDoorRetryMask(short v) { mDoorRetryMask = v; }
499         void SetShrapnelRadius(short v) { mShrapnelRadius = v; }
500
501
502         void SetActivationSound(short v) { mActivationSound = v; }
503         void SetFriendlyActivationSound(short v) { mFriendlyActivationSound = v; }
504         void SetClearSound(short v) { mClearSound = v; }
505         void SetKillSound(short v) { mKillSound = v; }
506         void SetApologySound(short v) { mApologySound = v; }
507         void SetFriendlyFireSound(short v) { mFriendlyFireSound = v; }
508         void SetFlamingSound(short v) { mFlamingSound = v; }
509         void SetRandomSound(short v) { mRandomSound = v; }
510         void SetRandomSoundMask(short v) { mRandomSoundMask = v; }
511
512         void SetCarryingItemType(short v) { mCarryingItemType = v; }
513
514         void SetHitShapes(short v) { mHitShapes = v; }
515         void SetHardDyingShape(short v) { mHardDyingShape = v; }
516         void SetSoftDyingShape(short v) { mSoftDyingShape = v; }
517         void SetHardDeadShapes(short v) { mHardDeadShapes = v; }
518         void SetSoftDeadShapes(short v) { mSoftDeadShapes = v; }
519         void SetStationaryShape(short v) { mStationaryShape = v; }
520         void SetMovingShape(short v) { mMovingShape = v; }
521         void SetTeleportInShape(short v) { mTeleportInShape = v; }
522         void SetTeleportOutShape(short v) { mTeleportOutShape = v; }
523
524         void SetAttackFrequency(short v) { mAttackFrequency = v; }
525
526         MonsterDefinition(bool verbose = false) : PhysicsElement(verbose) { }
527         ~MonsterDefinition() { }
528
529         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
530         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
531
532         static const int kSize = 156;
533 };
534
535 class ProjectileDefinition : public PhysicsElement
536 {
537         friend std::ostream& operator<<(std::ostream&, const ProjectileDefinition&);
538 private:
539         unsigned short mCollection;
540         unsigned short mColorTable;
541         short mShape;
542         
543         short mDetonationEffect;
544         short mMediaDetonationEffect;
545         short mContrailEffect;
546         short mTicksBetweenContrails;
547         short mMaximumContrails;
548         short mMediaProjectilePromotion;
549
550         short mRadius;
551         short mAreaOfEffect;
552         DamageDefinition mDamage;
553         
554         unsigned long mFlags;
555
556         short mSpeed;
557         short mMaximumRange;
558
559         double mSoundPitch;
560         short mFlybySound;
561         short mReboundSound;
562
563 public:
564         // accessors
565         unsigned short GetCollection() { return mCollection; }
566         unsigned short GetColorTable() { return mColorTable; }
567         short GetShape() { return mShape; }
568
569         short GetDetonationEffect() { return mDetonationEffect; }
570         short GetMediaDetonationEffect() { return mMediaDetonationEffect; }
571         short GetContrailEffect() { return mContrailEffect; }
572         short GetTicksBetweenContrails() { return mTicksBetweenContrails; }
573         short GetMaximumContrails() { return mMaximumContrails; }
574         short GetMediaProjectilePromotion() { return mMediaProjectilePromotion; }
575
576         short GetRadius() { return mRadius; }
577         short GetAreaOfEffect() { return mAreaOfEffect; }
578
579         DamageDefinition* GetDamage() { return &mDamage; }
580
581         bool GetFlag(int flag_index) { return mFlags & (1 << flag_index); }
582
583         short GetSpeed() { return mSpeed; }
584         short GetMaximumRange() { return mMaximumRange; }
585
586         double GetSoundPitch() { return mSoundPitch; }
587         short GetFlybySound() { return mFlybySound; }
588         short GetReboundSound() { return mReboundSound; }
589
590         // mutators
591         void SetCollection(unsigned short v) { mCollection = v; }
592         void SetColorTable(unsigned short v) { mColorTable = v; }
593         void SetShape(short v) { mShape = v; }
594         
595         void SetDetonationEffect(short v) { mDetonationEffect = v; }
596         void SetMediaDetonationEffect(short v) { mMediaDetonationEffect = v; }
597         void SetContrailEffect(short v) { mContrailEffect = v; }
598         void SetTicksBetweenContrails(short v) { mTicksBetweenContrails = v; }
599         void SetMaximumContrails(short v) { mMaximumContrails = v; }
600         void SetMediaProjectilePromotion(short v) { mMediaProjectilePromotion = v; }
601
602         void SetRadius(short v) { mRadius = v; }
603         void SetAreaOfEffect(short v) { mAreaOfEffect = v; }
604
605         void SetFlag(int flag_index, bool f) {
606                 if (f) mFlags |= (1 << flag_index);
607                 else mFlags &= ~(1 << flag_index);
608         }
609
610         void SetSpeed(short v) { mSpeed = v; }
611         void SetMaximumRange(short v) { mMaximumRange = v; }
612
613         void SetSoundPitch(double v) { mSoundPitch = v; }
614         void SetFlybySound(short v) { mFlybySound = v; }
615         void SetReboundSound(short v) { mReboundSound = v; }
616
617         ProjectileDefinition(bool verbose = false) : PhysicsElement(verbose) { }
618         ~ProjectileDefinition() { }
619         
620         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
621         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
622         
623         static const int kSize = 48;
624 };
625
626 class TriggerDefinition : public PhysicsElement
627 {
628         friend std::ostream& operator<<(std::ostream&, const TriggerDefinition&);
629 private:
630         short mRoundsPerMagazine;
631         short mAmmunitionType;
632         short mTicksPerRound;
633         short mRecoveryTicks;
634         short mChargingTicks;
635         short mRecoilMagnitude;
636         
637         short mFiringSound;
638         short mClickSound;
639         short mChargingSound;
640         short mShellCasingSound;
641         short mReloadingSound;
642         short mChargedSound;
643         
644         short mProjectileType;
645         short mThetaError;
646         short mDx;
647         short mDz;
648         short mShellCasingType;
649         short mBurstCount;
650 public:
651         // accessors
652         short GetRoundsPerMagazine() { return mRoundsPerMagazine; }
653         short GetAmmunitionType() { return mAmmunitionType; }
654         short GetTicksPerRound() { return mTicksPerRound; }
655         short GetRecoveryTicks() { return mRecoveryTicks; }
656         short GetChargingTicks() { return mChargingTicks; }
657         short GetRecoilMagnitude() { return mRecoilMagnitude; }
658         
659         short GetFiringSound() { return mFiringSound; }
660         short GetClickSound() { return mClickSound; }
661         short GetChargingSound() { return mChargingSound; }
662         short GetShellCasingSound() { return mShellCasingSound; }
663         short GetReloadingSound() { return mReloadingSound; }
664         short GetChargedSound() { return mChargedSound; }
665         
666         short GetProjectileType() { return mProjectileType; }
667         short GetThetaError() { return mThetaError; }
668         short GetDx() { return mDx; }
669         short GetDz() { return mDz; }
670         short GetShellCasingType() { return mShellCasingType; }
671         short GetBurstCount() { return mBurstCount; }
672
673         // mutators
674         void SetRoundsPerMagazine(short v) { mRoundsPerMagazine = v; }
675         void SetAmmunitionType(short v) { mAmmunitionType = v; }
676         void SetTicksPerRound(short v) { mTicksPerRound = v; }
677         void SetRecoveryTicks(short v) { mRecoveryTicks = v; }
678         void SetChargingTicks(short v) { mChargingTicks = v; }
679         void SetRecoilMagnitude(short v) { mRecoilMagnitude = v; }
680         
681         void SetFiringSound(short v) { mFiringSound = v; }
682         void SetClickSound(short v) { mClickSound = v; }
683         void SetChargingSound(short v) { mChargingSound = v; }
684         void SetShellCasingSound(short v) { mShellCasingSound = v; }
685         void SetReloadingSound(short v) { mReloadingSound = v; }
686         void SetChargedSound(short v) { mChargedSound = v; }
687         
688         void SetProjectileType(short v) { mProjectileType = v; }
689         void SetThetaError(short v) { mThetaError = v; }
690         void SetDx(short v) { mDx = v; }
691         void SetDz(short v) { mDz = v; }
692         void SetShellCasingType(short v) { mShellCasingType = v; }
693         void SetBurstCount(short v) { mBurstCount = v; }
694
695         TriggerDefinition(bool verbose = false) : PhysicsElement(verbose) { }
696         ~TriggerDefinition() { }
697
698         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
699         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
700 };
701
702 class WeaponDefinition : public PhysicsElement
703 {
704         friend std::ostream& operator<<(std::ostream&, const WeaponDefinition&);
705 private:
706         short mItemType;
707         short mPowerupType;
708         short mWeaponClass;
709         short mFlags;
710         
711         double mFiringLightIntensity;
712         short mFiringIntensityDecayTicks;
713
714         double mIdleHeight;
715         double mBobAmplitude;
716         double mKickHeight;
717         double mReloadHeight;
718         double mIdleWidth;
719         double mHorizontalAmplitude;
720
721         unsigned short mCollection;
722         unsigned short mColorTable;
723         
724         short mIdleShape;
725         short mFiringShape;
726         short mReloadingShape;
727         // short unused
728         short mChargingShape;
729         short mChargedShape;
730
731         short mReadyTicks;
732         short mAwaitReloadTicks;
733         short mLoadingTicks;
734         short mFinishLoadingTicks;
735         short mPowerupTicks;
736
737         TriggerDefinition mPrimaryTrigger;
738         TriggerDefinition mSecondaryTrigger;
739 public:
740         // accessors
741         short GetItemType() { return mItemType; }
742         short GetPowerupType() { return mPowerupType; }
743         short GetWeaponClass() { return mWeaponClass; }
744         bool GetFlag(int index) { return mFlags & (1 << index); }
745         
746         double GetFiringLightIntensity() { return mFiringLightIntensity; }
747         short GetFiringIntensityDecayTicks() { return mFiringIntensityDecayTicks; }
748
749         double GetIdleHeight() { return mIdleHeight; }
750         double GetBobAmplitude() { return mBobAmplitude; }
751         double GetKickHeight() { return mKickHeight; }
752         double GetReloadHeight() { return mReloadHeight; }
753         double GetIdleWidth() { return mIdleWidth; }
754         double GetHorizontalAmplitude() { return mHorizontalAmplitude; }
755
756         unsigned short GetCollection() { return mCollection; }
757         unsigned short GetColorTable() { return mColorTable; }
758         
759         short GetIdleShape() { return mIdleShape; }
760         short GetFiringShape() { return mFiringShape; }
761         short GetReloadingShape() { return mReloadingShape; }
762         short GetChargingShape() { return mChargingShape; }
763         short GetChargedShape() { return mChargedShape; }
764
765         short GetReadyTicks() { return mReadyTicks; }
766         short GetAwaitReloadTicks() { return mAwaitReloadTicks; }
767         short GetLoadingTicks() { return mLoadingTicks; }
768         short GetFinishLoadingTicks() { return mFinishLoadingTicks; }
769
770         TriggerDefinition* GetPrimaryTrigger() { return &mPrimaryTrigger; }
771         TriggerDefinition* GetSecondaryTrigger() { return &mSecondaryTrigger; }
772
773         // mutators
774         void SetItemType(short v) { mItemType = v; }
775         void SetPowerupType(short v) { mPowerupType = v; }
776         void SetWeaponClass(short v) { mWeaponClass = v; }
777         void SetFlag(int index, bool v) {
778                 if (v) mFlags |= (1 << index);
779                 else mFlags &= ~(1 << index);
780         }
781
782         void SetFiringLightIntensity(double v) { mFiringLightIntensity = v; }
783         void SetFiringIntensityDecayTicks(short v) { mFiringIntensityDecayTicks = v; }
784
785         void SetIdleHeight(double v) { mIdleHeight = v; }
786         void SetBobAmplitude(double v) { mBobAmplitude = v; }
787         void SetKickHeight(double v) { mKickHeight = v; }
788         void SetReloadHeight(double v) { mReloadHeight = v; }
789         void SetIdleWidth(double v) { mIdleWidth = v; }
790         void SetHorizontalAmplitude(double v) { mHorizontalAmplitude = v; }
791
792         void SetCollection(unsigned short v) { mCollection = v; }
793         void SetColorTable(unsigned short v) { mColorTable = v; }
794         
795         void SetIdleShape(short v) { mIdleShape = v; }
796         void SetFiringShape(short v) { mFiringShape = v; }
797         void SetReloadingShape(short v) { mReloadingShape = v; }
798         void SetChargingShape(short v) { mChargingShape = v; }
799         void SetChargedShape(short v) { mChargedShape = v; }
800
801         void SetReadyTicks(short v) { mReadyTicks = v; }
802         void SetAwaitReloadTicks(short v) { mAwaitReloadTicks = v; }
803         void SetLoadingTicks(short v) { mLoadingTicks = v; }
804         void SetFinishLoadingTicks(short v) { mFinishLoadingTicks = v; }
805
806
807         WeaponDefinition(bool verbose = false) : PhysicsElement(verbose) { }
808         ~WeaponDefinition() { }
809
810         BigEndianBuffer& SaveObject(BigEndianBuffer& buffer) const;
811         BigEndianBuffer& LoadObject(BigEndianBuffer& buffer);
812
813         static const int kSize = 134;
814 };
815
816 #endif