CPlayerAbilities.h
No notes
Syntax:
C++
#ifndef CPLAYERABILITIES_H #define CPLAYERABILITIES_H enum abilities_t { NONE = 1, FAST_SHOOT, SPEED_ENHANCEMENT, REGENERATION, ENVIRONMENTAL_RESISTANCE }; enum sound_t { ABILITY_ON, ABILITY_OFF, NO_TIME_LEFT }; const float MAX_ABILITY_DURATION = 30.0f; class CBasePlayer; class CPlayerAbilities { public: CPlayerAbilities(); void Think( void ); void SetPlayer( CBasePlayer* pPlayer ) { if( pPlayer ) m_pPlayer = pPlayer; } bool EnableAbility( abilities_t ability ); bool DisableAbility( void ); bool HasEnabledAbility( abilities_t ability ) const { return ( m_activatedAbility == ability ); } bool HasEnabledAbility( void ) const { return ( m_activatedAbility > NONE ); } bool HasAbilityTimeLeft( void ) const { return ( m_flAbilityTimeLeft > 0.0f ); } void PlaySound( sound_t sound ) const; //void RechargeAbilityTime( float flTime ); private: void Precache( void ); CBasePlayer* m_pPlayer; abilities_t m_activatedAbility; float m_flActivationTimeStart; float m_flAbilityTimeLeft; }; #endif