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

@@ -11,6 +11,7 @@ using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -40,7 +41,7 @@ namespace Content.Server.Recycling.Components
private void Clean()
{
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
{
appearance.SetData(RecyclerVisuals.Bloody, false);
}
@@ -48,7 +49,7 @@ namespace Content.Server.Recycling.Components
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
{
if (victim.TryGetComponent(out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind)
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(victim.Uid, out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind)
{
EntitySystem.Get<GameTicker>().OnGhostAttempt(mind, false);
mind.OwnedEntity?.PopupMessage(Loc.GetString("recycler-component-suicide-message"));
@@ -56,7 +57,7 @@ namespace Content.Server.Recycling.Components
victim.PopupMessageOtherClients(Loc.GetString("recycler-component-suicide-message-others", ("victim",victim)));
if (victim.TryGetComponent<SharedBodyComponent>(out var body))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBodyComponent?>(victim.Uid, out var body))
{
body.Gib(true);
}

View File

@@ -29,7 +29,7 @@ namespace Content.Server.Recycling
// TODO: Prevent collision with recycled items
// Can only recycle things that are recyclable... And also check the safety of the thing to recycle.
if (!entity.TryGetComponent(out RecyclableComponent? recyclable) || !recyclable.Safe && component.Safe) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out RecyclableComponent? recyclable) || !recyclable.Safe && component.Safe) return;
// Mobs are a special case!
if (CanGib(component, entity))
@@ -46,12 +46,12 @@ namespace Content.Server.Recycling
{
// We suppose this entity has a Recyclable component.
return IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity.Uid) && !component.Safe &&
component.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) && receiver.Powered;
IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out ApcPowerReceiverComponent? receiver) && receiver.Powered;
}
public void Bloodstain(RecyclerComponent component)
{
if (component.Owner.TryGetComponent(out AppearanceComponent? appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance))
{
appearance.SetData(RecyclerVisuals.Bloody, true);
}