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

@@ -56,7 +56,7 @@ namespace Content.Server.Administration
private void AddDebugVerbs(GetOtherVerbsEvent args)
{
if (!args.User.TryGetComponent<ActorComponent>(out var actor))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(args.User.Uid, out var actor))
return;
var player = actor.PlayerSession;
@@ -89,7 +89,7 @@ namespace Content.Server.Administration
if (_groupController.CanCommand(player, "controlmob") &&
args.User != args.Target &&
IoCManager.Resolve<IEntityManager>().HasComponent<MindComponent>(args.User.Uid) &&
args.Target.TryGetComponent<MindComponent>(out var targetMind))
IoCManager.Resolve<IEntityManager>().TryGetComponent<MindComponent?>(args.Target.Uid, out var targetMind))
{
Verb verb = new();
verb.Text = Loc.GetString("control-mob-verb-get-data-text");
@@ -127,7 +127,7 @@ namespace Content.Server.Administration
{
var coords = args.Target.Transform.Coordinates;
Timer.Spawn(_gameTiming.TickPeriod, () => _explosions.SpawnExplosion(coords, 0, 1, 2, 1), CancellationToken.None);
if (args.Target.TryGetComponent(out SharedBodyComponent? body))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Target.Uid, out SharedBodyComponent? body))
{
body.Gib();
}
@@ -168,7 +168,7 @@ namespace Content.Server.Administration
// Get Disposal tube direction verb
if (_groupController.CanCommand(player, "tubeconnections") &&
args.Target.TryGetComponent<IDisposalTubeComponent>(out var tube))
IoCManager.Resolve<IEntityManager>().TryGetComponent<IDisposalTubeComponent?>(args.Target.Uid, out var tube))
{
Verb verb = new();
verb.Text = Loc.GetString("tube-direction-verb-get-data-text");
@@ -194,7 +194,7 @@ namespace Content.Server.Administration
// Configuration verb. Is this even used for anything!?
if (_groupController.CanAdminMenu(player) &&
args.Target.TryGetComponent<ConfigurationComponent>(out var config))
IoCManager.Resolve<IEntityManager>().TryGetComponent<ConfigurationComponent?>(args.Target.Uid, out var config))
{
Verb verb = new();
verb.Text = Loc.GetString("configure-verb-get-data-text");

View File

@@ -50,7 +50,7 @@ namespace Content.Server.Administration.Commands
}
var target = entityManager.GetEntity(eUid);
if (!target.TryGetComponent(out MindComponent? mindComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out MindComponent? mindComponent))
{
shell.WriteLine(Loc.GetString("shell-entity-is-not-mob"));
return;

View File

@@ -59,17 +59,17 @@ namespace Content.Server.Administration.Commands
EntitySystem.Get<StatusEffectsSystem>().TryRemoveAllStatusEffects(target.Uid);
if (target.TryGetComponent(out FlammableComponent? flammable))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out FlammableComponent? flammable))
{
EntitySystem.Get<FlammableSystem>().Extinguish(target.Uid, flammable);
}
if (target.TryGetComponent(out DamageableComponent? damageable))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out DamageableComponent? damageable))
{
EntitySystem.Get<DamageableSystem>().SetAllDamage(damageable, 0);
}
if (target.TryGetComponent(out CreamPiedComponent? creamPied))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out CreamPiedComponent? creamPied))
{
EntitySystem.Get<CreamPieSystem>().SetCreamPied(target.Uid, creamPied, false);
}

View File

@@ -53,7 +53,7 @@ namespace Content.Server.Administration.Commands
var target = entityManager.GetEntity(eUid);
if (!target.TryGetComponent<InventoryComponent>(out var inventoryComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<InventoryComponent?>(target.Uid, out var inventoryComponent))
{
shell.WriteLine(Loc.GetString("shell-target-entity-does-not-have-message",("missing", "inventory")));
return;
@@ -82,7 +82,7 @@ namespace Content.Server.Administration.Commands
HumanoidCharacterProfile? profile = null;
// Check if we are setting the outfit of a player to respect the preferences
if (target.TryGetComponent<ActorComponent>(out var actorComponent))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(target.Uid, out var actorComponent))
{
var userId = actorComponent.PlayerSession.UserId;
var preferencesManager = IoCManager.Resolve<IServerPreferencesManager>();
@@ -100,7 +100,7 @@ namespace Content.Server.Administration.Commands
}
var equipmentEntity = entityManager.SpawnEntity(gearStr, target.Transform.Coordinates);
if (slot == EquipmentSlotDefines.Slots.IDCARD &&
equipmentEntity.TryGetComponent<PDAComponent>(out var pdaComponent) &&
IoCManager.Resolve<IEntityManager>().TryGetComponent<PDAComponent?>(equipmentEntity.Uid, out var pdaComponent) &&
pdaComponent.ContainedID != null)
{
pdaComponent.ContainedID.FullName = target.Name;

View File

@@ -114,7 +114,7 @@ namespace Content.Server.Administration.Commands
if (found.GetGridId(entMan) != GridId.Invalid)
{
player.AttachedEntity.Transform.Coordinates = found;
if (player.AttachedEntity.TryGetComponent(out IPhysBody? physics))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity.Uid, out IPhysBody? physics))
{
physics.LinearVelocity = Vector2.Zero;
}