Anvil Engine
Loading...
Searching...
No Matches
AEngine.h
Go to the documentation of this file.
1#pragma once
2#define NOMINMAX
3#include "ACore.h"
4#include "AMath.h"
5#include "AShader.h"
6#include "AnvilBSPFormat.h"
7#include "AnvilPhysics.h"
8#include "AResourceManager.h"
9#include <Windows.h>
10#include <glad/glad.h>
11#include <glfw/glfw3.h>
12#include <string>
13#include <vector>
14#include "AEntity.h"
15#include <functional>
16#include <map>
17
18class IGame;
19
25{
26 public:
30 AEngine();
34 virtual ~AEngine();
35
39 void Run();
44 void LoadMap(const char* mapName);
50 AEntity* CreateEntity(std::string name);
56 void BindAction(std::string name, std::function<void()> action)
57 {
58 m_triggerCallbacks[name] = action;
59 }
60
64 void OnTrigger(std::string name)
65 {
66 if (m_triggerCallbacks.count(name))
67 m_triggerCallbacks[name]();
68 }
69
73 static AEngine* Get()
74 {
75 return s_Instance;
76 }
77
82 {
83 return m_physicsWorld;
84 }
85
86 private:
87 static AEngine* s_Instance; // Singleton instance of the engine
88
89 AnvilPhysics* m_physicsWorld = nullptr; // Physics world instance
90 AShader* m_mainShader = nullptr; // Main shader program
91 IGame* m_game = nullptr; // Game interface implementation
92 HMODULE m_gameLib = nullptr; // Game library module handle
93 GLFWwindow* m_window = nullptr; // GLFW window instance
94 AResourceManager* m_resourceManager = nullptr; // Resource manager for assets
95 std::vector<AEntity*> m_entities; // Collection of all entities in the scene
96 std::vector<AVertex> m_worldVerts; // Vertices for the world geometry
97 std::vector<AFace> m_worldFaces; // Faces for the world geometry
98 uint32_t m_worldVAO = 0, m_worldVBO = 0, m_worldEBO = 0; // VAO, VBO, and EBO for world geometry
99 uint32_t m_worldIndexCount = 0; // Number of indices in the world geometry
100 float m_lastFrameTime = 0.0f; // Time of the last frame for delta time calculation
101 float m_deltaTime = 0.0f;
102 std::map<std::string, std::function<void()>> m_triggerCallbacks; // Map of trigger names to callback functions
103};
#define ANVIL_API
Definition ACore.h:6
Defines the structure for the ABSP (Anvil Binary Space Partition) format.
The main engine class that manages the application lifecycle, rendering, entities,...
Definition AEngine.h:25
AEngine()
Constructor for AEngine.
Definition AEngine.cpp:14
AnvilPhysics * GetPhysics()
Gets the physics world instance.
Definition AEngine.h:81
void OnTrigger(std::string name)
Executes the action associated with the trigger name.
Definition AEngine.h:64
void LoadMap(const char *mapName)
Loads a map by name.
Definition AEngine.cpp:53
static AEngine * Get()
Gets the singleton instance of the engine.
Definition AEngine.h:73
void Run()
Main engine loop that runs the application.
Definition AEngine.cpp:161
void BindAction(std::string name, std::function< void()> action)
Binds an action to a trigger name.
Definition AEngine.h:56
AEntity * CreateEntity(std::string name)
Creates a new entity with the specified name.
Definition AEngine.cpp:145
Represents an entity in the game engine with position, rotation, scale and components.
Definition AEntity.h:16
Definition AResourceManager.h:8
Definition AShader.h:8
A physics system class using ReactPhysics3D engine for physics simulation.
Definition AnvilPhysics.h:67
Definition IGame.h:8