experimental fix for pickup
This commit is contained in:
@@ -192,6 +192,8 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
|
||||
|
||||
template <typename EventContext>
|
||||
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
||||
ImGui::Text(std::to_string(m_AssaultDashCoolDownTimer).c_str());
|
||||
|
||||
m_AssaultDashDoubleTapDeltaTime += dt;
|
||||
m_AssaultDashCoolDownTimer -= dt;
|
||||
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
private:
|
||||
EventRelay<AmmoPickupSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||
bool OnTriggerTouch(Events::TriggerTouch& e);
|
||||
EventRelay<AmmoPickupSystem, Events::TriggerLeave> m_ETriggerLeave;
|
||||
bool OnTriggerLeave(Events::TriggerLeave& e);
|
||||
|
||||
struct NewAmmoPickup {
|
||||
glm::vec3 Pos;
|
||||
@@ -28,6 +30,13 @@ private:
|
||||
double DecreaseThisRespawnTimer;
|
||||
EntityID parentID;
|
||||
};
|
||||
struct EntityAtMaxValuePickupStruct {
|
||||
EntityWrapper player;
|
||||
EntityWrapper pickup;
|
||||
};
|
||||
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
||||
std::vector<EntityAtMaxValuePickupStruct> m_AmmoPickupAtMaxHealthAmmo;
|
||||
|
||||
void DoPickup(EntityWrapper &player, EntityWrapper &trigger);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -215,7 +215,8 @@
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<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:Team>
|
||||
<Team>
|
||||
@@ -241,7 +242,8 @@
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<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:Team>
|
||||
<Team>
|
||||
@@ -256,6 +258,25 @@
|
||||
</Components>
|
||||
<Children/>
|
||||
</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>
|
||||
|
||||
</Entity>
|
||||
|
||||
@@ -4,6 +4,7 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &AmmoPickupSystem::OnTriggerLeave);
|
||||
}
|
||||
|
||||
void AmmoPickupSystem::Update(double dt)
|
||||
@@ -36,6 +37,18 @@ void AmmoPickupSystem::Update(double dt)
|
||||
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& 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
|
||||
if (currentAmmo >= maxWeaponAmmo) {
|
||||
m_AmmoPickupAtMaxHealthAmmo.push_back({ e.Entity, e.Trigger });
|
||||
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;
|
||||
ePlayerAmmoPickup.AmmoGain = ammoGiven;
|
||||
ePlayerAmmoPickup.Player = e.Entity;
|
||||
ePlayerAmmoPickup.Player = player;
|
||||
m_EventBroker->Publish(ePlayerAmmoPickup);
|
||||
//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)
|
||||
//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"],
|
||||
e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
||||
m_ETriggerTouchVector.push_back({ trigger["Transform"]["Position"], gain,
|
||||
pickup["RespawnTimer"], pickup["RespawnTimer"], m_World->GetParent(trigger.ID) });
|
||||
|
||||
//delete the ammopickup
|
||||
m_World->DeleteEntity(e.Trigger.ID);
|
||||
return true;
|
||||
m_World->DeleteEntity(trigger.ID);
|
||||
}
|
||||
|
||||
@@ -208,12 +208,12 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||
void PlayerSpawnSystem::CheckForLatePlayers(double dt) {
|
||||
for (size_t i = 0; i < m_LatePlayersVector.size(); i++)
|
||||
{
|
||||
auto& req = m_SpawnRequests[i];
|
||||
auto& req = m_LatePlayersVector[i];
|
||||
req.timeSinceDeath += dt;
|
||||
if (req.timeSinceDeath > 2.5f) {
|
||||
//good but, this will only spawn them in the next cycle - i.e. not immediately
|
||||
//m_SpawnRequests.push_back(spawnReq);
|
||||
|
||||
|
||||
//insta spawn
|
||||
auto playerSpawns = m_World->GetComponents("PlayerSpawn");
|
||||
for (auto& cPlayerSpawn : *playerSpawns) {
|
||||
|
||||
Reference in New Issue
Block a user