Replace BlockSolutionAccessComponent with an attempt event (#26988)
* BlockSolutionAccessComponent now only blocks one specified solution. * Significant overhaul Separated spilling when worn functionality into its own component/system. Removed BlockSolutionAccessComponent. Added an event for solution access.
This commit is contained in:
@@ -48,6 +48,12 @@ public partial record struct SolutionOverflowEvent(Entity<SolutionComponent> Sol
|
||||
public bool Handled = false;
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public partial record struct SolutionAccessAttemptEvent(string SolutionName)
|
||||
{
|
||||
public bool Cancelled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Part of Chemistry system deal with SolutionContainers
|
||||
/// </summary>
|
||||
@@ -156,12 +162,6 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem
|
||||
[NotNullWhen(true)] out Entity<SolutionComponent>? entity,
|
||||
bool errorOnMissing = false)
|
||||
{
|
||||
if (TryComp(container, out BlockSolutionAccessComponent? blocker))
|
||||
{
|
||||
entity = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityUid uid;
|
||||
if (name is null)
|
||||
uid = container;
|
||||
@@ -170,7 +170,18 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem
|
||||
solutionContainer is ContainerSlot solutionSlot &&
|
||||
solutionSlot.ContainedEntity is { } containedSolution
|
||||
)
|
||||
{
|
||||
var attemptEv = new SolutionAccessAttemptEvent(name);
|
||||
RaiseLocalEvent(container, ref attemptEv);
|
||||
|
||||
if (attemptEv.Cancelled)
|
||||
{
|
||||
entity = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
uid = containedSolution;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity = null;
|
||||
@@ -218,11 +229,14 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem
|
||||
if (!Resolve(container, ref container.Comp, logMissing: false))
|
||||
yield break;
|
||||
|
||||
if (HasComp<BlockSolutionAccessComponent>(container))
|
||||
yield break;
|
||||
|
||||
foreach (var name in container.Comp.Containers)
|
||||
{
|
||||
var attemptEv = new SolutionAccessAttemptEvent(name);
|
||||
RaiseLocalEvent(container, ref attemptEv);
|
||||
|
||||
if (attemptEv.Cancelled)
|
||||
continue;
|
||||
|
||||
if (ContainerSystem.GetContainer(container, $"solution@{name}") is ContainerSlot slot && slot.ContainedEntity is { } solutionId)
|
||||
yield return (name, (solutionId, Comp<SolutionComponent>(solutionId)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user