experimental fix for pickup
This commit is contained in:
@@ -192,6 +192,8 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
|
|||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
||||||
|
ImGui::Text(std::to_string(m_AssaultDashCoolDownTimer).c_str());
|
||||||
|
|
||||||
m_AssaultDashDoubleTapDeltaTime += dt;
|
m_AssaultDashDoubleTapDeltaTime += dt;
|
||||||
m_AssaultDashCoolDownTimer -= dt;
|
m_AssaultDashCoolDownTimer -= dt;
|
||||||
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
EventRelay<AmmoPickupSystem, Events::TriggerTouch> m_ETriggerTouch;
|
EventRelay<AmmoPickupSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||||
bool OnTriggerTouch(Events::TriggerTouch& e);
|
bool OnTriggerTouch(Events::TriggerTouch& e);
|
||||||
|
EventRelay<AmmoPickupSystem, Events::TriggerLeave> m_ETriggerLeave;
|
||||||
|
bool OnTriggerLeave(Events::TriggerLeave& e);
|
||||||
|
|
||||||
struct NewAmmoPickup {
|
struct NewAmmoPickup {
|
||||||
glm::vec3 Pos;
|
glm::vec3 Pos;
|
||||||
@@ -28,6 +30,13 @@ private:
|
|||||||
double DecreaseThisRespawnTimer;
|
double DecreaseThisRespawnTimer;
|
||||||
EntityID parentID;
|
EntityID parentID;
|
||||||
};
|
};
|
||||||
|
struct EntityAtMaxValuePickupStruct {
|
||||||
|
EntityWrapper player;
|
||||||
|
EntityWrapper pickup;
|
||||||
|
};
|
||||||
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
||||||
|
std::vector<EntityAtMaxValuePickupStruct> m_AmmoPickupAtMaxHealthAmmo;
|
||||||
|
|
||||||
|
void DoPickup(EntityWrapper &player, EntityWrapper &trigger);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -215,7 +215,8 @@
|
|||||||
</c:CapturePoint>
|
</c:CapturePoint>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models\Core\UnitCube.mesh</Resource>
|
<Resource>Models\Core\UnitCube.mesh</Resource>
|
||||||
<Color A="1" B="1" G="0.200000003" R="0"/>
|
<Color A="0.300000012" B="1" G="0" R="0"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Team>
|
<c:Team>
|
||||||
<Team>
|
<Team>
|
||||||
@@ -241,7 +242,8 @@
|
|||||||
</c:CapturePoint>
|
</c:CapturePoint>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models\Core\UnitCube.mesh</Resource>
|
<Resource>Models\Core\UnitCube.mesh</Resource>
|
||||||
<Color A="1" B="1" G="1" R="0"/>
|
<Color A="0.300000012" B="0" G="0" R="1"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Team>
|
<c:Team>
|
||||||
<Team>
|
<Team>
|
||||||
@@ -256,6 +258,25 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AmmoPickup/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:RaptorCopter>
|
||||||
|
<Speed>8</Speed>
|
||||||
|
<Axis X="0" Y="0.100000001" Z="0"/>
|
||||||
|
</c:RaptorCopter>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.86800003" Z="0"/>
|
||||||
|
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
|
||||||
|
<Orientation X="0" Y="18741" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Trigger/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
|
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params)
|
|||||||
: System(params)
|
: System(params)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &AmmoPickupSystem::OnTriggerLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmmoPickupSystem::Update(double dt)
|
void AmmoPickupSystem::Update(double dt)
|
||||||
@@ -36,6 +37,18 @@ void AmmoPickupSystem::Update(double dt)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//still touching AmmoPickupAtMaxHealthAmmo?
|
||||||
|
for (auto& it = m_AmmoPickupAtMaxHealthAmmo.begin(); it != m_AmmoPickupAtMaxHealthAmmo.end(); ++it) {
|
||||||
|
if (!it->player.Valid() || !it->pickup.Valid()) {
|
||||||
|
m_AmmoPickupAtMaxHealthAmmo.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((int)it->player["AssaultWeapon"]["Ammo"] < (int)it->player["AssaultWeapon"]["MaxAmmo"]) {
|
||||||
|
DoPickup(it->player, it->pickup);
|
||||||
|
m_AmmoPickupAtMaxHealthAmmo.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -53,27 +66,50 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
|||||||
}
|
}
|
||||||
int maxWeaponAmmo = (int)e.Entity["AssaultWeapon"]["MaxAmmo"];
|
int maxWeaponAmmo = (int)e.Entity["AssaultWeapon"]["MaxAmmo"];
|
||||||
int& currentAmmo = (int)e.Entity["AssaultWeapon"]["Ammo"];
|
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
|
//cant pick up ammopacks if you are already at MaxAmmo
|
||||||
if (currentAmmo >= maxWeaponAmmo) {
|
if (currentAmmo >= maxWeaponAmmo) {
|
||||||
|
m_AmmoPickupAtMaxHealthAmmo.push_back({ e.Entity, e.Trigger });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
DoPickup(e.Entity, e.Trigger);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//personEntered = e.Entity, thingEntered = e.Trigger
|
bool AmmoPickupSystem::OnTriggerLeave(Events::TriggerLeave& e) {
|
||||||
|
//triggerleave erases possible AmmoPickupAtMaxHealthAmmo
|
||||||
|
for (auto& it = m_AmmoPickupAtMaxHealthAmmo.begin(); it != m_AmmoPickupAtMaxHealthAmmo.end(); ++it) {
|
||||||
|
if (it->pickup.ID == e.Trigger.ID && it->player.ID == e.Entity.ID) {
|
||||||
|
m_AmmoPickupAtMaxHealthAmmo.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) {
|
||||||
|
auto& weaponEntity = player["AssaultWeapon"];
|
||||||
|
auto& pickup = trigger["AmmoPickup"];
|
||||||
|
auto& gain = pickup["AmmoGain"];
|
||||||
|
int maxValue = (int)weaponEntity["MaxAmmo"];
|
||||||
|
int& currentValue = (int)weaponEntity["Ammo"];
|
||||||
|
|
||||||
|
//cant pick up if you are already at max
|
||||||
|
if (currentValue >= maxValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ammoGiven = 0.01*(double)gain * maxValue;
|
||||||
Events::AmmoPickup ePlayerAmmoPickup;
|
Events::AmmoPickup ePlayerAmmoPickup;
|
||||||
ePlayerAmmoPickup.AmmoGain = ammoGiven;
|
ePlayerAmmoPickup.AmmoGain = ammoGiven;
|
||||||
ePlayerAmmoPickup.Player = e.Entity;
|
ePlayerAmmoPickup.Player = player;
|
||||||
m_EventBroker->Publish(ePlayerAmmoPickup);
|
m_EventBroker->Publish(ePlayerAmmoPickup);
|
||||||
//immediately give the player the ammo
|
//immediately give the player the ammo
|
||||||
currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo);
|
currentValue = std::min(currentValue + ammoGiven, maxValue);
|
||||||
|
|
||||||
//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)
|
//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
|
//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"],
|
m_ETriggerTouchVector.push_back({ trigger["Transform"]["Position"], gain,
|
||||||
e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
pickup["RespawnTimer"], pickup["RespawnTimer"], m_World->GetParent(trigger.ID) });
|
||||||
|
|
||||||
//delete the ammopickup
|
//delete the ammopickup
|
||||||
m_World->DeleteEntity(e.Trigger.ID);
|
m_World->DeleteEntity(trigger.ID);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
|||||||
void PlayerSpawnSystem::CheckForLatePlayers(double dt) {
|
void PlayerSpawnSystem::CheckForLatePlayers(double dt) {
|
||||||
for (size_t i = 0; i < m_LatePlayersVector.size(); i++)
|
for (size_t i = 0; i < m_LatePlayersVector.size(); i++)
|
||||||
{
|
{
|
||||||
auto& req = m_SpawnRequests[i];
|
auto& req = m_LatePlayersVector[i];
|
||||||
req.timeSinceDeath += dt;
|
req.timeSinceDeath += dt;
|
||||||
if (req.timeSinceDeath > 2.5f) {
|
if (req.timeSinceDeath > 2.5f) {
|
||||||
//good but, this will only spawn them in the next cycle - i.e. not immediately
|
//good but, this will only spawn them in the next cycle - i.e. not immediately
|
||||||
|
|||||||
Reference in New Issue
Block a user