本文整理汇总了C++中simulation::Player::isLocalPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ Player::isLocalPlayer方法的具体用法?C++ Player::isLocalPlayer怎么用?C++ Player::isLocalPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation::Player
的用法示例。
在下文中一共展示了Player::isLocalPlayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stepOwnshipPlayer
//------------------------------------------------------------------------------
// stepOwnshipPlayer() -- Step to the next local player
//------------------------------------------------------------------------------
void SimStation::stepOwnshipPlayer()
{
Basic::PairStream* pl = getSimulation()->getPlayers();
if (pl != nullptr) {
Simulation::Player* f = nullptr;
Simulation::Player* n = nullptr;
bool found = false;
// Find the next player
Basic::List::Item* item = pl->getFirstItem();
while (item != nullptr) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
if (pair != nullptr) {
Simulation::Player* ip = static_cast<Simulation::Player*>(pair->object());
if ( ip->isMode(Simulation::Player::ACTIVE) &&
ip->isLocalPlayer() &&
ip->isClassType(typeid(Simulation::AirVehicle))
) {
if (f == nullptr) { f = ip; } // Remember the first
if (found) { n = ip; ; break; }
if (ip == getOwnship()) found = true;
}
}
item = item->getNext();
}
if (found && n == nullptr) n = f;
if (n != nullptr) setOwnshipPlayer(n);
pl->unref();
}
}
示例2: munitionDetonationMsgFactory
//------------------------------------------------------------------------------
// munitionDetonationMsgFactory() -- (Output) Munition detonation message factory
//------------------------------------------------------------------------------
bool Nib::munitionDetonationMsgFactory(const LCreal)
{
// Dummy weapon?
const Simulation::Weapon* ww = dynamic_cast<const Simulation::Weapon*>( getPlayer() );
if (ww != 0) {
if (ww->isDummy()) return true;
}
bool ok = true;
//std::cout << "NetIO::munitionDetonationMsgFactory() HERE!!" << std::endl;
// Get our NetIO
NetIO* disIO = (NetIO*)(getNetIO());
// If our NIB's player just detonated, then it must be a weapon!
Simulation::Weapon* mPlayer = dynamic_cast<Simulation::Weapon*>(getPlayer());
if (mPlayer == 0) return false;
// Ok, we have the weapon, now get the firing and target players
Simulation::Player* tPlayer = mPlayer->getTargetPlayer();
Simulation::Player* fPlayer = mPlayer->getLaunchVehicle();
if (fPlayer == 0) return false;
// ---
// PDU header
// ---
DetonationPDU pdu;
pdu.header.protocolVersion = disIO->getVersion();
pdu.header.PDUType = NetIO::PDU_DETONATION;
pdu.header.protocolFamily = NetIO::PDU_FAMILY_WARFARE;
pdu.header.length = sizeof(DetonationPDU);
pdu.header.exerciseIdentifier = disIO->getExerciseID();
pdu.header.timeStamp = disIO->timeStamp();
pdu.header.status = 0;
pdu.header.padding = 0;
// ---
// Set the PDU data with the firing (launcher) player's id
// ---
pdu.firingEntityID.ID = fPlayer->getID();
pdu.firingEntityID.simulationID.siteIdentification = getSiteID();
pdu.firingEntityID.simulationID.applicationIdentification = getApplicationID();
// ---
// Set the PDU data with the munition's ID
// ---
pdu.munitionID.ID = mPlayer->getID();
pdu.munitionID.simulationID.siteIdentification = getSiteID();
pdu.munitionID.simulationID.applicationIdentification = getApplicationID();
// ---
// Set the PDU data with the target's ID
// ---
{
bool tOk = false;
if (tPlayer != 0) {
pdu.targetEntityID.ID = tPlayer->getID();
if (tPlayer->isLocalPlayer()) {
// Local player, use our site/app/exerc IDs
pdu.targetEntityID.simulationID.siteIdentification = getSiteID();
pdu.targetEntityID.simulationID.applicationIdentification = getApplicationID();
tOk = true;
}
else {
// Networked player, use its NIB's IDs
const Nib* fNIB = dynamic_cast<const Nib*>( tPlayer->getNib() );
if (fNIB != 0) {
pdu.targetEntityID.simulationID.siteIdentification = fNIB->getSiteID();
pdu.targetEntityID.simulationID.applicationIdentification = fNIB->getApplicationID();
tOk = true;
}
}
}
if (!tOk) {
pdu.targetEntityID.ID = 0;
pdu.targetEntityID.simulationID.siteIdentification = 0;
pdu.targetEntityID.simulationID.applicationIdentification = 0;
}
}
// ---
// Event ID
// ---
pdu.eventID.simulationID.siteIdentification = getSiteID();
pdu.eventID.simulationID.applicationIdentification = getApplicationID();
pdu.eventID.eventNumber = mPlayer->getReleaseEventID();
// ---
// Location & Velocity
// ---
// World Coordinates
osg::Vec3d geocPos = mPlayer->getGeocPosition();
pdu.location.X_coord = geocPos[Basic::Nav::IX];
pdu.location.Y_coord = geocPos[Basic::Nav::IY];
pdu.location.Z_coord = geocPos[Basic::Nav::IZ];
//.........这里部分代码省略.........