Some new events and changes to ScoreSystem
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#ifndef Events_PlayerConnected
|
||||
#define Events_PlayerConnected
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct PlayerConnected : public Event
|
||||
{
|
||||
std::string PlayerName = "";
|
||||
int PlayerID = -1;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // !Events_PlayerConnected
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Core/EEntityDeleted.h"
|
||||
#include "Core/EComponentDeleted.h"
|
||||
#include "Core/EAmmoPickup.h"
|
||||
#include "Network/EPlayerConnected.h"
|
||||
|
||||
class Server : public Network
|
||||
{
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
#define ScoreScreenSystem_h__
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EPlayerDeath.h"
|
||||
#include "Core/EPlayerSpawned.h"
|
||||
#include "Network/EPlayerConnected.h"
|
||||
#include "Network/EPlayerDisconnected.h"
|
||||
#include "GLM.h"
|
||||
|
||||
class ScoreScreenSystem : public PureSystem
|
||||
@@ -17,6 +21,10 @@ public:
|
||||
bool OnPlayerDeath(const Events::PlayerDeath& e);
|
||||
EventRelay<ScoreScreenSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawn(const Events::PlayerSpawned& e);
|
||||
EventRelay<ScoreScreenSystem, Events::PlayerConnected> m_EPlayerConnected;
|
||||
bool OnPlayerConnected(const Events::PlayerConnected& e);
|
||||
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
|
||||
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
|
||||
|
||||
private:
|
||||
struct PlayerData {
|
||||
|
||||
@@ -3,24 +3,30 @@
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
<xs:element name="ScoreIdentity">
|
||||
<xs:annotation><xs:documentation>A component tracking data for the score of a player.</xs:documentation></xs:annotation>
|
||||
<xs:element name="Name" type="t:string" minOccurs="0"/>
|
||||
<xs:element name="ID" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>A unique id for tracking identities</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="KD" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The Kills per death score.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Kills" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The amount of kills.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Deaths" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The amount of deaths.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Ping" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Ping of a player.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Connected" type="t:Bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>If the player is currently connected or not</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="Name" type="t:string" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>A name for tracking score identities, this should be unique.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="ID" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>An id for tracking identities</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="KD" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The Kills per death score.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Kills" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The amount of kills.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Deaths" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The amount of deaths.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Ping" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Ping of a player.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Connected" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>If the player is currently connected or not</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -3,11 +3,15 @@
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
<xs:element name="ScoreScreen">
|
||||
<xs:annotation><xs:documentation>The screen where player scores will be shown.</xs:documentation></xs:annotation>
|
||||
<xs:element name="TotalIdentities" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The amount of score identities this scoreboard hold</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="NextPosition" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Where the next scoreIdentity should be placed.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="TotalIdentities" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The amount of score identities this scoreboard hold</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="NextPosition" type="t:int" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Where the next scoreIdentity should be placed.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
+1052
-1053
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity name="ScoreIdentity" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:ScoreIdentity>
|
||||
<Name></Name>
|
||||
</c:ScoreIdentity>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity name="Simonplzpush">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>Simon needs to push shit shit so i can write text from Component</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="2.09157753" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="ID">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>ID</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="-9.66245842" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Name">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>DickButt</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="-5.08430147" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Kills">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>5</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="-1.23991621" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Deaths">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>12</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="1.3544426" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="KD">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>0.42</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="4.43798256" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Ping">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>84</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="8.05187988" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
@@ -363,6 +363,11 @@ void Server::parseTCPConnect(Packet & packet)
|
||||
m_ConnectedPlayers.at(playerID).TCPAddress = m_Address;
|
||||
m_ConnectedPlayers.at(playerID).TCPPort = m_Port;
|
||||
|
||||
Events::PlayerConnected e;
|
||||
e.PlayerID = playerID;
|
||||
e.PlayerName = m_ConnectedPlayers.at(playerID).Name;
|
||||
m_EventBroker->Publish(e);
|
||||
|
||||
LOG_INFO("parseTCPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(),
|
||||
m_ConnectedPlayers.at(playerID).TCPAddress.to_string().c_str());
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "Game/Systems/KillFeedSystem.h"
|
||||
#include "Game/Systems/BoostSystem.h"
|
||||
#include "Game/Systems/BoostIconsHUDSystem.h"
|
||||
#include "Game/Systems/ScoreScreenSystem.h"
|
||||
#include "GUI/ButtonSystem.h"
|
||||
#include "GUI/MainMenuSystem.h"
|
||||
|
||||
@@ -151,6 +152,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
|
||||
m_SystemPipeline->AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer);
|
||||
m_SystemPipeline->AddSystem<BoostIconsHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<ScoreScreenSystem>(updateOrderLevel);
|
||||
// Populate Octree with collidables
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||
|
||||
@@ -7,11 +7,14 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &ScoreScreenSystem::OnPlayerDeath);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
|
||||
}
|
||||
|
||||
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt)
|
||||
{
|
||||
if(!entity.Valid() || !entity.HasComponent("ScoreScreen")){
|
||||
//TODO: Check team al
|
||||
if(!entity.HasComponent("ScoreScreen")){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,7 +31,20 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper&
|
||||
}
|
||||
if(found == false) {
|
||||
//There is no entry for this player, create one.
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/ScoreIdentity.xml");
|
||||
EntityWrapper scoreIdentity = entityFile->MergeInto(m_World);
|
||||
auto cScoreIdentity = scoreIdentity["ScoreIdentity"];
|
||||
auto data = it->second;
|
||||
std::printf("\n\n");
|
||||
std::printf(data.Name.c_str());
|
||||
std::printf("\n\n");
|
||||
|
||||
(std::string&)cScoreIdentity["Name"] = data.Name;
|
||||
(int&)cScoreIdentity["ID"] = data.ID;
|
||||
(int&)cScoreIdentity["Ping"] = 1337;
|
||||
|
||||
m_World->SetName(scoreIdentity.ID, data.Name);
|
||||
m_World->SetParent(scoreIdentity.ID, entity.ID);
|
||||
}
|
||||
}
|
||||
//For each scoreboard, go through children and see if they have all of the ones needed.
|
||||
@@ -37,16 +53,17 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper&
|
||||
//Just add a new component to the scorescreen entity, the "ScoreIdentity" component.
|
||||
}
|
||||
|
||||
void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e)
|
||||
bool ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e)
|
||||
{
|
||||
//When player die, add it to his score, and when possible the player who killed him.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
|
||||
bool ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
|
||||
{
|
||||
//When a player spawn, add a new entry to the score screen.
|
||||
if(!e.Player.Valid()) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
EntityWrapper entity = e.Player;
|
||||
|
||||
@@ -58,7 +75,7 @@ void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
|
||||
data.Name = e.PlayerName;
|
||||
data.Player = e.Player;
|
||||
if(!entity.HasComponent("Team")) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
data.Team = (int)entity["Team"]["Team"];
|
||||
|
||||
@@ -66,5 +83,15 @@ void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
|
||||
m_PlayerIdentities.insert(list);
|
||||
m_PlayerCounter++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ScoreScreenSystem::OnPlayerConnected(const Events::PlayerConnected& e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user