Files
tbd-station-14/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

49 lines
1.5 KiB
C#

using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.EntitySystems.Click;
using Content.Shared.Utility;
using Robust.Shared.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;
}
}
}