colobot/colobot-base/object/task/taskdeletemark.cpp

96 lines
2.2 KiB
C++
Raw Normal View History

/*
* This file is part of the Colobot: Gold Edition source code
2023-08-06 21:15:48 +00:00
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
2015-08-22 14:40:02 +00:00
* http://epsitec.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/taskdeletemark.h"
2015-08-15 12:02:07 +00:00
#include "common/global.h"
#include "graphics/engine/engine.h"
#include "graphics/engine/particle.h"
2020-07-30 02:21:35 +00:00
#include "graphics/engine/pyro_manager.h"
#include "graphics/engine/terrain.h"
#include "level/robotmain.h"
#include "math/geometry.h"
#include "object/object_manager.h"
#include "object/old_object.h"
#include "physics/physics.h"
2015-08-15 18:29:59 +00:00
CTaskDeleteMark::CTaskDeleteMark(COldObject* object) : CForegroundTask(object)
{
m_bExecuted = false;
}
CTaskDeleteMark::~CTaskDeleteMark()
{
}
// Management of an event.
bool CTaskDeleteMark::EventProcess(const Event &event)
{
return true;
}
Error CTaskDeleteMark::Start()
{
DeleteMark();
2015-07-12 11:46:25 +00:00
m_bExecuted = true;
2015-07-12 11:46:25 +00:00
return ERR_OK;
}
// Indicates whether the action is finished.
Error CTaskDeleteMark::IsEnded()
{
if ( m_bExecuted )
return ERR_STOP;
2015-07-12 11:46:25 +00:00
else
return ERR_CONTINUE;
}
// Suddenly ends the current action.
bool CTaskDeleteMark::Abort()
{
return true;
}
void CTaskDeleteMark::DeleteMark()
{
CObject* obj = CObjectManager::GetInstancePointer()->FindNearest(m_object, {
OBJECT_MARKPOWER,
OBJECT_MARKSTONE,
OBJECT_MARKURANIUM,
OBJECT_MARKKEYa,
OBJECT_MARKKEYb,
OBJECT_MARKKEYc,
OBJECT_MARKKEYd
}, 8.0f/g_unit);
if (obj != nullptr)
{
2020-07-30 02:21:35 +00:00
m_engine->GetPyroManager()->Create(Gfx::PT_WPCHECK, obj);
}
2015-08-02 06:45:02 +00:00
}