1
0

ResearchServerComponent.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Robust.Shared.GameStates;
  2. using Robust.Shared.Serialization;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  4. namespace Content.Shared.Research.Components;
  5. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  6. public sealed partial class ResearchServerComponent : Component
  7. {
  8. /// <summary>
  9. /// The name of the server
  10. /// </summary>
  11. [AutoNetworkedField]
  12. [DataField("serverName"), ViewVariables(VVAccess.ReadWrite)]
  13. public string ServerName = "RDSERVER";
  14. /// <summary>
  15. /// The amount of points on the server.
  16. /// </summary>
  17. [AutoNetworkedField]
  18. [DataField("points"), ViewVariables(VVAccess.ReadWrite)]
  19. public int Points;
  20. /// <summary>
  21. /// A unique numeric id representing the server
  22. /// </summary>
  23. [AutoNetworkedField]
  24. [ViewVariables(VVAccess.ReadOnly)]
  25. public int Id;
  26. /// <summary>
  27. /// Entities connected to the server
  28. /// </summary>
  29. /// <remarks>
  30. /// This is not safe to read clientside
  31. /// </remarks>
  32. [ViewVariables(VVAccess.ReadOnly)]
  33. public List<EntityUid> Clients = new();
  34. [DataField("nextUpdateTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
  35. public TimeSpan NextUpdateTime = TimeSpan.Zero;
  36. [DataField("researchConsoleUpdateTime"), ViewVariables(VVAccess.ReadWrite)]
  37. public TimeSpan ResearchConsoleUpdateTime = TimeSpan.FromSeconds(1);
  38. }
  39. /// <summary>
  40. /// Event raised on a server's clients when the point value of the server is changed.
  41. /// </summary>
  42. /// <param name="Server"></param>
  43. /// <param name="Total"></param>
  44. /// <param name="Delta"></param>
  45. [ByRefEvent]
  46. public readonly record struct ResearchServerPointsChangedEvent(EntityUid Server, int Total, int Delta);
  47. /// <summary>
  48. /// Event raised every second to calculate the amount of points added to the server.
  49. /// </summary>
  50. /// <param name="Server"></param>
  51. /// <param name="Points"></param>
  52. [ByRefEvent]
  53. public record struct ResearchServerGetPointsPerSecondEvent(EntityUid Server, int Points);