Reorganize & Fix a memory issue.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Engine/types/scene/Scene.h>
|
||||
#include <Engine/GameWindow.h>
|
||||
#include <Engine/types/Scene.h>
|
||||
#include <Engine/types/GameWindow.h>
|
||||
|
||||
namespace Globals {
|
||||
using namespace Engine;
|
||||
|
@@ -3,7 +3,6 @@
|
||||
#include <vector>
|
||||
#include <Engine/types/InstancedTexture.h>
|
||||
#include <Engine/types/entity/Hud.h>
|
||||
#include <Engine/types/scene/Fixed.h>
|
||||
#include <JGL/types/RenderTarget.h>
|
||||
|
||||
namespace Engine {
|
||||
@@ -23,14 +22,11 @@ protected:
|
||||
std::vector<InstancedTexture*> instanced_alpha_masks{};
|
||||
|
||||
std::vector<RenderTarget*> layers{};
|
||||
std::vector<Fixed*> fixed_list{};
|
||||
std::vector<Entity*> entity_list{};
|
||||
protected:
|
||||
[[nodiscard]] std::vector<Entity*> GetFlatEntityList(const std::vector<Entity*>& entity_list) const;
|
||||
public:
|
||||
[[nodiscard]] bool EntityListContains(const Entity* entity) const;
|
||||
[[nodiscard]] bool FixedListContains(const Fixed* fixed) const;
|
||||
[[nodiscard]] size_t FixedCount() const;
|
||||
[[nodiscard]] size_t EntityCount() const;
|
||||
[[nodiscard]] std::string GetName() const;
|
||||
[[nodiscard]] Camera* GetActiveCamera() const;
|
||||
@@ -41,15 +37,12 @@ public:
|
||||
|
||||
public:
|
||||
void AppendEntity(Entity* entity);
|
||||
void AppendFixed(Fixed* fixed);
|
||||
|
||||
// Removes and deallocates.
|
||||
void DestroyEntity(Entity* entity);
|
||||
void DestroyFixed(Fixed* fixed);
|
||||
|
||||
// Only removes from the list.
|
||||
void RemoveEntity(Entity* entity);
|
||||
void RemoveFixed(Fixed* fixed);
|
||||
|
||||
virtual void Unload();
|
||||
virtual void Init() {}
|
@@ -8,4 +8,5 @@ namespace Engine {
|
||||
class Engine::Hud : public Engine::Renderable {
|
||||
public:
|
||||
Hud() : Renderable(0) {};
|
||||
~Hud() override = default;
|
||||
};
|
||||
|
@@ -17,4 +17,5 @@ public:
|
||||
virtual void Render() = 0;
|
||||
public:
|
||||
explicit Renderable(unsigned int layer) : layer(layer) {}
|
||||
virtual ~Renderable() = default;
|
||||
};
|
@@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector2i.hpp>
|
||||
#include <J3ML/Geometry/AABB2D.hpp>
|
||||
#include <JGL/types/Texture.h>
|
||||
|
||||
using J3ML::LinearAlgebra::Vector2i;
|
||||
using JGL::Texture;
|
||||
|
||||
namespace Engine {
|
||||
class Fixed;
|
||||
}
|
||||
|
||||
// Things that are considered non-movable parts of the level.
|
||||
// TODO instanced textures.
|
||||
class Engine::Fixed {
|
||||
private:
|
||||
void GenerateCollision();
|
||||
protected:
|
||||
std::vector<Vector2i> collision{};
|
||||
bool enabled = false;
|
||||
bool collidable = false;
|
||||
Vector2i position = {0, 0};
|
||||
const Texture* texture = nullptr;
|
||||
public:
|
||||
[[nodiscard]] bool Collidable() const;
|
||||
[[nodiscard]] Vector2i GetPosition() const;
|
||||
[[nodiscard]] AABB2D GetBounds() const;
|
||||
[[nodiscard]] bool Enabled() const;
|
||||
[[nodiscard]] std::vector<Vector2i> GetCollision();
|
||||
[[nodiscard]] const Texture* GetTexture();
|
||||
public:
|
||||
void Enable();
|
||||
void Disable();
|
||||
virtual void Render() {};
|
||||
public:
|
||||
Fixed(const Vector2i& position, bool enabled, bool collidable, const Texture* texture) : position(position), enabled(enabled), collidable(collidable), texture(texture)
|
||||
{ if (collidable) GenerateCollision(); }
|
||||
virtual ~Fixed();
|
||||
};
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <Engine/types/scene/Scene.h>
|
||||
#include <Engine/types/Scene.h>
|
||||
|
||||
class ControllableBox final : public Engine::Scene {
|
||||
public:
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <Engine/types/scene/Scene.h>
|
||||
#include <Engine/types/Scene.h>
|
||||
#include <JGL/types/RenderTarget.h>
|
||||
|
||||
class LoadingScreen final : public Engine::Scene {
|
||||
|
Reference in New Issue
Block a user