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

@@ -58,7 +58,7 @@ namespace Content.Server.GameTicking.Presets
// (If the mob survives, that's a bug. Ghosting is kept regardless.)
var canReturn = canReturnGlobal && mind.CharacterDeadPhysically;
if (playerEntity != null && canReturnGlobal && playerEntity.TryGetComponent(out MobStateComponent? mobState))
if (playerEntity != null && canReturnGlobal && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity.Uid, out MobStateComponent? mobState))
{
if (mobState.IsCritical())
{

View File

@@ -80,7 +80,7 @@ namespace Content.Server.GameTicking.Presets
// Delete anything that may contain "dangerous" role-specific items.
// (This includes the PDA, as everybody gets the captain PDA in this mode for true-all-access reasons.)
if (mind.OwnedEntity != null && mind.OwnedEntity.TryGetComponent(out InventoryComponent? inventory))
if (mind.OwnedEntity != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(mind.OwnedEntity.Uid, out InventoryComponent? inventory))
{
var victimSlots = new[] {EquipmentSlotDefines.Slots.IDCARD, EquipmentSlotDefines.Slots.BELT, EquipmentSlotDefines.Slots.BACKPACK};
foreach (var slot in victimSlots)
@@ -151,7 +151,7 @@ namespace Content.Server.GameTicking.Presets
var avoidMeEntity = avoidMeMind.OwnedEntity;
if (avoidMeEntity == null)
continue;
if (avoidMeEntity.TryGetComponent(out MobStateComponent? mobState))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(avoidMeEntity.Uid, out MobStateComponent? mobState))
{
// Does have mob state component; if critical or dead, they don't really matter for spawn checks
if (mobState.IsCritical() || mobState.IsDead())
@@ -198,7 +198,7 @@ namespace Content.Server.GameTicking.Presets
public override bool OnGhostAttempt(Mind.Mind mind, bool canReturnGlobal)
{
var entity = mind.OwnedEntity;
if ((entity != null) && (entity.TryGetComponent(out MobStateComponent? mobState)))
if ((entity != null) && IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out MobStateComponent? mobState))
{
if (mobState.IsCritical())
{

View File

@@ -64,7 +64,7 @@ namespace Content.Server.GameTicking.Rules
{
var playerEntity = playerSession.AttachedEntity;
if (playerEntity == null
|| !playerEntity.TryGetComponent(out MobStateComponent? state))
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity.Uid, out MobStateComponent? state))
{
continue;
}

View File

@@ -91,7 +91,7 @@ namespace Content.Server.GameTicking.Rules
foreach (var playerSession in _playerManager.ServerSessions)
{
if (playerSession.AttachedEntity == null
|| !playerSession.AttachedEntity.TryGetComponent(out MobStateComponent? mobState)
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(playerSession.AttachedEntity.Uid, out MobStateComponent? mobState)
|| !IoCManager.Resolve<IEntityManager>().HasComponent<SuspicionRoleComponent>(playerSession.AttachedEntity.Uid))
{
continue;