示例#1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : 
// Output : const Vector
//-----------------------------------------------------------------------------
const Vector CBasePlayer::GetPlayerMins( void ) const
{
	if ( IsObserver() )
	{
		return VEC_OBS_HULL_MIN_SCALED( this );	
	}
	else
	{
		if ( GetFlags() & FL_DUCKING )
		{
			return VEC_DUCK_HULL_MIN_SCALED( this );
		}
		else
		{
			return VEC_HULL_MIN_SCALED( this );
		}
	}
}
		UpgradeStationInfo(CUpgrades *station, CTFBot *actor, CNavArea *start_area, CTFBotPathCost& cost_func) :
			station(station)
		{
			Extent extent;
			extent.Init(station);
			
			CUtlVector<CTFNavArea *> overlapping;
			TheNavMesh->CollectAreasOverlappingExtent(extent, &overlapping);
			
			FOR_EACH_VEC(overlapping, i) {
				auto area = overlapping[i];
				
				Extent ext_nav;
				area->GetExtent(&ext_nav);
				
				constexpr float bloat = 0.0f;
				Vector bloat_mins(-bloat, -bloat, -bloat);
				Vector bloat_maxs( bloat,  bloat,  bloat);
				
				Extent ext_vol = ext_nav;
				ext_vol.lo += (VEC_HULL_MIN_SCALED(actor) + bloat_mins);
				ext_vol.hi += (VEC_HULL_MAX_SCALED(actor) + bloat_maxs);
				
				Vector center = (ext_vol.hi + ext_vol.lo) * 0.5f;
				
				Vector mins = -(ext_vol.hi - center);
				Vector maxs =  (ext_vol.hi - center);
				
				Ray_t ray;
				ray.Init(center, center, mins, maxs);
				
				trace_t tr;
				enginetrace->ClipRayToEntity(ray, CONTENTS_SOLID, reinterpret_cast<IHandleEntity *>(station), &tr);
				
				if ((tr.contents & CONTENTS_SOLID) == 0) continue;
				
				constexpr float unit_size = 25.0f;
				
				int units_x = (int)(ext_nav.SizeX() / unit_size);
				int units_y = (int)(ext_nav.SizeY() / unit_size);
				
				std::vector<Vector> spots_edges;
				std::vector<Vector> spots_middle;
				
				for (int i = 0; i <= units_x; ++i) {
					for (int j = 0; j <= units_y; ++j) {
						float x = i * (ext_nav.SizeX() / units_x);
						float y = j * (ext_nav.SizeY() / units_y);
						
						// TODO: use area->GetZ for this part
						float z = ext_nav.lo.z;
						
						if (i == 0 || j == 0 || i == units_x || j == units_y) {
							spots_edges.emplace_back(ext_nav.lo.x + x, ext_nav.lo.y + y, z);
						} else {
							spots_middle.emplace_back(ext_nav.lo.x + x, ext_nav.lo.y + y, z);
						}
					}
				}
				
				std::random_shuffle(spots_edges.begin(),  spots_edges.end());
				std::random_shuffle(spots_middle.begin(), spots_middle.end());
				
#if 0
				int idx = 0;
				for (const auto& spot : spots_edges) {
					bool would_touch = WouldPlayerAtLocationTouchTrigger(spot, actor, station);
					NDebugOverlay::Box(spot, Vector(-1.0f, -1.0f, -1.0f), Vector(1.0f, 1.0f, 1.0f),
						(would_touch ? 0x00 : 0xff),
						(would_touch ? 0xff : 0x00),
						0x00, 0xff, 60.0f);
					++idx;
				}
				
				idx = 0;
				for (const auto& spot : spots_middle) {
					bool would_touch = WouldPlayerAtLocationTouchTrigger(spot, actor, station);
					NDebugOverlay::Box(spot, Vector(-1.0f, -1.0f, -1.0f), Vector(1.0f, 1.0f, 1.0f),
						(would_touch ? 0x00 : 0xff),
						(would_touch ? 0xff : 0x00),
						0x00, 0xff, 60.0f);
					++idx;
				}
#endif
				
				bool found_spot = false;
				
				for (const auto& spot : spots_edges) {
					if (found_spot) break;
					
					if (WouldPlayerAtLocationTouchTrigger(spot, actor, station)) {
					//	NDebugOverlay::Box(spot, Vector(-2.0f, -2.0f, -2.0f), Vector(2.0f, 2.0f, 2.0f), 0x00, 0xff, 0x00, 0xff, 3600.0f);
						this->spots.emplace_back(area, spot);
						found_spot = true;
					}
				}
				
				for (const auto& spot : spots_middle) {
					if (found_spot) break;
					
					if (WouldPlayerAtLocationTouchTrigger(spot, actor, station)) {
					//	NDebugOverlay::Box(spot, Vector(-2.0f, -2.0f, -2.0f), Vector(2.0f, 2.0f, 2.0f), 0xff, 0x00, 0x00, 0xff, 3600.0f);
						this->spots.emplace_back(area, spot);
						found_spot = true;
					}
				}
				
				if (found_spot) {
					NDebugOverlay::Box(ext_nav.lo, vec3_origin, (ext_nav.hi - ext_nav.lo), 0xff, 0xff, 0xff, 0x80, 60.0f);
				}
			}