Peoplemon  0.1.0
Peoplemon 3 game source documentation
Render.hpp
Go to the documentation of this file.
1 #ifndef CORE_SYSTEMS_RENDER_HPP
2 #define CORE_SYSTEMS_RENDER_HPP
3 
4 #include <BLIB/Engine/System.hpp>
5 #include <BLIB/Events.hpp>
8 
9 namespace core
10 {
11 namespace system
12 {
13 class Systems;
14 
20 class Render
21 : public bl::engine::System
22 , public bl::event::Listener<event::EntityMoved, event::EntityMoveFinished, event::EntityRotated> {
23 public:
29  Render(Systems& owner);
30 
34  virtual ~Render() = default;
35 
43  void updateShadow(bl::ecs::Entity entity, float distance, float radius);
44 
50  void removeShadow(bl::ecs::Entity entity);
51 
55  bl::rc::RenderTarget& getMainRenderTarget() { return *mainRenderTarget; }
56 
62  void setMainRenderTarget(bl::rc::RenderTarget& target);
63 
64 private:
65  Systems& owner;
66  bl::rc::RenderTarget* mainRenderTarget;
67  bl::ecs::ComponentPool<component::Renderable>& pool;
68  bl::ecs::ComponentPool<bl::com::Transform2D>& transformPool;
69  std::vector<std::pair<bl::ecs::Entity, bl::tmap::Direction>> stopRm;
70  std::vector<std::pair<bl::ecs::Entity, bl::tmap::Direction>> stopAdd;
71  std::vector<bl::ecs::Entity> shadowsToRemove;
72 
73  virtual void update(std::mutex& stageMutex, float dt, float realDt, float residual,
74  float realResidual) override;
75  virtual void init(bl::engine::Engine& engine) override;
76  virtual void notifyFrameStart() override;
77  virtual void observe(const event::EntityMoved& event) override;
78  virtual void observe(const event::EntityMoveFinished& event) override;
79  virtual void observe(const event::EntityRotated& event) override;
80 };
81 
82 } // namespace system
83 } // namespace core
84 
85 #endif
Core classes and functionality for both the editor and game.
Fired after an entity begins moving from one position to another.
Definition: EntityMoved.hpp:18
Fired when an entity completes a move from one tile to another.
Definition: EntityMoved.hpp:52
Fired when an entity rotates without moving.
Definition: EntityMoved.hpp:76
Basic system that synchronizes animation states based on movement state events.
Definition: Render.hpp:22
virtual ~Render()=default
Destroys the render system.
Render(Systems &owner)
Creates the render system.
Definition: Render.cpp:10
void setMainRenderTarget(bl::rc::RenderTarget &target)
Sets the main render target. Used by the editor.
Definition: Render.cpp:105
void removeShadow(bl::ecs::Entity entity)
Removes the shadow from the given entity.
Definition: Render.cpp:97
bl::rc::RenderTarget & getMainRenderTarget()
Returns the engine observer that the main game is rendering to.
Definition: Render.hpp:55
void updateShadow(bl::ecs::Entity entity, float distance, float radius)
Adds or updates the shadow of the given entity.
Definition: Render.cpp:58
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47