mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-09-01 15:09:19 +00:00
upload "kind" alien swarm
This commit is contained in:
+8
-348
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@@ -198,64 +198,13 @@ public:
|
||||
|
||||
unsigned int operator()( const NavVisPair_t &item ) const
|
||||
{
|
||||
#if PLATFORM_64BITS
|
||||
COMPILE_TIME_ASSERT( sizeof(CNavArea *) == 8 );
|
||||
int64 key[2] = { (int64)(item.pAreas[0] + item.pAreas[1]->GetID()), (int64)(item.pAreas[1] + item.pAreas[0]->GetID()) };
|
||||
return Hash16( key );
|
||||
#else
|
||||
COMPILE_TIME_ASSERT( sizeof(CNavArea *) == 4 );
|
||||
int key[2] = { (int)(item.pAreas[0] + item.pAreas[1]->GetID()), (int)(item.pAreas[1] + item.pAreas[0]->GetID()) };
|
||||
return Hash8( key );
|
||||
#endif
|
||||
int key[2] = { (int)item.pAreas[0] + item.pAreas[1]->GetID(), (int)item.pAreas[1] + item.pAreas[0]->GetID() };
|
||||
return Hash8( key );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// The 'place directory' is used to save and load places from
|
||||
// nav files in a size-efficient manner that also allows for the
|
||||
// order of the place ID's to change without invalidating the
|
||||
// nav files.
|
||||
//
|
||||
// The place directory is stored in the nav file as a list of
|
||||
// place name strings. Each nav area then contains an index
|
||||
// into that directory, or zero if no place has been assigned to
|
||||
// that area.
|
||||
//
|
||||
class PlaceDirectory
|
||||
{
|
||||
public:
|
||||
typedef unsigned short IndexType; // Loaded/Saved as UnsignedShort. Change this and you'll have to version.
|
||||
|
||||
PlaceDirectory( void );
|
||||
void Reset( void );
|
||||
bool IsKnown( Place place ) const; /// return true if this place is already in the directory
|
||||
IndexType GetIndex( Place place ) const; /// return the directory index corresponding to this Place (0 = no entry)
|
||||
void AddPlace( Place place ); /// add the place to the directory if not already known
|
||||
Place IndexToPlace( IndexType entry ) const; /// given an index, return the Place
|
||||
void Save( CUtlBuffer &fileBuffer ); /// store the directory
|
||||
void Load( CUtlBuffer &fileBuffer, int version ); /// load the directory
|
||||
const CUtlVector< Place > *GetPlaces( void ) const
|
||||
{
|
||||
return &m_directory;
|
||||
}
|
||||
|
||||
bool HasUnnamedPlaces( void ) const
|
||||
{
|
||||
return m_hasUnnamedAreas;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
CUtlVector< Place > m_directory;
|
||||
bool m_hasUnnamedAreas;
|
||||
};
|
||||
|
||||
extern PlaceDirectory placeDirectory;
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The CNavMesh is the global interface to the Navigation Mesh.
|
||||
@@ -326,7 +275,7 @@ public:
|
||||
CNavArea *GetNavArea( const Vector &pos, float beneathLimt = 120.0f ) const; // given a position, return the nav area that IsOverlapping and is *immediately* beneath it
|
||||
CNavArea *GetNavArea( CBaseEntity *pEntity, int nGetNavAreaFlags, float flBeneathLimit = 120.0f ) const;
|
||||
CNavArea *GetNavAreaByID( unsigned int id ) const;
|
||||
CNavArea *GetNearestNavArea( const Vector &pos, bool anyZ = false, float maxDist = 10000.0f, bool checkLOS = false, bool checkGround = true, int team = TEAM_ANY ) const;
|
||||
CNavArea *GetNearestNavArea( const Vector &pos, bool anyZ = false, float maxDist = 10000.0f, bool checkLOS = false, bool checkGround = true ) const;
|
||||
CNavArea *GetNearestNavArea( CBaseEntity *pEntity, int nGetNavAreaFlags = GETNAVAREA_CHECK_GROUND, float maxDist = 10000.0f ) const;
|
||||
|
||||
Place GetPlace( const Vector &pos ) const; // return Place at given coordinate
|
||||
@@ -343,12 +292,9 @@ public:
|
||||
/// increase "danger" weights in the given nav area and nearby ones
|
||||
void IncreaseDangerNearby( int teamID, float amount, CNavArea *area, const Vector &pos, float maxRadius, float dangerLimit = -1.0f );
|
||||
void DrawDanger( void ) const; // draw the current danger levels
|
||||
|
||||
void DrawPlayerCounts( void ) const; // draw the current player counts for each area
|
||||
void DrawFuncNavAvoid( void ) const; // draw bot avoidance areas from func_nav_avoid entities
|
||||
void DrawFuncNavPrefer( void ) const; // draw bot preference areas from func_nav_prefer entities
|
||||
#ifdef NEXT_BOT
|
||||
void DrawFuncNavPrerequisite( void ) const; // draw bot prerequisite areas from func_nav_prerequisite entities
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Auto-generation
|
||||
//
|
||||
@@ -406,7 +352,6 @@ public:
|
||||
void CommandNavSelectDamagingAreas( void ); // adds damaging areas to the selected set
|
||||
void CommandNavSelectHalfSpace( const CCommand &args ); // selects all areas that intersect the half-space
|
||||
void CommandNavSelectStairs( void ); // adds stairs areas to the selected set
|
||||
void CommandNavSelectOrphans( void ); // adds areas not connected to mesh to the selected set
|
||||
|
||||
void CommandNavSplit( void ); // split current area
|
||||
void CommandNavMerge( void ); // merge adjacent areas
|
||||
@@ -421,7 +366,6 @@ public:
|
||||
|
||||
void CommandNavConnect( void ); // connect marked area to selected area
|
||||
void CommandNavDisconnect( void ); // disconnect marked area from selected area
|
||||
void CommandNavDisconnectOutgoingOneWays( void ); // disconnect all outgoing one-way connects from each area in the selected set
|
||||
void CommandNavSplice( void ); // create new area in between marked and selected areas
|
||||
void CommandNavCrouch( void ); // toggle crouch attribute on current area
|
||||
void CommandNavTogglePlaceMode( void ); // switch between normal and place editing
|
||||
@@ -561,6 +505,8 @@ public:
|
||||
template < typename Functor >
|
||||
bool ForAllAreasOverlappingExtent( Functor &func, const Extent &extent )
|
||||
{
|
||||
VPROF_BUDGET( "CNavMesh::ForAllAreasOverlappingExtent", "NextBot" );
|
||||
|
||||
if ( !m_grid.Count() )
|
||||
{
|
||||
#if _DEBUG
|
||||
@@ -619,68 +565,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Populate the given vector with all navigation areas that overlap the given extent.
|
||||
*/
|
||||
template< typename NavAreaType >
|
||||
void CollectAreasOverlappingExtent( const Extent &extent, CUtlVector< NavAreaType * > *outVector )
|
||||
{
|
||||
if ( !m_grid.Count() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static unsigned int searchMarker = RandomInt( 0, 1024*1024 );
|
||||
if ( ++searchMarker == 0 )
|
||||
{
|
||||
++searchMarker;
|
||||
}
|
||||
|
||||
Extent areaExtent;
|
||||
|
||||
// get list in cell that contains position
|
||||
int startX = WorldToGridX( extent.lo.x );
|
||||
int endX = WorldToGridX( extent.hi.x );
|
||||
int startY = WorldToGridY( extent.lo.y );
|
||||
int endY = WorldToGridY( extent.hi.y );
|
||||
|
||||
for( int x = startX; x <= endX; ++x )
|
||||
{
|
||||
for( int y = startY; y <= endY; ++y )
|
||||
{
|
||||
int iGrid = x + y*m_gridSizeX;
|
||||
if ( iGrid >= m_grid.Count() )
|
||||
{
|
||||
ExecuteNTimes( 10, Warning( "** Walked off of the CNavMesh::m_grid in CollectAreasOverlappingExtent()\n" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
NavAreaVector *areaVector = &m_grid[ iGrid ];
|
||||
|
||||
// find closest area in this cell
|
||||
for( int v=0; v<areaVector->Count(); ++v )
|
||||
{
|
||||
CNavArea *area = areaVector->Element( v );
|
||||
|
||||
// skip if we've already visited this area
|
||||
if ( area->m_nearNavSearchMarker == searchMarker )
|
||||
continue;
|
||||
|
||||
// mark as visited
|
||||
area->m_nearNavSearchMarker = searchMarker;
|
||||
area->GetExtent( &areaExtent );
|
||||
|
||||
if ( extent.IsOverlapping( areaExtent ) )
|
||||
{
|
||||
outVector->AddToTail( (NavAreaType *)area );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template < typename Functor >
|
||||
bool ForAllAreasInRadius( Functor &func, const Vector &pos, float radius )
|
||||
{
|
||||
@@ -742,227 +626,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* Step through nav mesh along line between startArea and endArea.
|
||||
* Return true if enumeration reached endArea, false if doesn't reach it (no mesh between, bad connection, etc)
|
||||
*/
|
||||
template < typename Functor >
|
||||
bool ForAllAreasAlongLine( Functor &func, CNavArea *startArea, CNavArea *endArea )
|
||||
{
|
||||
if ( !startArea || !endArea )
|
||||
return false;
|
||||
|
||||
if ( startArea == endArea )
|
||||
{
|
||||
func( startArea );
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector start = startArea->GetCenter();
|
||||
Vector end = endArea->GetCenter();
|
||||
|
||||
Vector to = end - start;
|
||||
float range = to.NormalizeInPlace();
|
||||
|
||||
const float epsilon = 0.00001f;
|
||||
|
||||
if ( range < epsilon )
|
||||
{
|
||||
func( startArea );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( abs( to.x ) < epsilon )
|
||||
{
|
||||
NavDirType dir = ( to.y < 0.0f ) ? NORTH : SOUTH;
|
||||
|
||||
CNavArea *area = startArea;
|
||||
while( area )
|
||||
{
|
||||
func( area );
|
||||
|
||||
if ( area == endArea )
|
||||
return true;
|
||||
|
||||
const NavConnectVector *adjVector = area->GetAdjacentAreas( dir );
|
||||
|
||||
area = NULL;
|
||||
|
||||
for( int i=0; i<adjVector->Count(); ++i )
|
||||
{
|
||||
CNavArea *adjArea = adjVector->Element(i).area;
|
||||
|
||||
const Vector &adjOrigin = adjArea->GetCorner( NORTH_WEST );
|
||||
|
||||
if ( adjOrigin.x <= start.x && adjOrigin.x + adjArea->GetSizeX() >= start.x )
|
||||
{
|
||||
area = adjArea;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if ( abs( to.y ) < epsilon )
|
||||
{
|
||||
NavDirType dir = ( to.x < 0.0f ) ? WEST : EAST;
|
||||
|
||||
CNavArea *area = startArea;
|
||||
while( area )
|
||||
{
|
||||
func( area );
|
||||
|
||||
if ( area == endArea )
|
||||
return true;
|
||||
|
||||
const NavConnectVector *adjVector = area->GetAdjacentAreas( dir );
|
||||
|
||||
area = NULL;
|
||||
|
||||
for( int i=0; i<adjVector->Count(); ++i )
|
||||
{
|
||||
CNavArea *adjArea = adjVector->Element(i).area;
|
||||
|
||||
const Vector &adjOrigin = adjArea->GetCorner( NORTH_WEST );
|
||||
|
||||
if ( adjOrigin.y <= start.y && adjOrigin.y + adjArea->GetSizeY() >= start.y )
|
||||
{
|
||||
area = adjArea;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CNavArea *area = startArea;
|
||||
|
||||
while( area )
|
||||
{
|
||||
func( area );
|
||||
|
||||
if ( area == endArea )
|
||||
return true;
|
||||
|
||||
const Vector &origin = area->GetCorner( NORTH_WEST );
|
||||
float xMin = origin.x;
|
||||
float xMax = xMin + area->GetSizeX();
|
||||
float yMin = origin.y;
|
||||
float yMax = yMin + area->GetSizeY();
|
||||
|
||||
// clip ray to area
|
||||
Vector exit;
|
||||
NavDirType edge = NUM_DIRECTIONS;
|
||||
|
||||
if ( to.x < 0.0f )
|
||||
{
|
||||
// find Y at west edge intersection
|
||||
float t = ( xMin - start.x ) / ( end.x - start.x );
|
||||
if ( t > 0.0f && t < 1.0f )
|
||||
{
|
||||
float y = start.y + t * ( end.y - start.y );
|
||||
if ( y >= yMin && y <= yMax )
|
||||
{
|
||||
// intersects this edge
|
||||
exit.x = xMin;
|
||||
exit.y = y;
|
||||
edge = WEST;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// find Y at east edge intersection
|
||||
float t = ( xMax - start.x ) / ( end.x - start.x );
|
||||
if ( t > 0.0f && t < 1.0f )
|
||||
{
|
||||
float y = start.y + t * ( end.y - start.y );
|
||||
if ( y >= yMin && y <= yMax )
|
||||
{
|
||||
// intersects this edge
|
||||
exit.x = xMax;
|
||||
exit.y = y;
|
||||
edge = EAST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( edge == NUM_DIRECTIONS )
|
||||
{
|
||||
if ( to.y < 0.0f )
|
||||
{
|
||||
// find X at north edge intersection
|
||||
float t = ( yMin - start.y ) / ( end.y - start.y );
|
||||
if ( t > 0.0f && t < 1.0f )
|
||||
{
|
||||
float x = start.x + t * ( end.x - start.x );
|
||||
if ( x >= xMin && x <= xMax )
|
||||
{
|
||||
// intersects this edge
|
||||
exit.x = x;
|
||||
exit.y = yMin;
|
||||
edge = NORTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// find X at south edge intersection
|
||||
float t = ( yMax - start.y ) / ( end.y - start.y );
|
||||
if ( t > 0.0f && t < 1.0f )
|
||||
{
|
||||
float x = start.x + t * ( end.x - start.x );
|
||||
if ( x >= xMin && x <= xMax )
|
||||
{
|
||||
// intersects this edge
|
||||
exit.x = x;
|
||||
exit.y = yMax;
|
||||
edge = SOUTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( edge == NUM_DIRECTIONS )
|
||||
break;
|
||||
|
||||
const NavConnectVector *adjVector = area->GetAdjacentAreas( edge );
|
||||
|
||||
area = NULL;
|
||||
|
||||
for( int i=0; i<adjVector->Count(); ++i )
|
||||
{
|
||||
CNavArea *adjArea = adjVector->Element(i).area;
|
||||
|
||||
const Vector &adjOrigin = adjArea->GetCorner( NORTH_WEST );
|
||||
|
||||
if ( edge == NORTH || edge == SOUTH )
|
||||
{
|
||||
if ( adjOrigin.x <= exit.x && adjOrigin.x + adjArea->GetSizeX() >= exit.x )
|
||||
{
|
||||
area = adjArea;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( adjOrigin.y <= exit.y && adjOrigin.y + adjArea->GetSizeY() >= exit.y )
|
||||
{
|
||||
area = adjArea;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Apply the functor to all navigation ladders.
|
||||
@@ -1254,9 +917,6 @@ private:
|
||||
|
||||
void BeginVisibilityComputations( void );
|
||||
void EndVisibilityComputations( void );
|
||||
|
||||
void TestAllAreasForBlockedStatus( void ); // Used to update blocked areas after a round restart. Need to delay so the map logic has all fired.
|
||||
CountdownTimer m_updateBlockedAreasTimer;
|
||||
};
|
||||
|
||||
// the global singleton interface
|
||||
|
||||
Reference in New Issue
Block a user