Introduce new CObject base class and mixin class framework
parent
80d93c0fea
commit
f1684f85be
|
@ -160,9 +160,9 @@ set(BASE_SOURCES
|
|||
object/motion/motiontoto.cpp
|
||||
object/motion/motionvehicle.cpp
|
||||
object/motion/motionworm.cpp
|
||||
object/object.cpp
|
||||
object/object_factory.cpp
|
||||
object/object_manager.cpp
|
||||
object/old_object.cpp
|
||||
object/robotmain.cpp
|
||||
object/task/task.cpp
|
||||
object/task/taskadvance.cpp
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
#include "object/object_manager.h"
|
||||
#include "object/robotmain.h"
|
||||
#include "object/motion/motionhuman.h"
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "object/object_interface_type.h"
|
||||
|
||||
struct Event;
|
||||
|
||||
/**
|
||||
* \class CInteractiveObject
|
||||
* \brief Interface for interactive objects (objects able to process events from event loop)
|
||||
*/
|
||||
class CInteractiveObject
|
||||
{
|
||||
public:
|
||||
explicit CInteractiveObject(ObjectInterfaceTypes& types)
|
||||
{
|
||||
types[static_cast<int>(ObjectInterfaceType::Interactive)] = true;
|
||||
}
|
||||
virtual ~CInteractiveObject()
|
||||
{}
|
||||
|
||||
virtual bool EventProcess(const Event& event) = 0;
|
||||
};
|
|
@ -24,454 +24,69 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "object/object_interface_type.h"
|
||||
#include "object/old_object_interface.h"
|
||||
|
||||
#include "graphics/engine/engine.h"
|
||||
#include "graphics/engine/camera.h"
|
||||
|
||||
#include "object/object_type.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class CApplication;
|
||||
class CPhysics;
|
||||
class CBrain;
|
||||
class CMotion;
|
||||
class CAuto;
|
||||
class CDisplayText;
|
||||
class CRobotMain;
|
||||
class CBotVar;
|
||||
class CScript;
|
||||
class CLevelParserLine;
|
||||
struct Program;
|
||||
|
||||
// The father of all parts must always be the part number zero!
|
||||
const int OBJECTMAXPART = 40;
|
||||
const int MAXCRASHSPHERE = 40;
|
||||
const int OBJECTMAXDESELLIST = 10;
|
||||
const int OBJECTMAXCMDLINE = 20;
|
||||
|
||||
struct ObjectPart
|
||||
/**
|
||||
* \class CObject
|
||||
* \brief Base class for all 3D in-game objects
|
||||
*
|
||||
* CObject serves as a base class for all in-game objects, including:
|
||||
* - buildings,
|
||||
* - robots,
|
||||
* - astronaut,
|
||||
* - plants,
|
||||
* - aliens.
|
||||
*
|
||||
* As every object has its specific behavior, there are or will be
|
||||
* separate subclasses for each of the specific objects. For the time being,
|
||||
* old object interface is still present, but its functions will be moved to
|
||||
* appropriate subclasses with time. The new CObject interface implemented
|
||||
* here will feature only functions common to all objects.
|
||||
*/
|
||||
class CObject : public COldObjectInterface
|
||||
{
|
||||
bool bUsed;
|
||||
int object; // number of the object in CEngine
|
||||
int parentPart; // number of father part
|
||||
int masterParti; // master canal of the particle
|
||||
Math::Vector position;
|
||||
Math::Vector angle;
|
||||
Math::Vector zoom;
|
||||
bool bTranslate;
|
||||
bool bRotate;
|
||||
bool bZoom;
|
||||
Math::Matrix matTranslate;
|
||||
Math::Matrix matRotate;
|
||||
Math::Matrix matTransform;
|
||||
Math::Matrix matWorld;
|
||||
};
|
||||
|
||||
struct Character
|
||||
{
|
||||
float wheelFront; // position X of the front wheels
|
||||
float wheelBack; // position X of the back wheels
|
||||
float wheelLeft; // position Z of the left wheels
|
||||
float wheelRight; // position Z of the right wheels
|
||||
float height; // normal height on top of ground
|
||||
Math::Vector posPower; // position of the battery
|
||||
};
|
||||
|
||||
enum class ExplosionType
|
||||
{
|
||||
Bang = 1,
|
||||
Burn = 2,
|
||||
Water = 3,
|
||||
};
|
||||
|
||||
enum ResetCap
|
||||
{
|
||||
RESET_NONE = 0,
|
||||
RESET_MOVE = 1,
|
||||
RESET_DELETE = 2,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CObject
|
||||
{
|
||||
friend class CObjectFactory;
|
||||
friend class CObjectManager;
|
||||
|
||||
protected:
|
||||
|
||||
CObject(int id);
|
||||
|
||||
void DeleteObject(bool bAll=false);
|
||||
void SetPhysics(std::unique_ptr<CPhysics> physics);
|
||||
void SetBrain(std::unique_ptr<CBrain> brain);
|
||||
void SetMotion(std::unique_ptr<CMotion> motion);
|
||||
void SetAuto(std::unique_ptr<CAuto> automat);
|
||||
void SetShowLimitRadius(float radius);
|
||||
void SetCapacity(float capacity);
|
||||
float GetProxyDistance();
|
||||
void SetOption(int option);
|
||||
void SetJostlingSphere(Math::Vector pos, float radius);
|
||||
//! Constructor only accessible to subclasses
|
||||
CObject(int id, ObjectType type)
|
||||
: m_id(id)
|
||||
, m_type(type)
|
||||
{
|
||||
m_implementedInterfaces.fill(false);
|
||||
}
|
||||
|
||||
public:
|
||||
CObject(const CObject&) = delete;
|
||||
CObject& operator=(const CObject&) = delete;
|
||||
|
||||
virtual ~CObject();
|
||||
virtual ~CObject()
|
||||
{}
|
||||
|
||||
void Simplify();
|
||||
bool ExplodeObject(ExplosionType type, float force, float decay=1.0f);
|
||||
//! Returns object type
|
||||
inline ObjectType GetType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
//! Returns object's unique id
|
||||
inline int GetID() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
bool EventProcess(const Event &event);
|
||||
void UpdateMapping();
|
||||
//! Writes object properties to line in level file
|
||||
virtual void Write(CLevelParserLine* line) = 0;
|
||||
//! Reads object properties from line in level file
|
||||
virtual void Read(CLevelParserLine* line) = 0;
|
||||
|
||||
void DeletePart(int part);
|
||||
void SetObjectRank(int part, int objRank);
|
||||
int GetObjectRank(int part);
|
||||
void SetObjectParent(int part, int parent);
|
||||
ObjectType GetType();
|
||||
void SetType(ObjectType type);
|
||||
const char* GetName();
|
||||
int GetOption();
|
||||
int GetID();
|
||||
|
||||
virtual void Write(CLevelParserLine* line);
|
||||
virtual void Read(CLevelParserLine* line);
|
||||
|
||||
void SetDrawWorld(bool bDraw);
|
||||
void SetDrawFront(bool bDraw);
|
||||
|
||||
bool ReadProgram(Program* program, const char* filename);
|
||||
bool WriteProgram(Program* program, const char* filename);
|
||||
|
||||
int GetShadowLight();
|
||||
int GetEffectLight();
|
||||
|
||||
void FlushCrashShere();
|
||||
int CreateCrashSphere(Math::Vector pos, float radius, Sound sound, float hardness=0.45f);
|
||||
int GetCrashSphereTotal();
|
||||
bool GetCrashSphere(int rank, Math::Vector &pos, float &radius);
|
||||
float GetCrashSphereHardness(int rank);
|
||||
Sound GetCrashSphereSound(int rank);
|
||||
void SetGlobalSphere(Math::Vector pos, float radius);
|
||||
void GetGlobalSphere(Math::Vector &pos, float &radius);
|
||||
void GetJostlingSphere(Math::Vector &pos, float &radius);
|
||||
void SetShieldRadius(float radius);
|
||||
float GetShieldRadius();
|
||||
|
||||
void SetFloorHeight(float height);
|
||||
void FloorAdjust();
|
||||
|
||||
void SetLinVibration(Math::Vector dir);
|
||||
Math::Vector GetLinVibration();
|
||||
void SetCirVibration(Math::Vector dir);
|
||||
Math::Vector GetCirVibration();
|
||||
void SetTilt(Math::Vector dir);
|
||||
Math::Vector GetTilt();
|
||||
|
||||
void SetPosition(int part, const Math::Vector &pos);
|
||||
Math::Vector GetPosition(int part);
|
||||
void SetAngle(int part, const Math::Vector &angle);
|
||||
Math::Vector GetAngle(int part);
|
||||
void SetAngleY(int part, float angle);
|
||||
void SetAngleX(int part, float angle);
|
||||
void SetAngleZ(int part, float angle);
|
||||
float GetAngleY(int part);
|
||||
float GetAngleX(int part);
|
||||
float GetAngleZ(int part);
|
||||
void SetZoom(int part, float zoom);
|
||||
void SetZoom(int part, Math::Vector zoom);
|
||||
Math::Vector GetZoom(int part);
|
||||
void SetZoomX(int part, float zoom);
|
||||
float GetZoomX(int part);
|
||||
void SetZoomY(int part, float zoom);
|
||||
float GetZoomY(int part);
|
||||
void SetZoomZ(int part, float zoom);
|
||||
float GetZoomZ(int part);
|
||||
|
||||
void SetTrainer(bool bEnable);
|
||||
bool GetTrainer();
|
||||
|
||||
void SetToy(bool bEnable);
|
||||
bool GetToy();
|
||||
|
||||
void SetManual(bool bManual);
|
||||
bool GetManual();
|
||||
|
||||
void SetResetCap(ResetCap cap);
|
||||
ResetCap GetResetCap();
|
||||
void SetResetBusy(bool bBusy);
|
||||
bool GetResetBusy();
|
||||
void SetResetPosition(const Math::Vector &pos);
|
||||
Math::Vector GetResetPosition();
|
||||
void SetResetAngle(const Math::Vector &angle);
|
||||
Math::Vector GetResetAngle();
|
||||
void SetResetRun(Program* run);
|
||||
Program* GetResetRun();
|
||||
|
||||
void SetMasterParticle(int part, int parti);
|
||||
int GetMasterParticle(int part);
|
||||
|
||||
void SetPower(CObject* power);
|
||||
CObject* GetPower();
|
||||
void SetCargo(CObject* cargo);
|
||||
CObject* GetCargo();
|
||||
void SetTransporter(CObject* transporter);
|
||||
CObject* GetTransporter();
|
||||
void SetTransporterPart(int part);
|
||||
|
||||
bool SetCmdLine(int rank, float value);
|
||||
float GetCmdLine(int rank);
|
||||
|
||||
Math::Matrix* GetRotateMatrix(int part);
|
||||
Math::Matrix* GetWorldMatrix(int part);
|
||||
|
||||
void SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
|
||||
Math::Vector &lookat, Math::Vector &upVec,
|
||||
Gfx::CameraType type);
|
||||
|
||||
void GetCharacter(Character* character);
|
||||
Character* GetCharacter();
|
||||
|
||||
float GetAbsTime();
|
||||
|
||||
void SetEnergy(float level);
|
||||
float GetEnergy();
|
||||
|
||||
float GetCapacity();
|
||||
|
||||
void SetShield(float level);
|
||||
float GetShield();
|
||||
|
||||
void SetRange(float delay);
|
||||
float GetRange();
|
||||
|
||||
void SetTransparency(float value);
|
||||
|
||||
void SetFixed(bool bFixed);
|
||||
bool GetFixed();
|
||||
|
||||
void SetClip(bool bClip);
|
||||
bool GetClip();
|
||||
|
||||
void SetTeam(int team);
|
||||
int GetTeam();
|
||||
|
||||
bool JostleObject(float force);
|
||||
|
||||
void StartDetectEffect(CObject *target, bool bFound);
|
||||
|
||||
void SetVirusMode(bool bEnable);
|
||||
bool GetVirusMode();
|
||||
float GetVirusTime();
|
||||
|
||||
void SetCameraType(Gfx::CameraType type);
|
||||
Gfx::CameraType GetCameraType();
|
||||
void SetCameraDist(float dist);
|
||||
float GetCameraDist();
|
||||
void SetCameraLock(bool bLock);
|
||||
bool GetCameraLock();
|
||||
|
||||
void SetHighlight(bool mode);
|
||||
|
||||
void SetSelect(bool bMode, bool bDisplayError=true);
|
||||
bool GetSelect(bool bReal=false);
|
||||
|
||||
void SetSelectable(bool bMode);
|
||||
bool GetSelectable();
|
||||
|
||||
void SetActivity(bool bMode);
|
||||
bool GetActivity();
|
||||
|
||||
void SetVisible(bool bVisible);
|
||||
|
||||
void SetEnable(bool bEnable);
|
||||
bool GetEnable();
|
||||
|
||||
void SetCheckToken(bool bMode);
|
||||
bool GetCheckToken();
|
||||
|
||||
void SetProxyActivate(bool bActivate);
|
||||
bool GetProxyActivate();
|
||||
void SetProxyDistance(float distance);
|
||||
|
||||
void SetMagnifyDamage(float factor);
|
||||
float GetMagnifyDamage();
|
||||
|
||||
void SetParam(float value);
|
||||
float GetParam();
|
||||
void SetIgnoreBuildCheck(bool bIgnoreBuildCheck);
|
||||
bool GetIgnoreBuildCheck();
|
||||
|
||||
void SetExploding(bool bExplo);
|
||||
bool IsExploding();
|
||||
void SetLock(bool bLock);
|
||||
bool GetLock();
|
||||
void SetSpaceshipCargo(bool bCargo);
|
||||
bool IsSpaceshipCargo();
|
||||
void SetBurn(bool bBurn);
|
||||
bool GetBurn();
|
||||
void SetDead(bool bDead);
|
||||
bool GetDead();
|
||||
bool GetRuin();
|
||||
bool GetActive();
|
||||
|
||||
void SetGunGoalV(float gunGoal);
|
||||
void SetGunGoalH(float gunGoal);
|
||||
float GetGunGoalV();
|
||||
float GetGunGoalH();
|
||||
|
||||
bool StartShowLimit();
|
||||
void StopShowLimit();
|
||||
|
||||
bool IsProgram();
|
||||
void CreateSelectParticle();
|
||||
|
||||
void SetRunScript(CScript* script);
|
||||
CScript* GetRunScript();
|
||||
CBotVar* GetBotVar();
|
||||
CPhysics* GetPhysics();
|
||||
CBrain* GetBrain();
|
||||
CMotion* GetMotion();
|
||||
CAuto* GetAuto();
|
||||
|
||||
void SetDefRank(int rank);
|
||||
int GetDefRank();
|
||||
|
||||
bool GetTooltipName(std::string& name);
|
||||
|
||||
void AddDeselList(CObject* pObj);
|
||||
CObject* SubDeselList();
|
||||
void DeleteDeselList(CObject* pObj);
|
||||
|
||||
bool CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type = Gfx::ENG_SHADOW_NORM);
|
||||
bool CreateShadowLight(float height, Gfx::Color color);
|
||||
bool CreateEffectLight(float height, Gfx::Color color);
|
||||
|
||||
void FlatParent();
|
||||
|
||||
// TODO: move to more appropriate place
|
||||
//! Set value to be returned by receive() CBOT function
|
||||
void SetInfoReturn(float value);
|
||||
//! Return value to be returned by receive() CBOT function
|
||||
float GetInfoReturn();
|
||||
//! Check if object implements the given type of interface
|
||||
inline bool Implements(ObjectInterfaceType type) const
|
||||
{
|
||||
return m_implementedInterfaces[static_cast<int>(type)];
|
||||
}
|
||||
|
||||
protected:
|
||||
bool EventFrame(const Event &event);
|
||||
void VirusFrame(float rTime);
|
||||
void PartiFrame(float rTime);
|
||||
void InitPart(int part);
|
||||
void UpdateTotalPart();
|
||||
int SearchDescendant(int parent, int n);
|
||||
void UpdateEnergyMapping();
|
||||
bool UpdateTransformObject(int part, bool bForceUpdate);
|
||||
bool UpdateTransformObject();
|
||||
void UpdateSelectParticle();
|
||||
|
||||
protected:
|
||||
Gfx::CEngine* m_engine;
|
||||
Gfx::CLightManager* m_lightMan;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::CCamera* m_camera;
|
||||
Gfx::CParticle* m_particle;
|
||||
std::unique_ptr<CPhysics> m_physics;
|
||||
std::unique_ptr<CBrain> m_brain;
|
||||
std::unique_ptr<CMotion> m_motion;
|
||||
std::unique_ptr<CAuto> m_auto;
|
||||
CRobotMain* m_main;
|
||||
CSoundInterface* m_sound;
|
||||
CBotVar* m_botVar;
|
||||
CScript* m_runScript;
|
||||
|
||||
ObjectType m_type; // OBJECT_*
|
||||
const int m_id; // unique identifier
|
||||
std::string m_name; // name of the object
|
||||
Character m_character; // characteristic
|
||||
int m_option; // option
|
||||
int m_shadowLight; // number of light from the shadows
|
||||
float m_shadowHeight; // height of light from the shadows
|
||||
int m_effectLight; // number of light effects
|
||||
float m_effectHeight; // height of light effects
|
||||
Math::Vector m_linVibration; // linear vibration
|
||||
Math::Vector m_cirVibration; // circular vibration
|
||||
Math::Vector m_tilt; // tilt
|
||||
CObject* m_power; // battery used by the vehicle
|
||||
CObject* m_cargo; // object transported
|
||||
CObject* m_transporter; // object with the latter
|
||||
int m_transporterLink; // part
|
||||
float m_energy; // energy contained (if battery)
|
||||
float m_lastEnergy;
|
||||
float m_capacity; // capacity (if battery)
|
||||
float m_shield; // shield
|
||||
float m_range; // flight range
|
||||
float m_transparency; // transparency (0..1)
|
||||
float m_aTime;
|
||||
float m_shotTime; // time since last shot
|
||||
bool m_bVirusMode; // virus activated/triggered
|
||||
float m_virusTime; // lifetime of the virus
|
||||
float m_lastVirusParticle;
|
||||
bool m_bSelect; // object selected
|
||||
bool m_bSelectable; // selectable object
|
||||
bool m_bCheckToken; // object with audited tokens
|
||||
bool m_bVisible; // object active but undetectable
|
||||
bool m_bEnable; // dead object
|
||||
bool m_bProxyActivate; // active object so close
|
||||
bool m_bLock;
|
||||
bool m_bExplo;
|
||||
bool m_bCargo;
|
||||
bool m_bBurn;
|
||||
bool m_bDead;
|
||||
bool m_bFlat;
|
||||
bool m_bTrainer; // drive vehicle (without remote)
|
||||
bool m_bToy; // toy key
|
||||
bool m_bManual; // manual control (Scribbler)
|
||||
bool m_bIgnoreBuildCheck;
|
||||
bool m_bFixed;
|
||||
bool m_bClip;
|
||||
bool m_bShowLimit;
|
||||
float m_showLimitRadius;
|
||||
float m_gunGoalV;
|
||||
float m_gunGoalH;
|
||||
Gfx::CameraType m_cameraType;
|
||||
float m_cameraDist;
|
||||
bool m_bCameraLock;
|
||||
int m_defRank;
|
||||
float m_magnifyDamage;
|
||||
float m_proxyDistance;
|
||||
float m_param;
|
||||
int m_team;
|
||||
|
||||
int m_crashSphereUsed; // number of spheres used
|
||||
Math::Vector m_crashSpherePos[MAXCRASHSPHERE];
|
||||
float m_crashSphereRadius[MAXCRASHSPHERE];
|
||||
float m_crashSphereHardness[MAXCRASHSPHERE];
|
||||
Sound m_crashSphereSound[MAXCRASHSPHERE];
|
||||
Math::Vector m_globalSpherePos;
|
||||
float m_globalSphereRadius;
|
||||
Math::Vector m_jostlingSpherePos;
|
||||
float m_jostlingSphereRadius;
|
||||
float m_shieldRadius;
|
||||
|
||||
int m_totalPart;
|
||||
ObjectPart m_objectPart[OBJECTMAXPART];
|
||||
|
||||
int m_totalDesectList;
|
||||
CObject* m_objectDeselectList[OBJECTMAXDESELLIST];
|
||||
|
||||
int m_partiSel[4];
|
||||
|
||||
ResetCap m_resetCap;
|
||||
bool m_bResetBusy;
|
||||
Math::Vector m_resetPosition;
|
||||
Math::Vector m_resetAngle;
|
||||
Program* m_resetRun;
|
||||
|
||||
float m_infoReturn;
|
||||
|
||||
float m_cmdLine[OBJECTMAXCMDLINE];
|
||||
const int m_id; //!< unique identifier
|
||||
ObjectType m_type; //!< object type
|
||||
std::string m_name; //!< object class name
|
||||
ObjectInterfaceTypes m_implementedInterfaces; //! interfaces that the object implements
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/engine/lightning.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
#include "object/brain.h"
|
||||
#include "object/object_create_params.h"
|
||||
#include "object/robotmain.h"
|
||||
|
@ -66,6 +67,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
using COldObjectUPtr = std::unique_ptr<COldObject>;
|
||||
|
||||
CObjectFactory::CObjectFactory(Gfx::CEngine* engine,
|
||||
Gfx::CTerrain* terrain,
|
||||
Gfx::CModelManager* modelManager,
|
||||
|
@ -332,7 +335,7 @@ CObjectUPtr CObjectFactory::CreateBuilding(const ObjectCreateParams& params)
|
|||
ObjectType type = params.type;
|
||||
float power = params.power;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -1106,7 +1109,7 @@ CObjectUPtr CObjectFactory::CreateBuilding(const ObjectCreateParams& params)
|
|||
AddObjectAuto(obj.get());
|
||||
m_engine->LoadAllTextures();
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a small resource set on the ground.
|
||||
|
@ -1118,7 +1121,7 @@ CObjectUPtr CObjectFactory::CreateResource(const ObjectCreateParams& params)
|
|||
ObjectType type = params.type;
|
||||
float power = params.power;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -1173,7 +1176,7 @@ CObjectUPtr CObjectFactory::CreateResource(const ObjectCreateParams& params)
|
|||
|
||||
if ( type == OBJECT_SHOW ) // remains in the air?
|
||||
{
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
float radius = 1.5f;
|
||||
|
@ -1226,7 +1229,7 @@ CObjectUPtr CObjectFactory::CreateResource(const ObjectCreateParams& params)
|
|||
pos.y += height;
|
||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a flag placed on the ground.
|
||||
|
@ -1237,7 +1240,7 @@ CObjectUPtr CObjectFactory::CreateFlag(const ObjectCreateParams& params)
|
|||
float angle = params.angle;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -1286,7 +1289,7 @@ CObjectUPtr CObjectFactory::CreateFlag(const ObjectCreateParams& params)
|
|||
pos = obj->GetPosition(0);
|
||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a barrier placed on the ground.
|
||||
|
@ -1298,7 +1301,7 @@ CObjectUPtr CObjectFactory::CreateBarrier(const ObjectCreateParams& params)
|
|||
float height = params.height;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -1383,7 +1386,7 @@ CObjectUPtr CObjectFactory::CreateBarrier(const ObjectCreateParams& params)
|
|||
pos.y += height;
|
||||
obj->SetPosition(0, pos);
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a plant placed on the ground.
|
||||
|
@ -1395,7 +1398,7 @@ CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params)
|
|||
float height = params.height;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -1624,7 +1627,7 @@ CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params)
|
|||
pos.y += height;
|
||||
obj->SetPosition(0, pos);
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a mushroom placed on the ground.
|
||||
|
@ -1636,7 +1639,7 @@ CObjectUPtr CObjectFactory::CreateMushroom(const ObjectCreateParams& params)
|
|||
float height = params.height;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -1682,7 +1685,7 @@ CObjectUPtr CObjectFactory::CreateMushroom(const ObjectCreateParams& params)
|
|||
pos.y += height;
|
||||
obj->SetPosition(0, pos);
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a toy placed on the ground.
|
||||
|
@ -1696,7 +1699,7 @@ CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params)
|
|||
ObjectType type = params.type;
|
||||
int option = params.option;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
obj->SetOption(option);
|
||||
|
@ -2516,7 +2519,7 @@ CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params)
|
|||
pos.y += height;
|
||||
obj->SetPosition(0, pos);
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a crystal placed on the ground.
|
||||
|
@ -2528,7 +2531,7 @@ CObjectUPtr CObjectFactory::CreateQuartz(const ObjectCreateParams& params)
|
|||
float height = params.height;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -2623,7 +2626,7 @@ CObjectUPtr CObjectFactory::CreateQuartz(const ObjectCreateParams& params)
|
|||
m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
|
||||
m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a root placed on the ground.
|
||||
|
@ -2634,7 +2637,7 @@ CObjectUPtr CObjectFactory::CreateRoot(const ObjectCreateParams& params)
|
|||
float height = params.height;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -2790,7 +2793,7 @@ CObjectUPtr CObjectFactory::CreateRoot(const ObjectCreateParams& params)
|
|||
pos.y += height;
|
||||
obj->SetPosition(0, pos);
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a small home.
|
||||
|
@ -2801,7 +2804,7 @@ CObjectUPtr CObjectFactory::CreateHome(const ObjectCreateParams& params)
|
|||
float height = params.height;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -2830,7 +2833,7 @@ CObjectUPtr CObjectFactory::CreateHome(const ObjectCreateParams& params)
|
|||
pos.y += height;
|
||||
obj->SetPosition(0, pos);
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates ruin placed on the ground.
|
||||
|
@ -2841,7 +2844,7 @@ CObjectUPtr CObjectFactory::CreateRuin(const ObjectCreateParams& params)
|
|||
float height = params.height;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -3245,7 +3248,7 @@ CObjectUPtr CObjectFactory::CreateRuin(const ObjectCreateParams& params)
|
|||
obj->SetAngleX(0, angle);
|
||||
}
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a gadget apollo.
|
||||
|
@ -3256,7 +3259,7 @@ CObjectUPtr CObjectFactory::CreateApollo(const ObjectCreateParams& params)
|
|||
float angle = params.angle;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -3424,7 +3427,7 @@ CObjectUPtr CObjectFactory::CreateApollo(const ObjectCreateParams& params)
|
|||
pos = obj->GetPosition(0);
|
||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates a vehicle traveling any pose on the floor.
|
||||
|
@ -3439,7 +3442,7 @@ CObjectUPtr CObjectFactory::CreateVehicle(const ObjectCreateParams& params)
|
|||
bool toy = params.toy;
|
||||
int option = params.option;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
obj->SetOption(option);
|
||||
|
@ -3449,7 +3452,7 @@ CObjectUPtr CObjectFactory::CreateVehicle(const ObjectCreateParams& params)
|
|||
std::unique_ptr<CMotion> motion{new CMotionToto(obj.get())};
|
||||
motion->Create(pos, angle, type, 1.0f, m_modelManager);
|
||||
obj->SetMotion(std::move(motion));
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
if ( type == OBJECT_HUMAN ||
|
||||
|
@ -3526,7 +3529,7 @@ CObjectUPtr CObjectFactory::CreateVehicle(const ObjectCreateParams& params)
|
|||
obj->SetMotion(std::move(motion));
|
||||
obj->SetPhysics(std::move(physics));
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates an insect lands on any ground.
|
||||
|
@ -3537,7 +3540,7 @@ CObjectUPtr CObjectFactory::CreateInsect(const ObjectCreateParams& params)
|
|||
float angle = params.angle;
|
||||
ObjectType type = params.type;
|
||||
|
||||
CObjectUPtr obj(new CObject(params.id));
|
||||
COldObjectUPtr obj{new COldObject(params.id)};
|
||||
|
||||
obj->SetType(type);
|
||||
|
||||
|
@ -3580,12 +3583,12 @@ CObjectUPtr CObjectFactory::CreateInsect(const ObjectCreateParams& params)
|
|||
obj->SetPhysics(std::move(physics));
|
||||
obj->SetBrain(std::move(brain));
|
||||
|
||||
return obj;
|
||||
return std::move(obj);
|
||||
}
|
||||
|
||||
// Creates all sub-objects for managing the object.
|
||||
|
||||
void CObjectFactory::AddObjectAuto(CObject* obj)
|
||||
void CObjectFactory::AddObjectAuto(COldObject* obj)
|
||||
{
|
||||
std::unique_ptr<CAuto> objAuto;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ class CTerrain;
|
|||
} // namespace Gfx
|
||||
|
||||
class CObject;
|
||||
class COldObject;
|
||||
class CRobotMain;
|
||||
struct ObjectCreateParams;
|
||||
|
||||
|
@ -69,7 +70,7 @@ private:
|
|||
CObjectUPtr CreateHome(const ObjectCreateParams& params);
|
||||
CObjectUPtr CreateRuin(const ObjectCreateParams& params);
|
||||
CObjectUPtr CreateApollo(const ObjectCreateParams& params);
|
||||
void AddObjectAuto(CObject* obj);
|
||||
void AddObjectAuto(COldObject* obj);
|
||||
|
||||
private:
|
||||
Gfx::CEngine* m_engine;
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file object/object_interface_type.h
|
||||
* \brief ObjectInterfaceType enum
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
/**
|
||||
* \enum ObjectInterfaceType
|
||||
* \brief Type of interface that an object implements
|
||||
*/
|
||||
enum class ObjectInterfaceType
|
||||
{
|
||||
Interactive, //!< interactive objects can process events from event loop
|
||||
Max //!< maximum value (for getting number of items in enum)
|
||||
};
|
||||
|
||||
using ObjectInterfaceTypes = std::array<bool, static_cast<size_t>(ObjectInterfaceType::Max)>;
|
|
@ -25,6 +25,7 @@
|
|||
#include "object/object.h"
|
||||
#include "object/object_create_params.h"
|
||||
#include "object/object_factory.h"
|
||||
#include "object/old_object.h"
|
||||
#include "object/auto/auto.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
@ -53,7 +54,10 @@ bool CObjectManager::DeleteObject(CObject* instance)
|
|||
{
|
||||
assert(instance != nullptr);
|
||||
|
||||
instance->DeleteObject();
|
||||
// TODO: temporarily...
|
||||
auto oldObj = dynamic_cast<COldObject*>(instance);
|
||||
if (oldObj != nullptr)
|
||||
oldObj->DeleteObject();
|
||||
|
||||
auto it = m_objects.find(instance->GetID());
|
||||
if (it != m_objects.end())
|
||||
|
@ -69,8 +73,13 @@ void CObjectManager::DeleteAllObjects()
|
|||
{
|
||||
for (auto& it : m_objects)
|
||||
{
|
||||
bool all = true;
|
||||
it.second->DeleteObject(all);
|
||||
// TODO: temporarily...
|
||||
auto oldObj = dynamic_cast<COldObject*>(it.second.get());
|
||||
if (oldObj != nullptr)
|
||||
{
|
||||
bool all = true;
|
||||
oldObj->DeleteObject(all);
|
||||
}
|
||||
}
|
||||
|
||||
m_objects.clear();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,422 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file object/old_object.h
|
||||
* \brief COldObject - legacy CObject code
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "object/interactive_object.h"
|
||||
#include "object/object.h"
|
||||
|
||||
// The father of all parts must always be the part number zero!
|
||||
const int OBJECTMAXPART = 40;
|
||||
const int MAXCRASHSPHERE = 40;
|
||||
const int OBJECTMAXDESELLIST = 10;
|
||||
const int OBJECTMAXCMDLINE = 20;
|
||||
|
||||
struct ObjectPart
|
||||
{
|
||||
bool bUsed;
|
||||
int object; // number of the object in CEngine
|
||||
int parentPart; // number of father part
|
||||
int masterParti; // master canal of the particle
|
||||
Math::Vector position;
|
||||
Math::Vector angle;
|
||||
Math::Vector zoom;
|
||||
bool bTranslate;
|
||||
bool bRotate;
|
||||
bool bZoom;
|
||||
Math::Matrix matTranslate;
|
||||
Math::Matrix matRotate;
|
||||
Math::Matrix matTransform;
|
||||
Math::Matrix matWorld;
|
||||
};
|
||||
|
||||
|
||||
class COldObject : public CObject, public CInteractiveObject
|
||||
{
|
||||
friend class CObjectFactory;
|
||||
friend class CObjectManager;
|
||||
|
||||
protected:
|
||||
|
||||
COldObject(int id);
|
||||
|
||||
void DeleteObject(bool bAll=false);
|
||||
void SetPhysics(std::unique_ptr<CPhysics> physics);
|
||||
void SetBrain(std::unique_ptr<CBrain> brain);
|
||||
void SetMotion(std::unique_ptr<CMotion> motion);
|
||||
void SetAuto(std::unique_ptr<CAuto> automat);
|
||||
void SetShowLimitRadius(float radius);
|
||||
void SetCapacity(float capacity);
|
||||
float GetProxyDistance();
|
||||
void SetOption(int option);
|
||||
void SetJostlingSphere(Math::Vector pos, float radius);
|
||||
|
||||
|
||||
public:
|
||||
~COldObject();
|
||||
|
||||
void Simplify() override;
|
||||
bool ExplodeObject(ExplosionType type, float force, float decay=1.0f) override;
|
||||
|
||||
bool EventProcess(const Event& event) override;
|
||||
void UpdateMapping() override;
|
||||
|
||||
void DeletePart(int part) override;
|
||||
void SetObjectRank(int part, int objRank) override;
|
||||
int GetObjectRank(int part) override;
|
||||
void SetObjectParent(int part, int parent) override;
|
||||
void SetType(ObjectType type) override;
|
||||
const char* GetName() override;
|
||||
int GetOption() override;
|
||||
|
||||
void Write(CLevelParserLine* line) override;
|
||||
void Read(CLevelParserLine* line) override;
|
||||
|
||||
void SetDrawWorld(bool bDraw) override;
|
||||
void SetDrawFront(bool bDraw) override;
|
||||
|
||||
bool ReadProgram(Program* program, const char* filename) override;
|
||||
bool WriteProgram(Program* program, const char* filename) override;
|
||||
|
||||
int GetShadowLight() override;
|
||||
int GetEffectLight() override;
|
||||
|
||||
void FlushCrashShere() override;
|
||||
int CreateCrashSphere(Math::Vector pos, float radius, Sound sound, float hardness=0.45f) override;
|
||||
int GetCrashSphereTotal() override;
|
||||
bool GetCrashSphere(int rank, Math::Vector &pos, float &radius) override;
|
||||
float GetCrashSphereHardness(int rank) override;
|
||||
Sound GetCrashSphereSound(int rank) override;
|
||||
void SetGlobalSphere(Math::Vector pos, float radius) override;
|
||||
void GetGlobalSphere(Math::Vector &pos, float &radius) override;
|
||||
void GetJostlingSphere(Math::Vector &pos, float &radius) override;
|
||||
void SetShieldRadius(float radius) override;
|
||||
float GetShieldRadius() override;
|
||||
|
||||
void SetFloorHeight(float height) override;
|
||||
void FloorAdjust() override;
|
||||
|
||||
void SetLinVibration(Math::Vector dir) override;
|
||||
Math::Vector GetLinVibration() override;
|
||||
void SetCirVibration(Math::Vector dir) override;
|
||||
Math::Vector GetCirVibration() override;
|
||||
void SetTilt(Math::Vector dir) override;
|
||||
Math::Vector GetTilt() override;
|
||||
|
||||
void SetPosition(int part, const Math::Vector &pos) override;
|
||||
Math::Vector GetPosition(int part) override;
|
||||
void SetAngle(int part, const Math::Vector &angle) override;
|
||||
Math::Vector GetAngle(int part) override;
|
||||
void SetAngleY(int part, float angle) override;
|
||||
void SetAngleX(int part, float angle) override;
|
||||
void SetAngleZ(int part, float angle) override;
|
||||
float GetAngleY(int part) override;
|
||||
float GetAngleX(int part) override;
|
||||
float GetAngleZ(int part) override;
|
||||
void SetZoom(int part, float zoom) override;
|
||||
void SetZoom(int part, Math::Vector zoom) override;
|
||||
Math::Vector GetZoom(int part) override;
|
||||
void SetZoomX(int part, float zoom) override;
|
||||
float GetZoomX(int part) override;
|
||||
void SetZoomY(int part, float zoom) override;
|
||||
float GetZoomY(int part) override;
|
||||
void SetZoomZ(int part, float zoom) override;
|
||||
float GetZoomZ(int part) override;
|
||||
|
||||
void SetTrainer(bool bEnable) override;
|
||||
bool GetTrainer() override;
|
||||
|
||||
void SetToy(bool bEnable) override;
|
||||
bool GetToy() override;
|
||||
|
||||
void SetManual(bool bManual) override;
|
||||
bool GetManual() override;
|
||||
|
||||
void SetResetCap(ResetCap cap) override;
|
||||
ResetCap GetResetCap() override;
|
||||
void SetResetBusy(bool bBusy) override;
|
||||
bool GetResetBusy() override;
|
||||
void SetResetPosition(const Math::Vector &pos) override;
|
||||
Math::Vector GetResetPosition() override;
|
||||
void SetResetAngle(const Math::Vector &angle) override;
|
||||
Math::Vector GetResetAngle() override;
|
||||
void SetResetRun(Program* run) override;
|
||||
Program* GetResetRun() override;
|
||||
|
||||
void SetMasterParticle(int part, int parti) override;
|
||||
int GetMasterParticle(int part) override;
|
||||
|
||||
void SetPower(CObject* power) override;
|
||||
CObject* GetPower() override;
|
||||
void SetCargo(CObject* cargo) override;
|
||||
CObject* GetCargo() override;
|
||||
void SetTransporter(CObject* transporter) override;
|
||||
CObject* GetTransporter() override;
|
||||
void SetTransporterPart(int part) override;
|
||||
|
||||
bool SetCmdLine(int rank, float value) override;
|
||||
float GetCmdLine(int rank) override;
|
||||
|
||||
Math::Matrix* GetRotateMatrix(int part) override;
|
||||
Math::Matrix* GetWorldMatrix(int part) override;
|
||||
|
||||
void SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
|
||||
Math::Vector &lookat, Math::Vector &upVec,
|
||||
Gfx::CameraType type) override;
|
||||
|
||||
void GetCharacter(Character* character) override;
|
||||
Character* GetCharacter() override;
|
||||
|
||||
float GetAbsTime() override;
|
||||
|
||||
void SetEnergy(float level) override;
|
||||
float GetEnergy() override;
|
||||
|
||||
float GetCapacity() override;
|
||||
|
||||
void SetShield(float level) override;
|
||||
float GetShield() override;
|
||||
|
||||
void SetRange(float delay) override;
|
||||
float GetRange() override;
|
||||
|
||||
void SetTransparency(float value) override;
|
||||
|
||||
void SetFixed(bool bFixed) override;
|
||||
bool GetFixed() override;
|
||||
|
||||
void SetClip(bool bClip) override;
|
||||
bool GetClip() override;
|
||||
|
||||
void SetTeam(int team) override;
|
||||
int GetTeam() override;
|
||||
|
||||
bool JostleObject(float force) override;
|
||||
|
||||
void StartDetectEffect(CObject *target, bool bFound) override;
|
||||
|
||||
void SetVirusMode(bool bEnable) override;
|
||||
bool GetVirusMode() override;
|
||||
float GetVirusTime() override;
|
||||
|
||||
void SetCameraType(Gfx::CameraType type) override;
|
||||
Gfx::CameraType GetCameraType() override;
|
||||
void SetCameraDist(float dist) override;
|
||||
float GetCameraDist() override;
|
||||
void SetCameraLock(bool bLock) override;
|
||||
bool GetCameraLock() override;
|
||||
|
||||
void SetHighlight(bool mode) override;
|
||||
|
||||
void SetSelect(bool bMode, bool bDisplayError=true) override;
|
||||
bool GetSelect(bool bReal=false) override;
|
||||
|
||||
void SetSelectable(bool bMode) override;
|
||||
bool GetSelectable() override;
|
||||
|
||||
void SetActivity(bool bMode) override;
|
||||
bool GetActivity() override;
|
||||
|
||||
void SetVisible(bool bVisible) override;
|
||||
|
||||
void SetEnable(bool bEnable) override;
|
||||
bool GetEnable() override;
|
||||
|
||||
void SetCheckToken(bool bMode) override;
|
||||
bool GetCheckToken() override;
|
||||
|
||||
void SetProxyActivate(bool bActivate) override;
|
||||
bool GetProxyActivate() override;
|
||||
void SetProxyDistance(float distance) override;
|
||||
|
||||
void SetMagnifyDamage(float factor) override;
|
||||
float GetMagnifyDamage() override;
|
||||
|
||||
void SetParam(float value) override;
|
||||
float GetParam() override;
|
||||
void SetIgnoreBuildCheck(bool bIgnoreBuildCheck) override;
|
||||
bool GetIgnoreBuildCheck() override;
|
||||
|
||||
void SetExploding(bool bExplo) override;
|
||||
bool IsExploding() override;
|
||||
void SetLock(bool bLock) override;
|
||||
bool GetLock() override;
|
||||
void SetSpaceshipCargo(bool bCargo) override;
|
||||
bool IsSpaceshipCargo() override;
|
||||
void SetBurn(bool bBurn) override;
|
||||
bool GetBurn() override;
|
||||
void SetDead(bool bDead) override;
|
||||
bool GetDead() override;
|
||||
bool GetRuin() override;
|
||||
bool GetActive() override;
|
||||
|
||||
void SetGunGoalV(float gunGoal) override;
|
||||
void SetGunGoalH(float gunGoal) override;
|
||||
float GetGunGoalV() override;
|
||||
float GetGunGoalH() override;
|
||||
|
||||
bool StartShowLimit() override;
|
||||
void StopShowLimit() override;
|
||||
|
||||
bool IsProgram() override;
|
||||
void CreateSelectParticle() override;
|
||||
|
||||
void SetRunScript(CScript* script) override;
|
||||
CScript* GetRunScript() override;
|
||||
CBotVar* GetBotVar() override;
|
||||
CPhysics* GetPhysics() override;
|
||||
CBrain* GetBrain() override;
|
||||
CMotion* GetMotion() override;
|
||||
CAuto* GetAuto() override;
|
||||
|
||||
void SetDefRank(int rank) override;
|
||||
int GetDefRank() override;
|
||||
|
||||
bool GetTooltipName(std::string& name) override;
|
||||
|
||||
void AddDeselList(CObject* pObj) override;
|
||||
CObject* SubDeselList() override;
|
||||
void DeleteDeselList(CObject* pObj) override;
|
||||
|
||||
bool CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type = Gfx::ENG_SHADOW_NORM) override;
|
||||
bool CreateShadowLight(float height, Gfx::Color color) override;
|
||||
bool CreateEffectLight(float height, Gfx::Color color) override;
|
||||
|
||||
void FlatParent() override;
|
||||
|
||||
void SetInfoReturn(float value) override;
|
||||
float GetInfoReturn() override;
|
||||
|
||||
protected:
|
||||
bool EventFrame(const Event &event);
|
||||
void VirusFrame(float rTime);
|
||||
void PartiFrame(float rTime);
|
||||
void InitPart(int part);
|
||||
void UpdateTotalPart();
|
||||
int SearchDescendant(int parent, int n);
|
||||
void UpdateEnergyMapping();
|
||||
bool UpdateTransformObject(int part, bool bForceUpdate);
|
||||
bool UpdateTransformObject();
|
||||
void UpdateSelectParticle();
|
||||
|
||||
protected:
|
||||
Gfx::CEngine* m_engine;
|
||||
Gfx::CLightManager* m_lightMan;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::CCamera* m_camera;
|
||||
Gfx::CParticle* m_particle;
|
||||
std::unique_ptr<CPhysics> m_physics;
|
||||
std::unique_ptr<CBrain> m_brain;
|
||||
std::unique_ptr<CMotion> m_motion;
|
||||
std::unique_ptr<CAuto> m_auto;
|
||||
CRobotMain* m_main;
|
||||
CSoundInterface* m_sound;
|
||||
CBotVar* m_botVar;
|
||||
CScript* m_runScript;
|
||||
|
||||
std::string m_name; // name of the object
|
||||
Character m_character; // characteristic
|
||||
int m_option; // option
|
||||
int m_shadowLight; // number of light from the shadows
|
||||
float m_shadowHeight; // height of light from the shadows
|
||||
int m_effectLight; // number of light effects
|
||||
float m_effectHeight; // height of light effects
|
||||
Math::Vector m_linVibration; // linear vibration
|
||||
Math::Vector m_cirVibration; // circular vibration
|
||||
Math::Vector m_tilt; // tilt
|
||||
CObject* m_power; // battery used by the vehicle
|
||||
CObject* m_cargo; // object transported
|
||||
CObject* m_transporter; // object with the latter
|
||||
int m_transporterLink; // part
|
||||
float m_energy; // energy contained (if battery)
|
||||
float m_lastEnergy;
|
||||
float m_capacity; // capacity (if battery)
|
||||
float m_shield; // shield
|
||||
float m_range; // flight range
|
||||
float m_transparency; // transparency (0..1)
|
||||
float m_aTime;
|
||||
float m_shotTime; // time since last shot
|
||||
bool m_bVirusMode; // virus activated/triggered
|
||||
float m_virusTime; // lifetime of the virus
|
||||
float m_lastVirusParticle;
|
||||
bool m_bSelect; // object selected
|
||||
bool m_bSelectable; // selectable object
|
||||
bool m_bCheckToken; // object with audited tokens
|
||||
bool m_bVisible; // object active but undetectable
|
||||
bool m_bEnable; // dead object
|
||||
bool m_bProxyActivate; // active object so close
|
||||
bool m_bLock;
|
||||
bool m_bExplo;
|
||||
bool m_bCargo;
|
||||
bool m_bBurn;
|
||||
bool m_bDead;
|
||||
bool m_bFlat;
|
||||
bool m_bTrainer; // drive vehicle (without remote)
|
||||
bool m_bToy; // toy key
|
||||
bool m_bManual; // manual control (Scribbler)
|
||||
bool m_bIgnoreBuildCheck;
|
||||
bool m_bFixed;
|
||||
bool m_bClip;
|
||||
bool m_bShowLimit;
|
||||
float m_showLimitRadius;
|
||||
float m_gunGoalV;
|
||||
float m_gunGoalH;
|
||||
Gfx::CameraType m_cameraType;
|
||||
float m_cameraDist;
|
||||
bool m_bCameraLock;
|
||||
int m_defRank;
|
||||
float m_magnifyDamage;
|
||||
float m_proxyDistance;
|
||||
float m_param;
|
||||
int m_team;
|
||||
|
||||
int m_crashSphereUsed; // number of spheres used
|
||||
Math::Vector m_crashSpherePos[MAXCRASHSPHERE];
|
||||
float m_crashSphereRadius[MAXCRASHSPHERE];
|
||||
float m_crashSphereHardness[MAXCRASHSPHERE];
|
||||
Sound m_crashSphereSound[MAXCRASHSPHERE];
|
||||
Math::Vector m_globalSpherePos;
|
||||
float m_globalSphereRadius;
|
||||
Math::Vector m_jostlingSpherePos;
|
||||
float m_jostlingSphereRadius;
|
||||
float m_shieldRadius;
|
||||
|
||||
int m_totalPart;
|
||||
ObjectPart m_objectPart[OBJECTMAXPART];
|
||||
|
||||
int m_totalDesectList;
|
||||
CObject* m_objectDeselectList[OBJECTMAXDESELLIST];
|
||||
|
||||
int m_partiSel[4];
|
||||
|
||||
ResetCap m_resetCap;
|
||||
bool m_bResetBusy;
|
||||
Math::Vector m_resetPosition;
|
||||
Math::Vector m_resetAngle;
|
||||
Program* m_resetRun;
|
||||
|
||||
float m_infoReturn;
|
||||
|
||||
float m_cmdLine[OBJECTMAXCMDLINE];
|
||||
};
|
|
@ -0,0 +1,307 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file object/old_object_interface.h
|
||||
* \brief Legacy CObject interface
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "graphics/engine/engine.h"
|
||||
#include "graphics/engine/camera.h"
|
||||
|
||||
#include "object/object_type.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class CApplication;
|
||||
class CPhysics;
|
||||
class CBrain;
|
||||
class CMotion;
|
||||
class CAuto;
|
||||
class CDisplayText;
|
||||
class CRobotMain;
|
||||
class CBotVar;
|
||||
class CScript;
|
||||
class CLevelParserLine;
|
||||
struct Program;
|
||||
|
||||
|
||||
struct Character
|
||||
{
|
||||
float wheelFront; // position X of the front wheels
|
||||
float wheelBack; // position X of the back wheels
|
||||
float wheelLeft; // position Z of the left wheels
|
||||
float wheelRight; // position Z of the right wheels
|
||||
float height; // normal height on top of ground
|
||||
Math::Vector posPower; // position of the battery
|
||||
};
|
||||
|
||||
enum class ExplosionType
|
||||
{
|
||||
Bang = 1,
|
||||
Burn = 2,
|
||||
Water = 3,
|
||||
};
|
||||
|
||||
enum ResetCap
|
||||
{
|
||||
RESET_NONE = 0,
|
||||
RESET_MOVE = 1,
|
||||
RESET_DELETE = 2,
|
||||
};
|
||||
|
||||
class COldObjectInterface
|
||||
{
|
||||
public:
|
||||
virtual ~COldObjectInterface() {}
|
||||
|
||||
virtual void Simplify() = 0;
|
||||
virtual bool ExplodeObject(ExplosionType type, float force, float decay=1.0f) = 0;
|
||||
|
||||
virtual void UpdateMapping() = 0;
|
||||
|
||||
virtual void DeletePart(int part) = 0;
|
||||
virtual void SetObjectRank(int part, int objRank) = 0;
|
||||
virtual int GetObjectRank(int part) = 0;
|
||||
virtual void SetObjectParent(int part, int parent) = 0;
|
||||
virtual void SetType(ObjectType type) = 0;
|
||||
virtual const char* GetName() = 0;
|
||||
virtual int GetOption() = 0;
|
||||
|
||||
virtual void SetDrawWorld(bool bDraw) = 0;
|
||||
virtual void SetDrawFront(bool bDraw) = 0;
|
||||
|
||||
virtual bool ReadProgram(Program* program, const char* filename) = 0;
|
||||
virtual bool WriteProgram(Program* program, const char* filename) = 0;
|
||||
|
||||
virtual int GetShadowLight() = 0;
|
||||
virtual int GetEffectLight() = 0;
|
||||
|
||||
virtual void FlushCrashShere() = 0;
|
||||
virtual int CreateCrashSphere(Math::Vector pos, float radius, Sound sound, float hardness=0.45f) = 0;
|
||||
virtual int GetCrashSphereTotal() = 0;
|
||||
virtual bool GetCrashSphere(int rank, Math::Vector &pos, float &radius) = 0;
|
||||
virtual float GetCrashSphereHardness(int rank) = 0;
|
||||
virtual Sound GetCrashSphereSound(int rank) = 0;
|
||||
virtual void SetGlobalSphere(Math::Vector pos, float radius) = 0;
|
||||
virtual void GetGlobalSphere(Math::Vector &pos, float &radius) = 0;
|
||||
virtual void GetJostlingSphere(Math::Vector &pos, float &radius) = 0;
|
||||
virtual void SetShieldRadius(float radius) = 0;
|
||||
virtual float GetShieldRadius() = 0;
|
||||
|
||||
virtual void SetFloorHeight(float height) = 0;
|
||||
virtual void FloorAdjust() = 0;
|
||||
|
||||
virtual void SetLinVibration(Math::Vector dir) = 0;
|
||||
virtual Math::Vector GetLinVibration() = 0;
|
||||
virtual void SetCirVibration(Math::Vector dir) = 0;
|
||||
virtual Math::Vector GetCirVibration() = 0;
|
||||
virtual void SetTilt(Math::Vector dir) = 0;
|
||||
virtual Math::Vector GetTilt() = 0;
|
||||
|
||||
virtual void SetPosition(int part, const Math::Vector &pos) = 0;
|
||||
virtual Math::Vector GetPosition(int part) = 0;
|
||||
virtual void SetAngle(int part, const Math::Vector &angle) = 0;
|
||||
virtual Math::Vector GetAngle(int part) = 0;
|
||||
virtual void SetAngleY(int part, float angle) = 0;
|
||||
virtual void SetAngleX(int part, float angle) = 0;
|
||||
virtual void SetAngleZ(int part, float angle) = 0;
|
||||
virtual float GetAngleY(int part) = 0;
|
||||
virtual float GetAngleX(int part) = 0;
|
||||
virtual float GetAngleZ(int part) = 0;
|
||||
virtual void SetZoom(int part, float zoom) = 0;
|
||||
virtual void SetZoom(int part, Math::Vector zoom) = 0;
|
||||
virtual Math::Vector GetZoom(int part) = 0;
|
||||
virtual void SetZoomX(int part, float zoom) = 0;
|
||||
virtual float GetZoomX(int part) = 0;
|
||||
virtual void SetZoomY(int part, float zoom) = 0;
|
||||
virtual float GetZoomY(int part) = 0;
|
||||
virtual void SetZoomZ(int part, float zoom) = 0;
|
||||
virtual float GetZoomZ(int part) = 0;
|
||||
|
||||
virtual void SetTrainer(bool bEnable) = 0;
|
||||
virtual bool GetTrainer() = 0;
|
||||
|
||||
virtual void SetToy(bool bEnable) = 0;
|
||||
virtual bool GetToy() = 0;
|
||||
|
||||
virtual void SetManual(bool bManual) = 0;
|
||||
virtual bool GetManual() = 0;
|
||||
|
||||
virtual void SetResetCap(ResetCap cap) = 0;
|
||||
virtual ResetCap GetResetCap() = 0;
|
||||
virtual void SetResetBusy(bool bBusy) = 0;
|
||||
virtual bool GetResetBusy() = 0;
|
||||
virtual void SetResetPosition(const Math::Vector &pos) = 0;
|
||||
virtual Math::Vector GetResetPosition() = 0;
|
||||
virtual void SetResetAngle(const Math::Vector &angle) = 0;
|
||||
virtual Math::Vector GetResetAngle() = 0;
|
||||
virtual void SetResetRun(Program* run) = 0;
|
||||
virtual Program* GetResetRun() = 0;
|
||||
|
||||
virtual void SetMasterParticle(int part, int parti) = 0;
|
||||
virtual int GetMasterParticle(int part) = 0;
|
||||
|
||||
virtual void SetPower(CObject* power) = 0;
|
||||
virtual CObject* GetPower() = 0;
|
||||
virtual void SetCargo(CObject* cargo) = 0;
|
||||
virtual CObject* GetCargo() = 0;
|
||||
virtual void SetTransporter(CObject* transporter) = 0;
|
||||
virtual CObject* GetTransporter() = 0;
|
||||
virtual void SetTransporterPart(int part) = 0;
|
||||
|
||||
virtual bool SetCmdLine(int rank, float value) = 0;
|
||||
virtual float GetCmdLine(int rank) = 0;
|
||||
|
||||
virtual Math::Matrix* GetRotateMatrix(int part) = 0;
|
||||
virtual Math::Matrix* GetWorldMatrix(int part) = 0;
|
||||
|
||||
virtual void SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
|
||||
Math::Vector &lookat, Math::Vector &upVec,
|
||||
Gfx::CameraType type) = 0;
|
||||
|
||||
virtual void GetCharacter(Character* character) = 0;
|
||||
virtual Character* GetCharacter() = 0;
|
||||
|
||||
virtual float GetAbsTime() = 0;
|
||||
|
||||
virtual void SetEnergy(float level) = 0;
|
||||
virtual float GetEnergy() = 0;
|
||||
|
||||
virtual float GetCapacity() = 0;
|
||||
|
||||
virtual void SetShield(float level) = 0;
|
||||
virtual float GetShield() = 0;
|
||||
|
||||
virtual void SetRange(float delay) = 0;
|
||||
virtual float GetRange() = 0;
|
||||
|
||||
virtual void SetTransparency(float value) = 0;
|
||||
|
||||
virtual void SetFixed(bool bFixed) = 0;
|
||||
virtual bool GetFixed() = 0;
|
||||
|
||||
virtual void SetClip(bool bClip) = 0;
|
||||
virtual bool GetClip() = 0;
|
||||
|
||||
virtual void SetTeam(int team) = 0;
|
||||
virtual int GetTeam() = 0;
|
||||
|
||||
virtual bool JostleObject(float force) = 0;
|
||||
|
||||
virtual void StartDetectEffect(CObject *target, bool bFound) = 0;
|
||||
|
||||
virtual void SetVirusMode(bool bEnable) = 0;
|
||||
virtual bool GetVirusMode() = 0;
|
||||
virtual float GetVirusTime() = 0;
|
||||
|
||||
virtual void SetCameraType(Gfx::CameraType type) = 0;
|
||||
virtual Gfx::CameraType GetCameraType() = 0;
|
||||
virtual void SetCameraDist(float dist) = 0;
|
||||
virtual float GetCameraDist() = 0;
|
||||
virtual void SetCameraLock(bool bLock) = 0;
|
||||
virtual bool GetCameraLock() = 0;
|
||||
|
||||
virtual void SetHighlight(bool mode) = 0;
|
||||
|
||||
virtual void SetSelect(bool bMode, bool bDisplayError=true) = 0;
|
||||
virtual bool GetSelect(bool bReal=false) = 0;
|
||||
|
||||
virtual void SetSelectable(bool bMode) = 0;
|
||||
virtual bool GetSelectable() = 0;
|
||||
|
||||
virtual void SetActivity(bool bMode) = 0;
|
||||
virtual bool GetActivity() = 0;
|
||||
|
||||
virtual void SetVisible(bool bVisible) = 0;
|
||||
|
||||
virtual void SetEnable(bool bEnable) = 0;
|
||||
virtual bool GetEnable() = 0;
|
||||
|
||||
virtual void SetCheckToken(bool bMode) = 0;
|
||||
virtual bool GetCheckToken() = 0;
|
||||
|
||||
virtual void SetProxyActivate(bool bActivate) = 0;
|
||||
virtual bool GetProxyActivate() = 0;
|
||||
virtual void SetProxyDistance(float distance) = 0;
|
||||
|
||||
virtual void SetMagnifyDamage(float factor) = 0;
|
||||
virtual float GetMagnifyDamage() = 0;
|
||||
|
||||
virtual void SetParam(float value) = 0;
|
||||
virtual float GetParam() = 0;
|
||||
virtual void SetIgnoreBuildCheck(bool bIgnoreBuildCheck) = 0;
|
||||
virtual bool GetIgnoreBuildCheck() = 0;
|
||||
|
||||
virtual void SetExploding(bool bExplo) = 0;
|
||||
virtual bool IsExploding() = 0;
|
||||
virtual void SetLock(bool bLock) = 0;
|
||||
virtual bool GetLock() = 0;
|
||||
virtual void SetSpaceshipCargo(bool bCargo) = 0;
|
||||
virtual bool IsSpaceshipCargo() = 0;
|
||||
virtual void SetBurn(bool bBurn) = 0;
|
||||
virtual bool GetBurn() = 0;
|
||||
virtual void SetDead(bool bDead) = 0;
|
||||
virtual bool GetDead() = 0;
|
||||
virtual bool GetRuin() = 0;
|
||||
virtual bool GetActive() = 0;
|
||||
|
||||
virtual void SetGunGoalV(float gunGoal) = 0;
|
||||
virtual void SetGunGoalH(float gunGoal) = 0;
|
||||
virtual float GetGunGoalV() = 0;
|
||||
virtual float GetGunGoalH() = 0;
|
||||
|
||||
virtual bool StartShowLimit() = 0;
|
||||
virtual void StopShowLimit() = 0;
|
||||
|
||||
virtual bool IsProgram() = 0;
|
||||
virtual void CreateSelectParticle() = 0;
|
||||
|
||||
virtual void SetRunScript(CScript* script) = 0;
|
||||
virtual CScript* GetRunScript() = 0;
|
||||
virtual CBotVar* GetBotVar() = 0;
|
||||
virtual CPhysics* GetPhysics() = 0;
|
||||
virtual CBrain* GetBrain() = 0;
|
||||
virtual CMotion* GetMotion() = 0;
|
||||
virtual CAuto* GetAuto() = 0;
|
||||
|
||||
virtual void SetDefRank(int rank) = 0;
|
||||
virtual int GetDefRank() = 0;
|
||||
|
||||
virtual bool GetTooltipName(std::string& name) = 0;
|
||||
|
||||
virtual void AddDeselList(CObject* pObj) = 0;
|
||||
virtual CObject* SubDeselList() = 0;
|
||||
virtual void DeleteDeselList(CObject* pObj) = 0;
|
||||
|
||||
virtual bool CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type = Gfx::ENG_SHADOW_NORM) = 0;
|
||||
virtual bool CreateShadowLight(float height, Gfx::Color color) = 0;
|
||||
virtual bool CreateEffectLight(float height, Gfx::Color color) = 0;
|
||||
|
||||
virtual void FlatParent() = 0;
|
||||
|
||||
virtual void SetInfoReturn(float value) = 0;
|
||||
virtual float GetInfoReturn() = 0;
|
||||
};
|
||||
|
|
@ -2616,19 +2616,25 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
// Advances all the robots, but not toto.
|
||||
for (CObject* obj : m_objMan->GetAllObjects())
|
||||
{
|
||||
if (pm != nullptr) pm->UpdateObject(obj);
|
||||
if (obj->GetTransporter() != nullptr) continue;
|
||||
ObjectType type = obj->GetType();
|
||||
if (type == OBJECT_TOTO)
|
||||
if (pm != nullptr)
|
||||
pm->UpdateObject(obj);
|
||||
|
||||
if (obj->GetTransporter() != nullptr)
|
||||
continue;
|
||||
|
||||
if (obj->GetType() == OBJECT_TOTO)
|
||||
toto = obj;
|
||||
else
|
||||
obj->EventProcess(event);
|
||||
else if (obj->Implements(ObjectInterfaceType::Interactive))
|
||||
dynamic_cast<CInteractiveObject*>(obj)->EventProcess(event);
|
||||
}
|
||||
// Advances all objects transported by robots.
|
||||
for (CObject* obj : m_objMan->GetAllObjects())
|
||||
{
|
||||
if (obj->GetTransporter() == nullptr) continue;
|
||||
obj->EventProcess(event);
|
||||
if (obj->GetTransporter() == nullptr)
|
||||
continue;
|
||||
|
||||
if (obj->Implements(ObjectInterfaceType::Interactive))
|
||||
dynamic_cast<CInteractiveObject*>(obj)->EventProcess(event);
|
||||
}
|
||||
|
||||
m_engine->GetPyroManager()->EventProcess(event);
|
||||
|
@ -2652,7 +2658,7 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
|
||||
// Advances toto following the camera, because its position depends on the camera.
|
||||
if (toto != nullptr)
|
||||
toto->EventProcess(event);
|
||||
dynamic_cast<CInteractiveObject*>(toto)->EventProcess(event);
|
||||
|
||||
HiliteFrame(event.rTime);
|
||||
|
||||
|
@ -2791,7 +2797,10 @@ bool CRobotMain::EventObject(const Event &event)
|
|||
|
||||
for (CObject* obj : m_objMan->GetAllObjects())
|
||||
{
|
||||
obj->EventProcess(event);
|
||||
if (obj->Implements(ObjectInterfaceType::Interactive))
|
||||
{
|
||||
dynamic_cast<CInteractiveObject*>(obj)->EventProcess(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_resetCreate)
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
|
||||
CExchangePost::CExchangePost(int id)
|
||||
: CObject(id)
|
||||
: COldObject(id)
|
||||
, m_infoUpdate(false)
|
||||
{
|
||||
m_type = OBJECT_INFO;
|
||||
|
@ -187,7 +187,7 @@ void CExchangePost::SetInfoUpdate(bool update)
|
|||
|
||||
void CExchangePost::Write(CLevelParserLine* line)
|
||||
{
|
||||
CObject::Write(line);
|
||||
COldObject::Write(line);
|
||||
|
||||
int i = 0;
|
||||
for (const auto& info : m_infoList)
|
||||
|
@ -204,7 +204,7 @@ void CExchangePost::Write(CLevelParserLine* line)
|
|||
|
||||
void CExchangePost::Read(CLevelParserLine* line)
|
||||
{
|
||||
CObject::Read(line);
|
||||
COldObject::Read(line);
|
||||
|
||||
ReadInfo(line);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "object/object.h"
|
||||
#include "object/old_object.h"
|
||||
#include "object/auto/auto.h"
|
||||
|
||||
#include <string>
|
||||
|
@ -41,7 +41,7 @@ class CModelManager;
|
|||
class CEngine;
|
||||
}
|
||||
|
||||
class CExchangePost : public CObject
|
||||
class CExchangePost : public COldObject
|
||||
{
|
||||
public:
|
||||
CExchangePost(int id);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "ui/target.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
#include "object/object_manager.h"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue