Add Votekick functionality (#32005)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Lidgren.Network;
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace Content.Shared.Voting
|
||||
public (ushort votes, string name)[] Options = default!;
|
||||
public bool IsYourVoteDirty;
|
||||
public byte? YourVote;
|
||||
public bool DisplayVotes;
|
||||
public int TargetEntity;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
|
||||
{
|
||||
@@ -31,6 +33,8 @@ namespace Content.Shared.Voting
|
||||
VoteInitiator = buffer.ReadString();
|
||||
StartTime = TimeSpan.FromTicks(buffer.ReadInt64());
|
||||
EndTime = TimeSpan.FromTicks(buffer.ReadInt64());
|
||||
DisplayVotes = buffer.ReadBoolean();
|
||||
TargetEntity = buffer.ReadVariableInt32();
|
||||
|
||||
Options = new (ushort votes, string name)[buffer.ReadByte()];
|
||||
for (var i = 0; i < Options.Length; i++)
|
||||
@@ -58,6 +62,8 @@ namespace Content.Shared.Voting
|
||||
buffer.Write(VoteInitiator);
|
||||
buffer.Write(StartTime.Ticks);
|
||||
buffer.Write(EndTime.Ticks);
|
||||
buffer.Write(DisplayVotes);
|
||||
buffer.WriteVariableInt32(TargetEntity);
|
||||
|
||||
buffer.Write((byte) Options.Length);
|
||||
foreach (var (votes, name) in Options)
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
namespace Content.Shared.Voting
|
||||
namespace Content.Shared.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// Standard vote types that players can initiate themselves from the escape menu.
|
||||
/// </summary>
|
||||
public enum StandardVoteType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard vote types that players can initiate themselves from the escape menu.
|
||||
/// Vote to restart the round.
|
||||
/// </summary>
|
||||
public enum StandardVoteType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Vote to restart the round.
|
||||
/// </summary>
|
||||
Restart,
|
||||
Restart,
|
||||
|
||||
/// <summary>
|
||||
/// Vote to change the game preset for next round.
|
||||
/// </summary>
|
||||
Preset,
|
||||
/// <summary>
|
||||
/// Vote to change the game preset for next round.
|
||||
/// </summary>
|
||||
Preset,
|
||||
|
||||
/// <summary>
|
||||
/// Vote to change the map for the next round.
|
||||
/// </summary>
|
||||
Map
|
||||
}
|
||||
/// <summary>
|
||||
/// Vote to change the map for the next round.
|
||||
/// </summary>
|
||||
Map,
|
||||
|
||||
/// <summary>
|
||||
/// Vote to kick a player.
|
||||
/// </summary>
|
||||
Votekick
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reasons available to initiate a votekick.
|
||||
/// </summary>
|
||||
public enum VotekickReasonType : byte
|
||||
{
|
||||
Raiding,
|
||||
Cheating,
|
||||
Spam
|
||||
}
|
||||
|
||||
30
Content.Shared/Voting/VotingEvents.cs
Normal file
30
Content.Shared/Voting/VotingEvents.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Voting;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class VotePlayerListRequestEvent : EntityEventArgs
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class VotePlayerListResponseEvent : EntityEventArgs
|
||||
{
|
||||
public VotePlayerListResponseEvent((NetUserId, NetEntity, string)[] players, bool denied)
|
||||
{
|
||||
Players = players;
|
||||
Denied = denied;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The players available to have a votekick started for them.
|
||||
/// </summary>
|
||||
public (NetUserId, NetEntity, string)[] Players { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server will allow the user to start a votekick or not.
|
||||
/// </summary>
|
||||
public bool Denied;
|
||||
}
|
||||
Reference in New Issue
Block a user