Shots need more work
This commit is contained in:
@@ -31,6 +31,7 @@ void Systems::PhysicsSystem::Initialize()
|
||||
|
||||
// Events
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETankSteer, &Systems::PhysicsSystem::OnTankSteer);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETankSteer, &Systems::PhysicsSystem::OnSetVelocity);
|
||||
|
||||
hkMemorySystem::FrameInfo finfo(6000 * 1024); // Allocate 6MB of Physics solver buffer
|
||||
hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault(hkMallocAllocator::m_defaultMallocAllocator, finfo);
|
||||
@@ -579,3 +580,8 @@ bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Components/WheelPair.h"
|
||||
#include "Components/TowerSteering.h"
|
||||
#include "Events/TankSteer.h"
|
||||
#include "Events/SetVelocity.h"
|
||||
#include "OBJ.h"
|
||||
|
||||
// Math and base include
|
||||
@@ -85,6 +86,9 @@ private:
|
||||
EventRelay<Events::TankSteer> m_ETankSteer;
|
||||
bool OnTankSteer(const Events::TankSteer &event);
|
||||
|
||||
EventRelay<Events::SetVelocity> m_ESetVelocity;
|
||||
bool OnSetVelocity(const Events::SetVelocity &event);
|
||||
|
||||
void SetUpPhysicsState(EntityID entity, EntityID parent);
|
||||
void TearDownPhysicsState(EntityID entity, EntityID parent);
|
||||
|
||||
|
||||
@@ -49,6 +49,19 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
||||
glm::quat orientation = glm::angleAxis(barrelSteeringComponent->Velocity * m_TowerInputController->BarrelDirection * (float)dt, barrelSteeringComponent->Axis);
|
||||
transformComponent->Orientation *= orientation;
|
||||
}
|
||||
|
||||
auto shotComponent = m_World->GetComponent<Components::Shot>(entity, "Shot");
|
||||
if(shotComponent)
|
||||
{
|
||||
if(m_TowerInputController->shoot)
|
||||
{
|
||||
auto absoluteOrientation = m_World->GetSystem<Systems::TransformSystem>("TransformSystem")->AbsoluteOrientation(entity);
|
||||
Events::SetVelocity e;
|
||||
e.Entity = entity;
|
||||
e.Velocity = absoluteOrientation * (glm::vec3(0.f, 0.f, 1.f) * shotComponent->Speed * (float)dt);
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Systems::TankSteeringSystem::TankSteeringInputController::Update( double dt )
|
||||
@@ -61,6 +74,7 @@ void Systems::TankSteeringSystem::TowerSteeringInputController::Update( double d
|
||||
{
|
||||
TowerDirection = m_TowerDirection;
|
||||
BarrelDirection = m_BarrelDirection;
|
||||
shoot = m_Shoot;
|
||||
}
|
||||
|
||||
bool Systems::TankSteeringSystem::TankSteeringInputController::OnCommand(const Events::InputCommand &event)
|
||||
@@ -94,6 +108,11 @@ bool Systems::TankSteeringSystem::TowerSteeringInputController::OnCommand( const
|
||||
{
|
||||
m_BarrelDirection = val;
|
||||
}
|
||||
|
||||
else if (event.Command == "shoot")
|
||||
{
|
||||
shoot = (bool)val;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
#include "System.h"
|
||||
#include "Events/TankSteer.h"
|
||||
#include "Events/SetVelocity.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/TankSteering.h"
|
||||
#include "Components/TowerSteering.h"
|
||||
#include "Components/BarrelSteering.h"
|
||||
#include "Components/Vehicle.h"
|
||||
#include "Components/Shot.h"
|
||||
#include "Systems/TransformSystem.h"
|
||||
#include "InputController.h"
|
||||
|
||||
namespace Systems
|
||||
@@ -67,10 +70,13 @@ namespace Systems
|
||||
m_BarrelDirection = 0.f;
|
||||
TowerDirection = 0.f;
|
||||
BarrelDirection = 0.f;
|
||||
|
||||
m_Shoot = false;
|
||||
}
|
||||
|
||||
float TowerDirection;
|
||||
float BarrelDirection;
|
||||
bool shoot;
|
||||
void Update(double dt);
|
||||
protected:
|
||||
virtual bool OnCommand(const Events::InputCommand &event);
|
||||
@@ -78,7 +84,8 @@ namespace Systems
|
||||
|
||||
private:
|
||||
float m_TowerDirection;
|
||||
float m_BarrelDirection;
|
||||
float m_BarrelDirection;
|
||||
bool m_Shoot;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user