Add trade stations (#23863)

* puters

* Start on fulfillment

* weh

* Smol update

* FTL sound fixes or smth iunno

* Add consoles

* More tweaks

* Make it unanchorable

* final wehs

* weh

* Fix 1 test

* Shrimply bump the distance

* cat
This commit is contained in:
metalgearsloth
2024-01-19 13:02:28 +11:00
committed by GitHub
parent f69f3e0f41
commit a7388e5c05
17 changed files with 2413 additions and 2188 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Shuttles.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Server.Shuttles.Components;
@@ -23,6 +24,11 @@ public record struct GridSpawnGroup
public int MinCount = 1;
public int MaxCount = 1;
/// <summary>
/// Components to be added to any spawned grids.
/// </summary>
public ComponentRegistry AddComponents = new();
/// <summary>
/// Hide the IFF label of the grid.
/// </summary>

View File

@@ -235,6 +235,12 @@ public sealed partial class ShuttleSystem
component.State = FTLState.Starting;
var audio = _audio.PlayPvs(_startupSound, uid);
audio.Value.Component.Flags |= AudioFlags.GridAudio;
if (_physicsQuery.TryGetComponent(uid, out var gridPhysics))
{
_transform.SetLocalPosition(audio.Value.Entity, gridPhysics.LocalCenter);
}
// Make sure the map is setup before we leave to avoid pop-in (e.g. parallax).
SetupHyperspace();
return true;
@@ -260,6 +266,7 @@ public sealed partial class ShuttleSystem
{
// Startup time has elapsed and in hyperspace.
case FTLState.Starting:
{
DoTheDinosaur(xform);
comp.State = FTLState.Travelling;
@@ -268,7 +275,8 @@ public sealed partial class ShuttleSystem
var fromRotation = _transform.GetWorldRotation(xform);
var width = Comp<MapGridComponent>(uid).LocalAABB.Width;
xform.Coordinates = new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value), new Vector2(_index + width / 2f, 0f));
xform.Coordinates = new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value),
new Vector2(_index + width / 2f, 0f));
xform.LocalRotation = Angle.Zero;
_index += width + Buffer;
comp.Accumulator += comp.TravelTime - DefaultArrivalTime;
@@ -285,7 +293,9 @@ public sealed partial class ShuttleSystem
SetDockBolts(uid, true);
_console.RefreshShuttleConsoles(uid);
var target = comp.TargetUid != null ? new EntityCoordinates(comp.TargetUid.Value, Vector2.Zero) : comp.TargetCoordinates;
var target = comp.TargetUid != null
? new EntityCoordinates(comp.TargetUid.Value, Vector2.Zero)
: comp.TargetCoordinates;
var ev = new FTLStartedEvent(uid, target, fromMapUid, fromMatrix, fromRotation);
RaiseLocalEvent(uid, ref ev, true);
@@ -293,8 +303,15 @@ public sealed partial class ShuttleSystem
var wowdio = _audio.PlayPvs(comp.TravelSound, uid);
comp.TravelStream = wowdio?.Entity;
if (wowdio?.Component != null)
{
wowdio.Value.Component.Flags |= AudioFlags.GridAudio;
if (_physicsQuery.TryGetComponent(uid, out var gridPhysics))
{
_transform.SetLocalPosition(wowdio.Value.Entity, gridPhysics.LocalCenter);
}
}
}
break;
// Arriving, play effects
case FTLState.Travelling:
@@ -313,6 +330,7 @@ public sealed partial class ShuttleSystem
break;
// Arrived
case FTLState.Arriving:
{
DoTheDinosaur(xform);
SetDockBolts(uid, false);
SetDocks(uid, true);
@@ -383,6 +401,12 @@ public sealed partial class ShuttleSystem
comp.TravelStream = _audio.Stop(comp.TravelStream);
var audio = _audio.PlayPvs(_arrivalSound, uid);
audio.Value.Component.Flags |= AudioFlags.GridAudio;
// TODO: Shitcode til engine fix
if (_physicsQuery.TryGetComponent(uid, out var gridPhysics))
{
_transform.SetLocalPosition(audio.Value.Entity, gridPhysics.LocalCenter);
}
if (TryComp<FTLDestinationComponent>(uid, out var dest))
{
@@ -397,6 +421,7 @@ public sealed partial class ShuttleSystem
var ftlEvent = new FTLCompletedEvent(uid, _mapManager.GetMapEntityId(mapId));
RaiseLocalEvent(uid, ref ftlEvent, true);
}
break;
case FTLState.Cooldown:
RemComp<FTLComponent>(uid);
@@ -711,6 +736,9 @@ public sealed partial class ShuttleSystem
continue;
var aabb = fixture.Shape.ComputeAABB(transform, 0);
// Shift it slightly
aabb = aabb.Translated(-grid.TileSizeHalfVector);
// Create a small border around it.
aabb = aabb.Enlarged(0.2f);
aabbs.Add(aabb);

View File

@@ -156,6 +156,17 @@ public sealed partial class ShuttleSystem
var name = path.FilenameWithoutExtension;
_metadata.SetEntityName(ent[0], name);
}
foreach (var compReg in group.AddComponents.Values)
{
var compType = compReg.Component.GetType();
if (HasComp(ent[0], compType))
continue;
var comp = _factory.GetComponent(compType);
AddComp(ent[0], comp, true);
}
}
else
{

View File

@@ -25,6 +25,7 @@ namespace Content.Server.Shuttles.Systems;
[UsedImplicitly]
public sealed partial class ShuttleSystem : SharedShuttleSystem
{
[Dependency] private readonly IComponentFactory _factory = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
@@ -39,7 +40,6 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
[Dependency] private readonly MapLoaderSystem _loader = default!;
[Dependency] private readonly MetaDataSystem _metadata = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly ShuttleConsoleSystem _console = default!;