123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636 |
- /*
- ===========================================================================
- Doom 3 GPL Source Code
- Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
- This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
- Doom 3 Source Code is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- Doom 3 Source Code is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
- In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
- If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
- ===========================================================================
- */
- #ifndef __GAME_AFENTITY_H__
- #define __GAME_AFENTITY_H__
- /*
- ===============================================================================
- idMultiModelAF
- Entity using multiple separate visual models animated with a single
- articulated figure. Only used for debugging!
- ===============================================================================
- */
- const int GIB_DELAY = 200; // only gib this often to keep performace hits when blowing up several mobs
- class idMultiModelAF : public idEntity {
- public:
- CLASS_PROTOTYPE( idMultiModelAF );
- void Spawn( void );
- ~idMultiModelAF( void );
- virtual void Think( void );
- virtual void Present( void );
- protected:
- idPhysics_AF physicsObj;
- void SetModelForId( int id, const idStr &modelName );
- private:
- idList<idRenderModel *> modelHandles;
- idList<int> modelDefHandles;
- };
- /*
- ===============================================================================
- idChain
- Chain hanging down from the ceiling. Only used for debugging!
- ===============================================================================
- */
- class idChain : public idMultiModelAF {
- public:
- CLASS_PROTOTYPE( idChain );
- void Spawn( void );
- protected:
- void BuildChain( const idStr &name, const idVec3 &origin, float linkLength, float linkWidth, float density, int numLinks, bool bindToWorld = true );
- };
- /*
- ===============================================================================
- idAFAttachment
- ===============================================================================
- */
- class idAFAttachment : public idAnimatedEntity {
- public:
- CLASS_PROTOTYPE( idAFAttachment );
- idAFAttachment( void );
- virtual ~idAFAttachment( void );
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void SetBody( idEntity *bodyEnt, const char *headModel, jointHandle_t attachJoint );
- void ClearBody( void );
- idEntity * GetBody( void ) const;
- virtual void Think( void );
- virtual void Hide( void );
- virtual void Show( void );
- void PlayIdleAnim( int blendTime );
- virtual void GetImpactInfo( idEntity *ent, int id, const idVec3 &point, impactInfo_t *info );
- virtual void ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
- virtual void AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
- virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
- virtual void AddDamageEffect( const trace_t &collision, const idVec3 &velocity, const char *damageDefName );
- void SetCombatModel( void );
- idClipModel * GetCombatModel( void ) const;
- virtual void LinkCombat( void );
- virtual void UnlinkCombat( void );
- protected:
- idEntity * body;
- idClipModel * combatModel; // render model for hit detection of head
- int idleAnim;
- jointHandle_t attachJoint;
- };
- /*
- ===============================================================================
- idAFEntity_Base
- ===============================================================================
- */
- class idAFEntity_Base : public idAnimatedEntity {
- public:
- CLASS_PROTOTYPE( idAFEntity_Base );
- idAFEntity_Base( void );
- virtual ~idAFEntity_Base( void );
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- virtual void Think( void );
- virtual void GetImpactInfo( idEntity *ent, int id, const idVec3 &point, impactInfo_t *info );
- virtual void ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
- virtual void AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
- virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
- virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
- virtual bool UpdateAnimationControllers( void );
- virtual void FreeModelDef( void );
- virtual bool LoadAF( void );
- bool IsActiveAF( void ) const { return af.IsActive(); }
- const char * GetAFName( void ) const { return af.GetName(); }
- idPhysics_AF * GetAFPhysics( void ) { return af.GetPhysics(); }
- void SetCombatModel( void );
- idClipModel * GetCombatModel( void ) const;
- // contents of combatModel can be set to 0 or re-enabled (mp)
- void SetCombatContents( bool enable );
- virtual void LinkCombat( void );
- virtual void UnlinkCombat( void );
- int BodyForClipModelId( int id ) const;
- void SaveState( idDict &args ) const;
- void LoadState( const idDict &args );
- void AddBindConstraints( void );
- void RemoveBindConstraints( void );
- virtual void ShowEditingDialog( void );
- static void DropAFs( idEntity *ent, const char *type, idList<idEntity *> *list );
- protected:
- idAF af; // articulated figure
- idClipModel * combatModel; // render model for hit detection
- int combatModelContents;
- idVec3 spawnOrigin; // spawn origin
- idMat3 spawnAxis; // rotation axis used when spawned
- int nextSoundTime; // next time this can make a sound
- void Event_SetConstraintPosition( const char *name, const idVec3 &pos );
- void Event_SetAFGravity( const idVec3 &newGravity );
- void Event_SetAFActive( int value );
- void Event_SetAFRest( int value );
- };
- /*
- ===============================================================================
- idAFEntity_Gibbable
- ===============================================================================
- */
- extern const idEventDef EV_Gib;
- extern const idEventDef EV_Gibbed;
- class idAFEntity_Gibbable : public idAFEntity_Base {
- public:
- CLASS_PROTOTYPE( idAFEntity_Gibbable );
- idAFEntity_Gibbable( void );
- ~idAFEntity_Gibbable( void );
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- virtual void Present( void );
- virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
- #ifdef _D3XP
- void SetThrown( bool isThrown );
- virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
- #endif
- virtual void SpawnGibs( const idVec3 &dir, const char *damageDefName );
- #ifdef _D3XP
- bool IsGibbed() { return gibbed; };
- #endif
- protected:
- idRenderModel * skeletonModel;
- int skeletonModelDefHandle;
- bool gibbed;
- #ifdef _D3XP
- bool wasThrown;
- #endif
- virtual void Gib( const idVec3 &dir, const char *damageDefName );
- void InitSkeletonModel( void );
- void Event_Gib( const char *damageDefName );
- };
- /*
- ===============================================================================
- idAFEntity_Generic
- ===============================================================================
- */
- class idAFEntity_Generic : public idAFEntity_Gibbable {
- public:
- CLASS_PROTOTYPE( idAFEntity_Generic );
- idAFEntity_Generic( void );
- ~idAFEntity_Generic( void );
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- virtual void Think( void );
- void KeepRunningPhysics( void ) { keepRunningPhysics = true; }
- private:
- void Event_Activate( idEntity *activator );
- bool keepRunningPhysics;
- };
- /*
- ===============================================================================
- idAFEntity_WithAttachedHead
- ===============================================================================
- */
- class idAFEntity_WithAttachedHead : public idAFEntity_Gibbable {
- public:
- CLASS_PROTOTYPE( idAFEntity_WithAttachedHead );
- idAFEntity_WithAttachedHead();
- ~idAFEntity_WithAttachedHead();
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void SetupHead( void );
- virtual void Think( void );
- virtual void Hide( void );
- virtual void Show( void );
- virtual void ProjectOverlay( const idVec3 &origin, const idVec3 &dir, float size, const char *material );
- virtual void LinkCombat( void );
- virtual void UnlinkCombat( void );
- protected:
- virtual void Gib( const idVec3 &dir, const char *damageDefName );
- #ifndef _D3XP
- private:
- #else
- public:
- #endif
- idEntityPtr<idAFAttachment> head;
- void Event_Gib( const char *damageDefName );
- void Event_Activate( idEntity *activator );
- };
- /*
- ===============================================================================
- idAFEntity_Vehicle
- ===============================================================================
- */
- class idAFEntity_Vehicle : public idAFEntity_Base {
- public:
- CLASS_PROTOTYPE( idAFEntity_Vehicle );
- idAFEntity_Vehicle( void );
- void Spawn( void );
- void Use( idPlayer *player );
- protected:
- idPlayer * player;
- jointHandle_t eyesJoint;
- jointHandle_t steeringWheelJoint;
- float wheelRadius;
- float steerAngle;
- float steerSpeed;
- const idDeclParticle * dustSmoke;
- idEntity* bindPoint;
- float GetSteerAngle( void );
- };
- /*
- ===============================================================================
- idAFEntity_VehicleSimple
- ===============================================================================
- */
- class idAFEntity_VehicleSimple : public idAFEntity_Vehicle {
- public:
- CLASS_PROTOTYPE( idAFEntity_VehicleSimple );
- idAFEntity_VehicleSimple( void );
- ~idAFEntity_VehicleSimple( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void Spawn( void );
- virtual void Think( void );
- idAFConstraint_Suspension * suspension[4];
- int stoppingState;
- int ignitionEndtime;
- bool isAI;
- void Event_isLightsOff( void );
- void SpawnSuspension( void );
- protected:
- idClipModel * wheelModel;
-
- jointHandle_t wheelJoints[4];
- float wheelAngles[4];
- bool attackHeld;
- bool gasHeld;
- };
- /*
- ===============================================================================
- idAFEntity_VehicleFourWheels
- ===============================================================================
- */
- class idAFEntity_VehicleFourWheels : public idAFEntity_Vehicle {
- public:
- CLASS_PROTOTYPE( idAFEntity_VehicleFourWheels );
- idAFEntity_VehicleFourWheels( void );
- void Spawn( void );
- virtual void Think( void );
- protected:
- idAFBody * wheels[4];
- idAFConstraint_Hinge * steering[2];
- jointHandle_t wheelJoints[4];
- float wheelAngles[4];
- };
- /*
- ===============================================================================
- idAFEntity_VehicleSixWheels
- ===============================================================================
- */
- class idAFEntity_VehicleSixWheels : public idAFEntity_Vehicle {
- public:
- CLASS_PROTOTYPE( idAFEntity_VehicleSixWheels );
- idAFEntity_VehicleSixWheels( void );
- void Spawn( void );
- virtual void Think( void );
- #ifdef _D3XP
- float force;
- float velocity;
- float steerAngle;
- #endif
- private:
- idAFBody * wheels[6];
- idAFConstraint_Hinge * steering[4];
- jointHandle_t wheelJoints[6];
- float wheelAngles[6];
- };
- #ifdef _D3XP
- /*
- ===============================================================================
- idAFEntity_VehicleAutomated
- ===============================================================================
- */
- class idAFEntity_VehicleAutomated : public idAFEntity_VehicleSimple {
- public:
- CLASS_PROTOTYPE( idAFEntity_VehicleAutomated );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void Spawn( void );
- void PostSpawn( void );
- virtual void Think( void );
- private:
- idEntity *waypoint;
- float steeringSpeed;
- float currentSteering;
- float idealSteering;
- float originHeight;
- void Event_SetVelocity( float _velocity );
- void Event_SetTorque( float _torque );
- void Event_SetSteeringSpeed( float _steeringSpeed );
- void Event_SetWayPoint( idEntity *_waypoint );
- };
- #endif
- /*
- ===============================================================================
- idAFEntity_SteamPipe
- ===============================================================================
- */
- class idAFEntity_SteamPipe : public idAFEntity_Base {
- public:
- CLASS_PROTOTYPE( idAFEntity_SteamPipe );
- idAFEntity_SteamPipe( void );
- ~idAFEntity_SteamPipe( void );
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- virtual void Think( void );
- private:
- int steamBody;
- float steamForce;
- float steamUpForce;
- idForce_Constant force;
- renderEntity_t steamRenderEntity;
- qhandle_t steamModelDefHandle;
- void InitSteamRenderEntity( void );
- };
- /*
- ===============================================================================
- idAFEntity_ClawFourFingers
- ===============================================================================
- */
- class idAFEntity_ClawFourFingers : public idAFEntity_Base {
- public:
- CLASS_PROTOTYPE( idAFEntity_ClawFourFingers );
- idAFEntity_ClawFourFingers( void );
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- private:
- idAFConstraint_Hinge * fingers[4];
- void Event_SetFingerAngle( float angle );
- void Event_StopFingers( void );
- };
- #ifdef _D3XP
- /**
- * idHarvestable contains all of the code required to turn an entity into a harvestable
- * entity. The entity must create an instance of this class and call the appropriate
- * interface methods at the correct time.
- */
- class idHarvestable : public idEntity {
- public:
- CLASS_PROTOTYPE( idHarvestable );
- idHarvestable();
- ~idHarvestable();
- void Spawn();
- void Init(idEntity* parent);
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void SetParent(idEntity* parent);
- void Think();
- void Gib();
- protected:
- idEntityPtr<idEntity> parentEnt;
- float triggersize;
- idClipModel * trigger;
- float giveDelay;
- float removeDelay;
- bool given;
- idEntityPtr<idPlayer> player;
- int startTime;
- bool fxFollowPlayer;
- idEntityPtr<idEntityFx> fx;
- idStr fxOrient;
- protected:
- void BeginBurn();
- void BeginFX();
- void CalcTriggerBounds( float size, idBounds &bounds );
- bool GetFxOrientationAxis(idMat3& mat);
- void Event_SpawnHarvestTrigger( void );
- void Event_Touch( idEntity *other, trace_t *trace );
- } ;
- /*
- ===============================================================================
- idAFEntity_Harvest
- ===============================================================================
- */
- class idAFEntity_Harvest : public idAFEntity_WithAttachedHead {
- public:
- CLASS_PROTOTYPE( idAFEntity_Harvest );
- idAFEntity_Harvest();
- ~idAFEntity_Harvest();
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- virtual void Think( void );
- virtual void Gib( const idVec3 &dir, const char *damageDefName );
- protected:
- idEntityPtr<idHarvestable> harvestEnt;
- protected:
- void Event_SpawnHarvestEntity( void );
- };
- #endif
- #endif /* !__GAME_AFENTITY_H__ */
|