]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Content grid merging (#22448)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 21 Jan 2024 06:41:10 +0000 (17:41 +1100)
committerGitHub <noreply@github.com>
Sun, 21 Jan 2024 06:41:10 +0000 (17:41 +1100)
Mainly fixing thruster bugs

Content.Server/Shuttles/Systems/ThrusterSystem.cs
Resources/engineCommandPerms.yml

index 09607381c7afbca82899fc57cab24636eac3fba5..73e1ab0bebe8cdbb6044f836a0a2bcd81c057fe1 100644 (file)
@@ -45,7 +45,6 @@ public sealed class ThrusterSystem : EntitySystem
         SubscribeLocalEvent<ThrusterComponent, ComponentShutdown>(OnThrusterShutdown);
         SubscribeLocalEvent<ThrusterComponent, PowerChangedEvent>(OnPowerChange);
         SubscribeLocalEvent<ThrusterComponent, AnchorStateChangedEvent>(OnAnchorChange);
-        SubscribeLocalEvent<ThrusterComponent, ReAnchorEvent>(OnThrusterReAnchor);
         SubscribeLocalEvent<ThrusterComponent, MoveEvent>(OnRotate);
         SubscribeLocalEvent<ThrusterComponent, IsHotEvent>(OnIsHotEvent);
         SubscribeLocalEvent<ThrusterComponent, StartCollideEvent>(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<ShuttleComponent>(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);
index 423da9cdc8f93f7f81f882de94729c10c15b1248..b425d06099cf367f8f5dca6cda105b0d3a361e7e 100644 (file)
@@ -67,6 +67,7 @@
   - scene
   - replay_recording_stats
   - print_pvs_ack
+  - merge_grids
 
 
 - Flags: MAPPING