Convert all Create(PyroType) to Create(unique_ptr<CPyro>) so pyro manager doesn't need to know the different types
parent
1202df22ae
commit
72e7c19cd3
|
@ -45,8 +45,10 @@ namespace Gfx
|
|||
{
|
||||
|
||||
|
||||
CPyro::CPyro()
|
||||
CPyro::CPyro(PyroType type, CObject *obj)
|
||||
{
|
||||
m_object = obj;
|
||||
m_type = type;
|
||||
m_engine = CEngine::GetInstancePointer();
|
||||
m_main = CRobotMain::GetInstancePointer();
|
||||
m_terrain = m_main->GetTerrain();
|
||||
|
@ -68,21 +70,17 @@ void CPyro::DeleteObject()
|
|||
m_lightRank = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool CPyro::Create(PyroType type, CObject* obj, float force)
|
||||
bool CPyro::Create()
|
||||
{
|
||||
m_object = obj;
|
||||
m_force = force;
|
||||
|
||||
ObjectType oType = obj->GetType();
|
||||
int objRank = obj->GetObjectRank(0);
|
||||
ObjectType oType = m_object->GetType();
|
||||
int objRank = m_object->GetObjectRank(0);
|
||||
if (objRank == -1) return false;
|
||||
|
||||
Math::Vector min, max;
|
||||
m_engine->GetObjectBBox(objRank, min, max);
|
||||
Math::Vector pos = obj->GetPosition();
|
||||
Math::Vector pos = m_object->GetPosition();
|
||||
|
||||
for (const auto& crashSphere : obj->GetAllCrashSpheres())
|
||||
for (const auto& crashSphere : m_object->GetAllCrashSpheres())
|
||||
{
|
||||
m_crashSpheres.push_back(crashSphere.sphere);
|
||||
}
|
||||
|
@ -108,7 +106,6 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
}
|
||||
|
||||
m_pos = pos+(min+max)/2.0f;
|
||||
m_type = type;
|
||||
m_progress = 0.0f;
|
||||
m_speed = 1.0f/20.0f; m_time = 0.0f;
|
||||
m_lastParticle = 0.0f;
|
||||
|
@ -124,8 +121,8 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
// Seeking the position of the battery.
|
||||
|
||||
CObject* power = nullptr;
|
||||
if (obj->Implements(ObjectInterfaceType::Powered))
|
||||
power = dynamic_cast<CPoweredObject&>(*obj).GetPower();
|
||||
if (m_object->Implements(ObjectInterfaceType::Powered))
|
||||
power = dynamic_cast<CPoweredObject&>(*m_object).GetPower();
|
||||
|
||||
if (power == nullptr)
|
||||
{
|
||||
|
@ -136,7 +133,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
m_power = true;
|
||||
pos = power->GetPosition();
|
||||
pos.y += 1.0f;
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
Math::Matrix* mat = m_object->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(*mat, pos);
|
||||
}
|
||||
|
||||
|
@ -154,14 +151,14 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
if ( oType == OBJECT_STATION )
|
||||
{
|
||||
m_power = true;
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
Math::Matrix* mat = m_object->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(*mat, Math::Vector(-15.0f, 7.0f, 0.0f));
|
||||
m_pos = m_posPower;
|
||||
}
|
||||
if ( oType == OBJECT_ENERGY )
|
||||
{
|
||||
m_power = true;
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(0);
|
||||
Math::Matrix* mat = m_object->GetWorldMatrix(0);
|
||||
m_posPower = Math::Transform(*mat, Math::Vector(-7.0f, 6.0f, 0.0f));
|
||||
m_pos = m_posPower;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ protected:
|
|||
friend class CPyroManager;
|
||||
|
||||
//! Creates pyrotechnic effect
|
||||
bool Create(PyroType type, CObject* obj, float force);
|
||||
bool Create();
|
||||
//! Destroys the object
|
||||
void DeleteObject();
|
||||
|
||||
|
@ -74,7 +74,7 @@ protected:
|
|||
virtual void AfterEnd();
|
||||
|
||||
public:
|
||||
CPyro(); // should only be called by CPyroManager
|
||||
CPyro(PyroType type, CObject *obj);
|
||||
virtual ~CPyro();
|
||||
|
||||
//! Indicates whether the pyrotechnic effect is complete
|
||||
|
@ -116,7 +116,6 @@ protected:
|
|||
Math::Vector m_posPower; // center of the battery
|
||||
bool m_power = false; // battery exists?
|
||||
PyroType m_type = PT_NULL;
|
||||
float m_force = 0.0f;
|
||||
float m_size = 0.0f;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
|
@ -163,6 +162,7 @@ protected:
|
|||
class CFlagCreatePyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CFlagCreatePyro(CObject *pObj);
|
||||
void AfterCreate() override;
|
||||
void UpdateEffect() override;
|
||||
void AfterEnd() override;
|
||||
|
@ -171,6 +171,7 @@ public:
|
|||
class CFlagDeletePyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CFlagDeletePyro(CObject *pObj);
|
||||
void AfterCreate() override;
|
||||
void UpdateEffect() override;
|
||||
void AfterEnd() override;
|
||||
|
@ -179,6 +180,7 @@ public:
|
|||
class CWaypointHitPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CWaypointHitPyro(CObject *obj);
|
||||
void AfterCreate() override;
|
||||
void UpdateEffect() override;
|
||||
void AfterEnd() override;
|
||||
|
@ -187,6 +189,8 @@ public:
|
|||
class CFallPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CFallPyro(CObject *obj);
|
||||
|
||||
//! Start of an object freight falling
|
||||
void AfterCreate() override;
|
||||
//! Seeks an object to explode by the falling ball of bees
|
||||
|
@ -202,6 +206,7 @@ public:
|
|||
class CResetPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CResetPyro(CObject *obj);
|
||||
void AfterCreate() override;
|
||||
void UpdateEffect() override;
|
||||
void AfterEnd() override;
|
||||
|
@ -210,6 +215,7 @@ public:
|
|||
class CLostPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CLostPyro(CObject *obj);
|
||||
Error IsEnded() override;
|
||||
void UpdateEffect() override;
|
||||
};
|
||||
|
@ -217,6 +223,7 @@ public:
|
|||
class CWinPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CWinPyro(CObject *obj);
|
||||
Error IsEnded() override;
|
||||
void UpdateEffect() override;
|
||||
};
|
||||
|
@ -224,6 +231,7 @@ public:
|
|||
class CSpiderPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CSpiderPyro(CObject *obj);
|
||||
Error IsEnded() override;
|
||||
void AfterCreate() override;
|
||||
};
|
||||
|
@ -231,6 +239,7 @@ public:
|
|||
class CEggPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CEggPyro(CObject *obj);
|
||||
Error IsEnded() override;
|
||||
void AfterCreate() override;
|
||||
};
|
||||
|
@ -238,18 +247,21 @@ public:
|
|||
class CDeadGPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CDeadGPyro(CObject *obj);
|
||||
void AfterCreate() override;
|
||||
};
|
||||
|
||||
class CDeadWPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CDeadWPyro(CObject *obj);
|
||||
void AfterCreate() override;
|
||||
};
|
||||
|
||||
class CFindingPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CFindingPyro(CObject *obj);
|
||||
void AfterCreate() override;
|
||||
void UpdateEffect() override;
|
||||
};
|
||||
|
@ -257,6 +269,7 @@ public:
|
|||
class CSquashPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CSquashPyro(CObject *obj);
|
||||
void AfterCreate() override;
|
||||
void UpdateEffect() override;
|
||||
void AfterEnd() override;
|
||||
|
@ -265,6 +278,7 @@ public:
|
|||
class CFragVPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CFragVPyro(CObject *obj);
|
||||
Error IsEnded() override;
|
||||
void AfterCreate() override;
|
||||
};
|
||||
|
@ -272,6 +286,7 @@ public:
|
|||
class CBurnPyro : public CPyro
|
||||
{
|
||||
public:
|
||||
CBurnPyro(PyroType type, CObject *obj);
|
||||
void AfterCreate() override;
|
||||
void UpdateEffect() override;
|
||||
|
||||
|
@ -289,7 +304,9 @@ public:
|
|||
|
||||
class CFragExploOrShotPyro : public CPyro
|
||||
{
|
||||
float m_force;
|
||||
public:
|
||||
CFragExploOrShotPyro(PyroType type, CObject *obj, float force = 1.0f);
|
||||
void AfterCreate() override;
|
||||
Error IsEnded() override;
|
||||
void UpdateEffect() override;
|
||||
|
|
|
@ -35,47 +35,9 @@ Gfx::CPyroManager::CPyroManager()
|
|||
CPyroManager::~CPyroManager()
|
||||
{}
|
||||
|
||||
void Gfx::CPyroManager::Create(PyroType type, CObject* obj, float force)
|
||||
void Gfx::CPyroManager::Create(CPyroUPtr pyroUPtr)
|
||||
{
|
||||
std::unique_ptr<CPyro> pyroUPtr;
|
||||
switch (type)
|
||||
{
|
||||
case PT_FRAGT:
|
||||
case PT_FRAGO:
|
||||
case PT_FRAGW:
|
||||
case PT_EXPLOT:
|
||||
case PT_EXPLOO:
|
||||
case PT_EXPLOW:
|
||||
case PT_SHOTT:
|
||||
case PT_SHOTH:
|
||||
case PT_SHOTM:
|
||||
case PT_SHOTW:
|
||||
pyroUPtr = MakeUnique<CFragExploOrShotPyro>();
|
||||
break;
|
||||
case PT_BURNT:
|
||||
case PT_BURNO:
|
||||
pyroUPtr = MakeUnique<CBurnPyro>();
|
||||
break;
|
||||
case PT_FLCREATE: pyroUPtr = MakeUnique<CFlagCreatePyro>(); break;
|
||||
case PT_FLDELETE: pyroUPtr = MakeUnique<CFlagDeletePyro>(); break;
|
||||
case PT_WPCHECK: pyroUPtr = MakeUnique<CWaypointHitPyro>(); break;
|
||||
case PT_FALL: pyroUPtr = MakeUnique<CFallPyro>(); break;
|
||||
case PT_RESET: pyroUPtr = MakeUnique<CResetPyro>(); break;
|
||||
case PT_LOST: pyroUPtr = MakeUnique<CLostPyro>(); break;
|
||||
case PT_WIN: pyroUPtr = MakeUnique<CWinPyro>(); break;
|
||||
case PT_SPIDER: pyroUPtr = MakeUnique<CSpiderPyro>(); break;
|
||||
case PT_DEADG: pyroUPtr = MakeUnique<CDeadGPyro>(); break;
|
||||
case PT_DEADW: pyroUPtr = MakeUnique<CDeadWPyro>(); break;
|
||||
case PT_FINDING: pyroUPtr = MakeUnique<CFindingPyro>(); break;
|
||||
case PT_SQUASH: pyroUPtr = MakeUnique<CSquashPyro>(); break;
|
||||
case PT_FRAGV: pyroUPtr = MakeUnique<CFragVPyro>(); break;
|
||||
default:
|
||||
// shouldn't get here
|
||||
assert(false);
|
||||
pyroUPtr = MakeUnique<CPyro>();
|
||||
break;
|
||||
}
|
||||
pyroUPtr->Create(type, obj, force);
|
||||
pyroUPtr->Create();
|
||||
m_pyros.insert(std::move(pyroUPtr));
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
CPyroManager();
|
||||
~CPyroManager();
|
||||
|
||||
void Create(PyroType type, CObject* obj, float force=1.0f);
|
||||
void Create(CPyroUPtr pyroUPtr);
|
||||
void DeleteAll();
|
||||
|
||||
void CutObjectLink(CObject* obj);
|
||||
|
|
|
@ -52,18 +52,11 @@ enum PyroType
|
|||
PT_BURNT = 14, //! < burning of technical object
|
||||
PT_BURNO = 15, //! < burning of organic object
|
||||
PT_SPIDER = 16, //! < spider explosion
|
||||
PT_FALL = 17, //! < cargo falling
|
||||
PT_WPCHECK = 18, //! < indicator reaches
|
||||
PT_FLCREATE = 19, //! < flag create
|
||||
PT_FLDELETE = 20, //! < flag destroy
|
||||
PT_RESET = 21, //! < reset position of the object
|
||||
PT_WIN = 22, //! < fireworks
|
||||
PT_LOST = 23, //! < black smoke
|
||||
PT_DEADG = 24, //! < shooting death
|
||||
PT_DEADW = 25, //! < drowning death
|
||||
PT_FINDING = 26, //! < object discovered
|
||||
PT_FRAGV = 27, //! < fragmentation of plant object
|
||||
PT_SQUASH = 28, //! < flattening plants
|
||||
|
||||
PT_OTHER = 100, //! < No special type code; behaviour is decided by subclass
|
||||
};
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CBurnPyro::CBurnPyro(PyroType type, CObject *obj)
|
||||
: CPyro(type, obj)
|
||||
{}
|
||||
|
||||
void CBurnPyro::AfterCreate()
|
||||
{
|
||||
assert( m_type == PT_BURNT || m_type == PT_BURNO );
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
using namespace Gfx;
|
||||
|
||||
|
||||
CDeadGPyro::CDeadGPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CDeadGPyro::AfterCreate()
|
||||
{
|
||||
if (m_object->GetType() == OBJECT_HUMAN)
|
||||
|
@ -53,6 +57,10 @@ void CDeadGPyro::AfterCreate()
|
|||
m_speed = 1.0f/10.0f;
|
||||
}
|
||||
|
||||
CDeadWPyro::CDeadWPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CDeadWPyro::AfterCreate()
|
||||
{
|
||||
if (m_object->GetType() == OBJECT_HUMAN)
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CEggPyro::CEggPyro(CObject *obj)
|
||||
: CPyro(PT_EGG, obj)
|
||||
{}
|
||||
|
||||
Error CEggPyro::IsEnded() {
|
||||
// Destroys the object that exploded.
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CFallPyro::CFallPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CFallPyro::AfterCreate()
|
||||
{
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CFindingPyro::CFindingPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CFindingPyro::AfterCreate()
|
||||
{
|
||||
float limit = (m_size-1.0f)/4.0f;
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CFlagCreatePyro::CFlagCreatePyro(CObject *pObj)
|
||||
: CPyro(PT_OTHER, pObj)
|
||||
{}
|
||||
|
||||
void CFlagCreatePyro::AfterCreate()
|
||||
{
|
||||
m_sound->Play(SOUND_WAYPOINT, m_pos);
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CFlagDeletePyro::CFlagDeletePyro(CObject *pObj)
|
||||
: CPyro(PT_OTHER, pObj)
|
||||
{}
|
||||
|
||||
void CFlagDeletePyro::AfterCreate()
|
||||
{
|
||||
m_sound->Play(SOUND_WAYPOINT, m_pos);
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CFragExploOrShotPyro::CFragExploOrShotPyro(PyroType type, CObject *obj, float force)
|
||||
: CPyro(type, obj),
|
||||
m_force(force)
|
||||
{}
|
||||
|
||||
void CFragExploOrShotPyro::AfterCreate()
|
||||
{
|
||||
ObjectType oType = m_object->GetType();
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
using namespace Gfx;
|
||||
|
||||
|
||||
CFragVPyro::CFragVPyro(CObject *obj)
|
||||
: CPyro(PT_FRAGV, obj)
|
||||
{}
|
||||
|
||||
Error CFragVPyro::IsEnded() {
|
||||
// Destroys the object that exploded.
|
||||
//It should not be destroyed at the end of the Create,
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CResetPyro::CResetPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CResetPyro::AfterCreate()
|
||||
{
|
||||
m_speed = 1.0f/2.0f;
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CSpiderPyro::CSpiderPyro(CObject *obj)
|
||||
: CPyro(PT_SPIDER, obj)
|
||||
{}
|
||||
|
||||
Error CSpiderPyro::IsEnded() {
|
||||
// Destroys the object that exploded.
|
||||
//It should not be destroyed at the end of the Create,
|
||||
|
@ -99,5 +103,5 @@ void CSpiderPyro::AfterCreate()
|
|||
2.0f+Math::Rand()*2.0f, 10.0f, 2.0f, 0.6f);
|
||||
}
|
||||
|
||||
m_camera->StartEffect(CAM_EFFECT_EXPLO, m_pos, m_force);
|
||||
m_camera->StartEffect(CAM_EFFECT_EXPLO, m_pos, 1.0f);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CSquashPyro::CSquashPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CSquashPyro::AfterCreate()
|
||||
{
|
||||
m_speed = 1.0f/2.0f;
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CWaypointHitPyro::CWaypointHitPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CWaypointHitPyro::AfterCreate()
|
||||
{
|
||||
m_sound->Play(SOUND_WAYPOINT, m_pos);
|
||||
|
|
|
@ -28,6 +28,14 @@
|
|||
|
||||
using namespace Gfx;
|
||||
|
||||
CWinPyro::CWinPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
CLostPyro::CLostPyro(CObject *obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
void CWinPyro::UpdateEffect()
|
||||
{
|
||||
if ( m_object == nullptr )
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
#include "graphics/model/model_manager.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/mainmovie.h"
|
||||
|
@ -2045,7 +2046,7 @@ bool CRobotMain::DestroySelectedObject()
|
|||
if (obj == nullptr) return false;
|
||||
assert(obj->Implements(ObjectInterfaceType::Controllable));
|
||||
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FRAGT, obj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_FRAGT, obj));
|
||||
NotifyObjectDestroyed(obj);
|
||||
|
||||
dynamic_cast<CControllableObject&>(*obj).SetSelect(false); // deselects the object
|
||||
|
@ -2404,7 +2405,7 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
obj->SetProxyActivate(false);
|
||||
CreateShortcuts();
|
||||
m_sound->Play(SOUND_FINDING);
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FINDING, obj, 0.0f);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFindingPyro>(obj));
|
||||
DisplayError(INFO_FINDING, obj);
|
||||
}
|
||||
}
|
||||
|
@ -5042,7 +5043,7 @@ void CRobotMain::ResetCreate()
|
|||
{
|
||||
if (obj->GetAnimateOnReset())
|
||||
{
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_RESET, obj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CResetPyro>(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "common/make_unique.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/parser/parserline.h"
|
||||
|
@ -249,7 +250,7 @@ Error CAutoEgg::IsEnded()
|
|||
{
|
||||
if ( m_progress < 1.0f ) return ERR_CONTINUE;
|
||||
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_EGG, m_object); // exploding egg
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CEggPyro>(m_object)); // exploding egg
|
||||
|
||||
alien->SetScale(1.0f); // this is a big boy now
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/robotmain.h"
|
||||
|
@ -451,15 +452,15 @@ bool COldObject::DamageObject(DamageType type, float force, CObject* killer)
|
|||
|
||||
if ( m_type == OBJECT_HUMAN )
|
||||
{
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_SHOTH, this, loss);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_SHOTH, this, loss));
|
||||
}
|
||||
else if ( m_type == OBJECT_MOTHER )
|
||||
{
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_SHOTM, this, loss);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_SHOTM, this, loss));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_SHOTT, this, loss);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_SHOTT, this, loss));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -479,7 +480,6 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer)
|
|||
SetDamaging(false);
|
||||
}
|
||||
|
||||
Gfx::PyroType pyroType = Gfx::PT_NULL;
|
||||
if ( type == DestructionType::Explosion ) // explosion?
|
||||
{
|
||||
if ( m_type == OBJECT_ANT ||
|
||||
|
@ -487,17 +487,20 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer)
|
|||
m_type == OBJECT_BEE ||
|
||||
m_type == OBJECT_WORM )
|
||||
{
|
||||
pyroType = Gfx::PT_EXPLOO;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_EXPLOO, this, 1.0f));
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
else if ( m_type == OBJECT_MOTHER ||
|
||||
m_type == OBJECT_NEST ||
|
||||
m_type == OBJECT_BULLET )
|
||||
{
|
||||
pyroType = Gfx::PT_FRAGO;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_FRAGO, this, 1.0f));
|
||||
SetDying(DeathType::Exploding);
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
else if ( m_type == OBJECT_HUMAN )
|
||||
{
|
||||
pyroType = Gfx::PT_DEADG;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CDeadGPyro>(this));
|
||||
}
|
||||
else if ( m_type == OBJECT_BASE ||
|
||||
m_type == OBJECT_DERRICK ||
|
||||
|
@ -525,20 +528,27 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer)
|
|||
m_type == OBJECT_RUINradar ||
|
||||
m_type == OBJECT_RUINconvert ) // building?
|
||||
{
|
||||
pyroType = Gfx::PT_FRAGT;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_FRAGT, this, 1.0f));
|
||||
SetDying(DeathType::Exploding);
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
else if ( m_type == OBJECT_MOBILEtg )
|
||||
{
|
||||
pyroType = Gfx::PT_FRAGT;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_FRAGT, this, 1.0f));
|
||||
SetDying(DeathType::Exploding);
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
pyroType = Gfx::PT_EXPLOT;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_EXPLOT, this, 1.0f));
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
}
|
||||
else if ( type == DestructionType::ExplosionWater )
|
||||
{
|
||||
pyroType = Gfx::PT_FRAGW;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_FRAGW, this, 1.0f));
|
||||
SetDying(DeathType::Exploding);
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
else if ( type == DestructionType::Burn ) // burning?
|
||||
{
|
||||
|
@ -549,51 +559,39 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer)
|
|||
m_type == OBJECT_WORM ||
|
||||
m_type == OBJECT_BULLET )
|
||||
{
|
||||
pyroType = Gfx::PT_BURNO;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CBurnPyro>(Gfx::PT_BURNO, this));
|
||||
SetDying(DeathType::Burning);
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
else if ( m_type == OBJECT_HUMAN )
|
||||
{
|
||||
pyroType = Gfx::PT_DEADG;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CDeadGPyro>(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
pyroType = Gfx::PT_BURNT;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CBurnPyro>(Gfx::PT_BURNT, this));
|
||||
SetDying(DeathType::Burning);
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
}
|
||||
SetVirusMode(false);
|
||||
}
|
||||
else if ( type == DestructionType::Drowned )
|
||||
{
|
||||
pyroType = Gfx::PT_DEADW;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CDeadWPyro>(this));
|
||||
}
|
||||
else if ( type == DestructionType::Win )
|
||||
{
|
||||
pyroType = Gfx::PT_WPCHECK;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CWaypointHitPyro>(this));
|
||||
}
|
||||
else if ( type == DestructionType::Squash )
|
||||
{
|
||||
pyroType = Gfx::PT_SQUASH;
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CSquashPyro>(this));
|
||||
DeleteAllCrashSpheres();
|
||||
}
|
||||
assert(pyroType != Gfx::PT_NULL);
|
||||
if (pyroType == Gfx::PT_FRAGT ||
|
||||
pyroType == Gfx::PT_FRAGO ||
|
||||
pyroType == Gfx::PT_FRAGW)
|
||||
else
|
||||
{
|
||||
SetDying(DeathType::Exploding);
|
||||
}
|
||||
m_engine->GetPyroManager()->Create(pyroType, this);
|
||||
if ( pyroType == Gfx::PT_FRAGT ||
|
||||
pyroType == Gfx::PT_FRAGO ||
|
||||
pyroType == Gfx::PT_FRAGW ||
|
||||
pyroType == Gfx::PT_EXPLOT ||
|
||||
pyroType == Gfx::PT_EXPLOO ||
|
||||
pyroType == Gfx::PT_EXPLOW ||
|
||||
pyroType == Gfx::PT_BURNT ||
|
||||
pyroType == Gfx::PT_BURNO )
|
||||
{
|
||||
m_main->NotifyObjectDestroyed(this);
|
||||
// should be unreachable
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if ( Implements(ObjectInterfaceType::Programmable) )
|
||||
|
@ -1166,8 +1164,18 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
SetCameraType(line->GetParam("camera")->AsCameraType());
|
||||
SetCameraLock(line->GetParam("cameraLock")->AsBool(false));
|
||||
|
||||
if (line->GetParam("pyro")->IsDefined())
|
||||
m_engine->GetPyroManager()->Create(line->GetParam("pyro")->AsPyroType(), this);
|
||||
if (line->GetParam("pyro")->IsDefined()) {
|
||||
switch(line->GetParam("pyro")->AsPyroType()) {
|
||||
case Gfx::PT_WIN:
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CWinPyro>(this));
|
||||
break;
|
||||
case Gfx::PT_LOST:
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CLostPyro>(this));
|
||||
break;
|
||||
default:
|
||||
assert(false); // unreachable
|
||||
}
|
||||
}
|
||||
|
||||
SetBulletWall(line->GetParam("bulletWall")->AsBool(IsBulletWallByDefault(m_type)));
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/robotmain.h"
|
||||
|
@ -90,6 +91,6 @@ void CTaskDeleteMark::DeleteMark()
|
|||
|
||||
if (obj != nullptr)
|
||||
{
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_WPCHECK, obj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CWaypointHitPyro>(obj));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/water.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "math/geometry.h"
|
||||
|
@ -284,7 +285,7 @@ Error CTaskFlag::CreateFlag(int rank)
|
|||
//pNew->SetScale(0.0f);
|
||||
|
||||
m_sound->Play(SOUND_WAYPOINT, pos);
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FLCREATE, pNew);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFlagCreatePyro>(pNew));
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -322,7 +323,7 @@ Error CTaskFlag::DeleteFlag()
|
|||
|
||||
m_sound->Play(SOUND_WAYPOINT, iPos);
|
||||
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FLDELETE, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFlagDeletePyro>(pObj));
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/robotmain.h"
|
||||
|
@ -324,7 +325,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
|
|||
pos.y += 2.0f;
|
||||
m_object->SetPosition(pos); // against the top of jump
|
||||
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FALL, other); // the ball falls
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFallPyro>(other)); // the ball falls
|
||||
}
|
||||
|
||||
m_bBee = true;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "graphics/engine/engine.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/robotmain.h"
|
||||
|
@ -100,7 +101,7 @@ Error CTaskSpiderExplo::IsEnded()
|
|||
|
||||
if ( m_time < 1.0f ) return ERR_CONTINUE;
|
||||
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_SPIDER, m_object); // the spider explodes (suicide)
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CSpiderPyro>(m_object)); // the spider explodes (suicide)
|
||||
m_main->NotifyObjectDestroyed(m_object);
|
||||
|
||||
Abort();
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/robotmain.h"
|
||||
|
@ -420,14 +421,14 @@ bool CTaskTerraform::Terraform()
|
|||
type == OBJECT_EGG ) // Alien Organic?
|
||||
{
|
||||
if ( dist > 5.0f ) continue;
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FRAGO, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_FRAGO, pObj, 1.0f));
|
||||
m_main->NotifyObjectDestroyed(pObj);
|
||||
}
|
||||
else if ( type == OBJECT_TNT ||
|
||||
type == OBJECT_BOMB ) // Explosives?
|
||||
{
|
||||
if ( dist > 5.0f ) continue;
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_EXPLOT, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_EXPLOT, pObj, 1.0f));
|
||||
m_main->NotifyObjectDestroyed(pObj);
|
||||
dynamic_cast<CDamageableObject&>(*m_object).DamageObject(DamageType::Explosive, 0.9f);
|
||||
}
|
||||
|
@ -446,13 +447,13 @@ bool CTaskTerraform::Terraform()
|
|||
type == OBJECT_PLANT19 ) // Plants?
|
||||
{
|
||||
if ( dist > 7.5f ) continue;
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FRAGV, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragVPyro>(pObj));
|
||||
|
||||
}
|
||||
else // Other?
|
||||
{
|
||||
if ( dist > 5.0f ) continue;
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_FRAGT, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_FRAGT, pObj, 1.0f));
|
||||
m_main->NotifyObjectDestroyed(pObj);
|
||||
}
|
||||
}
|
||||
|
@ -476,12 +477,12 @@ bool CTaskTerraform::Terraform()
|
|||
dynamic_cast<CBaseAlien&>(*pObj).SetFixed(true); // not moving
|
||||
|
||||
if ( dist > 5.0f ) continue;
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_EXPLOO, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_EXPLOO, pObj, 1.0f));
|
||||
}
|
||||
else if ( type == OBJECT_BEE || type == OBJECT_WORM )
|
||||
{
|
||||
if ( dist > 5.0f ) continue;
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_EXPLOO, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CFragExploOrShotPyro>(Gfx::PT_EXPLOO, pObj, 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/engine/water.h"
|
||||
|
||||
#include "graphics/pyro/pyro.h"
|
||||
#include "graphics/pyro/pyro_manager.h"
|
||||
|
||||
#include "level/robotmain.h"
|
||||
|
@ -2546,7 +2547,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
if ( distance < 4.0f )
|
||||
{
|
||||
m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition());
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_WPCHECK, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CWaypointHitPyro>(pObj));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2557,7 +2558,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
if ( distance < 10.0f*1.5f )
|
||||
{
|
||||
m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition());
|
||||
m_engine->GetPyroManager()->Create(Gfx::PT_WPCHECK, pObj);
|
||||
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CWaypointHitPyro>(pObj));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue