2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.CombatMode;
|
|
|
|
|
using Content.Server.Interaction;
|
|
|
|
|
using Content.Shared.Interaction.Helpers;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-06-18 22:52:44 +10:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-30 11:37:06 +02:00
|
|
|
if (!_owner.InRangeUnobstructed(_useTarget, popup: true))
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
return Outcome.Failed;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 15:50:20 +01:00
|
|
|
if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent))
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
combatModeComponent.IsInCombatMode = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Click on da thing
|
|
|
|
|
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
|
2021-06-07 05:49:43 -07:00
|
|
|
interactionSystem.AiUseInteraction(_owner, _useTarget.Transform.Coordinates, _useTarget.Uid);
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
return Outcome.Success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|