Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ea0f04b20 | |||
| ac20e41a5d | |||
| 4f99f6ef74 | |||
| d0a083a1e3 | |||
| d5f06fa8c2 | |||
| 8bb8ebbea3 | |||
| b7d88808e2 | |||
| f8f536802f | |||
| 60df30fa59 | |||
| c544f349fd | |||
| 0c1a2d3160 |
+1
-1
Submodule assets updated: bc6e7df04c...504752c949
@@ -1,5 +1,5 @@
|
|||||||
#ifndef ECaptured_h__
|
#ifndef Events_Captured_h__
|
||||||
#define ECaptured_h__
|
#define Events_Captured_h__
|
||||||
|
|
||||||
#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
#include "../Core/Entity.h"
|
#include "../Core/Entity.h"
|
||||||
|
|||||||
@@ -10,28 +10,32 @@
|
|||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
|
|
||||||
|
#include "Core/World.h"
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
|
#include "Core/EPlayerDeath.h"
|
||||||
|
#include "Core/EPlayerDamage.h"
|
||||||
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
#include "Core/EAmmoPickup.h"
|
||||||
|
#include "Game/Events/EDoubleJump.h"
|
||||||
|
#include "Game/Events/EDashAbility.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
#include "Network/Network.h"
|
#include "Network/Network.h"
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Network/UDPClient.h"
|
#include "Network/UDPClient.h"
|
||||||
#include "Network/TCPClient.h"
|
#include "Network/TCPClient.h"
|
||||||
#include "Network/SnapshotDefinitions.h"
|
#include "Network/SnapshotDefinitions.h"
|
||||||
#include "Core/World.h"
|
|
||||||
#include "Core/EntityFile.h"
|
|
||||||
#include "Core/EventBroker.h"
|
|
||||||
#include "Core/ConfigFile.h"
|
|
||||||
#include "Core/EPlayerDeath.h"
|
|
||||||
#include "Input/EInputCommand.h"
|
|
||||||
#include "Core/EPlayerDamage.h"
|
|
||||||
#include "../Game/Events/EDoubleJump.h"
|
|
||||||
#include "Network/EInterpolate.h"
|
|
||||||
#include "Network/SnapshotFilter.h"
|
|
||||||
#include "Core/EPlayerSpawned.h"
|
|
||||||
#include "Core/EAmmoPickup.h"
|
|
||||||
#include "Network/ESearchForServers.h"
|
|
||||||
#include "../Game/Events/EDashAbility.h"
|
|
||||||
#include "Network/EDisplayServerlist.h"
|
#include "Network/EDisplayServerlist.h"
|
||||||
#include "Network/EConnectRequest.h"
|
#include "Network/EConnectRequest.h"
|
||||||
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
#include "Network/ESearchForServers.h"
|
||||||
|
#include "Network/EInterpolate.h"
|
||||||
|
#include "Network/SnapshotFilter.h"
|
||||||
|
|
||||||
class Client : public Network
|
class Client : public Network
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -40,7 +44,7 @@ public:
|
|||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
void Connect(std::string address, int port);
|
void Connect(std::string address, int port);
|
||||||
void Update() override;
|
void Update(double dt) override;
|
||||||
private:
|
private:
|
||||||
UDPClient m_Unreliable;
|
UDPClient m_Unreliable;
|
||||||
TCPClient m_Reliable;
|
TCPClient m_Reliable;
|
||||||
@@ -74,10 +78,10 @@ private:
|
|||||||
// Network logic
|
// Network logic
|
||||||
PlayerDefinition m_PlayerDefinitions[8];
|
PlayerDefinition m_PlayerDefinitions[8];
|
||||||
SnapshotDefinitions m_NextSnapshot;
|
SnapshotDefinitions m_NextSnapshot;
|
||||||
double m_DurationOfPingTime;
|
double m_DurationOfPingTime = 0;
|
||||||
std::clock_t m_StartPingTime;
|
double m_StartPingTime = 0;
|
||||||
std::clock_t m_TimeSinceSentInputs;
|
double m_TimeSinceSentInputs = 0;
|
||||||
unsigned int m_SendInputIntervalMs;
|
double m_SendInputInterval = 0.033;
|
||||||
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
@@ -100,6 +104,7 @@ private:
|
|||||||
void parseDoubleJump(Packet& packet);
|
void parseDoubleJump(Packet& packet);
|
||||||
void parseDashEffect(Packet& packet);
|
void parseDashEffect(Packet& packet);
|
||||||
void parseAmmoPickup(Packet& packet);
|
void parseAmmoPickup(Packet& packet);
|
||||||
|
void parseRemoveWorld(Packet& packet);
|
||||||
void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||||
void parseSnapshot(Packet& packet);
|
void parseSnapshot(Packet& packet);
|
||||||
void identifyPacketLoss();
|
void identifyPacketLoss();
|
||||||
@@ -109,7 +114,6 @@ private:
|
|||||||
void sendLocalPlayerTransform();
|
void sendLocalPlayerTransform();
|
||||||
void becomePlayer();
|
void becomePlayer();
|
||||||
void displayServerlist();
|
void displayServerlist();
|
||||||
void removeWorld();
|
|
||||||
void createMainMenu();
|
void createMainMenu();
|
||||||
// Mapping Logic
|
// Mapping Logic
|
||||||
// Returns if local EntityID exist in map
|
// Returns if local EntityID exist in map
|
||||||
@@ -138,8 +142,8 @@ private:
|
|||||||
UDPClient m_ServerlistRequest;
|
UDPClient m_ServerlistRequest;
|
||||||
std::vector<ServerInfo> m_Serverlist;
|
std::vector<ServerInfo> m_Serverlist;
|
||||||
bool m_SearchingForServers = false;
|
bool m_SearchingForServers = false;
|
||||||
std::clock_t m_StartSearchTime;
|
double m_TimeSearched = 0;
|
||||||
double m_SearchingTime = 200; // Config I guess
|
double m_SearchingTime = 0.2; // Config I guess
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ enum class MessageType
|
|||||||
OnDashEffect,
|
OnDashEffect,
|
||||||
ServerlistRequest,
|
ServerlistRequest,
|
||||||
AmmoPickup,
|
AmmoPickup,
|
||||||
|
RemoveWorld,
|
||||||
Invalid
|
Invalid
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
Network(World* world, EventBroker* eventBroker);
|
Network(World* world, EventBroker* eventBroker);
|
||||||
virtual ~Network() { };
|
virtual ~Network() { };
|
||||||
|
|
||||||
virtual void Update() = 0;
|
virtual void Update(double dt) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
World* m_World;
|
World* m_World;
|
||||||
@@ -40,6 +40,7 @@ protected:
|
|||||||
void saveToFile();
|
void saveToFile();
|
||||||
void updateNetworkData();
|
void updateNetworkData();
|
||||||
void popNetworkSegmentOfHeader(Packet& packet);
|
void popNetworkSegmentOfHeader(Packet& packet);
|
||||||
|
void removeWorld();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "../Network/Network.h"
|
#include "../Network/Network.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
@@ -24,6 +25,8 @@
|
|||||||
#include "Core/EPlayerDeath.h"
|
#include "Core/EPlayerDeath.h"
|
||||||
#include "Network/EPlayerConnected.h"
|
#include "Network/EPlayerConnected.h"
|
||||||
#include "Network/EKillDeath.h"
|
#include "Network/EKillDeath.h"
|
||||||
|
#include "Core/EWin.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
|
||||||
class Server : public Network
|
class Server : public Network
|
||||||
{
|
{
|
||||||
@@ -31,7 +34,7 @@ public:
|
|||||||
Server(World* world, EventBroker* eventBroker, int port);
|
Server(World* world, EventBroker* eventBroker, int port);
|
||||||
~Server();
|
~Server();
|
||||||
|
|
||||||
void Update() override;
|
void Update(double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Network channels
|
// Network channels
|
||||||
@@ -41,6 +44,7 @@ private:
|
|||||||
// dont forget to set these in the childrens receive logic
|
// dont forget to set these in the childrens receive logic
|
||||||
boost::asio::ip::address m_Address;
|
boost::asio::ip::address m_Address;
|
||||||
int m_Port = 27666;
|
int m_Port = 27666;
|
||||||
|
bool m_GameIsOver = false;
|
||||||
// Sending messages to client logic
|
// Sending messages to client logic
|
||||||
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
||||||
std::vector<PlayerID> m_PlayersToDisconnect;
|
std::vector<PlayerID> m_PlayersToDisconnect;
|
||||||
@@ -48,14 +52,14 @@ private:
|
|||||||
char readBuffer[BUFFERSIZE] = { 0 };
|
char readBuffer[BUFFERSIZE] = { 0 };
|
||||||
size_t bytesRead = 0;
|
size_t bytesRead = 0;
|
||||||
// time for previouse message
|
// time for previouse message
|
||||||
std::clock_t previousePingMessage = std::clock();
|
double previousPingMessage = 0;
|
||||||
std::clock_t previousSnapshotMessage = std::clock();
|
double previousSnapshotMessage = 0;
|
||||||
std::clock_t timOutTimer = std::clock();
|
double timeOutTimer = 0;
|
||||||
|
|
||||||
// How often we send messages (milliseconds)
|
// How often we send messages (seconds)
|
||||||
float pingIntervalMs;
|
double pingInterval = 1;
|
||||||
float snapshotInterval;
|
double snapshotInterval = 0.05;
|
||||||
int checkTimeOutInterval = 100;
|
double checkTimeOutInterval = 0.1;
|
||||||
int m_NextPlayerID = 0;
|
int m_NextPlayerID = 0;
|
||||||
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
||||||
//Timers
|
//Timers
|
||||||
@@ -71,6 +75,7 @@ private:
|
|||||||
void reliableBroadcast(Packet& packet);
|
void reliableBroadcast(Packet& packet);
|
||||||
void unreliableBroadcast(Packet& packet);
|
void unreliableBroadcast(Packet& packet);
|
||||||
void sendSnapshot();
|
void sendSnapshot();
|
||||||
|
void createWorldSnapshot(Packet& packet);
|
||||||
void addPlayersToPacket(Packet& packet, EntityID entityID);
|
void addPlayersToPacket(Packet& packet, EntityID entityID);
|
||||||
void addChildrenToPacket(Packet& packet, EntityID entityID);
|
void addChildrenToPacket(Packet& packet, EntityID entityID);
|
||||||
void addInputCommandsToPacket(Packet& packet);
|
void addInputCommandsToPacket(Packet& packet);
|
||||||
@@ -83,6 +88,7 @@ private:
|
|||||||
void kick(PlayerID player);
|
void kick(PlayerID player);
|
||||||
PlayerID getPlayerIDFromEndpoint();
|
PlayerID getPlayerIDFromEndpoint();
|
||||||
PlayerID getPlayerIDFromEntityID(EntityID entityID);
|
PlayerID getPlayerIDFromEntityID(EntityID entityID);
|
||||||
|
void resetMap();
|
||||||
void parsePlayerTransform(Packet& packet);
|
void parsePlayerTransform(Packet& packet);
|
||||||
void parseOnInputCommand(Packet& packet);
|
void parseOnInputCommand(Packet& packet);
|
||||||
void parseClientPing();
|
void parseClientPing();
|
||||||
@@ -110,6 +116,8 @@ private:
|
|||||||
bool OnAmmoPickup(const Events::AmmoPickup& e);
|
bool OnAmmoPickup(const Events::AmmoPickup& e);
|
||||||
EventRelay<Server, Events::PlayerDeath> m_EPlayerDeath;
|
EventRelay<Server, Events::PlayerDeath> m_EPlayerDeath;
|
||||||
bool OnPlayerDeath(const Events::PlayerDeath& e);
|
bool OnPlayerDeath(const Events::PlayerDeath& e);
|
||||||
|
EventRelay<Server, Events::Win> m_EWin;
|
||||||
|
bool OnWin(const Events::Win& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef Events_Reset_h__
|
||||||
|
#define Events_Reset_h__
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/EntityWrapper.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Reset : Event
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Engine/Collision/ETrigger.h"
|
#include "Engine/Collision/ETrigger.h"
|
||||||
#include "Core/ECaptured.h"
|
#include "Core/ECaptured.h"
|
||||||
#include "Core/EWin.h"
|
#include "Core/EWin.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -23,6 +24,7 @@ public:
|
|||||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override;
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Init();
|
||||||
//methods which will take care of specific events
|
//methods which will take care of specific events
|
||||||
EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
|
EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||||
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
|
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
|
||||||
@@ -30,6 +32,8 @@ private:
|
|||||||
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
|
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
|
||||||
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
|
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
|
||||||
bool CapturePointSystem::OnCaptured(const Events::Captured& e);
|
bool CapturePointSystem::OnCaptured(const Events::Captured& e);
|
||||||
|
EventRelay<CapturePointSystem, Events::Reset> m_EReset;
|
||||||
|
bool CapturePointSystem::OnReset(const Events::Reset& e);
|
||||||
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
|
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
|
||||||
|
|
||||||
bool m_WinnerWasFound = false;
|
bool m_WinnerWasFound = false;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Network/EPlayerConnected.h"
|
#include "Network/EPlayerConnected.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
#include "Engine/Input/EInputCommand.h"
|
||||||
#include "GLM.h"
|
#include "GLM.h"
|
||||||
|
|
||||||
class ScoreScreenSystem : public PureSystem
|
class ScoreScreenSystem : public PureSystem
|
||||||
@@ -25,6 +27,10 @@ public:
|
|||||||
bool OnPlayerConnected(const Events::PlayerConnected& e);
|
bool OnPlayerConnected(const Events::PlayerConnected& e);
|
||||||
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
|
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
|
||||||
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
|
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
|
||||||
|
EventRelay<ScoreScreenSystem, Events::Reset> m_EReset;
|
||||||
|
bool OnReset(const Events::Reset& e);
|
||||||
|
EventRelay<ScoreScreenSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PlayerData {
|
struct PlayerData {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
|
||||||
class SpectatorCameraSystem : public ImpureSystem
|
class SpectatorCameraSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -15,11 +16,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_PickedTeam;
|
int m_PickedTeam;
|
||||||
bool m_CamSetToTeamPick;
|
bool m_CamSetToTeamPick;
|
||||||
|
void reset();
|
||||||
|
|
||||||
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
||||||
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
||||||
|
EventRelay<SpectatorCameraSystem, Events::Reset> m_EReset;
|
||||||
|
bool OnReset(const Events::Reset& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -2,4 +2,5 @@
|
|||||||
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
|
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
|
||||||
<RespawnTime>0.0</RespawnTime>
|
<RespawnTime>0.0</RespawnTime>
|
||||||
<MaxRespawnTime>8.0</MaxRespawnTime>
|
<MaxRespawnTime>8.0</MaxRespawnTime>
|
||||||
|
<ResetCountdown>10.0</ResetCountdown>
|
||||||
</CapturePointGameMode>
|
</CapturePointGameMode>
|
||||||
@@ -12,6 +12,9 @@
|
|||||||
<xs:element name="MaxRespawnTime" type="t:double" minOccurs="0">
|
<xs:element name="MaxRespawnTime" type="t:double" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Players will be spawned when RespawnTime reaches this.</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Players will be spawned when RespawnTime reaches this.</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="ResetCountdown" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The map will be reset when time reaches 0.</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
+4705
-4705
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
#include "Network/Client.h"
|
#include "Network/Client.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
Client::Client(World* world, EventBroker* eventBroker)
|
Client::Client(World* world, EventBroker* eventBroker)
|
||||||
@@ -12,7 +12,7 @@ Client::Client(World* world, EventBroker* eventBroker)
|
|||||||
|
|
||||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
m_PlayerName = config->Get<std::string>("Networking.Name", "Raptorcopter");
|
m_PlayerName = config->Get<std::string>("Networking.Name", "Raptorcopter");
|
||||||
m_SendInputIntervalMs = config->Get<int>("Networking.SendInputIntervalMs", 33);
|
m_SendInputInterval = config->Get<int>("Networking.SendInputIntervalMs", 33) / 1000.0;
|
||||||
LOG_INFO("Client initialized");
|
LOG_INFO("Client initialized");
|
||||||
|
|
||||||
m_ServerlistRequest.Connect(m_PlayerName, "192.168.1.255", 32554);
|
m_ServerlistRequest.Connect(m_PlayerName, "192.168.1.255", 32554);
|
||||||
@@ -48,7 +48,7 @@ void Client::Connect(std::string address, int port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::Update()
|
void Client::Update(double dt)
|
||||||
{
|
{
|
||||||
m_EventBroker->Process<Client>();
|
m_EventBroker->Process<Client>();
|
||||||
while (m_Unreliable.IsSocketAvailable()) {
|
while (m_Unreliable.IsSocketAvailable()) {
|
||||||
@@ -85,7 +85,9 @@ void Client::Update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_SearchingForServers) {
|
if (m_SearchingForServers) {
|
||||||
if (m_SearchingTime < (1000* (std::clock() - m_StartSearchTime) / (double)CLOCKS_PER_SEC)) {
|
m_TimeSearched += dt;
|
||||||
|
if (m_SearchingTime < m_TimeSearched) {
|
||||||
|
m_TimeSearched = 0;
|
||||||
m_SearchingForServers = false;
|
m_SearchingForServers = false;
|
||||||
//displayServerlist();
|
//displayServerlist();
|
||||||
Events::DisplayServerlist e;
|
Events::DisplayServerlist e;
|
||||||
@@ -96,16 +98,25 @@ void Client::Update()
|
|||||||
|
|
||||||
if (m_IsConnected) {
|
if (m_IsConnected) {
|
||||||
// Don't send 1 input in 1 packet, bunch em up.
|
// Don't send 1 input in 1 packet, bunch em up.
|
||||||
if (m_SendInputIntervalMs < (1000 * (std::clock() - m_TimeSinceSentInputs) / (double)CLOCKS_PER_SEC)) {
|
m_TimeSinceSentInputs += dt;
|
||||||
|
if (m_SendInputInterval < m_TimeSinceSentInputs) {
|
||||||
sendInputCommands();
|
sendInputCommands();
|
||||||
m_TimeSinceSentInputs = std::clock();
|
m_TimeSinceSentInputs = 0;
|
||||||
}
|
}
|
||||||
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages
|
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages
|
||||||
sendLocalPlayerTransform();
|
sendLocalPlayerTransform();
|
||||||
|
|
||||||
hasServerTimedOut();
|
hasServerTimedOut();
|
||||||
}
|
}
|
||||||
//Network::Update();
|
|
||||||
|
if (ImGui::BeginPopupModal("Disconnected", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
ImGui::Text("You have been disconnected from server.\n\n");
|
||||||
|
ImGui::SetCursorPosX(ImGui::GetContentRegionAvailWidth() - 120);
|
||||||
|
if (ImGui::Button("OK", ImVec2(120, 0))) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseMessageType(Packet& packet)
|
void Client::parseMessageType(Packet& packet)
|
||||||
@@ -159,6 +170,9 @@ void Client::parseMessageType(Packet& packet)
|
|||||||
case MessageType::AmmoPickup:
|
case MessageType::AmmoPickup:
|
||||||
parseAmmoPickup(packet);
|
parseAmmoPickup(packet);
|
||||||
break;
|
break;
|
||||||
|
case MessageType::RemoveWorld:
|
||||||
|
parseRemoveWorld(packet);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -190,7 +204,7 @@ void Client::parseTCPConnect(Packet& packet)
|
|||||||
packet.WritePrimitive(m_PlayerID);
|
packet.WritePrimitive(m_PlayerID);
|
||||||
m_Unreliable.Send(packet);
|
m_Unreliable.Send(packet);
|
||||||
|
|
||||||
// LOG_INFO("Sent UDP Connect Server");
|
// LOG_INFO("Sent UDP Connect Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parsePlayerConnected(Packet & packet)
|
void Client::parsePlayerConnected(Packet & packet)
|
||||||
@@ -336,6 +350,13 @@ void Client::parseAmmoPickup(Packet & packet)
|
|||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::parseRemoveWorld(Packet & packet)
|
||||||
|
{
|
||||||
|
removeWorld();
|
||||||
|
Events::Reset e;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
||||||
{
|
{
|
||||||
for (auto field : componentInfo.FieldsInOrder) {
|
for (auto field : componentInfo.FieldsInOrder) {
|
||||||
@@ -583,7 +604,7 @@ bool Client::OnConnectRequest(const Events::ConnectRequest& e)
|
|||||||
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
||||||
{
|
{
|
||||||
m_SearchingForServers = true;
|
m_SearchingForServers = true;
|
||||||
m_StartSearchTime = std::clock();
|
m_TimeSearched = 0;
|
||||||
m_Serverlist.clear();
|
m_Serverlist.clear();
|
||||||
Packet packet(MessageType::ServerlistRequest);
|
Packet packet(MessageType::ServerlistRequest);
|
||||||
m_ServerlistRequest.Broadcast(packet, 13); // TODO: Config
|
m_ServerlistRequest.Broadcast(packet, 13); // TODO: Config
|
||||||
@@ -663,6 +684,7 @@ void Client::hasServerTimedOut()
|
|||||||
if (timeSincePing > m_TimeoutMs) {
|
if (timeSincePing > m_TimeoutMs) {
|
||||||
// Clear everything and go to menu.
|
// Clear everything and go to menu.
|
||||||
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
||||||
|
ImGui::OpenPopup("Disconnected");
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -706,19 +728,6 @@ void Client::displayServerlist()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::removeWorld()
|
|
||||||
{
|
|
||||||
std::vector<EntityID> childrenToBeDeleted;
|
|
||||||
auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid);
|
|
||||||
for (auto it = rootEntites.first; it != rootEntites.second; it++) {
|
|
||||||
childrenToBeDeleted.push_back(it->second);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < childrenToBeDeleted.size(); ++i) {
|
|
||||||
m_World->DeleteEntity(childrenToBeDeleted[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Client::createMainMenu()
|
void Client::createMainMenu()
|
||||||
{
|
{
|
||||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/StartMenu.xml");
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/StartMenu.xml");
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Network::Network(World* world, EventBroker* eventBroker)
|
|||||||
m_TimeoutMs = config->Get<int>("Networking.TimeoutMs", 20000);
|
m_TimeoutMs = config->Get<int>("Networking.TimeoutMs", 20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Network::Update()
|
void Network::Update(double dt)
|
||||||
{
|
{
|
||||||
updateNetworkData();
|
updateNetworkData();
|
||||||
}
|
}
|
||||||
@@ -92,3 +92,15 @@ void Network::popNetworkSegmentOfHeader(Packet & packet)
|
|||||||
packet.ReadPrimitive<int>();
|
packet.ReadPrimitive<int>();
|
||||||
packet.ReadPrimitive<int>();
|
packet.ReadPrimitive<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Network::removeWorld()
|
||||||
|
{
|
||||||
|
std::vector<EntityID> childrenToBeDeleted;
|
||||||
|
auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid);
|
||||||
|
for (auto it = rootEntites.first; it != rootEntites.second; it++) {
|
||||||
|
childrenToBeDeleted.push_back(it->second);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < childrenToBeDeleted.size(); ++i) {
|
||||||
|
m_World->DeleteEntity(childrenToBeDeleted[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,8 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
|||||||
, m_ServerlistRequest(13)
|
, m_ServerlistRequest(13)
|
||||||
{
|
{
|
||||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
|
snapshotInterval = config->Get<float>("Networking.SnapshotInterval", 0.05);
|
||||||
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
|
pingInterval = config->Get<float>("Networking.PingIntervalMs", 1000) / 1000.0;
|
||||||
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
|
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
|
||||||
|
|
||||||
// Subscribe to events
|
// Subscribe to events
|
||||||
@@ -17,6 +17,7 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup);
|
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EWin, &Server::OnWin);
|
||||||
// BindWW
|
// BindWW
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
port = config->Get<float>("Networking.Port", 27666);
|
port = config->Get<float>("Networking.Port", 27666);
|
||||||
@@ -30,7 +31,7 @@ Server::~Server()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::Update()
|
void Server::Update(double dt)
|
||||||
{
|
{
|
||||||
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
||||||
|
|
||||||
@@ -86,26 +87,44 @@ void Server::Update()
|
|||||||
}
|
}
|
||||||
m_PlayersToDisconnect.clear();
|
m_PlayersToDisconnect.clear();
|
||||||
|
|
||||||
std::clock_t currentTime = std::clock();
|
|
||||||
// Send snapshot
|
// Send snapshot
|
||||||
if (snapshotInterval < (1000 * (currentTime - previousSnapshotMessage) / (double)CLOCKS_PER_SEC)) {
|
previousSnapshotMessage += dt;
|
||||||
|
if (snapshotInterval < previousSnapshotMessage) {
|
||||||
sendSnapshot();
|
sendSnapshot();
|
||||||
previousSnapshotMessage = currentTime;
|
previousSnapshotMessage = 0;
|
||||||
}
|
}
|
||||||
// Send pings each
|
// Send pings each
|
||||||
if (pingIntervalMs < (1000 * (currentTime - previousePingMessage) / (double)CLOCKS_PER_SEC)) {
|
previousPingMessage += dt;
|
||||||
|
if (pingInterval < previousPingMessage) {
|
||||||
sendPing();
|
sendPing();
|
||||||
previousePingMessage = currentTime;
|
previousPingMessage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time out logic
|
// Time out logic
|
||||||
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
|
timeOutTimer += dt;
|
||||||
|
if (checkTimeOutInterval < timeOutTimer) {
|
||||||
checkForTimeOuts();
|
checkForTimeOuts();
|
||||||
timOutTimer = currentTime;
|
timeOutTimer = 0;
|
||||||
}
|
}
|
||||||
m_EventBroker->Process<Server>();
|
m_EventBroker->Process<Server>();
|
||||||
if (isReadingData) {
|
if (isReadingData) {
|
||||||
Network::Update();
|
Network::Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_GameIsOver) {
|
||||||
|
auto pool = m_World->GetComponents("CapturePointGameMode");
|
||||||
|
if (pool != nullptr && pool->size() > 0) {
|
||||||
|
// Take the first CapturePointGameMode component found.
|
||||||
|
ComponentWrapper& modeComponent = *pool->begin();
|
||||||
|
// Decrease timer.
|
||||||
|
Field<double> timer = modeComponent["ResetCountdown"];
|
||||||
|
timer -= dt;
|
||||||
|
if (timer < 0) {
|
||||||
|
resetMap();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resetMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +183,7 @@ void Server::reliableBroadcast(Packet& packet)
|
|||||||
|
|
||||||
void Server::unreliableBroadcast(Packet& packet)
|
void Server::unreliableBroadcast(Packet& packet)
|
||||||
{
|
{
|
||||||
m_Unreliable.SendToConnectedPlayers(packet, m_ConnectedPlayers);
|
m_Unreliable.SendToConnectedPlayers(packet, m_ConnectedPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send snapshot fields
|
// Send snapshot fields
|
||||||
@@ -173,10 +192,16 @@ void Server::sendSnapshot()
|
|||||||
Packet packet(MessageType::Snapshot);
|
Packet packet(MessageType::Snapshot);
|
||||||
addInputCommandsToPacket(packet);
|
addInputCommandsToPacket(packet);
|
||||||
addPlayersToPacket(packet, EntityID_Invalid);
|
addPlayersToPacket(packet, EntityID_Invalid);
|
||||||
//addChildrenToPacket(packet, EntityID_Invalid);
|
|
||||||
unreliableBroadcast(packet);
|
unreliableBroadcast(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send snapshot fields
|
||||||
|
void Server::createWorldSnapshot(Packet& packet)
|
||||||
|
{
|
||||||
|
addInputCommandsToPacket(packet);
|
||||||
|
addChildrenToPacket(packet, EntityID_Invalid);
|
||||||
|
}
|
||||||
|
|
||||||
void Server::addInputCommandsToPacket(Packet& packet)
|
void Server::addInputCommandsToPacket(Packet& packet)
|
||||||
{
|
{
|
||||||
// Number of input commands
|
// Number of input commands
|
||||||
@@ -379,8 +404,7 @@ void Server::parseTCPConnect(Packet & packet)
|
|||||||
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
|
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
|
||||||
|
|
||||||
Packet firstSnapshot(MessageType::Snapshot);
|
Packet firstSnapshot(MessageType::Snapshot);
|
||||||
addInputCommandsToPacket(firstSnapshot);
|
createWorldSnapshot(firstSnapshot);
|
||||||
addChildrenToPacket(firstSnapshot, EntityID_Invalid);
|
|
||||||
m_Reliable.Send(firstSnapshot);
|
m_Reliable.Send(firstSnapshot);
|
||||||
|
|
||||||
// Send notification that a player has connected
|
// Send notification that a player has connected
|
||||||
@@ -542,6 +566,13 @@ bool Server::OnPlayerDeath(const Events::PlayerDeath& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Server::OnWin(const Events::Win & e)
|
||||||
|
{
|
||||||
|
// Postpone the gameover reset
|
||||||
|
m_GameIsOver = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Server::parseClientPing()
|
void Server::parseClientPing()
|
||||||
{
|
{
|
||||||
LOG_INFO("%i: Parsing ping", m_PacketID);
|
LOG_INFO("%i: Parsing ping", m_PacketID);
|
||||||
@@ -664,3 +695,19 @@ PlayerID Server::getPlayerIDFromEntityID(EntityID entityID)
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::resetMap()
|
||||||
|
{
|
||||||
|
m_GameIsOver = false;
|
||||||
|
Events::Reset reset;
|
||||||
|
m_EventBroker->Publish(reset);
|
||||||
|
Packet removeMap(MessageType::RemoveWorld);
|
||||||
|
reliableBroadcast(removeMap);
|
||||||
|
removeWorld();
|
||||||
|
// Hardcoded for now.
|
||||||
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/CP_Rocky2.xml");
|
||||||
|
entityFile->MergeInto(m_World);
|
||||||
|
Packet newWorld(MessageType::Snapshot);
|
||||||
|
createWorldSnapshot(newWorld);
|
||||||
|
reliableBroadcast(newWorld);
|
||||||
|
}
|
||||||
+2
-2
@@ -232,10 +232,10 @@ void Game::Tick()
|
|||||||
PerformanceTimer::StartTimerAndStopPrevious("Network");
|
PerformanceTimer::StartTimerAndStopPrevious("Network");
|
||||||
m_EventBroker->Process<MultiplayerSnapshotFilter>();
|
m_EventBroker->Process<MultiplayerSnapshotFilter>();
|
||||||
if (m_NetworkClient != nullptr) {
|
if (m_NetworkClient != nullptr) {
|
||||||
m_NetworkClient->Update();
|
m_NetworkClient->Update(dt);
|
||||||
}
|
}
|
||||||
if (m_NetworkServer != nullptr) {
|
if (m_NetworkServer != nullptr) {
|
||||||
m_NetworkServer->Update();
|
m_NetworkServer->Update(dt);
|
||||||
}
|
}
|
||||||
//m_SoundManager->Update(dt);
|
//m_SoundManager->Update(dt);
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,26 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EReset, &CapturePointSystem::OnReset);
|
||||||
|
Init();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CapturePointSystem::Init()
|
||||||
|
{
|
||||||
|
m_WinnerWasFound = false;
|
||||||
|
//need to track these variables for the captureSystem to work as per design!
|
||||||
|
m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
||||||
|
m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
||||||
|
m_RedTeamHomeCapturePoint = m_NotACapturePoint;
|
||||||
|
m_BlueTeamHomeCapturePoint = m_NotACapturePoint;
|
||||||
|
m_NumberOfCapturePoints = 0;
|
||||||
|
m_ResetTimers = false;
|
||||||
|
m_RecentlyCapturedNeedNextCapturePointNow = false;
|
||||||
|
m_CapturePointNumberToEntityMap.clear();
|
||||||
|
//vectors which will keep track of enter/leave changes
|
||||||
|
m_ETriggerTouchVector.clear();
|
||||||
|
m_ETriggerLeaveVector.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//here all capturepoints will update their component
|
//here all capturepoints will update their component
|
||||||
@@ -24,6 +42,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
if (m_WinnerWasFound) {
|
if (m_WinnerWasFound) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!capturePointEntity.Valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
||||||
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
||||||
|
|
||||||
@@ -60,7 +81,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if we havent received all capturepoints yet, just return
|
//if we havent received all capturepoints yet, just return
|
||||||
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) {
|
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints > m_CapturePointNumberToEntityMap.size()) {
|
||||||
m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
|
m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -232,10 +253,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
|
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner)
|
||||||
|
{
|
||||||
(Field<bool>)capturePointModels["Model"]["Visible"] = isOwner;
|
(Field<bool>)capturePointModels["Model"]["Visible"] = isOwner;
|
||||||
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform"))
|
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform")) {
|
||||||
{
|
|
||||||
if (capModel.HasComponent("Model")) {
|
if (capModel.HasComponent("Model")) {
|
||||||
(Field<bool>)capModel["Model"]["Visible"] = isOwner;
|
(Field<bool>)capModel["Model"]["Visible"] = isOwner;
|
||||||
}
|
}
|
||||||
@@ -269,3 +290,9 @@ bool CapturePointSystem::OnCaptured(const Events::Captured& e)
|
|||||||
m_ResetTimers = true;
|
m_ResetTimers = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CapturePointSystem::OnReset(const Events::Reset& e)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EReset, &ScoreScreenSystem::OnReset);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &ScoreScreenSystem::OnInputCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt)
|
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt)
|
||||||
@@ -156,3 +158,25 @@ bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e
|
|||||||
m_DisconnectedIdentities.push_back(e.PlayerID);
|
m_DisconnectedIdentities.push_back(e.PlayerID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScoreScreenSystem::OnReset(const Events::Reset & e)
|
||||||
|
{
|
||||||
|
for (auto& it : m_PlayerIdentities) {
|
||||||
|
it.second.Deaths = 0;
|
||||||
|
it.second.Kills = 0;
|
||||||
|
it.second.Team = 1;
|
||||||
|
it.second.Player = EntityWrapper::Invalid;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScoreScreenSystem::OnInputCommand(const Events::InputCommand & e)
|
||||||
|
{
|
||||||
|
if (e.Command != "PickTeam" || e.PlayerID == -1 || e.Value == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PlayerIdentities.at(e.PlayerID).Team = e.Value;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
|
|||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EReset, &SpectatorCameraSystem::OnReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectatorCameraSystem::Update(double dt)
|
void SpectatorCameraSystem::Update(double dt)
|
||||||
@@ -27,6 +28,14 @@ void SpectatorCameraSystem::Update(double dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpectatorCameraSystem::reset()
|
||||||
|
{
|
||||||
|
m_CamSetToTeamPick = false;
|
||||||
|
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
||||||
|
Events::UnlockMouse unlock;
|
||||||
|
m_EventBroker->Publish(unlock);
|
||||||
|
}
|
||||||
|
|
||||||
bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
{
|
{
|
||||||
// Only the client should do this, and only if player is not spawned.
|
// Only the client should do this, and only if player is not spawned.
|
||||||
@@ -95,10 +104,13 @@ bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
|
|||||||
// If local player gets disconnected, they should be set to
|
// If local player gets disconnected, they should be set to
|
||||||
// the spectator camera next time a map loads that has one.
|
// the spectator camera next time a map loads that has one.
|
||||||
if (e.Entity == LocalPlayer.ID) {
|
if (e.Entity == LocalPlayer.ID) {
|
||||||
m_CamSetToTeamPick = false;
|
reset();
|
||||||
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
|
||||||
Events::UnlockMouse unlock;
|
|
||||||
m_EventBroker->Publish(unlock);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpectatorCameraSystem::OnReset(const Events::Reset & e)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ bool Material::findColorTexture(MaterialNode& material_node, MFnDependencyNode&
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found color splat map");
|
||||||
return findSplatTextures(material_node, material_node.ColorMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.ColorMaps, MFnDependencyNode(AllConnections[i].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,9 +162,9 @@ bool Material::findNormalTexture(MaterialNode& material_node, MFnDependencyNode&
|
|||||||
|
|
||||||
material_node.NormalMaps.push_back(newTexture);
|
material_node.NormalMaps.push_back(newTexture);
|
||||||
return true;
|
return true;
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllBumpConnections[j].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found normal splat map");
|
||||||
return findSplatTextures(material_node, material_node.NormalMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.NormalMaps, MFnDependencyNode(AllBumpConnections[j].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ bool Material::findSpecularTexture(MaterialNode& material_node, MFnDependencyNod
|
|||||||
material_node.type = MaterialNode::MaterialType::SingleTextures;
|
material_node.type = MaterialNode::MaterialType::SingleTextures;
|
||||||
return true;
|
return true;
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found specular splat map");
|
||||||
return findSplatTextures(material_node, material_node.SpecularMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.SpecularMaps, MFnDependencyNode(AllConnections[i].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ bool Material::findIncandescenceTexture(MaterialNode& material_node, MFnDependen
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found incandescens splat map");
|
||||||
return findSplatTextures(material_node, material_node.IncandescenceMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.IncandescenceMaps, MFnDependencyNode(AllConnections[i].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user