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_quest_restriction.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_quest_restriction.h')
| -rw-r--r-- | game/shared/tf/tf_quest_restriction.h | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/game/shared/tf/tf_quest_restriction.h b/game/shared/tf/tf_quest_restriction.h new file mode 100644 index 0000000..51609e8 --- /dev/null +++ b/game/shared/tf/tf_quest_restriction.h @@ -0,0 +1,164 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef TF_QUEST_RESTRICTION_H +#define TF_QUEST_RESTRICTION_H +#ifdef _WIN32 +#pragma once +#endif + +#include "tf_shareddefs.h" + +#ifdef CLIENT_DLL +#define CTFPlayer C_TFPlayer +#endif // CLIENT_DLL + +class CTFQuestEvaluator; +class CTFPlayer; + +enum EInvalidReasons_t +{ + INVALID_QUEST_REASON_WRONG_MAP = 0, + INVALID_QUEST_REASON_WRONG_CLASS, + INVALID_QUEST_REASON_WRONG_GAME_MODE, + INVALID_QUEST_REASON_NOT_ENOUGH_PLAYERS, + INVALID_QUEST_REASON_VALVE_SERVERS_ONLY, + INVALID_QUEST_REASON_NO_MVM, + + NUM_INVALID_REASONS, +}; + +struct InvalidReason +{ + InvalidReason() {} + + bool IsValid() const + { + return m_bits.IsAllClear(); + } + + CBitVec< NUM_INVALID_REASONS > m_bits; +}; + +typedef InvalidReason InvalidReasonsContainer_t; + +void GetInvalidReasonsNames( const InvalidReasonsContainer_t&, CUtlVector< CUtlString >& vecStrings ); + +//----------------------------------------------------------------------------- +// Purpose: base quest condition +//----------------------------------------------------------------------------- +class CTFQuestCondition +{ +public: + DECLARE_CLASS_NOBASE( CTFQuestCondition ) + + CTFQuestCondition(); + virtual ~CTFQuestCondition(); + + virtual const char *GetBaseName() const = 0; + virtual const char *GetConditionName() const { return m_pszTypeName; } + virtual const char *GetValueString() const { return ""; } + virtual bool BInitFromKV( KeyValues *pKVItem, CUtlVector<CUtlString> *pVecErrors /* = NULL */ ); + + virtual void PrintDebugText() const; + + virtual const CTFPlayer *GetQuestOwner() const; + virtual bool IsValidForPlayer( const CTFPlayer *pOwner, InvalidReasonsContainer_t& invalidReasons ) const; + + virtual bool IsOperator() const { return false; } + virtual bool IsEvaluator() const { return false; } + + void SetParent( CTFQuestCondition *pParent ) { m_pParent = pParent; } + CTFQuestCondition *GetParent() const { return m_pParent; } + + virtual CTFQuestCondition* AddChildByName( const char *pszChildName ) { Assert( 0 ); return NULL; } + + virtual int GetChildren( CUtlVector< CTFQuestCondition* >& vecChildren ) { return 0; } + virtual bool RemoveAndDeleteChild( CTFQuestCondition *pChild ) { return false; } + + virtual void GetRequiredParamKeys( KeyValues *pRequiredKeys ) {} + virtual void GetOutputKeyValues( KeyValues *pOutputKeys ) {} + + virtual void GetValidTypes( CUtlVector< const char* >& vecOutValidChildren ) const = 0; + virtual void GetValidChildren( CUtlVector< const char* >& vecOutValidChildren ) const = 0; + + virtual int GetMaxInputCount() const { return 0; } + + virtual const char* GetEventName() const { Assert( 0 ); return NULL; } + virtual void SetEventName( const char *pszEventName ) { Assert( 0 ); } + + void SetFieldName( const char* pszFieldName ) { m_pszFieldName = pszFieldName; } + void SetTypeName( const char* pszTypeName ) { m_pszTypeName = pszTypeName; } + +protected: + + void GetValidRestrictions( CUtlVector< const char* >& vecOutValidChildren ) const; + void GetValidEvaluators( CUtlVector< const char* >& vecOutValidChildren ) const; + + const char *m_pszFieldName; + const char *m_pszTypeName; + +private: + + CTFQuestCondition *m_pParent; +}; + + +//----------------------------------------------------------------------------- +// Purpose: base quest restriction +//----------------------------------------------------------------------------- +class CTFQuestRestriction : public CTFQuestCondition +{ +public: + DECLARE_CLASS( CTFQuestRestriction, CTFQuestCondition ) + + virtual const char *GetBaseName() const OVERRIDE { return "restriction"; } + virtual bool PassesRestrictions( IGameEvent *pEvent ) const = 0; + void SetEventName( const char *pszEventName ) OVERRIDE { m_pszEventName = pszEventName; } + virtual const char* GetEventName() const OVERRIDE { return m_pszEventName; } + + virtual void GetValidTypes( CUtlVector< const char* >& vecOutValidChildren ) const OVERRIDE; + virtual void GetValidChildren( CUtlVector< const char* >& vecOutValidChildren ) const OVERRIDE; + +protected: + + const char *m_pszEventName; +}; + + +//----------------------------------------------------------------------------- +// Purpose: base quest evaluator +//----------------------------------------------------------------------------- +class CTFQuestEvaluator : public CTFQuestCondition +{ +public: + CTFQuestEvaluator(); + + virtual const char *GetBaseName() const OVERRIDE { return "evaluator"; } + + virtual bool IsEvaluator() const OVERRIDE { return true; } + + virtual void EvaluateCondition( CTFQuestEvaluator *pSender, int nScore ) = 0; + virtual void ResetCondition() = 0; + + virtual void GetRequiredParamKeys( KeyValues *pRequiredKeys ) OVERRIDE; + virtual void GetOutputKeyValues( KeyValues *pOutputKeys ) OVERRIDE; + + virtual void GetValidTypes( CUtlVector< const char* >& vecOutValidChildren ) const OVERRIDE; + virtual void GetValidChildren( CUtlVector< const char* >& vecOutValidChildren ) const OVERRIDE; + + void SetAction( const char *pszAction ) { m_pszAction = pszAction; } + const char *GetAction() const { return m_pszAction; } + +private: + const char *m_pszAction; +}; + +CTFQuestRestriction *CreateRestrictionByName( const char *pszName, CTFQuestCondition* pParent ); +CTFQuestEvaluator *CreateEvaluatorByName( const char *pszName, CTFQuestCondition*); + +#endif // TF_QUEST_RESTRICTION_H |