Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b547938928 | |||
| d1832c1741 | |||
| 4432891437 | |||
| a006db9e63 | |||
| 717af2c4a4 | |||
| 969e7cb0d5 | |||
| 47a365a8fc | |||
| 71c03326aa | |||
| ba69c79821 | |||
| 0a31fa3dfd | |||
| ca457d9c00 | |||
| a08e54a147 | |||
| 2c3122bbdb | |||
| 10846be820 | |||
| 7d732c75ca |
@@ -16,6 +16,8 @@ struct InputCommand : Event
|
||||
std::string Command;
|
||||
/** The value of the command. */
|
||||
float Value = 0;
|
||||
/** Timestamp of the command. */
|
||||
double TimeStamp = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
~Client();
|
||||
|
||||
void Connect(std::string address, int port);
|
||||
void Update() override;
|
||||
|
||||
void Update(double dt) override;
|
||||
private:
|
||||
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
|
||||
void parseSpawnEvents();
|
||||
// Save for children
|
||||
@@ -56,13 +56,13 @@ public:
|
||||
bool m_IsConnected = false;
|
||||
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
|
||||
// Server Client Lookup map
|
||||
// Assumes that root node for client and server is EntityID 0.
|
||||
|
||||
// Don't Add items to these two maps with insert, use insertIntoServerClientMaps(EntityID, EntityID)!!!!
|
||||
std::unordered_map<EntityID, EntityID> m_ServerIDToClientID;
|
||||
std::unordered_map<EntityID, EntityID> m_ClientIDToServerID;
|
||||
|
||||
// Network logic
|
||||
UDPClient m_Unreliable;
|
||||
TCPClient m_Reliable;
|
||||
PlayerDefinition m_PlayerDefinitions[8];
|
||||
SnapshotDefinitions m_NextSnapshot;
|
||||
double m_DurationOfPingTime;
|
||||
@@ -70,9 +70,9 @@ public:
|
||||
std::clock_t m_TimeSinceSentInputs;
|
||||
unsigned int m_SendInputIntervalMs;
|
||||
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
||||
std::vector<Events::InputCommand> m_ReceivedInputCommands;
|
||||
|
||||
// Private member functions
|
||||
size_t receive(char* data);
|
||||
void disconnect();
|
||||
void parseMessageType(Packet& packet);
|
||||
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID);
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
void parseComponentDeletion(Packet& packet);
|
||||
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||
void parseSnapshot(Packet& packet);
|
||||
void parseOnInputCommand(Packet& packet);
|
||||
void publishInputCommands();
|
||||
void identifyPacketLoss();
|
||||
void hasServerTimedOut();
|
||||
EntityID createPlayer();
|
||||
@@ -110,9 +112,6 @@ public:
|
||||
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
||||
void parsePlayerDamage(Packet& packet);
|
||||
private:
|
||||
UDPClient m_Unreliable;
|
||||
TCPClient m_Reliable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,11 +22,13 @@ public:
|
||||
Network(World* world, EventBroker* eventBroker);
|
||||
virtual ~Network() { };
|
||||
|
||||
virtual void Update() = 0;
|
||||
virtual void Update(double dt) = 0;
|
||||
|
||||
protected:
|
||||
World* m_World;
|
||||
EventBroker* m_EventBroker;
|
||||
// for network
|
||||
double m_TimeStamp = 0;
|
||||
|
||||
// For Debug
|
||||
bool isReadingData = false;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define NetworkClient_h__
|
||||
|
||||
#include "Network/Packet.h"
|
||||
#define BUFFERSIZE 32000
|
||||
#define BUFFERSIZE 64000
|
||||
typedef unsigned int PlayerID;
|
||||
typedef unsigned int PacketID;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include "Network/Packet.h"
|
||||
#include "Network/PlayerDefinition.h"
|
||||
#define BUFFERSIZE 32000
|
||||
#define BUFFERSIZE 64000
|
||||
typedef unsigned int PlayerID;
|
||||
typedef unsigned int PacketID;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
Server(World* world, EventBroker* eventBroker, int port);
|
||||
~Server();
|
||||
|
||||
void Update() override;
|
||||
void Update(double dt) override;
|
||||
|
||||
private:
|
||||
// Network channels
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
int checkTimeOutInterval = 100;
|
||||
int m_NextPlayerID = 0;
|
||||
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
||||
std::vector<Events::InputCommand> m_InputCommandsToPublish;
|
||||
//Timers
|
||||
std::clock_t m_StartPingTime;
|
||||
|
||||
@@ -82,6 +83,7 @@ private:
|
||||
void parseTCPConnect(Packet & packet);
|
||||
void parseDisconnect();
|
||||
bool shouldSendToClient(EntityWrapper childEntity);
|
||||
void publishInputCommands();
|
||||
|
||||
// Debug event
|
||||
EventRelay<Server, Events::InputCommand> m_EInputCommand;
|
||||
|
||||
@@ -39,5 +39,5 @@ private:
|
||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||
|
||||
void updateMovementControllers(double dt);
|
||||
void updateVelocity(double dt);
|
||||
void updateVelocity(EntityWrapper player, double dt);
|
||||
};
|
||||
@@ -593,7 +593,7 @@
|
||||
<Resource>Models/Props/Walls/BigWallBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="56.3723755" Y="-0.458255291" Z="53.1675453"/>
|
||||
<Position X="57.2414131" Y="-0.458255291" Z="53.1675453"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -726,7 +726,7 @@
|
||||
<Resource>Models/Props/Walls/BigWallBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-2.87285304" Y="0" Z="0.0110195652"/>
|
||||
<Position X="-3.20842171" Y="0" Z="0.0110195652"/>
|
||||
<Scale X="1" Y="0.800000012" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
@@ -739,7 +739,7 @@
|
||||
<Resource>Models/Props/Walls/BigWallBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="2.9002583" Y="0" Z="-0.00627081469"/>
|
||||
<Position X="3.16696811" Y="0" Z="-0.00627081469"/>
|
||||
<Scale X="1" Y="0.800000012" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
@@ -1291,7 +1291,7 @@
|
||||
<Resource>Models/Props/Walls/BigWallBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="42.3930092" Y="-0.436794043" Z="53.3168259"/>
|
||||
<Position X="42.6762505" Y="-0.436794043" Z="53.3168259"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1302,7 +1302,7 @@
|
||||
<Resource>Models/Props/Walls/BigWallBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="2.79896975" Y="0" Z="0"/>
|
||||
<Position X="3.02606034" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -1314,7 +1314,7 @@
|
||||
<Resource>Models/Props/Walls/BigWallBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="5.67178059" Y="0" Z="0"/>
|
||||
<Position X="6.20324564" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -1326,7 +1326,7 @@
|
||||
<Resource>Models/Props/Walls/BigWallBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="8.55263519" Y="0" Z="0"/>
|
||||
<Position X="9.40820885" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -3310,6 +3310,60 @@
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/Stones/BigStone.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="2.85156512" Y="-1.23010564" Z="-1.48294902"/>
|
||||
<Scale X="1.50000012" Y="1" Z="1.4000001"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/Stones/MediumStone2.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-8.1107378" Y="1.61279738" Z="6.04347277"/>
|
||||
<Scale X="2.70000005" Y="2.20000005" Z="2.4000001"/>
|
||||
<Orientation X="1.02200007" Y="1.27200007" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/Stones/BigStone.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-12.3116245" Y="3.30153632" Z="2.33947349"/>
|
||||
<Orientation X="0" Y="3.46600008" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/Stones/BigStone.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="2.7208035" Y="0.631672204" Z="1.97706997"/>
|
||||
<Orientation X="0" Y="0" Z="5.86300039"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity>
|
||||
@@ -3319,7 +3373,7 @@
|
||||
<Resource>Models/Props/Stones/BigStone.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-32.077774" Y="1.78250229" Z="-52.9675865"/>
|
||||
<Position X="-32.141304" Y="1.78250229" Z="-52.9675865"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -3349,6 +3403,46 @@
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/Stones/BigStone.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="13.3016024" Y="-1.04082656" Z="-2.06582665"/>
|
||||
<Orientation X="0" Y="1.17200005" Z="6.28300047"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/Stones/SmallStone1.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="7.52924776" Y="0.407071143" Z="-2.09290624"/>
|
||||
<Scale X="3.4000001" Y="5.70000029" Z="3.70000029"/>
|
||||
<Orientation X="0" Y="1.7700001" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/Stones/BigStone.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-5.73053885" Y="-0.909733951" Z="4.32710028"/>
|
||||
<Orientation X="0" Y="3.46600008" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity>
|
||||
@@ -3698,7 +3792,7 @@
|
||||
<Resource>Models/Props/Stones/SmallStone1.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="17.9978104" Y="0.729522109" Z="64.9478226"/>
|
||||
<Position X="17.9978104" Y="0.729522109" Z="65.3742523"/>
|
||||
<Scale X="3" Y="3" Z="3"/>
|
||||
<Orientation X="2.68900013" Y="3.5940001" Z="0"/>
|
||||
</c:Transform>
|
||||
@@ -3948,7 +4042,7 @@
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-40.5458374" Y="-0.729142785" Z="-45.7907982"/>
|
||||
<Orientation X="4.93700027" Y="3.5" Z="1.37700009"/>
|
||||
<Orientation X="4.93700027" Y="4.81200027" Z="1.37700009"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -4671,6 +4765,7 @@
|
||||
<HomePointForTeam>
|
||||
<Blue/>
|
||||
</HomePointForTeam>
|
||||
<CapturePointNumber>4</CapturePointNumber>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||
@@ -4706,7 +4801,7 @@
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:CapturePoint>
|
||||
<CapturePointNumber>1</CapturePointNumber>
|
||||
<CapturePointNumber>3</CapturePointNumber>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||
@@ -4771,7 +4866,7 @@
|
||||
<Components>
|
||||
<c:CapturePoint>
|
||||
<CaptureTimer>1.5498908015879351</CaptureTimer>
|
||||
<CapturePointNumber>3</CapturePointNumber>
|
||||
<CapturePointNumber>1</CapturePointNumber>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||
@@ -4806,7 +4901,6 @@
|
||||
<HomePointForTeam>
|
||||
<Red/>
|
||||
</HomePointForTeam>
|
||||
<CapturePointNumber>4</CapturePointNumber>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||
@@ -5071,7 +5165,7 @@
|
||||
<c:Transform>
|
||||
<Position X="48.9189453" Y="7.06223536" Z="-78.9347992"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="22.6496716" Z="0"/>
|
||||
<Orientation X="0" Y="71.4059677" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
@@ -5090,7 +5184,7 @@
|
||||
<c:Transform>
|
||||
<Position X="-59.3499641" Y="7.46932745" Z="-20.6276321"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="19.304081" Z="0"/>
|
||||
<Orientation X="0" Y="68.0603104" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
@@ -5109,7 +5203,7 @@
|
||||
<c:Transform>
|
||||
<Position X="-1.13644195" Y="1.38919806" Z="38.9768829"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="16.9120293" Z="0"/>
|
||||
<Orientation X="0" Y="65.6683426" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
@@ -5128,7 +5222,7 @@
|
||||
<c:Transform>
|
||||
<Position X="54.7225227" Y="6.51863909" Z="29.0052128"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="17.2259693" Z="0"/>
|
||||
<Orientation X="0" Y="65.9822693" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
@@ -5147,7 +5241,7 @@
|
||||
<c:Transform>
|
||||
<Position X="-51.6792374" Y="8.44526482" Z="32.5153465"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="16.6746445" Z="0"/>
|
||||
<Orientation X="0" Y="65.4309921" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
@@ -5166,7 +5260,7 @@
|
||||
<c:Transform>
|
||||
<Position X="-42.3974304" Y="7.28327894" Z="81.9305344"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="14.8039036" Z="0"/>
|
||||
<Orientation X="0" Y="63.560215" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
@@ -5185,7 +5279,7 @@
|
||||
<c:Transform>
|
||||
<Position X="-9.85184956" Y="8.25567532" Z="39.6119232"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="13.8527527" Z="0"/>
|
||||
<Orientation X="0" Y="62.6090584" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
@@ -5204,7 +5298,7 @@
|
||||
<c:Transform>
|
||||
<Position X="49.2257118" Y="7.39368248" Z="-31.1810112"/>
|
||||
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||
<Orientation X="0" Y="11.0639687" Z="0"/>
|
||||
<Orientation X="0" Y="59.8201942" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
|
||||
@@ -23,9 +23,7 @@
|
||||
<Blue/>
|
||||
</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.0288832653" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
@@ -37,20 +35,6 @@
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="PlayerName">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Resource>Fonts/DroidSans.ttf,100</Resource>
|
||||
<Color A="1" B="0" G="1" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0.100000001" Y="0.248000011" Z="-0.248000011"/>
|
||||
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
|
||||
<Orientation X="0" Y="3.14199996" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="CameraModel">
|
||||
<Components>
|
||||
<c:Model>
|
||||
@@ -504,7 +488,6 @@
|
||||
<c:Model>
|
||||
<Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource>
|
||||
<Color A="1" B="1" G="0.309803933" R="0"/>
|
||||
<Visible>false</Visible>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
@@ -574,6 +557,21 @@
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="PlayerName">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>Insert name here</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,100</Resource>
|
||||
<Color A="1" B="0" G="1" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0.100000001" Y="1.50176644" Z="-0.248000011"/>
|
||||
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
|
||||
<Orientation X="0" Y="3.14199996" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
|
||||
@@ -35,20 +35,6 @@
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="PlayerName">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Resource>Fonts/DroidSans.ttf,100</Resource>
|
||||
<Color A="1" B="0" G="1" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0.100000001" Y="0.248000011" Z="-0.248000011"/>
|
||||
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
|
||||
<Orientation X="0" Y="3.14199996" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="CameraModel">
|
||||
<Components>
|
||||
<c:Model>
|
||||
@@ -571,6 +557,21 @@
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="PlayerName">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>Insert name here</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,100</Resource>
|
||||
<Color A="1" B="0" G="1" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0.100000001" Y="1.50199997" Z="-0.248000011"/>
|
||||
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
|
||||
<Orientation X="0" Y="3.14199996" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
|
||||
@@ -40,6 +40,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
||||
|
||||
m_EditorStats = new EditorStats();
|
||||
|
||||
m_Enabled = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.EditorEnabled", false);
|
||||
if (m_Enabled) {
|
||||
Enable();
|
||||
}
|
||||
|
||||
@@ -41,9 +41,11 @@ void Client::Connect(std::string address, int port)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Update()
|
||||
void Client::Update(double dt)
|
||||
{
|
||||
m_EventBroker->Process<Client>();
|
||||
//m_TimeStamp += dt;
|
||||
publishInputCommands();
|
||||
while (m_Unreliable.IsSocketAvailable()) {
|
||||
// Packet will get real data in receive
|
||||
Packet packet(MessageType::Invalid);
|
||||
@@ -72,7 +74,8 @@ void Client::Update()
|
||||
sendInputCommands();
|
||||
m_TimeSinceSentInputs = std::clock();
|
||||
}
|
||||
// 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.
|
||||
// Reliable messages and timestamps did not fix it.
|
||||
sendLocalPlayerTransform();
|
||||
|
||||
hasServerTimedOut();
|
||||
@@ -122,6 +125,9 @@ void Client::parseMessageType(Packet& packet)
|
||||
case MessageType::OnPlayerDamage:
|
||||
parsePlayerDamage(packet);
|
||||
break;
|
||||
case MessageType::OnInputCommand:
|
||||
//parsePlayerDamage(packet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -284,21 +290,30 @@ void Client::ignoreFields(Packet& packet, const ComponentInfo& componentInfo)
|
||||
|
||||
void Client::parseSnapshot(Packet& packet)
|
||||
{
|
||||
// Read input commands
|
||||
std::size_t numInputCommands = packet.ReadPrimitive<std::size_t>();
|
||||
for (std::size_t i = 0; i < numInputCommands; ++i) {
|
||||
Events::InputCommand e;
|
||||
e.PlayerID = packet.ReadPrimitive<EntityID>();
|
||||
EntityID player = packet.ReadPrimitive<EntityID>();
|
||||
std::string command = packet.ReadString();
|
||||
float value = packet.ReadPrimitive<float>();
|
||||
if (m_ServerIDToClientID.find(player) != m_ServerIDToClientID.end()) {
|
||||
e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(player));
|
||||
e.Command = command;
|
||||
e.Value = value;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
//// Read input commands
|
||||
//std::size_t numInputCommands = packet.ReadPrimitive<std::size_t>();
|
||||
//for (std::size_t i = 0; i < numInputCommands; ++i) {
|
||||
// Events::InputCommand e;
|
||||
// e.PlayerID = packet.ReadPrimitive<EntityID>();
|
||||
// EntityID player = packet.ReadPrimitive<EntityID>();
|
||||
// std::string command = packet.ReadString();
|
||||
// float value = packet.ReadPrimitive<float>();
|
||||
// double timestamp = packet.ReadPrimitive<double>();
|
||||
// if (m_ServerIDToClientID.find(player) != m_ServerIDToClientID.end()) {
|
||||
// e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(player));
|
||||
// e.Command = command;
|
||||
// e.Value = value;
|
||||
// e.TimeStamp = timestamp;
|
||||
// m_EventBroker->Publish(e);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Read timestamp
|
||||
double remoteTimestamp = packet.ReadPrimitive<double>();
|
||||
//if (abs(remoteTimestamp - m_TimeStamp) > 0.100) {
|
||||
// m_TimeStamp = remoteTimestamp;
|
||||
// LOG_INFO("Resynced remote and local timestamp");
|
||||
//}
|
||||
|
||||
// Read world state
|
||||
while (packet.DataReadSize() < packet.Size()) {
|
||||
@@ -359,6 +374,36 @@ void Client::parseSnapshot(Packet& packet)
|
||||
parseSpawnEvents();
|
||||
}
|
||||
|
||||
|
||||
void Client::parseOnInputCommand(Packet & packet)
|
||||
{
|
||||
while (packet.DataReadSize() < packet.Size()) {
|
||||
Events::InputCommand e;
|
||||
e.PlayerID = packet.ReadPrimitive<int>();
|
||||
e.Player = EntityWrapper(m_World, packet.ReadPrimitive<int>());
|
||||
e.Command = packet.ReadString();
|
||||
e.Value = packet.ReadPrimitive<float>();
|
||||
e.TimeStamp = packet.ReadPrimitive<double>();
|
||||
m_EventBroker->Publish(e);
|
||||
m_ReceivedInputCommands.push_back(e);
|
||||
//LOG_INFO("Server::parseOnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::publishInputCommands()
|
||||
{
|
||||
std::vector<Events::InputCommand> notPublishedEvents;
|
||||
for (int i = 0; i < m_ReceivedInputCommands.size(); i++) {
|
||||
if (m_ReceivedInputCommands.at(i).TimeStamp < m_TimeStamp) {
|
||||
m_EventBroker->Publish(m_ReceivedInputCommands.at(i));
|
||||
}
|
||||
else {
|
||||
notPublishedEvents.push_back(m_ReceivedInputCommands.at(i));
|
||||
}
|
||||
}
|
||||
m_ReceivedInputCommands = notPublishedEvents;
|
||||
}
|
||||
|
||||
void Client::disconnect()
|
||||
{
|
||||
m_IsConnected = false;
|
||||
@@ -402,7 +447,9 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
|
||||
}
|
||||
} else {
|
||||
if (m_IsConnected) {
|
||||
m_InputCommandBuffer.push_back(e);
|
||||
Events::InputCommand setTimestamp = e;
|
||||
setTimestamp.TimeStamp = m_TimeStamp;
|
||||
m_InputCommandBuffer.push_back(setTimestamp);
|
||||
}
|
||||
//LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
return true;
|
||||
@@ -436,8 +483,13 @@ bool Client::OnPlayerSpawned(const Events::PlayerSpawned& e)
|
||||
void Client::parsePlayerDamage(Packet& packet)
|
||||
{
|
||||
Events::PlayerDamage e;
|
||||
e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(packet.ReadPrimitive<EntityID>()));
|
||||
e.Victim = EntityWrapper(m_World, m_ServerIDToClientID.at(packet.ReadPrimitive<EntityID>()));
|
||||
PlayerID victimID = packet.ReadPrimitive<EntityID>();
|
||||
PlayerID inflictorID = packet.ReadPrimitive<EntityID>();
|
||||
if(!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)){
|
||||
return;
|
||||
}
|
||||
e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(victimID));
|
||||
e.Victim = EntityWrapper(m_World, m_ServerIDToClientID.at(inflictorID));
|
||||
e.Damage = packet.ReadPrimitive<double>();
|
||||
// Don't rebroadcast our own player damage events or we'll have an infinite loop!
|
||||
if (e.Inflictor != m_LocalPlayer) {
|
||||
@@ -511,6 +563,7 @@ void Client::sendInputCommands()
|
||||
for (int i = 0; i < m_InputCommandBuffer.size(); i++) {
|
||||
packet.WriteString(m_InputCommandBuffer[i].Command);
|
||||
packet.WritePrimitive(m_InputCommandBuffer[i].Value);
|
||||
packet.WritePrimitive(m_InputCommandBuffer[i].TimeStamp);
|
||||
}
|
||||
m_Reliable.Send(packet);
|
||||
m_InputCommandBuffer.clear();
|
||||
|
||||
@@ -9,7 +9,7 @@ Network::Network(World* world, EventBroker* eventBroker)
|
||||
m_TimeoutMs = config->Get<int>("Networking.TimeoutMs", 20000);
|
||||
}
|
||||
|
||||
void Network::Update()
|
||||
void Network::Update(double dt)
|
||||
{
|
||||
updateNetworkData();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Network/Server.h"
|
||||
|
||||
Server::Server(World* world, EventBroker* eventBroker, int port)
|
||||
Server::Server(World* world, EventBroker* eventBroker, int port)
|
||||
: Network(world, eventBroker)
|
||||
{
|
||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
@@ -26,10 +26,12 @@ Server::~Server()
|
||||
|
||||
}
|
||||
|
||||
void Server::Update()
|
||||
void Server::Update(double dt)
|
||||
{
|
||||
m_EventBroker->Process<Server>();
|
||||
m_TimeStamp += dt;
|
||||
publishInputCommands();
|
||||
PlayerDefinition pd;
|
||||
|
||||
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
||||
for (auto& kv : m_ConnectedPlayers) {
|
||||
while (kv.second.TCPSocket->available()) {
|
||||
@@ -80,11 +82,9 @@ void Server::Update()
|
||||
checkForTimeOuts();
|
||||
timOutTimer = currentTime;
|
||||
}
|
||||
m_EventBroker->Process<Server>();
|
||||
if (isReadingData) {
|
||||
Network::Update();
|
||||
Network::Update(dt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Server::parseMessageType(Packet& packet)
|
||||
@@ -146,7 +146,8 @@ void Server::unreliableBroadcast(Packet& packet)
|
||||
void Server::sendSnapshot()
|
||||
{
|
||||
Packet packet(MessageType::Snapshot);
|
||||
addInputCommandsToPacket(packet);
|
||||
//addInputCommandsToPacket(packet);
|
||||
packet.WritePrimitive(m_TimeStamp/*+ somePingvalue + offset*/);
|
||||
addChildrenToPacket(packet, EntityID_Invalid);
|
||||
unreliableBroadcast(packet);
|
||||
}
|
||||
@@ -160,6 +161,7 @@ void Server::addInputCommandsToPacket(Packet& packet)
|
||||
packet.WritePrimitive(m_ConnectedPlayers.at(command.PlayerID).EntityID);
|
||||
packet.WriteString(command.Command);
|
||||
packet.WritePrimitive(command.Value);
|
||||
packet.WritePrimitive(command.TimeStamp);
|
||||
}
|
||||
m_InputCommandsToBroadcast.clear();
|
||||
}
|
||||
@@ -280,7 +282,7 @@ void Server::parseTCPConnect(Packet & packet)
|
||||
// Read packet ID
|
||||
m_PreviousPacketID = m_PacketID; // Set previous packet id
|
||||
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
||||
|
||||
|
||||
LOG_INFO("Parsing connections");
|
||||
// Check if player is already connected
|
||||
// Ska vara till lagd i TCPServer receive
|
||||
@@ -333,8 +335,10 @@ void Server::disconnect(PlayerID playerID)
|
||||
e.PlayerID = playerID;
|
||||
m_EventBroker->Publish(e);
|
||||
//m_World->DeleteEntity(m_ConnectedPlayers[playerID].EntityID);
|
||||
// TODO Kolla Anders crashade efter timeout med break point
|
||||
m_ConnectedPlayers[playerID].TCPSocket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
|
||||
m_ConnectedPlayers[playerID].TCPSocket->close();
|
||||
m_World->DeleteEntity(m_ConnectedPlayers[playerID].EntityID);
|
||||
m_ConnectedPlayers.erase(playerID);
|
||||
// Send disconnect to the other players.
|
||||
}
|
||||
@@ -374,8 +378,7 @@ bool Server::OnInputCommand(const Events::InputCommand & e)
|
||||
}
|
||||
isReadingData = !isReadingData;
|
||||
m_SaveDataTimer = std::clock();
|
||||
}
|
||||
if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||
} else if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||
kick(0);
|
||||
}
|
||||
|
||||
@@ -465,7 +468,9 @@ void Server::parseOnInputCommand(Packet& packet)
|
||||
e.PlayerID = player; // Set correct player id
|
||||
e.Player = EntityWrapper(m_World, m_ConnectedPlayers.at(player).EntityID);
|
||||
e.Value = packet.ReadPrimitive<float>();
|
||||
m_EventBroker->Publish(e);
|
||||
e.TimeStamp = packet.ReadPrimitive<double>();
|
||||
/* m_EventBroker->Publish(e);*/
|
||||
m_InputCommandsToPublish.push_back(e);
|
||||
if (e.Command == "PrimaryFire" || e.Command == "Reload") {
|
||||
m_InputCommandsToBroadcast.push_back(e);
|
||||
}
|
||||
@@ -476,6 +481,11 @@ void Server::parseOnInputCommand(Packet& packet)
|
||||
|
||||
void Server::parsePlayerTransform(Packet& packet)
|
||||
{
|
||||
PlayerID playerID = GetPlayerIDFromEndpoint();
|
||||
if (playerID == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
glm::vec3 position;
|
||||
glm::vec3 orientation;
|
||||
position.x = packet.ReadPrimitive<float>();
|
||||
@@ -485,7 +495,6 @@ void Server::parsePlayerTransform(Packet& packet)
|
||||
orientation.y = packet.ReadPrimitive<float>();
|
||||
orientation.z = packet.ReadPrimitive<float>();
|
||||
|
||||
PlayerID playerID = GetPlayerIDFromEndpoint();
|
||||
bool hasAssaultWeapon = packet.ReadPrimitive<bool>();
|
||||
int magazineAmmo;
|
||||
int ammo;
|
||||
@@ -511,6 +520,20 @@ bool Server::shouldSendToClient(EntityWrapper childEntity)
|
||||
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid();
|
||||
}
|
||||
|
||||
void Server::publishInputCommands()
|
||||
{
|
||||
std::vector<Events::InputCommand> notPublishedEvents;
|
||||
for (int i = 0; i < m_InputCommandsToPublish.size(); i++) {
|
||||
if (m_InputCommandsToPublish.at(i).TimeStamp < m_TimeStamp) {
|
||||
m_EventBroker->Publish(m_InputCommandsToPublish.at(i));
|
||||
} else {
|
||||
LOG_INFO("Did not instantly publish command");
|
||||
notPublishedEvents.push_back(m_InputCommandsToPublish.at(i));
|
||||
}
|
||||
}
|
||||
m_InputCommandsToPublish = notPublishedEvents;
|
||||
}
|
||||
|
||||
PlayerID Server::GetPlayerIDFromEndpoint()
|
||||
{
|
||||
// check both tcp and udp connection
|
||||
|
||||
@@ -121,7 +121,6 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<Animation
|
||||
|
||||
|
||||
if (progress > 1.0f || progress < 0.0f) {
|
||||
LOG_INFO("Progress: %f", progress);
|
||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
||||
}
|
||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
||||
@@ -241,7 +240,6 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<Animation
|
||||
|
||||
|
||||
if (progress > 1.0f || progress < 0.0f) {
|
||||
LOG_INFO("Progress: %f", progress);
|
||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
||||
}
|
||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
||||
@@ -489,7 +487,6 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v
|
||||
|
||||
|
||||
if (progress > 1.0f || progress < 0.0f) {
|
||||
LOG_INFO("Progress: %f", progress);
|
||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
||||
}
|
||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
||||
@@ -609,12 +606,10 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v
|
||||
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
|
||||
} else {
|
||||
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (progress > 1.0f || progress < 0.0f) {
|
||||
LOG_INFO("Progress: %f", progress);
|
||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
||||
}
|
||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
||||
|
||||
+2
-2
@@ -199,10 +199,10 @@ void Game::Tick()
|
||||
// Update network
|
||||
m_EventBroker->Process<MultiplayerSnapshotFilter>();
|
||||
if (m_NetworkClient != nullptr) {
|
||||
m_NetworkClient->Update();
|
||||
m_NetworkClient->Update(dt);
|
||||
}
|
||||
if (m_NetworkServer != nullptr) {
|
||||
m_NetworkServer->Update();
|
||||
m_NetworkServer->Update(dt);
|
||||
}
|
||||
//m_SoundManager->Update(dt);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ bool MultiplayerSnapshotFilter::FilterComponent(EntityWrapper entity, SharedComp
|
||||
|| component.Info.Name == "AssaultWeapon"
|
||||
|| component.Info.Name == "Animation"
|
||||
|| component.Info.Name == "AnimationOffset"
|
||||
|| entity.Name() == "PlayerName"
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
//if (e.Victim != LocalPlayer) {
|
||||
// return false;
|
||||
//}
|
||||
if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
||||
if (e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ bool HealthSystem::OnInputCommand(Events::InputCommand& e)
|
||||
{
|
||||
if (e.Command == "TakeDamage" && e.Value > 0 && LocalPlayer.Valid()) {
|
||||
Events::PlayerDamage ev;
|
||||
ev.Inflictor = LocalPlayer;
|
||||
ev.Victim = LocalPlayer;
|
||||
ev.Damage = e.Value;
|
||||
m_EventBroker->Publish(ev);
|
||||
|
||||
@@ -16,7 +16,9 @@ PlayerMovementSystem::~PlayerMovementSystem()
|
||||
void PlayerMovementSystem::Update(double dt)
|
||||
{
|
||||
updateMovementControllers(dt);
|
||||
updateVelocity(dt);
|
||||
if (LocalPlayer.Valid()) {
|
||||
updateVelocity(LocalPlayer, dt);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
@@ -79,18 +81,18 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
}
|
||||
glm::vec3& velocity = cPhysics["Velocity"];
|
||||
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||
ImGui::Text(isOnGround ? "On ground" : "In air");
|
||||
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
|
||||
//ImGui::Text(isOnGround ? "On ground" : "In air");
|
||||
//ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
|
||||
glm::vec3 groundVelocity(0.f, 0.f, 0.f);
|
||||
groundVelocity.x = velocity.x;
|
||||
groundVelocity.z = velocity.z;
|
||||
ImGui::Text("groundVelocity: (%f, %f, %f) |%f|", groundVelocity.x, groundVelocity.y, groundVelocity.z, glm::length(groundVelocity));
|
||||
ImGui::Text("wishDirection: (%f, %f, %f) |%f|", wishDirection.x, wishDirection.y, wishDirection.z, glm::length(wishDirection));
|
||||
//ImGui::Text("groundVelocity: (%f, %f, %f) |%f|", groundVelocity.x, groundVelocity.y, groundVelocity.z, glm::length(groundVelocity));
|
||||
//ImGui::Text("wishDirection: (%f, %f, %f) |%f|", wishDirection.x, wishDirection.y, wishDirection.z, glm::length(wishDirection));
|
||||
float currentSpeedProj = glm::dot(groundVelocity, wishDirection);
|
||||
float addSpeed = wishSpeed - currentSpeedProj;
|
||||
ImGui::Text("currentSpeedProj: %f", currentSpeedProj);
|
||||
ImGui::Text("wishSpeed: %f", wishSpeed);
|
||||
ImGui::Text("addSpeed: %f", addSpeed);
|
||||
//ImGui::Text("currentSpeedProj: %f", currentSpeedProj);
|
||||
//ImGui::Text("wishSpeed: %f", wishSpeed);
|
||||
//ImGui::Text("addSpeed: %f", addSpeed);
|
||||
|
||||
if (addSpeed > 0) {
|
||||
static float accel = 15.f;
|
||||
@@ -221,15 +223,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
}
|
||||
|
||||
|
||||
void PlayerMovementSystem::updateVelocity(double dt)
|
||||
void PlayerMovementSystem::updateVelocity(EntityWrapper player, double dt)
|
||||
{
|
||||
// Only apply velocity to local player
|
||||
if (!LocalPlayer.Valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ComponentWrapper& cTransform = LocalPlayer["Transform"];
|
||||
ComponentWrapper& cPhysics = LocalPlayer["Physics"];
|
||||
ComponentWrapper& cTransform = player["Transform"];
|
||||
ComponentWrapper& cPhysics = player["Physics"];
|
||||
glm::vec3& velocity = cPhysics["Velocity"];
|
||||
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||
|
||||
|
||||
@@ -128,6 +128,12 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
// When a player is actually spawned (since the actual spawning is handled on the server)
|
||||
// Hack should be moved.
|
||||
|
||||
// TODO: Set the player name to whatever
|
||||
EntityWrapper playerName = e.Player.FirstChildByName("PlayerName");
|
||||
if (playerName.Valid()) {
|
||||
playerName["Text"]["Content"] = e.PlayerName;
|
||||
}
|
||||
|
||||
if (!IsClient) {
|
||||
return false;
|
||||
}
|
||||
@@ -153,12 +159,6 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Set the player name to whatever
|
||||
EntityWrapper playerName = e.Player.FirstChildByName("PlayerName");
|
||||
if (playerName.Valid()) {
|
||||
playerName["Text"]["Content"] = e.PlayerName;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -181,10 +181,10 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||
return false;
|
||||
}
|
||||
|
||||
SpawnRequest req;
|
||||
req.PlayerID = m_PlayerIDs.at(e.Player.ID);
|
||||
req.Team = cTeam["Team"];
|
||||
m_SpawnRequests.push_back(req);
|
||||
SpawnRequest req;
|
||||
req.PlayerID = m_PlayerIDs.at(e.Player.ID);
|
||||
req.Team = cTeam["Team"];
|
||||
m_SpawnRequests.push_back(req);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user