#include "PrecompiledHeader.h" #include "GameWorld.h" void GameWorld::Initialize() { World::Initialize(); ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/Plane.obj"); ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/ArrowCube.obj"); //Background Music { Events::PlayBGM e; e.Resource = "Sounds/SFX/WUB.mp3"; EventBroker->Publish(e); } // Interface BindKey(GLFW_KEY_A, "interface_horizontal", -1.f); BindKey(GLFW_KEY_D, "interface_horizontal", 1.f); BindGamepadAxis(Gamepad::Axis::LeftX, "interface_horizontal", 1.f); BindGamepadButton(Gamepad::Button::Left, "interface_horizontal", -1.f); BindGamepadButton(Gamepad::Button::Right, "interface_horizontal", 1.f); BindKey(GLFW_KEY_W, "interface_vertical", 1.f); BindKey(GLFW_KEY_S, "interface_vertical", -1.f); BindGamepadAxis(Gamepad::Axis::LeftY, "interface_vertical", 1.f); BindGamepadButton(Gamepad::Button::Up, "interface_vertical", 1.f); BindGamepadButton(Gamepad::Button::Down, "interface_vertical", -1.f); BindKey(GLFW_KEY_SPACE, "interface_confirm", 1.f); BindGamepadButton(Gamepad::Button::A, "interface_confirm", 1.f); BindKey(GLFW_KEY_W, "vertical", 1.f); BindKey(GLFW_KEY_S, "vertical", -1.f); BindKey(GLFW_KEY_A, "horizontal", -1.f); BindKey(GLFW_KEY_D, "horizontal", 1.f); BindGamepadAxis(Gamepad::Axis::LeftX, "horizontal", 1.f); BindGamepadAxis(Gamepad::Axis::LeftY, "vertical", 1.f); BindKey(GLFW_KEY_UP, "barrel_rotation", 1.f); BindKey(GLFW_KEY_DOWN, "barrel_rotation", -1.f); BindKey(GLFW_KEY_LEFT, "tower_rotation", -1.f); BindKey(GLFW_KEY_RIGHT, "tower_rotation", 1.f); BindGamepadAxis(Gamepad::Axis::RightX, "tower_rotation", 1.f); BindGamepadAxis(Gamepad::Axis::RightY, "barrel_rotation", 1.f); BindKey(GLFW_KEY_SPACE, "handbrake", 1.f); BindGamepadButton(Gamepad::Button::A, "handbrake", 1.f); BindKey(GLFW_KEY_Z, "shoot", 1.f); BindGamepadAxis(Gamepad::Axis::RightTrigger, "shoot", 1.f); BindGamepadAxis(Gamepad::Axis::RightTrigger, "jeep_vertical", 1.f); BindGamepadAxis(Gamepad::Axis::LeftTrigger, "jeep_vertical", -1.f); BindKey(GLFW_KEY_X, "use", 1.f); BindGamepadButton(Gamepad::Button::X, "use", 1.f); BindMouseButton(GLFW_MOUSE_BUTTON_1, "cam_lock", 1.f); BindKey(GLFW_KEY_Y, "cam_vertical", 1.f); BindKey(GLFW_KEY_H, "cam_vertical", -1.f); BindKey(GLFW_KEY_G, "cam_horizontal", -1.f); BindKey(GLFW_KEY_J, "cam_horizontal", 1.f); BindKey(GLFW_KEY_U, "cam_normal", 1.f); BindKey(GLFW_KEY_T, "cam_normal", -1.f); BindKey(GLFW_KEY_B, "cam_speed", -1.f); BindKey(GLFW_KEY_N, "cam_speed", 1.f); //BindGamepadButton(Gamepad::Button::Up, "Gamepad::Button::Up", 1.f); //BindGamepadButton(Gamepad::Button::Down, "Gamepad::Button::Down", 1.f); //BindGamepadButton(Gamepad::Button::Left, "Gamepad::Button::Left", 1.f); //BindGamepadButton(Gamepad::Button::Right, "Gamepad::Button::Right", 1.f); //BindGamepadButton(Gamepad::Button::Start, "Gamepad::Button::Start", 1.f); //BindGamepadButton(Gamepad::Button::Back, "Gamepad::Button::Back", 1.f); //BindGamepadButton(Gamepad::Button::LeftThumb, "Gamepad::Button::LeftThumb", 1.f); //BindGamepadButton(Gamepad::Button::RightThumb, "Gamepad::Button::RightThumb", 1.f); //BindGamepadButton(Gamepad::Button::LeftShoulder, "Gamepad::Button::LeftShoulder", 1.f); //BindGamepadButton(Gamepad::Button::RightShoulder, "Gamepad::Button::RightShoulder", 1.f); //BindGamepadButton(Gamepad::Button::A, "Gamepad::Button::A", 1.f); //BindGamepadButton(Gamepad::Button::B, "Gamepad::Button::B", 1.f); //BindGamepadButton(Gamepad::Button::X, "Gamepad::Button::X", 1.f); //BindGamepadButton(Gamepad::Button::Y, "Gamepad::Button::Y", 1.f); RegisterComponents(); auto camera = CreateEntity(); { auto transform = AddComponent(camera); transform->Position.z = 150.f; transform->Position.y = 10.f; //transform->Orientation = glm::quat(glm::vec3(glm::pi() / 8.f, 0.f, 0.f)); auto cameraComp = AddComponent(camera); cameraComp->FarClip = 2000.f; auto freeSteering = AddComponent(camera); } { Events::SetViewportCamera e; e.CameraEntity = camera; e.ViewportFrame = "ViewportFreeCam"; EventBroker->Publish(e); } #pragma region Tower_Debris_Template { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(0.f, 4.12801f, 1.18125f); auto model = AddComponent(debri); model->ModelFile = "Models/Turret/Gun/Gun.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Turret/Gun/Gun.obj"; m_TowerDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(0.f, 5.889f-0.92791f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Turret/GunRotation/GunRotation.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Turret/GunRotation/GunRotation.obj"; m_TowerDebrisTemplates.push_back(debri); } #pragma endregion #pragma region Wall_Debris_Template { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(3.43f, 2.287f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDebris1.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris1.obj"; m_WallDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(-3.744f, 1.508f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDebris2.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris2.obj"; m_WallDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(-3.592f, 4.664f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDebris2.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris2.obj"; m_WallDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(-2.535f, 2.879f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDebris3.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris3.obj"; m_WallDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(0.333f, 3.618f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDebris4.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris4.obj"; m_WallDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(2.586f, 4.333f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDebris5.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris5.obj"; m_WallDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(0.537f, 1.344f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDebris6.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->Mass = 200.f; physics->Restitution = .04f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris6.obj"; m_WallDebrisTemplates.push_back(debri); } { auto debri = CreateEntity(); AddComponent(debri); auto transform = AddComponent(debri); transform->Position = glm::vec3(0.f, 0.f, 0.f); auto model = AddComponent(debri); model->ModelFile = "Models/Wall/WallDestroyed/WallDestroyed.obj"; auto physics = AddComponent(debri); physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; physics->Mass = 200.f; physics->Restitution = .004f; physics->Friction = 0.9f; auto shape = CreateEntity(debri); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDestroyedColosion.obj"; m_WallDebrisTemplates.push_back(debri); } #pragma endregion Region for wall debris CreateTerrain(); /*EntityID tank1 = CreateTank(1); { auto transform = GetComponent(tank1); transform->Position.z = 50; Events::SetViewportCamera e; e.CameraEntity = GetProperty(tank1, "Camera"); e.ViewportFrame = "Viewport1"; EventBroker->Publish(e); } EntityID tank2 = CreateTank(2); { auto transform = GetComponent(tank2); transform->Position.x = 10.f; transform->Position.z = 50.f; Events::SetViewportCamera e; e.CameraEntity = GetProperty(tank2, "Camera"); e.ViewportFrame = "Viewport2"; EventBroker->Publish(e); }*/ { auto flag = CreateEntity(); auto transform = AddComponent(flag); transform->Position = glm::vec3(0, -50, 100); auto model = AddComponent(flag); model->ModelFile = "Models/Flag/FishingRod/FishingRod.obj"; { auto fish = CreateEntity(flag); auto transform = AddComponent(fish); transform->Position = glm::vec3(-1.3f, 1.0, 0); auto model = AddComponent(fish); model->ModelFile = "Models/Flag/LeFish/Salmon.obj"; CommitEntity(fish); } auto trigger = AddComponent(flag); { auto shape = CreateEntity(flag); auto transform = AddComponent(shape); transform->Position = glm::vec3(-0.9f, 0.9f, 0); auto box = AddComponent(shape); box->Width = 1.1f; box->Depth = 0.7f; box->Height = 3.9f; CommitEntity(shape); } auto flagComponent = AddComponent(flag); CommitEntity(flag); } //for (int i = 0; i < 500; i++) //{ // auto Light = CreateEntity(); // auto transform = AddComponent(Light); // transform->Position = glm::vec3((5 + (i*2.f))*cos(i*2.f), 3.f, (5 + (i*2.f))*sin(i*2.f)); // auto light = AddComponent(Light); // light->Specular = glm::vec3(0.5f, 0.5f, 0.5f); // light->Diffuse = glm::vec3(0.5f, 0.5f, 0.5f); // light->Radius = 15.f; // light->specularExponent = 100.f; // CommitEntity(Light); // //auto model = AddComponent(Light, "Model"); // //model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj"; //} { auto gateBase = CreateEntity(); auto transform = AddComponent(gateBase); transform->Position = glm::vec3(0, -50, 150); auto model = AddComponent(gateBase); model->ModelFile = "Models/Gate/Lift/Lift.obj"; auto physics = AddComponent(gateBase); physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; // Terrain-Layer { auto leftBaseShape = CreateEntity(gateBase); auto transform = AddComponent(leftBaseShape); transform->Position = glm::vec3(8.5f, 3, 0); auto box = AddComponent(leftBaseShape); box->Width = 3.f/2; box->Height = 6.094f/2; box->Depth = 4.f/2; CommitEntity(leftBaseShape); } { auto RightBaseShape = CreateEntity(gateBase); auto transform = AddComponent(RightBaseShape); transform->Position = glm::vec3(-8.5f, 3, 0); auto box = AddComponent(RightBaseShape); box->Width = 3.f/2; box->Height = 6.094f/2; box->Depth = 4.f/2; CommitEntity(RightBaseShape); } { auto LeftTopShape = CreateEntity(gateBase); auto transform = AddComponent(LeftTopShape); transform->Position = glm::vec3(7.5485f, 9.385f, 0); auto box = AddComponent(LeftTopShape); box->Width = 1.747f/2; box->Height = 6.851f/2; box->Depth = 1.767f/2; CommitEntity(LeftTopShape); } { auto RightTopShape = CreateEntity(gateBase); auto transform = AddComponent(RightTopShape); transform->Position = glm::vec3(-7.5485f, 9.385f, 0); auto box = AddComponent(RightTopShape); box->Width = 1.747f/2; box->Height = 6.851f/2; box->Depth = 1.767f/2; CommitEntity(RightTopShape); } { auto RampShape = CreateEntity(gateBase); auto transform = AddComponent(RampShape); transform->Position = glm::vec3(0, 0.24f, 0); auto box = AddComponent(RampShape); box->Width = 14.9f/2; box->Height = 0.38f/2; box->Depth = 1.484f/2; CommitEntity(RampShape); } CommitEntity(gateBase); } } void GameWorld::Update(double dt) { World::Update(dt); } void GameWorld::RegisterComponents() { m_ComponentFactory.Register([]() { return new Components::Transform(); }); m_ComponentFactory.Register([]() { return new Components::Template(); }); m_ComponentFactory.Register([]() { return new Components::Player(); }); m_ComponentFactory.Register([]() { return new Components::Flag(); }); m_ComponentFactory.Register([]() { return new Components::Move(); }); m_ComponentFactory.Register([]() { return new Components::Rotate(); }); m_ComponentFactory.Register([]() { return new Components::Team(); }); } void GameWorld::RegisterSystems() { m_SystemFactory.Register([this]() { return new Systems::TimerSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::DamageSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::TransformSystem(this, EventBroker, ResourceManager); }); //m_SystemFactory.Register([this]() { return new Systems::LevelGenerationSystem(this); }); m_SystemFactory.Register([this]() { return new Systems::InputSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::DebugSystem(this, EventBroker, ResourceManager); }); //m_SystemFactory.Register([this]() { return new Systems::CollisionSystem(this); }); m_SystemFactory.Register([this]() { return new Systems::ParticleSystem(this, EventBroker, ResourceManager); }); //m_SystemFactory.Register([this]() { return new Systems::PlayerSystem(this); }); m_SystemFactory.Register([this]() { return new Systems::FreeSteeringSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::TankSteeringSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::JeepSteeringSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::WheelPairSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::SoundSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::PhysicsSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::TriggerSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::FollowSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::GarageSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::WallSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::TowerSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::RenderSystem(this, EventBroker, ResourceManager); }); } void GameWorld::AddSystems() { AddSystem(); AddSystem(); AddSystem(); //AddSystem(); AddSystem(); AddSystem(); //AddSystem(); AddSystem(); //AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); AddSystem(); } void GameWorld::BindKey(int keyCode, std::string command, float value) { Events::BindKey e; e.KeyCode = keyCode; e.Command = command; e.Value = value; EventBroker->Publish(e); } void GameWorld::BindMouseButton(int button, std::string command, float value) { Events::BindMouseButton e; e.Button = button; e.Command = command; e.Value = value; EventBroker->Publish(e); } void GameWorld::BindGamepadAxis(Gamepad::Axis axis, std::string command, float value) { Events::BindGamepadAxis e; e.Axis = axis; e.Command = command; e.Value = value; EventBroker->Publish(e); } void GameWorld::BindGamepadButton(Gamepad::Button button, std::string command, float value) { Events::BindGamepadButton e; e.Button = button; e.Command = command; e.Value = value; EventBroker->Publish(e); } void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation, int teamID) { auto gateParent = CreateEntity(parent); auto transform = AddComponent(gateParent); transform->Position = position; transform->Orientation = orientation; { auto gateBase = CreateEntity(gateParent); auto transform = AddComponent(gateBase); auto model = AddComponent(gateBase); model->ModelFile = "Models/Gate/Lift/Lift.obj"; auto physics = AddComponent(gateBase); physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; { auto leftBaseShape = CreateEntity(gateBase); auto transform = AddComponent(leftBaseShape); transform->Position = glm::vec3(8.5f, 3, 0); auto box = AddComponent(leftBaseShape); box->Width = 3.f/2; box->Height = 6.094f/2; box->Depth = 4.f/2; CommitEntity(leftBaseShape); } { auto RightBaseShape = CreateEntity(gateBase); auto transform = AddComponent(RightBaseShape); transform->Position = glm::vec3(-8.5f, 3, 0); auto box = AddComponent(RightBaseShape); box->Width = 3.f/2; box->Height = 6.094f/2; box->Depth = 4.f/2; CommitEntity(RightBaseShape); } { auto LeftTopShape = CreateEntity(gateBase); auto transform = AddComponent(LeftTopShape); transform->Position = glm::vec3(7.5485f, 9.385f, 0); auto box = AddComponent(LeftTopShape); box->Width = 1.747f/2; box->Height = 6.851f/2; box->Depth = 1.767f/2; CommitEntity(LeftTopShape); } { auto RightTopShape = CreateEntity(gateBase); auto transform = AddComponent(RightTopShape); transform->Position = glm::vec3(-7.5485f, 9.385f, 0); auto box = AddComponent(RightTopShape); box->Width = 1.747f/2; box->Height = 6.851f/2; box->Depth = 1.767f/2; CommitEntity(RightTopShape); } { auto RampShape = CreateEntity(gateBase); auto transform = AddComponent(RampShape); transform->Position = glm::vec3(0, 0.24f, 0); auto mesh = AddComponent(RampShape); mesh->ResourceName = "Models/Gate/Lift/RampCollision.obj"; CommitEntity(RampShape); } CommitEntity(gateBase); } auto gate = CreateEntity(gateParent); { auto transform = AddComponent(gate); auto model = AddComponent(gate); model->ModelFile = "Models/Gate/Gate/Gate.obj"; auto physics = AddComponent(gate); physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; auto move = AddComponent(gate); move->Speed = 5.f; move->GoalPosition = glm::vec3(0, 9.02345f, 0); move->StartPosition = glm::vec3(0, 0, 0); { auto mainShape = CreateEntity(gate); auto transform = AddComponent(mainShape); transform->Position = glm::vec3(0.f, 3.09776f, 0.f); auto box = AddComponent(mainShape); box->Width = 6.963f; box->Height = 2.478f; box->Depth = 0.522f; CommitEntity(mainShape); } { auto lowerShape = CreateEntity(gate); auto transform = AddComponent(lowerShape); transform->Position = glm::vec3(0.f, 0.35f, 0.f); auto box = AddComponent(lowerShape); box->Width = 6.963f; box->Height = 0.308f; box->Depth = 0.222f; CommitEntity(lowerShape); } CommitEntity(gate); } { auto gateTrigger = CreateEntity(gateParent); auto transform = AddComponent(gateTrigger); transform->Position = glm::vec3(0, 2.8241, 0); auto trigger = AddComponent(gateTrigger); trigger->TeamID = teamID; auto triggerMove = AddComponent(gateTrigger); triggerMove->Entity = gate; auto teamComponent = AddComponent(gateTrigger); teamComponent->TeamID = teamID; { auto shape = CreateEntity(gateTrigger); auto transform = AddComponent(shape); transform->Position = glm::vec3(0.f, 2.8241f, 0.f); auto box = AddComponent(shape); box->Width = 6.963f; box->Height = 3.104f; box->Depth = 10.356f; CommitEntity(shape); } CommitEntity(gateTrigger); } } EntityID GameWorld::CreateTower(EntityID parent, glm::vec3 pos, int teamID) { auto towerBase = CreateEntity(parent); auto transform = AddComponent(towerBase); transform->Position = pos; auto towerComponent = AddComponent(towerBase); auto physics = AddComponent(towerBase); physics->Mass = 100.f; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; auto model = AddComponent(towerBase); model->ModelFile = "Models/Turret/Base/Base.obj"; auto health = AddComponent(towerBase); health->Amount = 50.f; auto shape = CreateEntity(towerBase); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Turret/Base/Base.obj"; CommitEntity(shape); { auto towerGunRotation = CreateEntity(towerBase); auto transform = AddComponent(towerGunRotation); transform->Position = glm::vec3(0.f, 5.889f-0.92791f, 0.f); auto towerGunBaseModel = CreateEntity(towerGunRotation); { auto transform = AddComponent(towerGunBaseModel); transform->Orientation = glm::quat(glm::vec3(0, -glm::pi() / 2.f, 0)); auto model = AddComponent(towerGunBaseModel); model->ModelFile = "Models/Turret/GunRotation/GunRotation.obj"; } CommitEntity(towerGunBaseModel); auto health = AddComponent(towerGunRotation); health->Amount = 50.f; { auto towerGun = CreateEntity(towerGunRotation); auto transform = AddComponent(towerGun); transform->Position = glm::vec3(0.f, 4.12801f, 1.18125f); //transform->Orientation = glm::quat(glm::vec3(0, -glm::pi() / 2.f, 0)); #pragma region Turret_Shot_Template { auto shot = CreateEntity(towerGun); auto transform = AddComponent(shot); transform->Position = glm::vec3(0.f, 0.f, -4.37612f); transform->Orientation = glm::angleAxis(-glm::pi() / 2.f, glm::vec3(1, 0, 0)); transform->Scale = glm::vec3(2.f); AddComponent(shot); auto physics = AddComponent(shot); physics->Mass = 25.f; physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->CollisionEvent = true; auto modelComponent = AddComponent(shot); modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj"; auto TurretShotComponent = AddComponent(shot); TurretShotComponent->Damage = 20.f; TurretShotComponent->ExplosionRadius = 30.f; TurretShotComponent->ExplosionStrength = 300000.f; { auto shape = CreateEntity(shot); auto transform = AddComponent(shape); auto boxShape = AddComponent(shape); boxShape->Width = 0.5f; boxShape->Height = 0.5f; boxShape->Depth = 0.5f; CommitEntity(shape); } CommitEntity(shot); m_ShotTemplate = shot; } #pragma endregion auto towerGunModel = CreateEntity(towerGun); { auto transform = AddComponent(towerGunModel); transform->Orientation = glm::quat(glm::vec3(0, -glm::pi() / 2.f, 0)); auto model = AddComponent(towerGunModel); model->ModelFile = "Models/Turret/Gun/Gun.obj"; } CommitEntity(towerGunModel); auto health = AddComponent(towerGun); health->Amount = 50.f; CommitEntity(towerGun); towerComponent->Gun = towerGun; } CommitEntity(towerGunRotation); towerComponent->GunBase = towerGunRotation; } towerComponent->ID = teamID; auto turretComponent = AddComponent(towerBase); turretComponent->ShotTemplate = m_ShotTemplate; turretComponent->ShotSpeed = 40.f; auto debrisComponent = AddComponent(towerBase); debrisComponent->TowerDebrisIDs = m_TowerDebrisTemplates; CommitEntity(towerBase); return towerBase; } EntityID GameWorld::CreateWall(EntityID parent, glm::vec3 pos, glm::quat orientation) { auto wall = CreateEntity(parent); auto transform = AddComponent(wall); transform->Position = pos; transform->Orientation = orientation; auto physics = AddComponent(wall); physics->Mass = 100.f; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; auto walldebris = AddComponent(wall); walldebris->Walldebris = m_WallDebrisTemplates; auto model = AddComponent(wall); model->ModelFile = "Models/Wall/WallWhole/Wall.obj"; auto damageModel = AddComponent(wall); damageModel->ModelFile = "Models/Wall/WallWhole/WallCracks.obj"; auto health = AddComponent(wall); health->Amount = 50.f; health->VulnerableToSplash = false; auto shape = CreateEntity(wall); auto shapetransform = AddComponent(shape); auto shapemesh = AddComponent(shape); shapemesh->ResourceName = "Models/Wall/WallCollision/Collision.obj"; CommitEntity(shape); CommitEntity(wall); return wall; } void GameWorld::CreateTerrain() { { auto road_middle = CreateEntity(); auto transform = AddComponent(road_middle); auto model = AddComponent(road_middle); model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; auto physics = AddComponent(road_middle); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; auto groundshape = CreateEntity(road_middle); auto transformshape = AddComponent(groundshape); auto meshShape = AddComponent(groundshape); meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; CommitEntity(groundshape); CommitEntity(road_middle); } { /*auto water = CreateEntity(); auto transform = AddComponent(water); transform->Position = glm::vec3(0, -35, 0); transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); transform->Scale = glm::vec3(5000.f, 10.f, 5000.f); auto model = AddComponent(water); model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj"; auto blendmap = AddComponent(water); blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg"; blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg"; blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg"; blendmap->TextureRepeats = 1.f; auto physics = AddComponent(water); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; { auto groundshape = CreateEntity(water); auto box = AddComponent(groundshape); box->Depth = 250.f; box->Height = 5.f; box->Width = 250.f; CommitEntity(groundshape); } CommitEntity(water);*/ { auto water = CreateEntity(); auto transform = AddComponent(water); { auto waves = CreateEntity(water); auto transform = AddComponent(water); auto model = AddComponent(water); model->ModelFile = "Models/Water/Waves.obj"; CommitEntity(waves); } CommitEntity(water); } } { auto ground_middle = CreateEntity(); auto transform = AddComponent(ground_middle); auto model = AddComponent(ground_middle); model->ModelFile = "Models/TerrainFiveIstles/Middle.obj"; model->AverageNormals = true; auto blendmap = AddComponent(ground_middle); blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; blendmap->TextureRepeats = 30.f; auto physics = AddComponent(ground_middle); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; auto groundshape = CreateEntity(ground_middle); auto transformshape = AddComponent(groundshape); auto meshShape = AddComponent(groundshape); meshShape->ResourceName = "Models/TerrainFiveIstles/Middle.obj"; CommitEntity(groundshape); CommitEntity(ground_middle); } { auto decoration_middle = CreateEntity(); auto transform = AddComponent(decoration_middle); auto model = AddComponent(decoration_middle); model->ModelFile = "Models/TerrainFiveIstles/Decoration/Middle.obj"; CommitEntity(decoration_middle); } CreateBase(glm::quat(), 1); CreateBase(glm::quat(glm::vec3(0, glm::pi(), 0)), 2); { auto tree = CreateEntity(); auto transform = AddComponent(tree); transform->Position = glm::vec3(0, -10, 0); auto physics = AddComponent(tree); physics->Mass = 100.f; physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; physics->CollisionEvent = false; //physics->LinearDamping = 3.f; physics->CalculateCenterOfMass = true; { auto stem = CreateEntity(tree); auto transform = AddComponent(stem); transform->Position = glm::vec3(0, -2.40906f, 0); auto model = AddComponent(stem); model->ModelFile = "Models/Tree/Stem/Stem.obj"; } { auto leafs = CreateEntity(tree); auto transform = AddComponent(leafs); transform->Position = glm::vec3(0, -2.45511f, 0); auto model = AddComponent(leafs); model->ModelFile = "Models/Tree/Leafs/Leafs.obj"; model->Transparent = true; CommitEntity(leafs); } { auto shape = CreateEntity(tree); auto transform = AddComponent(shape); transform->Position = glm::vec3(0.f, 0.f, 0.f); auto mesh = AddComponent(shape); mesh->ResourceName = "Models/Tree/Collision/Collision.obj"; CommitEntity(shape); } /*{ auto shape = CreateEntity(tree); auto transform = AddComponent(shape); auto box = AddComponent(shape); transform->Position = glm::vec3(0.f, 0, 0.f); box->Width = 0.296f; box->Height = 2.511f; box->Depth = 0.296f; CommitEntity(shape); } { auto shape = CreateEntity(tree); auto transform = AddComponent(shape); auto sphere = AddComponent(shape); transform->Position = glm::vec3(0, 2.04506f, 0.f); sphere->Radius = 1.389f; CommitEntity(shape); }*/ CommitEntity(tree); } } void GameWorld::CreateBase(glm::quat orientation, int teamID) { auto base = CreateEntity(); auto transform = AddComponent(base); transform->Orientation = orientation; #pragma region Terrain { auto ground_small = CreateEntity(base); auto transform = AddComponent(ground_small); auto model = AddComponent(ground_small); model->ModelFile = "Models/TerrainFiveIstles/Small.obj"; model->AverageNormals = true; auto blendmap = AddComponent(ground_small); blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; blendmap->TextureRepeats = 30.f; auto physics = AddComponent(ground_small); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; auto groundshape = CreateEntity(ground_small); auto transformshape = AddComponent(groundshape); auto meshShape = AddComponent(groundshape); meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj"; CommitEntity(groundshape); CommitEntity(ground_small); } { auto decoration_small = CreateEntity(base); auto transform = AddComponent(decoration_small); auto model = AddComponent(decoration_small); model->ModelFile = "Models/TerrainFiveIstles/Decoration/Small.obj"; CommitEntity(decoration_small); } { auto road_small = CreateEntity(base); auto transform = AddComponent(road_small); auto model = AddComponent(road_small); model->ModelFile = "Models/TerrainFiveIstles/Roads/SmallRoad.obj"; auto physics = AddComponent(road_small); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; auto groundshape = CreateEntity(road_small); auto transformshape = AddComponent(groundshape); auto meshShape = AddComponent(groundshape); meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/SmallRoad.obj"; CommitEntity(groundshape); CommitEntity(road_small); } { auto bridge_middle = CreateEntity(base); auto transform = AddComponent(bridge_middle); auto model = AddComponent(bridge_middle); model->ModelFile = "Models/TerrainFiveIstles/Bridges/MiddleBridge.obj"; model->AverageNormals = false; auto physics = AddComponent(bridge_middle); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; { auto shape = CreateEntity(bridge_middle); auto transform = AddComponent(shape); transform->Position = glm::vec3(70.31883f, 26.42735f, 0.50379f); auto box = AddComponent(shape); box->Width = 26.324f; box->Height = 2.727f; box->Depth = 6.798f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_middle); auto transform = AddComponent(shape); transform->Position = glm::vec3(70.43447f, 29.23594f, 7.37155f); auto box = AddComponent(shape); box->Width = 27.724f; box->Height = 1.334f; box->Depth = 0.571f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_middle); auto transform = AddComponent(shape); transform->Position = glm::vec3(70.43447f, 29.26906f, -6.68171f); auto box = AddComponent(shape); box->Width = 27.724f; box->Height = 1.334f; box->Depth = 0.571f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_middle); auto transform = AddComponent(shape); transform->Position = glm::vec3(70.36976f, 33.56011f, 9.68543f); auto box = AddComponent(shape); box->Width = 1.8f; box->Height = 15.984f; box->Depth = 1.456f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_middle); auto transform = AddComponent(shape); transform->Position = glm::vec3(70.36976f, 33.56011f, -8.67785f); auto box = AddComponent(shape); box->Width = 1.799f; box->Height = 15.983f; box->Depth = 1.456f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_middle); auto transform = AddComponent(shape); transform->Position = glm::vec3(99.16043f, 25.0318f, 0.54486f); transform->Orientation = glm::angleAxis(glm::radians(-9.087f), glm::vec3(0, 0, 1)); auto box = AddComponent(shape); box->Width = 3.566f; box->Height = 3.566f; box->Depth = 7.632f; CommitEntity(shape); } CommitEntity(bridge_middle); } // Banners std::string bannerModel = "Models/Banner/Blue/Blue.obj"; if (teamID == 2) { bannerModel = "Models/Banner/Red/Red.obj"; } { auto banner = CreateEntity(base); auto transform = AddComponent(banner); transform->Position = glm::vec3(70.2f, 50.36f, -8.68f); transform->Orientation = glm::quat(glm::vec3(0, glm::pi(), 0)); auto model = AddComponent(banner); model->ModelFile = bannerModel; model->Transparent = true; CommitEntity(banner); } { auto banner = CreateEntity(base); auto transform = AddComponent(banner); transform->Position = glm::vec3(70.2f, 50.36f, 9.86f); transform->Orientation = glm::quat(glm::vec3(0, glm::pi(), 0)); auto model = AddComponent(banner); model->ModelFile = bannerModel; model->Transparent = true; CommitEntity(banner); } { auto banner = CreateEntity(base); auto transform = AddComponent(banner); transform->Position = glm::vec3(166.17f, 49.711f, -8.68f); transform->Orientation = glm::quat(glm::vec3(0, glm::pi(), 0)); auto model = AddComponent(banner); model->ModelFile = bannerModel; model->Transparent = true; CommitEntity(banner); } { auto banner = CreateEntity(base); auto transform = AddComponent(banner); auto model = AddComponent(banner); transform->Position = glm::vec3(166.17f, 49.711f, 9.86f); transform->Orientation = glm::quat(glm::vec3(0, glm::pi(), 0)); model->ModelFile = bannerModel; model->Transparent = true; CommitEntity(banner); } { auto terrain_base = CreateEntity(base); auto transform = AddComponent(terrain_base); auto model = AddComponent(terrain_base); model->ModelFile = "Models/TerrainFiveIstles/Base.obj"; model->AverageNormals = true; auto blendmap = AddComponent(terrain_base); blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; blendmap->TextureRepeats = 30.f; auto physics = AddComponent(terrain_base); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; auto shape = CreateEntity(terrain_base); auto transformshape = AddComponent(shape); auto meshShape = AddComponent(shape); meshShape->ResourceName = "Models/TerrainFiveIstles/Base.obj"; CommitEntity(shape); CommitEntity(terrain_base); } { auto ground_base = CreateEntity(base); auto transform = AddComponent(ground_base); auto model = AddComponent(ground_base); model->ModelFile = "Models/TerrainFiveIstles/BaseGround.obj"; auto physics = AddComponent(ground_base); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; auto shape = CreateEntity(ground_base); auto transformshape = AddComponent(shape); auto meshShape = AddComponent(shape); meshShape->ResourceName = "Models/TerrainFiveIstles/BaseGround.obj"; CommitEntity(shape); CommitEntity(ground_base); } { auto decoration_base = CreateEntity(base); auto transform = AddComponent(decoration_base); auto model = AddComponent(decoration_base); model->ModelFile = "Models/TerrainFiveIstles/Decoration/Base.obj"; CommitEntity(decoration_base); } { auto road_base = CreateEntity(base); auto transform = AddComponent(road_base); auto model = AddComponent(road_base); model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; auto physics = AddComponent(road_base); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; auto groundshape = CreateEntity(road_base); auto transformshape = AddComponent(groundshape); auto meshShape = AddComponent(groundshape); meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; CommitEntity(groundshape); CommitEntity(road_base); } { auto bridge_base = CreateEntity(base); auto transform = AddComponent(bridge_base); auto model = AddComponent(bridge_base); model->ModelFile = "Models/TerrainFiveIstles/Bridges/BaseBridge.obj"; model->AverageNormals = false; auto physics = AddComponent(bridge_base); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; { auto shape = CreateEntity(bridge_base); auto transform = AddComponent(shape); transform->Position = glm::vec3(166.19089f, 25.99645f, -0.50379f); auto box = AddComponent(shape); box->Width = 27.723f; box->Height = 2.727f; box->Depth = 6.798f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_base); auto transform = AddComponent(shape); transform->Position = glm::vec3(166.19089f, 28.37571f, -6.68171f); auto box = AddComponent(shape); box->Width = 27.724f; box->Height = 1.334f; box->Depth = 0.571f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_base); auto transform = AddComponent(shape); transform->Position = glm::vec3(166.19089f, 28.37571f, 7.68929f); auto box = AddComponent(shape); box->Width = 27.724f; box->Height = 1.334f; box->Depth = 0.571f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_base); auto transform = AddComponent(shape); transform->Position = glm::vec3(166.12617f, 33.56011f, -8.67785f); auto box = AddComponent(shape); box->Width = 1.8; box->Height = 15.984f; box->Depth = 1.456f; CommitEntity(shape); } { auto shape = CreateEntity(bridge_base); auto transform = AddComponent(shape); transform->Position = glm::vec3(166.12617f, 33.56011f, 9.68543f); auto box = AddComponent(shape); box->Width = 1.8; box->Height = 15.984f; box->Depth = 1.456f; CommitEntity(shape); } CommitEntity(bridge_base); } #pragma endregion Terrain // Small island CreateGate(base, glm::vec3(113.59f, 29.02f, 0.32f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), teamID); // Z glm::quat yawRot = glm::angleAxis(glm::pi() / 2.f, glm::vec3(0, 1, 0)); CreateWall(base, glm::vec3(113.59f, 28.79635f, 15.26201f), yawRot); // glm::quat(glm::vec3(glm::radians(-9.21f), 0, 0))); CreateWall(base, glm::vec3(113.60f, 28.05425f, 24.41458f), glm::angleAxis(glm::radians(9.21f), glm::vec3(1, 0, 0)) * yawRot); CreateWall(base, glm::vec3(113.61f, 25.42271f, 32.34383f), glm::angleAxis(glm::radians(27.f), glm::vec3(1, 0, 0)) * yawRot); CreateWall(base, glm::vec3(113.62f, 20.54767f, 38.68277f), glm::angleAxis(glm::radians(47.9f), glm::vec3(1, 0, 0)) * yawRot); // -Z CreateWall(base, glm::vec3(113.59f, 28.734f, -13.85581f), glm::angleAxis(glm::radians(-3.634f), glm::vec3(1, 0, 0)) * yawRot); CreateWall(base, glm::vec3(113.60f, 27.166f, -22.438f), glm::angleAxis(glm::radians(-17.202f), glm::vec3(1, 0, 0)) * yawRot); CreateWall(base, glm::vec3(113.61f, 23.5952f, -30.50557f), glm::angleAxis(glm::radians(-30.638f), glm::vec3(1, 0, 0)) * yawRot); CreateWall(base, glm::vec3(113.62f, 18.30851f, -36.56623f), glm::angleAxis(glm::radians(-51.542f), glm::vec3(1, 0, 0)) * yawRot); // -X CreateGate(base, glm::vec3(273.f, 40.185f, 0.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), teamID); CreateWall(base, glm::vec3(273.f, 40.3f, -55.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, -45.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, -35.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, -25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, -15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, 15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, 25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateTower(base, glm::vec3(290.f, 40.3f, 15.f), teamID); // -Z CreateWall(base, glm::vec3(280.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(290.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(300.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(310.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(320.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(330.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(340.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(350.f, 40.3f, -62.f), glm::quat(glm::vec3(0, 0, 0))); // X CreateWall(base, glm::vec3(357.f, 40.3f, -55.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, -45.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, -35.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, -25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, -15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, -5.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, 5.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, 15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(357.f, 40.3f, 25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); // Z CreateWall(base, glm::vec3(280.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(290.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(300.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(310.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(320.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(330.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(340.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateWall(base, glm::vec3(350.f, 40.3f, 32.f), glm::quat(glm::vec3(0, 0, 0))); CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), teamID); } EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int teamID) { auto garage = CreateEntity(parent); auto transform = AddComponent(garage); transform->Position = Position; transform->Orientation = orientation; auto ElevatorBase = CreateEntity(garage); { auto transform = AddComponent(ElevatorBase); auto model = AddComponent(ElevatorBase); model->ModelFile = "Models/SpawnRamp/Main/Main.obj"; auto physics = AddComponent(ElevatorBase); physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; { auto mainShape = CreateEntity(ElevatorBase); auto transform = AddComponent(mainShape); transform->Position = glm::vec3(0.f, 0, 0.f); auto mesh = AddComponent(mainShape); mesh->ResourceName = "Models/SpawnRamp/Main/CollisionShape.obj"; CommitEntity(mainShape); } { auto StairsShape = CreateEntity(ElevatorBase); auto transform = AddComponent(StairsShape); transform->Position = glm::vec3(-7.48639f, 0.4809f, 3.79166f); auto box = AddComponent(StairsShape); box->Width = 1.211f; box->Height = 1.798f; box->Depth = 3.229f; CommitEntity(StairsShape); } } CommitEntity(ElevatorBase); auto leftHatch = CreateEntity(garage); { auto transform = AddComponent(leftHatch); transform->Position = glm::vec3(5.83103f, 1.3553f, -2.40268f); auto model = AddComponent(leftHatch); model->ModelFile = "Models/SpawnRamp/LeftHatch/LeftHatch.obj"; auto physics = AddComponent(leftHatch); physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; auto rotate = AddComponent(leftHatch); rotate->StartRotation = transform->Orientation; rotate->GoalRotation = transform->Orientation * glm::angleAxis(-glm::radians(110.f), glm::vec3(0, 0, 1)); rotate->Time = 5.f; { auto shape = CreateEntity(leftHatch); auto transform = AddComponent(shape); transform->Position = glm::vec3(-2.79331, 0, 0); auto box = AddComponent(shape); box->Width = 2.317f; box->Height = 0.183f; box->Depth = 6.987f; CommitEntity(shape); } CommitEntity(leftHatch); } auto rightHatch = CreateEntity(garage); { auto transform = AddComponent(rightHatch); transform->Position = glm::vec3(-4.52423f, 1.3553f, -2.40268f); auto model = AddComponent(rightHatch); model->ModelFile = "Models/SpawnRamp/RightHatch/RightHatch.obj"; auto physics = AddComponent(rightHatch); physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; auto rotate = AddComponent(rightHatch); rotate->StartRotation = transform->Orientation; rotate->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1)); rotate->Time = 5.f; { auto shape = CreateEntity(rightHatch); auto transform = AddComponent(shape); transform->Position = glm::vec3(2.79331, 0, 0); auto box = AddComponent(shape); box->Width = 2.317f; box->Height = 0.183f; box->Depth = 6.987f; CommitEntity(shape); } CommitEntity(rightHatch); } auto elevator = CreateEntity(garage); { auto transform = AddComponent(elevator); transform->Position = glm::vec3(0.69385f, 1.25222f, -2.39938f) + glm::vec3(0, -9.5f, 0); auto model = AddComponent(elevator); model->ModelFile = "Models/SpawnRamp/Elevator/Elevator.obj"; auto physics = AddComponent(elevator); physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; auto move = AddComponent(elevator); move->StartPosition = transform->Position; move->GoalPosition = transform->Position + glm::vec3(0, 9.5f, 0); move->Speed = 1.5f; { auto shape = CreateEntity(elevator); auto transform = AddComponent(shape); transform->Position = glm::vec3(0, 0, 0); auto box = AddComponent(shape); box->Width = 4.754f; box->Height = 0.141f; box->Depth = 6.86f; CommitEntity(shape); } auto spawnPoint = CreateEntity(elevator); { auto transform = AddComponent(spawnPoint); transform->Position.y = 1.f; auto spawnPointComponent = AddComponent(spawnPoint); auto teamComponent = AddComponent(spawnPoint); teamComponent->TeamID = teamID; } CommitEntity(spawnPoint); } CommitEntity(elevator); auto garageComponent = AddComponent(garage); garageComponent->DoorLeft = leftHatch; garageComponent->DoorRight = rightHatch; garageComponent->Elevator = elevator; CommitEntity(garage); { auto trigger = CreateEntity(garage); SetProperty(trigger, "Name", "BoundsTrigger"); auto transform = AddComponent(trigger); transform->Position = glm::vec3(0, 44.87521f, 0); auto triggerComponent = AddComponent(trigger); triggerComponent->TeamID = teamID; auto teamComponent = AddComponent(trigger); teamComponent->TeamID = teamID; { auto shape = CreateEntity(trigger); auto transform = AddComponent(shape); transform->Position = glm::vec3(0, 0, 0); auto box = AddComponent(shape); box->Width = 72.98f; box->Height = 54.53f; box->Depth = 72.98f; CommitEntity(shape); } CommitEntity(trigger); } { auto trigger = CreateEntity(garage); SetProperty(trigger, "Name", "ElevatorShaftTrigger"); auto transform = AddComponent(trigger); transform->Position = glm::vec3(0.69385f, -6.7997f, -2.0f); auto triggerComponent = AddComponent(trigger); triggerComponent->TeamID = teamID; auto teamComponent = AddComponent(trigger); teamComponent->TeamID = teamID; { auto shape = CreateEntity(trigger); auto transform = AddComponent(shape); transform->Position = glm::vec3(0, 0, 0); auto box = AddComponent(shape); box->Width = 2.0f; box->Height = 12.f; box->Depth = 2.0f; CommitEntity(shape); } CommitEntity(trigger); } return garage; }