本文整理汇总了C++中NetIO::sendInteraction方法的典型用法代码示例。如果您正苦于以下问题:C++ NetIO::sendInteraction方法的具体用法?C++ NetIO::sendInteraction怎么用?C++ NetIO::sendInteraction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetIO
的用法示例。
在下文中一共展示了NetIO::sendInteraction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: munitionDetonationMsgFactory
//.........这里部分代码省略.........
netIO->getInteractionParameterHandle(NetIO::QUANTITY_FIRED_MD_PI),
reinterpret_cast<char*>(&netBuffer),
sizeof(unsigned short) );
}
// ---
// Rate Of Fire
// ---
{
unsigned short rateOfFire = 0;
unsigned short netBuffer;
base::NetHandler::toNetOrder(&netBuffer, rateOfFire );
pParams->add(
netIO->getInteractionParameterHandle(NetIO::RATE_OF_FIRE_MD_PI),
reinterpret_cast<char*>(&netBuffer),
sizeof(unsigned short) );
}
// ---
// Warhead type
// ---
{
WarheadTypeEnum16 warheadType = WarheadTypeOther;
unsigned short netBuffer;
base::NetHandler::toNetOrder(&netBuffer, static_cast<unsigned short>(warheadType) );
pParams->add(
netIO->getInteractionParameterHandle(NetIO::WARHEAD_TYPE_MD_PI),
reinterpret_cast<char*>(&netBuffer),
sizeof(unsigned short) );
}
// ---
// Relative detonation location
// ---
{
RelativePositionStruct relativeDetonationLocation;
relativeDetonationLocation.bodyXDistance = 0;
relativeDetonationLocation.bodyYDistance = 0;
relativeDetonationLocation.bodyZDistance = 0;
RelativePositionStruct netBuffer;
base::NetHandler::toNetOrder(&netBuffer.bodyXDistance, relativeDetonationLocation.bodyXDistance );
base::NetHandler::toNetOrder(&netBuffer.bodyYDistance, relativeDetonationLocation.bodyYDistance );
base::NetHandler::toNetOrder(&netBuffer.bodyZDistance, relativeDetonationLocation.bodyZDistance );
pParams->add(
netIO->getInteractionParameterHandle(NetIO::RELATIVE_DETONATION_LOCATION_MD_PI),
reinterpret_cast<char*>(&netBuffer),
sizeof(RelativePositionStruct) );
}
// ---
// Detonation result code
// ---
{
DetonationResultCodeEnum8 detonationResultCode;
switch ( mPlayer->getDetonationResults() ) {
case simulation::Weapon::DETONATE_OTHER :
detonationResultCode = DetonationResultCodeOther;
break;
case simulation::Weapon::DETONATE_ENTITY_IMPACT :
detonationResultCode = EntityImpact;
break;
case simulation::Weapon::DETONATE_ENTITY_PROXIMATE_DETONATION :
detonationResultCode = EntityProximateDetonation;
break;
case simulation::Weapon::DETONATE_GROUND_IMPACT :
detonationResultCode = GroundImpact;
break;
case simulation::Weapon::DETONATE_GROUND_PROXIMATE_DETONATION :
detonationResultCode = GroundProximateDetonation;
break;
case simulation::Weapon::DETONATE_DETONATION :
detonationResultCode = Detonation;
break;
case simulation::Weapon::DETONATE_NONE :
detonationResultCode = None;
break;
default :
detonationResultCode = DetonationResultCodeOther;
break;
};
unsigned char netBuffer = static_cast<unsigned char>(detonationResultCode);
pParams->add(
netIO->getInteractionParameterHandle(NetIO::DETONATION_RESULT_CODE_MD_PI),
reinterpret_cast<char*>(&netBuffer),
sizeof(unsigned char) );
}
// ---
// Send the interaction
// ---
bool ok = netIO->sendInteraction(
netIO->getInteractionClassHandle(NetIO::MUNITION_DETONATION_INTERACTION), pParams );
// don't need this anymore
delete pParams;
return ok;
}