本文整理汇总了C++中ObjArray::NumObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjArray::NumObjects方法的具体用法?C++ ObjArray::NumObjects怎么用?C++ ObjArray::NumObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjArray
的用法示例。
在下文中一共展示了ObjArray::NumObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void Camera::Update()
{
LTVector vPos;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME,objArray);
int numObjects = objArray.NumObjects();
for (int i = 0; i < numObjects; i++ )
{
CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(objArray.GetObject(i));
if (pPlayer)
{
HCLIENT hClient = pPlayer->GetClient();
if (hClient)
{
g_pLTServer->SetClientViewPos(hClient, &vPos);
}
}
}
if (m_fActiveTime > 0.0f && g_pLTServer->GetTime() > m_fTurnOffTime)
{
TurnOff();
}
else
{
SetNextUpdate(UPDATE_NEXT_FRAME);
}
}
示例2: HandleSpawnFromMsg
void Spawner::HandleSpawnFromMsg( HOBJECT hSender, const CParsedMsg &crParsedMsg )
{
LTVector vPos;
LTRotation rRot;
const char *pName = "";
ObjArray<HOBJECT, 1> objArray;
g_pLTServer->FindNamedObjects( const_cast<char*>(crParsedMsg.GetArg(1).c_str()), objArray );
// Spawn the target object from the position of the specified object...
if( objArray.NumObjects() == 1 )
{
g_pLTServer->GetObjectPos( objArray.GetObject(0), &vPos );
g_pLTServer->GetObjectRotation( objArray.GetObject(0), &rRot );
}
else
{
g_pLTServer->GetObjectPos( m_hObject, &vPos );
g_pLTServer->GetObjectRotation( m_hObject, &rRot );
}
// Rename the object if desired
if( crParsedMsg.GetArgCount() > 2 )
{
pName = crParsedMsg.GetArg(2);
}
// Spawn using a target template...
Spawn( m_sTarget.c_str(), pName, vPos, rRot );
}
示例3: SendTriggerMsgToObjects
LTBOOL SendTriggerMsgToObjects(LPBASECLASS pSender, const char* pName, const char* pMsg)
{
if (!pMsg) return LTFALSE;
// Process the message as a command if it is a valid command...
if (g_pCmdMgr->IsValidCmd(pMsg))
{
return g_pCmdMgr->Process(pMsg);
}
if (!pName || pName[0] == '\0') return LTFALSE;
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
// ILTServer::FindNameObjects does not destroy pName so this is safe
g_pLTServer->FindNamedObjects((char*)pName, objArray);
int numObjects = objArray.NumObjects();
if (!numObjects) return LTFALSE;
for (int i = 0; i < numObjects; i++)
{
SendTriggerMsgToObject(pSender, objArray.GetObject(i), 0, pMsg);
}
return LTTRUE;
}
示例4: FindNamedObject
LTRESULT FindNamedObject(const char* szName, ILTBaseClass *& pObject, bool bMultipleOkay)
{
if ( !szName || !*szName ) return LT_NOTFOUND;
pObject = NULL;
ObjArray<HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects((char*)szName,objArray);
switch ( objArray.NumObjects() )
{
case 1:
{
pObject = g_pLTServer->HandleToObject(objArray.GetObject(0));
return LT_OK;
}
case 0:
{
return LT_NOTFOUND;
}
default:
{
if ( bMultipleOkay )
{
pObject = g_pLTServer->HandleToObject(objArray.GetObject(0));
return LT_OK;
}
else
{
g_pLTServer->CPrint("Error, %d objects named \"%s\" present in level", objArray.NumObjects(), szName);
return LT_ERROR;
}
}
}
}
示例5: CreateWorldModelDebris
void CDestructibleModel::CreateWorldModelDebris()
{
ILTServer* pServerDE = BaseClass::GetServerDE();
if (!pServerDE) return;
const char* pName = GetObjectName(m_hObject);
if (!pName || !pName[0]) return;
// Find all the debris objects...
int nNum = 0;
char strKey[128]; memset(strKey, 0, 128);
char strNum[18]; memset(strNum, 0, 18);
HCLASS hWMDebris = pServerDE->GetClass("WorldModelDebris");
while (1)
{
// Create the keyname string...
sprintf(strKey, "%sDebris%d", pName, nNum);
// Find any debris with that name...
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
pServerDE->FindNamedObjects(strKey, objArray);
int numObjects = objArray.NumObjects();
if (!numObjects) return;
for (int i = 0; i < numObjects; i++)
{
HOBJECT hObject = objArray.GetObject(i);
if (pServerDE->IsKindOf(pServerDE->GetObjectClass(hObject), hWMDebris))
{
WorldModelDebris* pDebris = (WorldModelDebris*)pServerDE->HandleToObject(hObject);
if (!pDebris) break;
LTVector vVel, vRotPeriods;
vVel.Init(GetRandom(-200.0f, 200.0f),
GetRandom(100.0f, 300.0f), GetRandom(-200.0f, 200.0f));
vRotPeriods.Init(GetRandom(-1.0f, 1.0f),
GetRandom(-1.0f, 1.0f), GetRandom(-1.0f, 1.0f));
pDebris->Start(&vRotPeriods, &vVel);
}
}
// Increment the counter...
nNum++;
}
}
示例6: DoExplosion
void CDestructibleModel::DoExplosion(char* pTargetName)
{
CWeapons weapons;
weapons.Init(m_hObject);
weapons.ObtainWeapon(m_nExplosionWeaponId);
weapons.ChangeWeapon(m_nExplosionWeaponId);
CWeapon* pWeapon = weapons.GetCurWeapon();
if (!pWeapon) return;
weapons.SetAmmo(pWeapon->GetAmmoId());
pWeapon->SetDamageFactor(m_fDamageFactor);
LTRotation rRot;
g_pLTServer->GetObjectRotation(m_hObject, &rRot);
LTVector vF, vPos;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
vF = rRot.Forward();
// Just blow up in place if we're not supposed to fire along
// forward vector and we don't have a target...
if (!m_bFireAlongForward)
{
pWeapon->SetLifetime(0.0f);
VEC_SET(vF, 0.0f, -1.0f, 0.0f); // Fire down
}
// See if we have a target...If so, point at it.
if (pTargetName)
{
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(pTargetName, objArray);
if (objArray.NumObjects())
{
LTVector vObjPos;
g_pLTServer->GetObjectPos(objArray.GetObject(0), &vObjPos);
vF = vObjPos - vPos;
vF.Normalize();
rRot = LTRotation(vF, LTVector(0.0f, 1.0f, 0.0f));
g_pLTServer->SetObjectRotation(m_hObject, &rRot);
}
}
WeaponFireInfo weaponFireInfo;
weaponFireInfo.hFiredFrom = m_hObject;
weaponFireInfo.vPath = vF;
weaponFireInfo.vFirePos = vPos;
weaponFireInfo.vFlashPos = vPos;
pWeapon->Fire(weaponFireInfo);
}
示例7: Update
void ScreenShake::Update()
{
if (--m_nNumShakes > 0)
{
SetNextUpdate(m_hObject, m_fFrequency);
}
LTVector vMyPos;
g_pLTServer->GetObjectPos(m_hObject, &vMyPos);
// Play sound...
if (m_hstrSound)
{
char* pSound = g_pLTServer->GetStringData(m_hstrSound);
g_pServerSoundMgr->PlaySoundFromPos(vMyPos, pSound, m_fSoundRadius, SOUNDPRIORITY_MISC_LOW);
}
// Time to shake. Get all the players in the area of effect...
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME, objArray);
int numObjects = objArray.NumObjects();
if (!numObjects) return;
for (int i = 0; i < numObjects; i++)
{
HOBJECT hObject = objArray.GetObject(i);
if (hObject && IsPlayer(hObject))
{
// Make sure object is in area of effect...
LTVector vPlayerPos;
g_pLTServer->GetObjectPos(hObject, &vPlayerPos);
if (m_fAreaOfEffect == c_fENTIRE_LEVEL ||
VEC_DIST(vPlayerPos, vMyPos) <= m_fAreaOfEffect)
{
CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);
if (pPlayer)
{
HCLIENT hClient = pPlayer->GetClient();
if (hClient)
{
HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_SHAKE_SCREEN);
g_pLTServer->WriteToMessageVector(hMessage, &m_vAmount);
g_pLTServer->EndMessage(hMessage);
}
}
}
}
}
}
示例8: FindWhoPlaysDecision
HOBJECT CinematicTrigger::FindWhoPlaysDecision(uint8 byDecision)
{
char* pCharName = DEFAULT_PLAYERNAME;
if (byDecision > 0)
{
char* pMsg = g_pLTServer->GetStringData(m_hstrWhoPlaysDecisions[m_nCurMessage]);
if (pMsg)
{
ConParse parse;
parse.Init(pMsg);
// Since the names will be seperated by semi-colons we need
// to parse until we get to the correct name...
LTBOOL bFound = LTTRUE;
for (int i=1; i <= byDecision; i++)
{
if (g_pLTServer->Common()->Parse(&parse) != LT_OK)
{
bFound = LTFALSE;
break;
}
}
// Parse should be on the correct name now...
if (bFound && parse.m_nArgs > 0)
{
if (parse.m_Args[0])
{
pCharName = parse.m_Args[0];
}
}
}
}
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(pCharName, objArray);
if (objArray.NumObjects())
{
return objArray.GetObject(0);
}
return LTNULL;
}
示例9: FirstUpdate
void Controller::FirstUpdate()
{
// Find target objects and make interlinks.
for (uint32 i=0; i < MAX_CONTROLLER_TARGETS; i++)
{
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(m_Fades[i].m_ObjectName, objArray);
if (objArray.NumObjects())
{
HOBJECT hObject = objArray.GetObject(0);
m_Fades[i].m_hTarget = hObject;
}
}
}
示例10: AllObjectsCreated
bool SoundNonPoint::AllObjectsCreated()
{
// resolve the object links. Basically, get the sound zone volumes
// and collect their info into the non-point sound object that
// gets created on the client.
ObjArray <HOBJECT, 1> objArray;
int32 i;
m_SCS.m_nNumZones = 0;
for (i=0; i < MAX_SOUND_VOLUMES; i++)
{
SoundZoneVolume* pSZV;
if(!LTStrEmpty(m_sSoundZone[i].c_str()))
{
g_pLTServer->FindNamedObjects(m_sSoundZone[i].c_str(), objArray);
if(objArray.NumObjects() > 0)
{
if (IsKindOf(objArray.GetObject(0), "SoundZoneVolume"))
{
HOBJECT hObj;
hObj = objArray.GetObject(0);
pSZV = (SoundZoneVolume*) g_pLTServer->HandleToObject(hObj);
// do a type check before casting...
if (pSZV)
{
g_pLTServer->GetObjectPos(hObj, &m_SCS.m_SoundZone[m_SCS.m_nNumZones].m_vPos);
g_pLTServer->GetObjectRotation(hObj, &m_SCS.m_SoundZone[m_SCS.m_nNumZones].m_rRotation);
m_SCS.m_SoundZone[m_SCS.m_nNumZones].m_vHalfDims = pSZV->GetHalfDims();
m_SCS.m_nNumZones++;
}
}
}
}
}
return true;
}
示例11: HandleDetachMsg
void WorldModel::HandleDetachMsg( const CParsedMsg &cMsg )
{
if( cMsg.GetArgCount() >= 2 )
{
// Look for the specific objects we want to detach
for( uint i = 1; i < cMsg.GetArgCount( ); i++ )
{
const char *pObjName = cMsg.GetArg(i).c_str();
if( !pObjName )
break;
ObjArray<HOBJECT, 1> objArray;
g_pLTServer->FindNamedObjects( const_cast<char *>(pObjName), objArray );
if( objArray.NumObjects() )
{
DetachObject( objArray.GetObject( 0 ) );
}
}
}
else
{
// Remove an Object we attached using the AttachDir...
if( m_hAttachDirObj )
{
DetachObject( m_hAttachDirObj );
m_hAttachDirObj = NULL;
}
else
{
// Objects attached via ATTACH ....
while( m_AttachMsgObjList.size( ))
{
ObjRefNotifierList::iterator msgiter = m_AttachMsgObjList.begin( );
HOBJECT hObj = *msgiter;
if( hObj )
DetachObject( hObj );
m_AttachMsgObjList.erase( msgiter );
}
}
}
}
示例12: OnAllObjectsCreated
uint32 Door::OnAllObjectsCreated( )
{
// Send to base class first...
ActiveWorldModel::OnAllObjectsCreated( );
// Create a link to our door link object if we have one...
if( !m_sDoorLink.empty() )
{
ObjArray<HOBJECT, 1> objArray;
g_pLTServer->FindNamedObjects( m_sDoorLink.c_str(), objArray );
if( objArray.NumObjects() > 0 )
{
m_hDoorLink = objArray.GetObject( 0 );
}
}
return 1;
}
示例13: PlayedBy
HOBJECT CinematicTrigger::PlayedBy(char *pszName)
{
if (!g_pLTServer || m_nCurMessage >= MAX_CT_MESSAGES) return m_hObject;
if (!pszName) return LTNULL;
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(pszName,objArray);
int numObjects = objArray.NumObjects();
for (int i = 0; i < numObjects; i++)
{
HOBJECT hObject = objArray.GetObject(i);
if (IsActor(hObject))
{
return hObject;
}
}
return LTNULL;
}
示例14: OnEveryObjectCreated
void WorldModel::OnEveryObjectCreated( )
{
// Save if we are currently set up to be activated...
uint32 dwFlags;
g_pCommonLT->GetObjectFlags( m_hObject, OFT_User, dwFlags );
m_bCanActivate = !!(dwFlags & USRFLG_CAN_ACTIVATE);
// Check for any objects to attach
if( !m_hstrAttachments ) return;
const char *pAttachments = g_pLTServer->GetStringData( m_hstrAttachments );
if( !pAttachments ) return;
ConParse parse( pAttachments );
while( g_pCommonLT->Parse( &parse ) == LT_OK )
{
// We have an object we want to attach... find it
if( parse.m_nArgs > 0 && parse.m_Args[0] )
{
ObjArray<HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects( parse.m_Args[0], objArray );
for( uint i = 0; i < objArray.NumObjects(); i++ )
{
AttachObject( objArray.GetObject( i ) );
}
}
}
// Once they are added free the string because we don't want to re-add the objects
// everytime this objects gets loaded. Our attachment list will take care of everything.
FREE_HSTRING( m_hstrAttachments );
}
示例15: DoActivate
void Intelligence::DoActivate(HOBJECT hSender)
{
// BL 10/30/00 - fix multiple photographs of items in multiplayer
{
if ( g_pGameServerShell->GetGameType() != SINGLE )
{
uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);
if ( !(dwFlags & FLAG_VISIBLE) )
{
return;
}
}
}
HOBJECT hPlayer = hSender;
if (!hSender || !IsPlayer(hSender))
{
// Find the player if the sender isn't one...
ObjArray <HOBJECT, 1> objArray;
g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME, objArray);
if (!objArray.NumObjects()) return;
hPlayer = objArray.GetObject(0);
}
// Increment the player's intelligence count...
CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hPlayer);
if (pPlayer)
{
if (g_pGameServerShell->GetGameType() == COOPERATIVE_ASSAULT && m_nPlayerTeamFilter)
{
if (pPlayer->GetTeamID() != m_nPlayerTeamFilter)
return;
uint8 nScore = (uint8)g_vtNetIntelScore.GetFloat();
pPlayer->AddToScore(nScore);
HCLIENT hClient = pPlayer->GetClient();
uint32 nPlayerID = g_pLTServer->GetClientID(hClient);
HMESSAGEWRITE hWrite = g_pLTServer->StartMessage (LTNULL, MID_TEAM_SCORED);
g_pLTServer->WriteToMessageDWord (hWrite, nPlayerID);
g_pLTServer->WriteToMessageByte (hWrite, (uint8)pPlayer->GetTeamID());
g_pLTServer->WriteToMessageByte (hWrite, nScore);
g_pLTServer->EndMessage (hWrite);
}
CPlayerSummaryMgr* pPSMgr = pPlayer->GetPlayerSummaryMgr();
if (pPSMgr)
{
pPSMgr->IncIntelligenceCount();
}
HCLIENT hClient = pPlayer->GetClient();
if (hClient)
{
HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_PLAYER_INFOCHANGE);
g_pLTServer->WriteToMessageByte(hMessage, IC_INTEL_PICKUP_ID);
g_pLTServer->WriteToMessageByte(hMessage, 0);
g_pLTServer->WriteToMessageByte(hMessage, 0);
g_pLTServer->WriteToMessageFloat(hMessage, 0.0f);
g_pLTServer->EndMessage(hMessage);
}
// Show the pop-up associated with the intelligence item, if
// applicable...
INTEL* pIntel = g_pIntelMgr->GetIntel(m_nIntelId);
if (pIntel && m_bShowPopup)
{
char buf[255];
sprintf(buf, "msg %s (popup %d", DEFAULT_PLAYERNAME, m_nInfoId);
// Add the scale fx...
for (int i=0; i < pIntel->nNumScaleFXNames; i++)
{
if (pIntel->szScaleFXNames[i])
{
strcat(buf, " ");
strcat(buf, pIntel->szScaleFXNames[i]);
}
}
strcat(buf, ")");
if (g_pCmdMgr->IsValidCmd(buf))
{
g_pCmdMgr->Process(buf);
}
}
// If we have a command, process it...
if (m_hstrPickedUpCmd)
//.........这里部分代码省略.........