Add utility AI (#806)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.Gloves;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves
|
||||
{
|
||||
/// <summary>
|
||||
/// Equip any head item currently in our inventory
|
||||
/// </summary>
|
||||
public sealed class EquipAnyGlovesExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
if (!owner.TryGetComponent(out AiControllerComponent controller))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.GLOVES) != 0)
|
||||
{
|
||||
yield return new EquipGloves(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.Gloves;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Clothing;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves
|
||||
{
|
||||
public sealed class PickUpAnyNearbyGlovesExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.GLOVES) != 0)
|
||||
{
|
||||
yield return new PickUpGloves(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.Head;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head
|
||||
{
|
||||
/// <summary>
|
||||
/// Equip any head item currently in our inventory
|
||||
/// </summary>
|
||||
public sealed class EquipAnyHeadExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.HEAD) != 0)
|
||||
{
|
||||
yield return new EquipHead(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.Head;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Clothing;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head
|
||||
{
|
||||
public sealed class PickUpAnyNearbyHeadExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.HEAD) != 0)
|
||||
{
|
||||
yield return new PickUpHead(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.OuterClothing;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing
|
||||
{
|
||||
/// <summary>
|
||||
/// Equip any head item currently in our inventory
|
||||
/// </summary>
|
||||
public sealed class EquipAnyOuterClothingExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.OUTERCLOTHING) != 0)
|
||||
{
|
||||
yield return new EquipOuterClothing(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.OuterClothing;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Clothing;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing
|
||||
{
|
||||
public sealed class PickUpAnyNearbyOuterClothingExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.OUTERCLOTHING) != 0)
|
||||
{
|
||||
yield return new PickUpOuterClothing(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.Shoes;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes
|
||||
{
|
||||
/// <summary>
|
||||
/// Equip any head item currently in our inventory
|
||||
/// </summary>
|
||||
public sealed class EquipAnyShoesExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.SHOES) != 0)
|
||||
{
|
||||
yield return new EquipShoes(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Clothing.Shoes;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Clothing;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes
|
||||
{
|
||||
public sealed class PickUpAnyNearbyShoesExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NormalBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
|
||||
{
|
||||
if (entity.TryGetComponent(out ClothingComponent clothing) &&
|
||||
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.SHOES) != 0)
|
||||
{
|
||||
yield return new PickUpShoes(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Melee;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee
|
||||
{
|
||||
public sealed class EquipMeleeExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
yield return new EquipMelee(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Melee;
|
||||
using Content.Server.AI.Utils;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee
|
||||
{
|
||||
public sealed class MeleeAttackNearbyPlayerExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
if (!owner.TryGetComponent(out AiControllerComponent controller))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(owner.Transform.GridPosition, typeof(SpeciesComponent),
|
||||
controller.VisionRadius))
|
||||
{
|
||||
if (entity.HasComponent<BasicActorComponent>() && entity != owner)
|
||||
{
|
||||
yield return new MeleeAttackEntity(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Melee;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Mobs;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee
|
||||
{
|
||||
public sealed class MeleeAttackNearbySpeciesExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
foreach (var entity in context.GetState<NearbySpeciesState>().GetValue())
|
||||
{
|
||||
yield return new MeleeAttackEntity(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Melee;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Combat.Nearby;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee
|
||||
{
|
||||
public sealed class PickUpMeleeWeaponExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<NearbyMeleeWeapons>().GetValue())
|
||||
{
|
||||
yield return new PickUpMeleeWeapon(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Ballistic;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects.Components.Weapon.Ranged.Projectile;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged.Ballistic
|
||||
{
|
||||
public sealed class DropEmptyBallisticExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
if (entity.HasComponent<BallisticMagazineWeaponComponent>())
|
||||
{
|
||||
yield return new DropEmptyBallistic(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Ballistic;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged.Ballistic
|
||||
{
|
||||
public sealed class EquipBallisticExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
yield return new EquipBallistic(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Ballistic;
|
||||
using Content.Server.AI.Utils;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Server.GameObjects.Components.Weapon.Ranged.Projectile;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged.Ballistic
|
||||
{
|
||||
public sealed class PickUpAmmoExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
if (!owner.TryGetComponent(out AiControllerComponent controller))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(owner.Transform.GridPosition, typeof(BallisticMagazineComponent),
|
||||
controller.VisionRadius))
|
||||
{
|
||||
yield return new PickUpAmmo(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Hitscan;
|
||||
using Content.Server.AI.Utils;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Server.GameObjects.Components.Power.Chargers;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged.Hitscan
|
||||
{
|
||||
public sealed class ChargeEquippedHitscanExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
if (!owner.TryGetComponent(out AiControllerComponent controller))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(owner.Transform.GridPosition, typeof(WeaponCapacitorChargerComponent),
|
||||
controller.VisionRadius))
|
||||
{
|
||||
yield return new PutHitscanInCharger(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Hitscan;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged.Hitscan
|
||||
{
|
||||
public class DropEmptyHitscanExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
if (entity.HasComponent<HitscanWeaponComponent>())
|
||||
{
|
||||
yield return new DropEmptyHitscan(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Hitscan;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged.Hitscan
|
||||
{
|
||||
public sealed class EquipHitscanExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
yield return new EquipHitscan(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Hitscan;
|
||||
using Content.Server.AI.Utils;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Server.GameObjects.Components.Power.Chargers;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged.Hitscan
|
||||
{
|
||||
public sealed class PickUpHitscanFromChargersExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
if (!owner.TryGetComponent(out AiControllerComponent controller))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(owner.Transform.GridPosition, typeof(WeaponCapacitorChargerComponent),
|
||||
controller.VisionRadius))
|
||||
{
|
||||
var contained = entity.GetComponent<WeaponCapacitorChargerComponent>().HeldItem;
|
||||
|
||||
if (contained != null)
|
||||
{
|
||||
yield return new PickUpHitscanFromCharger(owner, entity, contained, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Ballistic;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Hitscan;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Combat.Nearby;
|
||||
using Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan;
|
||||
using Content.Server.GameObjects.Components.Weapon.Ranged.Projectile;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged
|
||||
{
|
||||
public sealed class PickUpRangedExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatPrepBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<NearbyRangedWeapons>().GetValue())
|
||||
{
|
||||
if (entity.HasComponent<HitscanWeaponComponent>())
|
||||
{
|
||||
yield return new PickUpHitscanWeapon(owner, entity, Bonus);
|
||||
}
|
||||
|
||||
if (entity.HasComponent<BallisticMagazineWeaponComponent>())
|
||||
{
|
||||
yield return new PickUpBallisticMagWeapon(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Ballistic;
|
||||
using Content.Server.AI.Utility.Actions.Combat.Ranged.Hitscan;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Mobs;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Ranged
|
||||
{
|
||||
public sealed class RangedAttackNearbySpeciesExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.CombatBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<NearbySpeciesState>().GetValue())
|
||||
{
|
||||
yield return new HitscanAttackEntity(owner, entity, Bonus);
|
||||
yield return new BallisticAttackEntity(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.WorldState;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Expands into multiple separate utility actions for consideration, e.g. 5 nearby weapons 5 different actions
|
||||
/// Ideally you would use the cached states for this
|
||||
/// </summary>
|
||||
public abstract class ExpandableUtilityAction : IAiUtility
|
||||
{
|
||||
public abstract float Bonus { get; }
|
||||
|
||||
// e.g. you may have a "PickupFood" action for all nearby food sources if you have the "Hungry" BehaviorSet.
|
||||
public abstract IEnumerable<UtilityAction> GetActions(Blackboard context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Nutrition.Drink;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Nutrition;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Nutrition
|
||||
{
|
||||
public sealed class PickUpNearbyDrinkExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NeedsBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<NearbyDrinkState>().GetValue())
|
||||
{
|
||||
yield return new PickUpDrink(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Nutrition.Food;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Nutrition;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Nutrition
|
||||
{
|
||||
public sealed class PickUpNearbyFoodExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NeedsBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<NearbyFoodState>().GetValue())
|
||||
{
|
||||
yield return new PickUpFood(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Nutrition.Drink;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Nutrition
|
||||
{
|
||||
public sealed class UseDrinkInHandsExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NeedsBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
yield return new UseDrinkInInventory(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.AI.Utility.Actions;
|
||||
using Content.Server.AI.Utility.Actions.Nutrition.Food;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
|
||||
namespace Content.Server.AI.Utility.ExpandableActions.Nutrition
|
||||
{
|
||||
public sealed class UseFoodInInventoryExp : ExpandableUtilityAction
|
||||
{
|
||||
public override float Bonus => UtilityAction.NeedsBonus;
|
||||
|
||||
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
foreach (var entity in context.GetState<InventoryState>().GetValue())
|
||||
{
|
||||
yield return new UseFoodInInventory(owner, entity, Bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user