Fix misc bugs (#15314)

This commit is contained in:
Leon Friedrich
2023-04-12 12:18:30 +12:00
committed by GitHub
parent d068c4f36b
commit 21378f6e41
9 changed files with 31 additions and 19 deletions

View 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);

View 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;

View 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);
}

View 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);
}
}

View 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);
}

View 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) ||

View 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;

View File

@@ -56,9 +56,13 @@ public sealed class EncryptionKeySystem : EntitySystem
_hands.PickupOrDrop(args.User, ent);
}
// if tool use ever gets predicted this needs changing.
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.PlayPvs(component.KeyExtractionSound, uid);
_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);

View File

@@ -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;
}
}