* feat: RnD tech research console now have reroll feature * fix: disable Rediscover button when there is not enough currency or user have no access * refactor: xml-doc, extract method, minor simplify xaml * minor cleanup after review * refactor: change sending research server points amount into BUI from state to ResearchServerComponent (using AfterAutoHandleStateEvent) * feat: now tech rerolls will have cooldown to ensure no one can spam-spend all dept budget instantly * refactor: revert unneeded code * refactor: whitespaces --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
|
|
namespace Content.Shared.Research.Components;
|
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
|
|
public sealed partial class ResearchServerComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// The name of the server
|
|
/// </summary>
|
|
[AutoNetworkedField]
|
|
[DataField]
|
|
public string ServerName = "RDSERVER";
|
|
|
|
/// <summary>
|
|
/// The amount of points on the server.
|
|
/// </summary>
|
|
[AutoNetworkedField]
|
|
[DataField]
|
|
public int Points;
|
|
|
|
/// <summary>
|
|
/// Cost of technology research options reroll.
|
|
/// </summary>
|
|
[AutoNetworkedField]
|
|
[DataField]
|
|
public int RediscoverCost = 2000;
|
|
|
|
/// <summary>
|
|
/// A unique numeric id representing the server
|
|
/// </summary>
|
|
[AutoNetworkedField]
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
|
public int Id;
|
|
|
|
/// <summary>
|
|
/// Entities connected to the server
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This is not safe to read clientside
|
|
/// </remarks>
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
|
public List<EntityUid> Clients = new();
|
|
|
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
|
public TimeSpan NextUpdateTime = TimeSpan.Zero;
|
|
|
|
[DataField]
|
|
public TimeSpan ResearchConsoleUpdateTime = TimeSpan.FromSeconds(1);
|
|
|
|
/// <summary>
|
|
/// Time when next reroll for tech to research will be available.
|
|
/// </summary>
|
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
|
|
public TimeSpan NextRediscover;
|
|
|
|
/// <summary>
|
|
/// Minimal interval between rediscover actions.
|
|
/// </summary>
|
|
[DataField]
|
|
public TimeSpan RediscoverInterval = TimeSpan.FromSeconds(1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised on a server's clients when the point value of the server is changed.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ResearchServerPointsChangedEvent(EntityUid Server, int Total, int Delta);
|
|
|
|
/// <summary>
|
|
/// Event raised every second to calculate the amount of points added to the server.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct ResearchServerGetPointsPerSecondEvent(EntityUid Server, int Points);
|
|
|