Fix being able to use invalid verbs as a ghost (#1157)

* Add CanInteract check to 18 verbs

* Add more caninteract checks to verbs without it

Storage toggle open, ammo box dump, bolt open and close, revolver spin and magazine open and close
This commit is contained in:
DrSmugleaf
2020-06-22 18:54:56 +02:00
committed by GitHub
parent 6fe7d11d54
commit ff0f082138
16 changed files with 192 additions and 68 deletions

View File

@@ -219,23 +219,23 @@ namespace Content.Server.GameObjects.Components.Chemistry
{
protected override void GetData(IEntity user, SolutionComponent component, VerbData data)
{
if (user.TryGetComponent<HandsComponent>(out var hands))
if (!ActionBlockerSystem.CanInteract(user) ||
!user.TryGetComponent<HandsComponent>(out var hands) ||
hands.GetActiveHand == null ||
!hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
{
if (hands.GetActiveHand != null)
{
if (hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
{
if ((solution.Capabilities & SolutionCaps.PourOut) != 0 &&
(component.Capabilities & SolutionCaps.PourIn) != 0)
{
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
var myName = component.Owner.Prototype?.Name ?? "<Item>";
data.Visibility = VerbVisibility.Invisible;
return;
}
data.Text= $"Transfer liquid from [{heldEntityName}] to [{myName}].";
return;
}
}
}
if ((solution.Capabilities & SolutionCaps.PourOut) != 0 &&
(component.Capabilities & SolutionCaps.PourIn) != 0)
{
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
var myName = component.Owner.Prototype?.Name ?? "<Item>";
data.Text= $"Transfer liquid from [{heldEntityName}] to [{myName}].";
return;
}
data.Visibility = VerbVisibility.Invisible;
@@ -318,23 +318,23 @@ namespace Content.Server.GameObjects.Components.Chemistry
{
protected override void GetData(IEntity user, SolutionComponent component, VerbData data)
{
if (user.TryGetComponent<HandsComponent>(out var hands))
if (!ActionBlockerSystem.CanInteract(user) ||
!user.TryGetComponent<HandsComponent>(out var hands) ||
hands.GetActiveHand == null ||
!hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
{
if (hands.GetActiveHand != null)
{
if (hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
{
if ((solution.Capabilities & SolutionCaps.PourIn) != 0 &&
(component.Capabilities & SolutionCaps.PourOut) != 0)
{
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
var myName = component.Owner.Prototype?.Name ?? "<Item>";
data.Visibility = VerbVisibility.Invisible;
return;
}
data.Text = $"Transfer liquid from [{myName}] to [{heldEntityName}].";
return;
}
}
}
if ((solution.Capabilities & SolutionCaps.PourIn) != 0 &&
(component.Capabilities & SolutionCaps.PourOut) != 0)
{
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
var myName = component.Owner.Prototype?.Name ?? "<Item>";
data.Text = $"Transfer liquid from [{myName}] to [{heldEntityName}].";
return;
}
data.Visibility = VerbVisibility.Invisible;