Skip to content

Commit

Permalink
Client IPlayerSession Interface. (#696)
Browse files Browse the repository at this point in the history
* Added new IPlayerSession interface to client.
Removed session interfaces out of the lame `Interfaces` namespace.

* Fixed a doc comment.
  • Loading branch information
Acruid authored and PJB3005 committed Oct 25, 2018
1 parent d8ca95d commit 307030e
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 66 deletions.
4 changes: 3 additions & 1 deletion SS14.Client.Godot/MainScene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[ext_resource path="res://SS14Loader.cs" type="Script" id=1]

[node name="MainScene" type="Node"]
[node name="MainScene" type="Node" index="0"]

script = ExtResource( 1 )


1 change: 0 additions & 1 deletion SS14.Client/BaseClient.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using SS14.Client.Interfaces;
using SS14.Client.Interfaces.GameObjects;
using SS14.Client.Interfaces.Player;
using SS14.Client.Interfaces.State;
using SS14.Client.Player;
using SS14.Client.State.States;
Expand Down
2 changes: 1 addition & 1 deletion SS14.Client/Console/ClientChatConsole.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using SS14.Client.Interfaces.GameObjects;
using SS14.Client.Interfaces.Player;
using SS14.Client.Player;
using SS14.Client.UserInterface.CustomControls;
using SS14.Shared.Console;
using SS14.Shared.GameObjects;
Expand Down
1 change: 0 additions & 1 deletion SS14.Client/GameController/GameController.IoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using SS14.Client.Interfaces.Graphics.Lighting;
using SS14.Client.Interfaces.Input;
using SS14.Client.Interfaces.Map;
using SS14.Client.Interfaces.Player;
using SS14.Client.Interfaces.ResourceManagement;
using SS14.Client.Interfaces.State;
using SS14.Client.Interfaces.UserInterface;
Expand Down
2 changes: 1 addition & 1 deletion SS14.Client/GameObjects/EntitySystems/InputSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using SS14.Client.GameObjects.Components;
using SS14.Client.Interfaces.Input;
using SS14.Client.Interfaces.Player;
using SS14.Client.Player;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.Systems;
using SS14.Shared.Input;
Expand Down
2 changes: 1 addition & 1 deletion SS14.Client/GameStates/ClientGameStateManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using SS14.Client.Interfaces;
using SS14.Client.Interfaces.GameObjects;
using SS14.Client.Interfaces.GameStates;
using SS14.Client.Interfaces.Player;
using SS14.Shared;
using SS14.Shared.GameStates;
using SS14.Shared.Interfaces.Network;
Expand All @@ -12,6 +11,7 @@
using SS14.Shared.Network.Messages;
using System.Collections.Generic;
using System.Linq;
using SS14.Client.Player;

namespace SS14.Client.GameStates
{
Expand Down
2 changes: 1 addition & 1 deletion SS14.Client/Placement/PlacementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using SS14.Client.Interfaces.Graphics.ClientEye;
using SS14.Client.Interfaces.Input;
using SS14.Client.Interfaces.Placement;
using SS14.Client.Interfaces.Player;
using SS14.Client.Interfaces.ResourceManagement;
using SS14.Client.ResourceManagement;
using SS14.Shared.Enums;
Expand All @@ -28,6 +27,7 @@
using SS14.Client.Graphics;
using SS14.Client.GameObjects;
using SS14.Client.GameObjects.EntitySystems;
using SS14.Client.Player;
using SS14.Shared.Input;
using SS14.Shared.Utility;
using SS14.Shared.Serialization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System.Collections.Generic;
using SS14.Client.Player;
using SS14.Shared.GameStates;
using SS14.Shared.Interfaces.Network;
using SS14.Shared.Network;
using SS14.Shared.Players;

namespace SS14.Client.Interfaces.Player
namespace SS14.Client.Player
{
public interface IPlayerManager
{
IEnumerable<PlayerSession> Sessions { get; }
IReadOnlyDictionary<NetSessionId, PlayerSession> SessionsDict { get; }
IEnumerable<IPlayerSession> Sessions { get; }
IReadOnlyDictionary<NetSessionId, IPlayerSession> SessionsDict { get; }

LocalPlayer LocalPlayer { get; }

Expand All @@ -22,8 +22,7 @@ public interface IPlayerManager
void Startup(INetChannel channel);
void Update(float frameTime);
void Shutdown();

//void ApplyEffects(RenderImage image);

void ApplyPlayerStates(IEnumerable<PlayerState> list);
}
}
20 changes: 20 additions & 0 deletions SS14.Client/Player/IPlayerSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using SS14.Shared.Players;

namespace SS14.Client.Player
{
/// <summary>
/// Client side session of a player.
/// </summary>
public interface IPlayerSession : ICommonSession
{
/// <summary>
/// Current name of this player.
/// </summary>
new string Name { get; set; }

/// <summary>
/// Current connection latency of this session from the server to their client.
/// </summary>
short Ping { get; set; }
}
}
38 changes: 5 additions & 33 deletions SS14.Client/Player/PlayerManager.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using SS14.Client.Interfaces;
using SS14.Client.Interfaces.Player;
using SS14.Shared;
using SS14.Shared.Configuration;
using SS14.Shared.Enums;
using SS14.Shared.GameObjects;
Expand All @@ -15,6 +12,7 @@
using SS14.Shared.IoC;
using SS14.Shared.Network;
using SS14.Shared.Network.Messages;
using SS14.Shared.Players;
using SS14.Shared.Utility;

namespace SS14.Client.Player
Expand Down Expand Up @@ -43,7 +41,7 @@ public class PlayerManager : IPlayerManager
/// <summary>
/// Active sessions of connected clients to the server.
/// </summary>
private Dictionary<NetSessionId, PlayerSession> _sessions;
private Dictionary<NetSessionId, IPlayerSession> _sessions;

/// <inheritdoc />
public int PlayerCount => _sessions.Values.Count;
Expand All @@ -55,18 +53,18 @@ public class PlayerManager : IPlayerManager
public LocalPlayer LocalPlayer { get; private set; }

/// <inheritdoc />
public IEnumerable<PlayerSession> Sessions => _sessions.Values;
public IEnumerable<IPlayerSession> Sessions => _sessions.Values;

/// <inheritdoc />
public IReadOnlyDictionary<NetSessionId, PlayerSession> SessionsDict => _sessions;
public IReadOnlyDictionary<NetSessionId, IPlayerSession> SessionsDict => _sessions;

/// <inheritdoc />
public event EventHandler PlayerListUpdated;

/// <inheritdoc />
public void Initialize()
{
_sessions = new Dictionary<NetSessionId, PlayerSession>();
_sessions = new Dictionary<NetSessionId, IPlayerSession>();

_config.RegisterCVar("player.name", "Joe Genero", CVar.ARCHIVE);

Expand Down Expand Up @@ -243,31 +241,5 @@ private void UpdatePlayerList(IEnumerable<PlayerState> remotePlayers)
PlayerListUpdated?.Invoke(this, EventArgs.Empty);
}
}
/*
private void AddEffect(PostProcessingEffectType type, float duration)
{
PostProcessingEffect e;
switch (type)
{
case PostProcessingEffectType.Blur:
e = new BlurPostProcessingEffect(duration);
e.OnExpired += EffectExpired;
_effects.Add(e);
break;
case PostProcessingEffectType.Death:
e = new DeathPostProcessingEffect(duration);
e.OnExpired += EffectExpired;
_effects.Add(e);
break;
}
}
private void EffectExpired(PostProcessingEffect effect)
{
effect.OnExpired -= EffectExpired;
if (_effects.Contains(effect))
_effects.Remove(effect);
}
*/
}
}
20 changes: 6 additions & 14 deletions SS14.Client/Player/PlayerSession.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
using SS14.Shared.Enums;
using SS14.Shared.Network;
using SS14.Shared.Players;

namespace SS14.Client.Player
{
/// <summary>
/// Client side session of a player.
/// </summary>
public class PlayerSession : ICommonSession

public class PlayerSession : IPlayerSession
{
/// <summary>
/// Status of the session.
/// </summary>
/// <inheritdoc />
public SessionStatus Status { get; set; } = SessionStatus.Connecting;

/// <inheritdoc />
public NetSessionId SessionId { get; }

/// <summary>
/// Current name of this player.
/// </summary>
/// <inheritdoc cref="IPlayerSession" />
public string Name { get; set; } = "<Unknown>";

/// <summary>
/// Current connection latency of this session from the server to their client.
/// </summary>
/// <inheritdoc />
public short Ping { get; set; }

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion SS14.Client/SS14.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
<Compile Include="Interfaces\IBaseClient.cs" />
<Compile Include="Interfaces\ISceneTreeHolder.cs" />
<Compile Include="Interfaces\Map\IClientTileDefinitionManager.cs" />
<Compile Include="Interfaces\Player\IPlayerManager.cs" />
<Compile Include="Player\IPlayerManager.cs" />
<Compile Include="Player\IPlayerSession.cs" />
<Compile Include="Interfaces\State\IStateManager.cs" />
<Compile Include="Interfaces\Utility\IRand.cs" />
<Compile Include="Log\DebugConsoleLogHandler.cs" />
Expand Down
2 changes: 1 addition & 1 deletion SS14.Client/State/States/GameScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using SS14.Client.Interfaces.Graphics.ClientEye;
using SS14.Client.Interfaces.Input;
using SS14.Client.Interfaces.Placement;
using SS14.Client.Interfaces.Player;
using SS14.Client.Interfaces.UserInterface;
using SS14.Client.UserInterface.CustomControls;
using SS14.Shared.GameObjects;
Expand All @@ -17,6 +16,7 @@
using System.Collections.Generic;
using System.Linq;
using SS14.Client.GameObjects.EntitySystems;
using SS14.Client.Player;
using SS14.Shared.Interfaces.Timing;

namespace SS14.Client.State.States
Expand Down
1 change: 0 additions & 1 deletion SS14.Client/State/States/LobbyMenu.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using SS14.Client.Console;
using SS14.Client.Interfaces.Player;
using SS14.Shared.IoC;

namespace SS14.Client.State.States
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using SS14.Client.Interfaces.Graphics.ClientEye;
using SS14.Client.Interfaces.Input;
using SS14.Client.Interfaces.Player;
using SS14.Client.UserInterface.Controls;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.IoC;
Expand All @@ -11,6 +10,7 @@
using SS14.Client.ResourceManagement;
using SS14.Client.Graphics.Drawing;
using SS14.Client.Interfaces.State;
using SS14.Client.Player;
using SS14.Client.State.States;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Utility;
Expand Down
3 changes: 3 additions & 0 deletions SS14.Shared/Players/IBaseSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace SS14.Shared.Players
/// </summary>
public interface IBaseSession
{
/// <summary>
/// The UID of this session.
/// </summary>
NetSessionId SessionId { get; }

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions SS14.UnitTesting/SS14UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
using SS14.Shared.Timers;
using SS14.Shared.Timing;
using SS14.UnitTesting.Client;
using IPlayerManager = SS14.Client.Player.IPlayerManager;

namespace SS14.UnitTesting
{
Expand Down Expand Up @@ -196,7 +197,7 @@ private void RegisterIoC()
IoCManager.Register<IEntityNetworkManager, ClientEntityNetworkManager>();
IoCManager.Register<IClientGameStateManager, ClientGameStateManager>();
IoCManager.Register<IBaseClient, BaseClient>();
IoCManager.Register<SS14.Client.Interfaces.Player.IPlayerManager, SS14.Client.Player.PlayerManager>();
IoCManager.Register<IPlayerManager, SS14.Client.Player.PlayerManager>();
IoCManager.Register<IStateManager, StateManager>();
IoCManager.Register<IUserInterfaceManager, DummyUserInterfaceManager>();
IoCManager.Register<IGameControllerProxy, GameControllerProxyDummy>();
Expand Down Expand Up @@ -228,7 +229,7 @@ private void RegisterIoC()
IoCManager.Register<IServerGameStateManager, ServerGameStateManager>();
IoCManager.Register<IReflectionManager, ServerReflectionManager>();
IoCManager.Register<IConsoleShell, ConsoleShell>();
IoCManager.Register<IPlayerManager, PlayerManager>();
IoCManager.Register<SS14.Server.Interfaces.Player.IPlayerManager, PlayerManager>();
IoCManager.Register<IComponentFactory, ServerComponentFactory>();
IoCManager.Register<IBaseServer, BaseServer>();
IoCManager.Register<IMapLoader, MapLoader>();
Expand Down

0 comments on commit 307030e

Please sign in to comment.