Fix salvage gibbing (#9426)

This commit is contained in:
wrexbe
2022-07-05 08:03:36 -07:00
committed by GitHub
parent 8c4e17eef3
commit 4766638413
3 changed files with 17 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ using System.Threading.Tasks;
using NUnit.Framework; using NUnit.Framework;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement; using Robust.Client.ResourceManagement;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests namespace Content.IntegrationTests.Tests
@@ -17,11 +18,10 @@ namespace Content.IntegrationTests.Tests
await using var pairTracker = await PoolManager.GetServerClient(); await using var pairTracker = await PoolManager.GetServerClient();
var client = pairTracker.Pair.Client; var client = pairTracker.Pair.Client;
var prototypeManager = client.ResolveDependency<IPrototypeManager>();
var resourceCache = client.ResolveDependency<IResourceCache>();
await client.WaitRunTicks(5);
await client.WaitAssertion(() => await client.WaitAssertion(() =>
{ {
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var resourceCache = IoCManager.Resolve<IResourceCache>();
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.NoSpawn || proto.Abstract || !proto.Components.ContainsKey("Sprite")) continue; if (proto.NoSpawn || proto.Abstract || !proto.Components.ContainsKey("Sprite")) continue;
@@ -33,7 +33,6 @@ namespace Content.IntegrationTests.Tests
proto.ID); proto.ID);
} }
}); });
await client.WaitRunTicks(5);
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();
} }
} }

View File

@@ -20,6 +20,7 @@ using Robust.Shared.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.CodeAnalysis;
namespace Content.Server.Salvage; namespace Content.Server.Salvage;
@@ -63,16 +64,20 @@ public sealed class SalvageMobRestrictionsSystem : EntitySystem
private void OnRemoveGrid(EntityUid uid, SalvageMobRestrictionsGridComponent component, ComponentRemove args) private void OnRemoveGrid(EntityUid uid, SalvageMobRestrictionsGridComponent component, ComponentRemove args)
{ {
foreach (EntityUid target in component.MobsToKill) var metaQuery = GetEntityQuery<MetaDataComponent>();
var bodyQuery = GetEntityQuery<BodyComponent>();
var damageQuery = GetEntityQuery<DamageableComponent>();
foreach (var target in component.MobsToKill)
{ {
if (TryComp(target, out BodyComponent? body)) if (Deleted(target, metaQuery)) continue;
if (bodyQuery.TryGetComponent(target, out var body))
{ {
// Just because. // Just because.
body.Gib(); body.Gib();
} }
else if (TryComp(target, out DamageableComponent? dc)) else if (damageQuery.TryGetComponent(target, out var damageableComponent))
{ {
_damageableSystem.SetAllDamage(dc, 200); _damageableSystem.SetAllDamage(damageableComponent, 200);
} }
} }
} }

View File

@@ -255,8 +255,9 @@ namespace Content.Shared.Body.Components
private void AddedToBody(SharedBodyComponent body) private void AddedToBody(SharedBodyComponent body)
{ {
_entMan.GetComponent<TransformComponent>(Owner).LocalRotation = 0; var transformComponent = _entMan.GetComponent<TransformComponent>(Owner);
_entMan.GetComponent<TransformComponent>(Owner).AttachParent(body.Owner); transformComponent.LocalRotation = 0;
transformComponent.AttachParent(body.Owner);
OnAddedToBody(body); OnAddedToBody(body);
foreach (var mechanism in _mechanisms) foreach (var mechanism in _mechanisms)
@@ -267,9 +268,9 @@ namespace Content.Shared.Body.Components
private void RemovedFromBody(SharedBodyComponent old) private void RemovedFromBody(SharedBodyComponent old)
{ {
if (!_entMan.GetComponent<TransformComponent>(Owner).Deleted) if (_entMan.TryGetComponent<TransformComponent>(Owner, out var transformComponent))
{ {
_entMan.GetComponent<TransformComponent>(Owner).AttachToGridOrMap(); transformComponent.AttachToGridOrMap();
} }
OnRemovedFromBody(old); OnRemovedFromBody(old);