No atmos stacking (attempt 2) (#16687)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -3,17 +3,28 @@ using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Construction.EntitySystems;
|
||||
|
||||
public abstract class SharedAnchorableSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
|
||||
protected EntityQuery<TagComponent> TagQuery;
|
||||
|
||||
public const string Unstackable = "Unstackable";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
TagQuery = GetEntityQuery<TagComponent>();
|
||||
|
||||
SubscribeLocalEvent<AnchorableComponent, InteractUsingEvent>(OnInteractUsing,
|
||||
before: new[] { typeof(ItemSlotsSystem) }, after: new[] { typeof(SharedConstructionSystem) });
|
||||
}
|
||||
@@ -42,6 +53,38 @@ public abstract class SharedAnchorableSystem : EntitySystem
|
||||
// TODO tool system is fixed now, make this actually shared.
|
||||
}
|
||||
|
||||
public bool AnyUnstackablesAnchoredAt(EntityCoordinates location)
|
||||
{
|
||||
var gridUid = location.GetGridUid(EntityManager);
|
||||
|
||||
if (!TryComp<MapGridComponent>(gridUid, out var grid))
|
||||
return false;
|
||||
|
||||
var enumerator = grid.GetAnchoredEntitiesEnumerator(grid.LocalToTile(location));
|
||||
|
||||
while (enumerator.MoveNext(out var entity))
|
||||
{
|
||||
// If we find another unstackable here, return true.
|
||||
if (_tagSystem.HasTag(entity.Value, Unstackable, TagQuery))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AnyUnstackable(EntityUid uid, EntityCoordinates location)
|
||||
{
|
||||
// If we are unstackable, iterate through any other entities anchored on the current square
|
||||
if (_tagSystem.HasTag(uid, Unstackable, TagQuery))
|
||||
{
|
||||
return AnyUnstackablesAnchoredAt(location);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class TryUnanchorCompletedEvent : SimpleDoAfterEvent
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user