Remove entity storage compref (#19557)

This commit is contained in:
metalgearsloth
2023-08-31 18:32:03 +10:00
committed by GitHub
parent d1d9e4dcc3
commit 609bf63893
3 changed files with 31 additions and 13 deletions

View File

@@ -1,8 +1,13 @@
using Content.Shared.Storage.EntitySystems;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Storage.Components;
using Content.Shared.Storage.EntitySystems;
namespace Content.Client.Storage.Systems;
public sealed class EntityStorageSystem : SharedEntityStorageSystem
{
public override bool ResolveStorage(EntityUid uid, [NotNullWhen(true)] ref SharedEntityStorageComponent? component)
{
return Resolve(uid, ref component);
}
}

View File

@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Construction;
using Content.Server.Construction.Components;
@@ -49,6 +50,11 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
_construction.AddContainer(uid, ContainerName, construction);
}
public override bool ResolveStorage(EntityUid uid, [NotNullWhen(true)] ref SharedEntityStorageComponent? component)
{
return Resolve(uid, ref component);
}
private void OnWeldableAttempt(EntityUid uid, EntityStorageComponent component, WeldableAttemptEvent args)
{
if (component.Open)

View File

@@ -1,4 +1,5 @@
using System.Linq;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using Content.Shared.Body.Components;
using Content.Shared.Destructible;
@@ -100,6 +101,8 @@ public abstract class SharedEntityStorageSystem : EntitySystem
ToggleOpen(args.User, uid, component);
}
public abstract bool ResolveStorage(EntityUid uid, [NotNullWhen(true)] ref SharedEntityStorageComponent? component);
private void OnLockToggleAttempt(EntityUid uid, SharedEntityStorageComponent target, ref LockToggleAttemptEvent args)
{
// Cannot (un)lock open lockers.
@@ -169,7 +172,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public void ToggleOpen(EntityUid user, EntityUid target, SharedEntityStorageComponent? component = null)
{
if (!Resolve(target, ref component))
if (!ResolveStorage(target, ref component))
return;
if (component.Open)
@@ -184,7 +187,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public void EmptyContents(EntityUid uid, SharedEntityStorageComponent? component = null)
{
if (!Resolve(uid, ref component))
if (!ResolveStorage(uid, ref component))
return;
var uidXform = Transform(uid);
@@ -197,7 +200,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public void OpenStorage(EntityUid uid, SharedEntityStorageComponent? component = null)
{
if (!Resolve(uid, ref component))
if (!ResolveStorage(uid, ref component))
return;
var beforeev = new StorageBeforeOpenEvent();
@@ -215,8 +218,9 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public void CloseStorage(EntityUid uid, SharedEntityStorageComponent? component = null)
{
if (!Resolve(uid, ref component))
if (!ResolveStorage(uid, ref component))
return;
component.Open = false;
Dirty(component);
@@ -254,7 +258,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public bool Insert(EntityUid toInsert, EntityUid container, SharedEntityStorageComponent? component = null)
{
if (!Resolve(container, ref component))
if (!ResolveStorage(container, ref component))
return false;
if (component.Open)
@@ -271,7 +275,10 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public bool Remove(EntityUid toRemove, EntityUid container, SharedEntityStorageComponent? component = null, TransformComponent? xform = null)
{
if (!Resolve(container, ref component, ref xform, false))
if (!Resolve(container, ref xform, false))
return false;
if (!ResolveStorage(container, ref component))
return false;
RemComp<InsideEntityStorageComponent>(toRemove);
@@ -283,7 +290,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public bool CanInsert(EntityUid container, SharedEntityStorageComponent? component = null)
{
if (!Resolve(container, ref component))
if (!ResolveStorage(container, ref component))
return false;
if (component.Open)
@@ -317,7 +324,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public bool CanOpen(EntityUid user, EntityUid target, bool silent = false, SharedEntityStorageComponent? component = null)
{
if (!Resolve(target, ref component))
if (!ResolveStorage(target, ref component))
return false;
if (!HasComp<HandsComponent>(user))
@@ -359,7 +366,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
public bool AddToContents(EntityUid toAdd, EntityUid container, SharedEntityStorageComponent? component = null)
{
if (!Resolve(container, ref component))
if (!ResolveStorage(container, ref component))
return false;
if (toAdd == container)
@@ -419,7 +426,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
private void ModifyComponents(EntityUid uid, SharedEntityStorageComponent? component = null)
{
if (!Resolve(uid, ref component))
if (!ResolveStorage(uid, ref component))
return;
if (!component.IsCollidableWhenOpen && TryComp<FixturesComponent>(uid, out var fixtures) &&