]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix misc bugs (#15314)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Wed, 12 Apr 2023 00:18:30 +0000 (12:18 +1200)
committerGitHub <noreply@github.com>
Wed, 12 Apr 2023 00:18:30 +0000 (10:18 +1000)
Content.Client/Construction/ConstructionSystem.cs
Content.Server/Body/Systems/BodySystem.cs
Content.Server/Construction/ConstructionSystem.Interactions.cs
Content.Server/Tools/ToolSystem.LatticeCutting.cs
Content.Server/Tools/ToolSystem.TilePrying.cs
Content.Shared/Body/Systems/SharedBodySystem.Parts.cs
Content.Shared/Maps/TurfHelpers.cs
Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs
Content.Shared/Tiles/FloorTileSystem.cs

index c16d533a2ec50e4d2c6b9dc46d2f5177380b1687..4800b76b3ac0b3e4498531029239bbb10b0e152b 100644 (file)
@@ -44,7 +44,7 @@ namespace Content.Client.Construction
                 .Bind(ContentKeyFunctions.OpenCraftingMenu,
                     new PointerInputCmdHandler(HandleOpenCraftingMenu))
                 .Bind(EngineKeyFunctions.Use,
-                    new PointerInputCmdHandler(HandleUse))
+                    new PointerInputCmdHandler(HandleUse, outsidePrediction: true))
                 .Register<ConstructionSystem>();
 
             SubscribeLocalEvent<ConstructionGhostComponent, ExaminedEvent>(HandleConstructionGhostExamined);
index 472b6b8acdea71c209dcc8f62c4bbeeeaab3be27..bdc40c52e8e0f1e2ab1c2a4d8d46fda1ba28f1ad 100644 (file)
@@ -98,11 +98,13 @@ public sealed class BodySystem : SharedBodySystem
 
     public override bool DropPart(EntityUid? partId, BodyPartComponent? part = null)
     {
-        var oldBody = CompOrNull<BodyPartComponent>(partId)?.Body;
+        if (partId == null || !Resolve(partId.Value, ref part))
+            return false;
 
         if (!base.DropPart(partId, part))
             return false;
 
+        var oldBody = part.Body;
         if (oldBody == null || !TryComp<HumanoidAppearanceComponent>(oldBody, out var humanoid))
             return true;
 
index e2f538b27f43edb64cde5a6e71e810b6f8040a37..fcbea8efdc1dc139e17abd00e1a0a983103c5e5c 100644 (file)
@@ -34,7 +34,7 @@ namespace Content.Server.Construction
             SubscribeLocalEvent<ConstructionComponent, ConstructionInteractDoAfterEvent>(EnqueueEvent);
 
             // Event handling. Add your subscriptions here! Just make sure they're all handled by EnqueueEvent.
-            SubscribeLocalEvent<ConstructionComponent, InteractUsingEvent>(EnqueueEvent, new []{typeof(AnchorableSystem)typeof(EncryptionKeySystem)});
+            SubscribeLocalEvent<ConstructionComponent, InteractUsingEvent>(EnqueueEvent, new []{typeof(AnchorableSystem)},  new []{typeof(EncryptionKeySystem)});
             SubscribeLocalEvent<ConstructionComponent, OnTemperatureChangeEvent>(EnqueueEvent);
         }
 
index c9d08eb29adb6e2a3af7a33793a8911361e5e2ba..eb4b721d86e52a154b2eb44aa687f77a54332f1b 100644 (file)
@@ -54,7 +54,7 @@ public sealed partial class ToolSystem
 
     private bool TryCut(EntityUid toolEntity, EntityUid user, LatticeCuttingComponent component, EntityCoordinates clickLocation)
     {
-        if (!_mapManager.TryGetGrid(clickLocation.GetGridUid(EntityManager), out var mapGrid))
+        if (!_mapManager.TryFindGridAt(clickLocation.ToMap(EntityManager, _transformSystem), out var mapGrid))
             return false;
 
         var tile = mapGrid.GetTileRef(clickLocation);
@@ -71,7 +71,7 @@ public sealed partial class ToolSystem
             || tile.IsBlockedTurf(true))
             return false;
 
-        var ev = new LatticeCuttingCompleteEvent(clickLocation);
+        var ev = new LatticeCuttingCompleteEvent(coordinates);
         return UseTool(toolEntity, user, toolEntity, component.Delay, component.QualityNeeded, ev);
     }
 }
index cefeccbf749da4d5dbed6b82dc741dd248aa810b..8d760dc05390bc4cb67f0405a6b5c0f2e145e90a 100644 (file)
@@ -52,7 +52,7 @@ public sealed partial class ToolSystem
         if (!TryComp<ToolComponent?>(toolEntity, out var tool) && component.ToolComponentNeeded)
             return false;
 
-        if (!_mapManager.TryGetGrid(clickLocation.GetGridUid(EntityManager), out var mapGrid))
+        if (!_mapManager.TryFindGridAt(clickLocation.ToMap(EntityManager, _transformSystem), out var mapGrid))
             return false;
 
         var tile = mapGrid.GetTileRef(clickLocation);
@@ -67,7 +67,7 @@ public sealed partial class ToolSystem
         if (!tileDef.CanCrowbar)
             return false;
 
-        var ev = new TilePryingDoAfterEvent(clickLocation);
+        var ev = new TilePryingDoAfterEvent(coordinates);
 
         return UseTool(toolEntity, user, toolEntity, component.Delay, component.QualityNeeded, ev, toolComponent: tool);
     }
index 3c2ada65b237dce3ebe8c03e5f0d740df5d2f65b..1b446dff92ab57af994a0062d92fabd9e1006ffc 100644 (file)
@@ -232,7 +232,7 @@ public partial class SharedBodySystem
         return true;
     }
 
-    public virtual bool DropPart(EntityUid? partId, [NotNullWhen(true)] BodyPartComponent? part = null)
+    public virtual bool DropPart(EntityUid? partId, BodyPartComponent? part = null)
     {
         if (partId == null ||
             !Resolve(partId.Value, ref part, false) ||
index ea9b0f9e2fe5cf1463227347965e53f2fd7755a1..3f14e6ed471ffd34fdb2e9efce41884cc88cf038 100644 (file)
@@ -37,13 +37,11 @@ namespace Content.Shared.Maps
             if (!coordinates.IsValid(entityManager))
                 return null;
 
-
             mapManager ??= IoCManager.Resolve<IMapManager>();
-
-            if (!mapManager.TryGetGrid(coordinates.GetGridUid(entityManager), out var grid))
+            var pos = coordinates.ToMap(entityManager, entityManager.System<SharedTransformSystem>());
+            if (!mapManager.TryFindGridAt(pos, out var grid))
                 return null;
 
-
             if (!grid.TryGetTileRef(coordinates, out var tile))
                 return null;
 
index 16d6960d99bb3c4d064e61b1fe7d2b4374d0c08f..8fca649f7a948a365028442944ea78522ddb02e4 100644 (file)
@@ -56,9 +56,13 @@ public sealed class EncryptionKeySystem : EntitySystem
             _hands.PickupOrDrop(args.User, ent);
         }
 
-        // if tool use ever gets predicted this needs changing.
-        _popup.PopupEntity(Loc.GetString("encryption-keys-all-extracted"), uid, args.User);
-        _audio.PlayPvs(component.KeyExtractionSound, uid);
+        if (!_timing.IsFirstTimePredicted)
+            return;
+
+        // TODO add predicted pop-up overrides.
+        if (_net.IsServer)
+            _popup.PopupEntity(Loc.GetString("encryption-keys-all-extracted"), uid, args.User);
+        _audio.PlayPredicted(component.KeyExtractionSound, uid, args.User);
     }
 
     public void UpdateChannels(EntityUid uid, EncryptionKeyHolderComponent component)
@@ -89,7 +93,7 @@ public sealed class EncryptionKeySystem : EntitySystem
 
     private void OnInteractUsing(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
     {
-        if ( args.Handled || !TryComp<ContainerManagerComponent>(uid, out var storage))
+        if (args.Handled)
             return;
 
         if (HasComp<EncryptionKeyComponent>(args.Used))
@@ -97,7 +101,9 @@ public sealed class EncryptionKeySystem : EntitySystem
             args.Handled = true;
             TryInsertKey(uid, component, args);
         }
-        else if (TryComp<ToolComponent>(args.Used, out var tool) && tool.Qualities.Contains(component.KeysExtractionMethod))
+        else if (TryComp<ToolComponent>(args.Used, out var tool)
+                 && tool.Qualities.Contains(component.KeysExtractionMethod)
+                 && component.KeyContainer.ContainedEntities.Count > 0) // dont block deconstruction
         {
             args.Handled = true;
             TryRemoveKey(uid, component, args, tool);
index 0e4c3354769228741675680ac412d8d26af4ea87..0720de468bbdad868892031e6f959b42bc33e214 100644 (file)
@@ -67,7 +67,7 @@ public sealed class FloorTileSystem : EntitySystem
             var results = _physics.IntersectRay(locationMap.MapId, ray, dir.Length, returnOnFirstHit: true);
             canAccessCenter = !results.Any();
         }
-        
+
         // if user can access tile center then they can place floor
         // otherwise check it isn't blocked by a wall
         if (!canAccessCenter)
@@ -117,12 +117,18 @@ public sealed class FloorTileSystem : EntitySystem
             }
             else if (HasBaseTurf(currentTileDefinition, ContentTileDefinition.SpaceID))
             {
+                if (!_stackSystem.Use(uid, 1, stack))
+                    continue;
+
+                args.Handled = true;
+                if (_netManager.IsClient)
+                    return;
+
                 mapGrid = _mapManager.CreateGrid(locationMap.MapId);
                 var gridXform = Transform(mapGrid.Owner);
                 _transform.SetWorldPosition(gridXform, locationMap.Position);
                 location = new EntityCoordinates(mapGrid.Owner, Vector2.Zero);
                 PlaceAt(args.User, mapGrid, location, _tileDefinitionManager[component.OutputTiles[0]].TileId, component.PlaceTileSound, mapGrid.TileSize / 2f);
-                args.Handled = true;
                 return;
             }
         }