本文整理汇总了C++中PhysicsBody::setParentId方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsBody::setParentId方法的具体用法?C++ PhysicsBody::setParentId怎么用?C++ PhysicsBody::setParentId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsBody
的用法示例。
在下文中一共展示了PhysicsBody::setParentId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drop
void ShipModulesControllerSystem::drop(Entity* p_parent, unsigned int p_slot)
{
if (p_slot < 0)
return;
//Module is dropped based on damage it sustains
ConnectionPointSet* connected = static_cast<ConnectionPointSet*>(
p_parent->getComponent(ComponentType::ConnectionPointSet) );
Entity* toDrop = m_world->getEntity(connected->m_connectionPoints[p_slot].cpConnectedEntity);
ShipModule* m = static_cast<ShipModule*>(toDrop->getComponent(ComponentType::ShipModule));
NetworkSynced* networkSynced = static_cast<NetworkSynced*>(
toDrop->getComponent(ComponentType::NetworkSynced));
ConnectionPointSet* toDropConnected =
static_cast<ConnectionPointSet*>(
m_world->getComponentManager()->getComponent(toDrop,
ComponentType::getTypeFor(ComponentType::ConnectionPointSet)));
if (toDropConnected)
{
for (unsigned int i = 0; i < toDropConnected->m_connectionPoints.size(); i++)
{
int e = toDropConnected->m_connectionPoints[i].cpConnectedEntity;
if (e >= 0 && m->m_parentEntity != e)
drop(toDrop, i);
else if (m->m_parentEntity == e)
{
toDropConnected->m_connectionPoints[i].cpConnectedEntity = -1;
}
}
}
//Perform the drop
connected->m_connectionPoints[p_slot].cpConnectedEntity = -1;
m->m_parentEntity = -1;
PhysicsBody* b = static_cast<PhysicsBody*>(toDrop->getComponent(ComponentType::PhysicsBody));
PhysicsSystem* ps = static_cast<PhysicsSystem*>(m_world->getSystem(SystemType::PhysicsSystem));
Body* body = ps->getController()->getBody(b->m_id);
ps->getController()->DetachBodyFromCompound((RigidBody*)body);
b->setParentId(-1);
// ===========================
// Update module data
// ===========================
m->m_health = m->getMaxHealth();
m->m_value = ModuleHelper::changeModuleValueOnDetach(m->m_value);
m->deactivate();
m->m_lastShipEntityWhenAttached = -1;
// send status effect updates
updateModuleHealthEffect(networkSynced->getNetworkOwner(),
m->m_health/m->getMaxHealth());
updateModuleValueEffect(networkSynced->getNetworkOwner(),
m->m_value/m->getMaxValue());
//Change particle effects on slots
if (true) //m_editMode
{
Entity* parentShip = p_parent;
ShipModule* parentModule = static_cast<ShipModule*>(parentShip->getComponent(ComponentType::ShipModule));
Entity* firstChild = toDrop;
while (parentModule)
{
firstChild = parentShip;
parentShip = m_world->getEntity(parentModule->m_parentEntity);
parentModule = static_cast<ShipModule*>(parentShip->getComponent(ComponentType::ShipModule));
}
int shipSlot = -1;
if (firstChild == toDrop)
shipSlot = p_slot;
else
{
ConnectionPointSet* shipcps = static_cast<ConnectionPointSet*>(
m_world->getComponentManager()->getComponent(parentShip,
ComponentType::getTypeFor(ComponentType::ConnectionPointSet)));
for (unsigned int i = 0; i < shipcps->m_connectionPoints.size(); i++)
{
if (shipcps->m_connectionPoints[i].cpConnectedEntity == firstChild->getIndex())
{
shipSlot = i;
break;
}
}
}
NetworkSynced* parentNetworkSynced = static_cast<NetworkSynced*>(
p_parent->getComponent(ComponentType::NetworkSynced));
NetworkSynced* shipNetworkSynced = static_cast<NetworkSynced*>(
parentShip->getComponent(ComponentType::NetworkSynced));
//Remove particle effects from the slot
for (unsigned int i = 0; i < toDropConnected->m_connectionPoints.size(); i++)
{
if (toDropConnected->m_connectionPoints[i].cpConnectedEntity < 0)
{
SlotParticleEffectPacket slotPacket;
//.........这里部分代码省略.........