Inline TryGetComponent completely, for real
This commit is contained in:
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user