Inline UID
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Content.Server.AI.WorldState.States.Clothing
|
||||
{
|
||||
var result = new Dictionary<EquipmentSlotDefines.Slots, IEntity>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out InventoryComponent? inventoryComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out InventoryComponent? inventoryComponent))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace Content.Server.AI.WorldState.States.Clothing
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, typeof(ClothingComponent), controller.VisionRadius))
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(ClothingComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity.TryGetContainer(out var container))
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner.Uid))
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace Content.Server.AI.WorldState.States.Combat.Nearby
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, typeof(MeleeWeaponComponent), controller.VisionRadius))
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(MeleeWeaponComponent), controller.VisionRadius))
|
||||
{
|
||||
result.Add(entity);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Content.Server.AI.WorldState.States.Hands
|
||||
public override string Name => "AnyFreeHand";
|
||||
public override bool GetValue()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.Server.AI.WorldState.States.Hands
|
||||
{
|
||||
var result = new List<string>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.Server.AI.WorldState.States.Hands
|
||||
public override List<IEntity> GetValue()
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
||||
|
||||
public override IEntity? GetValue()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
||||
|
||||
public override IEnumerable<IEntity> GetValue()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
foreach (var item in handsComponent.GetAllHeldItems())
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(item.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(item.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
continue;
|
||||
|
||||
yield return item.Owner;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
||||
public override void SetValue(IEntity? value)
|
||||
{
|
||||
base.SetValue(value);
|
||||
if (value != null && !IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(value.Uid))
|
||||
if (value != null && !IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(value))
|
||||
{
|
||||
Logger.Warning("Set LastOpenedStorageState for an entity that doesn't have a storage component");
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ namespace Content.Server.AI.WorldState.States.Mobs
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, typeof(SharedBodyComponent), controller.VisionRadius))
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(SharedBodyComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity == Owner) continue;
|
||||
result.Add(entity);
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace Content.Server.AI.WorldState.States.Mobs
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var nearbyPlayers = Filter.Empty()
|
||||
.AddInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).MapPosition, controller.VisionRadius)
|
||||
.AddInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapPosition, controller.VisionRadius)
|
||||
.Recipients;
|
||||
|
||||
foreach (var player in nearbyPlayers)
|
||||
@@ -36,7 +36,7 @@ namespace Content.Server.AI.WorldState.States.Mobs
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity != Owner && IoCManager.Resolve<IEntityManager>().HasComponent<DamageableComponent>(player.AttachedEntity.Uid))
|
||||
if (player.AttachedEntity != Owner && IoCManager.Resolve<IEntityManager>().HasComponent<DamageableComponent>(player.AttachedEntity))
|
||||
{
|
||||
result.Add(player.AttachedEntity);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
|
||||
public override bool GetValue()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HungerComponent? hungerComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HungerComponent? hungerComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, typeof(DrinkComponent), controller.VisionRadius))
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(DrinkComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity.TryGetContainer(out var container))
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner.Uid))
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
{
|
||||
var result = new List<IEntity>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, typeof(FoodComponent), controller.VisionRadius))
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(FoodComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity.TryGetContainer(out var container))
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner.Uid))
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
|
||||
public override bool GetValue()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ThirstComponent? thirstComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ThirstComponent? thirstComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user