Added entity SpectatorCamera that shows respawntime, will activate when explosion effect is deleted.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "Core/EntityFileParser.h"
|
||||
|
||||
#include "Core/EPlayerDeath.h"
|
||||
#include "Core/EEntityDeleted.h"
|
||||
|
||||
class PlayerDeathSystem : public ImpureSystem
|
||||
{
|
||||
@@ -20,8 +21,12 @@ public:
|
||||
virtual void Update(double dt) override;
|
||||
|
||||
private:
|
||||
EntityWrapper m_LocalPlayerDeathEffect;
|
||||
|
||||
EventRelay<PlayerDeathSystem, Events::PlayerDeath> m_OnPlayerDeath;
|
||||
bool OnPlayerDeath(Events::PlayerDeath& e);
|
||||
EventRelay<PlayerDeathSystem, Events::EntityDeleted> m_EEntityDeleted;
|
||||
bool OnEntityDeleted(Events::EntityDeleted& e);
|
||||
|
||||
void createDeathEffect(EntityWrapper player);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity name="SpectatorCamera" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:Camera/>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity name="SpectatorHUD">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-0.5"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="RespawnTimer">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content></Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
<Color A="1" B="0" G="0" R="0"/>
|
||||
<Alignment>
|
||||
<Left/>
|
||||
</Alignment>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="-0.115000000" Y="-0.100000000" Z="0"/>
|
||||
<Scale X="0.0250000004" Y="0.0250000004" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
@@ -54,6 +54,7 @@
|
||||
<xs:element ref="c:DefenderWeapon" minOccurs="0"/>
|
||||
<xs:element ref="c:AmmoPickup" minOccurs="0"/>
|
||||
<xs:element ref="c:HealthPickup" minOccurs="0"/>
|
||||
<xs:element ref="c:CapturePointGameMode" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -4,6 +4,7 @@ PlayerDeathSystem::PlayerDeathSystem(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerDeathSystem::OnPlayerDeath);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &PlayerDeathSystem::OnEntityDeleted);
|
||||
}
|
||||
|
||||
void PlayerDeathSystem::Update(double dt)
|
||||
@@ -59,9 +60,32 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
||||
|
||||
//camera (with lifetime) behind the player
|
||||
if (player == LocalPlayer) {
|
||||
m_LocalPlayerDeathEffect = deathEffectEW;
|
||||
auto cam = deathEffectEW.FirstChildByName("Camera");
|
||||
Events::SetCamera eSetCamera;
|
||||
eSetCamera.CameraEntity = cam;
|
||||
m_EventBroker->Publish(eSetCamera);
|
||||
}
|
||||
}
|
||||
|
||||
bool PlayerDeathSystem::OnEntityDeleted(Events::EntityDeleted& e)
|
||||
{
|
||||
// We only care about when the local players death effect is removed.
|
||||
if (m_LocalPlayerDeathEffect.ID != e.DeletedEntity) {
|
||||
return false;
|
||||
}
|
||||
// Set the spectator camera as active, if it exists.
|
||||
auto pool = m_World->GetComponents("CapturePointGameMode");
|
||||
if (pool == nullptr || pool->size() == 0) {
|
||||
return false;
|
||||
}
|
||||
ComponentWrapper modeComponent = *pool->begin();
|
||||
EntityWrapper theLevel = EntityWrapper(m_LocalPlayerDeathEffect.World, modeComponent.EntityID);
|
||||
EntityWrapper spectatorCam = theLevel.FirstChildByName("SpectatorCamera");
|
||||
if (!spectatorCam.Valid() && spectatorCam.HasComponent("Camera")) {
|
||||
return false;
|
||||
}
|
||||
Events::SetCamera eSetCamera;
|
||||
eSetCamera.CameraEntity = spectatorCam;
|
||||
m_EventBroker->Publish(eSetCamera);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,18 @@ void PlayerSpawnSystem::Update(double dt)
|
||||
double& timer = (double&)modeComponent["RespawnTime"];
|
||||
timer += dt;
|
||||
double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"];
|
||||
EntityWrapper theLevel = EntityWrapper(m_World, modeComponent.EntityID);
|
||||
EntityWrapper spectatorCam = theLevel.FirstChildByName("SpectatorCamera");
|
||||
if (spectatorCam.Valid()) {
|
||||
EntityWrapper HUD = spectatorCam.FirstChildByName("SpectatorHUD");
|
||||
if (HUD.Valid()) {
|
||||
EntityWrapper respawnTimer = spectatorCam.FirstChildByName("RespawnTimer");
|
||||
if (respawnTimer.Valid()) {
|
||||
//Update respawn time in the HUD element.
|
||||
respawnTimer["Text"]["Content"] = "Time to respawn: " + std::to_string(1 + (int)(maxRespawnTime - timer));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (timer < maxRespawnTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user