Fix being able to do most verbs from within a container (#1613)

* Fix being able to do most verbs from within a container

* Fix missing container check when using global verbs
This commit is contained in:
DrSmugleaf
2020-08-15 20:38:37 +02:00
committed by GitHub
parent f37d6343ce
commit add4986001
7 changed files with 77 additions and 22 deletions

View File

@@ -2,6 +2,7 @@
using System.Reflection;
using Content.Shared.GameObjects.Verbs;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
@@ -37,6 +38,12 @@ namespace Content.Server.GameObjects.EntitySystems
var session = eventArgs.SenderSession;
var userEntity = session.AttachedEntity;
if (userEntity == null)
{
Logger.Warning($"{nameof(UseVerb)} called by player {session} with no attached entity.");
return;
}
foreach (var (component, verb) in VerbUtility.GetVerbs(entity))
{
if ($"{component.GetType()}:{verb.GetType()}" != use.VerbKey)
@@ -44,14 +51,14 @@ namespace Content.Server.GameObjects.EntitySystems
continue;
}
if (verb.RequireInteractionRange)
if (verb.RequireInteractionRange && !VerbUtility.InVerbUseRange(userEntity, entity))
{
var distanceSquared = (userEntity.Transform.WorldPosition - entity.Transform.WorldPosition)
.LengthSquared;
if (distanceSquared > VerbUtility.InteractionRangeSquared)
{
break;
}
break;
}
if (verb.BlockedByContainers && !userEntity.IsInSameOrNoContainer(entity))
{
break;
}
verb.Activate(userEntity, component);
@@ -65,14 +72,15 @@ namespace Content.Server.GameObjects.EntitySystems
continue;
}
if (globalVerb.RequireInteractionRange)
if (globalVerb.RequireInteractionRange &&
!VerbUtility.InVerbUseRange(userEntity, entity))
{
var distanceSquared = (userEntity.Transform.WorldPosition - entity.Transform.WorldPosition)
.LengthSquared;
if (distanceSquared > VerbUtility.InteractionRangeSquared)
{
break;
}
break;
}
if (globalVerb.BlockedByContainers && !userEntity.IsInSameOrNoContainer(entity))
{
break;
}
globalVerb.Activate(userEntity, entity);
@@ -92,6 +100,12 @@ namespace Content.Server.GameObjects.EntitySystems
var userEntity = player.AttachedEntity;
if (userEntity == null)
{
Logger.Warning($"{nameof(UseVerb)} called by player {player} with no attached entity.");
return;
}
var data = new List<VerbsResponseMessage.NetVerbData>();
//Get verbs, component dependent.
foreach (var (component, verb) in VerbUtility.GetVerbs(entity))
@@ -99,6 +113,9 @@ namespace Content.Server.GameObjects.EntitySystems
if (verb.RequireInteractionRange && !VerbUtility.InVerbUseRange(userEntity, entity))
continue;
if (verb.BlockedByContainers && !userEntity.IsInSameOrNoContainer(entity))
continue;
var verbData = verb.GetData(userEntity, component);
if (verbData.IsInvisible)
continue;
@@ -113,6 +130,9 @@ namespace Content.Server.GameObjects.EntitySystems
if (globalVerb.RequireInteractionRange && !VerbUtility.InVerbUseRange(userEntity, entity))
continue;
if (globalVerb.BlockedByContainers && !userEntity.IsInSameOrNoContainer(entity))
continue;
var verbData = globalVerb.GetData(userEntity, entity);
if (verbData.IsInvisible)
continue;