From f1684f85be1a61b5ab8a0a739dabec8b1b9af193 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 2 Jul 2015 23:48:30 +0200 Subject: [PATCH] Introduce new CObject base class and mixin class framework --- src/CMakeLists.txt | 2 +- src/graphics/engine/pyro.cpp | 1 + src/object/interactive_object.h | 41 ++ src/object/object.h | 489 +++------------------- src/object/object_factory.cpp | 65 +-- src/object/object_factory.h | 3 +- src/object/object_interface_type.h | 39 ++ src/object/object_manager.cpp | 15 +- src/object/{object.cpp => old_object.cpp} | 410 +++++++++--------- src/object/old_object.h | 422 +++++++++++++++++++ src/object/old_object_interface.h | 307 ++++++++++++++ src/object/robotmain.cpp | 29 +- src/object/subclass/exchange_post.cpp | 6 +- src/object/subclass/exchange_post.h | 4 +- src/ui/target.cpp | 1 + 15 files changed, 1136 insertions(+), 698 deletions(-) create mode 100644 src/object/interactive_object.h create mode 100644 src/object/object_interface_type.h rename src/object/{object.cpp => old_object.cpp} (90%) create mode 100644 src/object/old_object.h create mode 100644 src/object/old_object_interface.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 832c186e..47ac897b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index aa589029..23eabaa3 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.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" diff --git a/src/object/interactive_object.h b/src/object/interactive_object.h new file mode 100644 index 00000000..2bfa08b7 --- /dev/null +++ b/src/object/interactive_object.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(ObjectInterfaceType::Interactive)] = true; + } + virtual ~CInteractiveObject() + {} + + virtual bool EventProcess(const Event& event) = 0; +}; diff --git a/src/object/object.h b/src/object/object.h index 979c66a1..77189eb6 100644 --- a/src/object/object.h +++ b/src/object/object.h @@ -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 - -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 physics); - void SetBrain(std::unique_ptr brain); - void SetMotion(std::unique_ptr motion); - void SetAuto(std::unique_ptr 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(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 m_physics; - std::unique_ptr m_brain; - std::unique_ptr m_motion; - std::unique_ptr 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 }; - diff --git a/src/object/object_factory.cpp b/src/object/object_factory.cpp index 520600ee..65143bb2 100644 --- a/src/object/object_factory.cpp +++ b/src/object/object_factory.cpp @@ -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; + 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 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 objAuto; diff --git a/src/object/object_factory.h b/src/object/object_factory.h index 8b4edaa8..0e3e6cd0 100644 --- a/src/object/object_factory.h +++ b/src/object/object_factory.h @@ -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; diff --git a/src/object/object_interface_type.h b/src/object/object_interface_type.h new file mode 100644 index 00000000..d80a2a42 --- /dev/null +++ b/src/object/object_interface_type.h @@ -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 + +/** + * \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(ObjectInterfaceType::Max)>; diff --git a/src/object/object_manager.cpp b/src/object/object_manager.cpp index 146383b8..d2cd6aa7 100644 --- a/src/object/object_manager.cpp +++ b/src/object/object_manager.cpp @@ -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(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(it.second.get()); + if (oldObj != nullptr) + { + bool all = true; + oldObj->DeleteObject(all); + } } m_objects.clear(); diff --git a/src/object/object.cpp b/src/object/old_object.cpp similarity index 90% rename from src/object/object.cpp rename to src/object/old_object.cpp index 1c8ff054..264f7a79 100644 --- a/src/object/object.cpp +++ b/src/object/old_object.cpp @@ -18,7 +18,7 @@ */ -#include "object/object.h" +#include "object/old_object.h" #include "CBot/CBotDll.h" @@ -183,8 +183,9 @@ void uObject(CBotVar* botThis, void* user) // Object's constructor. -CObject::CObject(int id) - : m_id(id) +COldObject::COldObject(int id) + : CObject(id, OBJECT_NULL) + , CInteractiveObject(m_implementedInterfaces) { m_sound = CApplication::GetInstancePointer()->GetSound(); m_engine = Gfx::CEngine::GetInstancePointer(); @@ -301,7 +302,7 @@ CObject::CObject(int id) // Object's destructor. -CObject::~CObject() +COldObject::~COldObject() { if ( m_botVar != nullptr ) { @@ -316,7 +317,7 @@ CObject::~CObject() // If bAll = true, it does not help, // because all objects in the scene are quickly destroyed! -void CObject::DeleteObject(bool bAll) +void COldObject::DeleteObject(bool bAll) { if ( m_botVar != 0 ) { @@ -447,7 +448,7 @@ void CObject::DeleteObject(bool bAll) // Simplifies a object (he was the brain, among others). -void CObject::Simplify() +void COldObject::Simplify() { if ( m_brain != nullptr ) { @@ -487,7 +488,7 @@ void CObject::Simplify() // If false is returned, the object is still screwed. // If true is returned, the object is destroyed. -bool CObject::ExplodeObject(ExplosionType type, float force, float decay) +bool COldObject::ExplodeObject(ExplosionType type, float force, float decay) { Gfx::PyroType pyroType; float loss, shield; @@ -723,7 +724,7 @@ bool CObject::ExplodeObject(ExplosionType type, float force, float decay) // Initializes a new part. -void CObject::InitPart(int part) +void COldObject::InitPart(int part) { m_objectPart[part].bUsed = true; m_objectPart[part].object = -1; @@ -749,7 +750,7 @@ void CObject::InitPart(int part) // Removes part. -void CObject::DeletePart(int part) +void COldObject::DeletePart(int part) { if ( !m_objectPart[part].bUsed ) return; @@ -764,7 +765,7 @@ void CObject::DeletePart(int part) UpdateTotalPart(); } -void CObject::UpdateTotalPart() +void COldObject::UpdateTotalPart() { int i; @@ -781,7 +782,7 @@ void CObject::UpdateTotalPart() // Specifies the number of the object of a part. -void CObject::SetObjectRank(int part, int objRank) +void COldObject::SetObjectRank(int part, int objRank) { if ( !m_objectPart[part].bUsed ) // object not created? { @@ -793,7 +794,7 @@ void CObject::SetObjectRank(int part, int objRank) // Returns the number of part. -int CObject::GetObjectRank(int part) +int COldObject::GetObjectRank(int part) { if ( !m_objectPart[part].bUsed ) return -1; return m_objectPart[part].object; @@ -803,7 +804,7 @@ int CObject::GetObjectRank(int part) // Reminder: Part 0 is always the father of all // and therefore the main part (eg the chassis of a car). -void CObject::SetObjectParent(int part, int parent) +void COldObject::SetObjectParent(int part, int parent) { m_objectPart[part].parentPart = parent; } @@ -811,7 +812,7 @@ void CObject::SetObjectParent(int part, int parent) // Specifies the type of the object. -void CObject::SetType(ObjectType type) +void COldObject::SetType(ObjectType type) { m_type = type; m_name = GetObjectName(m_type); @@ -844,38 +845,27 @@ void CObject::SetType(ObjectType type) } } -ObjectType CObject::GetType() -{ - return m_type; -} - -const char* CObject::GetName() +const char* COldObject::GetName() { return m_name.c_str(); } - // Choosing the option to use. -void CObject::SetOption(int option) +void COldObject::SetOption(int option) { m_option = option; } -int CObject::GetOption() +int COldObject::GetOption() { return m_option; } -int CObject::GetID() -{ - return m_id; -} - // Saves all the parameters of the object. -void CObject::Write(CLevelParserLine* line) +void COldObject::Write(CLevelParserLine* line) { Math::Vector pos; float value; @@ -980,7 +970,7 @@ void CObject::Write(CLevelParserLine* line) // Returns all parameters of the object. -void CObject::Read(CLevelParserLine* line) +void COldObject::Read(CLevelParserLine* line) { Math::Vector pos, dir; @@ -1052,7 +1042,7 @@ void CObject::Read(CLevelParserLine* line) // Seeking the nth son of a father. -int CObject::SearchDescendant(int parent, int n) +int COldObject::SearchDescendant(int parent, int n) { int i; @@ -1071,14 +1061,14 @@ int CObject::SearchDescendant(int parent, int n) // Removes all spheres used for collisions. -void CObject::FlushCrashShere() +void COldObject::FlushCrashShere() { m_crashSphereUsed = 0; } // Adds a new sphere. -int CObject::CreateCrashSphere(Math::Vector pos, float radius, Sound sound, +int COldObject::CreateCrashSphere(Math::Vector pos, float radius, Sound sound, float hardness) { float zoom; @@ -1095,7 +1085,7 @@ int CObject::CreateCrashSphere(Math::Vector pos, float radius, Sound sound, // Returns the number of spheres. -int CObject::GetCrashSphereTotal() +int COldObject::GetCrashSphereTotal() { return m_crashSphereUsed; } @@ -1103,7 +1093,7 @@ int CObject::GetCrashSphereTotal() // Returns a sphere for collisions. // The position is absolute in the world. -bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius) +bool COldObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius) { if ( rank < 0 || rank >= m_crashSphereUsed ) { @@ -1138,21 +1128,21 @@ bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius) // Returns the hardness of a sphere. -Sound CObject::GetCrashSphereSound(int rank) +Sound COldObject::GetCrashSphereSound(int rank) { return m_crashSphereSound[rank]; } // Returns the hardness of a sphere. -float CObject::GetCrashSphereHardness(int rank) +float COldObject::GetCrashSphereHardness(int rank) { return m_crashSphereHardness[rank]; } // Specifies the global sphere, relative to the object. -void CObject::SetGlobalSphere(Math::Vector pos, float radius) +void COldObject::SetGlobalSphere(Math::Vector pos, float radius) { float zoom; @@ -1163,7 +1153,7 @@ void CObject::SetGlobalSphere(Math::Vector pos, float radius) // Returns the global sphere, in the world. -void CObject::GetGlobalSphere(Math::Vector &pos, float &radius) +void COldObject::GetGlobalSphere(Math::Vector &pos, float &radius) { pos = Math::Transform(m_objectPart[0].matWorld, m_globalSpherePos); radius = m_globalSphereRadius; @@ -1172,7 +1162,7 @@ void CObject::GetGlobalSphere(Math::Vector &pos, float &radius) // Specifies the sphere of jostling, relative to the object. -void CObject::SetJostlingSphere(Math::Vector pos, float radius) +void COldObject::SetJostlingSphere(Math::Vector pos, float radius) { m_jostlingSpherePos = pos; m_jostlingSphereRadius = radius; @@ -1180,7 +1170,7 @@ void CObject::SetJostlingSphere(Math::Vector pos, float radius) // Specifies the sphere of jostling, in the world. -void CObject::GetJostlingSphere(Math::Vector &pos, float &radius) +void COldObject::GetJostlingSphere(Math::Vector &pos, float &radius) { pos = Math::Transform(m_objectPart[0].matWorld, m_jostlingSpherePos); radius = m_jostlingSphereRadius; @@ -1189,14 +1179,14 @@ void CObject::GetJostlingSphere(Math::Vector &pos, float &radius) // Specifies the radius of the shield. -void CObject::SetShieldRadius(float radius) +void COldObject::SetShieldRadius(float radius) { m_shieldRadius = radius; } // Returns the radius of the shield. -float CObject::GetShieldRadius() +float COldObject::GetShieldRadius() { return m_shieldRadius; } @@ -1204,7 +1194,7 @@ float CObject::GetShieldRadius() // Positioning an object on a certain height, above the ground. -void CObject::SetFloorHeight(float height) +void COldObject::SetFloorHeight(float height) { Math::Vector pos; @@ -1223,7 +1213,7 @@ void CObject::SetFloorHeight(float height) // Adjust the inclination of an object laying on the ground. -void CObject::FloorAdjust() +void COldObject::FloorAdjust() { Math::Vector pos, n; Math::Point nn; @@ -1248,7 +1238,7 @@ void CObject::FloorAdjust() // Getes the linear vibration. -void CObject::SetLinVibration(Math::Vector dir) +void COldObject::SetLinVibration(Math::Vector dir) { if ( m_linVibration.x != dir.x || m_linVibration.y != dir.y || @@ -1259,14 +1249,14 @@ void CObject::SetLinVibration(Math::Vector dir) } } -Math::Vector CObject::GetLinVibration() +Math::Vector COldObject::GetLinVibration() { return m_linVibration; } // Getes the circular vibration. -void CObject::SetCirVibration(Math::Vector dir) +void COldObject::SetCirVibration(Math::Vector dir) { if ( m_cirVibration.x != dir.x || m_cirVibration.y != dir.y || @@ -1277,14 +1267,14 @@ void CObject::SetCirVibration(Math::Vector dir) } } -Math::Vector CObject::GetCirVibration() +Math::Vector COldObject::GetCirVibration() { return m_cirVibration; } // Getes the inclination. -void CObject::SetTilt(Math::Vector dir) +void COldObject::SetTilt(Math::Vector dir) { if ( m_tilt.x != dir.x || m_tilt.y != dir.y || @@ -1295,7 +1285,7 @@ void CObject::SetTilt(Math::Vector dir) } } -Math::Vector CObject::GetTilt() +Math::Vector COldObject::GetTilt() { return m_tilt; } @@ -1303,7 +1293,7 @@ Math::Vector CObject::GetTilt() // Getes the position of center of the object. -void CObject::SetPosition(int part, const Math::Vector &pos) +void COldObject::SetPosition(int part, const Math::Vector &pos) { Math::Vector shPos, n[20], norm; float height, radius; @@ -1422,14 +1412,14 @@ void CObject::SetPosition(int part, const Math::Vector &pos) } } -Math::Vector CObject::GetPosition(int part) +Math::Vector COldObject::GetPosition(int part) { return m_objectPart[part].position; } // Getes the rotation around three axis. -void CObject::SetAngle(int part, const Math::Vector &angle) +void COldObject::SetAngle(int part, const Math::Vector &angle) { m_objectPart[part].angle = angle; m_objectPart[part].bRotate = true; // it will recalculate the matrices @@ -1440,14 +1430,14 @@ void CObject::SetAngle(int part, const Math::Vector &angle) } } -Math::Vector CObject::GetAngle(int part) +Math::Vector COldObject::GetAngle(int part) { return m_objectPart[part].angle; } // Getes the rotation about the axis Y. -void CObject::SetAngleY(int part, float angle) +void COldObject::SetAngleY(int part, float angle) { m_objectPart[part].angle.y = angle; m_objectPart[part].bRotate = true; // it will recalculate the matrices @@ -1460,7 +1450,7 @@ void CObject::SetAngleY(int part, float angle) // Getes the rotation about the axis X. -void CObject::SetAngleX(int part, float angle) +void COldObject::SetAngleX(int part, float angle) { m_objectPart[part].angle.x = angle; m_objectPart[part].bRotate = true; // it will recalculate the matrices @@ -1468,23 +1458,23 @@ void CObject::SetAngleX(int part, float angle) // Getes the rotation about the axis Z. -void CObject::SetAngleZ(int part, float angle) +void COldObject::SetAngleZ(int part, float angle) { m_objectPart[part].angle.z = angle; m_objectPart[part].bRotate = true; //it will recalculate the matrices } -float CObject::GetAngleY(int part) +float COldObject::GetAngleY(int part) { return m_objectPart[part].angle.y; } -float CObject::GetAngleX(int part) +float COldObject::GetAngleX(int part) { return m_objectPart[part].angle.x; } -float CObject::GetAngleZ(int part) +float COldObject::GetAngleZ(int part) { return m_objectPart[part].angle.z; } @@ -1492,7 +1482,7 @@ float CObject::GetAngleZ(int part) // Getes the global zoom. -void CObject::SetZoom(int part, float zoom) +void COldObject::SetZoom(int part, float zoom) { m_objectPart[part].bTranslate = true; // it will recalculate the matrices m_objectPart[part].zoom.x = zoom; @@ -1504,7 +1494,7 @@ void CObject::SetZoom(int part, float zoom) m_objectPart[part].zoom.z != 1.0f ); } -void CObject::SetZoom(int part, Math::Vector zoom) +void COldObject::SetZoom(int part, Math::Vector zoom) { m_objectPart[part].bTranslate = true; // it will recalculate the matrices m_objectPart[part].zoom = zoom; @@ -1514,12 +1504,12 @@ void CObject::SetZoom(int part, Math::Vector zoom) m_objectPart[part].zoom.z != 1.0f ); } -Math::Vector CObject::GetZoom(int part) +Math::Vector COldObject::GetZoom(int part) { return m_objectPart[part].zoom; } -void CObject::SetZoomX(int part, float zoom) +void COldObject::SetZoomX(int part, float zoom) { m_objectPart[part].bTranslate = true; // it will recalculate the matrices m_objectPart[part].zoom.x = zoom; @@ -1529,7 +1519,7 @@ void CObject::SetZoomX(int part, float zoom) m_objectPart[part].zoom.z != 1.0f ); } -void CObject::SetZoomY(int part, float zoom) +void COldObject::SetZoomY(int part, float zoom) { m_objectPart[part].bTranslate = true; // it will recalculate the matrices m_objectPart[part].zoom.y = zoom; @@ -1539,7 +1529,7 @@ void CObject::SetZoomY(int part, float zoom) m_objectPart[part].zoom.z != 1.0f ); } -void CObject::SetZoomZ(int part, float zoom) +void COldObject::SetZoomZ(int part, float zoom) { m_objectPart[part].bTranslate = true; // it will recalculate the matrices m_objectPart[part].zoom.z = zoom; @@ -1549,22 +1539,22 @@ void CObject::SetZoomZ(int part, float zoom) m_objectPart[part].zoom.z != 1.0f ); } -float CObject::GetZoomX(int part) +float COldObject::GetZoomX(int part) { return m_objectPart[part].zoom.x; } -float CObject::GetZoomY(int part) +float COldObject::GetZoomY(int part) { return m_objectPart[part].zoom.y; } -float CObject::GetZoomZ(int part) +float COldObject::GetZoomZ(int part) { return m_objectPart[part].zoom.z; } -void CObject::SetTrainer(bool bEnable) +void COldObject::SetTrainer(bool bEnable) { m_bTrainer = bEnable; @@ -1574,77 +1564,77 @@ void CObject::SetTrainer(bool bEnable) } } -bool CObject::GetTrainer() +bool COldObject::GetTrainer() { return m_bTrainer; } -void CObject::SetToy(bool bEnable) +void COldObject::SetToy(bool bEnable) { m_bToy = bEnable; } -bool CObject::GetToy() +bool COldObject::GetToy() { return m_bToy; } -void CObject::SetManual(bool bManual) +void COldObject::SetManual(bool bManual) { m_bManual = bManual; } -bool CObject::GetManual() +bool COldObject::GetManual() { return m_bManual; } -void CObject::SetResetCap(ResetCap cap) +void COldObject::SetResetCap(ResetCap cap) { m_resetCap = cap; } -ResetCap CObject::GetResetCap() +ResetCap COldObject::GetResetCap() { return m_resetCap; } -void CObject::SetResetBusy(bool bBusy) +void COldObject::SetResetBusy(bool bBusy) { m_bResetBusy = bBusy; } -bool CObject::GetResetBusy() +bool COldObject::GetResetBusy() { return m_bResetBusy; } -void CObject::SetResetPosition(const Math::Vector &pos) +void COldObject::SetResetPosition(const Math::Vector &pos) { m_resetPosition = pos; } -Math::Vector CObject::GetResetPosition() +Math::Vector COldObject::GetResetPosition() { return m_resetPosition; } -void CObject::SetResetAngle(const Math::Vector &angle) +void COldObject::SetResetAngle(const Math::Vector &angle) { m_resetAngle = angle; } -Math::Vector CObject::GetResetAngle() +Math::Vector COldObject::GetResetAngle() { return m_resetAngle; } -Program* CObject::GetResetRun() +Program* COldObject::GetResetRun() { return m_resetRun; } -void CObject::SetResetRun(Program* run) +void COldObject::SetResetRun(Program* run) { m_resetRun = run; } @@ -1652,12 +1642,12 @@ void CObject::SetResetRun(Program* run) // Management of the particle master. -void CObject::SetMasterParticle(int part, int parti) +void COldObject::SetMasterParticle(int part, int parti) { m_objectPart[part].masterParti = parti; } -int CObject::GetMasterParticle(int part) +int COldObject::GetMasterParticle(int part) { return m_objectPart[part].masterParti; } @@ -1665,31 +1655,31 @@ int CObject::GetMasterParticle(int part) // Management of the stack transport. -void CObject::SetPower(CObject* power) +void COldObject::SetPower(CObject* power) { m_power = power; } -CObject* CObject::GetPower() +CObject* COldObject::GetPower() { return m_power; } // Management of the object transport. -void CObject::SetCargo(CObject* cargo) +void COldObject::SetCargo(CObject* cargo) { m_cargo = cargo; } -CObject* CObject::GetCargo() +CObject* COldObject::GetCargo() { return m_cargo; } // Management of the object "transporter" that transports it. -void CObject::SetTransporter(CObject* transporter) +void COldObject::SetTransporter(CObject* transporter) { m_transporter = transporter; @@ -1697,36 +1687,36 @@ void CObject::SetTransporter(CObject* transporter) m_engine->SetObjectShadowHide(m_objectPart[0].object, (m_transporter != 0)); } -CObject* CObject::GetTransporter() +CObject* COldObject::GetTransporter() { return m_transporter; } // Management of the conveying portion. -void CObject::SetTransporterPart(int part) +void COldObject::SetTransporterPart(int part) { m_transporterLink = part; } -void CObject::SetInfoReturn(float value) +void COldObject::SetInfoReturn(float value) { m_infoReturn = value; } -float CObject::GetInfoReturn() +float COldObject::GetInfoReturn() { return m_infoReturn; } -bool CObject::SetCmdLine(int rank, float value) +bool COldObject::SetCmdLine(int rank, float value) { if ( rank < 0 || rank >= OBJECTMAXCMDLINE ) return false; m_cmdLine[rank] = value; return true; } -float CObject::GetCmdLine(int rank) +float COldObject::GetCmdLine(int rank) { if ( rank < 0 || rank >= OBJECTMAXCMDLINE ) return 0.0f; return m_cmdLine[rank]; @@ -1735,12 +1725,12 @@ float CObject::GetCmdLine(int rank) // Returns matrices of an object portion. -Math::Matrix* CObject::GetRotateMatrix(int part) +Math::Matrix* COldObject::GetRotateMatrix(int part) { return &m_objectPart[part].matRotate; } -Math::Matrix* CObject::GetWorldMatrix(int part) +Math::Matrix* COldObject::GetWorldMatrix(int part) { if ( m_objectPart[0].bTranslate || m_objectPart[0].bRotate ) @@ -1754,7 +1744,7 @@ Math::Matrix* CObject::GetWorldMatrix(int part) // Indicates whether the object should be drawn below the interface. -void CObject::SetDrawWorld(bool bDraw) +void COldObject::SetDrawWorld(bool bDraw) { int i; @@ -1769,7 +1759,7 @@ void CObject::SetDrawWorld(bool bDraw) // Indicates whether the object should be drawn over the interface. -void CObject::SetDrawFront(bool bDraw) +void COldObject::SetDrawFront(bool bDraw) { int i; @@ -1784,7 +1774,7 @@ void CObject::SetDrawFront(bool bDraw) // Creates shade under a vehicle as a negative light. -bool CObject::CreateShadowLight(float height, Gfx::Color color) +bool COldObject::CreateShadowLight(float height, Gfx::Color color) { if ( !m_engine->GetLightMode() ) return true; @@ -1816,14 +1806,14 @@ bool CObject::CreateShadowLight(float height, Gfx::Color color) // Returns the number of negative light shade. -int CObject::GetShadowLight() +int COldObject::GetShadowLight() { return m_shadowLight; } // Creates light for the effects of a vehicle. -bool CObject::CreateEffectLight(float height, Gfx::Color color) +bool COldObject::CreateEffectLight(float height, Gfx::Color color) { if ( !m_engine->GetLightMode() ) return true; @@ -1851,14 +1841,14 @@ bool CObject::CreateEffectLight(float height, Gfx::Color color) // Returns the number of light effects. -int CObject::GetEffectLight() +int COldObject::GetEffectLight() { return m_effectLight; } // Creates the circular shadow underneath a vehicle. -bool CObject::CreateShadowCircle(float radius, float intensity, +bool COldObject::CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type) { float zoom; @@ -1880,7 +1870,7 @@ bool CObject::CreateShadowCircle(float radius, float intensity, // Reads a program. -bool CObject::ReadProgram(Program* program, const char* filename) +bool COldObject::ReadProgram(Program* program, const char* filename) { if ( m_brain != nullptr ) { @@ -1891,7 +1881,7 @@ bool CObject::ReadProgram(Program* program, const char* filename) // Writes a program. -bool CObject::WriteProgram(Program* program, const char* filename) +bool COldObject::WriteProgram(Program* program, const char* filename) { if ( m_brain != nullptr ) { @@ -1906,7 +1896,7 @@ bool CObject::WriteProgram(Program* program, const char* filename) // Returns true if the matrix has changed. // The rotations occur in the order Y, Z and X. -bool CObject::UpdateTransformObject(int part, bool bForceUpdate) +bool COldObject::UpdateTransformObject(int part, bool bForceUpdate) { Math::Vector position, angle, eye; bool bModif = false; @@ -2009,7 +1999,7 @@ bool CObject::UpdateTransformObject(int part, bool bForceUpdate) // Assume a maximum of 4 degrees of freedom. // Appropriate, for example, to a body, an arm, forearm, hand and fingers. -bool CObject::UpdateTransformObject() +bool COldObject::UpdateTransformObject() { bool bUpdate1, bUpdate2, bUpdate3, bUpdate4; int level1, level2, level3, level4, rank; @@ -2071,7 +2061,7 @@ bool CObject::UpdateTransformObject() // Puts all the progeny flat (there is more than fathers). // This allows for debris independently from each other in all directions. -void CObject::FlatParent() +void COldObject::FlatParent() { int i; @@ -2099,7 +2089,7 @@ void CObject::FlatParent() // Updates the mapping of the texture of the pile. -void CObject::UpdateEnergyMapping() +void COldObject::UpdateEnergyMapping() { if (Math::IsEqual(m_energy, m_lastEnergy, 0.01f)) return; @@ -2149,7 +2139,7 @@ void CObject::UpdateEnergyMapping() // Manual action. -bool CObject::EventProcess(const Event &event) +bool COldObject::EventProcess(const Event &event) { if ( event.type == EVENT_KEY_DOWN ) { @@ -2235,7 +2225,7 @@ bool CObject::EventProcess(const Event &event) // Animates the object. -bool CObject::EventFrame(const Event &event) +bool COldObject::EventFrame(const Event &event) { if ( m_type == OBJECT_HUMAN && m_main->GetMainMovie() == MM_SATCOMopen ) { @@ -2274,7 +2264,7 @@ bool CObject::EventFrame(const Event &event) // Updates the mapping of the object. -void CObject::UpdateMapping() +void COldObject::UpdateMapping() { if ( m_type == OBJECT_POWER || m_type == OBJECT_ATOMIC || @@ -2288,7 +2278,7 @@ void CObject::UpdateMapping() // Management of viruses. -void CObject::VirusFrame(float rTime) +void COldObject::VirusFrame(float rTime) { Gfx::ParticleType type; Math::Vector pos, speed; @@ -2334,7 +2324,7 @@ void CObject::VirusFrame(float rTime) // Management particles mistresses. -void CObject::PartiFrame(float rTime) +void COldObject::PartiFrame(float rTime) { Math::Vector pos, angle, factor; int i, channel; @@ -2374,7 +2364,7 @@ void CObject::PartiFrame(float rTime) // Changes the perspective to view if it was like in the vehicle, // or behind the vehicle. -void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, +void COldObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, Math::Vector &lookat, Math::Vector &upVec, Gfx::CameraType type) { @@ -2515,12 +2505,12 @@ void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, // Management of features. -void CObject::GetCharacter(Character* character) +void COldObject::GetCharacter(Character* character) { memcpy(character, &m_character, sizeof(Character)); } -Character* CObject::GetCharacter() +Character* COldObject::GetCharacter() { return &m_character; } @@ -2528,7 +2518,7 @@ Character* CObject::GetCharacter() // Returns the absolute time. -float CObject::GetAbsTime() +float COldObject::GetAbsTime() { return m_aTime; } @@ -2537,14 +2527,14 @@ float CObject::GetAbsTime() // Management of energy contained in a battery. // Single subject possesses the battery energy, but not the vehicle that carries the battery! -void CObject::SetEnergy(float level) +void COldObject::SetEnergy(float level) { if ( level < 0.0f ) level = 0.0f; if ( level > 1.0f ) level = 1.0f; m_energy = level; } -float CObject::GetEnergy() +float COldObject::GetEnergy() { if ( m_type != OBJECT_POWER && m_type != OBJECT_ATOMIC && @@ -2558,12 +2548,12 @@ float CObject::GetEnergy() // Single subject possesses a battery capacity, // but not the vehicle that carries the battery! -void CObject::SetCapacity(float capacity) +void COldObject::SetCapacity(float capacity) { m_capacity = capacity; } -float CObject::GetCapacity() +float COldObject::GetCapacity() { return m_capacity; } @@ -2571,12 +2561,12 @@ float CObject::GetCapacity() // Management of the shield. -void CObject::SetShield(float level) +void COldObject::SetShield(float level) { m_shield = level; } -float CObject::GetShield() +float COldObject::GetShield() { if ( m_type == OBJECT_FRET || m_type == OBJECT_STONE || @@ -2614,12 +2604,12 @@ float CObject::GetShield() // Management of flight range (zero = infinity). -void CObject::SetRange(float delay) +void COldObject::SetRange(float delay) { m_range = delay; } -float CObject::GetRange() +float COldObject::GetRange() { return m_range; } @@ -2627,7 +2617,7 @@ float CObject::GetRange() // Management of transparency of the object. -void CObject::SetTransparency(float value) +void COldObject::SetTransparency(float value) { int i; @@ -2649,12 +2639,12 @@ void CObject::SetTransparency(float value) // Indicates whether an object is stationary (ant on the back). -void CObject::SetFixed(bool bFixed) +void COldObject::SetFixed(bool bFixed) { m_bFixed = bFixed; } -bool CObject::GetFixed() +bool COldObject::GetFixed() { return m_bFixed; } @@ -2662,12 +2652,12 @@ bool CObject::GetFixed() // Indicates whether an object is subjected to clipping (obstacles). -void CObject::SetClip(bool bClip) +void COldObject::SetClip(bool bClip) { m_bClip = bClip; } -bool CObject::GetClip() +bool COldObject::GetClip() { return m_bClip; } @@ -2675,12 +2665,12 @@ bool CObject::GetClip() // Controls object team -void CObject::SetTeam(int team) +void COldObject::SetTeam(int team) { m_team = team; } -int CObject::GetTeam() +int COldObject::GetTeam() { return m_team; } @@ -2688,7 +2678,7 @@ int CObject::GetTeam() // Pushes an object. -bool CObject::JostleObject(float force) +bool COldObject::JostleObject(float force) { if ( m_type == OBJECT_FLAGb || m_type == OBJECT_FLAGr || @@ -2715,7 +2705,7 @@ bool CObject::JostleObject(float force) // Beginning of the effect when the instruction "detect" is used. -void CObject::StartDetectEffect(CObject *target, bool bFound) +void COldObject::StartDetectEffect(CObject *target, bool bFound) { Math::Matrix* mat; Math::Vector pos, goal; @@ -2756,7 +2746,7 @@ void CObject::StartDetectEffect(CObject *target, bool bFound) // Management of time from which a virus is active. -void CObject::SetVirusMode(bool bEnable) +void COldObject::SetVirusMode(bool bEnable) { m_bVirusMode = bEnable; m_virusTime = 0.0f; @@ -2770,12 +2760,12 @@ void CObject::SetVirusMode(bool bEnable) } } -bool CObject::GetVirusMode() +bool COldObject::GetVirusMode() { return m_bVirusMode; } -float CObject::GetVirusTime() +float COldObject::GetVirusTime() { return m_virusTime; } @@ -2783,32 +2773,32 @@ float CObject::GetVirusTime() // Management mode of the camera. -void CObject::SetCameraType(Gfx::CameraType type) +void COldObject::SetCameraType(Gfx::CameraType type) { m_cameraType = type; } -Gfx::CameraType CObject::GetCameraType() +Gfx::CameraType COldObject::GetCameraType() { return m_cameraType; } -void CObject::SetCameraDist(float dist) +void COldObject::SetCameraDist(float dist) { m_cameraDist = dist; } -float CObject::GetCameraDist() +float COldObject::GetCameraDist() { return m_cameraDist; } -void CObject::SetCameraLock(bool bLock) +void COldObject::SetCameraLock(bool bLock) { m_bCameraLock = bLock; } -bool CObject::GetCameraLock() +bool COldObject::GetCameraLock() { return m_bCameraLock; } @@ -2817,7 +2807,7 @@ bool CObject::GetCameraLock() // Management of the demonstration of the object. -void CObject::SetHighlight(bool mode) +void COldObject::SetHighlight(bool mode) { if (mode) { @@ -2840,7 +2830,7 @@ void CObject::SetHighlight(bool mode) // Indicates whether the object is selected or not. -void CObject::SetSelect(bool bMode, bool bDisplayError) +void COldObject::SetSelect(bool bMode, bool bDisplayError) { Error err; @@ -2881,7 +2871,7 @@ void CObject::SetSelect(bool bMode, bool bDisplayError) // Indicates whether the object is selected or not. -bool CObject::GetSelect(bool bReal) +bool COldObject::GetSelect(bool bReal) { if ( !bReal && m_main->GetFixScene() ) return false; return m_bSelect; @@ -2890,14 +2880,14 @@ bool CObject::GetSelect(bool bReal) // Indicates whether the object is selectable or not. -void CObject::SetSelectable(bool bMode) +void COldObject::SetSelectable(bool bMode) { m_bSelectable = bMode; } // Indicates whether the object is selecionnable or not. -bool CObject::GetSelectable() +bool COldObject::GetSelectable() { return m_bSelectable; } @@ -2905,7 +2895,7 @@ bool CObject::GetSelectable() // Management of the activities of an object. -void CObject::SetActivity(bool bMode) +void COldObject::SetActivity(bool bMode) { if ( m_brain != nullptr ) { @@ -2913,7 +2903,7 @@ void CObject::SetActivity(bool bMode) } } -bool CObject::GetActivity() +bool COldObject::GetActivity() { if ( m_brain != nullptr ) { @@ -2925,14 +2915,14 @@ bool CObject::GetActivity() // Indicates if necessary to check the tokens of the object. -void CObject::SetCheckToken(bool bMode) +void COldObject::SetCheckToken(bool bMode) { m_bCheckToken = bMode; } // Indicates if necessary to check the tokens of the object. -bool CObject::GetCheckToken() +bool COldObject::GetCheckToken() { return m_bCheckToken; } @@ -2942,7 +2932,7 @@ bool CObject::GetCheckToken() // The object is not hidden or visually disabled, but ignores detections! // For example: underground worm. -void CObject::SetVisible(bool bVisible) +void COldObject::SetVisible(bool bVisible) { m_bVisible = bVisible; } @@ -2953,12 +2943,12 @@ void CObject::SetVisible(bool bVisible) // This mode is used for objects "resetables" // during training to simulate destruction. -void CObject::SetEnable(bool bEnable) +void COldObject::SetEnable(bool bEnable) { m_bEnable = bEnable; } -bool CObject::GetEnable() +bool COldObject::GetEnable() { return m_bEnable; } @@ -2966,22 +2956,22 @@ bool CObject::GetEnable() // Management mode or an object is only active when you're close. -void CObject::SetProxyActivate(bool bActivate) +void COldObject::SetProxyActivate(bool bActivate) { m_bProxyActivate = bActivate; } -bool CObject::GetProxyActivate() +bool COldObject::GetProxyActivate() { return m_bProxyActivate; } -void CObject::SetProxyDistance(float distance) +void COldObject::SetProxyDistance(float distance) { m_proxyDistance = distance; } -float CObject::GetProxyDistance() +float COldObject::GetProxyDistance() { return m_proxyDistance; } @@ -2989,12 +2979,12 @@ float CObject::GetProxyDistance() // Management of the method of increasing damage. -void CObject::SetMagnifyDamage(float factor) +void COldObject::SetMagnifyDamage(float factor) { m_magnifyDamage = factor; } -float CObject::GetMagnifyDamage() +float COldObject::GetMagnifyDamage() { return m_magnifyDamage; } @@ -3002,12 +2992,12 @@ float CObject::GetMagnifyDamage() // Management of free parameter. -void CObject::SetParam(float value) +void COldObject::SetParam(float value) { m_param = value; } -float CObject::GetParam() +float COldObject::GetParam() { return m_param; } @@ -3015,24 +3005,24 @@ float CObject::GetParam() // For example, a cube of titanium is blocked while it is used to make something, // or a vehicle is blocked as its construction is not finished. -void CObject::SetLock(bool bLock) +void COldObject::SetLock(bool bLock) { m_bLock = bLock; } -bool CObject::GetLock() +bool COldObject::GetLock() { return m_bLock; } // Ignore checks in build() function -void CObject::SetIgnoreBuildCheck(bool bIgnoreBuildCheck) +void COldObject::SetIgnoreBuildCheck(bool bIgnoreBuildCheck) { m_bIgnoreBuildCheck = bIgnoreBuildCheck; } -bool CObject::GetIgnoreBuildCheck() +bool COldObject::GetIgnoreBuildCheck() { return m_bIgnoreBuildCheck; } @@ -3040,12 +3030,12 @@ bool CObject::GetIgnoreBuildCheck() // Management of the mode "current explosion" of an object. // An object in this mode is not saving. -void CObject::SetExploding(bool bExplo) +void COldObject::SetExploding(bool bExplo) { m_bExplo = bExplo; } -bool CObject::IsExploding() +bool COldObject::IsExploding() { return m_bExplo; } @@ -3053,12 +3043,12 @@ bool CObject::IsExploding() // Mode management "cargo ship" during movies. -void CObject::SetSpaceshipCargo(bool bCargo) +void COldObject::SetSpaceshipCargo(bool bCargo) { m_bCargo = bCargo; } -bool CObject::IsSpaceshipCargo() +bool COldObject::IsSpaceshipCargo() { return m_bCargo; } @@ -3066,7 +3056,7 @@ bool CObject::IsSpaceshipCargo() // Management of the HS mode of an object. -void CObject::SetBurn(bool bBurn) +void COldObject::SetBurn(bool bBurn) { m_bBurn = bBurn; @@ -3077,12 +3067,12 @@ void CObject::SetBurn(bool bBurn) //? } } -bool CObject::GetBurn() +bool COldObject::GetBurn() { return m_bBurn; } -void CObject::SetDead(bool bDead) +void COldObject::SetDead(bool bDead) { m_bDead = bDead; @@ -3098,17 +3088,17 @@ void CObject::SetDead(bool bDead) //? } } -bool CObject::GetDead() +bool COldObject::GetDead() { return m_bDead; } -bool CObject::GetRuin() +bool COldObject::GetRuin() { return m_bBurn|m_bFlat; } -bool CObject::GetActive() +bool COldObject::GetActive() { return !m_bLock && !m_bBurn && !m_bFlat && m_bVisible && m_bEnable; } @@ -3116,7 +3106,7 @@ bool CObject::GetActive() // Management of the point of aim. -void CObject::SetGunGoalV(float gunGoal) +void COldObject::SetGunGoalV(float gunGoal) { if ( m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || @@ -3150,7 +3140,7 @@ void CObject::SetGunGoalV(float gunGoal) m_gunGoalV = gunGoal; } -void CObject::SetGunGoalH(float gunGoal) +void COldObject::SetGunGoalH(float gunGoal) { if ( m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || @@ -3184,12 +3174,12 @@ void CObject::SetGunGoalH(float gunGoal) m_gunGoalH = gunGoal; } -float CObject::GetGunGoalV() +float COldObject::GetGunGoalV() { return m_gunGoalV; } -float CObject::GetGunGoalH() +float COldObject::GetGunGoalH() { return m_gunGoalH; } @@ -3198,7 +3188,7 @@ float CObject::GetGunGoalH() // Shows the limits of the object. -bool CObject::StartShowLimit() +bool COldObject::StartShowLimit() { if ( m_showLimitRadius == 0.0f ) return false; @@ -3207,19 +3197,19 @@ bool CObject::StartShowLimit() return true; } -void CObject::StopShowLimit() +void COldObject::StopShowLimit() { m_bShowLimit = false; } -void CObject::SetShowLimitRadius(float radius) +void COldObject::SetShowLimitRadius(float radius) { m_showLimitRadius = radius; } // Indicates whether a program is under execution. -bool CObject::IsProgram() +bool COldObject::IsProgram() { if ( m_brain == nullptr ) return false; return m_brain->IsProgram(); @@ -3228,7 +3218,7 @@ bool CObject::IsProgram() // Creates or removes particles associated to the object. -void CObject::CreateSelectParticle() +void COldObject::CreateSelectParticle() { Math::Vector pos, speed; Math::Point dim; @@ -3290,7 +3280,7 @@ void CObject::CreateSelectParticle() // Updates the particles associated to the object. -void CObject::UpdateSelectParticle() +void COldObject::UpdateSelectParticle() { Math::Vector pos[4]; Math::Point dim[4]; @@ -3443,67 +3433,67 @@ void CObject::UpdateSelectParticle() // Getes the pointer to the current script execution. -void CObject::SetRunScript(CScript* script) +void COldObject::SetRunScript(CScript* script) { m_runScript = script; } -CScript* CObject::GetRunScript() +CScript* COldObject::GetRunScript() { return m_runScript; } // Returns the variables of "this" for CBOT. -CBotVar* CObject::GetBotVar() +CBotVar* COldObject::GetBotVar() { return m_botVar; } // Returns the physics associated to the object. -CPhysics* CObject::GetPhysics() +CPhysics* COldObject::GetPhysics() { return m_physics.get(); } -void CObject::SetPhysics(std::unique_ptr physics) +void COldObject::SetPhysics(std::unique_ptr physics) { m_physics = std::move(physics); } // Returns the brain associated to the object. -CBrain* CObject::GetBrain() +CBrain* COldObject::GetBrain() { return m_brain.get(); } -void CObject::SetBrain(std::unique_ptr brain) +void COldObject::SetBrain(std::unique_ptr brain) { m_brain = std::move(brain); } // Returns the movement associated to the object. -CMotion* CObject::GetMotion() +CMotion* COldObject::GetMotion() { return m_motion.get(); } -void CObject::SetMotion(std::unique_ptr motion) +void COldObject::SetMotion(std::unique_ptr motion) { m_motion = std::move(motion); } // Returns the controller associated to the object. -CAuto* CObject::GetAuto() +CAuto* COldObject::GetAuto() { return m_auto.get(); } -void CObject::SetAuto(std::unique_ptr automat) +void COldObject::SetAuto(std::unique_ptr automat) { m_auto = std::move(automat); } @@ -3512,12 +3502,12 @@ void CObject::SetAuto(std::unique_ptr automat) // Management of the position in the file definition. -void CObject::SetDefRank(int rank) +void COldObject::SetDefRank(int rank) { m_defRank = rank; } -int CObject::GetDefRank() +int COldObject::GetDefRank() { return m_defRank; } @@ -3525,7 +3515,7 @@ int CObject::GetDefRank() // Getes the object name for the tooltip. -bool CObject::GetTooltipName(std::string& name) +bool COldObject::GetTooltipName(std::string& name) { GetResource(RES_OBJECT, m_type, name); if(GetTeam() != 0) { @@ -3537,7 +3527,7 @@ bool CObject::GetTooltipName(std::string& name) // Adds the object previously selected in the list. -void CObject::AddDeselList(CObject* pObj) +void COldObject::AddDeselList(CObject* pObj) { int i; @@ -3555,7 +3545,7 @@ void CObject::AddDeselList(CObject* pObj) // Removes the previously selected object in the list. -CObject* CObject::SubDeselList() +CObject* COldObject::SubDeselList() { if ( m_totalDesectList == 0 ) return 0; @@ -3564,7 +3554,7 @@ CObject* CObject::SubDeselList() // Removes an object reference if it is in the list. -void CObject::DeleteDeselList(CObject* pObj) +void COldObject::DeleteDeselList(CObject* pObj) { int i, j; diff --git a/src/object/old_object.h b/src/object/old_object.h new file mode 100644 index 00000000..1889dfe6 --- /dev/null +++ b/src/object/old_object.h @@ -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 physics); + void SetBrain(std::unique_ptr brain); + void SetMotion(std::unique_ptr motion); + void SetAuto(std::unique_ptr 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 m_physics; + std::unique_ptr m_brain; + std::unique_ptr m_motion; + std::unique_ptr 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]; +}; diff --git a/src/object/old_object_interface.h b/src/object/old_object_interface.h new file mode 100644 index 00000000..90c635cd --- /dev/null +++ b/src/object/old_object_interface.h @@ -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 + +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; +}; + diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 0b52e492..a2c44d81 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -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(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(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(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(obj)->EventProcess(event); + } } if (m_resetCreate) diff --git a/src/object/subclass/exchange_post.cpp b/src/object/subclass/exchange_post.cpp index 29b2dfca..0dbd47c0 100644 --- a/src/object/subclass/exchange_post.cpp +++ b/src/object/subclass/exchange_post.cpp @@ -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); } diff --git a/src/object/subclass/exchange_post.h b/src/object/subclass/exchange_post.h index a59f3f48..4ed622b4 100644 --- a/src/object/subclass/exchange_post.h +++ b/src/object/subclass/exchange_post.h @@ -20,7 +20,7 @@ #pragma once -#include "object/object.h" +#include "object/old_object.h" #include "object/auto/auto.h" #include @@ -41,7 +41,7 @@ class CModelManager; class CEngine; } -class CExchangePost : public CObject +class CExchangePost : public COldObject { public: CExchangePost(int id); diff --git a/src/ui/target.cpp b/src/ui/target.cpp index 8e4767f8..642fcd64 100644 --- a/src/ui/target.cpp +++ b/src/ui/target.cpp @@ -20,6 +20,7 @@ #include "ui/target.h" +#include "object/old_object.h" #include "object/object_manager.h"