Files
crystall-punk-14/Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs
SlamBamActionman bed9e9ac6a Coordinates Disks & Shuttle FTL Travel (#23240)
* Adds the CentComm Disk and configures it to work with direct-use shuttles

* Added functionality for drone shuttles (i.e. cargo shuttle)

* Adds support for pods, and a disk console object for disks to be inserted into. Also sprites.

* Added the disk to HoP's locker

* Removed leftover logs & comments

* Fix for integration test

* Apply suggestions from code review (formatting & proper DataField)

Co-authored-by: 0x6273 <0x40@keemail.me>

* Fix integration test & changes based on code review

* Includes Disk Cases to contain Coordinate Disks, which are now CDs instead of Floppy Disks

* Check pods & non-evac shuttles for CentCom travel, even in FTL

* Import

* Remove CentCom travel restrictions & pod disk consoles

* Major changes that changes the coordinates disk system to work with salvage expeditions

* Missed CC diskcase removal

* Fix build

* Review suggestions and changes

* Major additional changes after merge

* Minor tag miss

* Integration test fix

* review

---------

Co-authored-by: 0x6273 <0x40@keemail.me>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-04-01 15:50:00 +11:00

80 lines
2.8 KiB
C#

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<EntityPrototype>]
public const string CoordinatesDisk = "CoordinatesDisk";
private void OnSalvageClaimMessage(EntityUid uid, SalvageExpeditionConsoleComponent component, ClaimSalvageMessage args)
{
var station = _station.GetOwningStation(uid);
if (!TryComp<SalvageExpeditionDataComponent>(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<SalvageDifficultyPrototype>(missionparams.Difficulty), missionparams.Seed);
data.NextOffer = _timing.CurTime + mission.Duration + TimeSpan.FromSeconds(1);
_labelSystem.Label(cdUid, GetFTLName(_prototypeManager.Index<DatasetPrototype>("names_borer"), missionparams.Seed));
_audio.PlayPvs(component.PrintSound, uid);
UpdateConsoles((station.Value, data));
}
private void OnSalvageConsoleInit(Entity<SalvageExpeditionConsoleComponent> console, ref ComponentInit args)
{
UpdateConsole(console);
}
private void OnSalvageConsoleParent(Entity<SalvageExpeditionConsoleComponent> console, ref EntParentChangedMessage args)
{
UpdateConsole(console);
}
private void UpdateConsoles(Entity<SalvageExpeditionDataComponent> component)
{
var state = GetState(component);
var query = AllEntityQuery<SalvageExpeditionConsoleComponent, UserInterfaceComponent, TransformComponent>();
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.TrySetUiState(uid, SalvageConsoleUiKey.Expedition, state, ui: uiComp);
}
}
private void UpdateConsole(Entity<SalvageExpeditionConsoleComponent> component)
{
var station = _station.GetOwningStation(component);
SalvageExpeditionConsoleState state;
if (TryComp<SalvageExpeditionDataComponent>(station, out var dataComponent))
{
state = GetState(dataComponent);
}
else
{
state = new SalvageExpeditionConsoleState(TimeSpan.Zero, false, true, 0, new List<SalvageMissionParams>());
}
_ui.TrySetUiState(component, SalvageConsoleUiKey.Expedition, state);
}
}