CatStation/Content.Server/Shuttles/Systems/ShuttleSystem.cs
Princess Cheeseballs 2c6ffecf62
Move GameTicker to Shared (#45834)
* Scope creep my ass

* why was this shit not pushed????

* gone...

* fix that

* review plus buildd

* asfsafsafsafsafas

* grug

* burber

* I'll fix this later

* shrimply die

* also this

* it's snerf or snuthin

* assaads

* round snend

* aaaa

* fix this shit for real

* actually, don't start GameRules until MapInit now that I think aboot it.

* forgot u

* don't actually need this part nullable

* Deffer comp removal

* one liner

* do that too

* chungus

* Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?)

* deferred removal :V

* aaaaaaaaaaaaaaa

* whhop

* Whoop

* better

* landmine that I placed for myself then forgot about lmao

* cleanup

* FUCKING `!`

* gotovo

* amogus

* please don't check by metadata I beg

* waawsasfdfsasfa

* sfafsasfafsas

* fdsaasffsasfa

* code

* fix

* fasasffasfasfsad

* chungaas

* I may be stupid

* gra

* graaaaaaaaaaaaaaaaa

* comment

* gra

* clearing is not predicted and would require major refactors, so don't cache on client.

* lame shit :P

* last holes

* nukeopsfsafsasafsfafsa

* why  was that shit public bruh

* bubrbgwahrghfaka

* dynamic

* revert change that did nothing lmao
2026-09-16 19:34:19 +00:00

185 lines
6.8 KiB
C#

using Content.Server.Administration.Logs;
using Content.Server.Buckle.Systems;
using Content.Server.Parallax;
using Content.Server.Procedural;
using Content.Server.Shuttles.Events;
using Content.Server.Station.Systems;
using Content.Server.Stunnable;
using Content.Shared.Buckle.Components;
using Content.Shared.Damage.Systems;
using Content.Shared.Gibbing;
using Content.Shared.Light.Components;
using Content.Shared.Maps;
using Content.Shared.Movement.Events;
using Content.Shared.Salvage;
using Content.Shared.Shuttles.Components;
using Content.Shared.Shuttles.Systems;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Server.Shuttles.Systems;
[UsedImplicitly]
public sealed partial class ShuttleSystem : SharedShuttleSystem
{
[Dependency] private IAdminLogManager _logger = default!;
[Dependency] private IConfigurationManager _cfg = default!;
[Dependency] private IGameTiming _gameTiming = default!;
[Dependency] private IRobustRandom _random = default!;
[Dependency] private BiomeSystem _biomes = default!;
[Dependency] private GibbingSystem _gibbing = default!;
[Dependency] private BuckleSystem _buckle = default!;
[Dependency] private DamageableSystem _damageSys = default!;
[Dependency] private DockingSystem _dockSystem = default!;
[Dependency] private DungeonSystem _dungeon = default!;
[Dependency] private EntityLookupSystem _lookup = default!;
[Dependency] private MapLoaderSystem _loader = default!;
[Dependency] private MapSystem _mapSystem = default!;
[Dependency] private MetaDataSystem _metadata = default!;
[Dependency] private PvsOverrideSystem _pvs = default!;
[Dependency] private SharedAudioSystem _audio = default!;
[Dependency] private SharedPhysicsSystem _physics = default!;
[Dependency] private SharedTransformSystem _transform = default!;
[Dependency] private SharedSalvageSystem _salvage = default!;
[Dependency] private ShuttleConsoleSystem _console = default!;
[Dependency] private ServerStationSystem _station = default!;
[Dependency] private StunSystem _stuns = default!;
[Dependency] private ThrowingSystem _throwing = default!;
[Dependency] private ThrusterSystem _thruster = default!;
[Dependency] private UserInterfaceSystem _uiSystem = default!;
[Dependency] private TurfSystem _turf = default!;
[Dependency] private EntityQuery<BuckleComponent> _buckleQuery = default!;
[Dependency] private EntityQuery<MapGridComponent> _gridQuery = default!;
[Dependency] private EntityQuery<PhysicsComponent> _physicsQuery = default!;
public override void Initialize()
{
base.Initialize();
InitializeFTL();
InitializeGridFills();
InitializeIFF();
InitializeImpact();
SubscribeLocalEvent<ShuttleComponent, ComponentStartup>(OnShuttleStartup);
SubscribeLocalEvent<ShuttleComponent, ComponentShutdown>(OnShuttleShutdown);
SubscribeLocalEvent<ShuttleComponent, TileFrictionEvent>(OnTileFriction);
SubscribeLocalEvent<ShuttleComponent, FTLStartedEvent>(OnFTLStarted);
SubscribeLocalEvent<ShuttleComponent, FTLCompletedEvent>(OnFTLCompleted);
SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
UpdateHyperspace();
}
private void OnGridInit(GridInitializeEvent ev)
{
if (HasComp<MapComponent>(ev.EntityUid))
return;
EnsureComp<ShuttleComponent>(ev.EntityUid);
// This and RoofComponent should be mutually exclusive, so ImplicitRoof should be removed if the grid has RoofComponent
if (HasComp<RoofComponent>(ev.EntityUid))
RemComp<ImplicitRoofComponent>(ev.EntityUid);
else
EnsureComp<ImplicitRoofComponent>(ev.EntityUid);
}
private void OnShuttleStartup(EntityUid uid, ShuttleComponent component, ComponentStartup args)
{
if (!HasComp<MapGridComponent>(uid))
{
return;
}
if (!TryComp(uid, out PhysicsComponent? physicsComponent))
{
return;
}
if (component.Enabled)
{
Enable(uid, component: physicsComponent, shuttle: component);
}
component.DampingModifier = component.BodyModifier;
}
public void Toggle(EntityUid uid, ShuttleComponent component)
{
if (!TryComp(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(uid, component, BodyStatus.InAir);
_physics.SetFixedRotation(uid, false, manager: manager, body: component);
}
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(uid, 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 (Comp<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating)
return;
Disable(uid);
}
private void OnTileFriction(Entity<ShuttleComponent> ent, ref TileFrictionEvent args)
{
args.Modifier *= ent.Comp.DampingModifier;
}
private void OnFTLStarted(Entity<ShuttleComponent> ent, ref FTLStartedEvent args)
{
ent.Comp.DampingModifier = 0f;
}
private void OnFTLCompleted(Entity<ShuttleComponent> ent, ref FTLCompletedEvent args)
{
ent.Comp.DampingModifier = ent.Comp.BodyModifier;
}
}