mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-08 15:27:27 +00:00
* Add shuttle interior drawing back
Just do it per-tile she'll be right, at least it's done with 1 draw call.
* Revamp shuttle console
* Bunch of cleanup work
* Lables sortito
* dok
* Pixel alignment and colours
* Fix a bunch of drawing bugs
* Shuttle map drawing
* Drawing fixes
* Map parallax working finally
* weh
* Commit all my stuff
* mic
* deez
* Update everything
* Xamlify everything
* uh
* Rudimentary blocker range
* My enemies have succeeded
* Bunch of changes to FTL
* Heaps of cleanup
* Fix FTL bugs
* FTL
* weewoo
* FTL fallback
* wew
* weh
* Basic FTL working
* FTL working
* FTL destination fixes
* a
* Exclusion zones
* Fix drawing / FTL
* Beacons working
* Coordinates drawing
* Fix unknown map names
* Dorks beginning
* State + docking cleanup start
* Basic dock drawing
* Bunch of drawing fixes
* Batching / color fixes
* Cleanup and beacons support
* weh
* weh
* Begin pings
* First draft at map objects
* Map fixup
* Faster drawing
* Fix perf + FTL
* Cached drawing
* Fix drawing
* Best I got
* strips
* Back to lists but with caching
* Final optimisation
* Fix dock bounds
* Docking work
* stinker
* kobolds
* Btns
* Docking vis working
* Fix docking pre-vis
* canasses
* Helldivers 2
* a
* Array life
* Fix
* Fix TODOs
* liltenhead feature club
* dorking
* Merge artifacts
* Last-minute touchup
(cherry picked from commit c5486873db)
205 lines
7.5 KiB
C#
205 lines
7.5 KiB
C#
using System.Numerics;
|
|
using Content.Server.Salvage.Expeditions;
|
|
using Content.Server.Salvage.Expeditions.Structure;
|
|
using Content.Server.Shuttles.Components;
|
|
using Content.Server.Shuttles.Events;
|
|
using Content.Server.Shuttles.Systems;
|
|
using Content.Server.Station.Components;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Salvage.Expeditions;
|
|
using Content.Shared.Shuttles.Components;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server.Salvage;
|
|
|
|
public sealed partial class SalvageSystem
|
|
{
|
|
/*
|
|
* Handles actively running a salvage expedition.
|
|
*/
|
|
|
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
|
|
|
private void InitializeRunner()
|
|
{
|
|
SubscribeLocalEvent<FTLRequestEvent>(OnFTLRequest);
|
|
SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
|
|
SubscribeLocalEvent<FTLCompletedEvent>(OnFTLCompleted);
|
|
SubscribeLocalEvent<ConsoleFTLAttemptEvent>(OnConsoleFTLAttempt);
|
|
}
|
|
|
|
private void OnConsoleFTLAttempt(ref ConsoleFTLAttemptEvent ev)
|
|
{
|
|
if (!TryComp<TransformComponent>(ev.Uid, out var xform) ||
|
|
!TryComp<SalvageExpeditionComponent>(xform.MapUid, out var salvage))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// TODO: This is terrible but need bluespace harnesses or something.
|
|
var query = EntityQueryEnumerator<HumanoidAppearanceComponent, MobStateComponent, TransformComponent>();
|
|
|
|
while (query.MoveNext(out var uid, out _, out var mobState, out var mobXform))
|
|
{
|
|
if (mobXform.MapUid != xform.MapUid)
|
|
continue;
|
|
|
|
// Don't count unidentified humans (loot) or anyone you murdered so you can still maroon them once dead.
|
|
if (_mobState.IsDead(uid, mobState))
|
|
continue;
|
|
|
|
// Okay they're on salvage, so are they on the shuttle.
|
|
if (mobXform.GridUid != ev.Uid)
|
|
{
|
|
ev.Cancelled = true;
|
|
ev.Reason = Loc.GetString("salvage-expedition-not-all-present");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Announces status updates to salvage crewmembers on the state of the expedition.
|
|
/// </summary>
|
|
private void Announce(EntityUid mapUid, string text)
|
|
{
|
|
var mapId = Comp<MapComponent>(mapUid).MapId;
|
|
|
|
// I love TComms and chat!!!
|
|
_chat.ChatMessageToManyFiltered(
|
|
Filter.BroadcastMap(mapId),
|
|
ChatChannel.Radio,
|
|
text,
|
|
text,
|
|
_mapManager.GetMapEntityId(mapId),
|
|
false,
|
|
true,
|
|
null);
|
|
}
|
|
|
|
private void OnFTLRequest(ref FTLRequestEvent ev)
|
|
{
|
|
if (!HasComp<SalvageExpeditionComponent>(ev.MapUid) ||
|
|
!TryComp<FTLDestinationComponent>(ev.MapUid, out var dest))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Only one shuttle can occupy an expedition.
|
|
dest.Enabled = false;
|
|
_shuttleConsoles.RefreshShuttleConsoles();
|
|
}
|
|
|
|
private void OnFTLCompleted(ref FTLCompletedEvent args)
|
|
{
|
|
if (!TryComp<SalvageExpeditionComponent>(args.MapUid, out var component))
|
|
return;
|
|
|
|
// Someone FTLd there so start announcement
|
|
if (component.Stage != ExpeditionStage.Added)
|
|
return;
|
|
|
|
Announce(args.MapUid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", (component.EndTime - _timing.CurTime).Minutes)));
|
|
|
|
if (component.DungeonLocation != Vector2.Zero)
|
|
Announce(args.MapUid, Loc.GetString("salvage-expedition-announcement-dungeon", ("direction", component.DungeonLocation.GetDir())));
|
|
|
|
component.Stage = ExpeditionStage.Running;
|
|
Dirty(args.MapUid, component);
|
|
}
|
|
|
|
private void OnFTLStarted(ref FTLStartedEvent ev)
|
|
{
|
|
if (!TryComp<SalvageExpeditionComponent>(ev.FromMapUid, out var expedition) ||
|
|
!TryComp<SalvageExpeditionDataComponent>(expedition.Station, out var station))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Check if any shuttles remain.
|
|
var query = EntityQueryEnumerator<ShuttleComponent, TransformComponent>();
|
|
|
|
while (query.MoveNext(out _, out var xform))
|
|
{
|
|
if (xform.MapUid == ev.FromMapUid)
|
|
return;
|
|
}
|
|
|
|
// Last shuttle has left so finish the mission.
|
|
QueueDel(ev.FromMapUid.Value);
|
|
}
|
|
|
|
// Runs the expedition
|
|
private void UpdateRunner()
|
|
{
|
|
// Generic missions
|
|
var query = EntityQueryEnumerator<SalvageExpeditionComponent>();
|
|
|
|
// Run the basic mission timers (e.g. announcements, auto-FTL, completion, etc)
|
|
while (query.MoveNext(out var uid, out var comp))
|
|
{
|
|
var remaining = comp.EndTime - _timing.CurTime;
|
|
|
|
if (comp.Stage < ExpeditionStage.FinalCountdown && remaining < TimeSpan.FromSeconds(45))
|
|
{
|
|
comp.Stage = ExpeditionStage.FinalCountdown;
|
|
Dirty(uid, comp);
|
|
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-seconds", ("duration", TimeSpan.FromSeconds(45).Seconds)));
|
|
}
|
|
else if (comp.Stage < ExpeditionStage.MusicCountdown && remaining < TimeSpan.FromMinutes(2))
|
|
{
|
|
// TODO: Some way to play audio attached to a map for players.
|
|
comp.Stream = _audio.PlayGlobal(comp.Sound, Filter.BroadcastMap(Comp<MapComponent>(uid).MapId), true).Value.Entity;
|
|
comp.Stage = ExpeditionStage.MusicCountdown;
|
|
Dirty(uid, comp);
|
|
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", TimeSpan.FromMinutes(2).Minutes)));
|
|
}
|
|
else if (comp.Stage < ExpeditionStage.Countdown && remaining < TimeSpan.FromMinutes(4))
|
|
{
|
|
comp.Stage = ExpeditionStage.Countdown;
|
|
Dirty(uid, comp);
|
|
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", TimeSpan.FromMinutes(5).Minutes)));
|
|
}
|
|
// Auto-FTL out any shuttles
|
|
else if (remaining < TimeSpan.FromSeconds(ShuttleSystem.DefaultStartupTime) + TimeSpan.FromSeconds(0.5))
|
|
{
|
|
var ftlTime = (float) remaining.TotalSeconds;
|
|
|
|
if (remaining < TimeSpan.FromSeconds(ShuttleSystem.DefaultStartupTime))
|
|
{
|
|
ftlTime = MathF.Max(0, (float) remaining.TotalSeconds - 0.5f);
|
|
}
|
|
|
|
ftlTime = MathF.Min(ftlTime, ShuttleSystem.DefaultStartupTime);
|
|
var shuttleQuery = AllEntityQuery<ShuttleComponent, TransformComponent>();
|
|
|
|
if (TryComp<StationDataComponent>(comp.Station, out var data))
|
|
{
|
|
foreach (var member in data.Grids)
|
|
{
|
|
while (shuttleQuery.MoveNext(out var shuttleUid, out var shuttle, out var shuttleXform))
|
|
{
|
|
if (shuttleXform.MapUid != uid || HasComp<FTLComponent>(shuttleUid))
|
|
continue;
|
|
|
|
_shuttle.FTLToDock(shuttleUid, shuttle, member, ftlTime);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (remaining < TimeSpan.Zero)
|
|
{
|
|
QueueDel(uid);
|
|
}
|
|
}
|
|
}
|
|
}
|