Verb invocation command (#5148)

This commit is contained in:
mirrorcult
2021-11-04 23:48:30 -07:00
committed by GitHub
parent 418e3eaef8
commit 3e8f5784a1
6 changed files with 230 additions and 14 deletions

View File

@@ -74,7 +74,7 @@ namespace Content.Shared.Verbs
/// </remarks>
public class GetInteractionVerbsEvent : GetVerbsEvent
{
public GetInteractionVerbsEvent(IEntity user, IEntity target) : base(user, target) { }
public GetInteractionVerbsEvent(IEntity user, IEntity target, bool force=false) : base(user, target, force) { }
}
/// <summary>
@@ -88,11 +88,11 @@ namespace Content.Shared.Verbs
/// </remarks>
public class GetActivationVerbsEvent : GetVerbsEvent
{
public GetActivationVerbsEvent(IEntity user, IEntity target) : base(user, target) { }
public GetActivationVerbsEvent(IEntity user, IEntity target, bool force=false) : base(user, target, force) { }
}
/// <summary>
/// Request alternative-interaction verbs.
/// Request alternative-interaction verbs.
/// </summary>
/// <remarks>
/// When interacting with an entity via alt + left-click/E/Z the highest priority alt-interact verb is executed.
@@ -100,11 +100,11 @@ namespace Content.Shared.Verbs
/// </remarks>
public class GetAlternativeVerbsEvent : GetVerbsEvent
{
public GetAlternativeVerbsEvent(IEntity user, IEntity target) : base(user, target) { }
public GetAlternativeVerbsEvent(IEntity user, IEntity target, bool force=false) : base(user, target, force) { }
}
/// <summary>
/// Request Miscellaneous verbs.
/// Request Miscellaneous verbs.
/// </summary>
/// <remarks>
/// Includes (nearly) global interactions like "examine", "pull", or "debug". These verbs are collectively shown
@@ -112,7 +112,7 @@ namespace Content.Shared.Verbs
/// </remarks>
public class GetOtherVerbsEvent : GetVerbsEvent
{
public GetOtherVerbsEvent(IEntity user, IEntity target) : base(user, target) { }
public GetOtherVerbsEvent(IEntity user, IEntity target, bool force=false) : base(user, target, force) { }
}
/// <summary>
@@ -171,18 +171,18 @@ namespace Content.Shared.Verbs
/// </remarks>
public IEntity? Using;
public GetVerbsEvent(IEntity user, IEntity target)
public GetVerbsEvent(IEntity user, IEntity target, bool force=false)
{
User = user;
Target = target;
CanAccess = (Target == User) || user.IsInSameOrParentContainer(target) &&
CanAccess = force || (Target == User) || user.IsInSameOrParentContainer(target) &&
EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(user, target);
// A large number of verbs need to check action blockers. Instead of repeatedly having each system individually
// call ActionBlocker checks, just cache it for the verb request.
var actionBlockerSystem = EntitySystem.Get<ActionBlockerSystem>();
CanInteract = actionBlockerSystem.CanInteract(user);
CanInteract = force || actionBlockerSystem.CanInteract(user);
if (!user.TryGetComponent(out Hands) ||
!actionBlockerSystem.CanUse(user))