Action, Action Container, and Action Upgrade changes (#24005)

* Added TransferActionWithNewAttached and TransferAllActionsWithNewAttached and OnActionAdded event method to ActionContainerSystem. These are needed where the action needs to have a different attached entity for usage.  Fixed a bug with not being able to upgrade actions between levels.  Added a way to grant and remove a singular action.

* adds an action container component to mind on action added to fix tests

* Swaps trycomp for hascomp

* Maybe this will fix the thests

* Grants action container to performer as well

* Wait that makes no sense, removing that

* fixes mind action grant logic

* Changes ent check back to netent check

* Reverts unintended container changes
This commit is contained in:
keronshb
2024-01-15 01:37:38 -05:00
committed by GitHub
parent ff3fe2e79b
commit c8466055ef
5 changed files with 182 additions and 22 deletions

View File

@@ -691,6 +691,24 @@ public abstract class SharedActionsSystem : EntitySystem
}
}
/// <summary>
/// Grants the provided action from the container to the target entity. If the target entity has no action
/// component, this will give them one.
/// </summary>
/// <param name="performer"></param>
/// <param name="container"></param>
/// <param name="actionId"></param>
public void GrantContainedAction(Entity<ActionsComponent?> performer, Entity<ActionsContainerComponent?> container, EntityUid actionId)
{
if (!Resolve(container, ref container.Comp))
return;
performer.Comp ??= EnsureComp<ActionsComponent>(performer);
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))
@@ -723,6 +741,18 @@ public abstract class SharedActionsSystem : EntitySystem
}
}
/// <summary>
/// Removes a single provided action provided by another entity.
/// </summary>
public void RemoveProvidedAction(EntityUid performer, EntityUid container, EntityUid actionId, ActionsComponent? comp = null)
{
if (!Resolve(performer, ref comp, false) || !TryGetActionData(actionId, out var action))
return;
if (action.Container == container)
RemoveAction(performer, actionId, comp);
}
public void RemoveAction(EntityUid? actionId)
{
if (actionId == null)