Barebones new building (TODO: not currently buildable)

coolant-mod
immibis 2020-01-27 21:14:34 +01:00
parent a67266553f
commit 84585f4ebc
9 changed files with 226 additions and 1 deletions

View File

@ -432,6 +432,8 @@ set(BASE_SOURCES
object/subclass/shielder.h
object/subclass/static_object.cpp
object/subclass/static_object.h
object/subclass/water_pump.cpp
object/subclass/water_pump.h
object/task/task.cpp
object/task/task.h
object/task/taskadvance.cpp

View File

@ -567,6 +567,7 @@ void InitializeRestext()
stringsObject[OBJECT_APOLLO4] = TR("Remains of Apollo mission");
stringsObject[OBJECT_APOLLO5] = TR("Remains of Apollo mission");
stringsObject[OBJECT_APOLLO2] = TR("Lunar Roving Vehicle");
stringsObject[OBJECT_WATERPUMP] = TR("Water pump");

View File

@ -533,6 +533,7 @@ ObjectType CLevelParserParam::ToObjectType(std::string value)
if (value == "Me" ) return OBJECT_HUMAN;
if (value == "Tech" ) return OBJECT_TECH;
if (value == "MissionController" ) return OBJECT_CONTROLLER;
if (value == "WaterPump" ) return OBJECT_WATERPUMP;
return static_cast<ObjectType>(Cast<int>(value, "object"));
}
@ -730,6 +731,7 @@ const std::string CLevelParserParam::FromObjectType(ObjectType value)
if (value == OBJECT_HUMAN ) return "Me";
if (value == OBJECT_TECH ) return "Tech";
if (value == OBJECT_CONTROLLER ) return "MissionController";
if (value == OBJECT_WATERPUMP ) return "WaterPump";
return boost::lexical_cast<std::string>(static_cast<int>(value));
}

View File

@ -46,6 +46,7 @@
#include "object/subclass/base_building.h"
#include "object/subclass/base_robot.h"
#include "object/subclass/exchange_post.h"
#include "object/subclass/water_pump.h"
#include "object/subclass/shielder.h"
#include "object/subclass/static_object.h"
@ -87,6 +88,9 @@ CObjectUPtr CObjectFactory::CreateObject(const ObjectCreateParams& params)
case OBJECT_INFO:
return CExchangePost::Create(params, m_oldModelManager, m_engine);
case OBJECT_WATERPUMP:
return CWaterPump::Create(params, m_oldModelManager, m_engine);
case OBJECT_PORTICO:
case OBJECT_BASE:
case OBJECT_DERRICK:

View File

@ -230,6 +230,7 @@ enum ObjectType
OBJECT_APOLLO4 = 903, //!< ApolloModule
OBJECT_APOLLO5 = 904, //!< ApolloAntenna
OBJECT_HOME1 = 910, //!< Home
OBJECT_WATERPUMP = 920, //!< WaterPump
OBJECT_MAX = 1000 //!< number of values
};

View File

@ -0,0 +1,124 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* 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/subclass/water_pump.h"
#include "common/make_unique.h"
#include "common/regex_utils.h"
#include "graphics/engine/oldmodelmanager.h"
#include "level/parser/parserexceptions.h"
#include "level/parser/parserline.h"
#include "level/parser/parserparam.h"
#include "object/object_create_params.h"
#include "sound/sound.h"
#include "ui/controls/interface.h"
#include "ui/controls/list.h"
#include "ui/controls/window.h"
#include <boost/lexical_cast.hpp>
CWaterPump::CWaterPump(int id)
: CBaseBuilding(id, OBJECT_WATERPUMP)
{}
std::unique_ptr<CWaterPump> CWaterPump::Create(
const ObjectCreateParams& params,
Gfx::COldModelManager* modelManager,
Gfx::CEngine* engine)
{
auto obj = MakeUnique<CWaterPump>(params.id);
obj->SetTeam(params.team);
int rank = engine->CreateObject();
engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
obj->SetObjectRank(0, rank);
modelManager->AddModelReference("info1.mod", false, rank);
obj->SetPosition(params.pos);
obj->SetRotationY(params.angle);
obj->SetFloorHeight(0.0f);
/*rank = engine->CreateObject();
engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
obj->SetObjectRank(1, rank);
obj->SetObjectParent(1, 0);
modelManager->AddModelReference("info1.mod", false, rank);
obj->SetPartPosition(1, Math::Vector(0.0f, 1.0f, 0.0f));
obj->SetPartRotationY(1, 0.0f);*/
/* rank = engine->CreateObject();
engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
obj->SetObjectRank(1, rank);
obj->SetObjectParent(1, 0);
modelManager->AddModelReference("info2.mod", false, rank);
obj->SetPartPosition(1, Math::Vector(0.0f, 5.0f, 0.0f));
for (int i = 0; i < 3; ++i)
{
rank = engine->CreateObject();
engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
obj->SetObjectRank(2+i*2, rank);
obj->SetObjectParent(2+i*2, 1);
modelManager->AddModelReference("info3.mod", false, rank);
obj->SetPartPosition(2+i*2, Math::Vector(0.0f, 4.5f, 0.0f));
rank = engine->CreateObject();
engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
obj->SetObjectRank(3+i*2, rank);
obj->SetObjectParent(3+i*2, 2+i*2);
modelManager->AddModelReference("radar4.mod", false, rank);
obj->SetPartPosition(3+i*2, Math::Vector(0.0f, 0.0f, -4.0f));
obj->SetPartRotationY(2+i*2, 2.0f*Math::PI/3.0f*i);
}*/
obj->AddCrashSphere(CrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f));
obj->AddCrashSphere(CrashSphere(Math::Vector(0.0f, 11.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f));
obj->SetCameraCollisionSphere(Math::Sphere(Math::Vector(0.0f, 5.0f, 0.0f), 6.0f));
obj->CreateShadowCircle(8.0f, 1.0f);
Math::Vector pos = obj->GetPosition();
pos.y += params.height;
obj->SetPosition(pos); // to display the shadows immediately
/*auto objAuto = MakeUnique<CAutoInfo>(obj.get());
objAuto->Init();
obj->SetAuto(std::move(objAuto));*/
engine->LoadAllTextures();
return obj;
}
void CWaterPump::Write(CLevelParserLine* line)
{
CBaseBuilding::Write(line);
}
void CWaterPump::Read(CLevelParserLine* line)
{
CBaseBuilding::Read(line);
}

View File

@ -0,0 +1,88 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* 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
*/
#pragma once
#include "object/subclass/base_building.h"
#include "object/auto/auto.h"
#include <string>
#include <vector>
#include <boost/optional.hpp>
struct ObjectCreateParams;
namespace Gfx
{
class COldModelManager;
class CEngine;
}
class CWaterPump : public CBaseBuilding
{
public:
CWaterPump(int id);
static std::unique_ptr<CWaterPump> Create(
const ObjectCreateParams& params,
Gfx::COldModelManager* modelManager,
Gfx::CEngine* engine);
void Write(CLevelParserLine* line) override;
void Read(CLevelParserLine* line) override;
};
// TODO: integrate this with CExchangePost
/*class CAutoInfo : public CAuto
{
public:
CAutoInfo(CExchangePost* object);
~CAutoInfo();
void DeleteObject(bool all=false) override;
void Init() override;
void Start(int param) override;
bool EventProcess(const Event &event) override;
Error GetError() override;
bool CreateInterface(bool select) override;
bool Write(CLevelParserLine* line) override;
bool Read(CLevelParserLine* line) override;
protected:
void UpdateInterface(float rTime);
void UpdateList();
void UpdateListVirus();
protected:
CExchangePost* m_exchangePost;
enum class Phase : unsigned int;
Phase m_phase;
float m_progress;
float m_speed;
float m_timeVirus;
float m_lastParticle;
Math::Vector m_goal;
bool m_lastVirus;
};*/

View File

@ -2725,7 +2725,8 @@ bool CPhysics::ExploOther(ObjectType iType,
oType == OBJECT_NUCLEAR ||
oType == OBJECT_PARA ||
oType == OBJECT_SAFE ||
oType == OBJECT_HUSTON ) // building?
oType == OBJECT_HUSTON ||
oType == OBJECT_WATERPUMP) // building?
{
assert(pObj->Implements(ObjectInterfaceType::Damageable));
// TODO: implement "killer"?

View File

@ -115,6 +115,7 @@ const char* GetObjectName(ObjectType type)
if ( type == OBJECT_BEE ) return "AlienWasp";
if ( type == OBJECT_WORM ) return "AlienWorm";
if ( type == OBJECT_RUINmobilew1) return "Wreck";
if ( type == OBJECT_WATERPUMP ) return "WaterPump";
return "";
}
@ -213,6 +214,7 @@ std::string GetHelpFilename(ObjectType type)
if ( type == OBJECT_BEE ) helpfile = "object/wasp";
if ( type == OBJECT_WORM ) helpfile = "object/worm";
if ( type == OBJECT_RUINmobilew1) helpfile = "object/wreck";
// XXX WaterPump
if (helpfile.empty())
return "";