Refactor object dying status and GetActive
parent
b2e7815001
commit
e11d2ec33e
|
@ -322,7 +322,7 @@ CObject* CLightning::SearchObject(Math::Vector pos)
|
|||
float min = 100000.0f;
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if (!obj->GetActive()) continue; // inactive object?
|
||||
if (!obj->GetDetectable()) continue; // inactive object?
|
||||
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
|
||||
|
|
|
@ -3580,7 +3580,7 @@ CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos,
|
|||
bool shield = false;
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if (!obj->GetActive()) continue; // inactive?
|
||||
if (!obj->GetDetectable()) continue; // inactive?
|
||||
if (obj == father) continue;
|
||||
|
||||
ObjectType oType = obj->GetType();
|
||||
|
@ -3677,7 +3677,7 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
|
|||
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if (!obj->GetActive()) continue; // inactive?
|
||||
if (!obj->GetDetectable()) continue; // inactive?
|
||||
if (obj == father) continue;
|
||||
|
||||
ObjectType oType = obj->GetType();
|
||||
|
|
|
@ -262,7 +262,8 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
|
||||
if ( m_type == PT_DEADG )
|
||||
{
|
||||
m_object->SetDead(true);
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
dynamic_cast<CDestroyableObject*>(m_object)->SetDying(DeathType::Dead);
|
||||
|
||||
assert(obj->Implements(ObjectInterfaceType::Movable));
|
||||
dynamic_cast<CMovableObject*>(obj)->GetMotion()->SetAction(MHS_DEADg, 1.0f);
|
||||
|
@ -274,7 +275,8 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
}
|
||||
if ( m_type == PT_DEADW )
|
||||
{
|
||||
m_object->SetDead(true);
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
dynamic_cast<CDestroyableObject*>(m_object)->SetDying(DeathType::Dead);
|
||||
|
||||
assert(obj->Implements(ObjectInterfaceType::Movable));
|
||||
dynamic_cast<CMovableObject*>(obj)->GetMotion()->SetAction(MHS_DEADw, 1.0f);
|
||||
|
@ -1530,7 +1532,8 @@ void CPyro::ExploStart()
|
|||
|
||||
m_object->Simplify();
|
||||
m_object->SetLock(true); // ruin not usable yet
|
||||
m_object->SetExploding(true); // being destroyed
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
dynamic_cast<CDestroyableObject*>(m_object)->SetDying(DeathType::Exploding); // being destroyed
|
||||
m_object->FlatParent();
|
||||
|
||||
if ( m_object->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject*>(m_object)->GetSelect() )
|
||||
|
@ -2172,12 +2175,13 @@ void CPyro::BurnTerminate()
|
|||
m_object->SetLock(false);
|
||||
}
|
||||
|
||||
m_object->SetBurn(false); // ruin usable (c-e-d. recoverable)
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
dynamic_cast<CDestroyableObject*>(m_object)->SetDying(DeathType::Alive); // ruin usable (c-e-d. recoverable)
|
||||
}
|
||||
|
||||
void CPyro::FallStart()
|
||||
{
|
||||
m_object->SetBurn(true); // usable
|
||||
m_object->SetLock(true); // usable
|
||||
|
||||
Math::Vector pos = m_object->GetPosition();
|
||||
m_fallFloor = m_terrain->GetFloorLevel(pos);
|
||||
|
@ -2308,7 +2312,7 @@ Error CPyro::FallIsEnded()
|
|||
if (pos.y > m_fallFloor) return ERR_CONTINUE;
|
||||
|
||||
m_sound->Play(SOUND_BOUM, pos);
|
||||
m_object->SetBurn(false); // usable again
|
||||
m_object->SetLock(false); // usable again
|
||||
|
||||
return ERR_STOP;
|
||||
}
|
||||
|
|
|
@ -1864,13 +1864,13 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
|
|||
|
||||
for (CObject* obj : m_objMan->GetAllObjects())
|
||||
{
|
||||
if (!obj->GetActive()) continue;
|
||||
if (!obj->GetDetectable()) continue;
|
||||
|
||||
CObject* transporter = nullptr;
|
||||
if (obj->Implements(ObjectInterfaceType::Transportable))
|
||||
transporter = dynamic_cast<CTransportableObject*>(obj)->GetTransporter();
|
||||
|
||||
if (transporter != nullptr && !transporter->GetActive()) continue;
|
||||
if (transporter != nullptr && !transporter->GetDetectable()) continue;
|
||||
if (obj->GetProxyActivate()) continue;
|
||||
|
||||
CObject* target = obj;
|
||||
|
@ -1881,6 +1881,7 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
|
|||
if (target == nullptr) target = obj; // standalone battery
|
||||
}
|
||||
|
||||
if (!obj->Implements(ObjectInterfaceType::Old)) continue;
|
||||
for (int j = 0; j < OBJECTMAXPART; j++)
|
||||
{
|
||||
int rank = obj->GetObjectRank(j);
|
||||
|
@ -3884,7 +3885,7 @@ float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
|
|||
float min = 100000.0f;
|
||||
for (CObject* obj : m_objMan->GetAllObjects())
|
||||
{
|
||||
if (!obj->GetActive()) continue; // inactive?
|
||||
if (!obj->GetDetectable()) continue; // inactive?
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
|
||||
if (obj == exclu) continue;
|
||||
|
@ -4106,7 +4107,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* transporter)
|
|||
float tMax;
|
||||
for (CObject* obj : m_objMan->GetAllObjects())
|
||||
{
|
||||
if (!obj->GetActive()) continue; // inactive?
|
||||
if (!obj->GetDetectable()) continue; // inactive?
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
|
||||
if (obj == metal) continue;
|
||||
|
@ -4547,9 +4548,7 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s
|
|||
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||
if (obj->GetType() == OBJECT_FIX) continue;
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
if (obj->GetBurn()) continue;
|
||||
if (obj->GetDead()) continue;
|
||||
if (obj->IsExploding()) continue;
|
||||
if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(obj)->IsDying()) continue;
|
||||
|
||||
if (obj->Implements(ObjectInterfaceType::Carrier))
|
||||
{
|
||||
|
@ -4603,9 +4602,7 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s
|
|||
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||
if (obj->GetType() == OBJECT_FIX) continue;
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
|
||||
if (obj->GetBurn()) continue;
|
||||
if (obj->GetDead()) continue;
|
||||
if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(obj)->IsDying()) continue;
|
||||
|
||||
if (!SaveFileStack(obj, file, objRank++)) break;
|
||||
}
|
||||
|
@ -4801,8 +4798,7 @@ CObject* CRobotMain::IOReadScene(std::string filename, std::string filecbot)
|
|||
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||
if (obj->GetType() == OBJECT_FIX) continue;
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
if (obj->GetBurn()) continue;
|
||||
if (obj->GetDead()) continue;
|
||||
if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(obj)->IsDying()) continue;
|
||||
|
||||
if (!ReadFileStack(obj, file, objRank++)) break;
|
||||
}
|
||||
|
|
|
@ -56,10 +56,7 @@ int CSceneCondition::CountObjects()
|
|||
int nb = 0;
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
// Do not use GetActive () because an invisible worm (underground)
|
||||
// should be regarded as existing here!
|
||||
if (obj->GetLock()) continue;
|
||||
if (obj->GetRuin()) continue;
|
||||
if (!obj->GetActive()) continue;
|
||||
|
||||
if (!this->countTransported)
|
||||
{
|
||||
|
|
|
@ -273,7 +273,7 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos)
|
|||
CObject* best = nullptr;
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( !obj->GetActive() ) continue;
|
||||
if ( !obj->GetDetectable() ) continue;
|
||||
|
||||
ObjectType oType = obj->GetType();
|
||||
if ( oType != OBJECT_ANT &&
|
||||
|
|
|
@ -278,7 +278,7 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
|
|||
oType != OBJECT_BEE &&
|
||||
oType != OBJECT_WORM ) continue;
|
||||
|
||||
if ( !obj->GetActive() ) continue; // inactive?
|
||||
if ( !obj->GetDetectable() ) continue; // inactive?
|
||||
|
||||
//? if ( g_researchDone & RESEARCH_QUICK )
|
||||
if ( false )
|
||||
|
|
|
@ -65,7 +65,7 @@ bool CProgrammableObjectImpl::EventProcess(const Event &event)
|
|||
{
|
||||
if (event.type == EVENT_FRAME)
|
||||
{
|
||||
if ( m_object->GetRuin() && IsProgram() )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(m_object)->IsDying() && IsProgram() )
|
||||
{
|
||||
StopProgram();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@ enum class DestructionType
|
|||
Drowned = 4, //!< drowned (only for Me)
|
||||
};
|
||||
|
||||
enum class DeathType
|
||||
{
|
||||
Alive = -1, //!< not dead
|
||||
Exploding, //!< killed by explosion
|
||||
Burning, //!< killed by fire
|
||||
Dead //!< dead human
|
||||
};
|
||||
|
||||
/**
|
||||
* \class CDestroyableObject
|
||||
* \brief Interface for objects that can be destroyed
|
||||
|
@ -53,4 +61,11 @@ public:
|
|||
|
||||
//! Returns the distance modifier for CLightning, used to modify hit probability. Value in range [0..1], where 0 is never and 1 is normal probability
|
||||
virtual float GetLightningHitProbability() = 0;
|
||||
|
||||
//! Set the status that means the object is currently dying
|
||||
virtual void SetDying(DeathType deathType) = 0;
|
||||
//! Return object death type
|
||||
virtual DeathType GetDying() = 0;
|
||||
//! Is object currently dying?
|
||||
virtual bool IsDying() = 0;
|
||||
};
|
||||
|
|
|
@ -424,11 +424,8 @@ bool CMotionAnt::EventFrame(const Event &event)
|
|||
m_armMember += a;
|
||||
}
|
||||
|
||||
if ( m_object->GetRuin() ) // destroyed?
|
||||
{
|
||||
m_actionType = MAS_RUIN;
|
||||
}
|
||||
if ( m_object->GetBurn() ) // burning?
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning ) // burning?
|
||||
{
|
||||
if ( m_object->GetFixed() )
|
||||
{
|
||||
|
@ -439,6 +436,10 @@ bool CMotionAnt::EventFrame(const Event &event)
|
|||
m_actionType = -1;
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<CDestroyableObject*>(m_object)->IsDying() ) // destroyed?
|
||||
{
|
||||
m_actionType = MAS_RUIN;
|
||||
}
|
||||
|
||||
for ( i=0 ; i<6 ; i++ ) // the six legs
|
||||
{
|
||||
|
|
|
@ -403,14 +403,15 @@ bool CMotionBee::EventFrame(const Event &event)
|
|||
m_actionType = -1;
|
||||
if (IsObjectCarryingCargo(m_object)) m_actionType = MBS_HOLD; // carries the ball
|
||||
|
||||
if ( m_object->GetRuin() ) // destroyed?
|
||||
{
|
||||
m_actionType = MBS_RUIN;
|
||||
}
|
||||
if ( m_object->GetBurn() ) // burning?
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning ) // burning?
|
||||
{
|
||||
m_actionType = MBS_BURN;
|
||||
}
|
||||
else if ( dynamic_cast<CDestroyableObject*>(m_object)->IsDying() ) // destroyed?
|
||||
{
|
||||
m_actionType = MBS_RUIN;
|
||||
}
|
||||
|
||||
for ( i=0 ; i<6 ; i++ ) // the six legs
|
||||
{
|
||||
|
@ -473,14 +474,12 @@ bool CMotionBee::EventFrame(const Event &event)
|
|||
|
||||
if ( m_physics->GetLand() ) // on the ground?
|
||||
{
|
||||
if ( m_object->GetRuin() )
|
||||
{
|
||||
}
|
||||
else if ( bStop || m_object->GetBurn() )
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( bStop || dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning )
|
||||
{
|
||||
m_object->SetPartRotationZ(2, sinf(m_armTimeAbs*1.7f)*0.15f+0.35f); // tail
|
||||
}
|
||||
else
|
||||
if ( !dynamic_cast<CDestroyableObject*>(m_object)->IsDying() )
|
||||
{
|
||||
a = Math::Mod(m_armTimeMarch, 1.0f);
|
||||
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
|
||||
|
|
|
@ -1462,6 +1462,7 @@ bool CMotionHuman::EventFrame(const Event &event)
|
|||
}
|
||||
}
|
||||
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
// Management of the head.
|
||||
if ( m_actionType == MHS_TAKE || // takes?
|
||||
m_actionType == MHS_FLAG ) // takes?
|
||||
|
@ -1491,10 +1492,7 @@ bool CMotionHuman::EventFrame(const Event &event)
|
|||
m_object->SetPartRotationX(1, sinf(m_armTimeAbs*0.7f)*0.10f);
|
||||
m_object->SetPartRotationY(1, sinf(m_armTimeAbs*3.0f)*0.30f*factor);
|
||||
}
|
||||
else if ( m_object->GetDead() ) // dead?
|
||||
{
|
||||
}
|
||||
else
|
||||
else if ( !dynamic_cast<CDestroyableObject*>(m_object)->IsDying() ) // dead?
|
||||
{
|
||||
m_object->SetPartRotationZ(1, Math::Smooth(m_object->GetPartRotationZ(1), sinf(m_armTimeAbs*1.0f)*0.2f, event.rTime*5.0f));
|
||||
m_object->SetPartRotationX(1, sinf(m_armTimeAbs*1.1f)*0.1f);
|
||||
|
|
|
@ -392,7 +392,8 @@ bool CMotionQueen::EventFrame(const Event &event)
|
|||
}
|
||||
}
|
||||
|
||||
if ( !bStop && !m_object->GetRuin() )
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( !bStop && !dynamic_cast<CDestroyableObject*>(m_object)->IsDying() )
|
||||
{
|
||||
a = Math::Mod(m_armTimeMarch, 1.0f);
|
||||
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
|
||||
|
|
|
@ -359,11 +359,8 @@ bool CMotionSpider::EventFrame(const Event &event)
|
|||
m_armMember += a;
|
||||
}
|
||||
|
||||
if ( m_object->GetRuin() ) // destroyed?
|
||||
{
|
||||
m_actionType = MSS_RUIN;
|
||||
}
|
||||
if ( m_object->GetBurn() ) // burning?
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if (dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning ) // burning?
|
||||
{
|
||||
if ( m_object->GetFixed() )
|
||||
{
|
||||
|
@ -374,6 +371,10 @@ bool CMotionSpider::EventFrame(const Event &event)
|
|||
m_actionType = -1;
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<CDestroyableObject*>(m_object)->IsDying() ) // destroyed?
|
||||
{
|
||||
m_actionType = MSS_RUIN;
|
||||
}
|
||||
|
||||
for ( i=0 ; i<8 ; i++ ) // the 8 legs
|
||||
{
|
||||
|
|
|
@ -1677,7 +1677,8 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
|
|||
m_armMember += a;
|
||||
}
|
||||
|
||||
if ( m_object->GetRuin() ) // burn or explode?
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( dynamic_cast<CDestroyableObject*>(m_object)->IsDying() ) // burn or explode?
|
||||
{
|
||||
action = 3;
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@ bool CMotionWorm::EventFrame(const Event &event)
|
|||
m_armTimeAbs += event.rTime;
|
||||
m_armTimeMarch += event.rTime*m_armLinSpeed;
|
||||
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
under = 0; // no piece under the ground
|
||||
for ( i=0 ; i<WORM_PART+2 ; i++ )
|
||||
{
|
||||
|
@ -271,14 +272,14 @@ bool CMotionWorm::EventFrame(const Event &event)
|
|||
{
|
||||
h = 0.0f;
|
||||
}
|
||||
if ( m_object->GetBurn() ) // is burning?
|
||||
if ( dynamic_cast<CDestroyableObject*>(m_object)->IsDying() ) // is burning?
|
||||
{
|
||||
h = 0.0f; // remains on earth
|
||||
}
|
||||
h += 0.3f;
|
||||
height[i] = h;
|
||||
}
|
||||
m_object->SetVisible(under!=WORM_PART+2);
|
||||
m_object->SetUnderground(under == WORM_PART+2);
|
||||
|
||||
if ( !m_engine->IsVisiblePoint(m_object->GetPosition()) ) return true;
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float
|
|||
|
||||
if (pObj == nullptr) continue;
|
||||
if (IsObjectBeingTransported(pObj)) continue;
|
||||
if ( !pObj->GetActive() ) continue;
|
||||
if ( !pObj->GetDetectable() ) continue;
|
||||
if ( pObj->GetProxyActivate() ) continue;
|
||||
|
||||
oType = pObj->GetType();
|
||||
|
|
|
@ -130,7 +130,7 @@ COldObject::COldObject(int id)
|
|||
m_bSelect = false;
|
||||
m_bSelectable = true;
|
||||
m_bCheckToken = true;
|
||||
m_bVisible = true;
|
||||
m_underground = false;
|
||||
m_bTrainer = false;
|
||||
m_bToy = false;
|
||||
m_bManual = false;
|
||||
|
@ -140,10 +140,8 @@ COldObject::COldObject(int id)
|
|||
m_bVirusMode = false;
|
||||
m_virusTime = 0.0f;
|
||||
m_lastVirusParticle = 0.0f;
|
||||
m_bExplo = false;
|
||||
m_bCargo = false;
|
||||
m_bBurn = false;
|
||||
m_bDead = false;
|
||||
m_dying = DeathType::Alive;
|
||||
m_bFlat = false;
|
||||
m_gunGoalV = 0.0f;
|
||||
m_gunGoalH = 0.0f;
|
||||
|
@ -339,7 +337,7 @@ bool COldObject::DamageObject(DamageType type, float force)
|
|||
assert(Implements(ObjectInterfaceType::Damageable));
|
||||
assert(!Implements(ObjectInterfaceType::Destroyable) || Implements(ObjectInterfaceType::Shielded) || Implements(ObjectInterfaceType::Fragile));
|
||||
|
||||
if ( m_bDead ) return false;
|
||||
if ( IsDying() ) return false;
|
||||
|
||||
if ( m_type == OBJECT_ANT ||
|
||||
m_type == OBJECT_WORM ||
|
||||
|
@ -438,7 +436,7 @@ void COldObject::DestroyObject(DestructionType type)
|
|||
if(type == DestructionType::NoEffect) assert(!!"DestructionType::NoEffect should not be passed to DestroyObject()!");
|
||||
assert(type != DestructionType::Drowned || m_type == OBJECT_HUMAN);
|
||||
|
||||
if ( m_bDead ) return;
|
||||
if ( IsDying() ) return;
|
||||
|
||||
if (Implements(ObjectInterfaceType::Shielded))
|
||||
{
|
||||
|
@ -511,7 +509,7 @@ void COldObject::DestroyObject(DestructionType type)
|
|||
m_type == OBJECT_BULLET )
|
||||
{
|
||||
pyroType = Gfx::PT_BURNO;
|
||||
SetBurn(true);
|
||||
SetDying(DeathType::Burning);
|
||||
}
|
||||
else if ( m_type == OBJECT_HUMAN )
|
||||
{
|
||||
|
@ -520,7 +518,7 @@ void COldObject::DestroyObject(DestructionType type)
|
|||
else
|
||||
{
|
||||
pyroType = Gfx::PT_BURNT;
|
||||
SetBurn(true);
|
||||
SetDying(DeathType::Burning);
|
||||
}
|
||||
SetVirusMode(false);
|
||||
}
|
||||
|
@ -1147,7 +1145,8 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
SetGunGoalV(line->GetParam("aimV")->AsFloat(0.0f));
|
||||
SetGunGoalH(line->GetParam("aimH")->AsFloat(0.0f));
|
||||
|
||||
m_bBurn = line->GetParam("burnMode")->AsBool(false);
|
||||
if (line->GetParam("burnMode")->AsBool(false))
|
||||
SetDying(DeathType::Burning);
|
||||
m_bVirusMode = line->GetParam("virusMode")->AsBool(false);
|
||||
m_virusTime = line->GetParam("virusTime")->AsFloat(0.0f);
|
||||
|
||||
|
@ -2032,7 +2031,7 @@ bool COldObject::EventProcess(const Event &event)
|
|||
m_type != OBJECT_SPIDER &&
|
||||
m_type != OBJECT_BEE )
|
||||
{
|
||||
if ( !m_bDead ) m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
|
||||
if ( !IsDying() ) m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
|
||||
m_main->DeselectAll();
|
||||
}
|
||||
return false;
|
||||
|
@ -2056,7 +2055,7 @@ bool COldObject::EventProcess(const Event &event)
|
|||
float axeX = 0.0f;
|
||||
float axeY = 0.0f;
|
||||
float axeZ = 0.0f;
|
||||
if ( m_bBurn ) // Gifted?
|
||||
if ( GetDying() == DeathType::Burning ) // Burning?
|
||||
{
|
||||
axeZ = -1.0f; // tomb
|
||||
|
||||
|
@ -2198,7 +2197,7 @@ bool COldObject::EventFrame(const Event &event)
|
|||
|
||||
if ( m_engine->GetPause() && m_type != OBJECT_SHOW ) return true;
|
||||
|
||||
if ( m_bBurn ) m_burnTime += event.rTime;
|
||||
if ( GetDying() == DeathType::Burning ) m_burnTime += event.rTime;
|
||||
|
||||
m_aTime += event.rTime;
|
||||
m_shotTime += event.rTime;
|
||||
|
@ -2749,13 +2748,11 @@ bool COldObject::GetCheckToken()
|
|||
}
|
||||
|
||||
|
||||
// Management of the visibility of an object.
|
||||
// The object is not hidden or visually disabled, but ignores detections!
|
||||
// For example: underground worm.
|
||||
// Sets if this object is underground or not. Underground objects are not detectable. Used by AlienWorm
|
||||
|
||||
void COldObject::SetVisible(bool bVisible)
|
||||
void COldObject::SetUnderground(bool underground)
|
||||
{
|
||||
m_bVisible = bVisible;
|
||||
m_underground = underground;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2785,55 +2782,35 @@ float COldObject::GetParam()
|
|||
}
|
||||
|
||||
|
||||
// Management of the mode "current explosion" of an object.
|
||||
// An object in this mode is not saving.
|
||||
|
||||
void COldObject::SetExploding(bool bExplo)
|
||||
void COldObject::SetDying(DeathType deathType)
|
||||
{
|
||||
m_bExplo = bExplo;
|
||||
}
|
||||
|
||||
bool COldObject::IsExploding()
|
||||
{
|
||||
return m_bExplo;
|
||||
}
|
||||
|
||||
// Management of the HS mode of an object.
|
||||
|
||||
void COldObject::SetBurn(bool bBurn)
|
||||
{
|
||||
m_bBurn = bBurn;
|
||||
m_dying = deathType;
|
||||
m_burnTime = 0.0f;
|
||||
}
|
||||
|
||||
bool COldObject::GetBurn()
|
||||
{
|
||||
return m_bBurn;
|
||||
}
|
||||
|
||||
void COldObject::SetDead(bool bDead)
|
||||
{
|
||||
m_bDead = bDead;
|
||||
|
||||
if ( bDead && Implements(ObjectInterfaceType::Programmable) )
|
||||
if ( IsDying() && Implements(ObjectInterfaceType::Programmable) )
|
||||
{
|
||||
StopProgram(); // stops the current task
|
||||
}
|
||||
}
|
||||
|
||||
bool COldObject::GetDead()
|
||||
DeathType COldObject::GetDying()
|
||||
{
|
||||
return m_bDead;
|
||||
return m_dying;
|
||||
}
|
||||
|
||||
bool COldObject::GetRuin()
|
||||
bool COldObject::IsDying()
|
||||
{
|
||||
return m_bBurn|m_bFlat;
|
||||
return m_dying != DeathType::Alive;
|
||||
}
|
||||
|
||||
bool COldObject::GetActive()
|
||||
{
|
||||
return !GetLock() && !m_bBurn && !m_bFlat && m_bVisible;
|
||||
return !GetLock() && !IsDying() && !m_bFlat;
|
||||
}
|
||||
|
||||
bool COldObject::GetDetectable()
|
||||
{
|
||||
return GetActive() && !m_underground;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
void SetSelectable(bool bMode);
|
||||
bool GetSelectable() override;
|
||||
|
||||
void SetVisible(bool bVisible);
|
||||
void SetUnderground(bool underground);
|
||||
|
||||
void SetCheckToken(bool bMode);
|
||||
bool GetCheckToken();
|
||||
|
@ -245,14 +245,12 @@ public:
|
|||
void SetParam(float value) override;
|
||||
float GetParam() override;
|
||||
|
||||
void SetExploding(bool bExplo) override;
|
||||
bool IsExploding() override;
|
||||
void SetBurn(bool bBurn) override;
|
||||
bool GetBurn() override;
|
||||
void SetDead(bool bDead) override;
|
||||
bool GetDead() override;
|
||||
bool GetRuin() override;
|
||||
void SetDying(DeathType deathType) override;
|
||||
DeathType GetDying() override;
|
||||
bool IsDying() override;
|
||||
|
||||
bool GetActive() override;
|
||||
bool GetDetectable() override;
|
||||
|
||||
void SetGunGoalV(float gunGoal);
|
||||
void SetGunGoalH(float gunGoal);
|
||||
|
@ -358,11 +356,9 @@ protected:
|
|||
bool m_bSelect; // object selected
|
||||
bool m_bSelectable; // selectable object
|
||||
bool m_bCheckToken; // object with audited tokens
|
||||
bool m_bVisible; // object active but undetectable
|
||||
bool m_bExplo;
|
||||
bool m_underground; // object active but undetectable
|
||||
bool m_bCargo;
|
||||
bool m_bBurn;
|
||||
bool m_bDead;
|
||||
DeathType m_dying;
|
||||
bool m_bFlat;
|
||||
bool m_bTrainer; // drive vehicle (without remote)
|
||||
bool m_bToy; // toy key
|
||||
|
|
|
@ -135,57 +135,20 @@ float COldObjectInterface::GetParam()
|
|||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetExploding(bool bExplo)
|
||||
{
|
||||
throw std::logic_error("SetExploding: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::IsExploding()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("IsExploding: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetBurn(bool bBurn)
|
||||
{
|
||||
throw std::logic_error("SetBurn: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetBurn()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetBurn: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetDead(bool bDead)
|
||||
{
|
||||
throw std::logic_error("SetDead: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetDead()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetDead: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetRuin()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetRuin: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetActive()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
return true;
|
||||
//throw std::logic_error("GetActive: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetDetectable()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return true;
|
||||
//throw std::logic_error("GetDetectable: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
CAuto* COldObjectInterface::GetAuto()
|
||||
{
|
||||
|
|
|
@ -102,15 +102,11 @@ public:
|
|||
virtual float GetParam();
|
||||
//@}
|
||||
|
||||
// TODO: What to do with these?
|
||||
virtual void SetExploding(bool bExplo);
|
||||
virtual bool IsExploding();
|
||||
virtual void SetBurn(bool bBurn);
|
||||
virtual bool GetBurn();
|
||||
virtual void SetDead(bool bDead);
|
||||
virtual bool GetDead();
|
||||
virtual bool GetRuin();
|
||||
// Main CObject?
|
||||
//! Is this object active (not dead)?
|
||||
virtual bool GetActive();
|
||||
//! Is this object detectable (not dead and not underground)?
|
||||
virtual bool GetDetectable();
|
||||
|
||||
// This will be eventually removed after refactoring to subclasses
|
||||
virtual CAuto* GetAuto();
|
||||
|
|
|
@ -1271,7 +1271,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
|
|||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( obj == m_object ) continue;
|
||||
if ( !obj->GetActive() ) continue;
|
||||
if ( !obj->GetDetectable() ) continue;
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
|
||||
for (const auto& objCrashSphere : obj->GetAllCrashSpheres())
|
||||
|
|
|
@ -1258,7 +1258,7 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
|
|||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( obj == m_object ) continue;
|
||||
if ( !obj->GetActive() ) continue; // inactive?
|
||||
if ( !obj->GetDetectable() ) continue; // inactive?
|
||||
if (IsObjectBeingTransported(obj)) continue;
|
||||
|
||||
for (const auto& crashSphere : obj->GetAllCrashSpheres())
|
||||
|
|
|
@ -561,7 +561,7 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
|
|||
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( pObj == m_object ) continue;
|
||||
if ( !pObj->GetActive() ) continue; // inactive?
|
||||
if ( !pObj->GetDetectable() ) continue; // inactive?
|
||||
if (IsObjectBeingTransported(pObj)) continue;
|
||||
|
||||
for (const auto& crashSphere : pObj->GetAllCrashSpheres())
|
||||
|
|
|
@ -818,7 +818,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
}
|
||||
}
|
||||
|
||||
if ( m_object->GetDead() ) // dead man?
|
||||
if ( m_object->GetType() == OBJECT_HUMAN && dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Dead ) // dead man?
|
||||
{
|
||||
motorSpeed.x = 0.0f;
|
||||
motorSpeed.z = 0.0f;
|
||||
|
@ -1455,7 +1455,7 @@ bool CPhysics::EventFrame(const Event &event)
|
|||
iAngle = angle = m_object->GetRotation();
|
||||
|
||||
// Accelerate is the descent, brake is the ascent.
|
||||
if ( m_bFreeze || m_object->GetDead() )
|
||||
if ( m_bFreeze || (m_object->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(m_object)->IsDying()) )
|
||||
{
|
||||
m_linMotion.terrainSpeed.x = 0.0f;
|
||||
m_linMotion.terrainSpeed.z = 0.0f;
|
||||
|
@ -1594,7 +1594,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
|
||||
if ( type == OBJECT_MOTHER )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f && m_object->GetActive() )
|
||||
if ( m_lastSoundInsect <= 0.0f && m_object->GetDetectable() )
|
||||
{
|
||||
m_sound->Play(SOUND_INSECTm, m_object->GetPosition());
|
||||
if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
|
||||
|
@ -1603,7 +1603,8 @@ void CPhysics::SoundMotor(float rTime)
|
|||
}
|
||||
else if ( type == OBJECT_ANT )
|
||||
{
|
||||
if ( m_object->GetBurn() ||
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning ||
|
||||
m_object->GetFixed() )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
|
@ -1612,7 +1613,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
m_lastSoundInsect = 0.4f+Math::Rand()*0.6f;
|
||||
}
|
||||
}
|
||||
else if ( m_object->GetActive() )
|
||||
else if ( m_object->GetDetectable() )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
{
|
||||
|
@ -1624,7 +1625,8 @@ void CPhysics::SoundMotor(float rTime)
|
|||
}
|
||||
else if ( type == OBJECT_BEE )
|
||||
{
|
||||
if ( m_object->GetActive() )
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( m_object->GetDetectable() )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
{
|
||||
|
@ -1633,7 +1635,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
|
||||
}
|
||||
}
|
||||
else if ( m_object->GetBurn() )
|
||||
else if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
{
|
||||
|
@ -1644,7 +1646,8 @@ void CPhysics::SoundMotor(float rTime)
|
|||
}
|
||||
else if ( type == OBJECT_WORM )
|
||||
{
|
||||
if ( m_object->GetActive() )
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( m_object->GetDetectable() )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
{
|
||||
|
@ -1653,7 +1656,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
|
||||
}
|
||||
}
|
||||
else if ( m_object->GetBurn() )
|
||||
else if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
{
|
||||
|
@ -1664,7 +1667,8 @@ void CPhysics::SoundMotor(float rTime)
|
|||
}
|
||||
else if ( type == OBJECT_SPIDER )
|
||||
{
|
||||
if ( m_object->GetBurn() ||
|
||||
assert(m_object->Implements(ObjectInterfaceType::Destroyable));
|
||||
if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning ||
|
||||
m_object->GetFixed() )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
|
@ -1673,7 +1677,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
m_lastSoundInsect = 0.4f+Math::Rand()*0.6f;
|
||||
}
|
||||
}
|
||||
else if ( m_object->GetActive() )
|
||||
else if ( m_object->GetDetectable() )
|
||||
{
|
||||
if ( m_lastSoundInsect <= 0.0f )
|
||||
{
|
||||
|
@ -1687,7 +1691,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
{
|
||||
if ( !m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
if ( m_bMotor && m_object->GetActive() )
|
||||
if ( m_bMotor && m_object->GetDetectable() )
|
||||
{
|
||||
SoundMotorFull(rTime, type); // full diet
|
||||
}
|
||||
|
@ -1710,7 +1714,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
if ( m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
if ( m_bMotor && !m_bSwim &&
|
||||
m_object->GetActive() && !m_object->GetDead() )
|
||||
m_object->GetDetectable() )
|
||||
{
|
||||
SoundReactorFull(rTime, type); // full diet
|
||||
}
|
||||
|
@ -1774,7 +1778,7 @@ void CPhysics::WaterFrame(float aTime, float rTime)
|
|||
if ( type == OBJECT_TOTO ) return;
|
||||
if ( type == OBJECT_NULL ) return;
|
||||
|
||||
if ( !m_object->GetActive() ) return;
|
||||
if ( !m_object->GetDetectable() ) return;
|
||||
|
||||
if (type == OBJECT_HUMAN && m_object->GetOption() != 0 ) // human without a helmet?)
|
||||
{
|
||||
|
@ -2468,7 +2472,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
int colType;
|
||||
ObjectType iType, oType;
|
||||
|
||||
if ( m_object->GetRuin() ) return 0; // is burning or exploding?
|
||||
if ( m_object->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(m_object)->IsDying() ) return 0; // is burning or exploding?
|
||||
if ( !m_object->GetCollisions() ) return 0;
|
||||
|
||||
// iiPos = sphere center is the old position.
|
||||
|
@ -2487,8 +2491,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
{
|
||||
if ( pObj == m_object ) continue; // yourself?
|
||||
if (IsObjectBeingTransported(pObj)) continue;
|
||||
if ( pObj->GetRuin() ) continue; // is burning or exploding?
|
||||
if ( pObj->GetDead() ) continue; // dead man?
|
||||
if ( pObj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(pObj)->IsDying() ) continue; // is burning or exploding?
|
||||
|
||||
oType = pObj->GetType();
|
||||
if ( oType == OBJECT_NULL ) continue;
|
||||
|
@ -3443,7 +3446,7 @@ void CPhysics::MotorParticle(float aTime, float rTime)
|
|||
|
||||
if ( (type == OBJECT_HUMAN || type == OBJECT_TECH) && m_bSwim )
|
||||
{
|
||||
if ( !m_object->GetDead() )
|
||||
if ( !m_object->Implements(ObjectInterfaceType::Destroyable) || dynamic_cast<CDestroyableObject*>(m_object)->GetDying() != DeathType::Dead )
|
||||
{
|
||||
h = Math::Mod(aTime, 5.0f);
|
||||
if ( h < 3.5f && ( h < 1.5f || h > 1.6f ) ) return;
|
||||
|
|
|
@ -1147,7 +1147,7 @@ void CMap::UpdateObject(CObject* pObj)
|
|||
if ( !m_bEnable ) return;
|
||||
if ( m_totalFix >= m_totalMove ) return; // full table?
|
||||
|
||||
if ( !pObj->GetActive() ) return;
|
||||
if ( !pObj->GetDetectable() ) return;
|
||||
if ( pObj->Implements(ObjectInterfaceType::Controllable) && !dynamic_cast<CControllableObject*>(pObj)->GetSelectable() ) return;
|
||||
if ( pObj->GetProxyActivate() ) return;
|
||||
if (IsObjectBeingTransported(pObj)) return;
|
||||
|
|
|
@ -140,7 +140,7 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
|
|||
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( !obj->GetActive() ) continue;
|
||||
if ( !obj->GetDetectable() ) continue;
|
||||
if ( obj->GetProxyActivate() ) continue;
|
||||
if ( obj->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject*>(obj)->GetSelect() ) continue;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ bool CMainShort::CreateShortcuts()
|
|||
std::vector<int> teams;
|
||||
for (CObject* object : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if (!object->GetActive())
|
||||
if (!object->GetDetectable())
|
||||
continue;
|
||||
|
||||
if(GetShortcutIcon(object->GetType()) == -1)
|
||||
|
@ -144,7 +144,7 @@ bool CMainShort::CreateShortcuts()
|
|||
int rank = 0;
|
||||
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( !pObj->GetActive() ) continue;
|
||||
if ( !pObj->GetDetectable() ) continue;
|
||||
if ( pObj->Implements(ObjectInterfaceType::Controllable) && !dynamic_cast<CControllableObject*>(pObj)->GetSelectable() ) continue;
|
||||
if ( pObj->GetProxyActivate() ) continue;
|
||||
|
||||
|
|
Loading…
Reference in New Issue