Merge remote-tracking branch 'origin/master' into DashAbiltyEffect

This commit is contained in:
stiffly
2016-03-02 16:57:07 +01:00
57 changed files with 16659 additions and 560 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ void EditorRenderSystem::Update(double dt)
EntityWrapper entity(m_World, cModel.EntityID);
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
for (auto matGroup : model->MaterialGroups()) {
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f, false);
if (cModel["Transparent"]) {
scene.Jobs.TransparentObjects.push_back(modelJob);
} else {
@@ -18,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms()
m_ColorCorrectionProgram->Link();
}
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure)
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure)
{
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLERROR("DrawScreenQuadPass::Draw: Pre");
@@ -33,10 +33,6 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLu
glBindTexture(GL_TEXTURE_2D, sceneTexture);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, bloomTexture);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, sceneTextureLowRes);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, bloomTextureLowRes);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
File diff suppressed because it is too large Load Diff
+7 -10
View File
@@ -8,13 +8,12 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
Enable(GL_BLEND);
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Enable(GL_DEPTH_TEST);
DepthMask(GL_FALSE);
DepthFunc(GL_LEQUAL);
DepthMask(GL_TRUE);
Enable(GL_CULL_FACE);
Enable(GL_STENCIL_TEST);
StencilFunc(GL_NOTEQUAL, 1, 0xFF);
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
StencilMask(0xFF);
// Enable(GL_STENCIL_TEST);
// StencilFunc(GL_NOTEQUAL, 1, 0xFF);
// StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// StencilMask(0xFF);
ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f));
}
@@ -26,11 +25,9 @@ DrawFinalPassState::~DrawFinalPassState()
DrawStencilState::DrawStencilState(GLuint frameBuffer)
{
BindFramebuffer(frameBuffer);
Enable(GL_STENCIL_TEST);
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
StencilFunc(GL_ALWAYS, 1, 0xFF);
StencilMask(0xFF);
Enable(GL_DEPTH_TEST);
DepthMask(GL_TRUE);
Enable(GL_CULL_FACE);
ClearColor(glm::vec4(0.f));
}
+2 -1
View File
@@ -23,11 +23,12 @@ void PickingPass::InitializeTextures()
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
}
void PickingPass::InitializeFrameBuffers()
{
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0)));
m_PickingBuffer.Generate();
+10 -9
View File
@@ -240,6 +240,8 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
fillColor = (glm::vec4)fillComponent["Color"];
}
bool isShielded = m_World->HasComponent(cModel.EntityID, "Shielded") || m_World->HasComponent(cModel.EntityID, "Player");
glm::mat4 modelMatrix = Transform::ModelMatrix(cModel.EntityID, m_World);
//Loop through all materialgroups of a model
for (auto matGroup : model->MaterialGroups()) {
@@ -255,20 +257,19 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
cModel,
m_World,
fillColor,
fillPercentage
fillPercentage,
isShielded
));
if (m_World->HasComponent(cModel.EntityID, "Shield")){
explosionEffectJob->CalculateHash();
Jobs.ShieldObjects.push_back(explosionEffectJob);
} else if (m_World->HasComponent(cModel.EntityID, "Shielded")
|| m_World->HasComponent(cModel.EntityID, "Player")) {
} else if (isShielded) {
if (explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
cModel["Transparent"] = true;
}
if (cModel["Transparent"]) {
Jobs.TransparentShieldedObjects.push_back(explosionEffectJob);
Jobs.TransparentObjects.push_back(explosionEffectJob);
} else {
explosionEffectJob->CalculateHash();
Jobs.OpaqueShieldedObjects.push_back(explosionEffectJob);
@@ -294,20 +295,20 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
cModel,
m_World,
fillColor,
fillPercentage
fillPercentage,
isShielded
));
if (m_World->HasComponent(cModel.EntityID, "Shield")) {
modelJob->CalculateHash();
Jobs.ShieldObjects.push_back(modelJob);
} else if (m_World->HasComponent(cModel.EntityID, "Shielded")
|| m_World->HasComponent(cModel.EntityID, "Player")) {
} else if (isShielded) {
if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) {
cModel["Transparent"] = true;
}
if (cModel["Transparent"]) {
Jobs.TransparentShieldedObjects.push_back(modelJob);
Jobs.TransparentObjects.push_back(modelJob);
} else {
modelJob->CalculateHash();
Jobs.OpaqueShieldedObjects.push_back(modelJob);
+5 -11
View File
@@ -110,7 +110,7 @@ void Renderer::Draw(RenderFrame& frame)
{
GLERROR("PRE");
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking\0Ambient Occlusion");
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
if(m_CubeMapTexture == 0) {
m_CubeMapPass->LoadTextures("Nevada");
@@ -174,7 +174,7 @@ void Renderer::Draw(RenderFrame& frame)
if (m_DebugTextureToDraw == 0) {
PerformanceTimer::StartTimer("Renderer-Color Correction Pass");
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure);
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure);
PerformanceTimer::StopTimer("Renderer-Color Correction Pass");
}
@@ -186,18 +186,12 @@ void Renderer::Draw(RenderFrame& frame)
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTexture());
}
if (m_DebugTextureToDraw == 3) {
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTextureLowRes());
}
if (m_DebugTextureToDraw == 4) {
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTextureLowRes());
}
if (m_DebugTextureToDraw == 5) {
m_DrawScreenQuadPass->Draw(m_DrawBloomPass->GaussianTexture());
}
if (m_DebugTextureToDraw == 6) {
if (m_DebugTextureToDraw == 4) {
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
}
if (m_DebugTextureToDraw == 7) {
if (m_DebugTextureToDraw == 5) {
m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture());
}
PerformanceTimer::StopTimer("Renderer-Misc Debug Draws");
@@ -250,7 +244,7 @@ void Renderer::InitializeRenderPasses()
m_LightCullingPass = new LightCullingPass(this);
m_CubeMapPass = new CubeMapPass(this);
m_SSAOPass = new SSAOPass(this, m_Config);
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_PickingPass->DepthBuffer());
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass);
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
m_DrawBloomPass = new DrawBloomPass(this, m_Config);
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
+12
View File
@@ -25,7 +25,9 @@
#include "Rendering/AnimationSystem.h"
#include "Network/MultiplayerSnapshotFilter.h"
#include "Game/Systems/AmmunitionHUDSystem.h"
#include "Game/Systems/CapturePointArrowHUDSystem.h"
#include "Game/Systems/KillFeedSystem.h"
#include "Game/Systems/BoostSystem.h"
#include "GUI/ButtonSystem.h"
#include "GUI/MainMenuSystem.h"
@@ -131,7 +133,17 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointArrowHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<BoostSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer);
// Populate Octree with collidables
+68 -40
View File
@@ -5,6 +5,7 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params)
{
if (IsServer) {
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &AmmoPickupSystem::OnTriggerLeave);
}
if (IsClient) {
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &AmmoPickupSystem::OnAmmoPickup);
@@ -14,43 +15,51 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params)
void AmmoPickupSystem::Update(double dt)
{
if (IsServer) {
for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) {
auto& ammoPickupPosition = *it;
//set the double timer value (value 3)
ammoPickupPosition.DecreaseThisRespawnTimer -= dt;
if (ammoPickupPosition.DecreaseThisRespawnTimer < 0.0) {
//spawn and delete the vector item
auto it = m_ETriggerTouchVector.begin();
while (it != m_ETriggerTouchVector.end()) {
auto& somePickup = *it;
somePickup.DecreaseThisRespawnTimer -= dt;
if (somePickup.DecreaseThisRespawnTimer < 0.0) {
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/AmmoPickup.xml");
EntityFileParser parser(entityFile);
EntityID ammoPickupID = parser.MergeEntities(m_World);
//let the world know a pickup has spawned (graphics effects, etc)
//let the world know a pickup has spawned
Events::PickupSpawned ePickupSpawned;
ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID);
m_EventBroker->Publish(ePickupSpawned);
//set values from the old entity to the new entity
//copy values from the old entity to the new entity
auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID);
newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos;
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain;
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer;
m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID);
newAmmoPickupEntity["Transform"]["Position"] = somePickup.Pos;
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = somePickup.AmmoGain;
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = somePickup.RespawnTimer;
m_World->SetParent(newAmmoPickupEntity.ID, somePickup.parentID);
//erase the current element (AmmoPickupPosition)
m_ETriggerTouchVector.erase(it);
//erase the current element (somePickup)
it = m_ETriggerTouchVector.erase(it);
}
else {
it++;
}
}
//still touching m_PickupAtMaximum?
for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) {
if (!it->player.Valid()) {
m_PickupAtMaximum.erase(it);
break;
}
if ((int)it->player["AssaultWeapon"]["Ammo"] < (int)it->player["AssaultWeapon"]["MaxAmmo"]) {
DoPickup(it->player, it->trigger);
m_PickupAtMaximum.erase(it);
break;
}
}
}
}
bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
{
/*if (e.Entity != LocalPlayer) {
return false;
}*/
if (!e.Entity.Valid()) {
return false;
}
@@ -61,30 +70,13 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
if (!e.Trigger.HasComponent("AmmoPickup")) {
return false;
}
int maxWeaponAmmo = (int)e.Entity["AssaultWeapon"]["MaxAmmo"];
int& currentAmmo = (int)e.Entity["AssaultWeapon"]["Ammo"];
int ammoGiven = 0.01*(double)e.Trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo;
//cant pick up ammopacks if you are already at MaxAmmo
if (currentAmmo >= maxWeaponAmmo) {
//if at maxammo, save the trigger-touch to a vector since standing inside it will not re-trigger the trigger
if ((int)e.Entity["AssaultWeapon"]["Ammo"] >= (int)e.Entity["AssaultWeapon"]["MaxAmmo"]) {
m_PickupAtMaximum.push_back({ e.Entity, e.Trigger });
return false;
}
//personEntered = e.Entity, thingEntered = e.Trigger
Events::AmmoPickup ePlayerAmmoPickup;
ePlayerAmmoPickup.AmmoGain = ammoGiven;
ePlayerAmmoPickup.Player = e.Entity;
m_EventBroker->Publish(ePlayerAmmoPickup);
//immediately give the player the ammo
//currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo);
//copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
//we need to copy all values since each value can be different for each ammoPickup
m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"],
e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
//delete the ammopickup
m_World->DeleteEntity(e.Trigger.ID);
DoPickup(e.Entity, e.Trigger);
return true;
}
@@ -107,3 +99,39 @@ bool AmmoPickupSystem::OnAmmoPickup(Events::AmmoPickup & e)
currentAmmo = std::min(currentAmmo + e.AmmoGain, maxWeaponAmmo);
return false;
}
bool AmmoPickupSystem::OnTriggerLeave(Events::TriggerLeave& e) {
if (!e.Trigger.HasComponent("AmmoPickup")) {
return false;
}
//triggerleave erases possible m_PickupAtMaximum
for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) {
if (it->trigger.ID == e.Trigger.ID && it->player.ID == e.Entity.ID) {
m_PickupAtMaximum.erase(it);
break;
}
}
return true;
}
void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) {
int maxWeaponAmmo = (int)player["AssaultWeapon"]["MaxAmmo"];
int& currentAmmo = (int)player["AssaultWeapon"]["Ammo"];
int ammoGiven = 0.01*(double)trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo;
Events::AmmoPickup ePlayerAmmoPickup;
ePlayerAmmoPickup.AmmoGain = ammoGiven;
ePlayerAmmoPickup.Player = player;
m_EventBroker->Publish(ePlayerAmmoPickup);
//immediately give the player the ammo (on server)
currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo);
//copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
//we need to copy all values since each value can be different for each ammoPickup
m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"], trigger["AmmoPickup"]["AmmoGain"],
trigger["AmmoPickup"]["RespawnTimer"], trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(trigger.ID) });
//delete the ammopickup
m_World->DeleteEntity(trigger.ID);
}
+63
View File
@@ -0,0 +1,63 @@
#include "Systems/BoostSystem.h"
BoostSystem::BoostSystem(SystemParams params)
: System(params)
{
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &BoostSystem::OnPlayerDamage);
}
bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
{
if (e.Victim.ID == e.Inflictor.ID) {
return false;
}
if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
return false;
}
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
return false;
}
//if its not friendly fire, return
if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) {
return false;
}
//determine the inflictors class
auto className = DetermineClass(e.Inflictor);
if (className == "") {
return false;
}
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
std::string classXML = "Schema/Entities/" + className + ".xml";
//check if player already has a child with the component, if so delete that child
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
if (playerBoostAssaultEntity.Valid()) {
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
}
//load boost XML file, set it entity parented with the victim player
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
EntityFileParser parser(entityFile);
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
m_World->SetName(boostAssaultEntity, className);
m_World->SetParent(boostAssaultEntity, e.Victim.ID);
return true;
}
std::string BoostSystem::DetermineClass(EntityWrapper inflictorPlayer)
{
//determine the class based on what component the inflictor-player has
if (m_World->HasComponent(inflictorPlayer.ID, "DashAbility")) {
return "BoostAssault";
}
if (m_World->HasComponent(inflictorPlayer.ID, "ShieldAbility")) {
return "BoostDefender";
}
if (m_World->HasComponent(inflictorPlayer.ID, "SprintAbility")) {
return "BoostSniper";
}
return "";
}
@@ -0,0 +1,183 @@
#include "Systems/CapturePointArrowHUDSystem.h"
CapturePointArrowHUDSystem::CapturePointArrowHUDSystem(SystemParams params)
: System(params)
, ImpureSystem()
{
EVENT_SUBSCRIBE_MEMBER(m_ECapturedEvent, &CapturePointArrowHUDSystem::OnCapturePointCaptured);
}
void CapturePointArrowHUDSystem::Update(double dt)
{
bool loadCheck = true;
int redTeamEnum;
int blueTeamEnum;
int spectatorTeamEnum;
//Get list for all CapturePointArrowHUDComponents
auto arrowHUDs = m_World->GetComponents("CapturePointArrowHUD");
auto capturePoints = m_World->GetComponents("CapturePoint");
if(arrowHUDs == nullptr) {
return;
}
for(auto& cArrowHUD : *arrowHUDs) {
//Get what team the current arrow corresponds to
EntityWrapper arrowEntity = EntityWrapper(m_World, cArrowHUD.EntityID);
if (!arrowEntity.Valid()) {
continue;
}
if(!arrowEntity.HasComponent("Team")) {
continue;
}
auto cTeam = arrowEntity["Team"];
int currentTeam = (int)cTeam["Team"];
if (loadCheck) {
redTeamEnum = (int)cTeam["Team"].Enum("Red");
blueTeamEnum = (int)cTeam["Team"].Enum("Blue");
spectatorTeamEnum = (int)cTeam["Team"].Enum("Spectator");
loadCheck = false;
if (!m_InitialtargetsSet) {
std::unordered_map<int, glm::vec3> blueTargets, redTargets;
EntityWrapper homeBlue, homeRed;
int lastCP = -INFINITY;
int firstCP = INFINITY;
for (auto& cCP : *capturePoints) {
auto homePointTeam = (int)cCP["HomePointForTeam"];
EntityWrapper capturePointEntity = EntityWrapper(m_World, cCP.EntityID);
int capturePointID = (int)capturePointEntity["CapturePoint"]["CapturePointNumber"];
if(capturePointID < firstCP) {
firstCP = capturePointID;
}
if(capturePointID > lastCP) {
lastCP = capturePointID;
}
if (!capturePointEntity.HasComponent("Team")) {
continue;
}
int currentOwner = (int)capturePointEntity["Team"]["Team"];
if(currentOwner != redTeamEnum) {
//This capturePoint is not owned by the red team and is therefor an eligible target for red team
glm::vec3 targetPos = Transform::AbsolutePosition(capturePointEntity);
redTargets.insert(std::pair<int, glm::vec3>(capturePointID, targetPos));
}
if(currentOwner != blueTeamEnum) {
//This capturePoint is not owned by the blue team and is therefor an eligible target for blue team
glm::vec3 targetPos = Transform::AbsolutePosition(capturePointEntity);
blueTargets.insert(std::pair<int, glm::vec3>(capturePointID, targetPos));
}
if(homePointTeam == blueTeamEnum) {
//CP is the home point for blue team.
homeBlue = capturePointEntity;
} else if (homePointTeam == redTeamEnum) {
//CP is the home point for red team.
homeRed = capturePointEntity;
}
}
if(!homeRed.Valid() || !homeBlue.Valid()) {
//One or both teams have no home point, cant continue
return;
}
std::unordered_map<int, glm::vec3>::const_iterator got;
//Find next target for red team.
if((int)homeRed["CapturePoint"]["CapturePointNumber"] == lastCP) {
//Red home base is the last capture point, count back from lastCP and find next target
for (int i = lastCP; i >= firstCP; i--) {
got = redTargets.find(i);
if(got == redTargets.end()) {
continue;
} else {
m_RedTeamCurrentTarget = got->second;
break;
}
}
} else if ((int)homeRed["CapturePoint"]["CapturePointNumber"] == firstCP) {
//Red home is the first capture point, count forward from firstCP and find next target.
for (int i = firstCP; i <= lastCP; i++) {
got = redTargets.find(i);
if(got == redTargets.end()) {
//Target was not found, try the next one after that.
continue;
} else {
m_RedTeamCurrentTarget = got->second;
break;
}
}
}
//Find next target for blue team
if ((int)homeBlue["CapturePoint"]["CapturePointNumber"] == lastCP) {
//Red home base is the last capture point, count back from lastCP and find next target
for (int i = lastCP; i >= firstCP; i--) {
got = blueTargets.find(i);
if (got == blueTargets.end()) {
continue;
} else {
m_BlueTeamCurrentTarget = got->second;
break;
}
}
} else if ((int)homeBlue["CapturePoint"]["CapturePointNumber"] == firstCP) {
//Red home is the first capture point, count forward from firstCP and find next target.
for (int i = firstCP; i <= lastCP; i++) {
got = blueTargets.find(i);
if (got == blueTargets.end()) {
//Target was not found, try the next one after that.
continue;
} else {
m_BlueTeamCurrentTarget = got->second;
break;
}
}
}
}
}
//if red team, get red team next point, otherwise blue team next point.
//Untill this is awailable we will just use the hardcoded value in the component.
//This will also give us a position, so we wont need to loop through all capturePoints.
glm::vec3 pos;
if(currentTeam == redTeamEnum) {
pos = m_RedTeamCurrentTarget;
} else if (currentTeam == blueTeamEnum) {
pos = m_BlueTeamCurrentTarget;
}
glm::vec3& arrowOri = arrowEntity["Transform"]["Orientation"];
glm::vec3 lookVector = glm::normalize(Transform::AbsolutePosition(arrowEntity) - pos); //Maybe should be player instead
float pitch = std::asin(-lookVector.y);
float yaw = std::atan2(lookVector.x, lookVector.z);
arrowOri.x = pitch;
arrowOri.y = yaw;
arrowOri.z = 0.f;
EntityWrapper parent = arrowEntity.Parent();
if (parent.Valid()) {
arrowOri -= Transform::AbsoluteOrientationEuler(parent);
}
}
}
bool CapturePointArrowHUDSystem::OnCapturePointCaptured(Events::Captured& e)
{
if(!e.BlueTeamNextCapturePoint.Valid() || !e.RedTeamNextCapturePoint.Valid()) {
return 0;
}
m_RedTeamCurrentTarget = Transform::AbsolutePosition(e.RedTeamNextCapturePoint);
m_BlueTeamCurrentTarget = Transform::AbsolutePosition(e.BlueTeamNextCapturePoint);
m_InitialtargetsSet = true;
return 0;
}
+2 -3
View File
@@ -103,9 +103,8 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
}
}
if (m_RecentlyCapturedNeedNextCapturePointNow) {
m_CapturedEvent.NextCapturePoint = m_CapturedEvent.TeamNumberThatCapturedCapturePoint == blueTeam ?
m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]] :
m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]];
m_CapturedEvent.BlueTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]];
m_CapturedEvent.RedTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]];
m_EventBroker->Publish(m_CapturedEvent);
m_RecentlyCapturedNeedNextCapturePointNow = false;
}
+5
View File
@@ -30,6 +30,11 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
ComponentWrapper cHealth = e.Victim["Health"];
double& health = cHealth["Health"];
//if player has the boost from a defender, subtract the damage taken by StrengthOfEffect amount
auto playerBoostDefenderEntity = e.Victim.FirstChildByName("BoostDefender");
if (playerBoostDefenderEntity.Valid()) {
e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"];
}
health -= e.Damage;
return true;
+55 -23
View File
@@ -5,18 +5,19 @@ PickupSpawnSystem::PickupSpawnSystem(SystemParams params)
{
if (IsServer) {
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &PickupSpawnSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &PickupSpawnSystem::OnTriggerLeave);
}
}
void PickupSpawnSystem::Update(double dt)
{
if (IsServer) {
for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) {
auto& healthPickupPosition = *it;
//set the double timer value (value 3)
healthPickupPosition.DecreaseThisRespawnTimer -= dt;
if (healthPickupPosition.DecreaseThisRespawnTimer < 0) {
//spawn and delete the vector item
auto it = m_ETriggerTouchVector.begin();
while (it != m_ETriggerTouchVector.end()) {
auto& somePickup = *it;
somePickup.DecreaseThisRespawnTimer -= dt;
if (somePickup.DecreaseThisRespawnTimer < 0.0) {
//spawn the new healthPickup
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/HealthPickup.xml");
EntityFileParser parser(entityFile);
EntityID healthPickupID = parser.MergeEntities(m_World);
@@ -26,45 +27,76 @@ void PickupSpawnSystem::Update(double dt)
ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID);
m_EventBroker->Publish(ePickupSpawned);
//set values from the old entity to the new entity
//copy values from the old entity to the new entity
auto& newHealthPickupEntity = EntityWrapper(m_World, healthPickupID);
newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos;
newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain;
newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer;
m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID);
newHealthPickupEntity["Transform"]["Position"] = somePickup.Pos;
newHealthPickupEntity["HealthPickup"]["HealthGain"] = somePickup.HealthGain;
newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = somePickup.RespawnTimer;
m_World->SetParent(newHealthPickupEntity.ID, somePickup.parentID);
//erase the current element (healthPickupPosition)
m_ETriggerTouchVector.erase(it);
//erase the current element (somePickup)
it = m_ETriggerTouchVector.erase(it);
} else {
it++;
}
}
//still touching PickupAtMaximum?
for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) {
if (!it->player.Valid()) {
m_PickupAtMaximum.erase(it);
break;
}
if ((double)it->player["Health"]["Health"] < (double)it->player["Health"]["MaxHealth"]) {
DoPickup(it->player, it->trigger);
m_PickupAtMaximum.erase(it);
break;
}
}
}
}
bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e)
{
if (!e.Trigger.HasComponent("HealthPickup")) {
return false;
}
double healthGiven = 0.01*(double)e.Trigger["HealthPickup"]["HealthGain"] * (double)e.Entity["Health"]["MaxHealth"];
//cant pick up healthpacks if you are already at MaxHealth
//if at maxhealth, save the trigger-touch to a vector since standing inside it will not re-trigger the trigger
if ((double)e.Entity["Health"]["Health"] >= (double)e.Entity["Health"]["MaxHealth"]) {
m_PickupAtMaximum.push_back({ e.Entity, e.Trigger });
return false;
}
//personEntered = e.Entity, thingEntered = e.Trigger
DoPickup(e.Entity, e.Trigger);
return true;
}
bool PickupSpawnSystem::OnTriggerLeave(Events::TriggerLeave& e)
{
if (!e.Trigger.HasComponent("HealthPickup")) {
return false;
}
//triggerleave erases possible m_PickupAtMaximum
for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) {
if (it->trigger.ID == e.Trigger.ID && it->player.ID == e.Entity.ID) {
m_PickupAtMaximum.erase(it);
break;
}
}
return true;
}
void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger)
{
double healthGiven = 0.01*(double)trigger["HealthPickup"]["HealthGain"] * (double)player["Health"]["MaxHealth"];
//only the server will increase the players hp and set it in the next delta
Events::PlayerHealthPickup ePlayerHealthPickup;
ePlayerHealthPickup.HealthAmount = healthGiven;
ePlayerHealthPickup.Player = e.Entity;
ePlayerHealthPickup.Player = player;
m_EventBroker->Publish(ePlayerHealthPickup);
//copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
//we need to copy all values since each value can be different for each healthPickup
m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"], e.Trigger["HealthPickup"]["HealthGain"],
e.Trigger["HealthPickup"]["RespawnTimer"], e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"], trigger["HealthPickup"]["HealthGain"],
trigger["HealthPickup"]["RespawnTimer"], trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(trigger.ID) });
//delete the healthpickup
m_World->DeleteEntity(e.Trigger.ID);
return true;
m_World->DeleteEntity(trigger.ID);
}
+10
View File
@@ -62,6 +62,12 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
float playerMovementSpeed = player["Player"]["MovementSpeed"];
float playerCrouchSpeed = player["Player"]["CrouchSpeed"];
glm::vec3& wishDirection = player["Player"]["CurrentWishDirection"];
auto playerBoostAssaultEntity = player.FirstChildByName("BoostAssault");
if (playerBoostAssaultEntity.Valid()) {
playerMovementSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
playerCrouchSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
}
if (player.HasComponent("Physics")) {
ComponentWrapper cPhysics = player["Physics"];
@@ -113,6 +119,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
//if doubleTapped do Assault Dash - but only boost maximum 50.0f
float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f;
accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f);
//if player has Boost from an Assault class, accelerate the player faster
if (playerBoostAssaultEntity.Valid()) {
accelerationSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
}
velocity += accelerationSpeed * wishDirection;
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
}
@@ -366,9 +366,10 @@ bool AssaultWeaponBehaviour::shoot(double damage)
return false;
}
// Check for friendly fire
// If friendly fire - reduce damage to 0 (needed to make Boosts, Ammosharing work)
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
return false;
damage = 0;
}
// Deal damage!