Bladeren bron

Lesson 17.4

Godzil 3 jaren geleden
bovenliggende
commit
33c8ed70c2
3 gewijzigde bestanden met toevoegingen van 47 en 0 verwijderingen
  1. 23 0
      source/include/EventBus.h
  2. 23 0
      source/include/Events/Collision.h
  3. 1 0
      source/include/Game.h

+ 23 - 0
source/include/EventBus.h

@@ -0,0 +1,23 @@
+/*
+ * 2D Game Engine 
+ * EventBus.h: 
+ * Based on pikuma.com 2D game engine in C++ and Lua course
+ * Copyright (c) 2021 986-Studio. All rights reserved.
+ *
+ * Created by Manoël Trapier on 16/02/2021.
+ */
+
+#ifndef GAMEENGINE_SOURCE_INCLUDE_EVENTBUS_H
+#define GAMEENGINE_SOURCE_INCLUDE_EVENTBUS_H
+
+class EventBus
+{
+public:
+    EventBus() = default;
+    ~EventBus() = default;
+
+    void SubscribeToEvent<T>();
+    void EmitEvent<T>();
+};
+
+#endif /* GAMEENGINE_SOURCE_INCLUDE_EVENTBUS_H */

+ 23 - 0
source/include/Events/Collision.h

@@ -0,0 +1,23 @@
+/*
+ * 2D Game Engine 
+ * Collision.h: 
+ * Based on pikuma.com 2D game engine in C++ and Lua course
+ * Copyright (c) 2021 986-Studio. All rights reserved.
+ *
+ * Created by Manoël Trapier on 16/02/2021.
+ */
+
+#ifndef GAMEENGINE_SOURCE_INCLUDE_EVENTS_COLLISION_H
+#define GAMEENGINE_SOURCE_INCLUDE_EVENTS_COLLISION_H
+
+#include <ECS.h>
+
+class CollisionEvent : public Event
+{
+public:
+    Entity a;
+    Entity b;
+    CollisionEvent(Entity a, Entity b) : a(a), b(b) {};
+};
+
+#endif /* GAMEENGINE_SOURCE_INCLUDE_EVENTS_COLLISION_H */

+ 1 - 0
source/include/Game.h

@@ -30,6 +30,7 @@ private:
 
     std::unique_ptr<Registry> registry;
     std::unique_ptr<AssetStore> assetStore;
+    std::unique_ptr<EventBus> eventBus;
 
 public:
     Game();