Merge branch 'master' of https://github.com/teamfisk/TacticalZ
This commit is contained in:
@@ -12,7 +12,8 @@ namespace Events
|
||||
struct Captured : Event
|
||||
{
|
||||
int TeamNumberThatCapturedCapturePoint;
|
||||
EntityID CapturePointID;
|
||||
EntityID CapturePointTakenID;
|
||||
EntityWrapper NextCapturePoint;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -104,6 +104,11 @@ protected:
|
||||
if (!m_Enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (io.WantCaptureMouse || io.WantCaptureKeyboard) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_SpeedMultiplier += e.DeltaY * (0.1 * m_SpeedMultiplier);
|
||||
m_Config->Set("Editor.CameraSpeed", m_SpeedMultiplier);
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
virtual bool OnCommand(const Events::InputCommand& e) override;
|
||||
virtual void Reset();
|
||||
|
||||
void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer);
|
||||
void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer);
|
||||
virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; }
|
||||
virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; }
|
||||
|
||||
@@ -41,7 +41,6 @@ protected:
|
||||
bool m_Crouching = false;
|
||||
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
||||
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
||||
double m_AssaultDashCoolDownTimer = 0.0;
|
||||
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
|
||||
//and its very unlikely that someone wants to change that value
|
||||
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
|
||||
@@ -191,21 +190,21 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
|
||||
}
|
||||
|
||||
template <typename EventContext>
|
||||
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
||||
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer) {
|
||||
m_AssaultDashDoubleTapDeltaTime += dt;
|
||||
m_AssaultDashCoolDownTimer -= dt;
|
||||
assaultDashCoolDownTimer -= dt;
|
||||
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
||||
if (m_AssaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) {
|
||||
if (assaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) {
|
||||
m_PlayerIsDashing = true;
|
||||
} else {
|
||||
m_PlayerIsDashing = false;
|
||||
}
|
||||
|
||||
//dashing with shift
|
||||
if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f) {
|
||||
if (m_ShiftDashing && assaultDashCoolDownTimer <= 0.0f) {
|
||||
//player is dashing with shift
|
||||
//the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in!
|
||||
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||
assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||
m_AssaultDashDoubleTapped = true;
|
||||
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||
return;
|
||||
@@ -227,7 +226,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
||||
}
|
||||
m_ValidDoubleTap = false;
|
||||
|
||||
if (!(m_AssaultDashCoolDownTimer <= 0.0f)) {
|
||||
if (!(assaultDashCoolDownTimer <= 0.0f)) {
|
||||
//if we cant dash at the moment, then just reset the tap-sensitivity-timer
|
||||
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||
return;
|
||||
@@ -235,7 +234,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
||||
//ok, we have a valid tap, lets do it
|
||||
m_AssaultDashDoubleTapped = true;
|
||||
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||
assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||
|
||||
Events::DashAbility e;
|
||||
m_EventBroker->Publish(e);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Network/EInterpolate.h"
|
||||
#include "Network/SnapshotFilter.h"
|
||||
#include "Core/EPlayerSpawned.h"
|
||||
#include "Core/EAmmoPickup.h"
|
||||
#include "Network/ESearchForServers.h"
|
||||
|
||||
struct ServerInfo
|
||||
@@ -106,7 +107,8 @@ private:
|
||||
void parsePlayerDamage(Packet& packet);
|
||||
void parseComponentDeletion(Packet& packet);
|
||||
void parseDoubleJump(Packet& packet);
|
||||
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||
void parseAmmoPickup(Packet& packet);
|
||||
void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||
void parseSnapshot(Packet& packet);
|
||||
void identifyPacketLoss();
|
||||
void hasServerTimedOut();
|
||||
|
||||
@@ -21,6 +21,7 @@ enum class MessageType
|
||||
PlayerTransform,
|
||||
OnDoubleJump,
|
||||
ServerlistRequest,
|
||||
AmmoPickup,
|
||||
Invalid
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "../Game/Events/EDoubleJump.h"
|
||||
#include "Core/EEntityDeleted.h"
|
||||
#include "Core/EComponentDeleted.h"
|
||||
#include "Core/EAmmoPickup.h"
|
||||
|
||||
class Server : public Network
|
||||
{
|
||||
@@ -88,7 +89,7 @@ private:
|
||||
void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint);
|
||||
bool shouldSendToClient(EntityWrapper childEntity);
|
||||
|
||||
// Debug event
|
||||
// Events
|
||||
EventRelay<Server, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
EventRelay<Server, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
@@ -99,6 +100,8 @@ private:
|
||||
bool OnComponentDeleted(const Events::ComponentDeleted& e);
|
||||
EventRelay<Server, Events::PlayerDamage> m_EPlayerDamage;
|
||||
bool OnPlayerDamage(const Events::PlayerDamage& e);
|
||||
EventRelay<Server, Events::AmmoPickup> m_EAmmoPickup;
|
||||
bool OnAmmoPickup(const Events::AmmoPickup& e);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
private:
|
||||
EventRelay<AmmoPickupSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||
bool OnTriggerTouch(Events::TriggerTouch& e);
|
||||
EventRelay<AmmoPickupSystem, Events::AmmoPickup> m_EAmmoPickup;
|
||||
bool OnAmmoPickup(Events::AmmoPickup& e);
|
||||
|
||||
struct NewAmmoPickup {
|
||||
glm::vec3 Pos;
|
||||
|
||||
@@ -42,9 +42,9 @@ private:
|
||||
int m_NumberOfCapturePoints = 0;
|
||||
std::map<int, EntityWrapper> m_CapturePointNumberToEntityMap;
|
||||
|
||||
//std::vector<ComponentWrapper>
|
||||
|
||||
bool m_ResetTimers = false;
|
||||
bool m_RecentlyCapturedNeedNextCapturePointNow = false;
|
||||
Events::Captured m_CapturedEvent;
|
||||
|
||||
//vectors which will keep track of enter/leave changes
|
||||
std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerTouchVector;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<DashAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DashAbility.xsd">
|
||||
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
|
||||
<CoolDownTimer>0.0</CoolDownTimer>
|
||||
</DashAbility>
|
||||
@@ -10,7 +10,10 @@
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>This is the cooldown on dash</xs:documentation></xs:annotation>
|
||||
<xs:annotation><xs:documentation>This is the max cooldown on dash</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="CoolDownTimer" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>This is the current cooldown on dash</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
|
||||
@@ -101,8 +101,7 @@ void Client::Update()
|
||||
|
||||
void Client::parseMessageType(Packet& packet)
|
||||
{
|
||||
// Pop packetSize which is used by TCP Client to
|
||||
// create a packet of the correct size
|
||||
// Pop packetSize
|
||||
packet.ReadPrimitive<int>();
|
||||
int messageType = packet.ReadPrimitive<int>();
|
||||
if (messageType == -1)
|
||||
@@ -144,6 +143,9 @@ void Client::parseMessageType(Packet& packet)
|
||||
case MessageType::OnDoubleJump:
|
||||
parseDoubleJump(packet);
|
||||
break;
|
||||
case MessageType::AmmoPickup:
|
||||
parseAmmoPickup(packet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -233,7 +235,6 @@ void Client::parseSpawnEvents()
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
m_PlayerSpawnEvents = tempSpawn;
|
||||
// m_PlayerSpawnEvents.clear();
|
||||
}
|
||||
|
||||
void Client::parsePlayersSpawned(Packet& packet)
|
||||
@@ -296,6 +297,14 @@ void Client::parseDoubleJump(Packet & packet)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::parseAmmoPickup(Packet & packet)
|
||||
{
|
||||
Events::AmmoPickup e;
|
||||
e.AmmoGain = packet.ReadPrimitive<int>();
|
||||
e.Player = m_LocalPlayer;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
||||
{
|
||||
for (auto field : componentInfo.FieldsInOrder) {
|
||||
|
||||
@@ -13,7 +13,7 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &Server::OnEntityDeleted);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EComponentDeleted, &Server::OnComponentDeleted);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup);
|
||||
// BindWW
|
||||
if (port == 0) {
|
||||
port = config->Get<float>("Networking.Port", 27666);
|
||||
@@ -510,6 +510,19 @@ bool Server::OnPlayerDamage(const Events::PlayerDamage& e)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Server::OnAmmoPickup(const Events::AmmoPickup & e)
|
||||
{
|
||||
for (auto& kv : m_ConnectedPlayers) {
|
||||
if (e.Player.ID == kv.second.EntityID) {
|
||||
Packet packet(MessageType::AmmoPickup);
|
||||
// We dont send playerID as it will be set at client to local
|
||||
packet.WritePrimitive(e.AmmoGain);
|
||||
m_Reliable.Send(packet, kv.second);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Server::parseClientPing()
|
||||
{
|
||||
LOG_INFO("%i: Parsing ping", m_PacketID);
|
||||
@@ -604,12 +617,14 @@ bool Server::shouldSendToClient(EntityWrapper childEntity)
|
||||
auto children = m_World->GetDirectChildren(childEntity.ID);
|
||||
for (auto it = children.first; it != children.second; it++) {
|
||||
EntityWrapper child(m_World, it->second);
|
||||
if(child.HasComponent("CapturePoint")) {
|
||||
if (child.HasComponent("CapturePoint") || child.HasComponent("HealthPickup")
|
||||
|| child.HasComponent("AmmoPickup")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|
||||
|| childEntity.HasComponent("CapturePoint");
|
||||
|| childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup")
|
||||
|| childEntity.HasComponent("AmmoPickup");
|
||||
}
|
||||
|
||||
PlayerID Server::GetPlayerIDFromEndpoint()
|
||||
|
||||
@@ -3,37 +3,43 @@
|
||||
AmmoPickupSystem::AmmoPickupSystem(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
|
||||
if (IsServer) {
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
|
||||
}
|
||||
if (IsClient) {
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &AmmoPickupSystem::OnAmmoPickup);
|
||||
}
|
||||
}
|
||||
|
||||
void AmmoPickupSystem::Update(double dt)
|
||||
{
|
||||
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 entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/AmmoPickup.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID ammoPickupID = parser.MergeEntities(m_World);
|
||||
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 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)
|
||||
Events::PickupSpawned ePickupSpawned;
|
||||
ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID);
|
||||
m_EventBroker->Publish(ePickupSpawned);
|
||||
//let the world know a pickup has spawned (graphics effects, etc)
|
||||
Events::PickupSpawned ePickupSpawned;
|
||||
ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID);
|
||||
m_EventBroker->Publish(ePickupSpawned);
|
||||
|
||||
//set 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);
|
||||
//set 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);
|
||||
|
||||
//erase the current element (AmmoPickupPosition)
|
||||
m_ETriggerTouchVector.erase(it);
|
||||
break;
|
||||
//erase the current element (AmmoPickupPosition)
|
||||
m_ETriggerTouchVector.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +47,11 @@ void AmmoPickupSystem::Update(double dt)
|
||||
|
||||
bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
||||
{
|
||||
if (e.Entity != LocalPlayer) {
|
||||
/*if (e.Entity != LocalPlayer) {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
if (!e.Entity.Valid()) {
|
||||
return false;
|
||||
}
|
||||
//TODO: add other weapontypes
|
||||
@@ -66,7 +76,7 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
||||
ePlayerAmmoPickup.Player = e.Entity;
|
||||
m_EventBroker->Publish(ePlayerAmmoPickup);
|
||||
//immediately give the player the ammo
|
||||
currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo);
|
||||
//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
|
||||
@@ -77,3 +87,23 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
||||
m_World->DeleteEntity(e.Trigger.ID);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AmmoPickupSystem::OnAmmoPickup(Events::AmmoPickup & e)
|
||||
{
|
||||
if (!e.Player.Valid()) {
|
||||
return false;
|
||||
}
|
||||
//TODO: add other weapontypes
|
||||
if (!e.Player.HasComponent("AssaultWeapon")) {
|
||||
return false;
|
||||
}
|
||||
int maxWeaponAmmo = (int)e.Player["AssaultWeapon"]["MaxAmmo"];
|
||||
int& currentAmmo = (int)e.Player["AssaultWeapon"]["Ammo"];
|
||||
//cant pick up ammopacks if you are already at MaxAmmo
|
||||
if (currentAmmo >= maxWeaponAmmo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
currentAmmo = std::min(currentAmmo + e.AmmoGain, maxWeaponAmmo);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||
, PureSystem("CapturePoint")
|
||||
{
|
||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||
if (!IsClient) {
|
||||
if (IsServer) {
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||
@@ -18,7 +18,7 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
||||
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
||||
{
|
||||
if (IsClient) {
|
||||
if (!IsServer) {
|
||||
return;
|
||||
}
|
||||
if (m_WinnerWasFound) {
|
||||
@@ -102,6 +102,13 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
nextPossibleCapturePoint["Blue"] = i - 1;
|
||||
}
|
||||
}
|
||||
if (m_RecentlyCapturedNeedNextCapturePointNow) {
|
||||
m_CapturedEvent.NextCapturePoint = m_CapturedEvent.TeamNumberThatCapturedCapturePoint == blueTeam ?
|
||||
m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]] :
|
||||
m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]];
|
||||
m_EventBroker->Publish(m_CapturedEvent);
|
||||
m_RecentlyCapturedNeedNextCapturePointNow = false;
|
||||
}
|
||||
|
||||
//reset timers and reset the bool that triggers this
|
||||
if (m_ResetTimers) {
|
||||
@@ -188,10 +195,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
teamComponent["Team"] = currentTeam;
|
||||
cCapturePoint["CaptureTimer"] = glm::sign((double)cCapturePoint["CaptureTimer"])*captureTimeToTakeOver;
|
||||
//publish Captured event
|
||||
Events::Captured e;
|
||||
e.CapturePointID = cCapturePoint.EntityID;
|
||||
e.TeamNumberThatCapturedCapturePoint = currentTeam;
|
||||
m_EventBroker->Publish(e);
|
||||
m_RecentlyCapturedNeedNextCapturePointNow = true;
|
||||
m_CapturedEvent.CapturePointTakenID = cCapturePoint.EntityID;
|
||||
m_CapturedEvent.TeamNumberThatCapturedCapturePoint = currentTeam;
|
||||
//NextPossibleCapturePoint will be calculated in the next update...
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,37 +3,40 @@
|
||||
PickupSpawnSystem::PickupSpawnSystem(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &PickupSpawnSystem::OnTriggerTouch);
|
||||
if (IsServer) {
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &PickupSpawnSystem::OnTriggerTouch);
|
||||
}
|
||||
}
|
||||
|
||||
void PickupSpawnSystem::Update(double dt)
|
||||
{
|
||||
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 entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/HealthPickup.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID healthPickupID = parser.MergeEntities(m_World);
|
||||
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 entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/HealthPickup.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID healthPickupID = parser.MergeEntities(m_World);
|
||||
|
||||
//let the world know a pickup has spawned (graphics effects, etc)
|
||||
Events::PickupSpawned ePickupSpawned;
|
||||
ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID);
|
||||
m_EventBroker->Publish(ePickupSpawned);
|
||||
//let the world know a pickup has spawned (graphics effects, etc)
|
||||
Events::PickupSpawned ePickupSpawned;
|
||||
ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID);
|
||||
m_EventBroker->Publish(ePickupSpawned);
|
||||
|
||||
//set 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);
|
||||
//set 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);
|
||||
|
||||
//erase the current element (healthPickupPosition)
|
||||
m_ETriggerTouchVector.erase(it);
|
||||
break;
|
||||
//erase the current element (healthPickupPosition)
|
||||
m_ETriggerTouchVector.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,8 +61,8 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
||||
|
||||
//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)e.Trigger["Transform"]["Position"], e.Trigger["HealthPickup"]["HealthGain"],
|
||||
e.Trigger["HealthPickup"]["RespawnTimer"], e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
||||
|
||||
//delete the healthpickup
|
||||
m_World->DeleteEntity(e.Trigger.ID);
|
||||
|
||||
@@ -48,7 +48,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||
if (playerModel.Valid()) {
|
||||
ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"];
|
||||
float pitch = cameraOrientation.x + 0.2;
|
||||
float pitch = cameraOrientation.x + 0.2f;
|
||||
double time = (pitch + glm::half_pi<float>()) / glm::pi<float>();
|
||||
cAnimationOffset["Time"] = time;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
ComponentWrapper cPhysics = player["Physics"];
|
||||
//Assault Dash Check
|
||||
if (player.HasComponent("DashAbility")) {
|
||||
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"]);
|
||||
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"]);
|
||||
}
|
||||
wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
|
||||
//this makes sure you can only dash in the 4 directions: forw,backw,left,right
|
||||
@@ -311,6 +311,7 @@ bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e)
|
||||
return false;
|
||||
}
|
||||
spawnHexagon(EntityWrapper(m_World, e.entityID));
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
||||
|
||||
@@ -94,7 +94,7 @@ bool SoundSystem::OnCaptured(const Events::Captured & e)
|
||||
if (!LocalPlayer.Valid()) {
|
||||
return false;
|
||||
}
|
||||
int homeTeam = (int)m_World->GetComponent(e.CapturePointID, "Team")["Team"];
|
||||
int homeTeam = (int)m_World->GetComponent(e.CapturePointTakenID, "Team")["Team"];
|
||||
int team = (int)m_World->GetComponent(LocalPlayer.ID, "Team")["Team"];
|
||||
Events::PlaySoundOnEntity ev;
|
||||
if (team == homeTeam) {
|
||||
|
||||
Reference in New Issue
Block a user