#include "GameWorld.h" void GameWorld::Update(double dt) { World::Update(dt); } void GameWorld::RegisterComponents() { m_ComponentFactory.Register("Bounds", []() { return new Components::Bounds(); }); m_ComponentFactory.Register("Camera", []() { return new Components::Camera(); }); m_ComponentFactory.Register("Collision", []() { return new Components::Collision(); }); m_ComponentFactory.Register("DirectionalLight", []() { return new Components::DirectionalLight(); }); m_ComponentFactory.Register("Input", []() { return new Components::Input(); }); m_ComponentFactory.Register("Model", []() { return new Components::Model(); }); m_ComponentFactory.Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); }); m_ComponentFactory.Register("PointLight", []() { return new Components::PointLight(); }); m_ComponentFactory.Register("PowerUp", []() { return new Components::PowerUp(); }); m_ComponentFactory.Register("SoundEmitter", []() { return new Components::SoundEmitter(); }); m_ComponentFactory.Register("Sprite", []() { return new Components::Sprite(); }); m_ComponentFactory.Register("Stat", []() { return new Components::Stat(); }); m_ComponentFactory.Register("Template", []() { return new Components::Template(); }); m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); }); } void GameWorld::RegisterSystems() { //m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); }); m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); }); //m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); }); //m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); }); m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); }); m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); }); m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); }); } void GameWorld::Initialize() { World::Initialize(); //AddSystem("LevelGenerationSystem"); AddSystem("InputSystem"); //AddSystem("CollisionSystem"); //AddSystem("ParticleSystem"); AddSystem("PlayerSystem"); AddSystem("SoundSystem"); AddSystem("RenderSystem"); std::shared_ptr transform; std::shared_ptr model; std::shared_ptr camera; EntityID ent; ent = CreateEntity(); transform = AddComponent(ent, "Transform"); transform->Position = glm::vec3(0.f, 0.f, 0.f); model = AddComponent(ent, "Model"); model->ModelFile = "ship.obj"; auto soundEmitter = AddComponent(ent, "SoundEmitter"); soundEmitter->Gain = 1; soundEmitter->MaxDistance = FLT_MAX; soundEmitter->ReferenceDistance = 10; soundEmitter->Loop = true; soundEmitter->Pitch = 1; GetSystem("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav"); ent = CreateEntity(); SetProperty(ent, "Name", std::string("Camera")); transform = AddComponent(ent, "Transform"); AddComponent(ent, "Input"); transform->Position = glm::vec3(0.f, 2.f, 10.f); camera = AddComponent(ent, "Camera"); camera->FOV = 45.f; camera->FarClip = 1000.f; camera->NearClip = 0.01f; transform->Orientation = glm::angleAxis(glm::radians(25.0f),glm::vec3(1,0,0)); } GameWorld::GameWorld(std::shared_ptr renderer) : m_Renderer(renderer), World() { }