diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/tf/tf_condition.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/shared/tf/tf_condition.h')
| -rw-r--r-- | game/shared/tf/tf_condition.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/game/shared/tf/tf_condition.h b/game/shared/tf/tf_condition.h new file mode 100644 index 0000000..d2e8804 --- /dev/null +++ b/game/shared/tf/tf_condition.h @@ -0,0 +1,111 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Condition Objects +// +//============================================================================= +#ifndef TF_CONDITION_H +#define TF_CONDITION_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "utlvector.h" +#include "utlstack.h" +#include "tf_shareddefs.h" + +#ifdef CLIENT_DLL + // Avoid redef warnings + #undef CTFPlayer + #define CTFPlayer C_TFPlayer + class C_TFPlayer; +#endif + +class CTFPlayer; +class CTFCondition; + +class CTFConditionList +{ +public: + DECLARE_EMBEDDED_NETWORKVAR(); + DECLARE_CLASS_NOBASE( CTFConditionList ); + DECLARE_PREDICTABLE(); + + CTFConditionList(); + + bool Add( ETFCond type, float duration, CTFPlayer* outer, CBaseEntity* provider = NULL ); + bool _Add( ETFCond type, float duration, CTFPlayer* outer, CBaseEntity* provider = NULL ); + bool Remove( ETFCond type, bool ignore_duration=false ); + bool _Remove( ETFCond type, bool ignore_duration=false ); + void RemoveAll(); + + bool InCond( ETFCond type ) const; + CBaseEntity *GetProvider( ETFCond type ) const; + + void Think(); + void ServerThink(); + +#ifdef CLIENT_DLL + // Forwarded from player shared. + virtual void OnPreDataChanged( void ); + virtual void OnDataChanged( CTFPlayer* outer ); + void UpdateClientConditions( CTFPlayer* outer ); +#endif + +private: + CUtlVector< CTFCondition* > _conditions; + + CNetworkVar( int, _condition_bits ); // Bitfield of set conditions for fast checking. + int _old_condition_bits; +}; + +class CTFCondition +{ +public: + CTFCondition( ETFCond type, float duration, CTFPlayer* outer, CBaseEntity* provider = NULL ); + virtual ~CTFCondition(); + + virtual void Add( float duration ); + + virtual void OnAdded() = 0; + virtual void OnRemoved() = 0; + virtual void OnThink() = 0; + virtual void OnServerThink() = 0; + + // Condition Traits + virtual bool IsHealable() { return false; } + virtual bool UsesMinDuration() { return false; } + + ETFCond GetType() { return _type; } + float GetMaxDuration() { return _max_duration; } + void SetMaxDuration( float val ) { _max_duration = val; } + float GetMinDuration() { return _min_duration; } + void SetMinDuration( float val ) { if ( UsesMinDuration() ) { _min_duration = val; } } + CTFPlayer* GetOuter() { return _outer; } + void SetProvider( CBaseEntity *provider ) { _provider = provider; } + CBaseEntity* GetProvider() { return _provider; } + +private: + float _min_duration; + float _max_duration; + const ETFCond _type; + CTFPlayer* _outer; + CHandle< CBaseEntity > _provider; +}; + +class CTFCondition_CritBoost : public CTFCondition +{ +public: + CTFCondition_CritBoost( ETFCond type, float duration, CTFPlayer* outer, CBaseEntity* provider = NULL ); + + virtual void OnAdded(); + virtual void OnRemoved(); + virtual void OnThink(); + virtual void OnServerThink(); + + // Condition Traits + virtual bool IsHealable() { return false; } + virtual bool UsesMinDuration() { return true; } +}; + +#endif |