Remove unused reset code
parent
f5df59cb89
commit
20dbb8320b
|
@ -184,7 +184,6 @@ set(BASE_SOURCES
|
|||
object/task/taskmanip.cpp
|
||||
object/task/taskpen.cpp
|
||||
object/task/taskrecover.cpp
|
||||
object/task/taskreset.cpp
|
||||
object/task/tasksearch.cpp
|
||||
object/task/taskshield.cpp
|
||||
object/task/taskspiderexplo.cpp
|
||||
|
|
|
@ -56,6 +56,8 @@ CPyro::CPyro()
|
|||
m_lightRank = -1;
|
||||
m_soundChannel = -1;
|
||||
LightOperFlush();
|
||||
|
||||
m_resetAngle = 0.0f;
|
||||
}
|
||||
|
||||
CPyro::~CPyro()
|
||||
|
@ -341,9 +343,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
if ( m_type == PT_RESET )
|
||||
{
|
||||
m_speed = 1.0f/2.0f;
|
||||
m_object->SetPosition(0, m_object->GetResetPosition());
|
||||
m_object->SetAngle(0, m_object->GetResetAngle());
|
||||
m_object->SetZoom(0, 0.0f);
|
||||
m_resetAngle = m_object->GetAngleY(0);
|
||||
}
|
||||
if ( m_type == PT_FINDING )
|
||||
{
|
||||
|
@ -1010,8 +1010,8 @@ bool CPyro::EventProcess(const Event &event)
|
|||
|
||||
if(m_object != nullptr)
|
||||
{
|
||||
Math::Vector angle = m_object->GetResetAngle();
|
||||
m_object->SetAngleY(0, angle.y-powf((1.0f-m_progress)*5.0f, 2.0f));
|
||||
float angle = m_resetAngle;
|
||||
m_object->SetAngleY(0, angle-powf((1.0f-m_progress)*5.0f, 2.0f));
|
||||
m_object->SetZoom(0, m_progress);
|
||||
}
|
||||
}
|
||||
|
@ -1216,8 +1216,7 @@ Error CPyro::IsEnded()
|
|||
|
||||
if ( m_type == PT_RESET )
|
||||
{
|
||||
m_object->SetPosition(0, m_object->GetResetPosition());
|
||||
m_object->SetAngle(0, m_object->GetResetAngle());
|
||||
m_object->SetAngleY(0, m_resetAngle);
|
||||
m_object->SetZoom(0, 1.0f);
|
||||
}
|
||||
|
||||
|
@ -1347,15 +1346,6 @@ void CPyro::DeleteObject(bool primary, bool secondary)
|
|||
{
|
||||
if (m_object == nullptr) return;
|
||||
|
||||
if (m_object->GetResetCap() == RESET_MOVE) // resettable object?
|
||||
{
|
||||
m_object->SetEnable(false); // object cache and inactive
|
||||
Math::Vector pos = m_object->GetPosition();
|
||||
pos.y = -100.0f;
|
||||
m_object->SetPosition(0, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
ObjectType type = m_object->GetType();
|
||||
if ( secondary &&
|
||||
type != OBJECT_FACTORY &&
|
||||
|
|
|
@ -184,6 +184,7 @@ protected:
|
|||
bool m_fallEnding;
|
||||
|
||||
std::vector<Math::Sphere> m_crashSpheres;
|
||||
float m_resetAngle;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ CAutoConvert::CAutoConvert(COldObject* object) : CAuto(object)
|
|||
{
|
||||
Init();
|
||||
m_phase = ACP_STOP;
|
||||
m_bResetDelete = false;
|
||||
m_soundChannel = -1;
|
||||
}
|
||||
|
||||
|
@ -229,8 +228,6 @@ bool CAutoConvert::EventProcess(const Event &event)
|
|||
cargo = SearchStone(OBJECT_STONE);
|
||||
if ( cargo != nullptr )
|
||||
{
|
||||
m_bResetDelete = ( cargo->GetResetCap() != RESET_NONE );
|
||||
|
||||
CObjectManager::GetInstancePointer()->DeleteObject(cargo);
|
||||
}
|
||||
|
||||
|
@ -476,12 +473,7 @@ void CAutoConvert::CreateMetal()
|
|||
Math::Vector pos = m_object->GetPosition();
|
||||
float angle = m_object->GetAngleY(0);
|
||||
|
||||
CObject* cargo = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_METAL);
|
||||
|
||||
if ( m_bResetDelete )
|
||||
{
|
||||
cargo->SetResetCap(RESET_DELETE);
|
||||
}
|
||||
CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_METAL);
|
||||
|
||||
m_main->DisplayError(INFO_CONVERT, m_object);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ protected:
|
|||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
bool m_bResetDelete;
|
||||
bool m_bSoundClose;
|
||||
int m_soundChannel;
|
||||
};
|
||||
|
|
|
@ -503,11 +503,6 @@ void CAutoDerrick::CreateCargo(Math::Vector pos, float angle, ObjectType type,
|
|||
CObject* cargo = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type);
|
||||
cargo->SetLock(true); // object not yet usable
|
||||
|
||||
if ( m_object->GetResetCap() == RESET_MOVE )
|
||||
{
|
||||
cargo->SetResetCap(RESET_DELETE);
|
||||
}
|
||||
|
||||
pos = cargo->GetPosition();
|
||||
pos.y += height;
|
||||
cargo->SetPosition(0, pos);
|
||||
|
|
|
@ -1251,18 +1251,6 @@ Error CBrain::StartTaskGunGoal(float dirV, float dirH)
|
|||
return err;
|
||||
}
|
||||
|
||||
// Reset.
|
||||
|
||||
Error CBrain::StartTaskReset(Math::Vector goal, Math::Vector angle)
|
||||
{
|
||||
StopTask();
|
||||
|
||||
m_primaryTask = new CTaskManager(m_object);
|
||||
Error err = m_primaryTask->StartTaskReset(goal, angle);
|
||||
UpdateInterface();
|
||||
return err;
|
||||
}
|
||||
|
||||
// Completes the task when the time came.
|
||||
|
||||
Error CBrain::EndedTask()
|
||||
|
|
|
@ -141,7 +141,6 @@ public:
|
|||
Error StartTaskFireAnt(Math::Vector impact);
|
||||
Error StartTaskSpiderExplo();
|
||||
Error StartTaskGunGoal(float dirV, float dirH);
|
||||
Error StartTaskReset(Math::Vector goal, Math::Vector angle);
|
||||
|
||||
void UpdateInterface(float rTime);
|
||||
void UpdateInterface();
|
||||
|
|
|
@ -290,10 +290,6 @@ COldObject::COldObject(int id)
|
|||
m_character.wheelRight = 1.0f;
|
||||
|
||||
m_resetCap = RESET_NONE;
|
||||
m_bResetBusy = false;
|
||||
m_resetPosition = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_resetAngle = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_resetRun = nullptr;
|
||||
|
||||
m_cameraType = Gfx::CAM_TYPE_BACK;
|
||||
m_cameraDist = 50.0f;
|
||||
|
@ -947,9 +943,6 @@ void COldObject::Write(CLevelParserLine* line)
|
|||
if ( GetResetCap() != 0 )
|
||||
{
|
||||
line->AddParam("resetCap", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(GetResetCap()))});
|
||||
line->AddParam("resetPos", CLevelParserParamUPtr{new CLevelParserParam(GetResetPosition()/g_unit)});
|
||||
line->AddParam("resetAngle", CLevelParserParamUPtr{new CLevelParserParam(GetResetAngle()/(Math::PI/180.0f))});
|
||||
line->AddParam("resetRun", CLevelParserParamUPtr{new CLevelParserParam(m_brain->GetProgramIndex(GetResetRun()))});
|
||||
}
|
||||
|
||||
if ( m_bVirusMode )
|
||||
|
@ -1020,9 +1013,6 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
SetGunGoalH(line->GetParam("aimH")->AsFloat(0.0f));
|
||||
|
||||
SetResetCap(static_cast<ResetCap>(line->GetParam("resetCap")->AsInt(0)));
|
||||
SetResetPosition(line->GetParam("resetPos")->AsPoint(Math::Vector())*g_unit);
|
||||
SetResetAngle(line->GetParam("resetAngle")->AsPoint(Math::Vector())*(Math::PI/180.0f));
|
||||
SetResetRun(m_brain->GetProgram(line->GetParam("resetRun")->AsInt(-1)));
|
||||
m_bBurn = line->GetParam("burnMode")->AsBool(false);
|
||||
m_bVirusMode = line->GetParam("virusMode")->AsBool(false);
|
||||
m_virusTime = line->GetParam("virusTime")->AsFloat(0.0f);
|
||||
|
@ -1476,47 +1466,6 @@ ResetCap COldObject::GetResetCap()
|
|||
return m_resetCap;
|
||||
}
|
||||
|
||||
void COldObject::SetResetBusy(bool bBusy)
|
||||
{
|
||||
m_bResetBusy = bBusy;
|
||||
}
|
||||
|
||||
bool COldObject::GetResetBusy()
|
||||
{
|
||||
return m_bResetBusy;
|
||||
}
|
||||
|
||||
void COldObject::SetResetPosition(const Math::Vector &pos)
|
||||
{
|
||||
m_resetPosition = pos;
|
||||
}
|
||||
|
||||
Math::Vector COldObject::GetResetPosition()
|
||||
{
|
||||
return m_resetPosition;
|
||||
}
|
||||
|
||||
void COldObject::SetResetAngle(const Math::Vector &angle)
|
||||
{
|
||||
m_resetAngle = angle;
|
||||
}
|
||||
|
||||
Math::Vector COldObject::GetResetAngle()
|
||||
{
|
||||
return m_resetAngle;
|
||||
}
|
||||
|
||||
Program* COldObject::GetResetRun()
|
||||
{
|
||||
return m_resetRun;
|
||||
}
|
||||
|
||||
void COldObject::SetResetRun(Program* run)
|
||||
{
|
||||
m_resetRun = run;
|
||||
}
|
||||
|
||||
|
||||
// Management of the particle master.
|
||||
|
||||
void COldObject::SetMasterParticle(int part, int parti)
|
||||
|
|
|
@ -152,14 +152,6 @@ public:
|
|||
|
||||
void SetResetCap(ResetCap cap) override;
|
||||
ResetCap GetResetCap() override;
|
||||
void SetResetBusy(bool bBusy);
|
||||
bool GetResetBusy();
|
||||
void SetResetPosition(const Math::Vector &pos);
|
||||
Math::Vector GetResetPosition() override;
|
||||
void SetResetAngle(const Math::Vector &angle);
|
||||
Math::Vector GetResetAngle() override;
|
||||
void SetResetRun(Program* run);
|
||||
Program* GetResetRun() override;
|
||||
|
||||
void SetMasterParticle(int part, int parti) override;
|
||||
|
||||
|
|
|
@ -197,21 +197,6 @@ ResetCap COldObjectInterface::GetResetCap()
|
|||
throw std::logic_error("GetResetCap: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetResetPosition()
|
||||
{
|
||||
throw std::logic_error("GetResetPosition: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetResetAngle()
|
||||
{
|
||||
throw std::logic_error("GetResetAngle: not implemented!");
|
||||
}
|
||||
|
||||
Program* COldObjectInterface::GetResetRun()
|
||||
{
|
||||
throw std::logic_error("GetResetRun: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetMasterParticle(int part, int parti)
|
||||
{
|
||||
throw std::logic_error("SetMasterParticle: not implemented!");
|
||||
|
|
|
@ -67,8 +67,7 @@ enum class ExplosionType
|
|||
enum ResetCap
|
||||
{
|
||||
RESET_NONE = 0,
|
||||
RESET_MOVE = 1,
|
||||
RESET_DELETE = 2,
|
||||
RESET_MOVE = 1
|
||||
};
|
||||
|
||||
class COldObjectInterface
|
||||
|
@ -121,9 +120,6 @@ public:
|
|||
|
||||
virtual ResetCap GetResetCap();
|
||||
virtual void SetResetCap(ResetCap resetCap);
|
||||
virtual Math::Vector GetResetPosition();
|
||||
virtual Math::Vector GetResetAngle();
|
||||
virtual Program* GetResetRun();
|
||||
|
||||
virtual void SetMasterParticle(int part, int parti);
|
||||
|
||||
|
|
|
@ -3679,9 +3679,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
dynamic_cast<CProgrammableObject*>(oldObj)->GetBrain()
|
||||
->SetSoluceName(const_cast<char*>(line->GetParam("soluce")->AsPath("ai").c_str()));
|
||||
|
||||
oldObj->SetResetPosition(oldObj->GetPosition());
|
||||
oldObj->SetResetAngle(oldObj->GetRotation());
|
||||
oldObj->SetResetRun(loadedPrograms[run]);
|
||||
if (line->GetParam("reset")->AsBool(false))
|
||||
oldObj->SetResetCap(RESET_MOVE);
|
||||
}
|
||||
|
@ -5297,98 +5294,8 @@ void CRobotMain::ReadFreeParam()
|
|||
//! Resets all objects to their original position
|
||||
void CRobotMain::ResetObject()
|
||||
{
|
||||
// TODO: ?
|
||||
#if 0
|
||||
CObject* obj;
|
||||
CObject* transporter;
|
||||
CAuto* objAuto;
|
||||
CBrain* brain;
|
||||
CPyro* pyro;
|
||||
ResetCap cap;
|
||||
Math::Vector pos, angle;
|
||||
int i;
|
||||
|
||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||
|
||||
// Removes all pyrotechnic effects in progress.
|
||||
while ( true )
|
||||
{
|
||||
pyro = static_cast<CPyro*>(iMan->SearchInstance(CLASS_PYRO, 0));
|
||||
if ( pyro == 0 ) break;
|
||||
|
||||
pyro->DeleteObject();
|
||||
delete pyro;
|
||||
}
|
||||
|
||||
// Removes all bullets in progress.
|
||||
m_particle->DeleteParticle(PARTIGUN1);
|
||||
m_particle->DeleteParticle(PARTIGUN2);
|
||||
m_particle->DeleteParticle(PARTIGUN3);
|
||||
m_particle->DeleteParticle(PARTIGUN4);
|
||||
|
||||
for ( i=0 ; i<1000000 ; i++ )
|
||||
{
|
||||
obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
||||
if ( obj == 0 ) break;
|
||||
|
||||
cap = obj->GetResetCap();
|
||||
if ( cap == RESET_NONE ) continue;
|
||||
|
||||
if ( cap == RESET_DELETE )
|
||||
{
|
||||
transporter = obj->GetTransporter();
|
||||
if ( transporter != 0 )
|
||||
{
|
||||
transporter->SetCargo(0);
|
||||
obj->SetTransporter(0);
|
||||
}
|
||||
obj->DeleteObject();
|
||||
delete obj;
|
||||
i --;
|
||||
continue;
|
||||
}
|
||||
|
||||
objAuto = obj->GetAuto();
|
||||
if ( objAuto != 0 )
|
||||
{
|
||||
objAuto->Abort();
|
||||
}
|
||||
|
||||
if ( obj->GetEnable() ) // object still active?
|
||||
{
|
||||
brain = obj->GetBrain();
|
||||
if ( brain != 0 )
|
||||
{
|
||||
pos = obj->GetResetPosition();
|
||||
angle = obj->GetResetAngle();
|
||||
|
||||
if ( pos == obj->GetPosition() &&
|
||||
angle == obj->GetRotation() ) continue;
|
||||
brain->StartTaskReset(pos, angle);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
obj->SetEnable(true); // active again
|
||||
|
||||
pos = obj->GetResetPosition();
|
||||
angle = obj->GetResetAngle();
|
||||
|
||||
if ( pos == obj->GetPosition() &&
|
||||
angle == obj->GetRotation() ) continue;
|
||||
|
||||
pyro = new CPyro();
|
||||
pyro->Create(PT_RESET, obj);
|
||||
|
||||
brain = obj->GetBrain();
|
||||
if ( brain != 0 )
|
||||
{
|
||||
brain->RunProgram(obj->GetResetRun());
|
||||
}
|
||||
}
|
||||
#else
|
||||
// schedule reset during next frame
|
||||
m_resetCreate = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Resets all objects to their original position
|
||||
|
|
|
@ -195,7 +195,6 @@ public:
|
|||
bool DeleteObject();
|
||||
|
||||
void ResetObject();
|
||||
void ResetCreate();
|
||||
void UpdateAudio(bool frame);
|
||||
void SetEndMission(Error result, float delay);
|
||||
Error CheckEndMission(bool frame);
|
||||
|
@ -377,6 +376,7 @@ protected:
|
|||
void InitEye();
|
||||
|
||||
void CreateScene(bool soluce, bool fixScene, bool resetObject);
|
||||
void ResetCreate();
|
||||
|
||||
Math::Vector LookatPoint(Math::Vector eye, float angleH, float angleV, float length);
|
||||
int CreateLight(Math::Vector direction, Gfx::Color color);
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "object/task/taskfireant.h"
|
||||
#include "object/task/taskgungoal.h"
|
||||
#include "object/task/taskspiderexplo.h"
|
||||
#include "object/task/taskreset.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
|
@ -220,17 +219,6 @@ Error CTaskManager::StartTaskSpiderExplo()
|
|||
return (static_cast<CTaskSpiderExplo*>(m_task))->Start();
|
||||
}
|
||||
|
||||
// Reset.
|
||||
|
||||
Error CTaskManager::StartTaskReset(Math::Vector goal, Math::Vector angle)
|
||||
{
|
||||
m_task = new CTaskReset(m_object);
|
||||
return (static_cast<CTaskReset*>(m_task))->Start(goal, angle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Management of an event.
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ public:
|
|||
Error StartTaskFireAnt(Math::Vector impact);
|
||||
Error StartTaskGunGoal(float dirV, float dirH);
|
||||
Error StartTaskSpiderExplo();
|
||||
Error StartTaskReset(Math::Vector goal, Math::Vector angle);
|
||||
|
||||
bool EventProcess(const Event &event);
|
||||
Error IsEnded();
|
||||
|
|
|
@ -1,335 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
|
||||
#include "object/task/taskreset.h"
|
||||
|
||||
#include "object/brain.h"
|
||||
#include "object/old_object.h"
|
||||
#include "object/object_manager.h"
|
||||
#include "object/robotmain.h"
|
||||
#include "object/interface/carrier_object.h"
|
||||
#include "object/interface/powered_object.h"
|
||||
#include "object/interface/transportable_object.h"
|
||||
|
||||
|
||||
|
||||
const float RESET_DELAY_ZOOM = 0.7f;
|
||||
const float RESET_DELAY_MOVE = 0.7f;
|
||||
|
||||
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
||||
CTaskReset::CTaskReset(COldObject* object) : CTask(object)
|
||||
{
|
||||
}
|
||||
|
||||
// Object's destructor.
|
||||
|
||||
CTaskReset::~CTaskReset()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Management of an event.
|
||||
|
||||
bool CTaskReset::EventProcess(const Event &event)
|
||||
{
|
||||
Math::Vector pos, speed;
|
||||
Math::Point dim;
|
||||
float angle, duration;
|
||||
|
||||
if ( m_engine->GetPause() ) return true;
|
||||
if ( event.type != EVENT_FRAME ) return true;
|
||||
if ( m_bError ) return false;
|
||||
|
||||
m_time += event.rTime;
|
||||
m_progress += event.rTime*m_speed;
|
||||
|
||||
if ( m_phase == TRSP_ZOUT )
|
||||
{
|
||||
angle = m_iAngle;
|
||||
angle += powf(m_progress*5.0f, 2.0f); // accelerates
|
||||
m_object->SetAngleY(0, angle);
|
||||
m_object->SetZoom(0, 1.0f-m_progress);
|
||||
|
||||
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
|
||||
{
|
||||
m_lastParticle = m_time;
|
||||
|
||||
pos = m_begin;
|
||||
pos.x += (Math::Rand()-0.5f)*5.0f;
|
||||
pos.z += (Math::Rand()-0.5f)*5.0f;
|
||||
speed.x = 0.0f;
|
||||
speed.z = 0.0f;
|
||||
speed.y = 5.0f+Math::Rand()*5.0f;
|
||||
dim.x = Math::Rand()*2.0f+2.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
|
||||
|
||||
pos = m_begin;
|
||||
speed.x = (Math::Rand()-0.5f)*20.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*20.0f;
|
||||
speed.y = Math::Rand()*10.0f;
|
||||
speed *= 1.0f-m_progress*0.5f;
|
||||
pos += speed*1.5f;
|
||||
speed = -speed;
|
||||
dim.x = 0.6f;
|
||||
dim.y = dim.x;
|
||||
pos.y += dim.y;
|
||||
duration = Math::Rand()*1.5f+1.5f;
|
||||
m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
|
||||
duration, 0.0f,
|
||||
duration*0.9f, 0.7f);
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_phase == TRSP_MOVE )
|
||||
{
|
||||
pos = m_begin+(m_goal-m_begin)*m_progress;
|
||||
m_object->SetPosition(0, pos);
|
||||
|
||||
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
|
||||
{
|
||||
m_lastParticle = m_time;
|
||||
|
||||
pos.x += (Math::Rand()-0.5f)*5.0f;
|
||||
pos.z += (Math::Rand()-0.5f)*5.0f;
|
||||
speed.x = 0.0f;
|
||||
speed.z = 0.0f;
|
||||
speed.y = 2.0f+Math::Rand()*2.0f;
|
||||
dim.x = Math::Rand()*2.0f+2.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_phase == TRSP_ZIN )
|
||||
{
|
||||
angle = m_angle.y;
|
||||
angle += -powf((1.0f-m_progress)*5.0f, 2.0f); // slows
|
||||
m_object->SetAngleY(0, angle);
|
||||
m_object->SetZoom(0, m_progress);
|
||||
|
||||
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
|
||||
{
|
||||
m_lastParticle = m_time;
|
||||
|
||||
pos = m_goal;
|
||||
pos.x += (Math::Rand()-0.5f)*5.0f;
|
||||
pos.z += (Math::Rand()-0.5f)*5.0f;
|
||||
speed.x = 0.0f;
|
||||
speed.z = 0.0f;
|
||||
speed.y = 5.0f+Math::Rand()*5.0f;
|
||||
dim.x = Math::Rand()*2.0f+2.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
|
||||
|
||||
pos = m_goal;
|
||||
speed.x = (Math::Rand()-0.5f)*20.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*20.0f;
|
||||
speed.y = Math::Rand()*10.0f;
|
||||
speed *= 0.5f+m_progress*0.5f;
|
||||
dim.x = 0.6f;
|
||||
dim.y = dim.x;
|
||||
pos.y += dim.y;
|
||||
duration = Math::Rand()*1.5f+1.5f;
|
||||
m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
|
||||
duration, 0.0f,
|
||||
duration*0.9f, 0.7f);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Assigns the goal was achieved.
|
||||
// A positive angle makes a turn right.
|
||||
|
||||
Error CTaskReset::Start(Math::Vector goal, Math::Vector angle)
|
||||
{
|
||||
if (m_object->Implements(ObjectInterfaceType::Carrier))
|
||||
{
|
||||
CCarrierObject* carrier = dynamic_cast<CCarrierObject*>(m_object);
|
||||
CObject* cargo = carrier->GetCargo();
|
||||
if ( cargo != nullptr && cargo->GetResetCap() == RESET_MOVE )
|
||||
{
|
||||
assert(cargo->Implements(ObjectInterfaceType::Transportable));
|
||||
dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(nullptr);
|
||||
carrier->SetCargo(nullptr); // does nothing
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_main->GetNiceReset() ) // quick return?
|
||||
{
|
||||
m_object->SetPosition(0, goal);
|
||||
m_object->SetAngle(0, angle);
|
||||
Program* program = m_object->GetResetRun();
|
||||
if(program != nullptr)
|
||||
{
|
||||
m_brain->AddProgram(program);
|
||||
m_brain->RunProgram(program);
|
||||
}
|
||||
|
||||
m_bError = false;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
m_begin = m_object->GetPosition();
|
||||
m_goal = goal;
|
||||
m_angle = angle;
|
||||
|
||||
if ( SearchVehicle() ) // starting location occupied?
|
||||
{
|
||||
m_bError = true;
|
||||
return ERR_RESET_NEAR;
|
||||
}
|
||||
|
||||
m_iAngle = m_object->GetAngleY(0);
|
||||
m_time = 0.0f;
|
||||
m_phase = TRSP_ZOUT;
|
||||
m_speed = 1.0f/RESET_DELAY_ZOOM;
|
||||
m_progress = 0.0f;
|
||||
m_lastParticle = 0.0f;
|
||||
|
||||
m_object->SetResetBusy(true);
|
||||
|
||||
int i = m_sound->Play(SOUND_GGG, m_begin, 1.0f, 2.0f, true);
|
||||
m_sound->AddEnvelope(i, 0.0f, 0.5f, RESET_DELAY_ZOOM, SOPER_STOP);
|
||||
|
||||
m_bError = false;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
// Indicates whether the action is finished.
|
||||
|
||||
Error CTaskReset::IsEnded()
|
||||
{
|
||||
if ( !m_main->GetNiceReset() ) // quick return?
|
||||
{
|
||||
return ERR_STOP;
|
||||
}
|
||||
|
||||
if ( m_engine->GetPause() ) return ERR_CONTINUE;
|
||||
if ( m_bError ) return ERR_STOP;
|
||||
if ( m_progress < 1.0f ) return ERR_CONTINUE;
|
||||
|
||||
if ( m_phase == TRSP_ZOUT )
|
||||
{
|
||||
float dist = Math::Distance(m_begin, m_goal);
|
||||
m_phase = TRSP_MOVE;
|
||||
m_speed = 1.0f/(dist*RESET_DELAY_MOVE/100.0f);
|
||||
m_progress = 0.0f;
|
||||
return ERR_CONTINUE;
|
||||
}
|
||||
|
||||
if ( m_phase == TRSP_MOVE )
|
||||
{
|
||||
m_object->SetPosition(0, m_goal);
|
||||
m_object->SetAngle(0, m_angle);
|
||||
|
||||
int i = m_sound->Play(SOUND_GGG, m_goal, 1.0f, 0.5f, true);
|
||||
m_sound->AddEnvelope(i, 0.0f, 2.0f, RESET_DELAY_ZOOM, SOPER_STOP);
|
||||
|
||||
m_phase = TRSP_ZIN;
|
||||
m_speed = 1.0f/RESET_DELAY_ZOOM;
|
||||
m_progress = 0.0f;
|
||||
return ERR_CONTINUE;
|
||||
}
|
||||
|
||||
m_object->SetAngle(0, m_angle);
|
||||
m_object->SetZoom(0, 1.0f);
|
||||
|
||||
if (m_object->Implements(ObjectInterfaceType::Powered))
|
||||
{
|
||||
CObject* power = dynamic_cast<CPoweredObject*>(m_object)->GetPower();
|
||||
if (power != nullptr)
|
||||
{
|
||||
power->SetEnergy(power->GetCapacity()); // refueling
|
||||
}
|
||||
}
|
||||
|
||||
Program* program = m_object->GetResetRun();
|
||||
if (program != nullptr)
|
||||
{
|
||||
m_brain->AddProgram(program);
|
||||
m_brain->RunProgram(program);
|
||||
}
|
||||
m_object->SetResetBusy(false);
|
||||
return ERR_STOP;
|
||||
}
|
||||
|
||||
|
||||
// Seeks if a vehicle is too close.
|
||||
|
||||
bool CTaskReset::SearchVehicle()
|
||||
{
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( obj == m_object ) continue;
|
||||
|
||||
ObjectType type = obj->GetType();
|
||||
if ( type != OBJECT_HUMAN &&
|
||||
type != OBJECT_TECH &&
|
||||
type != OBJECT_MOBILEfa &&
|
||||
type != OBJECT_MOBILEta &&
|
||||
type != OBJECT_MOBILEwa &&
|
||||
type != OBJECT_MOBILEia &&
|
||||
type != OBJECT_MOBILEfc &&
|
||||
type != OBJECT_MOBILEtc &&
|
||||
type != OBJECT_MOBILEwc &&
|
||||
type != OBJECT_MOBILEic &&
|
||||
type != OBJECT_MOBILEfi &&
|
||||
type != OBJECT_MOBILEti &&
|
||||
type != OBJECT_MOBILEwi &&
|
||||
type != OBJECT_MOBILEii &&
|
||||
type != OBJECT_MOBILEfs &&
|
||||
type != OBJECT_MOBILEts &&
|
||||
type != OBJECT_MOBILEws &&
|
||||
type != OBJECT_MOBILEis &&
|
||||
type != OBJECT_MOBILErt &&
|
||||
type != OBJECT_MOBILErc &&
|
||||
type != OBJECT_MOBILErr &&
|
||||
type != OBJECT_MOBILErs &&
|
||||
type != OBJECT_MOBILEsa &&
|
||||
type != OBJECT_MOBILEtg &&
|
||||
type != OBJECT_MOBILEft &&
|
||||
type != OBJECT_MOBILEtt &&
|
||||
type != OBJECT_MOBILEwt &&
|
||||
type != OBJECT_MOBILEit &&
|
||||
type != OBJECT_MOBILEdr &&
|
||||
type != OBJECT_MOTHER &&
|
||||
type != OBJECT_ANT &&
|
||||
type != OBJECT_SPIDER &&
|
||||
type != OBJECT_BEE &&
|
||||
type != OBJECT_WORM ) continue;
|
||||
|
||||
if (obj->GetCrashSphereCount() == 0) continue;
|
||||
|
||||
auto crashSphere = obj->GetFirstCrashSphere();
|
||||
if (Math::DistanceToSphere(m_goal, crashSphere.sphere) < 5.0f)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
// taskreset.h
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "object/task/task.h"
|
||||
|
||||
#include "math/vector.h"
|
||||
|
||||
|
||||
|
||||
enum TaskResetPhase
|
||||
{
|
||||
TRSP_ZOUT = 1, // disappears
|
||||
TRSP_MOVE = 2, // moves
|
||||
TRSP_ZIN = 3, // reappears
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CTaskReset : public CTask
|
||||
{
|
||||
public:
|
||||
CTaskReset(COldObject* object);
|
||||
~CTaskReset();
|
||||
|
||||
bool EventProcess(const Event &event);
|
||||
|
||||
Error Start(Math::Vector goal, Math::Vector angle);
|
||||
Error IsEnded();
|
||||
|
||||
protected:
|
||||
bool SearchVehicle();
|
||||
|
||||
protected:
|
||||
Math::Vector m_begin;
|
||||
Math::Vector m_goal;
|
||||
Math::Vector m_angle;
|
||||
|
||||
TaskResetPhase m_phase;
|
||||
bool m_bError;
|
||||
float m_time;
|
||||
float m_speed;
|
||||
float m_progress;
|
||||
float m_lastParticle; // time of generation last particle
|
||||
float m_iAngle;
|
||||
};
|
||||
|
|
@ -1815,7 +1815,6 @@ void CPhysics::WaterFrame(float aTime, float rTime)
|
|||
if ( type == OBJECT_NULL ) return;
|
||||
|
||||
if ( !m_object->GetActive() ) return;
|
||||
if ( m_object->GetResetBusy() ) return; // reset in progress?
|
||||
|
||||
if ( m_water->GetLava() ||
|
||||
(type == OBJECT_HUMAN &&
|
||||
|
@ -2566,7 +2565,6 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
|
||||
if ( oType == OBJECT_WAYPOINT &&
|
||||
pObj->GetEnable() &&
|
||||
!m_object->GetResetBusy() &&
|
||||
m_object->GetTrainer() ) // driving vehicle?
|
||||
{
|
||||
Math::Vector oPos = pObj->GetPosition();
|
||||
|
|
|
@ -5993,7 +5993,7 @@ bool CMainDialog::GetMovies()
|
|||
return m_bMovies;
|
||||
}
|
||||
|
||||
// IWhether to make an animation in CTaskReset.
|
||||
// Whether to make an animation on reset.
|
||||
|
||||
bool CMainDialog::GetNiceReset()
|
||||
{
|
||||
|
|
|
@ -238,7 +238,7 @@ protected:
|
|||
bool m_bRain; // rain in the interface?
|
||||
bool m_bSoluce4; // solutions in program 4?
|
||||
bool m_bMovies; // cinematics?
|
||||
bool m_bNiceReset; // for CTaskReset
|
||||
bool m_bNiceReset; // for reset animation
|
||||
bool m_bHimselfDamage; // for shots
|
||||
bool m_bCameraScroll; // for CCamera
|
||||
bool m_bCameraInvertX; // for CCamera
|
||||
|
|
Loading…
Reference in New Issue