mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
Revert "feat: RnD tech research console now have reroll feature (#32931)"
This reverts commit 1f2d80297c.
Discussed during the maintainer meeting and voted to be reverted at this time.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using Content.Shared.Research.Systems;
|
||||
using Content.Shared.Research.Systems;
|
||||
|
||||
namespace Content.Client.Research;
|
||||
|
||||
public sealed class ResearchSystem : SharedResearchSystem;
|
||||
public sealed class ResearchSystem : SharedResearchSystem
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -7,22 +7,23 @@ using Robust.Shared.Prototypes;
|
||||
namespace Content.Client.Research.UI;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class ResearchConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
|
||||
public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private ResearchConsoleMenu? _consoleMenu;
|
||||
|
||||
public ResearchConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_consoleMenu = this.CreateWindow<ResearchConsoleMenu>();
|
||||
_consoleMenu.SetEntity(Owner);
|
||||
var owner = Owner;
|
||||
|
||||
_consoleMenu.OnTechnologyRediscoverPressed += () =>
|
||||
{
|
||||
SendMessage(new ConsoleRediscoverTechnologyMessage());
|
||||
};
|
||||
_consoleMenu = this.CreateWindow<ResearchConsoleMenu>();
|
||||
_consoleMenu.SetEntity(owner);
|
||||
|
||||
_consoleMenu.OnTechnologyCardPressed += id =>
|
||||
{
|
||||
@@ -55,7 +56,6 @@ public sealed class ResearchConsoleBoundUserInterface(EntityUid owner, Enum uiKe
|
||||
|
||||
if (state is not ResearchConsoleBoundInterfaceState castState)
|
||||
return;
|
||||
|
||||
_consoleMenu?.UpdatePanels(castState);
|
||||
_consoleMenu?.UpdateInformationPanel(castState);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
@@ -22,7 +22,6 @@
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalAlignment="Right">
|
||||
<Button Name="ServerButton" Text="{Loc 'research-console-menu-server-selection-button'}" MinHeight="40"/>
|
||||
<Button Name="RediscoverButton" Margin="0 5 0 0" ToolTip="{Loc 'research-console-menu-server-rediscover-tooltip'}" MinHeight="40"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal"
|
||||
|
||||
@@ -12,7 +12,6 @@ using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Research.UI;
|
||||
@@ -21,26 +20,15 @@ namespace Content.Client.Research.UI;
|
||||
public sealed partial class ResearchConsoleMenu : FancyWindow
|
||||
{
|
||||
public Action<string>? OnTechnologyCardPressed;
|
||||
public Action? OnTechnologyRediscoverPressed;
|
||||
public Action? OnServerButtonPressed;
|
||||
|
||||
[Dependency] private readonly IEntityManager _entity = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
private readonly ResearchSystem _research;
|
||||
private readonly SpriteSystem _sprite;
|
||||
private readonly AccessReaderSystem _accessReader;
|
||||
|
||||
// if set to null - we are waiting for server info and should not let rerolls
|
||||
private TimeSpan? _nextRediscover;
|
||||
private int _rediscoverCost;
|
||||
private int _serverPoints;
|
||||
|
||||
private TimeSpan _nextUpdate;
|
||||
private readonly TimeSpan _updateInterval = TimeSpan.FromMilliseconds(500);
|
||||
|
||||
public EntityUid Entity;
|
||||
|
||||
public ResearchConsoleMenu()
|
||||
@@ -53,7 +41,6 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
|
||||
_accessReader = _entity.System<AccessReaderSystem>();
|
||||
|
||||
ServerButton.OnPressed += _ => OnServerButtonPressed?.Invoke();
|
||||
RediscoverButton.OnPressed += OnRediscoverPressed;
|
||||
}
|
||||
|
||||
public void SetEntity(EntityUid entity)
|
||||
@@ -77,7 +64,9 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
|
||||
MinHeight = 10
|
||||
});
|
||||
|
||||
var hasAccess = HasAccess();
|
||||
var hasAccess = _player.LocalEntity is not { } local ||
|
||||
!_entity.TryGetComponent<AccessReaderComponent>(Entity, out var access) ||
|
||||
_accessReader.IsAllowed(local, Entity, access);
|
||||
foreach (var techId in database.CurrentTechnologyCards)
|
||||
{
|
||||
var tech = _prototype.Index<TechnologyPrototype>(techId);
|
||||
@@ -90,12 +79,6 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
|
||||
SyncTechnologyList(UnlockedCardsContainer, unlockedTech);
|
||||
}
|
||||
|
||||
private void UpdateRediscoverButton()
|
||||
{
|
||||
RediscoverButton.Disabled = !HasAccess() || _serverPoints < _rediscoverCost || _timing.CurTime < _nextRediscover;
|
||||
RediscoverButton.Text = Loc.GetString("research-console-menu-server-rediscover-button", ("cost", _rediscoverCost));
|
||||
}
|
||||
|
||||
public void UpdateInformationPanel(ResearchConsoleBoundInterfaceState state)
|
||||
{
|
||||
var amountMsg = new FormattedMessage();
|
||||
@@ -154,27 +137,6 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
|
||||
};
|
||||
TierDisplayContainer.AddChild(control);
|
||||
}
|
||||
|
||||
_serverPoints = state.Points;
|
||||
_rediscoverCost = state.RediscoverCost;
|
||||
_nextRediscover = state.NextRediscover;
|
||||
|
||||
UpdateRediscoverButton();
|
||||
}
|
||||
|
||||
private void OnRediscoverPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
RediscoverButton.Disabled = true;
|
||||
_nextRediscover = null;
|
||||
|
||||
OnTechnologyRediscoverPressed?.Invoke();
|
||||
}
|
||||
|
||||
private bool HasAccess()
|
||||
{
|
||||
return _player.LocalEntity is not { } local
|
||||
|| !_entity.TryGetComponent<AccessReaderComponent>(Entity, out var access)
|
||||
|| _accessReader.IsAllowed(local, Entity, access);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -217,24 +179,5 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
|
||||
container.Children.Remove(techControl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
if(_nextUpdate > _timing.CurTime)
|
||||
return;
|
||||
|
||||
_nextUpdate = _timing.CurTime + _updateInterval;
|
||||
|
||||
if (!RediscoverButton.Disabled)
|
||||
return;
|
||||
|
||||
if (_nextRediscover == null || _nextRediscover > _timing.CurTime)
|
||||
return;
|
||||
|
||||
UpdateRediscoverButton();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ public sealed partial class ResearchSystem
|
||||
private void InitializeConsole()
|
||||
{
|
||||
SubscribeLocalEvent<ResearchConsoleComponent, ConsoleUnlockTechnologyMessage>(OnConsoleUnlock);
|
||||
SubscribeLocalEvent<ResearchConsoleComponent, ConsoleRediscoverTechnologyMessage>(OnRediscoverTechnology);
|
||||
SubscribeLocalEvent<ResearchConsoleComponent, BeforeActivatableUIOpenEvent>(OnConsoleBeforeUiOpened);
|
||||
SubscribeLocalEvent<ResearchConsoleComponent, ResearchServerPointsChangedEvent>(OnPointsChanged);
|
||||
SubscribeLocalEvent<ResearchConsoleComponent, ResearchRegistrationChangedEvent>(OnConsoleRegistrationChanged);
|
||||
@@ -26,41 +25,6 @@ public sealed partial class ResearchSystem
|
||||
SubscribeLocalEvent<ResearchConsoleComponent, GotEmaggedEvent>(OnEmagged);
|
||||
}
|
||||
|
||||
private void OnRediscoverTechnology(
|
||||
EntityUid uid,
|
||||
ResearchConsoleComponent console,
|
||||
ConsoleRediscoverTechnologyMessage args
|
||||
)
|
||||
{
|
||||
var act = args.Actor;
|
||||
|
||||
if (!this.IsPowered(uid, EntityManager))
|
||||
return;
|
||||
|
||||
if (!HasAccess(uid, act))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("research-console-no-access-popup"), act);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryGetClientServer(uid, out var serverEnt, out var serverComponent))
|
||||
return;
|
||||
|
||||
if(serverComponent.NextRediscover > _timing.CurTime)
|
||||
return;
|
||||
|
||||
var rediscoverCost = serverComponent.RediscoverCost;
|
||||
if (rediscoverCost > serverComponent.Points)
|
||||
return;
|
||||
|
||||
serverComponent.NextRediscover = _timing.CurTime + serverComponent.RediscoverInterval;
|
||||
|
||||
ModifyServerPoints(serverEnt.Value, -rediscoverCost);
|
||||
UpdateTechnologyCards(serverEnt.Value);
|
||||
SyncClientWithServer(uid);
|
||||
UpdateConsoleInterface(uid);
|
||||
}
|
||||
|
||||
private void OnConsoleUnlock(EntityUid uid, ResearchConsoleComponent component, ConsoleUnlockTechnologyMessage args)
|
||||
{
|
||||
var act = args.Actor;
|
||||
@@ -71,7 +35,7 @@ public sealed partial class ResearchSystem
|
||||
if (!PrototypeManager.TryIndex<TechnologyPrototype>(args.Id, out var technologyPrototype))
|
||||
return;
|
||||
|
||||
if (!HasAccess(uid, act))
|
||||
if (TryComp<AccessReaderComponent>(uid, out var access) && !_accessReader.IsAllowed(act, uid, access))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("research-console-no-access-popup"), act);
|
||||
return;
|
||||
@@ -108,17 +72,17 @@ public sealed partial class ResearchSystem
|
||||
if (!Resolve(uid, ref component, ref clientComponent, false))
|
||||
return;
|
||||
|
||||
|
||||
var points = 0;
|
||||
var nextRediscover = TimeSpan.MaxValue;
|
||||
var rediscoverCost = 0;
|
||||
if (TryGetClientServer(uid, out _, out var serverComponent, clientComponent) && clientComponent.ConnectedToServer)
|
||||
ResearchConsoleBoundInterfaceState state;
|
||||
|
||||
if (TryGetClientServer(uid, out _, out var serverComponent, clientComponent))
|
||||
{
|
||||
points = serverComponent.Points;
|
||||
nextRediscover = serverComponent.NextRediscover;
|
||||
rediscoverCost = serverComponent.RediscoverCost;
|
||||
var points = clientComponent.ConnectedToServer ? serverComponent.Points : 0;
|
||||
state = new ResearchConsoleBoundInterfaceState(points);
|
||||
}
|
||||
else
|
||||
{
|
||||
state = new ResearchConsoleBoundInterfaceState(default);
|
||||
}
|
||||
var state = new ResearchConsoleBoundInterfaceState(points, nextRediscover, rediscoverCost);
|
||||
|
||||
_uiSystem.SetUiState(uid, ResearchConsoleUiKey.Key, state);
|
||||
}
|
||||
@@ -157,9 +121,4 @@ public sealed partial class ResearchSystem
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private bool HasAccess(EntityUid uid, EntityUid act)
|
||||
{
|
||||
return TryComp<AccessReaderComponent>(uid, out var access) && _accessReader.IsAllowed(act, uid, access);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,10 +165,10 @@ public sealed partial class ResearchSystem
|
||||
if (args.Server != null)
|
||||
return;
|
||||
component.MainDiscipline = null;
|
||||
component.CurrentTechnologyCards = new();
|
||||
component.SupportedDisciplines = new();
|
||||
component.UnlockedTechnologies = new();
|
||||
component.UnlockedRecipes = new();
|
||||
component.CurrentTechnologyCards = new List<string>();
|
||||
component.SupportedDisciplines = new List<ProtoId<TechDisciplinePrototype>>();
|
||||
component.UnlockedTechnologies = new List<ProtoId<TechnologyPrototype>>();
|
||||
component.UnlockedRecipes = new List<ProtoId<LatheRecipePrototype>>();
|
||||
Dirty(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
namespace Content.Shared.Research.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class ResearchServerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the server
|
||||
/// </summary>
|
||||
[AutoNetworkedField]
|
||||
[DataField]
|
||||
[DataField("serverName"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string ServerName = "RDSERVER";
|
||||
|
||||
/// <summary>
|
||||
/// The amount of points on the server.
|
||||
/// </summary>
|
||||
[AutoNetworkedField]
|
||||
[DataField]
|
||||
[DataField("points"), ViewVariables(VVAccess.ReadWrite)]
|
||||
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>
|
||||
@@ -43,34 +37,27 @@ public sealed partial class ResearchServerComponent : Component
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public List<EntityUid> Clients = new();
|
||||
|
||||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
[DataField("nextUpdateTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
public TimeSpan NextUpdateTime = TimeSpan.Zero;
|
||||
|
||||
[DataField]
|
||||
[DataField("researchConsoleUpdateTime"), ViewVariables(VVAccess.ReadWrite)]
|
||||
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>
|
||||
/// <param name="Server"></param>
|
||||
/// <param name="Total"></param>
|
||||
/// <param name="Delta"></param>
|
||||
[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>
|
||||
/// <param name="Server"></param>
|
||||
/// <param name="Points"></param>
|
||||
[ByRefEvent]
|
||||
public record struct ResearchServerGetPointsPerSecondEvent(EntityUid Server, int Points);
|
||||
|
||||
|
||||
@@ -9,13 +9,15 @@ namespace Content.Shared.Research.Components
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleUnlockTechnologyMessage(string id) : BoundUserInterfaceMessage
|
||||
public sealed class ConsoleUnlockTechnologyMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Id = id;
|
||||
}
|
||||
public string Id;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleRediscoverTechnologyMessage : BoundUserInterfaceMessage;
|
||||
public ConsoleUnlockTechnologyMessage(string id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleServerSelectionMessage : BoundUserInterfaceMessage
|
||||
@@ -24,12 +26,12 @@ namespace Content.Shared.Research.Components
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchConsoleBoundInterfaceState(int points, TimeSpan nextRediscover, int rediscoverCost) : BoundUserInterfaceState
|
||||
public sealed class ResearchConsoleBoundInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public int Points = points;
|
||||
|
||||
public TimeSpan NextRediscover = nextRediscover;
|
||||
|
||||
public int RediscoverCost = rediscoverCost;
|
||||
public int Points;
|
||||
public ResearchConsoleBoundInterfaceState(int points)
|
||||
{
|
||||
Points = points;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Research.Prototypes;
|
||||
using Content.Shared.Research.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Research.Components;
|
||||
|
||||
@@ -13,12 +14,12 @@ public sealed partial class TechnologyDatabaseComponent : Component
|
||||
/// A main discipline that locks out other discipline technology past a certain tier.
|
||||
/// </summary>
|
||||
[AutoNetworkedField]
|
||||
[DataField]
|
||||
public ProtoId<TechDisciplinePrototype>? MainDiscipline;
|
||||
[DataField("mainDiscipline", customTypeSerializer: typeof(PrototypeIdSerializer<TechDisciplinePrototype>))]
|
||||
public string? MainDiscipline;
|
||||
|
||||
[AutoNetworkedField]
|
||||
[DataField]
|
||||
public List<ProtoId<TechnologyPrototype>> CurrentTechnologyCards = new();
|
||||
[DataField("currentTechnologyCards")]
|
||||
public List<string> CurrentTechnologyCards = new();
|
||||
|
||||
/// <summary>
|
||||
/// Which research disciplines are able to be unlocked
|
||||
|
||||
@@ -6,8 +6,6 @@ research-console-menu-main-discipline = Main Discipline: [color={$color}]{$name}
|
||||
research-console-menu-server-selection-button = Server list
|
||||
research-console-menu-server-sync-button = Sync
|
||||
research-console-menu-server-research-button = Research
|
||||
research-console-menu-server-rediscover-button = Rediscover ({$cost})
|
||||
research-console-menu-server-rediscover-tooltip = Reroll list of technologies to research
|
||||
research-console-available-text = Researchable Technologies
|
||||
research-console-unlocked-text = Unlocked Technologies
|
||||
research-console-tier-discipline-info = Tier {$tier}, [color={$color}]{$discipline}[/color]
|
||||
|
||||
Reference in New Issue
Block a user