Move more pyro behaviour into subclasses (particle speed, mass, percentage)
parent
72e7c19cd3
commit
02c5cb7aa7
|
@ -328,7 +328,7 @@ void CPyro::DeleteObject(bool primary, bool secondary)
|
|||
}
|
||||
}
|
||||
|
||||
void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
|
||||
void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part, float maxHParticleSpeed, float maxVParticleSpeed, float minParticleMass, float maxParticleMass, float overridePercent)
|
||||
{
|
||||
int objRank = obj->GetObjectRank(part);
|
||||
if (objRank == -1) return;
|
||||
|
@ -340,9 +340,9 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
|
|||
if (total < 50) percent = 0.25f;
|
||||
if (total < 20) percent = 0.50f;
|
||||
|
||||
if ( m_type == PT_FRAGV || m_type == PT_EGG )
|
||||
if ( overridePercent >= 0 )
|
||||
{
|
||||
percent = 0.30f;
|
||||
percent = overridePercent;
|
||||
}
|
||||
|
||||
if (oType == OBJECT_POWER ||
|
||||
|
@ -434,27 +434,10 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
|
|||
|
||||
Math::Matrix* mat = obj->GetWorldMatrix(part);
|
||||
Math::Vector pos = Math::Transform(*mat, offset);
|
||||
if ( m_type == PT_FRAGV || m_type == PT_EGG )
|
||||
{
|
||||
speed.x = (Math::Rand()-0.5f)*10.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*10.0f;
|
||||
speed.y = Math::Rand()*15.0f;
|
||||
mass = Math::Rand()*20.0f+20.0f;
|
||||
}
|
||||
else if ( m_type == PT_SPIDER )
|
||||
{
|
||||
speed.x = (Math::Rand()-0.5f)*10.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*10.0f;
|
||||
speed.y = Math::Rand()*20.0f;
|
||||
mass = Math::Rand()*10.0f+15.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed.x = (Math::Rand()-0.5f)*30.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*30.0f;
|
||||
speed.y = Math::Rand()*30.0f;
|
||||
mass = Math::Rand()*10.0f+15.0f;
|
||||
}
|
||||
speed.x = (Math::Rand()-0.5f)*2.0f*maxHParticleSpeed;
|
||||
speed.z = (Math::Rand()-0.5f)*2.0f*maxHParticleSpeed;
|
||||
speed.y = Math::Rand()*maxVParticleSpeed;
|
||||
mass = Math::Rand()*(maxParticleMass-minParticleMass) + minParticleMass;
|
||||
if ( oType == OBJECT_STONE ) speed *= 0.5f;
|
||||
if ( oType == OBJECT_URANIUM ) speed *= 0.4f;
|
||||
float duration = Math::Rand()*3.0f+3.0f;
|
||||
|
|
|
@ -93,7 +93,12 @@ protected:
|
|||
void DeleteObject(bool primary, bool secondary);
|
||||
|
||||
//! Creates an explosion with triangular form of particles
|
||||
void CreateTriangle(CObject* obj, ObjectType oType, int part);
|
||||
void CreateTriangle(CObject* obj, ObjectType oType, int part,
|
||||
float maxHParticleSpeed = 15.0f,
|
||||
float maxVParticleSpeed = 30.0f,
|
||||
float minParticleMass = 15.0f,
|
||||
float maxParticleMass = 25.0f,
|
||||
float overridePercent = -1);
|
||||
|
||||
//! Empty the table of operations of animation of light
|
||||
void LightOperFlush();
|
||||
|
|
|
@ -48,13 +48,10 @@ enum PyroType
|
|||
PT_SHOTW = 12, //! < hit under water (TODO: check if unused)
|
||||
|
||||
// Other subclasses
|
||||
PT_EGG = 13, //! < break the egg
|
||||
PT_BURNT = 14, //! < burning of technical object
|
||||
PT_BURNO = 15, //! < burning of organic object
|
||||
PT_SPIDER = 16, //! < spider explosion
|
||||
PT_WIN = 22, //! < fireworks
|
||||
PT_LOST = 23, //! < black smoke
|
||||
PT_FRAGV = 27, //! < fragmentation of plant object
|
||||
|
||||
PT_OTHER = 100, //! < No special type code; behaviour is decided by subclass
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
using namespace Gfx;
|
||||
|
||||
CEggPyro::CEggPyro(CObject *obj)
|
||||
: CPyro(PT_EGG, obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
Error CEggPyro::IsEnded() {
|
||||
|
@ -47,6 +47,6 @@ void CEggPyro::AfterCreate()
|
|||
|
||||
for (int part = 0; part < OBJECTMAXPART; part++)
|
||||
{
|
||||
CreateTriangle(m_object, m_object->GetType(), part);
|
||||
CreateTriangle(m_object, m_object->GetType(), part, 5, 15, 20, 40, 0.30f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace Gfx;
|
|||
|
||||
|
||||
CFragVPyro::CFragVPyro(CObject *obj)
|
||||
: CPyro(PT_FRAGV, obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
Error CFragVPyro::IsEnded() {
|
||||
|
@ -48,6 +48,6 @@ void CFragVPyro::AfterCreate()
|
|||
m_engine->DeleteShadowSpot(m_object->GetObjectRank(0));
|
||||
for (int part = 0; part < OBJECTMAXPART; part++)
|
||||
{
|
||||
CreateTriangle(m_object, m_object->GetType(), part);
|
||||
CreateTriangle(m_object, m_object->GetType(), part, 5, 15, 20, 40, 0.30f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
using namespace Gfx;
|
||||
|
||||
CSpiderPyro::CSpiderPyro(CObject *obj)
|
||||
: CPyro(PT_SPIDER, obj)
|
||||
: CPyro(PT_OTHER, obj)
|
||||
{}
|
||||
|
||||
Error CSpiderPyro::IsEnded() {
|
||||
|
@ -66,7 +66,7 @@ void CSpiderPyro::AfterCreate()
|
|||
|
||||
for (int part = 0; part < OBJECTMAXPART; part++)
|
||||
{
|
||||
CreateTriangle(m_object, m_object->GetType(), part);
|
||||
CreateTriangle(m_object, m_object->GetType(), part, 5, 20, 15, 25);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
|
|
Loading…
Reference in New Issue