proximityMine.h
Engine/source/T3D/proximityMine.h
Classes:
class
class
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _PROXIMITYMINE_H_ 25#define _PROXIMITYMINE_H_ 26 27#ifndef _ITEM_H_ 28 #include "T3D/item.h" 29#endif 30 31class ExplosionData; 32class SFXTrack; 33class ProximityMine; 34 35//---------------------------------------------------------------------------- 36 37struct ProximityMineData: public ItemData 38{ 39 typedef ItemData Parent; 40 41 DECLARE_CALLBACK( void, onTriggered, ( ProximityMine* obj, SceneObject* target ) ); 42 DECLARE_CALLBACK( void, onExplode, ( ProximityMine* obj, Point3F pos ) ); 43 44public: 45 F32 armingDelay; 46 S32 armingSequence; 47 SFXTrack* armingSound; 48 49 F32 autoTriggerDelay; 50 bool triggerOnOwner; 51 F32 triggerRadius; 52 F32 triggerSpeed; 53 F32 triggerDelay; 54 S32 triggerSequence; 55 SFXTrack* triggerSound; 56 57 F32 explosionOffset; 58 59 ProximityMineData(); 60 DECLARE_CONOBJECT( ProximityMineData ); 61 static void initPersistFields(); 62 bool preload( bool server, String& errorStr ); 63 virtual void packData( BitStream* stream ); 64 virtual void unpackData( BitStream* stream ); 65}; 66 67//---------------------------------------------------------------------------- 68 69class ProximityMine: public Item 70{ 71 typedef Item Parent; 72 73protected: 74 enum MaskBits { 75 DeployedMask = Parent::NextFreeMask, 76 ExplosionMask = Parent::NextFreeMask << 1, 77 NextFreeMask = Parent::NextFreeMask << 2 78 }; 79 80 enum State 81 { 82 Thrown = 0, //!< Mine has been thrown, but not yet attached to a surface 83 Deployed, //!< Mine has attached to a surface but is not yet armed 84 Armed, //!< Mine is armed and will trigger if any object enters the trigger area 85 Triggered, //!< Mine has been triggered and will explode soon 86 Exploded, //!< Mine has exploded and will be deleted on the server shortly 87 NumStates 88 }; 89 90 ProximityMineData* mDataBlock; 91 92 TSThread* mAnimThread; 93 SceneObject* mOwner; 94 95 State mState; 96 F32 mStateTimeout; 97 98 void setDeployedPos( const Point3F& pos, const Point3F& normal ); 99 100 void prepRenderImage( SceneRenderState* state ); 101 void renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ); 102 103public: 104 DECLARE_CONOBJECT( ProximityMine ); 105 106 ProximityMine(); 107 ~ProximityMine(); 108 109 static void consoleInit(); 110 111 bool onAdd(); 112 void onRemove(); 113 bool onNewDataBlock( GameBaseData* dptr, bool reload ); 114 115 virtual void setTransform( const MatrixF& mat ); 116 void processTick( const Move* move ); 117 void explode(); 118 119 void advanceTime( F32 dt ); 120 121 U32 packUpdate ( NetConnection* conn, U32 mask, BitStream* stream ); 122 void unpackUpdate( NetConnection* conn, BitStream* stream ); 123}; 124 125#endif // _PROXIMITYMINE_H_ 126
