Adds the Central Command outpost for Roundend and ERT to spawn at. (#9146)
* Adds Reach II * Updated Reach II to work after refactor * removing old map * Adding the Central Command outpost * Reachii isn't meant to be in here at all. * updated possible error in .yml * updating .yml * Updated CentComm, fixed some issues like lighting. * Imagine if we also docked at centcomm * a Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
5e316afe86
commit
6325a10a43
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Buckle.Components;
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Server.Doors.Systems;
|
||||
@@ -51,20 +52,49 @@ public sealed partial class ShuttleSystem
|
||||
float startupTime = DefaultStartupTime,
|
||||
float hyperspaceTime = DefaultTravelTime)
|
||||
{
|
||||
if (HasComp<HyperspaceComponent>(component.Owner))
|
||||
{
|
||||
_sawmill.Warning($"Tried queuing {ToPrettyString(component.Owner)} which already has HyperspaceComponent?");
|
||||
return;
|
||||
}
|
||||
if (!TrySetupHyperspace(component.Owner, out var hyperspace))
|
||||
return;
|
||||
|
||||
SetDocks(component.Owner, false);
|
||||
var hyperspace = AddComp<HyperspaceComponent>(component.Owner);
|
||||
hyperspace.StartupTime = startupTime;
|
||||
hyperspace.TravelTime = hyperspaceTime;
|
||||
hyperspace.Accumulator = hyperspace.StartupTime;
|
||||
hyperspace.TargetCoordinates = coordinates;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves a shuttle from its current position to docked on the target one. Goes through the hyperspace map while the timer is running.
|
||||
/// </summary>
|
||||
public void Hyperspace(ShuttleComponent component,
|
||||
EntityUid target,
|
||||
float startupTime = DefaultStartupTime,
|
||||
float hyperspaceTime = DefaultTravelTime)
|
||||
{
|
||||
if (!TrySetupHyperspace(component.Owner, out var hyperspace))
|
||||
return;
|
||||
|
||||
hyperspace.StartupTime = startupTime;
|
||||
hyperspace.TravelTime = hyperspaceTime;
|
||||
hyperspace.Accumulator = hyperspace.StartupTime;
|
||||
hyperspace.TargetUid = target;
|
||||
}
|
||||
|
||||
private bool TrySetupHyperspace(EntityUid uid, [NotNullWhen(true)] out HyperspaceComponent? component)
|
||||
{
|
||||
component = null;
|
||||
|
||||
if (HasComp<HyperspaceComponent>(uid))
|
||||
{
|
||||
_sawmill.Warning($"Tried queuing {ToPrettyString(uid)} which already has HyperspaceComponent?");
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Maybe move this to docking instead?
|
||||
SetDocks(uid, false);
|
||||
|
||||
component = AddComp<HyperspaceComponent>(uid);
|
||||
// TODO: Need BroadcastGrid to not be bad.
|
||||
SoundSystem.Play(_startupSound.GetSound(), Filter.Pvs(component.Owner, GetSoundRange(component.Owner), entityManager: EntityManager), _startupSound.Params);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateHyperspace(float frameTime)
|
||||
@@ -107,8 +137,8 @@ public sealed partial class ShuttleSystem
|
||||
// Arrive.
|
||||
case HyperspaceState.Travelling:
|
||||
DoTheDinosaur(xform);
|
||||
SetDocks(comp.Owner, true);
|
||||
SetDockBolts(comp.Owner, false);
|
||||
SetDocks(comp.Owner, true);
|
||||
|
||||
if (TryComp(comp.Owner, out body))
|
||||
{
|
||||
@@ -118,7 +148,15 @@ public sealed partial class ShuttleSystem
|
||||
body.AngularDamping = ShuttleIdleAngularDamping;
|
||||
}
|
||||
|
||||
xform.Coordinates = comp.TargetCoordinates;
|
||||
if (comp.TargetUid != null && TryComp<ShuttleComponent>(comp.Owner, out var shuttle))
|
||||
{
|
||||
TryHyperspaceDock(shuttle, comp.TargetUid.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
xform.Coordinates = comp.TargetCoordinates;
|
||||
}
|
||||
|
||||
SoundSystem.Play(_arrivalSound.GetSound(),
|
||||
Filter.Pvs(comp.Owner, GetSoundRange(comp.Owner), entityManager: EntityManager));
|
||||
RemComp<HyperspaceComponent>(comp.Owner);
|
||||
@@ -141,11 +179,11 @@ public sealed partial class ShuttleSystem
|
||||
|
||||
private void SetDockBolts(EntityUid uid, bool enabled)
|
||||
{
|
||||
foreach (var (dock, door, xform) in EntityQuery<DockingComponent, AirlockComponent, TransformComponent>(true))
|
||||
foreach (var (_, door, xform) in EntityQuery<DockingComponent, AirlockComponent, TransformComponent>(true))
|
||||
{
|
||||
if (xform.ParentUid != uid) continue;
|
||||
|
||||
_doors.TryClose(dock.Owner);
|
||||
_doors.TryClose(door.Owner);
|
||||
door.SetBoltsWithAudio(enabled);
|
||||
}
|
||||
}
|
||||
@@ -209,4 +247,52 @@ public sealed partial class ShuttleSystem
|
||||
toKnock.Add(child.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryHyperspaceDock(ShuttleComponent component, EntityUid targetUid)
|
||||
{
|
||||
if (!TryComp<TransformComponent>(component.Owner, out var xform) ||
|
||||
!TryComp<TransformComponent>(targetUid, out var targetXform)) return false;
|
||||
|
||||
var config = GetDockingConfig(component, targetUid);
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
// Set position
|
||||
xform.Coordinates = config.Coordinates;
|
||||
xform.WorldRotation = config.Angle;
|
||||
|
||||
// Connect everything
|
||||
foreach (var (dockA, dockB) in config.Docks)
|
||||
{
|
||||
_dockSystem.Dock(dockA, dockB);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var shuttleAABB = Comp<IMapGridComponent>(component.Owner).Grid.WorldAABB;
|
||||
Box2? aabb = null;
|
||||
|
||||
// Spawn nearby.
|
||||
foreach (var grid in _mapManager.GetAllMapGrids(targetXform.MapID))
|
||||
{
|
||||
var gridAABB = grid.WorldAABB;
|
||||
aabb = aabb?.Union(gridAABB) ?? gridAABB;
|
||||
}
|
||||
|
||||
aabb ??= new Box2();
|
||||
|
||||
var minRadius = MathF.Max(aabb.Value.Width, aabb.Value.Height) + MathF.Max(shuttleAABB.Width, shuttleAABB.Height);
|
||||
var spawnPos = aabb.Value.Center + _random.NextVector2(minRadius, minRadius + 10f);
|
||||
|
||||
if (TryComp<PhysicsComponent>(component.Owner, out var shuttleBody))
|
||||
{
|
||||
shuttleBody.LinearVelocity = Vector2.Zero;
|
||||
shuttleBody.AngularVelocity = 0f;
|
||||
}
|
||||
|
||||
xform.WorldPosition = spawnPos;
|
||||
xform.WorldRotation = _random.NextAngle();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user