Inline TryGetComponent completely, for real

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:17:01 +01:00
parent 2ff4ec65d5
commit 69b270017b
425 changed files with 1143 additions and 995 deletions

View File

@@ -55,7 +55,7 @@ namespace Content.Server.AI.EntitySystems
public Faction GetHostileFactions(Faction faction) => _hostileFactions.TryGetValue(faction, out var hostiles) ? hostiles : Faction.None;
public Faction GetFactions(IEntity entity) =>
entity.TryGetComponent(out AiFactionTagComponent? factionTags)
IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AiFactionTagComponent? factionTags)
? factionTags.Factions
: Faction.None;

View File

@@ -52,7 +52,7 @@ namespace Content.Server.AI.EntitySystems
{
// TODO: Need to generecise this but that will be part of a larger cleanup later anyway.
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(message.Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(message.Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
!message.Entity.TryGetComponent(out UtilityAi? controller))
!IoCManager.Resolve<IEntityManager>().TryGetComponent(message.Entity.Uid, out UtilityAi? controller))
{
continue;
}