Make more uids nullable (#5794)
This commit is contained in:
@@ -39,7 +39,7 @@ namespace Content.Server.AI.LoadBalancer
|
||||
|
||||
var entity = _request.Context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (entity == null || !IoCManager.Resolve<IEntityManager>().HasComponent<AiControllerComponent>(entity))
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AiControllerComponent>(entity))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.ActionBlocker
|
||||
{
|
||||
var self = context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (self == null || !EntitySystem.Get<ActionBlockerSystem>().CanMove(self))
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanMove(self))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (target.TryGetContainer(out var container))
|
||||
if (target!.Value.TryGetContainer(out var container))
|
||||
{
|
||||
if (entMan.TryGetComponent(container.Owner, out EntityStorageComponent? storageComponent))
|
||||
{
|
||||
@@ -43,12 +43,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers
|
||||
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (owner == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return EntitySystem.Get<AiReachableSystem>().CanAccess(owner, target, SharedInteractionSystem.InteractionRange) ? 1.0f : 0.0f;
|
||||
return EntitySystem.Get<AiReachableSystem>().CanAccess(owner, target.Value, SharedInteractionSystem.InteractionRange) ? 1.0f : 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
|
||||
|
||||
if (target == null
|
||||
|| IoCManager.Resolve<IEntityManager>().Deleted(target)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, DrinkComponent.DefaultSolutionName, out var drink))
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Value, DrinkComponent.DefaultSolutionName, out var drink))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (owner == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out ThirstComponent? thirst))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out ThirstComponent? thirst))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<FoodComponent?>(target, out var foodComp)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, foodComp.SolutionName, out var food))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<FoodComponent?>(target.Value, out var foodComp)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Value, foodComp.SolutionName, out var food))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (owner == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out HungerComponent? hunger))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out HungerComponent? hunger))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ using Robust.Shared.GameObjects;
|
||||
namespace Content.Server.AI.WorldState.States.Combat
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class WeaponEntityState : PlanningStateData<EntityUid>
|
||||
public sealed class WeaponEntityState : PlanningStateData<EntityUid?>
|
||||
{
|
||||
// Similar to TargetEntity
|
||||
public override string Name => "WeaponEntity";
|
||||
public override void Reset()
|
||||
{
|
||||
Value = default;
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,13 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
||||
/// AKA what's in active hand
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class EquippedEntityState : StateData<EntityUid>
|
||||
public sealed class EquippedEntityState : StateData<EntityUid?>
|
||||
{
|
||||
public override string Name => "EquippedEntity";
|
||||
|
||||
public override EntityUid GetValue()
|
||||
public override EntityUid? GetValue()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return handsComponent.GetActiveHand?.Owner ?? default;
|
||||
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<HandsComponent>(Owner)?.GetActiveHand?.Owner;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ using Robust.Shared.GameObjects;
|
||||
namespace Content.Server.AI.WorldState.States.Movement
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class MoveTargetState : PlanningStateData<EntityUid>
|
||||
public sealed class MoveTargetState : PlanningStateData<EntityUid?>
|
||||
{
|
||||
public override string Name => "MoveTarget";
|
||||
public override void Reset()
|
||||
{
|
||||
Value = default;
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<EntityUid>
|
||||
public sealed class TargetEntityState : PlanningStateData<EntityUid?>
|
||||
{
|
||||
public override string Name => "TargetEntity";
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
Value = default;
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user