-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing Drawable.h CI - Clean unused build archis remove no needed hash table include Remove WShadow not useful
- Loading branch information
1 parent
022a65f
commit badaaa4
Showing
22 changed files
with
693 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// Created by Tristan Klempka on 22/07/2024. | ||
// | ||
|
||
#ifndef EVENTDISPATCHER_H | ||
#define EVENTDISPATCHER_H | ||
|
||
#include <unordered_map> | ||
#include <vector> | ||
#include <functional> | ||
#include <optional> | ||
#include "Entity.h" | ||
|
||
enum class EventType { | ||
EntityUpdated, | ||
EntityChildAdded, | ||
ComponentAdded, | ||
ComponentRemoved, | ||
EntityCreated, | ||
EntityDestroyed, | ||
|
||
GlobalTransformChanged, | ||
LocalTransformChanged | ||
}; | ||
|
||
struct Event { | ||
EventType type; | ||
Entity::Id entityId; | ||
std::optional<Entity::Id> parentId; | ||
std::optional<Entity::Id> childId; | ||
|
||
Event(EventType type, Entity::Id entityId, std::optional<Entity::Id> parentId = std::nullopt); | ||
}; | ||
|
||
class EventBuilder { | ||
public: | ||
explicit EventBuilder(EventType type, Entity::Id entityId); | ||
|
||
EventBuilder& withParentId(Entity::Id parentId); | ||
EventBuilder& withChildId(Entity::Id childId); | ||
[[nodiscard]] Event build() const; | ||
|
||
private: | ||
Event event; | ||
}; | ||
|
||
class EventDispatcher { | ||
public: | ||
using EventCallback = std::function<void(const Event&)>; | ||
|
||
void subscribe(EventType eventType, EventCallback callback); | ||
void dispatch(const Event& event) const; | ||
|
||
private: | ||
std::unordered_map<EventType, std::vector<EventCallback>> listeners; | ||
}; | ||
|
||
#endif //EVENTDISPATCHER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Created by Tristan Klempka on 24/07/2024. | ||
// | ||
|
||
#ifndef HIERARCHYSYSTEM_H | ||
#define HIERARCHYSYSTEM_H | ||
|
||
#include <SFML/Graphics/Transform.hpp> // for Transform | ||
#include <functional> // for function | ||
#include <optional> // for optional | ||
#include <unordered_map> // for unordered_map | ||
#include <unordered_set> // for unordered_set | ||
#include <vector> // for vector | ||
#include "Entity.h" // for Entity | ||
#include "System.h" // for System | ||
#include "components/Node.h" // for Node | ||
class EventDispatcher; | ||
|
||
class HierarchySystem : public System { | ||
public: | ||
using QueryFunction = std::function<void(std::function<void(Entity::Id, Node&)>, | ||
std::optional<std::unordered_set<Entity::Id>>)>; | ||
|
||
explicit HierarchySystem(QueryFunction query, EventDispatcher& dispatcher); | ||
|
||
void update() override; | ||
|
||
private: | ||
QueryFunction m_query; | ||
std::unordered_set<Entity::Id> m_rootNodes; | ||
std::unordered_map<Entity::Id, sf::Transform> m_nodeTransforms; | ||
std::unordered_map<Entity::Id, Entity::Id> m_parentMap; | ||
std::unordered_map<Entity::Id, std::vector<Entity::Id>> m_childNodes; | ||
|
||
void onEventEntityCreated(Entity::Id entityId); | ||
void onEventEntityChildAdded(Entity::Id parentId, Entity::Id childId); | ||
void propagateTransform(Entity::Id parentId, const sf::Transform& parentTransform); | ||
void onEventGlobalTransformChanged(Entity::Id entityId); | ||
void onEventLocalTransformChanged(Entity::Id entityId); | ||
}; | ||
|
||
#endif //HIERARCHYSYSTEM_H |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Created by Tristan Klempka on 22/07/2024. | ||
// | ||
|
||
#ifndef WINDOW_H | ||
#define WINDOW_H | ||
|
||
#include <SFML/Graphics/RenderWindow.hpp> // for RenderWindow | ||
#include <SFML/System/String.hpp> // for String | ||
#include <SFML/Window/VideoMode.hpp> // for VideoMode | ||
#include <string> // for string | ||
namespace sf { class Event; } | ||
|
||
class Window { | ||
public: | ||
Window(const sf::VideoMode& mode, const std::string& title) | ||
: m_window(mode, title) {} | ||
|
||
Window(const Window&) = delete; | ||
Window& operator=(const Window&) = delete; | ||
Window(Window&&) = delete; | ||
Window& operator=(Window&&) = delete; | ||
|
||
bool isOpen() const { return m_window.isOpen(); } | ||
bool pollEvent(sf::Event& event) { return m_window.pollEvent(event); } | ||
void close() { m_window.close(); } | ||
sf::RenderWindow& getRenderWindow() { | ||
return m_window; | ||
} | ||
|
||
private: | ||
sf::RenderWindow m_window; | ||
}; | ||
|
||
#endif //WINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.