using Content.Shared.Shuttles.Components; using Content.Shared.Procedural; using Content.Shared.Salvage.Expeditions; using Content.Shared.Dataset; using Robust.Shared.Prototypes; namespace Content.Server.Salvage; public sealed partial class SalvageSystem { [ValidatePrototypeId] public const string CoordinatesDisk = "CoordinatesDisk"; private void OnSalvageClaimMessage(EntityUid uid, SalvageExpeditionConsoleComponent component, ClaimSalvageMessage args) { var station = _station.GetOwningStation(uid); if (!TryComp(station, out var data) || data.Claimed) return; if (!data.Missions.TryGetValue(args.Index, out var missionparams)) return; var cdUid = Spawn(CoordinatesDisk, Transform(uid).Coordinates); SpawnMission(missionparams, station.Value, cdUid); data.ActiveMission = args.Index; var mission = GetMission(_prototypeManager.Index(missionparams.Difficulty), missionparams.Seed); data.NextOffer = _timing.CurTime + mission.Duration + TimeSpan.FromSeconds(1); _labelSystem.Label(cdUid, GetFTLName(_prototypeManager.Index("NamesBorer"), missionparams.Seed)); _audio.PlayPvs(component.PrintSound, uid); UpdateConsoles((station.Value, data)); } private void OnSalvageConsoleInit(Entity console, ref ComponentInit args) { UpdateConsole(console); } private void OnSalvageConsoleParent(Entity console, ref EntParentChangedMessage args) { UpdateConsole(console); } private void UpdateConsoles(Entity component) { var state = GetState(component); var query = AllEntityQuery(); while (query.MoveNext(out var uid, out _, out var uiComp, out var xform)) { var station = _station.GetOwningStation(uid, xform); if (station != component.Owner) continue; _ui.SetUiState((uid, uiComp), SalvageConsoleUiKey.Expedition, state); } } private void UpdateConsole(Entity component) { var station = _station.GetOwningStation(component); SalvageExpeditionConsoleState state; if (TryComp(station, out var dataComponent)) { state = GetState(dataComponent); } else { state = new SalvageExpeditionConsoleState(TimeSpan.Zero, false, true, 0, new List()); } _ui.SetUiState(component.Owner, SalvageConsoleUiKey.Expedition, state); } }