123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- /*
- ===========================================================================
- 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_TRIGGER_H__
- #define __GAME_TRIGGER_H__
- extern const idEventDef EV_Enable;
- extern const idEventDef EV_Disable;
- /*
- ===============================================================================
- Trigger base.
- ===============================================================================
- */
- class idTrigger : public idEntity {
- public:
- CLASS_PROTOTYPE( idTrigger );
- static void DrawDebugInfo( void );
- idTrigger();
- void Spawn( void );
- const function_t * GetScriptFunction( void ) const;
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- virtual void Enable( void );
- virtual void Disable( void );
- protected:
- void CallScript( void ) const;
- void Event_Enable( void );
- void Event_Disable( void );
- const function_t * scriptFunction;
- };
- /*
- ===============================================================================
- Trigger which can be activated multiple times.
- ===============================================================================
- */
- class idTrigger_Multi : public idTrigger {
- public:
- CLASS_PROTOTYPE( idTrigger_Multi );
- idTrigger_Multi( void );
- void Spawn( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- private:
- float wait;
- float random;
- float delay;
- float random_delay;
- int nextTriggerTime;
- idStr requires;
- int removeItem;
- bool touchClient;
- bool touchOther;
- bool triggerFirst;
- bool triggerWithSelf;
- bool CheckFacing( idEntity *activator );
- void TriggerAction( idEntity *activator );
- void Event_TriggerAction( idEntity *activator );
- void Event_Trigger( idEntity *activator );
- void Event_Touch( idEntity *other, trace_t *trace );
- };
- /*
- ===============================================================================
- Trigger which can only be activated by an entity with a specific name.
- ===============================================================================
- */
- class idTrigger_EntityName : public idTrigger {
- public:
- CLASS_PROTOTYPE( idTrigger_EntityName );
- idTrigger_EntityName( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void Spawn( void );
- private:
- float wait;
- float random;
- float delay;
- float random_delay;
- int nextTriggerTime;
- bool triggerFirst;
- idStr entityName;
- void TriggerAction( idEntity *activator );
- void Event_TriggerAction( idEntity *activator );
- void Event_Trigger( idEntity *activator );
- void Event_Touch( idEntity *other, trace_t *trace );
- };
- /*
- ===============================================================================
- Trigger which repeatedly fires targets.
- ===============================================================================
- */
- class idTrigger_Timer : public idTrigger {
- public:
- CLASS_PROTOTYPE( idTrigger_Timer );
- idTrigger_Timer( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void Spawn( void );
- virtual void Enable( void );
- virtual void Disable( void );
- private:
- float random;
- float wait;
- bool on;
- float delay;
- idStr onName;
- idStr offName;
- void Event_Timer( void );
- void Event_Use( idEntity *activator );
- };
- /*
- ===============================================================================
- Trigger which fires targets after being activated a specific number of times.
- ===============================================================================
- */
- class idTrigger_Count : public idTrigger {
- public:
- CLASS_PROTOTYPE( idTrigger_Count );
- idTrigger_Count( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void Spawn( void );
- private:
- int goal;
- int count;
- float delay;
- void Event_Trigger( idEntity *activator );
- void Event_TriggerAction( idEntity *activator );
- };
- /*
- ===============================================================================
- Trigger which hurts touching entities.
- ===============================================================================
- */
- class idTrigger_Hurt : public idTrigger {
- public:
- CLASS_PROTOTYPE( idTrigger_Hurt );
- idTrigger_Hurt( void );
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
- void Spawn( void );
- private:
- bool on;
- float delay;
- int nextTime;
- void Event_Touch( idEntity *other, trace_t *trace );
- void Event_Toggle( idEntity *activator );
- };
- /*
- ===============================================================================
- Trigger which fades the player view.
- ===============================================================================
- */
- class idTrigger_Fade : public idTrigger {
- public:
- CLASS_PROTOTYPE( idTrigger_Fade );
- private:
- void Event_Trigger( idEntity *activator );
- };
- /*
- ===============================================================================
- Trigger which continuously tests whether other entities are touching it.
- ===============================================================================
- */
- class idTrigger_Touch : public idTrigger {
- public:
- CLASS_PROTOTYPE( idTrigger_Touch );
- idTrigger_Touch( void );
- void Spawn( void );
- virtual void Think( void );
- void Save( idSaveGame *savefile );
- void Restore( idRestoreGame *savefile );
- virtual void Enable( void );
- virtual void Disable( void );
- void TouchEntities( void );
- private:
- idClipModel * clipModel;
- void Event_Trigger( idEntity *activator );
- };
- #endif /* !__GAME_TRIGGER_H__ */
|