本文整理汇总了C++中ratl::vector_vs类的典型用法代码示例。如果您正苦于以下问题:C++ vector_vs类的具体用法?C++ vector_vs怎么用?C++ vector_vs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector_vs类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
////////////////////////////////////////////////////////////////////////////////////
// Initialize
//
// This function scans through the list of tracks and hooks itself up with the
// track (and possibly lane)
////////////////////////////////////////////////////////////////////////////////////
void Initialize()
{
mTrack = 0;
mLane = 0;
mCols = 0;
mRows = 0;
hstring target = mEnt->target;
for (int track=0; track<mRailTracks.size(); track++)
{
if (mRailTracks[track].mName==target)
{
mTrack = &(mRailTracks[track]);
break;
}
}
if (mTrack==0)
{
for (int lane=0; lane<mRailLanes.size(); lane++)
{
if (mRailLanes[lane].mName==target)
{
mLane = &(mRailLanes[lane]);
mTrack = mLane->mTrack;
break;
}
}
}
assert(mTrack!=0);
if (mTrack)
{
mTrack->mMovers.push_back(this);
mCols = (int)((mEnt->maxs[mTrack->mWAxis] - mEnt->mins[mTrack->mWAxis]) / mTrack->mGridCellSize) + 1;
mRows = (int)((mEnt->maxs[mTrack->mHAxis] - mEnt->mins[mTrack->mHAxis]) / mTrack->mGridCellSize) + 1;
// Make Sure The Mover Fits In The Track And Lane
//------------------------------------------------
if (mRows>mTrack->mRows)
{
// assert(0);
mRows = mTrack->mRows;
}
if (mCols>mTrack->mCols)
{
// assert(0);
mCols = mTrack->mCols;
}
if (mLane && mCols>(mLane->mMaxCol - mLane->mMinCol + 1))
{
// assert(0);
mCols = (mLane->mMaxCol - mLane->mMinCol + 1);
}
}
}
示例2: Distance
////////////////////////////////////////////////////////////////////////////////////////
// Vehicle_Find
//
// Will look through all registered vehicles and choose the closest one that the given
// entity can get to.
//
////////////////////////////////////////////////////////////////////////////////////////
gentity_t* Vehicle_Find(gentity_t *ent)
{
gentity_t* closest = 0;
float closestDist = 0;
float curDist = 0;
for (int i=0; i<mRegistered.size(); i++)
{
if (!mRegistered[i]->owner)
{
curDist = Distance(mRegistered[i]->currentOrigin, ent->currentOrigin);
if (curDist<1000 && (!closest || curDist<closestDist))
{
if (NAV::InSameRegion(ent, mRegistered[i]))
{
closest = mRegistered[i];
closestDist = curDist;
}
}
}
}
return closest;
}
示例3: SP_rail_lane
void SP_rail_lane(gentity_t *ent)
{
gi.SetBrushModel(ent, ent->model);
G_SpawnInt("delay", "0", &ent->delay);
mRailLanes.push_back().Setup(ent);
G_FreeEntity(ent);
}
示例4: SP_rail_track
void SP_rail_track(gentity_t *ent)
{
gi.SetBrushModel(ent, ent->model);
G_SpawnInt("delay", "0", &ent->delay);
mRailTracks.push_back().Setup(ent);
G_FreeEntity(ent);
mRailSystemActive = true;
}
示例5:
void Pilot_Update(void)
{
mActivePilotCount = 0;
mRegistered.clear();
for (int i=0; i<ENTITYNUM_WORLD; i++)
{
if (g_entities[i].inuse &&
g_entities[i].client &&
g_entities[i].NPC &&
g_entities[i].NPC->greetEnt &&
g_entities[i].NPC->greetEnt->owner==(&g_entities[i])
)
{
mActivePilotCount++;
}
if ( g_entities[i].inuse &&
g_entities[i].client &&
g_entities[i].m_pVehicle &&
!g_entities[i].owner &&
g_entities[i].health>0 &&
g_entities[i].m_pVehicle->m_pVehicleInfo->type==VH_SPEEDER &&
!mRegistered.full())
{
mRegistered.push_back(&g_entities[i]);
}
}
if (player &&
player->inuse &&
TIMER_Done(player, "FlybySoundArchitectureDebounce"))
{
TIMER_Set(player, "FlybySoundArchitectureDebounce", 300);
Vehicle_t* pVeh = G_IsRidingVehicle(player);
if (pVeh &&
(pVeh->m_pVehicleInfo->soundFlyBy || pVeh->m_pVehicleInfo->soundFlyBy2) &&
//fabsf(pVeh->m_pParentEntity->currentAngles[2])<15.0f &&
VectorLength(pVeh->m_pParentEntity->client->ps.velocity)>500.0f)
{
vec3_t projectedPosition;
vec3_t projectedDirection;
vec3_t projectedRight;
vec3_t anglesNoRoll;
VectorCopy(pVeh->m_pParentEntity->currentAngles, anglesNoRoll);
anglesNoRoll[2] = 0;
AngleVectors(anglesNoRoll, projectedDirection, projectedRight, 0);
VectorMA(player->currentOrigin, 1.2f, pVeh->m_pParentEntity->client->ps.velocity, projectedPosition);
VectorMA(projectedPosition, Q_flrand(-200.0f, 200.0f), projectedRight, projectedPosition);
gi.trace(&mPilotViewTrace,
player->currentOrigin,
0,
0,
projectedPosition,
player->s.number,
MASK_SHOT, G2_NOCOLLIDE, 0);
if ((mPilotViewTrace.allsolid==qfalse) &&
(mPilotViewTrace.startsolid==qfalse) &&
(mPilotViewTrace.fraction<0.99f) &&
(mPilotViewTrace.plane.normal[2]<0.5f) &&
(DotProduct(projectedDirection, mPilotViewTrace.plane.normal)<-0.5f)
)
{
// CG_DrawEdge(player->currentOrigin, mPilotViewTrace.endpos, EDGE_IMPACT_POSSIBLE);
TIMER_Set(player, "FlybySoundArchitectureDebounce", Q_irand(1000, 2000));
int soundFlyBy = pVeh->m_pVehicleInfo->soundFlyBy;
if (pVeh->m_pVehicleInfo->soundFlyBy2 && (!soundFlyBy || !Q_irand(0,1)))
{
soundFlyBy = pVeh->m_pVehicleInfo->soundFlyBy2;
}
G_SoundAtSpot(mPilotViewTrace.endpos, soundFlyBy, qtrue);
}
else
{
// CG_DrawEdge(player->currentOrigin, mPilotViewTrace.endpos, EDGE_IMPACT_SAFE);
}
}
}
}
示例6: if
void Rail_Update()
{
if (mRailSystemActive)// && false)
{
for (int track=0; track<mRailTracks.size(); track++)
{
if (level.time>mRailTracks[track].mNextUpdateTime && !mRailTracks[track].mMovers.empty())
{
mRailTracks[track].Update();
}
}
// Is The Player Outside?
//------------------------
if (player && gi.WE_IsOutside(player->currentOrigin))
{
int wooshSound;
vec3_t wooshSoundPos;
vec3_t moverOrigin;
vec3_t playerToMover;
float playerToMoverDistance;
float playerToMoverDistanceFraction;
// Iterate Over All The Movers
//-----------------------------
for (int moverIndex=0; moverIndex<mRailMovers.size(); moverIndex++)
{
CRailMover& mover = mRailMovers[moverIndex];
// Is It Active, And Has The Sound Already Played On It?
//--------------------------------------------------------
if (mover.Active() && !mover.mSoundPlayed)
{
VectorAdd(mover.mEnt->currentOrigin, mover.mOriginOffset.v, moverOrigin);
VectorSubtract(moverOrigin, player->currentOrigin, playerToMover);
playerToMover[2] = 0.0f;
playerToMoverDistance = VectorNormalize(playerToMover);
// Is It Close Enough?
//---------------------
if ((( mover.mLane || !mover.mCenter) && // Not Center Track
(playerToMoverDistance<WOOSH_ALL_RANGE) && // And Close Enough
(DotProduct(playerToMover, mover.mTrack->mDirection.v)>-0.45f)) // And On The Side
|| //OR
((!mover.mLane && mover.mCenter) && // Is Center Track
(playerToMoverDistance<WOOSH_SUPPORT_RANGE || // And Close Enough for Support
(playerToMoverDistance<WOOSH_TUNNEL_RANGE && mover.mRows>10)) // Or Close Enough For Tunnel
))
{
mover.mSoundPlayed = true;
wooshSound = 0;
// The Centered Entities Play Right On The Player's Head For Full Volume
//-----------------------------------------------------------------------
if (mover.mCenter && !mover.mLane)
{
VectorCopy(player->currentOrigin, wooshSoundPos);
wooshSoundPos[2] += 50;
// If It Is Very Long, Play The Tunnel Sound
//-------------------------------------------
if (mover.mRows>10)
{
wooshSound = mWooshTun[Q_irand(0, mWooshTun.size()-1)];
}
// Otherwise It Is A Support
//---------------------------
else
{
wooshSound = mWooshSup[Q_irand(0, mWooshSup.size()-1)];
}
}
// All Other Entities Play At A Fraction Of Their Normal Range
//-------------------------------------------------------------
else
{
// Scale The Play Pos By The Square Of The Distance
//--------------------------------------------------
playerToMoverDistanceFraction = playerToMoverDistance/WOOSH_ALL_RANGE;
playerToMoverDistanceFraction *= playerToMoverDistanceFraction;
playerToMoverDistanceFraction *= 0.6f;
playerToMoverDistance *= playerToMoverDistanceFraction;
VectorMA(player->currentOrigin, playerToMoverDistance, playerToMover, wooshSoundPos);
// Large Building
//----------------
if (mover.mRows>4)
{
wooshSound = mWooshLar[Q_irand(0, mWooshLar.size()-1)];
}
// Medium Building
//-----------------
else if (mover.mRows>2)
{
wooshSound = mWooshMed[Q_irand(0, mWooshMed.size()-1)];
}
//.........这里部分代码省略.........
示例7: SP_rail_mover
void SP_rail_mover(gentity_t *ent)
{
gi.SetBrushModel(ent, ent->model);
mRailMovers.push_back().Setup(ent);
}
示例8: NPC_AnimalUpdateLeader
////////////////////////////////////////////////////////////////////////////////////////
// Update The Packs, Delete Dead Leaders, Join / Split Packs, Find MY Leader
////////////////////////////////////////////////////////////////////////////////////////
gentity_t* NPC_AnimalUpdateLeader(void)
{
// Find The Closest Pack Leader, Not Counting Myself
//---------------------------------------------------
gentity_t* closestLeader = 0;
float closestDist = 0;
int myLeaderNum = 0;
for (int i=0; i<mPacks.size(); i++)
{
// Dump Dead Leaders
//-------------------
if (mPacks[i]==0 || mPacks[i]->health<=0)
{
if (mPacks[i]==NPC->client->leader)
{
NPC->client->leader = 0;
}
mPacks.erase_swap(i);
if (i>=mPacks.size())
{
closestLeader = 0;
break;
}
}
// Don't Count Self
//------------------
if (mPacks[i]==NPC)
{
myLeaderNum = i;
continue;
}
float Dist = Distance(mPacks[i]->currentOrigin, NPC->currentOrigin);
if (!closestLeader || Dist<closestDist)
{
closestDist = Dist;
closestLeader = mPacks[i];
}
}
// In Joining Distance?
//----------------------
if (closestLeader && closestDist<JOIN_PACK_DISTANCE)
{
// Am I Already A Leader?
//------------------------
if (NPC->client->leader==NPC)
{
mPacks.erase_swap(myLeaderNum); // Erase Myself From The Leader List
}
// Join The Pack!
//----------------
NPC->client->leader = closestLeader;
}
// Do I Have A Leader?
//---------------------
if (NPC->client->leader)
{
// AM I A Leader?
//----------------
if (NPC->client->leader!=NPC)
{
// If Our Leader Is Dead, Clear Him Out
if ( NPC->client->leader->health<=0 || NPC->client->leader->inuse == 0)
{
NPC->client->leader = 0;
}
// If My Leader Isn't His Own Leader, Then, Use His Leader
//---------------------------------------------------------
else if (NPC->client->leader->client->leader!=NPC->client->leader)
{
// Eh. Can this get more confusing?
NPC->client->leader = NPC->client->leader->client->leader;
}
// If Our Leader Is Too Far Away, Clear Him Out
//------------------------------------------------------
else if ( Distance(NPC->client->leader->currentOrigin, NPC->currentOrigin)>LEAVE_PACK_DISTANCE)
{
NPC->client->leader = 0;
}
}
}
// If We Couldn't Find A Leader, Then Become One
//-----------------------------------------------
else if (!mPacks.full())
//.........这里部分代码省略.........