Fix salvage gibbing (#9426)
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
@@ -17,11 +18,10 @@ namespace Content.IntegrationTests.Tests
|
||||
await using var pairTracker = await PoolManager.GetServerClient();
|
||||
var client = pairTracker.Pair.Client;
|
||||
|
||||
var prototypeManager = client.ResolveDependency<IPrototypeManager>();
|
||||
var resourceCache = client.ResolveDependency<IResourceCache>();
|
||||
await client.WaitRunTicks(5);
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
||||
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.NoSpawn || proto.Abstract || !proto.Components.ContainsKey("Sprite")) continue;
|
||||
@@ -33,7 +33,6 @@ namespace Content.IntegrationTests.Tests
|
||||
proto.ID);
|
||||
}
|
||||
});
|
||||
await client.WaitRunTicks(5);
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ using Robust.Shared.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Content.Server.Salvage;
|
||||
|
||||
@@ -63,16 +64,20 @@ public sealed class SalvageMobRestrictionsSystem : EntitySystem
|
||||
|
||||
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.
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,8 +255,9 @@ namespace Content.Shared.Body.Components
|
||||
|
||||
private void AddedToBody(SharedBodyComponent body)
|
||||
{
|
||||
_entMan.GetComponent<TransformComponent>(Owner).LocalRotation = 0;
|
||||
_entMan.GetComponent<TransformComponent>(Owner).AttachParent(body.Owner);
|
||||
var transformComponent = _entMan.GetComponent<TransformComponent>(Owner);
|
||||
transformComponent.LocalRotation = 0;
|
||||
transformComponent.AttachParent(body.Owner);
|
||||
OnAddedToBody(body);
|
||||
|
||||
foreach (var mechanism in _mechanisms)
|
||||
@@ -267,9 +268,9 @@ namespace Content.Shared.Body.Components
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user