#include "GameWorld.h" 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 pointLight; std::shared_ptr camera; std::shared_ptr bounds; std::shared_ptr collision; std::shared_ptr soundEmitter; EntityID ent; // Fucking lights ent = CreateEntity(); transform = AddComponent(ent, "Transform"); transform->Position = glm::vec3(0.f, 7.f, 0.f); pointLight = AddComponent(ent, "PointLight"); pointLight->Specular = glm::vec3(1.0, 1.0, 1.0); pointLight->Diffuse = glm::vec3(0.0, 0.0, 5.0); pointLight->constantAttenuation = 0.f; pointLight->linearAttenuation = 1.f; pointLight->quadraticAttenuation = 0.f; pointLight->spotExponent = 0.0f; model = AddComponent(ent, "Model"); model->ModelFile = "Models/sphere.obj"; ent = CreateEntity(); transform = AddComponent(ent, "Transform"); transform->Position = glm::vec3(10.f, 7.f, 0.f); pointLight = AddComponent(ent, "PointLight"); pointLight->Specular = glm::vec3(1.0, 1.0, 1.0); pointLight->Diffuse = glm::vec3(0.0, 5.0, 0.0); pointLight->constantAttenuation = 0.f; pointLight->linearAttenuation = 1.f; pointLight->quadraticAttenuation = 0.f; pointLight->spotExponent = 0.0f; model = AddComponent(ent, "Model"); model->ModelFile = "Models/sphere.obj"; ent = CreateEntity(); transform = AddComponent(ent, "Transform"); transform->Position = glm::vec3(-10.f, 7.f, 0.f); pointLight = AddComponent(ent, "PointLight"); pointLight->Specular = glm::vec3(1.0, 1.0, 1.0); pointLight->Diffuse = glm::vec3(5.0, 0.0, 0.0); pointLight->constantAttenuation = 0.f; pointLight->linearAttenuation = 1.f; pointLight->quadraticAttenuation = 0.f; pointLight->spotExponent = 0.0f; model = AddComponent(ent, "Model"); model->ModelFile = "Models/sphere.obj"; //ground ent = CreateEntity(); transform = AddComponent(ent, "Transform"); transform->Position = glm::vec3(0.f, 0.f, 0.f); model = AddComponent(ent, "Model"); model->ModelFile = "Models/plane.obj"; // Player m_Player = CreateEntity(); SetProperty(m_Player, "Name", std::string("PlayerShip")); transform = AddComponent(m_Player, "Transform"); transform->Position = glm::vec3(0.f, 2.f, -5.f); transform->Scale = glm::vec3(1.0f); model = AddComponent(m_Player, "Model"); model->ModelFile = "Models/ship.obj"; pointLight = AddComponent(m_Player, "PointLight"); pointLight->Specular = glm::vec3(1.0, 1.0, 1.0); pointLight->Diffuse = glm::vec3(0.4, 0.4, 1.0); pointLight->constantAttenuation = 0.f; pointLight->linearAttenuation = 1.f; pointLight->quadraticAttenuation = 0.f; pointLight->spotExponent = 0.0f; AddComponent(m_Player, "Input"); collision = AddComponent(m_Player, "Collision"); collision->Phantom = false; collision->Interested = true; bounds = AddComponent(m_Player, "Bounds"); <<<<<<< HEAD bounds->Origin = glm::vec3(transform->Position.x, transform->Position.y - 4, transform->Position.z + 3); bounds->VolumeVector = glm::vec3(4.f,0.7f,4); soundEmitter = AddComponent(m_Player, "SoundEmitter"); soundEmitter->Loop = true; soundEmitter->MaxDistance = FLT_MAX; soundEmitter->ReferenceDistance = 10; soundEmitter->Gain = 1; soundEmitter->Pitch = 1; soundEmitter->Path = "Sounds/hallelujah.wav"; GetSystem("SoundSystem")->PlaySound(soundEmitter); ======= bounds->Origin = glm::vec3(0, 0, 2.f); bounds->VolumeVector = glm::vec3(4.f, 0.7f, 1); >>>>>>> f76c0b336f87a259a7eabf3c532fc885f155a605 // Camera entcamera = CreateEntity(m_Player); SetProperty(entcamera, "Name", std::string("Camera")); transform = AddComponent(entcamera, "Transform"); AddComponent(entcamera, "Input"); transform->Position = glm::vec3(0.f, 10.f, 14.f); camera = AddComponent(entcamera, "Camera"); camera->FOV = 45.f; camera->FarClip = 1000.f; camera->NearClip = 0.01f; transform->Orientation = glm::angleAxis(glm::radians(15.0f),glm::vec3(1,0,0)); /*ent = CreateEntity(); transform = AddComponent(ent, "Transform"); transform->Position = glm::vec3(10.f, 4.f, 0.f); model = AddComponent(ent, "Model"); model->ModelFile = "Models/ship.obj"; collision = AddComponent(player2, "Collision"); collision->Phantom = false; bounds = AddComponent(player2, "Bounds"); bounds->Origin = transform->Position; bounds->VolumeVector = glm::vec3(2.f,2.f,2.f);*/ } 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); }); }