2023-04-25 19:46:20 +06:00
|
|
|
using System.IO;
|
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
using Lidgren.Network;
|
|
|
|
|
using Robust.Shared.Network;
|
|
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
2024-01-28 18:37:24 +07:00
|
|
|
namespace Content.Shared._White.Sponsors;
|
2023-04-25 19:46:20 +06:00
|
|
|
|
2023-05-01 17:32:16 +06:00
|
|
|
public enum WhiteSponsorTier
|
|
|
|
|
{
|
|
|
|
|
DJ = 5,
|
|
|
|
|
ROBUSTER = 4,
|
|
|
|
|
CLOWN = 3,
|
|
|
|
|
PRIKOLIST = 2,
|
|
|
|
|
MEATYORE = 1
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 19:46:20 +06:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class SponsorInfo
|
|
|
|
|
{
|
|
|
|
|
[JsonPropertyName("tier")]
|
|
|
|
|
public int? Tier { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("oocColor")]
|
|
|
|
|
public string? OOCColor { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("priorityJoin")]
|
|
|
|
|
public bool HavePriorityJoin { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("allowedMarkings")]
|
|
|
|
|
public string[] AllowedMarkings { get; set; } = Array.Empty<string>();
|
2023-04-28 01:06:54 +06:00
|
|
|
|
|
|
|
|
[JsonPropertyName("extraSlots")]
|
|
|
|
|
public int ExtraSlots { get; set; }
|
2023-04-28 06:07:50 +06:00
|
|
|
|
|
|
|
|
[JsonPropertyName("MeatyOreCoin")]
|
|
|
|
|
public int MeatyOreCoin { get; set; }
|
2024-10-13 19:11:01 +03:00
|
|
|
|
|
|
|
|
[JsonPropertyName("antagChance")]
|
|
|
|
|
public int AntagChance { get; set; }
|
2023-04-25 19:46:20 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Server sends sponsoring info to client on connect only if user is sponsor
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class MsgSponsorInfo : NetMessage
|
|
|
|
|
{
|
|
|
|
|
public override MsgGroups MsgGroup => MsgGroups.Command;
|
|
|
|
|
|
|
|
|
|
public SponsorInfo? Info;
|
|
|
|
|
|
|
|
|
|
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
|
|
|
|
|
{
|
|
|
|
|
var isSponsor = buffer.ReadBoolean();
|
|
|
|
|
buffer.ReadPadBits();
|
|
|
|
|
|
|
|
|
|
if (!isSponsor)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var length = buffer.ReadVariableInt32();
|
|
|
|
|
using var stream = new MemoryStream(length);
|
|
|
|
|
buffer.ReadAlignedMemory(stream, length);
|
|
|
|
|
serializer.DeserializeDirect(stream, out Info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
|
|
|
|
|
{
|
|
|
|
|
buffer.Write(Info != null);
|
|
|
|
|
buffer.WritePadBits();
|
|
|
|
|
|
|
|
|
|
if (Info == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var stream = new MemoryStream();
|
|
|
|
|
serializer.SerializeDirect(stream, Info);
|
|
|
|
|
buffer.WriteVariableInt32((int) stream.Length);
|
|
|
|
|
buffer.Write(stream.AsSpan());
|
|
|
|
|
}
|
|
|
|
|
}
|