* 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
157 lines
5.8 KiB
C#
157 lines
5.8 KiB
C#
using Content.Server.Body.Systems;
|
|
using Content.Server.Doors.Systems;
|
|
using Content.Server.Parallax;
|
|
using Content.Server.Shuttles.Components;
|
|
using Content.Server.Station.Systems;
|
|
using Content.Server.Stunnable;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Shuttles.Systems;
|
|
using Content.Shared.Throwing;
|
|
using JetBrains.Annotations;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Systems;
|
|
using Robust.Shared.Random;
|
|
|
|
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!;
|
|
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
|
[Dependency] private readonly BiomeSystem _biomes = default!;
|
|
[Dependency] private readonly BodySystem _bobby = default!;
|
|
[Dependency] private readonly DockingSystem _dockSystem = default!;
|
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
|
[Dependency] private readonly FixtureSystem _fixtures = default!;
|
|
[Dependency] private readonly MapLoaderSystem _loader = default!;
|
|
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
|
[Dependency] private readonly ShuttleConsoleSystem _console = default!;
|
|
[Dependency] private readonly StationSystem _station = default!;
|
|
[Dependency] private readonly StunSystem _stuns = default!;
|
|
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
|
[Dependency] private readonly ThrusterSystem _thruster = default!;
|
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
|
|
|
public const float TileMassMultiplier = 0.5f;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
InitializeFTL();
|
|
InitializeGridFills();
|
|
InitializeIFF();
|
|
InitializeImpact();
|
|
|
|
SubscribeLocalEvent<ShuttleComponent, ComponentStartup>(OnShuttleStartup);
|
|
SubscribeLocalEvent<ShuttleComponent, ComponentShutdown>(OnShuttleShutdown);
|
|
|
|
SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
|
|
SubscribeLocalEvent<FixturesComponent, GridFixtureChangeEvent>(OnGridFixtureChange);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
UpdateHyperspace(frameTime);
|
|
}
|
|
|
|
private void OnGridFixtureChange(EntityUid uid, FixturesComponent manager, GridFixtureChangeEvent args)
|
|
{
|
|
foreach (var fixture in args.NewFixtures)
|
|
{
|
|
_physics.SetDensity(uid, fixture.Key, fixture.Value, TileMassMultiplier, false, manager);
|
|
_fixtures.SetRestitution(uid, fixture.Key, fixture.Value, 0.1f, false, manager);
|
|
}
|
|
}
|
|
|
|
private void OnGridInit(GridInitializeEvent ev)
|
|
{
|
|
if (HasComp<MapComponent>(ev.EntityUid))
|
|
return;
|
|
|
|
EntityManager.EnsureComponent<ShuttleComponent>(ev.EntityUid);
|
|
}
|
|
|
|
private void OnShuttleStartup(EntityUid uid, ShuttleComponent component, ComponentStartup args)
|
|
{
|
|
if (!EntityManager.HasComponent<MapGridComponent>(uid))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (component.Enabled)
|
|
{
|
|
Enable(uid, component: physicsComponent, shuttle: component);
|
|
}
|
|
}
|
|
|
|
public void Toggle(EntityUid uid, ShuttleComponent component)
|
|
{
|
|
if (!EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
|
|
return;
|
|
|
|
component.Enabled = !component.Enabled;
|
|
|
|
if (component.Enabled)
|
|
{
|
|
Enable(uid, component: physicsComponent, shuttle: component);
|
|
}
|
|
else
|
|
{
|
|
Disable(uid, component: physicsComponent);
|
|
}
|
|
}
|
|
|
|
public void Enable(EntityUid uid, FixturesComponent? manager = null, PhysicsComponent? component = null, ShuttleComponent? shuttle = null)
|
|
{
|
|
if (!Resolve(uid, ref manager, ref component, ref shuttle, false))
|
|
return;
|
|
|
|
_physics.SetBodyType(uid, BodyType.Dynamic, manager: manager, body: component);
|
|
_physics.SetBodyStatus(component, BodyStatus.InAir);
|
|
_physics.SetFixedRotation(uid, false, manager: manager, body: component);
|
|
_physics.SetLinearDamping(component, shuttle.LinearDamping);
|
|
_physics.SetAngularDamping(component, shuttle.AngularDamping);
|
|
}
|
|
|
|
public void Disable(EntityUid uid, FixturesComponent? manager = null, PhysicsComponent? component = null)
|
|
{
|
|
if (!Resolve(uid, ref manager, ref component, false))
|
|
return;
|
|
|
|
_physics.SetBodyType(uid, BodyType.Static, manager: manager, body: component);
|
|
_physics.SetBodyStatus(component, BodyStatus.OnGround);
|
|
_physics.SetFixedRotation(uid, true, manager: manager, body: component);
|
|
}
|
|
|
|
private void OnShuttleShutdown(EntityUid uid, ShuttleComponent component, ComponentShutdown args)
|
|
{
|
|
// None of the below is necessary for any cleanup if we're just deleting.
|
|
if (EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating)
|
|
return;
|
|
|
|
Disable(uid);
|
|
}
|
|
}
|