Inline TryGetComponent completely
This commit is contained in:
@@ -146,7 +146,7 @@ namespace Content.Client.Body.UI
|
||||
BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(part.Owner.Name)}";
|
||||
|
||||
// TODO BODY Part damage
|
||||
if (part.Owner.TryGetComponent(out DamageableComponent? damageable))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(part.Owner.Uid, out DamageableComponent? damageable))
|
||||
{
|
||||
BodyPartHealth.Text = Loc.GetString("body-scanner-display-body-part-damage-text",("damage", damageable.TotalDamage));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Content.Client.Fluids
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!entity.TryGetComponent(out SpriteComponent? spriteComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SpriteComponent? spriteComponent))
|
||||
{
|
||||
Logger.Warning($"Missing SpriteComponent for PuddleVisualizer on entityUid = {entity.Uid}");
|
||||
return;
|
||||
|
||||
@@ -181,8 +181,8 @@ namespace Content.Client.Storage
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(entityUid, out var entity))
|
||||
return;
|
||||
|
||||
entity.TryGetComponent(out ISpriteComponent? sprite);
|
||||
entity.TryGetComponent(out ItemComponent? item);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ISpriteComponent? sprite);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ItemComponent? item);
|
||||
|
||||
button.AddChild(new BoxContainer
|
||||
{
|
||||
@@ -252,7 +252,7 @@ namespace Content.Client.Storage
|
||||
{
|
||||
var controlledEntity = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (controlledEntity != null && controlledEntity.TryGetComponent(out HandsComponent? hands))
|
||||
if (controlledEntity != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(controlledEntity.Uid, out HandsComponent? hands))
|
||||
{
|
||||
#pragma warning disable 618
|
||||
StorageEntity.SendNetworkMessage(new InsertEntityMessage());
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Storage.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -19,7 +20,7 @@ namespace Content.Client.Storage.Visualizers
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (entity.TryGetComponent<ISpriteComponent>(out var spriteComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(entity.Uid, out var spriteComponent))
|
||||
{
|
||||
_rsiPath ??= spriteComponent.BaseRSI!.Path!;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Storage.Visualizers
|
||||
@@ -18,7 +19,7 @@ namespace Content.Client.Storage.Visualizers
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
if (!entity.TryGetComponent(out ISpriteComponent? sprite))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
chair = entityManager.SpawnEntity(StrapDummyId, coordinates);
|
||||
|
||||
// Default state, unbuckled
|
||||
Assert.True(human.TryGetComponent(out buckle));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out buckle));
|
||||
Assert.NotNull(buckle);
|
||||
Assert.Null(buckle.BuckledTo);
|
||||
Assert.False(buckle.Buckled);
|
||||
@@ -88,7 +88,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
Assert.True(standingState.Stand(human.Uid));
|
||||
|
||||
// Default state, no buckled entities, strap
|
||||
Assert.True(chair.TryGetComponent(out strap));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(chair.Uid, out strap));
|
||||
Assert.NotNull(strap);
|
||||
Assert.IsEmpty(strap.BuckledEntities);
|
||||
Assert.Zero(strap.OccupiedSize);
|
||||
@@ -239,10 +239,10 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
IEntity chair = entityManager.SpawnEntity(StrapDummyId, coordinates);
|
||||
|
||||
// Component sanity check
|
||||
Assert.True(human.TryGetComponent(out buckle));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out buckle));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().HasComponent<StrapComponent>(chair.Uid));
|
||||
Assert.True(human.TryGetComponent(out hands));
|
||||
Assert.True(human.TryGetComponent(out body));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out hands));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out body));
|
||||
|
||||
// Buckle
|
||||
Assert.True(buckle.TryBuckle(human, chair));
|
||||
@@ -255,7 +255,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
var akms = entityManager.SpawnEntity(ItemDummyId, coordinates);
|
||||
|
||||
// Equip items
|
||||
Assert.True(akms.TryGetComponent(out ItemComponent item));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(akms.Uid, out ItemComponent item));
|
||||
Assert.True(hands.PutInHand(item));
|
||||
}
|
||||
});
|
||||
@@ -324,7 +324,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
chair = entityManager.SpawnEntity(StrapDummyId, coordinates);
|
||||
|
||||
// Component sanity check
|
||||
Assert.True(human.TryGetComponent(out buckle));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out buckle));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().HasComponent<StrapComponent>(chair.Uid));
|
||||
|
||||
// Buckle
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
var human = entityManager.SpawnEntity("DamageableDummy", MapCoordinates.Nullspace);
|
||||
|
||||
// Sanity check
|
||||
Assert.True(human.TryGetComponent(out DamageableComponent damageable));
|
||||
Assert.True(human.TryGetComponent(out MobStateComponent mobState));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out DamageableComponent damageable));
|
||||
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out MobStateComponent mobState));
|
||||
mobState.UpdateState(0);
|
||||
Assert.That(mobState.IsAlive, Is.True);
|
||||
Assert.That(mobState.IsCritical, Is.False);
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.AI.Components;
|
||||
using Content.Server.AI.Utility.AiLogic;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility
|
||||
{
|
||||
@@ -9,7 +10,7 @@ namespace Content.Server.AI.Utility
|
||||
{
|
||||
public static Blackboard? GetBlackboard(IEntity entity)
|
||||
{
|
||||
if (!entity.TryGetComponent(out AiControllerComponent? aiControllerComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AiControllerComponent? aiControllerComponent))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace Content.Server.Actions.Actions
|
||||
|
||||
public void DoInstantAction(InstantActionEventArgs args)
|
||||
{
|
||||
if (!args.Performer.TryGetComponent<ServerUserInterfaceComponent>(out var serverUi)) return;
|
||||
if (!args.Performer.TryGetComponent<ActorComponent>(out var actor)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ServerUserInterfaceComponent?>(args.Performer.Uid, out var serverUi)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(args.Performer.Uid, out var actor)) return;
|
||||
if (!serverUi.TryGetBoundUserInterface(InstrumentUiKey.Key,out var bui)) return;
|
||||
|
||||
bui.Toggle(actor.PlayerSession);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Actions;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -29,7 +30,7 @@ namespace Content.Server.Actions.Commands
|
||||
}
|
||||
|
||||
if (attachedEntity == null) return;
|
||||
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Uid, out ServerActionsComponent? actionsComponent))
|
||||
{
|
||||
shell.WriteLine("user has no actions component");
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Server.Cuffs.Components;
|
||||
using Content.Shared.Alert;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
@@ -14,7 +16,7 @@ namespace Content.Server.Alert.Click
|
||||
{
|
||||
public void AlertClicked(ClickAlertEventArgs args)
|
||||
{
|
||||
if (args.Player.TryGetComponent(out CuffableComponent? cuffableComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Player.Uid, out CuffableComponent? cuffableComponent))
|
||||
{
|
||||
cuffableComponent.TryUncuff(args.Player);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Content.Server.Arcade.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!Powered || !IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User.Uid))
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
|
||||
private void OnPumpInteractHand(EntityUid uid, GasVolumePumpComponent component, InteractHandEvent args)
|
||||
{
|
||||
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
if (component.Owner.Transform.Anchored)
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Body.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Body.Components
|
||||
@@ -16,7 +17,7 @@ namespace Content.Server.Body.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -28,7 +29,7 @@ namespace Content.Server.Body.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (session.AttachedEntity.TryGetComponent(out SharedBodyComponent? body))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(session.AttachedEntity.Uid, out SharedBodyComponent? body))
|
||||
{
|
||||
var state = InterfaceState(body);
|
||||
UserInterface?.SetState(state);
|
||||
|
||||
@@ -7,6 +7,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Buckle.Systems
|
||||
@@ -94,7 +95,7 @@ namespace Content.Server.Buckle.Systems
|
||||
// This fixes buckle offsets and draw depths.
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
{
|
||||
if (!buckledEntity.TryGetComponent(out BuckleComponent? buckled))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(buckledEntity.Uid, out BuckleComponent? buckled))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -111,7 +112,7 @@ namespace Content.Server.Buckle.Systems
|
||||
{
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
{
|
||||
if (!buckledEntity.TryGetComponent(out BuckleComponent? buckled))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(buckledEntity.Uid, out BuckleComponent? buckled))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Chemistry.EntitySystems
|
||||
{
|
||||
@@ -31,7 +32,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
if (!args.CanAccess || !args.CanInteract || !component.CanChangeTransferAmount)
|
||||
return;
|
||||
|
||||
if (!args.User.TryGetComponent<ActorComponent>(out var actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(args.User.Uid, out var actor))
|
||||
return;
|
||||
|
||||
// Custom transfer verb
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Content.Server.Cloning
|
||||
{
|
||||
if (!ClonesWaitingForMind.TryGetValue(mind, out var entityUid) ||
|
||||
!EntityManager.TryGetEntity(entityUid, out var entity) ||
|
||||
!entity.TryGetComponent(out MindComponent? mindComp) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out MindComponent? mindComp) ||
|
||||
mindComp.Mind != null)
|
||||
return;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Server.Cloning
|
||||
private void HandleActivate(EntityUid uid, CloningPodComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (!component.Powered ||
|
||||
!args.User.TryGetComponent(out ActorComponent? actor))
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace Content.Server.Cloning
|
||||
{
|
||||
if (component.Parent == EntityUid.Invalid ||
|
||||
!EntityManager.TryGetEntity(component.Parent, out var parent) ||
|
||||
!parent.TryGetComponent<CloningPodComponent>(out var cloningPodComponent) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<CloningPodComponent?>(parent.Uid, out var cloningPodComponent) ||
|
||||
component.Owner != cloningPodComponent.BodyContainer?.ContainedEntity)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().RemoveComponent<BeingClonedComponent>(component.Owner.Uid);
|
||||
|
||||
@@ -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<MobStateComponent>(out var state))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(userEntity.Uid, out var state))
|
||||
{
|
||||
// Manually check this.
|
||||
if (state.IsIncapacitated())
|
||||
@@ -101,7 +101,7 @@ namespace Content.Server.Cuffs
|
||||
{
|
||||
var owner = message.Sender;
|
||||
|
||||
if (!owner.TryGetComponent(out CuffableComponent? cuffable) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out CuffableComponent? cuffable) ||
|
||||
!cuffable.Initialized) return;
|
||||
|
||||
var dirty = false;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Content.Server.Disposal.Tube
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
return;
|
||||
|
||||
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;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Content.Server.Disposal.Tube
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
return;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Disposal.Tube;
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Content.Server.Fluids.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!eventArgs.Target.TryGetComponent(out PuddleComponent? puddleComponent) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Target.Uid, out PuddleComponent? puddleComponent) ||
|
||||
!solutionSystem.TryGetSolution(puddleComponent.OwnerUid, puddleComponent.SolutionName, out var puddleSolution))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Content.Server.GameTicking
|
||||
#region Equip Helpers
|
||||
public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear, HumanoidCharacterProfile? profile)
|
||||
{
|
||||
if (entity.TryGetComponent(out InventoryComponent? inventory))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out InventoryComponent? inventory))
|
||||
{
|
||||
foreach (var slot in EquipmentSlotDefines.AllSlots)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out HandsComponent? handsComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out HandsComponent? handsComponent))
|
||||
{
|
||||
var inhand = startingGear.Inhand;
|
||||
foreach (var (hand, prototype) in inhand)
|
||||
@@ -256,7 +256,7 @@ namespace Content.Server.GameTicking
|
||||
|
||||
public void EquipIdCard(IEntity entity, string characterName, JobPrototype jobPrototype)
|
||||
{
|
||||
if (!entity.TryGetComponent(out InventoryComponent? inventory))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out InventoryComponent? inventory))
|
||||
return;
|
||||
|
||||
if (!inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.IDCARD, out ItemComponent? item))
|
||||
@@ -266,7 +266,7 @@ namespace Content.Server.GameTicking
|
||||
|
||||
var itemEntity = item.Owner;
|
||||
|
||||
if (!itemEntity.TryGetComponent(out PDAComponent? pdaComponent) || pdaComponent.ContainedID == null)
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(itemEntity.Uid, out PDAComponent? pdaComponent) || pdaComponent.ContainedID == null)
|
||||
return;
|
||||
|
||||
var card = pdaComponent.ContainedID;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Interaction.Components
|
||||
/// <returns>True if a "bad action" happened, false if the normal action should happen.</returns>
|
||||
public static bool TryRollClumsy(IEntity entity, float chance)
|
||||
{
|
||||
return entity.TryGetComponent(out ClumsyComponent? clumsy)
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClumsyComponent? clumsy)
|
||||
&& clumsy.RollClumsy(chance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Player;
|
||||
using System;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Light.EntitySystems
|
||||
{
|
||||
@@ -36,13 +37,13 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
public void ToggleLight(UnpoweredFlashlightComponent flashlight)
|
||||
{
|
||||
if (!flashlight.Owner.TryGetComponent(out PointLightComponent? light))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(flashlight.Owner.Uid, out PointLightComponent? light))
|
||||
return;
|
||||
|
||||
flashlight.LightOn = !flashlight.LightOn;
|
||||
light.Enabled = flashlight.LightOn;
|
||||
|
||||
if (flashlight.Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(flashlight.Owner.Uid, out AppearanceComponent? appearance))
|
||||
appearance.SetData(UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(light.Owner), flashlight.ToggleSound.GetSound(), flashlight.Owner);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Content.Server.Lock
|
||||
|
||||
private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
|
||||
{
|
||||
if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(lockComp.Owner.Uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(StorageVisuals.CanLock, true);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace Content.Server.Lock
|
||||
SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5));
|
||||
}
|
||||
|
||||
if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearanceComp))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(lockComp.Owner.Uid, out AppearanceComponent? appearanceComp))
|
||||
{
|
||||
appearanceComp.SetData(StorageVisuals.Locked, true);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace Content.Server.Lock
|
||||
SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.UnlockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5));
|
||||
}
|
||||
|
||||
if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearanceComp))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(lockComp.Owner.Uid, out AppearanceComponent? appearanceComp))
|
||||
{
|
||||
appearanceComp.SetData(StorageVisuals.Locked, false);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Server.Morgue.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (Morgue != null && !((!IoCManager.Resolve<IEntityManager>().EntityExists(Morgue.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Morgue.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && Morgue.TryGetComponent<MorgueEntityStorageComponent>(out var comp))
|
||||
if (Morgue != null && !((!IoCManager.Resolve<IEntityManager>().EntityExists(Morgue.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Morgue.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && IoCManager.Resolve<IEntityManager>().TryGetComponent<MorgueEntityStorageComponent?>(Morgue.Uid, out var comp))
|
||||
{
|
||||
comp.Activate(new ActivateEventArgs(eventArgs.User, Morgue));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Content.Server.Research.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
OpenUserInterface(actor.PlayerSession);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Tabletop.Events;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
|
||||
@@ -60,11 +61,11 @@ namespace Content.Server.Tabletop
|
||||
{
|
||||
var draggedEntity = EntityManager.GetEntity(msg.DraggedEntityUid);
|
||||
|
||||
if (!draggedEntity.TryGetComponent<TabletopDraggableComponent>(out var draggableComponent)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<TabletopDraggableComponent?>(draggedEntity.Uid, out var draggableComponent)) return;
|
||||
|
||||
draggableComponent.DraggingPlayer = msg.DraggingPlayer;
|
||||
|
||||
if (!draggedEntity.TryGetComponent<AppearanceComponent>(out var appearance)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(draggedEntity.Uid, out var appearance)) return;
|
||||
|
||||
if (draggableComponent.DraggingPlayer != null)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
@@ -209,7 +210,7 @@ namespace Content.Server.Tools
|
||||
|
||||
// TODO: Clean up this inherited oldcode.
|
||||
|
||||
if (args.Target.TryGetComponent(out ReagentTankComponent? tank)
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Target.Uid, out ReagentTankComponent? tank)
|
||||
&& tank.TankType == ReagentTankType.Fuel
|
||||
&& _solutionContainerSystem.TryGetDrainableSolution(args.Target.Uid, out var targetSolution)
|
||||
&& _solutionContainerSystem.TryGetSolution(uid, welder.FuelSolution, out var welderSolution))
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Content.Server.UserInterface
|
||||
|
||||
private bool InteractUI(IEntity user, ActivatableUIComponent aui)
|
||||
{
|
||||
if (!user.TryGetComponent(out ActorComponent? actor)) return false;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out ActorComponent? actor)) return false;
|
||||
|
||||
if (aui.AdminOnly && !_adminManager.IsAdmin(actor.PlayerSession)) return false;
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Content.Shared.Lathe
|
||||
|
||||
public bool CanProduce(LatheRecipePrototype recipe, int quantity = 1)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out SharedMaterialStorageComponent? storage)
|
||||
|| !Owner.TryGetComponent(out SharedLatheDatabaseComponent? database)) return false;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SharedMaterialStorageComponent? storage)
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SharedLatheDatabaseComponent? database)) return false;
|
||||
|
||||
if (!database.Contains(recipe)) return false;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Content.Shared.Movement.EntitySystems
|
||||
|
||||
// For stuff like "Moving out of locker" or the likes
|
||||
if (owner.IsInContainer() &&
|
||||
(!owner.TryGetComponent(out MobStateComponent? mobState) ||
|
||||
(!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out MobStateComponent? mobState) ||
|
||||
mobState.IsAlive()))
|
||||
{
|
||||
var relayMoveEvent = new RelayMovementEntityEvent(owner);
|
||||
@@ -85,7 +85,7 @@ namespace Content.Shared.Movement.EntitySystems
|
||||
if (ent == null || !IoCManager.Resolve<IEntityManager>().EntityExists(ent.Uid))
|
||||
return false;
|
||||
|
||||
if (!ent.TryGetComponent(out T? comp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(ent.Uid, out T? comp))
|
||||
return false;
|
||||
|
||||
component = comp;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Storage.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.Storage.EntitySystems
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Content.Shared.Storage.EntitySystems
|
||||
private void CounterEntityInserted(EntityUid uid, ItemCounterComponent itemCounter,
|
||||
EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (!itemCounter.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(itemCounter.Owner.Uid, out AppearanceComponent? appearanceComponent)) return;
|
||||
|
||||
var count = GetCount(args, itemCounter);
|
||||
if (count == null)
|
||||
@@ -35,7 +36,7 @@ namespace Content.Shared.Storage.EntitySystems
|
||||
private void CounterEntityRemoved(EntityUid uid, ItemCounterComponent itemCounter,
|
||||
EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (!itemCounter.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(itemCounter.Owner.Uid, out AppearanceComponent? appearanceComponent)) return;
|
||||
|
||||
var count = GetCount(args, itemCounter);
|
||||
if (count == null)
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Storage.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.Storage.EntitySystems
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Content.Shared.Storage.EntitySystems
|
||||
|
||||
private void InitLayers(EntityUid uid, ItemMapperComponent component, ComponentInit args)
|
||||
{
|
||||
if (component.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearanceComponent))
|
||||
{
|
||||
var list = new List<string>(component.MapLayers.Keys);
|
||||
appearanceComponent.SetData(StorageMapVisuals.InitLayers, new ShowLayerData(list));
|
||||
@@ -30,7 +31,7 @@ namespace Content.Shared.Storage.EntitySystems
|
||||
private void MapperEntityRemoved(EntityUid uid, ItemMapperComponent itemMapper,
|
||||
EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (itemMapper.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemMapper.Owner.Uid, out AppearanceComponent? appearanceComponent)
|
||||
&& TryGetLayers(args, itemMapper, out var containedLayers))
|
||||
{
|
||||
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));
|
||||
@@ -40,7 +41,7 @@ namespace Content.Shared.Storage.EntitySystems
|
||||
private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper,
|
||||
EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (itemMapper.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemMapper.Owner.Uid, out AppearanceComponent? appearanceComponent)
|
||||
&& TryGetLayers(args, itemMapper, out var containedLayers))
|
||||
{
|
||||
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));
|
||||
|
||||
Reference in New Issue
Block a user