using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Research.Components { [RegisterComponent, NetworkedComponent] public sealed class ResearchServerComponent : Component { /// /// The name of the server /// [DataField("servername"), ViewVariables(VVAccess.ReadWrite)] public string ServerName = "RDSERVER"; /// /// The amount of points on the server. /// [DataField("points"), ViewVariables(VVAccess.ReadWrite)] public int Points; /// /// A unique numeric id representing the server /// [ViewVariables(VVAccess.ReadOnly)] public int Id; /// /// Entities connected to the server /// /// /// This is not safe to read clientside /// [ViewVariables(VVAccess.ReadOnly)] public List Clients = new(); [DataField("nextUpdateTime", customTypeSerializer: typeof(TimeOffsetSerializer))] public TimeSpan NextUpdateTime = TimeSpan.Zero; [DataField("researchConsoleUpdateTime"), ViewVariables(VVAccess.ReadWrite)] public readonly TimeSpan ResearchConsoleUpdateTime = TimeSpan.FromSeconds(1); } [Serializable, NetSerializable] public sealed class ResearchServerState : ComponentState { public string ServerName; public int Points; public int Id; public ResearchServerState(string serverName, int points, int id) { ServerName = serverName; Points = points; Id = id; } } /// /// Event raised on a server's clients when the point value of the server is changed. /// /// /// /// [ByRefEvent] public readonly record struct ResearchServerPointsChangedEvent(EntityUid Server, int Total, int Delta); /// /// Event raised every second to calculate the amount of points added to the server. /// /// /// [ByRefEvent] public record struct ResearchServerGetPointsPerSecondEvent(EntityUid Server, int Points); }