* Update RobustToolbox * Transition direct type usages * More updates * Fix invalid use of to map * Update RobustToolbox * Fix dropping items * Rename name usages of "GridCoordinates" to "EntityCoordinates" * Revert "Update RobustToolbox" This reverts commit 9f334a17c5908ded0043a63158bb671e4aa3f346. * Revert "Update RobustToolbox" This reverts commit 3a9c8cfa3606fa501aa84407796d2ad920853a09. # Conflicts: # RobustToolbox * Fix cursed IMapGrid method usage. * GridTileLookupTest now uses EntityCoordinates Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <zddm@outlook.es>
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using Content.Server.GameObjects.Components.Mobs;
|
|
using Content.Server.GameObjects.EntitySystems.Click;
|
|
using Content.Server.Utility;
|
|
using Content.Shared.Utility;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Content.Server.AI.Operators.Inventory
|
|
{
|
|
/// <summary>
|
|
/// A Generic interacter; if you need to check stuff then make your own
|
|
/// </summary>
|
|
public class InteractWithEntityOperator : AiOperator
|
|
{
|
|
private readonly IEntity _owner;
|
|
private readonly IEntity _useTarget;
|
|
|
|
public InteractWithEntityOperator(IEntity owner, IEntity useTarget)
|
|
{
|
|
_owner = owner;
|
|
_useTarget = useTarget;
|
|
|
|
}
|
|
|
|
public override Outcome Execute(float frameTime)
|
|
{
|
|
if (_useTarget.Transform.GridID != _owner.Transform.GridID)
|
|
{
|
|
return Outcome.Failed;
|
|
}
|
|
|
|
if (!_owner.InRangeUnobstructed(_useTarget, popup: true))
|
|
{
|
|
return Outcome.Failed;
|
|
}
|
|
|
|
if (_owner.TryGetComponent(out CombatModeComponent combatModeComponent))
|
|
{
|
|
combatModeComponent.IsInCombatMode = false;
|
|
}
|
|
|
|
// Click on da thing
|
|
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
|
|
interactionSystem.UseItemInHand(_owner, _useTarget.Transform.Coordinates, _useTarget.Uid);
|
|
|
|
return Outcome.Success;
|
|
}
|
|
}
|
|
}
|