aboutsummaryrefslogtreecommitdiff
path: root/sp/src/game/server/nav_entities.h
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /sp/src/game/server/nav_entities.h
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'sp/src/game/server/nav_entities.h')
-rw-r--r--sp/src/game/server/nav_entities.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/sp/src/game/server/nav_entities.h b/sp/src/game/server/nav_entities.h
new file mode 100644
index 00000000..2caba4cf
--- /dev/null
+++ b/sp/src/game/server/nav_entities.h
@@ -0,0 +1,130 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// nav_entities.h
+// Navigation entities
+// Author: Michael S. Booth ([email protected]), January 2003
+
+#ifndef NAV_ENTITIES_H
+#define NAV_ENTITIES_H
+
+//-----------------------------------------------------------------------------------------------------
+/**
+ * An entity that modifies pathfinding cost to all areas it overlaps, to allow map designers
+ * to tell bots to avoid/prefer certain regions.
+ */
+class CFuncNavCost : public CBaseEntity
+{
+public:
+ DECLARE_DATADESC();
+ DECLARE_CLASS( CFuncNavCost, CBaseEntity );
+
+ virtual void Spawn( void );
+ virtual void UpdateOnRemove( void );
+
+ void InputEnable( inputdata_t &inputdata );
+ void InputDisable( inputdata_t &inputdata );
+
+ bool IsEnabled( void ) const { return !m_isDisabled; }
+
+ void CostThink( void );
+
+ bool IsApplicableTo( CBaseCombatCharacter *who ) const; // Return true if this cost applies to the given actor
+
+ virtual float GetCostMultiplier( CBaseCombatCharacter *who ) const { return 1.0f; }
+
+protected:
+ int m_team;
+ bool m_isDisabled;
+ string_t m_iszTags;
+
+ static CUtlVector< CHandle< CFuncNavCost > > gm_masterCostVector;
+ static CountdownTimer gm_dirtyTimer;
+ void UpdateAllNavCostDecoration( void );
+
+ CUtlVector< CFmtStr > m_tags;
+ bool HasTag( const char *groupname ) const;
+};
+
+
+//-----------------------------------------------------------------------------------------------------
+class CFuncNavAvoid : public CFuncNavCost
+{
+public:
+ DECLARE_CLASS( CFuncNavAvoid, CFuncNavCost );
+
+ virtual float GetCostMultiplier( CBaseCombatCharacter *who ) const; // return pathfind cost multiplier for the given actor
+};
+
+
+//-----------------------------------------------------------------------------------------------------
+class CFuncNavPrefer : public CFuncNavCost
+{
+public:
+ DECLARE_CLASS( CFuncNavPrefer, CFuncNavCost );
+
+ virtual float GetCostMultiplier( CBaseCombatCharacter *who ) const; // return pathfind cost multiplier for the given actor
+};
+
+
+//-----------------------------------------------------------------------------------------------------
+/**
+ * An entity that can block/unblock nav areas. This is meant for semi-transient areas that block
+ * pathfinding but can be ignored for longer-term queries like computing L4D flow distances and
+ * escape routes.
+ */
+class CFuncNavBlocker : public CBaseEntity
+{
+ DECLARE_DATADESC();
+ DECLARE_CLASS( CFuncNavBlocker, CBaseEntity );
+
+public:
+ void Spawn();
+ virtual void UpdateOnRemove( void );
+
+ void InputBlockNav( inputdata_t &inputdata );
+ void InputUnblockNav( inputdata_t &inputdata );
+
+ inline bool IsBlockingNav( int teamNumber ) const
+ {
+ if ( teamNumber == TEAM_ANY )
+ {
+ bool isBlocked = false;
+ for ( int i=0; i<MAX_NAV_TEAMS; ++i )
+ {
+ isBlocked |= m_isBlockingNav[ i ];
+ }
+
+ return isBlocked;
+ }
+
+ teamNumber = teamNumber % MAX_NAV_TEAMS;
+ return m_isBlockingNav[ teamNumber ];
+ }
+
+ int DrawDebugTextOverlays( void );
+
+ bool operator()( CNavArea *area ); // functor that blocks areas in our extent
+
+ static bool CalculateBlocked( bool *pResultByTeam, const Vector &vecMins, const Vector &vecMaxs );
+
+private:
+
+ void UpdateBlocked();
+
+ static CUtlLinkedList<CFuncNavBlocker *> gm_NavBlockers;
+
+ void BlockNav( void );
+ void UnblockNav( void );
+ bool m_isBlockingNav[MAX_NAV_TEAMS];
+ int m_blockedTeamNumber;
+ bool m_bDisabled;
+ Vector m_CachedMins, m_CachedMaxs;
+
+};
+
+#endif // NAV_ENTITIES_H