Issue #399 : Sniffer can delete mark and probe ground
parent
8cc74002cf
commit
bf55691e44
2
data
2
data
|
@ -1 +1 @@
|
|||
Subproject commit b29aa975122f8165f1683c5d143ed37b8c872ab4
|
||||
Subproject commit 1aa40099ac6898775f990884908bb840ae2f94d6
|
|
@ -147,6 +147,7 @@ set(BASE_SOURCES
|
|||
object/task/task.cpp
|
||||
object/task/taskadvance.cpp
|
||||
object/task/taskbuild.cpp
|
||||
object/task/taskdeletemark.cpp
|
||||
object/task/taskfire.cpp
|
||||
object/task/taskfireant.cpp
|
||||
object/task/taskflag.cpp
|
||||
|
|
|
@ -160,7 +160,7 @@ enum EventType
|
|||
|
||||
EVENT_LIST0 = 110,
|
||||
EVENT_LIST1 = 111,
|
||||
EVENT_LIST2 = 112,
|
||||
EVENT_LIST2 = 112, // list of resolutions
|
||||
EVENT_LIST3 = 113,
|
||||
EVENT_LIST4 = 114,
|
||||
EVENT_LIST5 = 115,
|
||||
|
@ -453,6 +453,7 @@ enum EventType
|
|||
EVENT_OBJECT_RESET = 1233,
|
||||
EVENT_OBJECT_DIMSHIELD = 1234,
|
||||
EVENT_OBJECT_TARGET = 1235,
|
||||
EVENT_OBJECT_DELSEARCH = 1236, // delete mark on ground
|
||||
EVENT_OBJECT_PROGLIST = 1310,
|
||||
EVENT_OBJECT_PROGRUN = 1311,
|
||||
EVENT_OBJECT_PROGEDIT = 1312,
|
||||
|
|
|
@ -369,6 +369,7 @@ void InitializeRestext()
|
|||
stringsEvent[EVENT_OBJECT_BEGSHIELD] = TR("Extend shield (\\key action;)");
|
||||
stringsEvent[EVENT_OBJECT_ENDSHIELD] = TR("Withdraw shield (\\key action;)");
|
||||
stringsEvent[EVENT_OBJECT_DIMSHIELD] = TR("Shield radius");
|
||||
stringsEvent[EVENT_OBJECT_DELSEARCH] = TR("Delete mark");
|
||||
stringsEvent[EVENT_OBJECT_PROGRUN] = TR("Execute the selected program");
|
||||
stringsEvent[EVENT_OBJECT_PROGEDIT] = TR("Edit the selected program");
|
||||
stringsEvent[EVENT_OBJECT_INFOOK] = TR("\\SatCom on standby");
|
||||
|
|
|
@ -565,6 +565,11 @@ bool CBrain::EventProcess(const Event &event)
|
|||
{
|
||||
err = StartTaskSearch();
|
||||
}
|
||||
|
||||
if ( action == EVENT_OBJECT_DELSEARCH )
|
||||
{
|
||||
err = StartTaskDeleteMark();
|
||||
}
|
||||
|
||||
if ( action == EVENT_OBJECT_TERRAFORM )
|
||||
{
|
||||
|
@ -980,6 +985,19 @@ Error CBrain::StartTaskSearch()
|
|||
return err;
|
||||
}
|
||||
|
||||
// Delete mark on ground
|
||||
|
||||
Error CBrain::StartTaskDeleteMark()
|
||||
{
|
||||
StopTask();
|
||||
|
||||
m_primaryTask = new CTaskManager(m_object);
|
||||
Error err = m_primaryTask->StartTaskDeleteMark();
|
||||
UpdateInterface();
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
// Terraformed the ground.
|
||||
|
||||
Error CBrain::StartTaskTerraform()
|
||||
|
@ -1163,7 +1181,6 @@ void CBrain::ColorFlag(int color)
|
|||
UpdateInterface();
|
||||
}
|
||||
|
||||
|
||||
// Creates all the interface when the object is selected.
|
||||
|
||||
bool CBrain::CreateInterface(bool bSelect)
|
||||
|
@ -1474,6 +1491,14 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
pos.y = oy+sy*0.5f;
|
||||
pw->CreateButton(pos, dim, 40, EVENT_OBJECT_SEARCH);
|
||||
DefaultEnter(pw, EVENT_OBJECT_SEARCH);
|
||||
|
||||
pos.x = ox+sx*9.0f;
|
||||
pos.y = oy+sy*0.5f;
|
||||
pw->CreateButton(pos, dim, 111, EVENT_OBJECT_GFLAT);
|
||||
|
||||
pos.x = ox+sx*10.1f;
|
||||
pos.y = oy+sy*0.5f;
|
||||
pw->CreateButton(pos, dim, 11, EVENT_OBJECT_DELSEARCH);
|
||||
}
|
||||
|
||||
if ( type == OBJECT_MOBILErt && // Terraformer?
|
||||
|
@ -2118,6 +2143,7 @@ void CBrain::UpdateInterface()
|
|||
EnableInterface(pw, EVENT_OBJECT_FCREATE, bEnable);
|
||||
EnableInterface(pw, EVENT_OBJECT_FDELETE, bEnable);
|
||||
EnableInterface(pw, EVENT_OBJECT_SEARCH, bEnable);
|
||||
EnableInterface(pw, EVENT_OBJECT_DELSEARCH, bEnable);
|
||||
EnableInterface(pw, EVENT_OBJECT_TERRAFORM, bEnable);
|
||||
EnableInterface(pw, EVENT_OBJECT_RECOVER, bEnable);
|
||||
EnableInterface(pw, EVENT_OBJECT_FIRE, bEnable);
|
||||
|
|
|
@ -132,6 +132,7 @@ public:
|
|||
Error StartTaskFlag(TaskFlagOrder order, int rank);
|
||||
Error StartTaskBuild(ObjectType type);
|
||||
Error StartTaskSearch();
|
||||
Error StartTaskDeleteMark();
|
||||
Error StartTaskTerraform();
|
||||
Error StartTaskPen(bool down, int color);
|
||||
Error StartTaskRecover();
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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/taskdeletemark.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
||||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "object/robotmain.h"
|
||||
|
||||
|
||||
CTaskDeleteMark::CTaskDeleteMark(CObject* object) : CTask(object)
|
||||
{
|
||||
m_bExecuted = false;
|
||||
}
|
||||
|
||||
CTaskDeleteMark::~CTaskDeleteMark()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Management of an event.
|
||||
|
||||
bool CTaskDeleteMark::EventProcess(const Event &event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Error CTaskDeleteMark::Start()
|
||||
{
|
||||
DeleteMark();
|
||||
|
||||
m_bExecuted = true;
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
// Indicates whether the action is finished.
|
||||
|
||||
Error CTaskDeleteMark::IsEnded()
|
||||
{
|
||||
if ( m_bExecuted )
|
||||
return ERR_STOP;
|
||||
else
|
||||
return ERR_CONTINUE;
|
||||
}
|
||||
|
||||
// Suddenly ends the current action.
|
||||
|
||||
bool CTaskDeleteMark::Abort()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CTaskDeleteMark::DeleteMark()
|
||||
{
|
||||
ObjectType type;
|
||||
CObject* pObj;
|
||||
Math::Vector oPos=m_object->GetPosition(0);
|
||||
int i;
|
||||
|
||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||
|
||||
for ( i=0 ; i<1000000 ; i++ )
|
||||
{
|
||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
||||
if ( pObj == 0 ) break;
|
||||
|
||||
type = pObj->GetType();
|
||||
|
||||
if ( type == OBJECT_MARKPOWER ||
|
||||
type == OBJECT_MARKSTONE ||
|
||||
type == OBJECT_MARKURANIUM ||
|
||||
type == OBJECT_MARKKEYa ||
|
||||
type == OBJECT_MARKKEYb ||
|
||||
type == OBJECT_MARKKEYc ||
|
||||
type == OBJECT_MARKKEYd )
|
||||
{
|
||||
if ( Math::Distance(oPos, pObj->GetPosition(0)) < 8.0f )
|
||||
{
|
||||
pObj->DeleteObject(); // removes the mark
|
||||
delete pObj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
// tasksearch.h
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "object/task/task.h"
|
||||
#include "object/object.h"
|
||||
|
||||
|
||||
class CTaskDeleteMark : public CTask
|
||||
{
|
||||
public:
|
||||
CTaskDeleteMark(CObject* object);
|
||||
~CTaskDeleteMark();
|
||||
|
||||
bool EventProcess(const Event &event);
|
||||
|
||||
Error Start();
|
||||
Error IsEnded();
|
||||
bool Abort();
|
||||
|
||||
protected:
|
||||
void DeleteMark();
|
||||
protected:
|
||||
bool m_bExecuted;
|
||||
};
|
|
@ -30,6 +30,7 @@
|
|||
#include "object/task/tasktake.h"
|
||||
#include "object/task/taskbuild.h"
|
||||
#include "object/task/tasksearch.h"
|
||||
#include "object/task/taskdeletemark.h"
|
||||
#include "object/task/taskterraform.h"
|
||||
#include "object/task/taskpen.h"
|
||||
#include "object/task/taskrecover.h"
|
||||
|
@ -133,6 +134,15 @@ Error CTaskManager::StartTaskSearch()
|
|||
return (static_cast<CTaskSearch*>(m_task))->Start();
|
||||
}
|
||||
|
||||
// Delete mark on ground
|
||||
|
||||
Error CTaskManager::StartTaskDeleteMark()
|
||||
{
|
||||
m_task = new CTaskDeleteMark(m_object);
|
||||
return (static_cast<CTaskDeleteMark*>(m_task))->Start();
|
||||
}
|
||||
|
||||
|
||||
// Reads an information terminal.
|
||||
|
||||
Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
Error StartTaskFlag(TaskFlagOrder order, int rank);
|
||||
Error StartTaskBuild(ObjectType type);
|
||||
Error StartTaskSearch();
|
||||
Error StartTaskDeleteMark();
|
||||
Error StartTaskInfo(const char *name, float value, float power, bool bSend);
|
||||
Error StartTaskTerraform();
|
||||
Error StartTaskPen(bool bDown, int color);
|
||||
|
|
Loading…
Reference in New Issue