Torque3D Documentation / _generateds / proximityMine.h

proximityMine.h

Engine/source/T3D/proximityMine.h

More...

Classes:

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   };
 78
 79   enum State
 80   {
 81      Thrown = 0,       //!< Mine has been thrown, but not yet attached to a surface
 82      Deployed,         //!< Mine has attached to a surface but is not yet armed
 83      Armed,            //!< Mine is armed and will trigger if any object enters the trigger area
 84      Triggered,        //!< Mine has been triggered and will explode soon
 85      Exploded,         //!< Mine has exploded and will be deleted on the server shortly
 86      NumStates
 87   };
 88
 89   ProximityMineData*   mDataBlock;
 90
 91   TSThread*            mAnimThread;
 92   SceneObject*         mOwner;
 93
 94   State                mState;
 95   F32                  mStateTimeout;
 96
 97   void setDeployedPos( const Point3F& pos, const Point3F& normal );
 98
 99   void prepRenderImage( SceneRenderState* state );
100   void renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat );
101
102public:
103   DECLARE_CONOBJECT( ProximityMine );
104
105   ProximityMine();
106   ~ProximityMine();
107
108   static void consoleInit();
109
110   bool onAdd();
111   void onRemove();
112   bool onNewDataBlock( GameBaseData* dptr, bool reload );
113
114   virtual void setTransform( const MatrixF& mat );
115   void processTick( const Move* move );
116   void explode();
117
118   void advanceTime( F32 dt );
119
120   U32  packUpdate  ( NetConnection* conn, U32 mask, BitStream* stream );
121   void unpackUpdate( NetConnection* conn, BitStream* stream );
122};
123
124#endif // _PROXIMITYMINE_H_
125