2012-03-19 11:44:39 +00:00
|
|
|
// * This file is part of the COLOBOT source code
|
2012-03-09 16:08:05 +00:00
|
|
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
|
|
|
// *
|
|
|
|
// * 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
|
2012-04-10 17:49:15 +00:00
|
|
|
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
|
|
|
|
|
// taskspiderexplo.cpp
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2012-06-20 15:00:16 +00:00
|
|
|
|
|
|
|
#include "object/task/taskspiderexplo.h"
|
|
|
|
|
2012-06-22 14:31:55 +00:00
|
|
|
#include "old/pyro.h"
|
2012-06-09 22:18:08 +00:00
|
|
|
#include "object/motion/motionspider.h"
|
2012-06-20 15:00:16 +00:00
|
|
|
#include "physics/physics.h"
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
// Object's constructor.
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
CTaskSpiderExplo::CTaskSpiderExplo(CInstanceManager* iMan, CObject* object)
|
|
|
|
: CTask(iMan, object)
|
|
|
|
{
|
|
|
|
m_time = 0.0f;
|
2012-06-10 13:28:12 +00:00
|
|
|
m_bError = false;
|
2012-03-08 18:32:05 +00:00
|
|
|
}
|
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
// Object's destructor.
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
CTaskSpiderExplo::~CTaskSpiderExplo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
// Management of an event.
|
2012-03-08 18:32:05 +00:00
|
|
|
|
2012-06-10 13:28:12 +00:00
|
|
|
bool CTaskSpiderExplo::EventProcess(const Event &event)
|
2012-03-08 18:32:05 +00:00
|
|
|
{
|
2012-06-10 13:28:12 +00:00
|
|
|
if ( m_engine->RetPause() ) return true;
|
|
|
|
if ( event.event != EVENT_FRAME ) return true;
|
2012-03-08 18:32:05 +00:00
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
// Momentarily stationary object (ant on the back)?
|
2012-03-08 18:32:05 +00:00
|
|
|
if ( m_object->RetFixed() )
|
|
|
|
{
|
2012-06-10 13:28:12 +00:00
|
|
|
m_bError = true;
|
|
|
|
return true;
|
2012-03-08 18:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_time += event.rTime;
|
|
|
|
|
2012-06-10 13:28:12 +00:00
|
|
|
return true;
|
2012-03-08 18:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
// Assigns the goal was achieved.
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
Error CTaskSpiderExplo::Start()
|
|
|
|
{
|
2012-04-10 17:49:15 +00:00
|
|
|
m_motion->SetAction(MSS_EXPLO, 1.0f); // swells abdominal
|
2012-03-08 18:32:05 +00:00
|
|
|
m_time = 0.0f;
|
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
m_physics->SetMotorSpeedX(0.0f); // stops the advance
|
|
|
|
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
|
2012-03-08 18:32:05 +00:00
|
|
|
|
2012-06-10 13:28:12 +00:00
|
|
|
m_bError = false;
|
2012-03-08 18:32:05 +00:00
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
// Indicates whether the action is finished.
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
Error CTaskSpiderExplo::IsEnded()
|
|
|
|
{
|
|
|
|
CPyro* pyro;
|
|
|
|
|
|
|
|
if ( m_engine->RetPause() ) return ERR_CONTINUE;
|
|
|
|
|
|
|
|
if ( m_bError )
|
|
|
|
{
|
|
|
|
Abort();
|
|
|
|
return ERR_STOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_time < 1.0f ) return ERR_CONTINUE;
|
|
|
|
|
|
|
|
pyro = new CPyro(m_iMan);
|
2012-04-10 17:49:15 +00:00
|
|
|
pyro->Create(PT_SPIDER, m_object); // the spider explodes (suicide)
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
Abort();
|
|
|
|
return ERR_STOP;
|
|
|
|
}
|
|
|
|
|
2012-04-10 17:49:15 +00:00
|
|
|
// Suddenly ends the current action.
|
2012-03-08 18:32:05 +00:00
|
|
|
|
2012-06-10 13:28:12 +00:00
|
|
|
bool CTaskSpiderExplo::Abort()
|
2012-03-08 18:32:05 +00:00
|
|
|
{
|
2012-06-10 13:28:12 +00:00
|
|
|
return true;
|
2012-03-08 18:32:05 +00:00
|
|
|
}
|
|
|
|
|