Remove IMobStateComponent (#5220)

This commit is contained in:
Javier Guardia Fernández
2021-11-08 15:11:58 +01:00
committed by GitHub
parent 4236551d86
commit f5b11d6af8
35 changed files with 84 additions and 144 deletions

View File

@@ -1,6 +1,6 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
namespace Content.Server.AI.Utility.Considerations.Combat
{
@@ -10,7 +10,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat
{
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || !target.TryGetComponent(out IMobStateComponent? mobState))
if (target == null || !target.TryGetComponent(out MobStateComponent? mobState))
{
return 0.0f;
}

View File

@@ -1,6 +1,6 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
namespace Content.Server.AI.Utility.Considerations.Combat
{
@@ -10,7 +10,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat
{
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || !target.TryGetComponent(out IMobStateComponent? mobState))
if (target == null || !target.TryGetComponent(out MobStateComponent? mobState))
{
return 0.0f;
}

View File

@@ -2,15 +2,12 @@ using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Server.Stunnable;
using Content.Server.Stunnable.Components;
using Content.Shared.Administration;
using Content.Shared.Damage;
using Content.Shared.Jittering;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.StatusEffect;
using Content.Shared.Stunnable;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
@@ -56,7 +53,7 @@ namespace Content.Server.Administration.Commands
public static void PerformRejuvenate(IEntity target)
{
target.GetComponentOrNull<IMobStateComponent>()?.UpdateState(0);
target.GetComponentOrNull<MobStateComponent>()?.UpdateState(0);
target.GetComponentOrNull<HungerComponent>()?.ResetFood();
target.GetComponentOrNull<ThirstComponent>()?.ResetThirst();

View File

@@ -1,7 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Atmos;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Physics;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -61,7 +61,7 @@ namespace Content.Server.Atmos.Components
&& (maxForce >= (MoveResist * MoveForcePushRatio)))
|| (physics.BodyType == BodyType.Static && (maxForce >= (MoveResist * MoveForceForcePushRatio))))
{
if (physics.Owner.HasComponent<IMobStateComponent>())
if (physics.Owner.HasComponent<MobStateComponent>())
{
physics.BodyStatus = BodyStatus.InAir;
@@ -75,7 +75,7 @@ namespace Content.Server.Atmos.Components
if (Deleted || !Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) return;
// Uhh if you get race conditions good luck buddy.
if (physicsComponent.Owner.HasComponent<IMobStateComponent>())
if (physicsComponent.Owner.HasComponent<MobStateComponent>())
{
physicsComponent.BodyStatus = BodyStatus.OnGround;
}

View File

@@ -8,6 +8,7 @@ using Content.Server.Popups;
using Content.Shared.Atmos;
using Content.Shared.Body.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -92,7 +93,7 @@ namespace Content.Server.Body.Behavior
public override void Update(float frameTime)
{
if (Body != null && Body.Owner.TryGetComponent(out IMobStateComponent? mobState) && mobState.IsCritical())
if (Body != null && Body.Owner.TryGetComponent(out MobStateComponent? mobState) && mobState.IsCritical())
{
return;
}

View File

@@ -1,7 +1,6 @@
using Content.Server.GameTicking;
using Content.Server.Mind.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.State;
using Content.Shared.MobState.Components;
using Content.Shared.Movement.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -20,7 +19,7 @@ namespace Content.Server.Body
private void OnRelayMoveInput(EntityUid uid, BodyComponent component, RelayMoveInputEvent args)
{
if (EntityManager.TryGetComponent<IMobStateComponent>(uid, out var mobState) &&
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) &&
mobState.IsDead() &&
EntityManager.TryGetComponent<MindComponent>(uid, out var mind) &&
mind.HasMind)

View File

@@ -13,7 +13,7 @@ using Content.Shared.Alert;
using Content.Shared.Atmos;
using Content.Shared.Body.Components;
using Content.Shared.Damage;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Popups;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
@@ -190,7 +190,7 @@ namespace Content.Server.Body.Respiratory
if (bloodstreamAmount < amountNeeded)
{
if (!Owner.GetComponent<IMobStateComponent>().IsCritical())
if (!Owner.GetComponent<MobStateComponent>().IsCritical())
{
// Panic inhale
foreach (var lung in lungs)
@@ -313,7 +313,7 @@ namespace Content.Server.Body.Respiratory
/// </param>
public void Update(float frameTime)
{
if (!Owner.TryGetComponent<IMobStateComponent>(out var state) ||
if (!Owner.TryGetComponent<MobStateComponent>(out var state) ||
state.IsDead())
{
return;

View File

@@ -1,12 +1,11 @@
using System;
using Content.Server.CharacterAppearance.Components;
using Content.Server.EUI;
using Content.Server.Mind.Components;
using Content.Server.Power.Components;
using Content.Server.UserInterface;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Cloning;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -108,7 +107,7 @@ namespace Content.Server.Cloning.Components
if (cloningSystem.ClonesWaitingForMind.TryGetValue(mind, out var cloneUid))
{
if (Owner.EntityManager.TryGetEntity(cloneUid, out var clone) &&
clone.TryGetComponent<IMobStateComponent>(out var cloneState) &&
clone.TryGetComponent<MobStateComponent>(out var cloneState) &&
!cloneState.IsDead() &&
clone.TryGetComponent(out MindComponent? cloneMindComp) &&
(cloneMindComp.Mind == null || cloneMindComp.Mind == mind))
@@ -121,7 +120,7 @@ namespace Content.Server.Cloning.Components
}
if (mind.OwnedEntity != null &&
mind.OwnedEntity.TryGetComponent<IMobStateComponent>(out var state) &&
mind.OwnedEntity.TryGetComponent<MobStateComponent>(out var state) &&
!state.IsDead())
{
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive"));

View File

@@ -1,15 +1,15 @@
using Content.Server.Cuffs.Components;
using Content.Server.Hands.Components;
using Content.Shared.Hands.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Cuffs;
using Content.Shared.Hands.Components;
using Content.Shared.MobState.Components;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.IoC;
using Content.Shared.MobState;
using Robust.Shared.Localization;
using Robust.Shared.Player;
namespace Content.Server.Cuffs
@@ -66,7 +66,7 @@ namespace Content.Server.Cuffs
if (args.User == args.Target)
{
// This UncuffAttemptEvent check should probably be In MobStateSystem, not here?
if (userEntity.TryGetComponent<IMobStateComponent>(out var state))
if (userEntity.TryGetComponent<MobStateComponent>(out var state))
{
// Manually check this.
if (state.IsIncapacitated())

View File

@@ -4,7 +4,7 @@ using Content.Server.Ghost.Components;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Ghost;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Preferences;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
@@ -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 IMobStateComponent? mobState))
if (playerEntity != null && canReturnGlobal && playerEntity.TryGetComponent(out MobStateComponent? mobState))
{
if (mobState.IsCritical())
{

View File

@@ -11,25 +11,25 @@ using Content.Server.PDA;
using Content.Server.Players;
using Content.Server.Spawners.Components;
using Content.Server.Traitor;
using Content.Server.Traitor.Uplink;
using Content.Server.Traitor.Uplink.Account;
using Content.Server.Traitor.Uplink.Components;
using Content.Server.TraitorDeathMatch.Components;
using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Inventory;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Traitor.Uplink;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Content.Server.Traitor.Uplink.Components;
using Content.Shared.Traitor.Uplink;
using Content.Server.Traitor.Uplink;
using Content.Shared.Damage.Prototypes;
using Content.Server.Traitor.Uplink.Account;
namespace Content.Server.GameTicking.Presets
{
@@ -151,7 +151,7 @@ namespace Content.Server.GameTicking.Presets
var avoidMeEntity = avoidMeMind.OwnedEntity;
if (avoidMeEntity == null)
continue;
if (avoidMeEntity.TryGetComponent(out IMobStateComponent? mobState))
if (avoidMeEntity.TryGetComponent(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 IMobStateComponent? mobState)))
if ((entity != null) && (entity.TryGetComponent(out MobStateComponent? mobState)))
{
if (mobState.IsCritical())
{

View File

@@ -1,10 +1,9 @@
using System;
using System.Threading;
using Content.Server.Chat.Managers;
using Content.Shared;
using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
@@ -63,7 +62,7 @@ namespace Content.Server.GameTicking.Rules
{
var playerEntity = playerSession.AttachedEntity;
if (playerEntity == null
|| !playerEntity.TryGetComponent(out IMobStateComponent? state))
|| !playerEntity.TryGetComponent(out MobStateComponent? state))
{
continue;
}

View File

@@ -6,9 +6,8 @@ using Content.Server.Players;
using Content.Server.Suspicion;
using Content.Server.Suspicion.EntitySystems;
using Content.Server.Suspicion.Roles;
using Content.Shared;
using Content.Shared.CCVar;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Sound;
using Robust.Server.Player;
using Robust.Shared.Audio;
@@ -90,7 +89,7 @@ namespace Content.Server.GameTicking.Rules
foreach (var playerSession in _playerManager.GetAllPlayers())
{
if (playerSession.AttachedEntity == null
|| !playerSession.AttachedEntity.TryGetComponent(out IMobStateComponent? mobState)
|| !playerSession.AttachedEntity.TryGetComponent(out MobStateComponent? mobState)
|| !playerSession.AttachedEntity.HasComponent<SuspicionRoleComponent>())
{
continue;

View File

@@ -7,7 +7,7 @@ using Content.Server.Popups;
using Content.Shared.DragDrop;
using Content.Shared.Interaction;
using Content.Shared.Kitchen.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Popups;
using Robust.Server.GameObjects;
@@ -106,7 +106,7 @@ namespace Content.Server.Kitchen.Components
return;
// Prevent dead from being spiked TODO: Maybe remove when rounds can be played and DOT is implemented
if (victim.TryGetComponent<IMobStateComponent>(out var state) &&
if (victim.TryGetComponent<MobStateComponent>(out var state) &&
!state.IsDead())
{
Owner.PopupMessage(user, Loc.GetString("comp-kitchen-spike-deny-not-dead", ("victim", victim)));

View File

@@ -4,13 +4,12 @@ using Content.Server.Mind.Components;
using Content.Server.Power.Components;
using Content.Server.Preferences.Managers;
using Content.Server.UserInterface;
using Content.Shared.ActionBlocker;
using Content.Shared.Acts;
using Content.Shared.Damage;
using Content.Shared.DragDrop;
using Content.Shared.Interaction;
using Content.Shared.MedicalScanner;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Popups;
using Content.Shared.Preferences;
using Robust.Server.GameObjects;
@@ -110,7 +109,7 @@ namespace Content.Server.Medical.Components
UserInterface?.SetState(newState);
}
private MedicalScannerStatus GetStatusFromDamageState(IMobStateComponent state)
private MedicalScannerStatus GetStatusFromDamageState(MobStateComponent state)
{
if (state.IsAlive())
{
@@ -135,7 +134,7 @@ namespace Content.Server.Medical.Components
if (Powered)
{
var body = _bodyContainer.ContainedEntity;
var state = body?.GetComponentOrNull<IMobStateComponent>();
var state = body?.GetComponentOrNull<MobStateComponent>();
return state == null
? MedicalScannerStatus.Open

View File

@@ -2,7 +2,7 @@ using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Shared.Examine;
using Content.Shared.Ghost;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -131,7 +131,7 @@ namespace Content.Server.Mind.Components
}
var dead =
Owner.TryGetComponent<IMobStateComponent>(out var state) &&
Owner.TryGetComponent<MobStateComponent>(out var state) &&
state.IsDead();
if (!HasMind)

View File

@@ -8,7 +8,7 @@ using Content.Server.Mind.Components;
using Content.Server.Objectives;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
@@ -139,7 +139,7 @@ namespace Content.Server.Mind
// This can be null if they're deleted (spike / brain nom)
if (OwnedEntity == null)
return true;
var targetMobState = OwnedEntity.GetComponentOrNull<IMobStateComponent>();
var targetMobState = OwnedEntity.GetComponentOrNull<MobStateComponent>();
// This can be null if it's a brain (this happens very often)
// Brains are the result of gibbing so should definitely count as dead
if (targetMobState == null)

View File

@@ -2,7 +2,7 @@ using Content.Server.Alert;
using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.MobState.State;
using Robust.Shared.GameObjects;
@@ -24,7 +24,7 @@ namespace Content.Server.MobState.States
return;
}
if (!entity.TryGetComponent(out IMobStateComponent? stateComponent))
if (!entity.TryGetComponent(out MobStateComponent? stateComponent))
{
return;
}

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using Content.Server.Alert;
using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.EntitySystems;
using Content.Shared.Nutrition.Components;
@@ -182,7 +182,7 @@ namespace Content.Server.Nutrition.Components
return;
// --> Current Hunger is below dead threshold
if (!Owner.TryGetComponent(out IMobStateComponent? mobState))
if (!Owner.TryGetComponent(out MobStateComponent? mobState))
return;
if (!mobState.IsDead())

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using Content.Server.Alert;
using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.EntitySystems;
using Content.Shared.Nutrition.Components;
@@ -179,7 +179,7 @@ namespace Content.Server.Nutrition.Components
return;
// --> Current Hunger is below dead threshold
if (!Owner.TryGetComponent(out IMobStateComponent? mobState))
if (!Owner.TryGetComponent(out MobStateComponent? mobState))
return;
if (!mobState.IsDead())

View File

@@ -1,7 +1,7 @@
using System.Linq;
using Content.Server.Mind.Components;
using Content.Server.Objectives.Interfaces;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -20,7 +20,7 @@ namespace Content.Server.Objectives.Conditions
var allHumans = entityMgr.EntityQuery<MindComponent>(true).Where(mc =>
{
var entity = mc.Mind?.OwnedEntity;
return (entity?.GetComponentOrNull<IMobStateComponent>()?.IsAlive() ?? false) && mc.Mind != mind;
return (entity?.GetComponentOrNull<MobStateComponent>()?.IsAlive() ?? false) && mc.Mind != mind;
}).Select(mc => mc.Mind).ToList();
return new KillRandomPersonCondition {Target = IoCManager.Resolve<IRobustRandom>().Pick(allHumans)};
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using Content.Server.Explosion;
using Content.Server.Pointing.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Pointing.Components;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -44,7 +44,7 @@ namespace Content.Server.Pointing.EntitySystems
var players = _playerManager
.GetPlayersInRange(transform.Coordinates, 15)
.Where(player => player.AttachedEntity != null && player.AttachedEntity.TryGetComponent(out IMobStateComponent? mobStateComponent) && !mobStateComponent.IsDead())
.Where(player => player.AttachedEntity != null && player.AttachedEntity.TryGetComponent(out MobStateComponent? mobStateComponent) && !mobStateComponent.IsDead())
.ToArray();
if (players.Length == 0)

View File

@@ -6,9 +6,8 @@ using Content.Server.Roles;
using Content.Server.Suspicion.EntitySystems;
using Content.Server.Suspicion.Roles;
using Content.Shared.Examine;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Suspicion;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
@@ -60,7 +59,7 @@ namespace Content.Server.Suspicion
public bool IsDead()
{
return Owner.TryGetComponent(out IMobStateComponent? state) &&
return Owner.TryGetComponent(out MobStateComponent? state) &&
state.IsDead();
}

View File

@@ -1,7 +1,7 @@
using System;
using Content.Server.Interaction;
using Content.Server.Items;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Tag;
using Content.Shared.Throwing;
using Robust.Shared.GameObjects;
@@ -46,7 +46,7 @@ namespace Content.Server.Throwing
return;
}
if (entity.HasComponent<IMobStateComponent>())
if (entity.HasComponent<MobStateComponent>())
{
Logger.Warning("Throwing not supported for mobs!");
return;