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

Conflicts:
	vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
ViktorLjung
2014-06-05 06:46:05 +02:00
7 changed files with 345 additions and 717 deletions
+20
View File
@@ -0,0 +1,20 @@
#ifndef Components_TowerDebris_h__
#define Components_TowerDebris_h__
#include "Component.h"
#include <string>
#include <vector>
namespace Components
{
struct TowerDebris : Component
{
std::vector<EntityID> TowerDebrisIDs;
virtual TowerDebris* Clone() const override { return new TowerDebris(*this); }
};
}
#endif // Components_TowerDebris_h__
+56 -1
View File
@@ -112,6 +112,51 @@ void GameWorld::Initialize()
EventBroker->Publish(e);
}
#pragma region Tower_Debris_Template
{
auto debri = CreateEntity();
AddComponent<Components::Template>(debri);
auto transform = AddComponent<Components::Transform>(debri);
transform->Position = glm::vec3(0.f, 4.12801f, 1.18125f);
auto model = AddComponent<Components::Model>(debri);
model->ModelFile = "Models/Turret/Gun/Gun.obj";
auto physics = AddComponent<Components::Physics>(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<Components::Transform>(shape);
auto shapemesh = AddComponent<Components::MeshShape>(shape);
shapemesh->ResourceName = "Models/Turret/Gun/Gun.obj";
m_TowerDebrisTemplates.push_back(debri);
}
{
auto debri = CreateEntity();
AddComponent<Components::Template>(debri);
auto transform = AddComponent<Components::Transform>(debri);
transform->Position = glm::vec3(0.f, 5.889f-0.92791f, 0.f);
auto model = AddComponent<Components::Model>(debri);
model->ModelFile = "Models/Turret/GunRotation/GunRotation.obj";
auto physics = AddComponent<Components::Physics>(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<Components::Transform>(shape);
auto shapemesh = AddComponent<Components::MeshShape>(shape);
shapemesh->ResourceName = "Models/Turret/GunRotation/GunRotation.obj";
m_TowerDebrisTemplates.push_back(debri);
}
#pragma endregion
#pragma region Wall_Debris_Template
{
@@ -734,6 +779,9 @@ EntityID GameWorld::CreateTower(EntityID parent, glm::vec3 pos, int teamID)
turretComponent->ShotTemplate = m_ShotTemplate;
turretComponent->ShotSpeed = 40.f;
auto debrisComponent = AddComponent<Components::TowerDebris>(towerBase);
debrisComponent->TowerDebrisIDs = m_TowerDebrisTemplates;
CommitEntity(towerBase);
return towerBase;
@@ -1330,7 +1378,7 @@ void GameWorld::CreateBase(glm::quat orientation, int teamID)
CreateWall(base, glm::vec3(273.f, 40.3f, -15.f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)));
CreateWall(base, glm::vec3(273.f, 40.3f, 15.f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)));
CreateWall(base, glm::vec3(273.f, 40.3f, 25.f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)));
CreateTower(base, glm::vec3(290.f, 40.3f, 15.f), teamID);
//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)));
@@ -1363,6 +1411,13 @@ void GameWorld::CreateBase(glm::quat orientation, int teamID)
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)));
CreateTower(base, glm::vec3(273.01227f, 40.43885f, 32.99123f), teamID);
CreateTower(base, glm::vec3(273.01227f, 40.30102f, -62.82098f), teamID);
CreateTower(base, glm::vec3(357.36978f, 40.43885f, -62.82098f), teamID);
CreateTower(base, glm::vec3(357.36978f, 40.43885f, 32.99123f), teamID);
CreateTower(base, glm::vec3(119.64996f, 28.90156f, 16.63123f), teamID);
CreateTower(base, glm::vec3(119.05541f, 29.54314f, 18.33529f), teamID);
CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)), teamID);
CreateFlag(base, glm::vec3(291.f, 41.7412f, -36.2f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)), teamID);
+1
View File
@@ -94,6 +94,7 @@ private:
void CreateBase(glm::quat orientation, int playerID);
void CreateFlag(EntityID parent, glm::vec3 position, glm::quat orientation, int TeamID);
std::vector<EntityID> m_WallDebrisTemplates;
std::vector<EntityID> m_TowerDebrisTemplates;
EntityID m_ShotTemplate;
};
+56 -1
View File
@@ -7,12 +7,15 @@ void Systems::TowerSystem::RegisterComponents( ComponentFactory* cf )
cf->Register<Components::Tower>([]() { return new Components::Tower(); });
cf->Register<Components::Turret>([]() { return new Components::Turret(); });
cf->Register<Components::TurretShot>([]() {return new Components::TurretShot(); });
cf->Register<Components::TowerDebris>([]() {return new Components::TowerDebris(); });
}
void Systems::TowerSystem::Initialize()
{
//EVENT_SUBSCRIBE_MEMBER(m_eDamage, &Systems::TowerSystem::Damage);
EVENT_SUBSCRIBE_MEMBER(m_ECollision, &Systems::TowerSystem::OnCollision);
EVENT_SUBSCRIBE_MEMBER(m_eDamage, &Systems::TowerSystem::Damage);
Temp_m_TimeSinceLastShot = 0;
}
@@ -21,6 +24,58 @@ void Systems::TowerSystem::Update( double dt )
}
bool Systems::TowerSystem::Damage( const Events::Damage &event )
{
auto debrisComponent = m_World->GetComponent<Components::TowerDebris>(event.Entity);
if(!debrisComponent)
{
return false;
}
LOG_INFO("TowerSystem::Damage");
// Change to damage model
auto wallhealthcomponent = m_World->GetComponent<Components::Health>(event.Entity);
if(wallhealthcomponent->Amount > 0)
{
return false;
}
LOG_INFO("Entity %i is dead", event.Entity);
auto entitytransform = m_World->GetComponent<Components::Transform>(event.Entity);
if(!entitytransform)
return false;
//auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
Components::Transform transformComponent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(event.Entity);
// Spawn debris
for(auto d : debrisComponent->TowerDebrisIDs)
{
auto debris = m_World->CloneEntity(d);
auto transform = m_World->GetComponent<Components::Transform>(debris);
Components::Transform absolutetransformComponent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(debris);
transform->Orientation = transform->Orientation * transformComponent.Orientation;
transform->Position = transform->Orientation * transform->Position + transformComponent.Position;
//DO STUFF! :D
float distance = glm::distance(transform->Position, transformComponent.Position);
float radius = 15.f;
float strength = (1.f - pow(distance / radius, 2)) * 2000.f;
glm::vec3 direction = glm::normalize(transformComponent.Position - transform->Position);
Events::ApplyPointImpulse e;
e.Entity = debris;
e.Impulse = direction * strength;
e.Position = transformComponent.Position;
EventBroker->Publish(e);
}
entitytransform->Position = glm::vec3(0.f, -50000000.f, 0.f);
return true;
}
void Systems::TowerSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
{
auto towerComponent = m_World->GetComponent<Components::Tower>(entity);
@@ -48,7 +103,7 @@ void Systems::TowerSystem::UpdateEntity( double dt, EntityID entity, EntityID pa
for(auto player : *players)
{
auto playerComponent = std::dynamic_pointer_cast<Components::Player>(player);
if(towerComponent->ID != playerComponent->ID) //!= betyder att den bara targetar sitt eget lag, == fienden.
if(towerComponent->ID == playerComponent->ID) //!= betyder att den bara targetar sitt eget lag, == fienden.
continue;
auto playerTransform = m_World->GetComponent<Components::Transform>(player->Entity);
+6
View File
@@ -9,10 +9,14 @@
#include "Components/Turret.h"
#include "Components/TurretShot.h"
#include "Components/Health.h"
#include "Components/TowerDebris.h"
#include "Components/Model.h"
#include "Events/SetVelocity.h"
#include "Events/CreateExplosion.h"
#include "Events/Collision.h"
#include "Events/Damage.h"
#include "Events/ApplyPointImpulse.h"
@@ -37,6 +41,8 @@ namespace Systems
EventRelay<TowerSystem, Events::Collision> m_ECollision;
bool OnCollision(const Events::Collision &e);
EventRelay<TowerSystem, Events::Damage> m_eDamage;
bool Damage(const Events::Damage &event);
private: