Fix 3000 errors
This commit is contained in:
@@ -12,18 +12,18 @@ namespace Content.Server.AI.WorldState
|
||||
{
|
||||
// Some stuff like "My Health" is easy to represent as components but abstract stuff like "How much food is nearby"
|
||||
// is harder. This also allows data to be cached if it's being hit frequently.
|
||||
|
||||
|
||||
// This also stops you from re-writing the same boilerplate everywhere of stuff like "Do I have OuterClothing on?"
|
||||
|
||||
private readonly Dictionary<Type, IAiState> _states = new();
|
||||
private readonly List<IPlanningState> _planningStates = new();
|
||||
|
||||
public Blackboard(IEntity owner)
|
||||
public Blackboard(EntityUid owner)
|
||||
{
|
||||
Setup(owner);
|
||||
}
|
||||
|
||||
private void Setup(IEntity owner)
|
||||
private void Setup(EntityUid owner)
|
||||
{
|
||||
var typeFactory = IoCManager.Resolve<IDynamicTypeFactory>();
|
||||
var blackboardManager = IoCManager.Resolve<BlackboardManager>();
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Content.Server.AI.WorldState
|
||||
/// </summary>
|
||||
public interface IAiState
|
||||
{
|
||||
void Setup(IEntity owner);
|
||||
void Setup(EntityUid owner);
|
||||
}
|
||||
|
||||
public interface IPlanningState
|
||||
@@ -32,9 +32,9 @@ namespace Content.Server.AI.WorldState
|
||||
public abstract class StateData<T> : IAiState
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
protected IEntity Owner { get; private set; } = default!;
|
||||
protected EntityUid Owner { get; private set; } = default!;
|
||||
|
||||
public void Setup(IEntity owner)
|
||||
public void Setup(EntityUid owner)
|
||||
{
|
||||
Owner = owner;
|
||||
}
|
||||
@@ -51,11 +51,11 @@ namespace Content.Server.AI.WorldState
|
||||
{
|
||||
// Probably not the best class name but couldn't think of anything better
|
||||
public abstract string Name { get; }
|
||||
private IEntity? Owner { get; set; }
|
||||
private EntityUid Owner { get; set; }
|
||||
|
||||
private T? _value;
|
||||
|
||||
public void Setup(IEntity owner)
|
||||
public void Setup(EntityUid owner)
|
||||
{
|
||||
Owner = owner;
|
||||
}
|
||||
@@ -79,10 +79,10 @@ namespace Content.Server.AI.WorldState
|
||||
public abstract class PlanningStateData<T> : IAiState, IPlanningState
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
protected IEntity? Owner { get; private set; }
|
||||
protected EntityUid Owner { get; private set; }
|
||||
protected T? Value;
|
||||
|
||||
public void Setup(IEntity owner)
|
||||
public void Setup(EntityUid owner)
|
||||
{
|
||||
Owner = owner;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ namespace Content.Server.AI.WorldState
|
||||
public abstract class CachedStateData<T> : IAiState, ICachedState
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
protected IEntity Owner { get; private set; } = default!;
|
||||
protected EntityUid Owner { get; private set; } = default!;
|
||||
private bool _cached;
|
||||
protected T Value = default!;
|
||||
private TimeSpan _lastCache = TimeSpan.Zero;
|
||||
@@ -117,7 +117,7 @@ namespace Content.Server.AI.WorldState
|
||||
/// </summary>
|
||||
protected double CacheTime { get; set; } = 2.0f;
|
||||
|
||||
public void Setup(IEntity owner)
|
||||
public void Setup(EntityUid owner)
|
||||
{
|
||||
Owner = owner;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Clothing
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class EquippedClothingState : StateData<Dictionary<EquipmentSlotDefines.Slots, IEntity>>
|
||||
public sealed class EquippedClothingState : StateData<Dictionary<EquipmentSlotDefines.Slots, EntityUid>>
|
||||
{
|
||||
public override string Name => "EquippedClothing";
|
||||
|
||||
public override Dictionary<EquipmentSlotDefines.Slots, IEntity> GetValue()
|
||||
public override Dictionary<EquipmentSlotDefines.Slots, EntityUid> GetValue()
|
||||
{
|
||||
var result = new Dictionary<EquipmentSlotDefines.Slots, IEntity>();
|
||||
var result = new Dictionary<EquipmentSlotDefines.Slots, EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out InventoryComponent? inventoryComponent))
|
||||
{
|
||||
|
||||
@@ -11,13 +11,13 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Clothing
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NearbyClothingState : CachedStateData<List<IEntity>>
|
||||
public sealed class NearbyClothingState : CachedStateData<List<EntityUid>>
|
||||
{
|
||||
public override string Name => "NearbyClothing";
|
||||
|
||||
protected override List<IEntity> GetTrueValue()
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
|
||||
@@ -9,13 +9,13 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Combat.Nearby
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NearbyMeleeWeapons : CachedStateData<List<IEntity>>
|
||||
public sealed class NearbyMeleeWeapons : CachedStateData<List<EntityUid>>
|
||||
{
|
||||
public override string Name => "NearbyMeleeWeapons";
|
||||
|
||||
protected override List<IEntity> GetTrueValue()
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
|
||||
@@ -4,13 +4,13 @@ using Robust.Shared.GameObjects;
|
||||
namespace Content.Server.AI.WorldState.States.Combat
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class WeaponEntityState : PlanningStateData<IEntity>
|
||||
public sealed class WeaponEntityState : PlanningStateData<EntityUid>
|
||||
{
|
||||
// Similar to TargetEntity
|
||||
public override string Name => "WeaponEntity";
|
||||
public override void Reset()
|
||||
{
|
||||
Value = null;
|
||||
Value = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Hands
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class HandItemsState : StateData<List<IEntity>>
|
||||
public class HandItemsState : StateData<List<EntityUid>>
|
||||
{
|
||||
public override string Name => "HandItems";
|
||||
public override List<IEntity> GetValue()
|
||||
public override List<EntityUid> GetValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
var result = new List<EntityUid>();
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return result;
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
||||
/// AKA what's in active hand
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class EquippedEntityState : StateData<IEntity>
|
||||
public sealed class EquippedEntityState : StateData<EntityUid>
|
||||
{
|
||||
public override string Name => "EquippedEntity";
|
||||
|
||||
public override IEntity? GetValue()
|
||||
public override EntityUid GetValue()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return null;
|
||||
return default;
|
||||
}
|
||||
|
||||
return handsComponent.GetActiveHand?.Owner;
|
||||
return handsComponent.GetActiveHand?.Owner ?? default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Inventory
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class EnumerableInventoryState : StateData<IEnumerable<IEntity>>
|
||||
public sealed class EnumerableInventoryState : StateData<IEnumerable<EntityUid>>
|
||||
{
|
||||
public override string Name => "EnumerableInventory";
|
||||
|
||||
public override IEnumerable<IEntity> GetValue()
|
||||
public override IEnumerable<EntityUid> GetValue()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
|
||||
@@ -9,16 +9,16 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
||||
/// If we open a storage locker than it will be stored here
|
||||
/// Useful if we want to close it after
|
||||
/// </summary>
|
||||
public sealed class LastOpenedStorageState : StoredStateData<IEntity>
|
||||
public sealed class LastOpenedStorageState : StoredStateData<EntityUid>
|
||||
{
|
||||
// TODO: IF we chain lockers need to handle it.
|
||||
// Fine for now I guess
|
||||
public override string Name => "LastOpenedStorage";
|
||||
|
||||
public override void SetValue(IEntity? value)
|
||||
public override void SetValue(EntityUid value)
|
||||
{
|
||||
base.SetValue(value);
|
||||
if (value != null && !IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(value))
|
||||
if (value.Valid && !IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(value))
|
||||
{
|
||||
Logger.Warning("Set LastOpenedStorageState for an entity that doesn't have a storage component");
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Mobs
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NearbyBodiesState : CachedStateData<List<IEntity>>
|
||||
public sealed class NearbyBodiesState : CachedStateData<List<EntityUid>>
|
||||
{
|
||||
public override string Name => "NearbyBodies";
|
||||
|
||||
protected override List<IEntity> GetTrueValue()
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.AI.Components;
|
||||
using Content.Shared.Damage;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.AI.WorldState.States.Mobs
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NearbyPlayersState : CachedStateData<List<IEntity>>
|
||||
public sealed class NearbyPlayersState : CachedStateData<List<EntityUid>>
|
||||
{
|
||||
public override string Name => "NearbyPlayers";
|
||||
|
||||
protected override List<IEntity> GetTrueValue()
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
@@ -31,14 +28,14 @@ namespace Content.Server.AI.WorldState.States.Mobs
|
||||
|
||||
foreach (var player in nearbyPlayers)
|
||||
{
|
||||
if (player.AttachedEntity == null)
|
||||
if (player.AttachedEntity is not {Valid: true} playerEntity)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity != Owner && IoCManager.Resolve<IEntityManager>().HasComponent<DamageableComponent>(player.AttachedEntity))
|
||||
if (player.AttachedEntity != Owner && IoCManager.Resolve<IEntityManager>().HasComponent<DamageableComponent>(playerEntity))
|
||||
{
|
||||
result.Add(player.AttachedEntity);
|
||||
result.Add(playerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ using Robust.Shared.GameObjects;
|
||||
namespace Content.Server.AI.WorldState.States.Movement
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class MoveTargetState : PlanningStateData<IEntity>
|
||||
public sealed class MoveTargetState : PlanningStateData<EntityUid>
|
||||
{
|
||||
public override string Name => "MoveTarget";
|
||||
public override void Reset()
|
||||
{
|
||||
Value = null;
|
||||
Value = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NearbyDrinkState: CachedStateData<List<IEntity>>
|
||||
public sealed class NearbyDrinkState: CachedStateData<List<EntityUid>>
|
||||
{
|
||||
public override string Name => "NearbyDrink";
|
||||
|
||||
protected override List<IEntity> GetTrueValue()
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
|
||||
@@ -11,13 +11,13 @@ using Robust.Shared.IoC;
|
||||
namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NearbyFoodState : CachedStateData<List<IEntity>>
|
||||
public sealed class NearbyFoodState : CachedStateData<List<EntityUid>>
|
||||
{
|
||||
public override string Name => "NearbyFood";
|
||||
|
||||
protected override List<IEntity> GetTrueValue()
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
|
||||
@@ -4,11 +4,11 @@ using Robust.Shared.GameObjects;
|
||||
namespace Content.Server.AI.WorldState.States
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class SelfState : StateData<IEntity>
|
||||
public sealed class SelfState : StateData<EntityUid>
|
||||
{
|
||||
public override string Name => "Self";
|
||||
|
||||
public override IEntity GetValue()
|
||||
public override EntityUid GetValue()
|
||||
{
|
||||
return Owner;
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace Content.Server.AI.WorldState.States
|
||||
/// Could be target item to equip, target to attack, etc.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class TargetEntityState : PlanningStateData<IEntity>
|
||||
public sealed class TargetEntityState : PlanningStateData<EntityUid>
|
||||
{
|
||||
public override string Name => "TargetEntity";
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
Value = null;
|
||||
Value = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user