Compare commits

...

36 Commits

Author SHA1 Message Date
Tobias Dahl 7fa634ef7c Revert "Shadow will actually shut itself off and delete itself now" 2016-03-13 21:35:57 +01:00
Tobias Dahl 080f5ac856 Merge pull request #216 from teamfisk/ShadowOptimization
Shadow will actually shut itself off and delete itself now
2016-03-13 21:32:42 +01:00
Jace 4ecbef59bf Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-13 21:29:59 +01:00
Jace 8a1217e8b5 Hoodwinked GLFW into creating a fullscreen windowed window by initializing it one pixel higher than the resolution height 2016-03-13 21:29:39 +01:00
FakeShemp 8e150da7ff Use CommonFunctions::DeleteTexture() instead 2016-03-13 21:25:04 +01:00
William Moberg c790b952fb Merge pull request #214 from teamfisk/PerfectSoundForRelease
Perfect sound for release
2016-03-13 21:01:21 +01:00
antc13 be3d75a5cf Merge branch 'master' of https://github.com/teamfisk/TacticalZ 2016-03-13 20:48:23 +01:00
antc13 b3c935c7cc Fixed rotation/translation on some objects on CP_Rocky2. They somehow got weird rotation values. 2016-03-13 20:48:05 +01:00
Jace f05b09ca7a Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-13 19:54:22 +01:00
Jace e76740d72b Point lights child of a camera no longer visible to other cameras 2016-03-13 19:53:34 +01:00
Jace d3927de7cc Super fancy new class pick, don't overwrite plz 2016-03-13 19:51:01 +01:00
stiffly fe090504cf Now listens to SetCamera event and the background music should be working properly. 2016-03-13 17:35:05 +01:00
Adam Byléhn 672d6f884d Merge pull request #215 from teamfisk/RestartMap
Added pop up for client when server timeouts.
2016-03-13 16:33:51 +01:00
Jocke 5ea0f04b20 Added pop up for client when server timeouts. 2016-03-13 16:21:55 +01:00
FakeShemp 9b5e4c10fd Shadow will actually shut itself off and delete itself now 2016-03-13 16:19:17 +01:00
stiffly fb400bb743 Merge remote-tracking branch 'origin/master' into PerfectSoundForRelease 2016-03-13 15:37:14 +01:00
stiffly aa2475dfd6 Stops bgm when the game is reset. 2016-03-13 15:36:56 +01:00
Jace 36c4837813 Merge pull request #213 from teamfisk/Dirtybit
Linker warnings fix
2016-03-13 15:29:45 +01:00
William Moberg 2fa3637018 Transform.cpp was deleted since stuff was moved to TransformSystem, takes care of linker warnings. 2016-03-13 15:26:35 +01:00
antc13 52e5e2527a Merge branch 'master' of https://github.com/teamfisk/TacticalZ 2016-03-13 15:21:44 +01:00
antc13 36253a8afd Made minor changes to light positions on CP_Rocky2. Replaced a model & changed glow value on some walls. 2016-03-13 15:21:29 +01:00
stiffly 5c343cb254 Merge remote-tracking branch 'origin/master' into PerfectSoundForRelease 2016-03-13 15:10:52 +01:00
Adam Byléhn b73595eed0 Merge pull request #210 from teamfisk/RestartMap
Restart map
2016-03-13 15:10:01 +01:00
Teejoon f9e640ffc6 Added borders to capture points so that you can see if your inside of outside when not looking down 2016-03-13 14:59:57 +01:00
stiffly f2c7a9f27a Merge remote-tracking branch 'origin/master' into PerfectSoundForRelease 2016-03-13 14:56:00 +01:00
William Moberg ac20e41a5d Fixed merge conflicts. Scoreboard updates team when a team is picked. Fixed some code standard violations and misspellings. 2016-03-13 14:23:56 +01:00
William Moberg 4f99f6ef74 Merge branch 'master' into RestartMap
# Conflicts:
#	src/Game/Systems/CapturePointSystem.cpp
2016-03-13 13:37:51 +01:00
antc13 d0a083a1e3 Fixed rotation/translation on some objects on CP_Rocky2. 2016-03-13 13:13:14 +01:00
antc13 d5f06fa8c2 Merge branch 'master' of https://github.com/teamfisk/TacticalZ 2016-03-13 12:20:36 +01:00
antc13 8bb8ebbea3 Fixed Splatmap Export 2016-03-13 12:20:25 +01:00
stiffly 20d46f63c8 The main menu music would not start again when you returned to the main menu. 2016-03-13 00:16:55 +01:00
Jocke b7d88808e2 Redid timers. 2016-03-12 21:38:46 +01:00
Jocke f8f536802f Time for ending the game is now in CapturePointGameMode component. The timer i counted down to 0 and then the map is "Reset". 2016-03-12 20:28:48 +01:00
Jocke 60df30fa59 Scoreboard is now works. 2016-03-12 19:36:12 +01:00
Jocke c544f349fd The logic for removing the world is working but when we send the map again the clients memory usage goes crazy. 2016-03-12 17:49:50 +01:00
Jocke 0c1a2d3160 WIP 2016-03-12 14:31:15 +01:00
31 changed files with 15631 additions and 10799 deletions
+1 -1
Submodule assets updated: bc6e7df04c...6ffc1ab82a
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef ECaptured_h__
#define ECaptured_h__
#ifndef Events_Captured_h__
#define Events_Captured_h__
#include "EventBroker.h"
#include "../Core/Entity.h"
+26 -22
View File
@@ -10,28 +10,32 @@
#include <boost/asio.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/MessageType.h"
#include "Network/PlayerDefinition.h"
#include "Network/UDPClient.h"
#include "Network/TCPClient.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/EConnectRequest.h"
#include "Network/EPlayerDisconnected.h"
#include "Network/ESearchForServers.h"
#include "Network/EInterpolate.h"
#include "Network/SnapshotFilter.h"
class Client : public Network
{
public:
@@ -40,7 +44,7 @@ public:
~Client();
void Connect(std::string address, int port);
void Update() override;
void Update(double dt) override;
private:
UDPClient m_Unreliable;
TCPClient m_Reliable;
@@ -74,10 +78,10 @@ private:
// Network logic
PlayerDefinition m_PlayerDefinitions[8];
SnapshotDefinitions m_NextSnapshot;
double m_DurationOfPingTime;
std::clock_t m_StartPingTime;
std::clock_t m_TimeSinceSentInputs;
unsigned int m_SendInputIntervalMs;
double m_DurationOfPingTime = 0;
double m_StartPingTime = 0;
double m_TimeSinceSentInputs = 0;
double m_SendInputInterval = 0.033;
std::vector<Events::InputCommand> m_InputCommandBuffer;
// Private member functions
@@ -100,6 +104,7 @@ private:
void parseDoubleJump(Packet& packet);
void parseDashEffect(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 parseSnapshot(Packet& packet);
void identifyPacketLoss();
@@ -109,7 +114,6 @@ private:
void sendLocalPlayerTransform();
void becomePlayer();
void displayServerlist();
void removeWorld();
void createMainMenu();
// Mapping Logic
// Returns if local EntityID exist in map
@@ -138,8 +142,8 @@ private:
UDPClient m_ServerlistRequest;
std::vector<ServerInfo> m_Serverlist;
bool m_SearchingForServers = false;
std::clock_t m_StartSearchTime;
double m_SearchingTime = 200; // Config I guess
double m_TimeSearched = 0;
double m_SearchingTime = 0.2; // Config I guess
};
#endif
+1
View File
@@ -23,6 +23,7 @@ enum class MessageType
OnDashEffect,
ServerlistRequest,
AmmoPickup,
RemoveWorld,
Invalid
};
+2 -1
View File
@@ -22,7 +22,7 @@ public:
Network(World* world, EventBroker* eventBroker);
virtual ~Network() { };
virtual void Update() = 0;
virtual void Update(double dt) = 0;
protected:
World* m_World;
@@ -40,6 +40,7 @@ protected:
void saveToFile();
void updateNetworkData();
void popNetworkSegmentOfHeader(Packet& packet);
void removeWorld();
};
#endif
+16 -8
View File
@@ -11,6 +11,7 @@
#include "Network/MessageType.h"
#include "Network/PlayerDefinition.h"
#include "Core/World.h"
#include "Core/EntityFile.h"
#include "Core/EventBroker.h"
#include "../Network/Network.h"
#include "Input/EInputCommand.h"
@@ -24,6 +25,8 @@
#include "Core/EPlayerDeath.h"
#include "Network/EPlayerConnected.h"
#include "Network/EKillDeath.h"
#include "Core/EWin.h"
#include "Game/Events/EReset.h"
class Server : public Network
{
@@ -31,7 +34,7 @@ public:
Server(World* world, EventBroker* eventBroker, int port);
~Server();
void Update() override;
void Update(double dt) override;
private:
// Network channels
@@ -41,6 +44,7 @@ private:
// dont forget to set these in the childrens receive logic
boost::asio::ip::address m_Address;
int m_Port = 27666;
bool m_GameIsOver = false;
// Sending messages to client logic
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
std::vector<PlayerID> m_PlayersToDisconnect;
@@ -48,14 +52,14 @@ private:
char readBuffer[BUFFERSIZE] = { 0 };
size_t bytesRead = 0;
// time for previouse message
std::clock_t previousePingMessage = std::clock();
std::clock_t previousSnapshotMessage = std::clock();
std::clock_t timOutTimer = std::clock();
double previousPingMessage = 0;
double previousSnapshotMessage = 0;
double timeOutTimer = 0;
// How often we send messages (milliseconds)
float pingIntervalMs;
float snapshotInterval;
int checkTimeOutInterval = 100;
// How often we send messages (seconds)
double pingInterval = 1;
double snapshotInterval = 0.05;
double checkTimeOutInterval = 0.1;
int m_NextPlayerID = 0;
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
//Timers
@@ -71,6 +75,7 @@ private:
void reliableBroadcast(Packet& packet);
void unreliableBroadcast(Packet& packet);
void sendSnapshot();
void createWorldSnapshot(Packet& packet);
void addPlayersToPacket(Packet& packet, EntityID entityID);
void addChildrenToPacket(Packet& packet, EntityID entityID);
void addInputCommandsToPacket(Packet& packet);
@@ -83,6 +88,7 @@ private:
void kick(PlayerID player);
PlayerID getPlayerIDFromEndpoint();
PlayerID getPlayerIDFromEntityID(EntityID entityID);
void resetMap();
void parsePlayerTransform(Packet& packet);
void parseOnInputCommand(Packet& packet);
void parseClientPing();
@@ -110,6 +116,8 @@ private:
bool OnAmmoPickup(const Events::AmmoPickup& e);
EventRelay<Server, Events::PlayerDeath> m_EPlayerDeath;
bool OnPlayerDeath(const Events::PlayerDeath& e);
EventRelay<Server, Events::Win> m_EWin;
bool OnWin(const Events::Win& e);
};
#endif
+3 -1
View File
@@ -30,6 +30,7 @@
#include "../Engine/Core/EPause.h"
#include "../Engine/Core/EComponentAttached.h"
#include "../Core/EPlayerSpawned.h"
#include "../Rendering/ESetCamera.h"
typedef std::pair<ALuint, std::vector<ALuint>> QueuedBuffers;
@@ -91,7 +92,6 @@ private:
void matchBGMLoop();
Source* m_CurrentBGM = nullptr;
Source* m_CurrentBGMCombo = nullptr;
bool m_DrumLoopHasBeenStarted = false;
// Logic
World* m_World = nullptr;
@@ -139,6 +139,8 @@ private:
bool OnPlayQueueOnEntity(const Events::PlayQueueOnEntity &e);
EventRelay<SoundManager, Events::ChangeBGM> m_EChangeBGM;
bool OnChangeBGM(const Events::ChangeBGM &e);
EventRelay<SoundManager, Events::SetCamera> m_ESetCamera;
bool OnSetCamera(const Events::SetCamera& e);
};
+16
View File
@@ -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 "Core/ECaptured.h"
#include "Core/EWin.h"
#include "Game/Events/EReset.h"
#include <tuple>
#include <vector>
@@ -23,6 +24,7 @@ public:
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override;
private:
void Init();
//methods which will take care of specific events
EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
@@ -30,6 +32,8 @@ private:
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
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);
bool m_WinnerWasFound = false;
+6
View File
@@ -8,6 +8,8 @@
#include "Core/EPlayerSpawned.h"
#include "Network/EPlayerConnected.h"
#include "Network/EPlayerDisconnected.h"
#include "Game/Events/EReset.h"
#include "Engine/Input/EInputCommand.h"
#include "GLM.h"
class ScoreScreenSystem : public PureSystem
@@ -25,6 +27,10 @@ public:
bool OnPlayerConnected(const Events::PlayerConnected& e);
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
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:
struct PlayerData {
@@ -4,6 +4,7 @@
#include "Core/System.h"
#include "Input/EInputCommand.h"
#include "Network/EPlayerDisconnected.h"
#include "Game/Events/EReset.h"
class SpectatorCameraSystem : public ImpureSystem
{
@@ -15,11 +16,14 @@ public:
private:
int m_PickedTeam;
bool m_CamSetToTeamPick;
void reset();
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
bool OnDisconnect(const Events::PlayerDisconnected& e);
EventRelay<SpectatorCameraSystem, Events::Reset> m_EReset;
bool OnReset(const Events::Reset& e);
};
#endif
@@ -2,4 +2,5 @@
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
<RespawnTime>0.0</RespawnTime>
<MaxRespawnTime>8.0</MaxRespawnTime>
<ResetCountdown>10.0</ResetCountdown>
</CapturePointGameMode>
@@ -12,6 +12,9 @@
<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: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:complexType>
</xs:element>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="BlueCapturepointBorde" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="0" Y="0.271661639" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Bottom">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>3</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="-0" Y="-8.74227801e-09" Z="-0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.392156869" B="10" G="0.784313738" R="0"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.5" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="LowerMid">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>2</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="0" Y="0.0866025388" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.313725501" B="10" G="0.784313738" R="0"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.899999976" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="UpperMid">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>1</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="0" Y="0.0866025463" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.196078435" B="10" G="0.784313738" R="0"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="1.29999995" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Top">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform/>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.117647059" B="10" G="0.784313738" R="0"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="1.70000005" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="RedCapturepointBorde" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="0" Y="0.271661639" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Bottom">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>3</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="-0" Y="-8.74227801e-09" Z="-0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.392156869" B="0" G="0.235294119" R="21.9607849"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.5" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="LowerMid">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>2</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="0" Y="0.0866025388" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.313725501" B="0" G="0.235294119" R="21.9607849"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.899999976" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="UpperMid">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>1</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="0" Y="0.0866025463" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.196078435" B="0" G="0.235294119" R="21.9607849"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="1.29999995" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Top">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform/>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.117647059" B="0" G="0.235294119" R="21.9607849"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="1.70000005" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="SpectatorCapturepointBorde" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="0" Y="0.271661639" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Bottom">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>3</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="-0" Y="-8.74227801e-09" Z="-0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.392156869" B="8.03921604" G="8.03921604" R="8.03921604"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.5" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="LowerMid">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>2</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="0" Y="0.0866025388" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.313725501" B="10" G="8.03921604" R="8.03921604"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.899999976" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="UpperMid">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Time>1</Time>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform>
<Position X="0" Y="0.0866025463" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.196078435" B="8.03921604" G="8.03921604" R="8.03921604"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="1.29999995" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Top">
<Components>
<c:FloatingEffect>
<Period>6</Period>
<Axis X="0" Y="1" Z="0"/>
<Amplitude>0.10000000149011612</Amplitude>
</c:FloatingEffect>
<c:Transform/>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
<Color A="0.117647059" B="8.03921604" G="8.03921604" R="8.03921604"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="1.70000005" Z="0"/>
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
File diff suppressed because it is too large Load Diff
-162
View File
@@ -1,162 +0,0 @@
#include "Core/TransformSystem.h"
std::unordered_map<EntityWrapper, glm::vec3> TransformSystem::PositionCache;
std::unordered_map<EntityWrapper, glm::quat> TransformSystem::OrientationCache;
std::unordered_map<EntityWrapper, glm::vec3> TransformSystem::ScaleCache;
std::unordered_map<EntityWrapper, glm::mat4> TransformSystem::MatrixCache;
int TransformSystem::RecalculatedPositions = 0;
int TransformSystem::RecalculatedOrientations = 0;
int TransformSystem::RecalculatedScales = 0;
TransformSystem::TransformSystem(SystemParams params)
: System(params)
{
EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &TransformSystem::OnEntityDeleted);
}
bool TransformSystem::OnEntityDeleted(const Events::EntityDeleted& e)
{
// Clean up deleted entity
PositionCache.erase(e.DeletedEntity);
OrientationCache.erase(e.DeletedEntity);
ScaleCache.erase(e.DeletedEntity);
MatrixCache.erase(e.DeletedEntity);
return true;
}
//glm::mat4 Transform::AbsoluteTransformation(EntityWrapper entity)
//{
// glm::mat4 t = glm::mat4(1.f);
//
// while (entity.Valid()) {
// t = glm::translate((const glm::vec3&)entity["Transform"]["Position"]) * glm::toMat4(glm::quat((const glm::vec3&)entity["Transform"]["Orientation"])) * glm::scale((const glm::vec3&)entity["Transform"]["Scale"]) * t;
// entity = entity.Parent();
// }
//
// return t;
//}
glm::vec3 TransformSystem::AbsolutePosition(World* world, EntityID entity)
{
return TransformSystem::AbsolutePosition(EntityWrapper(world, entity));
}
glm::vec3 TransformSystem::AbsolutePosition(EntityWrapper entity)
{
if (!entity.Valid()) {
return glm::vec3();
}
auto cacheIt = PositionCache.find(entity);
ComponentWrapper cTransform = entity["Transform"];
ComponentWrapper::SubscriptProxy cTransformPosition = cTransform["Position"];
if (cacheIt != PositionCache.end() && !cTransformPosition.Dirty(DirtySetType::Transform)) {
return cacheIt->second;
} else {
EntityWrapper parent = entity.Parent();
// Calculate position
glm::vec3 position = AbsolutePosition(parent) + TransformSystem::AbsoluteOrientation(parent) * (TransformSystem::AbsoluteScale(parent) * (const glm::vec3&)cTransformPosition);
// Cache it
PositionCache[entity] = position;
RecalculatedPositions++;
// Unset dirty flag
cTransformPosition.SetDirty(DirtySetType::Transform, false);
return position;
}
}
glm::vec3 TransformSystem::AbsoluteOrientationEuler(EntityWrapper entity)
{
glm::vec3 orientation;
while (entity.Valid()) {
ComponentWrapper transform = entity["Transform"];
orientation += (Field<glm::vec3>)transform["Orientation"];
entity = entity.Parent();
}
return orientation;
}
glm::quat TransformSystem::AbsoluteOrientation(World* world, EntityID entity)
{
return TransformSystem::AbsoluteOrientation(EntityWrapper(world, entity));
}
glm::quat TransformSystem::AbsoluteOrientation(EntityWrapper entity)
{
if (!entity.Valid()) {
return glm::quat();
}
auto cacheIt = OrientationCache.find(entity);
ComponentWrapper cTransform = entity["Transform"];
ComponentWrapper::SubscriptProxy cTransformOrientation = cTransform["Orientation"];
if (cacheIt != OrientationCache.end() && !cTransformOrientation.Dirty(DirtySetType::Transform)) {
return cacheIt->second;
} else {
EntityWrapper parent = entity.Parent();
// Calculate orientation
glm::quat orientation = AbsoluteOrientation(parent) * glm::quat((const glm::vec3&)cTransformOrientation);
// Cache it
OrientationCache[entity] = orientation;
RecalculatedOrientations++;
// Unset dirty flag
cTransformOrientation.SetDirty(DirtySetType::Transform, false);
return orientation;
}
}
glm::vec3 TransformSystem::AbsoluteScale(World* world, EntityID entity)
{
return TransformSystem::AbsoluteScale(EntityWrapper(world, entity));
}
glm::vec3 TransformSystem::AbsoluteScale(EntityWrapper entity)
{
if (!entity.Valid()) {
return glm::vec3(1.f);
}
auto cacheIt = ScaleCache.find(entity);
ComponentWrapper cTransform = entity["Transform"];
ComponentWrapper::SubscriptProxy cTransformScale = cTransform["Scale"];
if (cacheIt != ScaleCache.end() && !cTransformScale.Dirty(DirtySetType::Transform)) {
return cacheIt->second;
} else {
EntityWrapper parent = entity.Parent();
// Calculate scale
glm::vec3 scale = AbsoluteScale(parent) * (const glm::vec3&)cTransformScale;
// Cache it
ScaleCache[entity] = scale;
RecalculatedPositions++;
// Unset dirty flag
cTransformScale.SetDirty(DirtySetType::Transform, false);
return scale;
}
}
glm::mat4 TransformSystem::ModelMatrix(EntityID entityID, World* world)
{
return ModelMatrix(EntityWrapper(world, entityID));
}
glm::mat4 TransformSystem::ModelMatrix(EntityWrapper entity)
{
auto cacheIt = MatrixCache.find(entity);
ComponentWrapper cTransform = entity["Transform"];
bool isDirty = cTransform["Position"].Dirty(DirtySetType::Transform) || cTransform["Orientation"].Dirty(DirtySetType::Transform) || cTransform["Scale"].Dirty(DirtySetType::Transform);
if (cacheIt != MatrixCache.end() && !isDirty) {
return cacheIt->second;
} else {
glm::mat4 matrix = glm::translate(AbsolutePosition(entity)) * glm::toMat4(AbsoluteOrientation(entity)) * glm::scale(AbsoluteScale(entity));
MatrixCache[entity] = matrix;
return matrix;
}
}
glm::vec3 TransformSystem::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
{
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
}
+31 -22
View File
@@ -1,5 +1,5 @@
#include "Network/Client.h"
#include "Network/EPlayerDisconnected.h"
using namespace boost::asio::ip;
Client::Client(World* world, EventBroker* eventBroker)
@@ -12,7 +12,7 @@ Client::Client(World* world, EventBroker* eventBroker)
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
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");
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>();
while (m_Unreliable.IsSocketAvailable()) {
@@ -85,7 +85,9 @@ void Client::Update()
}
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;
//displayServerlist();
Events::DisplayServerlist e;
@@ -96,16 +98,25 @@ void Client::Update()
if (m_IsConnected) {
// 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();
m_TimeSinceSentInputs = std::clock();
m_TimeSinceSentInputs = 0;
}
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages
sendLocalPlayerTransform();
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)
@@ -159,6 +170,9 @@ void Client::parseMessageType(Packet& packet)
case MessageType::AmmoPickup:
parseAmmoPickup(packet);
break;
case MessageType::RemoveWorld:
parseRemoveWorld(packet);
break;
default:
break;
}
@@ -190,7 +204,7 @@ void Client::parseTCPConnect(Packet& packet)
packet.WritePrimitive(m_PlayerID);
m_Unreliable.Send(packet);
// LOG_INFO("Sent UDP Connect Server");
// LOG_INFO("Sent UDP Connect Server");
}
void Client::parsePlayerConnected(Packet & packet)
@@ -336,6 +350,13 @@ void Client::parseAmmoPickup(Packet & packet)
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)
{
for (auto field : componentInfo.FieldsInOrder) {
@@ -583,7 +604,7 @@ bool Client::OnConnectRequest(const Events::ConnectRequest& e)
bool Client::OnSearchForServers(const Events::SearchForServers& e)
{
m_SearchingForServers = true;
m_StartSearchTime = std::clock();
m_TimeSearched = 0;
m_Serverlist.clear();
Packet packet(MessageType::ServerlistRequest);
m_ServerlistRequest.Broadcast(packet, 13); // TODO: Config
@@ -663,6 +684,7 @@ void Client::hasServerTimedOut()
if (timeSincePing > m_TimeoutMs) {
// Clear everything and go to menu.
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
ImGui::OpenPopup("Disconnected");
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()
{
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/StartMenu.xml");
+13 -1
View File
@@ -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();
}
@@ -92,3 +92,15 @@ void Network::popNetworkSegmentOfHeader(Packet & packet)
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]);
}
}
+62 -15
View File
@@ -5,8 +5,8 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
, m_ServerlistRequest(13)
{
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
snapshotInterval = config->Get<float>("Networking.SnapshotInterval", 0.05);
pingInterval = config->Get<float>("Networking.PingIntervalMs", 1000) / 1000.0;
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
// 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_EAmmoPickup, &Server::OnAmmoPickup);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath);
EVENT_SUBSCRIBE_MEMBER(m_EWin, &Server::OnWin);
// BindWW
if (port == 0) {
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);
@@ -86,26 +87,44 @@ void Server::Update()
}
m_PlayersToDisconnect.clear();
std::clock_t currentTime = std::clock();
// Send snapshot
if (snapshotInterval < (1000 * (currentTime - previousSnapshotMessage) / (double)CLOCKS_PER_SEC)) {
previousSnapshotMessage += dt;
if (snapshotInterval < previousSnapshotMessage) {
sendSnapshot();
previousSnapshotMessage = currentTime;
previousSnapshotMessage = 0;
}
// Send pings each
if (pingIntervalMs < (1000 * (currentTime - previousePingMessage) / (double)CLOCKS_PER_SEC)) {
previousPingMessage += dt;
if (pingInterval < previousPingMessage) {
sendPing();
previousePingMessage = currentTime;
previousPingMessage = 0;
}
// Time out logic
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
timeOutTimer += dt;
if (checkTimeOutInterval < timeOutTimer) {
checkForTimeOuts();
timOutTimer = currentTime;
timeOutTimer = 0;
}
m_EventBroker->Process<Server>();
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)
{
m_Unreliable.SendToConnectedPlayers(packet, m_ConnectedPlayers);
m_Unreliable.SendToConnectedPlayers(packet, m_ConnectedPlayers);
}
// Send snapshot fields
@@ -173,10 +192,16 @@ void Server::sendSnapshot()
Packet packet(MessageType::Snapshot);
addInputCommandsToPacket(packet);
addPlayersToPacket(packet, EntityID_Invalid);
//addChildrenToPacket(packet, EntityID_Invalid);
unreliableBroadcast(packet);
}
// Send snapshot fields
void Server::createWorldSnapshot(Packet& packet)
{
addInputCommandsToPacket(packet);
addChildrenToPacket(packet, EntityID_Invalid);
}
void Server::addInputCommandsToPacket(Packet& packet)
{
// Number of input commands
@@ -379,8 +404,7 @@ void Server::parseTCPConnect(Packet & packet)
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
Packet firstSnapshot(MessageType::Snapshot);
addInputCommandsToPacket(firstSnapshot);
addChildrenToPacket(firstSnapshot, EntityID_Invalid);
createWorldSnapshot(firstSnapshot);
m_Reliable.Send(firstSnapshot);
// Send notification that a player has connected
@@ -542,6 +566,13 @@ bool Server::OnPlayerDeath(const Events::PlayerDeath& e)
return false;
}
bool Server::OnWin(const Events::Win & e)
{
// Postpone the gameover reset
m_GameIsOver = true;
return true;
}
void Server::parseClientPing()
{
LOG_INFO("%i: Parsing ping", m_PacketID);
@@ -663,4 +694,20 @@ PlayerID Server::getPlayerIDFromEntityID(EntityID entityID)
}
}
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);
}
+5
View File
@@ -362,6 +362,11 @@ void RenderSystem::fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs,
continue;
}
EntityWrapper entity(world, pointlightC.EntityID);
if (!isEntityVisible(entity)) {
continue;
}
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World));
jobs.push_back(pointLightJob);
}
+12 -3
View File
@@ -67,10 +67,19 @@ void Renderer::InitializeWindow()
// Create a window
GLFWmonitor* monitor = nullptr;
if (m_Fullscreen) {
monitor = glfwGetPrimaryMonitor();
//monitor = glfwGetPrimaryMonitor();
//const GLFWvidmode* mode = glfwGetVideoMode(monitor);
//glfwWindowHint(GLFW_RED_BITS, mode->redBits);
//glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
//glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
//glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
glfwWindowHint(GLFW_DECORATED, false);
glfwWindowHint(GLFW_AUTO_ICONIFY, false);
}
//glfwWindowHint(GLFW_SAMPLES, 8);
m_Window = glfwCreateWindow(m_Resolution.Width, m_Resolution.Height, "daydream", monitor, nullptr);
//glfwWindowHint(GLFW_SAMPLES, 8);
m_Window = glfwCreateWindow(m_Resolution.Width, m_Resolution.Height + 1, "daydream", monitor, nullptr);
if (!m_Window) {
LOG_ERROR("GLFW: Failed to create window");
exit(EXIT_FAILURE);
+38 -21
View File
@@ -30,10 +30,7 @@ SoundManager::SoundManager(World* world, EventBroker* eventBroker)
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundManager::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_EPlayQueueOnEntity, &SoundManager::OnPlayQueueOnEntity);
EVENT_SUBSCRIBE_MEMBER(m_EChangeBGM, &SoundManager::OnChangeBGM);
Events::ChangeBGM e;
e.FilePath = "Audio/bgm/MenuMusic.wav";
m_EventBroker->Publish(e);
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &SoundManager::OnSetCamera);
}
SoundManager::~SoundManager()
@@ -67,8 +64,7 @@ void SoundManager::Update(double dt)
deleteInactiveEmitters();
updateEmitters(dt);
updateListener(dt);
if (m_DrumLoopHasBeenStarted)
matchBGMLoop();
matchBGMLoop();
}
void SoundManager::deleteInactiveEmitters()
@@ -363,15 +359,6 @@ bool SoundManager::OnPlayerSpawned(const Events::PlayerSpawned &e)
{
if (e.PlayerID == -1) { // Local player
m_LocalPlayer = e.Player;
if (m_DrumLoopHasBeenStarted) {
return true;
}
m_CurrentBGMCombo = createSource("Audio/BGM/Layer2.wav");
m_CurrentBGMCombo->Type = SoundType::BGM;
alSourcei(m_CurrentBGMCombo->ALsource, AL_LOOPING, 1);
setGain(m_CurrentBGMCombo, 0);
playSound(m_CurrentBGMCombo);
m_DrumLoopHasBeenStarted = true;
return true;
}
return false;
@@ -394,7 +381,9 @@ bool SoundManager::OnPlayQueueOnEntity(const Events::PlayQueueOnEntity &e)
bool SoundManager::OnChangeBGM(const Events::ChangeBGM &e)
{
if (m_CurrentBGM != nullptr) {
stopSound(m_CurrentBGM);
if (getSourceState(m_CurrentBGM->ALsource) == AL_PLAYING) {
stopSound(m_CurrentBGM);
}
}
m_CurrentBGM = createSource(e.FilePath);
m_CurrentBGM->Type = SoundType::BGM;
@@ -403,6 +392,34 @@ bool SoundManager::OnChangeBGM(const Events::ChangeBGM &e)
return true;
}
bool SoundManager::OnSetCamera(const Events::SetCamera& e)
{
if (e.CameraEntity.Name() == "Overview_Camera_Start_Menu") {
if (m_CurrentBGMCombo != nullptr) {
if (getSourceState(m_CurrentBGMCombo->ALsource) == AL_PLAYING) {
stopSound(m_CurrentBGMCombo);
}
}
Events::ChangeBGM changeBGM;
changeBGM.FilePath = "Audio/BGM/MenuMusic.wav";
m_EventBroker->Publish(changeBGM);
} else if (e.CameraEntity.Name() == "PickTeamCamera") {
Events::ChangeBGM changeBGM;
changeBGM.FilePath = "Audio/BGM/Layer1.wav";
m_EventBroker->Publish(changeBGM);
if (m_CurrentBGMCombo != nullptr) {
if (getSourceState(m_CurrentBGMCombo->ALsource) == AL_PLAYING) {
stopSound(m_CurrentBGMCombo);
}
}
m_CurrentBGMCombo = createSource("Audio/BGM/Layer2.wav");
m_CurrentBGMCombo->Type = SoundType::BGM;
alSourcei(m_CurrentBGMCombo->ALsource, AL_LOOPING, 1);
setGain(m_CurrentBGMCombo, 0);
playSound(m_CurrentBGMCombo);
}
}
ALenum SoundManager::getSourceState(ALuint source)
{
ALenum state;
@@ -419,14 +436,14 @@ void SoundManager::setSoundProperties(Source* source, ComponentWrapper* soundCom
{
float gain;
switch (source->Type) {
case SoundType::SFX:
gain = m_SFXVolumeChannel;
case SoundType::SFX:
gain = m_SFXVolumeChannel;
break;
case SoundType::BGM:
case SoundType::BGM:
gain = m_BGMVolumeChannel;
break;
case SoundType::Announcer:
gain = m_AnnouncerVolumeChannel;
case SoundType::Announcer:
gain = m_AnnouncerVolumeChannel;
break;
default:
gain = 1.f;
+2 -2
View File
@@ -232,10 +232,10 @@ void Game::Tick()
PerformanceTimer::StartTimerAndStopPrevious("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);
+31 -4
View File
@@ -10,8 +10,26 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
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
@@ -24,6 +42,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
if (m_WinnerWasFound) {
return;
}
if (!capturePointEntity.Valid()) {
return;
}
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
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 (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));
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;
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform"))
{
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform")) {
if (capModel.HasComponent("Model")) {
(Field<bool>)capModel["Model"]["Visible"] = isOwner;
}
@@ -269,3 +290,9 @@ bool CapturePointSystem::OnCaptured(const Events::Captured& e)
m_ResetTimers = true;
return true;
}
bool CapturePointSystem::OnReset(const Events::Reset& e)
{
Init();
return true;
}
+24
View File
@@ -9,6 +9,8 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params)
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
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)
@@ -156,3 +158,25 @@ bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e
m_DisconnectedIdentities.push_back(e.PlayerID);
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;
}
-5
View File
@@ -30,11 +30,6 @@ bool SoundSystem::OnPlayerSpawned(const Events::PlayerSpawned &e)
Events::PlayAnonuncerVoice go;
go.FilePath = "Audio/Announcer/" + m_Announcer + "/Go.wav";
m_EventBroker->Publish(go);
{
Events::ChangeBGM ev;
ev.FilePath = "Audio/BGM/Layer1.wav";
m_EventBroker->Publish(ev);
}
}
return true;
}
+21 -5
View File
@@ -9,6 +9,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
{
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
EVENT_SUBSCRIBE_MEMBER(m_EReset, &SpectatorCameraSystem::OnReset);
}
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)
{
// Only the client should do this, and only if player is not spawned.
@@ -52,7 +61,11 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
// TODO: 1 Signifies spectator, should probably have real enum here later.
// Spectators should never end up at the class select, instead put them at the SpectatorCamera.
if (swapToClass && m_PickedTeam != 1) {
camName = "PickClassCamera";
if (m_PickedTeam == 2) {
camName = "PickClassCameraRed";
} else if (m_PickedTeam == 3) {
camName = "PickClassCameraBlue";
}
} else if (e.Command == "SwapToTeamPick") {
camName = "PickTeamCamera";
} else {
@@ -95,10 +108,13 @@ bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
// If local player gets disconnected, they should be set to
// the spectator camera next time a map loads that has one.
if (e.Entity == LocalPlayer.ID) {
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);
reset();
}
return true;
}
bool SpectatorCameraSystem::OnReset(const Events::Reset & e)
{
reset();
return true;
}
+6 -6
View File
@@ -108,7 +108,7 @@ bool Material::findColorTexture(MaterialNode& material_node, MFnDependencyNode&
return true;
} 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()));
}
}
@@ -162,9 +162,9 @@ bool Material::findNormalTexture(MaterialNode& material_node, MFnDependencyNode&
material_node.NormalMaps.push_back(newTexture);
return true;
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
MGlobal::displayInfo(MString() + "find splat map");
return findSplatTextures(material_node, material_node.NormalMaps, MFnDependencyNode(AllConnections[i].node()));
} else if (AllBumpConnections[j].node().hasFn(MFn::kLayeredTexture)) {
MGlobal::displayInfo(MString() + "found normal splat map");
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;
return true;
} 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()));
}
}
@@ -270,7 +270,7 @@ bool Material::findIncandescenceTexture(MaterialNode& material_node, MFnDependen
return true;
} 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()));
}
}