Double jump is now working.
This commit is contained in:
@@ -4,6 +4,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPDoubleJump, &PlayerMovementSystem::OnDoubleJump);
|
||||
}
|
||||
|
||||
PlayerMovementSystem::~PlayerMovementSystem()
|
||||
@@ -28,7 +29,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
if (!player.Valid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Aim pitch
|
||||
EntityWrapper cameraEntity = player.FirstChildByName("Camera");
|
||||
if (cameraEntity.Valid()) {
|
||||
@@ -114,15 +114,14 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
if (isOnGround) {
|
||||
controller->SetDoubleJumping(false);
|
||||
} else {
|
||||
// If IsServer and network is off this will not work
|
||||
if (IsClient) {
|
||||
//put a hexagon at the players feet
|
||||
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityFileParser parser(hexagonEffect);
|
||||
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||
hexagonEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
|
||||
spawnHexagon(player);
|
||||
controller->SetDoubleJumping(true);
|
||||
// Publish event for client to listen to
|
||||
Events::DoubleJump e;
|
||||
e.entityID = player.ID;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
@@ -291,3 +290,26 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e)
|
||||
{
|
||||
// If entity does not exist, exit
|
||||
if (!EntityWrapper(m_World, e.entityID).Valid()) {
|
||||
return false;
|
||||
}
|
||||
// If entity IsLocalPlayer, exit
|
||||
if (e.entityID == m_LocalPlayer.ID) {
|
||||
return false;
|
||||
}
|
||||
spawnHexagon(EntityWrapper(m_World, e.entityID));
|
||||
}
|
||||
|
||||
void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
||||
{
|
||||
//put a hexagon at the entitys... feet?
|
||||
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityFileParser parser(hexagonEffect);
|
||||
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
|
||||
}
|
||||
Reference in New Issue
Block a user