mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
# Description This PR fully replaces the "Tier 3 Tech Lockout" with a research softcap. How it works is that technologies are allowed to set a softcap contribution, meaning that they multiplicatively increase the cost of all other research by a certain amount. By default, this is done by all Tier 3 Technologies. Essentially, this means that you're no longer limited to a single research category's tier 3 selections. Instead the costs of research increase the more capstones you unlock. The current cost increase for research is displayed on the console. <details><summary><h1>Media</h1></summary> <p>  </p> </details> # Changelog 🆑 - remove: Removed the "Tier 3 Tech Lockout" mechanic. You are no longer limited to 1 discipline worth of t3 research. - add: Research is now "Softcapped" by Tier 3 unlocks. Each unlocked Tier 3 technology multiplicatively increases the cost of all other research. Rushing a capstone can be quite expensive, as will be getting multiple capstones. I hope you're glad that you can build more than one prober now without guaranteeing the station will explode. (cherry picked from commit b7da1f4ff64ca3ce8c4dc4545186573174b3e89c)
106 lines
4.1 KiB
C#
106 lines
4.1 KiB
C#
using Content.Server.Power.EntitySystems;
|
|
using Content.Server.Research.Components;
|
|
using Content.Shared.UserInterface;
|
|
using Content.Shared.Access.Components;
|
|
using Content.Shared.Emag.Components;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Research.Components;
|
|
using Content.Shared.Research.Prototypes;
|
|
|
|
namespace Content.Server.Research.Systems;
|
|
|
|
public sealed partial class ResearchSystem
|
|
{
|
|
private void InitializeConsole()
|
|
{
|
|
SubscribeLocalEvent<ResearchConsoleComponent, ConsoleUnlockTechnologyMessage>(OnConsoleUnlock);
|
|
SubscribeLocalEvent<ResearchConsoleComponent, BeforeActivatableUIOpenEvent>(OnConsoleBeforeUiOpened);
|
|
SubscribeLocalEvent<ResearchConsoleComponent, ResearchServerPointsChangedEvent>(OnPointsChanged);
|
|
SubscribeLocalEvent<ResearchConsoleComponent, ResearchRegistrationChangedEvent>(OnConsoleRegistrationChanged);
|
|
SubscribeLocalEvent<ResearchConsoleComponent, TechnologyDatabaseModifiedEvent>(OnConsoleDatabaseModified);
|
|
}
|
|
|
|
private void OnConsoleUnlock(EntityUid uid, ResearchConsoleComponent component, ConsoleUnlockTechnologyMessage args)
|
|
{
|
|
var act = args.Actor;
|
|
|
|
if (!this.IsPowered(uid, EntityManager))
|
|
return;
|
|
|
|
if (!PrototypeManager.TryIndex<TechnologyPrototype>(args.Id, out var technologyPrototype))
|
|
return;
|
|
|
|
if (TryComp<AccessReaderComponent>(uid, out var access) && !_accessReader.IsAllowed(act, uid, access))
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("research-console-no-access-popup"), act);
|
|
return;
|
|
}
|
|
|
|
if (!UnlockTechnology(uid, args.Id, act)
|
|
|| !TryComp<TechnologyDatabaseComponent>(uid, out var database))
|
|
return;
|
|
|
|
if (!HasComp<EmaggedComponent>(uid))
|
|
{
|
|
var getIdentityEvent = new TryGetIdentityShortInfoEvent(uid, act);
|
|
RaiseLocalEvent(getIdentityEvent);
|
|
|
|
var message = Loc.GetString(
|
|
"research-console-unlock-technology-radio-broadcast",
|
|
("technology", Loc.GetString(technologyPrototype.Name)),
|
|
("amount", technologyPrototype.Cost * database.SoftCapMultiplier),
|
|
("approver", getIdentityEvent.Title ?? string.Empty)
|
|
);
|
|
_radio.SendRadioMessage(uid, message, component.AnnouncementChannel, uid, escapeMarkup: false);
|
|
}
|
|
|
|
SyncClientWithServer(uid);
|
|
UpdateConsoleInterface(uid, component);
|
|
}
|
|
|
|
private void OnConsoleBeforeUiOpened(EntityUid uid, ResearchConsoleComponent component, BeforeActivatableUIOpenEvent args)
|
|
{
|
|
SyncClientWithServer(uid);
|
|
}
|
|
|
|
private void UpdateConsoleInterface(EntityUid uid, ResearchConsoleComponent? component = null, ResearchClientComponent? clientComponent = null)
|
|
{
|
|
if (!Resolve(uid, ref component, ref clientComponent, false))
|
|
return;
|
|
|
|
ResearchConsoleBoundInterfaceState state;
|
|
|
|
if (TryGetClientServer(uid, out _, out var serverComponent, clientComponent))
|
|
{
|
|
var points = clientComponent.ConnectedToServer ? serverComponent.Points : 0;
|
|
var softCap = clientComponent.ConnectedToServer ? serverComponent.CurrentSoftCapMultiplier : 1;
|
|
state = new ResearchConsoleBoundInterfaceState(points, softCap);
|
|
}
|
|
else
|
|
{
|
|
state = new ResearchConsoleBoundInterfaceState(default, default);
|
|
}
|
|
|
|
_uiSystem.SetUiState(uid, ResearchConsoleUiKey.Key, state);
|
|
}
|
|
|
|
private void OnPointsChanged(EntityUid uid, ResearchConsoleComponent component, ref ResearchServerPointsChangedEvent args)
|
|
{
|
|
if (!_uiSystem.IsUiOpen(uid, ResearchConsoleUiKey.Key))
|
|
return;
|
|
UpdateConsoleInterface(uid, component);
|
|
}
|
|
|
|
private void OnConsoleRegistrationChanged(EntityUid uid, ResearchConsoleComponent component, ref ResearchRegistrationChangedEvent args)
|
|
{
|
|
SyncClientWithServer(uid);
|
|
UpdateConsoleInterface(uid, component);
|
|
}
|
|
|
|
private void OnConsoleDatabaseModified(EntityUid uid, ResearchConsoleComponent component, ref TechnologyDatabaseModifiedEvent args)
|
|
{
|
|
UpdateConsoleInterface(uid, component);
|
|
}
|
|
|
|
}
|