From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 21 Jan 2024 06:41:10 +0000 (+1100) Subject: Content grid merging (#22448) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=b057ec61044c5a55e021dd3cd8f5974f7e7b1a2a;p=space-station-14.git Content grid merging (#22448) Mainly fixing thruster bugs --- diff --git a/Content.Server/Shuttles/Systems/ThrusterSystem.cs b/Content.Server/Shuttles/Systems/ThrusterSystem.cs index 09607381c7..73e1ab0beb 100644 --- a/Content.Server/Shuttles/Systems/ThrusterSystem.cs +++ b/Content.Server/Shuttles/Systems/ThrusterSystem.cs @@ -45,7 +45,6 @@ public sealed class ThrusterSystem : EntitySystem SubscribeLocalEvent(OnThrusterShutdown); SubscribeLocalEvent(OnPowerChange); SubscribeLocalEvent(OnAnchorChange); - SubscribeLocalEvent(OnThrusterReAnchor); SubscribeLocalEvent(OnRotate); SubscribeLocalEvent(OnIsHotEvent); SubscribeLocalEvent(OnStartCollide); @@ -151,9 +150,9 @@ public sealed class ThrusterSystem : EntitySystem private void OnRotate(EntityUid uid, ThrusterComponent component, ref MoveEvent args) { // TODO: Disable visualizer for old direction + // TODO: Don't make them rotatable and make it require anchoring. if (!component.Enabled || - component.Type != ThrusterType.Linear || !EntityManager.TryGetComponent(uid, out TransformComponent? xform) || !EntityManager.TryGetComponent(xform.GridUid, out ShuttleComponent? shuttleComponent)) { @@ -176,22 +175,44 @@ public sealed class ThrusterSystem : EntitySystem // Disable if new tile invalid if (component.IsOn && !canEnable) { - DisableThruster(uid, component, xform, args.OldRotation); + DisableThruster(uid, component, args.OldPosition.EntityId, xform, args.OldRotation); return; } var oldDirection = (int) args.OldRotation.GetCardinalDir() / 2; var direction = (int) args.NewRotation.GetCardinalDir() / 2; + var oldShuttleComponent = shuttleComponent; - shuttleComponent.LinearThrust[oldDirection] -= component.Thrust; - shuttleComponent.BaseLinearThrust[oldDirection] -= component.BaseThrust; - DebugTools.Assert(shuttleComponent.LinearThrusters[oldDirection].Contains(uid)); - shuttleComponent.LinearThrusters[oldDirection].Remove(uid); + if (args.ParentChanged) + { + oldShuttleComponent = Comp(args.OldPosition.EntityId); + + // If no parent change doesn't matter for angular. + if (component.Type == ThrusterType.Angular) + { + oldShuttleComponent.AngularThrust -= component.Thrust; + DebugTools.Assert(oldShuttleComponent.AngularThrusters.Contains(uid)); + oldShuttleComponent.AngularThrusters.Remove(uid); + + shuttleComponent.AngularThrust += component.Thrust; + DebugTools.Assert(!shuttleComponent.AngularThrusters.Contains(uid)); + shuttleComponent.AngularThrusters.Add(uid); + return; + } + } - shuttleComponent.LinearThrust[direction] += component.Thrust; - shuttleComponent.BaseLinearThrust[direction] += component.BaseThrust; - DebugTools.Assert(!shuttleComponent.LinearThrusters[direction].Contains(uid)); - shuttleComponent.LinearThrusters[direction].Add(uid); + if (component.Type == ThrusterType.Linear) + { + oldShuttleComponent.LinearThrust[oldDirection] -= component.Thrust; + oldShuttleComponent.BaseLinearThrust[oldDirection] -= component.BaseThrust; + DebugTools.Assert(oldShuttleComponent.LinearThrusters[oldDirection].Contains(uid)); + oldShuttleComponent.LinearThrusters[oldDirection].Remove(uid); + + shuttleComponent.LinearThrust[direction] += component.Thrust; + shuttleComponent.BaseLinearThrust[direction] += component.BaseThrust; + DebugTools.Assert(!shuttleComponent.LinearThrusters[direction].Contains(uid)); + shuttleComponent.LinearThrusters[direction].Add(uid); + } } private void OnAnchorChange(EntityUid uid, ThrusterComponent component, ref AnchorStateChangedEvent args) @@ -206,14 +227,6 @@ public sealed class ThrusterSystem : EntitySystem } } - private void OnThrusterReAnchor(EntityUid uid, ThrusterComponent component, ref ReAnchorEvent args) - { - DisableThruster(uid, component, args.OldGrid); - - if (CanEnable(uid, component)) - EnableThruster(uid, component); - } - private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args) { _ambient.SetAmbience(uid, false); diff --git a/Resources/engineCommandPerms.yml b/Resources/engineCommandPerms.yml index 423da9cdc8..b425d06099 100644 --- a/Resources/engineCommandPerms.yml +++ b/Resources/engineCommandPerms.yml @@ -67,6 +67,7 @@ - scene - replay_recording_stats - print_pvs_ack + - merge_grids - Flags: MAPPING