本文整理汇总了C++中CGameRules::ServerHit方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameRules::ServerHit方法的具体用法?C++ CGameRules::ServerHit怎么用?C++ CGameRules::ServerHit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameRules
的用法示例。
在下文中一共展示了CGameRules::ServerHit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
//------------------------------------------------------------------------
void CVehicleDamageBehaviorBurn::Update(const float deltaTime)
{
m_timeCounter -= deltaTime;
if(m_timeCounter <= 0.0f)
{
CGameRules *pGameRules = g_pGame->GetGameRules();
if(pGameRules && gEnv->bServer)
{
Vec3 worldPos;
if(m_pHelper)
worldPos = m_pHelper->GetWorldSpaceTranslation();
else
worldPos = m_pVehicle->GetEntity()->GetWorldTM().GetTranslation();
SEntityProximityQuery query;
query.box = AABB(worldPos-Vec3(m_radius), worldPos+Vec3(m_radius));
gEnv->pEntitySystem->QueryProximity(query);
IEntity *pEntity = 0;
for(int i = 0; i < query.nCount; ++i)
{
if((pEntity = query.pEntities[i]) && pEntity->GetPhysics())
{
float damage = (pEntity->GetId() == m_pVehicle->GetEntityId()) ? m_selfDamage : m_damage;
// SNH: need to check vertical distance here as the QueryProximity() call seems to work in 2d only
Vec3 pos = pEntity->GetWorldPos();
if(abs(pos.z - worldPos.z) < m_radius)
{
if(damage > 0.f)
{
HitInfo hitInfo;
hitInfo.damage = damage;
hitInfo.pos = worldPos;
hitInfo.radius = m_radius;
hitInfo.targetId = pEntity->GetId();
hitInfo.shooterId = m_shooterId;
hitInfo.weaponId = m_pVehicle->GetEntityId();
hitInfo.type = pGameRules->GetHitTypeId("fire");
pGameRules->ServerHit(hitInfo);
}
}
}
}
if(gEnv->pAISystem)
gEnv->pAISystem->RegisterDamageRegion(this, Sphere(worldPos, m_radius));
}
m_timeCounter = m_interval;
}
m_pVehicle->NeedsUpdate();
}
示例2: DestructionDamageRatioReached
void CVTOLVehicleManager::DestructionDamageRatioReached(IVehicle* pVehicle, SVTOLInfo& info, float frameTime)
{
pVehicle->ClientEvictAllPassengers();
LockSeats(pVehicle, true);
IPhysicalEntity* pPhysics = pVehicle->GetEntity()->GetPhysics();
if(pPhysics)
{
DestroyVTOL(pVehicle->GetEntity(), info);
CGameRules::SModuleRMIEntityParams params;
params.m_listenerIndex = m_moduleRMIIndex;
params.m_entityId = info.entityId;
params.m_data = eRMITypeSingleEntity_vtol_destroyed;
// RMI will patch entityIDs between clients
g_pGame->GetGameRules()->GetGameObject()->InvokeRMIWithDependentObject(CGameRules::ClModuleRMISingleEntity(), params, eRMI_ToRemoteClients, info.entityId);
}
//Damage any players inside
CGameRules* pGameRules = g_pGame->GetGameRules();
CVehicleMovementMPVTOL* pMovement = static_cast<CVehicleMovementMPVTOL*>(pVehicle->GetMovement());
if (pGameRules && pMovement)
{
EntityId destroyerId = pMovement->GetDestroyerId();
HitInfo hitInfo(destroyerId, 0, pVehicle->GetEntityId(), g_pGameCVars->g_VTOLOnDestructionPlayerDamage, 0, 0, 0, CGameRules::EHitType::VTOLExplosion);
TPlayerList& currentPlayerList = info.playersInside;
TPlayerList::const_iterator iter = currentPlayerList.begin();
TPlayerList::const_iterator end = currentPlayerList.end();
while(iter != end)
{
hitInfo.targetId = *iter;
pGameRules->ServerHit(hitInfo);
++iter;
}
}
}