CatStation/Content.Shared/StationRecords/Systems/SharedGeneralStationRecordConsoleSystem.cs
Rouden 4d0c40f358
Predict StationRecords (#40240)
* Make StationRecords YAML savable

* Update SharedStationRecordsSystem.cs

* Predict Station Records

* Attribute subs, query Resolve & DirtyFields

* Cleanup, prediction fixes, locale fixes

* Update GeneralRecordsUi.cs

Remove GeneralStationRecordConsoleState and obsolete SelectStationRecord
2026-07-17 03:36:39 +00:00

46 lines
1.6 KiB
C#

using Content.Shared.Station;
using Content.Shared.StationRecords.Components;
using Content.Shared.StationRecords.Events;
namespace Content.Shared.StationRecords.Systems;
public abstract partial class SharedGeneralStationRecordConsoleSystem : EntitySystem
{
[Dependency] protected SharedStationSystem StationSys = default!;
[Dependency] protected StationRecordsSystem StationRecordsSys = default!;
[Dependency] protected EntityQuery<StationRecordsComponent> RecordsQuery = default!;
[SubscribeLocalEvent]
private void OnRecordModified(Entity<GeneralStationRecordConsoleComponent> ent, ref RecordModifiedEvent args)
{
UpdateUserInterface(ent);
}
[SubscribeLocalEvent]
private void OnGeneralRecordCreated(Entity<GeneralStationRecordConsoleComponent> ent, ref GeneralRecordCreatedEvent args)
{
UpdateUserInterface(ent);
}
[SubscribeLocalEvent]
private void OnRecordRemoved(Entity<GeneralStationRecordConsoleComponent> ent, ref RecordRemovedEvent args)
{
UpdateUserInterface(ent);
}
[SubscribeLocalEvent]
private void OnRecordDelete(Entity<GeneralStationRecordConsoleComponent> ent, ref DeleteStationRecord args)
{
if (!ent.Comp.CanDeleteEntries)
return;
var owning = StationSys.GetOwningStation(ent.Owner);
if (owning != null)
StationRecordsSys.RemoveRecord(new StationRecordKey(args.Id, owning.Value));
UpdateUserInterface(ent);
}
protected virtual void UpdateUserInterface(Entity<GeneralStationRecordConsoleComponent> ent) { }
}