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/server/NextBot/NavMeshEntities | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/NextBot/NavMeshEntities')
| -rw-r--r-- | game/server/NextBot/NavMeshEntities/func_nav_prerequisite.cpp | 75 | ||||
| -rw-r--r-- | game/server/NextBot/NavMeshEntities/func_nav_prerequisite.h | 56 |
2 files changed, 131 insertions, 0 deletions
diff --git a/game/server/NextBot/NavMeshEntities/func_nav_prerequisite.cpp b/game/server/NextBot/NavMeshEntities/func_nav_prerequisite.cpp new file mode 100644 index 0000000..5ac954a --- /dev/null +++ b/game/server/NextBot/NavMeshEntities/func_nav_prerequisite.cpp @@ -0,0 +1,75 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// NextBot paths that go through this entity must fulfill the given prerequisites to pass +// Michael Booth, August 2009 + +#include "cbase.h" +#include "func_nav_prerequisite.h" +#include "ndebugoverlay.h" +#include "modelentities.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + +LINK_ENTITY_TO_CLASS( func_nav_prerequisite, CFuncNavPrerequisite ); + +BEGIN_DATADESC( CFuncNavPrerequisite ) + DEFINE_KEYFIELD( m_task, FIELD_INTEGER, "Task" ), + DEFINE_KEYFIELD( m_taskEntityName, FIELD_STRING, "Entity" ), + DEFINE_KEYFIELD( m_taskValue, FIELD_FLOAT, "Value" ), + DEFINE_KEYFIELD( m_isDisabled, FIELD_BOOLEAN, "StartDisabled" ), + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +END_DATADESC() + +IMPLEMENT_AUTO_LIST( IFuncNavPrerequisiteAutoList ); + + +//----------------------------------------------------------------------------- +CFuncNavPrerequisite::CFuncNavPrerequisite() +{ + m_task = TASK_NONE; + m_hTaskEntity = NULL; +} + + +//----------------------------------------------------------------------------- +void CFuncNavPrerequisite::Spawn( void ) +{ + AddSpawnFlags( SF_TRIGGER_ALLOW_CLIENTS ); + + BaseClass::Spawn(); + InitTrigger(); +} + + +//----------------------------------------------------------------------------- +bool CFuncNavPrerequisite::IsTask( TaskType task ) const +{ + return task == m_task ? true : false; +} + + +//----------------------------------------------------------------------------- +CBaseEntity *CFuncNavPrerequisite::GetTaskEntity( void ) +{ + if ( m_hTaskEntity == NULL ) + { + m_hTaskEntity = gEntList.FindEntityByName( NULL, m_taskEntityName ); + } + return m_hTaskEntity; +} + + +//-------------------------------------------------------------------------------------------------------- +void CFuncNavPrerequisite::InputEnable( inputdata_t &inputdata ) +{ + m_isDisabled = false; +} + + +//-------------------------------------------------------------------------------------------------------- +void CFuncNavPrerequisite::InputDisable( inputdata_t &inputdata ) +{ + m_isDisabled = true; +} diff --git a/game/server/NextBot/NavMeshEntities/func_nav_prerequisite.h b/game/server/NextBot/NavMeshEntities/func_nav_prerequisite.h new file mode 100644 index 0000000..bcc23f6 --- /dev/null +++ b/game/server/NextBot/NavMeshEntities/func_nav_prerequisite.h @@ -0,0 +1,56 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// NextBot paths that go through this entity must fulfill the given prerequisites to pass +// Michael Booth, August 2009 + +#ifndef FUNC_NAV_PREREQUISITE_H +#define FUNC_NAV_PREREQUISITE_H + +#include "triggers.h" + +/** + * NextBot paths that pass through this entity must fulfill the given prerequisites to pass + */ +DECLARE_AUTO_LIST( IFuncNavPrerequisiteAutoList ); + +class CFuncNavPrerequisite : public CBaseTrigger, public IFuncNavPrerequisiteAutoList +{ + DECLARE_CLASS( CFuncNavPrerequisite, CBaseTrigger ); + +public: + CFuncNavPrerequisite(); + + DECLARE_DATADESC(); + + virtual void Spawn( void ); + + enum TaskType + { + TASK_NONE = 0, + TASK_DESTROY_ENTITY = 1, + TASK_MOVE_TO_ENTITY = 2, + TASK_WAIT = 3, + }; + + bool IsTask( TaskType type ) const; + CBaseEntity *GetTaskEntity( void ); + float GetTaskValue( void ) const; + + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + bool IsEnabled( void ) const { return !m_isDisabled; } + +protected: + int m_task; + string_t m_taskEntityName; + float m_taskValue; + bool m_isDisabled; + EHANDLE m_hTaskEntity; +}; + +inline float CFuncNavPrerequisite::GetTaskValue( void ) const +{ + return m_taskValue; +} + + +#endif // FUNC_NAV_PREREQUISITE_H |