Add GrantContainedActions() (#21206)
This commit is contained in:
@@ -494,6 +494,9 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
(TryComp(action.Container, out ActionsContainerComponent? containerComp)
|
||||
&& containerComp.Container.Contains(actionId)));
|
||||
|
||||
if (action.AttachedEntity != null)
|
||||
RemoveAction(action.AttachedEntity.Value, actionId, action: action);
|
||||
|
||||
DebugTools.AssertOwner(performer, comp);
|
||||
comp ??= EnsureComp<ActionsComponent>(performer);
|
||||
action.AttachedEntity = performer;
|
||||
@@ -532,6 +535,26 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grants all actions currently contained in some action-container. If the target entity has no action
|
||||
/// component, this will give them one.
|
||||
/// </summary>
|
||||
/// <param name="performer">Entity to receive the actions</param>
|
||||
/// <param name="container">The entity that contains thee actions.</param>
|
||||
public void GrantContainedActions(Entity<ActionsComponent?> performer, Entity<ActionsContainerComponent?> container)
|
||||
{
|
||||
if (!Resolve(container, ref container.Comp))
|
||||
return;
|
||||
|
||||
performer.Comp ??= EnsureComp<ActionsComponent>(performer);
|
||||
|
||||
foreach (var actionId in container.Comp.Container.ContainedEntities)
|
||||
{
|
||||
if (TryGetActionData(actionId, out var action))
|
||||
AddActionDirect(performer, actionId, performer.Comp, action);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<(EntityUid Id, BaseActionComponent Comp)> GetActions(EntityUid holderId, ActionsComponent? actions = null)
|
||||
{
|
||||
if (!Resolve(holderId, ref actions, false))
|
||||
|
||||
Reference in New Issue
Block a user