-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added per player difficulties and per player modifier packets
- Loading branch information
1 parent
cc72d7c
commit 5dd6876
Showing
7 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...tedServer.Kernel/PacketHandlers/MultiplayerSession/MultiplayerCore/GetPerPlayerHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using BeatTogether.DedicatedServer.Ignorance.IgnoranceCore; | ||
using BeatTogether.DedicatedServer.Kernel.Abstractions; | ||
using BeatTogether.DedicatedServer.Kernel.Configuration; | ||
using BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MpCorePackets; | ||
using Serilog; | ||
|
||
namespace BeatTogether.DedicatedServer.Kernel.PacketHandlers.MultiplayerSession.MenuRpc | ||
{ | ||
class GetPerPlayerHandler : BasePacketHandler<GetPerPlayer> | ||
{ | ||
private InstanceConfiguration _configuration; | ||
private readonly IPacketDispatcher _PacketDispatcher; | ||
private readonly ILogger _logger = Log.ForContext<GetPerPlayerHandler>(); | ||
|
||
public GetPerPlayerHandler( | ||
IPacketDispatcher PacketDispatcher, | ||
InstanceConfiguration configuration) | ||
{ | ||
_PacketDispatcher = PacketDispatcher; | ||
_configuration = configuration; | ||
} | ||
|
||
public override void Handle(IPlayer sender, GetPerPlayer packet) | ||
{ | ||
|
||
_logger.Debug( | ||
$"Handling packet of type '{nameof(GetPerPlayer)}' " + | ||
$"(SenderId={sender.ConnectionId})." | ||
); | ||
_PacketDispatcher.SendToPlayer(sender, new PerPlayer() | ||
{ | ||
PPDEnabled = _configuration.AllowPerPlayerDifficulties, | ||
PPMEnabled = _configuration.AllowPerPlayerModifiers, | ||
}, IgnoranceChannelTypes.Reliable); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...icatedServer.Kernel/PacketHandlers/MultiplayerSession/MultiplayerCore/PerPlayerHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using BeatTogether.DedicatedServer.Ignorance.IgnoranceCore; | ||
using BeatTogether.DedicatedServer.Kernel.Abstractions; | ||
using BeatTogether.DedicatedServer.Kernel.Configuration; | ||
using BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MpCorePackets; | ||
using Serilog; | ||
|
||
namespace BeatTogether.DedicatedServer.Kernel.PacketHandlers.MultiplayerSession.MenuRpc | ||
{ | ||
class PerPlayerHandler : BasePacketHandler<PerPlayer> | ||
{ | ||
private InstanceConfiguration _configuration; | ||
private readonly IPacketDispatcher _PacketDispatcher; | ||
private readonly ILogger _logger = Log.ForContext<GetPerPlayerHandler>(); | ||
|
||
public PerPlayerHandler( | ||
IPacketDispatcher PacketDispatcher, | ||
InstanceConfiguration configuration) | ||
{ | ||
_PacketDispatcher = PacketDispatcher; | ||
_configuration = configuration; | ||
} | ||
|
||
public override void Handle(IPlayer sender, PerPlayer packet) | ||
{ | ||
|
||
_logger.Debug( | ||
$"Handling packet of type '{nameof(PerPlayer)}' " + | ||
$"(SenderId={sender.ConnectionId})." | ||
); | ||
if(sender.IsServerOwner) | ||
{ | ||
_configuration.AllowPerPlayerDifficulties = packet.PPDEnabled; | ||
_configuration.AllowPerPlayerModifiers = packet.PPMEnabled; | ||
_PacketDispatcher.SendToNearbyPlayers(new PerPlayer() | ||
{ | ||
PPDEnabled = _configuration.AllowPerPlayerDifficulties, | ||
PPMEnabled = _configuration.AllowPerPlayerModifiers, | ||
}, IgnoranceChannelTypes.Reliable); | ||
} | ||
|
||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...gether.DedicatedServer.Messaging/Packets/MultiplayerSession/MpCorePackets/GetPerPlayer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using BeatTogether.DedicatedServer.Messaging.Abstractions; | ||
using BeatTogether.DedicatedServer.Messaging.Util; | ||
|
||
namespace BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MpCorePackets | ||
{ | ||
public sealed class GetPerPlayer : INetSerializable | ||
{ | ||
public void ReadFrom(ref SpanBuffer bufferReader) | ||
{ | ||
} | ||
|
||
public void WriteTo(ref SpanBuffer bufferWriter) | ||
{ | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
BeatTogether.DedicatedServer.Messaging/Packets/MultiplayerSession/MpCorePackets/PerPlayer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using BeatTogether.DedicatedServer.Messaging.Abstractions; | ||
using BeatTogether.DedicatedServer.Messaging.Util; | ||
|
||
namespace BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MpCorePackets | ||
{ | ||
public sealed class PerPlayer : INetSerializable | ||
{ | ||
public bool PPDEnabled; | ||
public bool PPMEnabled; | ||
|
||
public void ReadFrom(ref SpanBuffer bufferReader) | ||
{ | ||
PPDEnabled = bufferReader.ReadBool(); | ||
PPMEnabled = bufferReader.ReadBool(); | ||
} | ||
|
||
public void WriteTo(ref SpanBuffer bufferWriter) | ||
{ | ||
bufferWriter.WriteBool(PPDEnabled); | ||
bufferWriter.WriteBool(PPMEnabled); | ||
} | ||
} | ||
} |