Add GetWorld to Actor. Integrate google test. Add Model manager class. Rename *.h to *.hpp files
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
#include "Actor.h"
|
||||
#include "Actor.hpp"
|
||||
|
||||
#include "Game/SaveMap/SaveMap.h"
|
||||
#include "Log/Log.h"
|
||||
#include "Game/SaveMap/SaveMap.hpp"
|
||||
#include "Game/World/World.hpp"
|
||||
#include "Log/Log.hpp"
|
||||
|
||||
void Actor::OnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
Actor::Actor()
|
||||
{
|
||||
@@ -55,3 +60,9 @@ void Actor::RemoveTag(const std::string& tag) noexcept
|
||||
{
|
||||
tags.remove(tag);
|
||||
}
|
||||
|
||||
void Actor::Destroy()
|
||||
{
|
||||
OnDestroy();
|
||||
//world_->actors.remove(this);
|
||||
}
|
||||
|
||||
@@ -6,16 +6,23 @@
|
||||
#include "RTTI_Meta.h"
|
||||
#include "Game/SaveMap/ISave.h"
|
||||
#include "Delegate/Delegate.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "Math/Vector.hpp"
|
||||
|
||||
class World;
|
||||
GENERATE_META(Actor)
|
||||
|
||||
class Actor : public ISave, public IRTTI
|
||||
{
|
||||
World* world_;
|
||||
|
||||
Vector3D loc;
|
||||
Vector3D rot;
|
||||
Vector3D scale;
|
||||
|
||||
std::list<std::string> tags;
|
||||
|
||||
protected:
|
||||
virtual void OnDestroy();
|
||||
public:
|
||||
Actor();
|
||||
|
||||
@@ -47,4 +54,9 @@ public:
|
||||
void AddTag(const std::string& tag) noexcept;
|
||||
void RemoveTag(const std::string& tag) noexcept;
|
||||
const std::list<std::string>& GetTags() const { return tags; }
|
||||
void Destroy();
|
||||
|
||||
World* GetWorld() const { return world_; }
|
||||
|
||||
friend class World;
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Mesh.hpp"
|
||||
|
||||
#include "Game/SaveMap/SaveMap.h"
|
||||
#include "Game/SaveMap/SaveMap.hpp"
|
||||
|
||||
Mesh::Mesh()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../Actor.h"
|
||||
#include "../Actor.hpp"
|
||||
|
||||
GENERATE_META(Mesh)
|
||||
class Mesh : public Actor
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "ObjectFactory.h"
|
||||
#include "ObjectFactory.hpp"
|
||||
#include "Actors/Mesh/StaticMesh.hpp"
|
||||
|
||||
#include "Game/Actors/Actor.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "Game/Actors/Actor.hpp"
|
||||
#include "Math/Vector.hpp"
|
||||
|
||||
std::vector<ObjectFactory> base_object_factories = {
|
||||
GENERATE_FACTORY_OBJECT(Actor)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "GameInstance.h"
|
||||
#include "GameInstance.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "Core/CoreInstance.h"
|
||||
#include "Game/WorldFactory.h"
|
||||
#include "SaveMap/SaveMap.h"
|
||||
#include "Game/World/World.h"
|
||||
#include "Core/CoreInstance.hpp"
|
||||
#include "Game/WorldFactory.hpp"
|
||||
#include "SaveMap/SaveMap.hpp"
|
||||
#include "Game/World/World.hpp"
|
||||
|
||||
extern std::vector<WorldFactory> world_factories;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
virtual ~GameInstance();
|
||||
|
||||
World* GetWorld() const { return world; }
|
||||
CoreInstance& GetCore() const { return core; }
|
||||
|
||||
friend class CoreInstance;
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Resource.h"
|
||||
#include "Resource.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "IResource.h"
|
||||
#include "IResource.hpp"
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "SaveMap.h"
|
||||
#include "SaveMap.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <stdexcept>
|
||||
#include "Game/ObjectFactory.h"
|
||||
#include "Game/ObjectFactory.hpp"
|
||||
|
||||
extern std::vector<ObjectFactory> factories;
|
||||
extern std::vector<ObjectFactory> base_object_factories;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "World.h"
|
||||
#include "World.hpp"
|
||||
|
||||
#include "Game/SaveMap/SaveMap.h"
|
||||
#include "Game/SaveMap/SaveMap.hpp"
|
||||
|
||||
World::World(GameInstance& game_instance) : game_instance(game_instance)
|
||||
{
|
||||
@@ -35,4 +35,7 @@ std::shared_ptr<SaveMap> World::save()
|
||||
void World::load(std::shared_ptr<SaveMap> save)
|
||||
{
|
||||
actors = std::move(reinterpret_cast<std::list<Actor*>&>(save->GetListObject("Actors")));
|
||||
|
||||
for (auto& i : actors)
|
||||
i->world_ = this;
|
||||
}
|
||||
@@ -5,11 +5,12 @@
|
||||
#include <string>
|
||||
|
||||
#include "RTTI.h"
|
||||
#include "Game/Actors/Actor.h"
|
||||
#include "Game/Actors/Actor.hpp"
|
||||
#include "Game/Actors/Mesh/Mesh.hpp"
|
||||
|
||||
class GameInstance;
|
||||
|
||||
GENERATE_META(World);
|
||||
class World : public ISave
|
||||
{
|
||||
GameInstance& game_instance;
|
||||
@@ -49,6 +50,7 @@ public:
|
||||
T* object = new T();
|
||||
object->SetActorLocate(loc);
|
||||
object->SetActorRotate(rot);
|
||||
static_cast<Actor*>(object)->world_ = this;
|
||||
actors.push_back(object);
|
||||
return object;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include "Game/SaveMap/SaveMap.h"
|
||||
#include "Game/SaveMap/SaveMap.hpp"
|
||||
|
||||
class GameInstance;
|
||||
class World;
|
||||
Reference in New Issue
Block a user