Fixed saving Shielder's shield (#365)
parent
ef35a3a2ef
commit
b698c40abf
|
@ -174,6 +174,11 @@ void CBrain::SetMotion(CMotion* motion)
|
|||
bool CBrain::Write(CLevelParserLine* line)
|
||||
{
|
||||
line->AddParam("bVirusActive", new CLevelParserParam(m_bActiveVirus));
|
||||
|
||||
if ( m_object->GetType() == OBJECT_MOBILErs )
|
||||
{
|
||||
line->AddParam("bShieldActive", new CLevelParserParam(m_secondaryTask != nullptr));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -183,7 +188,13 @@ bool CBrain::Write(CLevelParserLine* line)
|
|||
bool CBrain::Read(CLevelParserLine* line)
|
||||
{
|
||||
m_bActiveVirus = line->GetParam("bVirusActive")->AsBool(false);
|
||||
|
||||
if ( m_object->GetType() == OBJECT_MOBILErs )
|
||||
{
|
||||
if( line->GetParam("bShieldActive")->AsBool(false) )
|
||||
{
|
||||
StartTaskShield(TSM_START);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,16 +169,12 @@ Error CTaskManager::StartTaskRecover()
|
|||
|
||||
Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
|
||||
{
|
||||
if ( mode == TSM_UP )
|
||||
if ( mode == TSM_UP || mode == TSM_START )
|
||||
{
|
||||
m_task = new CTaskShield(m_object);
|
||||
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
|
||||
}
|
||||
if ( mode == TSM_DOWN && m_task != 0 )
|
||||
{
|
||||
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
|
||||
}
|
||||
if ( mode == TSM_UPDATE && m_task != 0 )
|
||||
else if ( m_task != 0 )
|
||||
{
|
||||
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
|
||||
}
|
||||
|
|
|
@ -252,6 +252,42 @@ Error CTaskShield::Start(TaskShieldMode mode, float delay)
|
|||
return ERR_OK;
|
||||
}
|
||||
|
||||
if ( mode == TSM_START )
|
||||
{
|
||||
Math::Point dim;
|
||||
|
||||
m_object->SetShieldRadius(GetRadius());
|
||||
|
||||
mat = m_object->GetWorldMatrix(0);
|
||||
pos = Math::Vector(7.0f, 15.0f, 0.0f);
|
||||
pos = Transform(*mat, pos); // sphere position
|
||||
m_shieldPos = pos;
|
||||
|
||||
pos = m_shieldPos;
|
||||
speed = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
dim.x = GetRadius();
|
||||
dim.y = dim.x;
|
||||
m_rankSphere = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISPHERE3, 2.0f, 0.0f, 0.0f);
|
||||
|
||||
m_phase = TS_SHIELD;
|
||||
m_progress = 0.0f;
|
||||
m_speed = 1.0f/999.9f;
|
||||
m_time = 0.0f;
|
||||
m_delay = delay;
|
||||
m_lastParticle = 0.0f;
|
||||
m_lastRay = 0.0f;
|
||||
m_lastIncrease = 0.0f;
|
||||
m_energyUsed = 0.0f;
|
||||
|
||||
m_bError = false; // ok
|
||||
|
||||
if ( m_object->GetSelect() )
|
||||
{
|
||||
m_brain->UpdateInterface();
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
type = m_object->GetType();
|
||||
if ( type != OBJECT_MOBILErs ) return ERR_SHIELD_VEH;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ enum TaskShieldMode
|
|||
TSM_UP = 1, // deploys shield
|
||||
TSM_DOWN = 2, // returns the shield
|
||||
TSM_UPDATE = 3, // radius change
|
||||
TSM_START = 4, // start with shield up
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue