2020-07-08 09:37:35 +10:00
|
|
|
using System;
|
2020-06-18 22:52:44 +10:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Content.Server.AI.Operators;
|
2020-06-25 01:43:58 +10:00
|
|
|
using Content.Server.AI.Operators.Combat.Melee;
|
2020-06-18 22:52:44 +10:00
|
|
|
using Content.Server.AI.Operators.Movement;
|
|
|
|
|
using Content.Server.AI.Utility.Considerations;
|
|
|
|
|
using Content.Server.AI.Utility.Considerations.Combat;
|
|
|
|
|
using Content.Server.AI.Utility.Considerations.Combat.Melee;
|
2020-07-11 23:09:37 +10:00
|
|
|
using Content.Server.AI.Utility.Considerations.Containers;
|
2020-06-18 22:52:44 +10:00
|
|
|
using Content.Server.AI.Utility.Considerations.Movement;
|
|
|
|
|
using Content.Server.AI.WorldState;
|
|
|
|
|
using Content.Server.AI.WorldState.States;
|
|
|
|
|
using Content.Server.AI.WorldState.States.Combat;
|
|
|
|
|
using Content.Server.AI.WorldState.States.Inventory;
|
|
|
|
|
using Content.Server.AI.WorldState.States.Movement;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Weapon.Melee.Components;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-07-08 09:37:35 +10:00
|
|
|
using Robust.Shared.IoC;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.AI.Utility.Actions.Combat.Melee
|
|
|
|
|
{
|
2020-06-25 01:43:58 +10:00
|
|
|
public sealed class MeleeWeaponAttackEntity : UtilityAction
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
public EntityUid Target { get; set; } = default!;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
public override void SetupOperators(Blackboard context)
|
|
|
|
|
{
|
2020-06-23 02:55:50 +10:00
|
|
|
MoveToEntityOperator moveOperator;
|
2020-07-08 09:37:35 +10:00
|
|
|
var equipped = context.GetState<EquippedEntityState>().GetValue();
|
2021-12-05 18:09:01 +01:00
|
|
|
if (equipped != default && IoCManager.Resolve<IEntityManager>().TryGetComponent(equipped, out MeleeWeaponComponent? meleeWeaponComponent))
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2021-02-20 17:37:17 +11:00
|
|
|
moveOperator = new MoveToEntityOperator(Owner, Target, meleeWeaponComponent.Range - 0.01f);
|
2020-06-23 02:55:50 +10:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-08 09:37:35 +10:00
|
|
|
// TODO: Abort
|
2021-02-20 17:37:17 +11:00
|
|
|
moveOperator = new MoveToEntityOperator(Owner, Target);
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ActionOperators = new Queue<AiOperator>(new AiOperator[]
|
|
|
|
|
{
|
|
|
|
|
moveOperator,
|
2021-02-20 17:37:17 +11:00
|
|
|
new SwingMeleeWeaponOperator(Owner, Target),
|
2020-06-18 22:52:44 +10:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateBlackboard(Blackboard context)
|
|
|
|
|
{
|
|
|
|
|
base.UpdateBlackboard(context);
|
2021-02-20 17:37:17 +11:00
|
|
|
context.GetState<TargetEntityState>().SetValue(Target);
|
|
|
|
|
context.GetState<MoveTargetState>().SetValue(Target);
|
2020-06-18 22:52:44 +10:00
|
|
|
var equipped = context.GetState<EquippedEntityState>().GetValue();
|
|
|
|
|
context.GetState<WeaponEntityState>().SetValue(equipped);
|
|
|
|
|
}
|
2020-11-21 14:02:00 +01:00
|
|
|
|
2020-07-08 09:37:35 +10:00
|
|
|
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
|
|
|
|
|
{
|
|
|
|
|
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();
|
2020-06-18 22:52:44 +10:00
|
|
|
|
2020-07-08 09:37:35 +10:00
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
considerationsManager.Get<TargetIsDeadCon>()
|
|
|
|
|
.InverseBoolCurve(context),
|
|
|
|
|
considerationsManager.Get<TargetIsCritCon>()
|
|
|
|
|
.QuadraticCurve(context, -0.8f, 1.0f, 1.0f, 0.0f),
|
2020-08-12 06:01:55 +10:00
|
|
|
considerationsManager.Get<TargetDistanceCon>()
|
|
|
|
|
.PresetCurve(context, PresetCurve.Distance),
|
2020-07-08 09:37:35 +10:00
|
|
|
considerationsManager.Get<TargetHealthCon>()
|
2020-08-12 06:01:55 +10:00
|
|
|
.PresetCurve(context, PresetCurve.TargetHealth),
|
2020-07-08 09:37:35 +10:00
|
|
|
considerationsManager.Get<MeleeWeaponSpeedCon>()
|
|
|
|
|
.QuadraticCurve(context, 1.0f, 0.5f, 0.0f, 0.0f),
|
|
|
|
|
considerationsManager.Get<MeleeWeaponDamageCon>()
|
|
|
|
|
.QuadraticCurve(context, 1.0f, 0.25f, 0.0f, 0.0f),
|
2020-07-11 23:09:37 +10:00
|
|
|
considerationsManager.Get<TargetAccessibleCon>()
|
|
|
|
|
.BoolCurve(context),
|
2020-07-08 09:37:35 +10:00
|
|
|
};
|
|
|
|
|
}
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
}
|