Moved StartDetectEffect to CRobotMain
parent
3f32b7c8a3
commit
a9673d5f72
|
@ -2446,46 +2446,6 @@ bool COldObject::JostleObject(float force)
|
|||
}
|
||||
|
||||
|
||||
// Beginning of the effect when the instruction "detect" is used.
|
||||
|
||||
void COldObject::StartDetectEffect(CObject *target, bool bFound)
|
||||
{
|
||||
Math::Matrix* mat;
|
||||
Math::Vector pos, goal;
|
||||
Math::Point dim;
|
||||
|
||||
mat = GetWorldMatrix(0);
|
||||
pos = Math::Transform(*mat, Math::Vector(2.0f, 3.0f, 0.0f));
|
||||
|
||||
if ( target == 0 )
|
||||
{
|
||||
goal = Math::Transform(*mat, Math::Vector(50.0f, 3.0f, 0.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
goal = target->GetPosition();
|
||||
goal.y += 3.0f;
|
||||
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-3.0f);
|
||||
}
|
||||
|
||||
dim.x = 3.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateRay(pos, goal, Gfx::PARTIRAY2, dim, 0.2f);
|
||||
|
||||
if ( target != 0 )
|
||||
{
|
||||
goal = target->GetPosition();
|
||||
goal.y += 3.0f;
|
||||
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-1.0f);
|
||||
dim.x = 6.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(goal, Math::Vector(0.0f, 0.0f, 0.0f), dim,
|
||||
bFound?Gfx::PARTIGLINT:Gfx::PARTIGLINTr, 0.5f);
|
||||
}
|
||||
|
||||
m_sound->Play(bFound?SOUND_BUILD:SOUND_RECOVER);
|
||||
}
|
||||
|
||||
|
||||
// Management of time from which a virus is active.
|
||||
|
||||
|
|
|
@ -220,8 +220,6 @@ public:
|
|||
Math::Sphere GetJostlingSphere() const override;
|
||||
bool JostleObject(float force) override;
|
||||
|
||||
void StartDetectEffect(CObject *target, bool bFound) override;
|
||||
|
||||
void SetVirusMode(bool bEnable) override;
|
||||
bool GetVirusMode() override;
|
||||
|
||||
|
|
|
@ -136,11 +136,6 @@ bool COldObjectInterface::GetFixed()
|
|||
}
|
||||
|
||||
|
||||
void COldObjectInterface::StartDetectEffect(CObject *target, bool bFound)
|
||||
{
|
||||
throw std::logic_error("StartDetectEffect: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetVirusMode(bool bEnable)
|
||||
{
|
||||
throw std::logic_error("SetVirusMode: not implemented!");
|
||||
|
|
|
@ -107,9 +107,6 @@ public:
|
|||
virtual void SetFixed(bool bFixed);
|
||||
virtual bool GetFixed();
|
||||
|
||||
// This either goes to CProgrammableObject or gets removed entirely (detect() was used in Ceebot-Teen only, unless we want to restore it)
|
||||
virtual void StartDetectEffect(CObject *target, bool bFound);
|
||||
|
||||
// Not sure. Maybe a separate interface, or maybe CControllableObject (buildings can have viruses too)
|
||||
virtual void SetVirusMode(bool bEnable);
|
||||
virtual bool GetVirusMode();
|
||||
|
|
|
@ -6468,3 +6468,43 @@ float CRobotMain::GetGlobalMagnifyDamage()
|
|||
{
|
||||
return m_globalMagnifyDamage;
|
||||
}
|
||||
|
||||
// Beginning of the effect when the instruction "detect" is used.
|
||||
|
||||
void CRobotMain::StartDetectEffect(COldObject* object, CObject* target)
|
||||
{
|
||||
Math::Matrix* mat;
|
||||
Math::Vector pos, goal;
|
||||
Math::Point dim;
|
||||
|
||||
mat = object->GetWorldMatrix(0);
|
||||
pos = Math::Transform(*mat, Math::Vector(2.0f, 3.0f, 0.0f));
|
||||
|
||||
if ( target == 0 )
|
||||
{
|
||||
goal = Math::Transform(*mat, Math::Vector(50.0f, 3.0f, 0.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
goal = target->GetPosition();
|
||||
goal.y += 3.0f;
|
||||
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-3.0f);
|
||||
}
|
||||
|
||||
dim.x = 3.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateRay(pos, goal, Gfx::PARTIRAY2, dim, 0.2f);
|
||||
|
||||
if ( target != nullptr )
|
||||
{
|
||||
goal = target->GetPosition();
|
||||
goal.y += 3.0f;
|
||||
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-1.0f);
|
||||
dim.x = 6.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(goal, Math::Vector(0.0f, 0.0f, 0.0f), dim,
|
||||
target != nullptr ? Gfx::PARTIGLINT : Gfx::PARTIGLINTr, 0.5f);
|
||||
}
|
||||
|
||||
m_sound->Play(target != nullptr ? SOUND_BUILD : SOUND_RECOVER);
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ class CSceneEndCondition;
|
|||
class CAudioChangeCondition;
|
||||
class CPlayerProfile;
|
||||
class CSettings;
|
||||
class COldObject;
|
||||
|
||||
namespace Gfx
|
||||
{
|
||||
|
@ -370,6 +371,8 @@ public:
|
|||
//! Returns global magnifyDamage setting
|
||||
float GetGlobalMagnifyDamage();
|
||||
|
||||
void StartDetectEffect(COldObject* object, CObject* target);
|
||||
|
||||
protected:
|
||||
bool EventFrame(const Event &event);
|
||||
bool EventObject(const Event &event);
|
||||
|
|
|
@ -1288,7 +1288,10 @@ bool CScriptFunctions::rDetect(CBotVar* var, CBotVar* result, int& exception, vo
|
|||
|
||||
pBest = CObjectManager::GetInstancePointer()->Radar(pThis, type_v, 0.0f, 45.0f*Math::PI/180.0f, 0.0f, 20.0f, false, FILTER_NONE, true);
|
||||
|
||||
pThis->StartDetectEffect(pBest, pBest != nullptr);
|
||||
if (pThis->Implements(ObjectInterfaceType::Old))
|
||||
{
|
||||
script->m_main->StartDetectEffect(dynamic_cast<COldObject*>(pThis), pBest);
|
||||
}
|
||||
|
||||
if ( pBest == 0 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue