本文整理汇总了C++中ratl::vector_vs::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_vs::size方法的具体用法?C++ vector_vs::size怎么用?C++ vector_vs::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ratl::vector_vs
的用法示例。
在下文中一共展示了vector_vs::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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)];
}
//.........这里部分代码省略.........
示例4: 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())
//.........这里部分代码省略.........