Inline AddComponent

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:33:40 +01:00
parent 2d130e31d6
commit f64df117be
18 changed files with 26 additions and 19 deletions

View File

@@ -7,6 +7,7 @@ using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -113,7 +114,7 @@ namespace Content.Client.Doors
{
if (!entity.HasComponent<AnimationPlayerComponent>())
{
entity.AddComponent<AnimationPlayerComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
}
}

View File

@@ -143,7 +143,7 @@ namespace Content.Client.Entry
/// </summary>
public static void AttachPlayerToEntity(EntityAttachedEventArgs eventArgs)
{
eventArgs.NewEntity.AddComponent<CharacterInterfaceComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<CharacterInterfaceComponent>(eventArgs.NewEntity);
}
/// <summary>

View File

@@ -5,6 +5,7 @@ using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Lathe.Visualizers
{
@@ -51,7 +52,7 @@ namespace Content.Client.Lathe.Visualizers
{
if (!entity.HasComponent<AnimationPlayerComponent>())
{
entity.AddComponent<AnimationPlayerComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
}
}

View File

@@ -5,6 +5,7 @@ using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Lathe.Visualizers
{
@@ -51,7 +52,7 @@ namespace Content.Client.Lathe.Visualizers
{
if (!entity.HasComponent<AnimationPlayerComponent>())
{
entity.AddComponent<AnimationPlayerComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
}
}

View File

@@ -4,6 +4,7 @@ using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
namespace Content.Client.Singularity.Visualizers
@@ -47,7 +48,7 @@ namespace Content.Client.Singularity.Visualizers
{
if (!entity.HasComponent<AnimationPlayerComponent>())
{
entity.AddComponent<AnimationPlayerComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
}
}

View File

@@ -5,6 +5,7 @@ using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -39,7 +40,7 @@ namespace Content.Client.Trigger
{
if (!entity.HasComponent<AnimationPlayerComponent>())
{
entity.AddComponent<AnimationPlayerComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
}
}

View File

@@ -4,6 +4,7 @@ using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
@@ -122,7 +123,7 @@ namespace Content.Client.VendingMachines.UI
if (!entity.HasComponent<AnimationPlayerComponent>())
{
entity.AddComponent<AnimationPlayerComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
}
}

View File

@@ -28,10 +28,10 @@ namespace Content.IntegrationTests.Tests
var entMgr = IoCManager.Resolve<IEntityManager>();
var container = entMgr.SpawnEntity(null, MapCoordinates.Nullspace);
var inv = container.AddComponent<InventoryComponent>();
var inv = (InventoryComponent) IoCManager.Resolve<IEntityManager>().AddComponent<InventoryComponent>(container);
var child = entMgr.SpawnEntity(null, MapCoordinates.Nullspace);
var item = child.AddComponent<ClothingComponent>();
var item = (ClothingComponent) IoCManager.Resolve<IEntityManager>().AddComponent<ClothingComponent>(child);
item.SlotFlags = SlotFlags.HEAD;
// Equip item.

View File

@@ -92,7 +92,7 @@ namespace Content.IntegrationTests.Tests.Networking
var map = sMapManager.CreateMap();
var player = sPlayerManager.ServerSessions.Single();
serverEnt = sEntityManager.SpawnEntity(null, new MapCoordinates((0, 0), map));
serverComponent = serverEnt.AddComponent<PredictionTestComponent>();
serverComponent = IoCManager.Resolve<IEntityManager>().AddComponent<PredictionTestComponent>(serverEnt);
// Make client "join game" so they receive game state updates.
player.JoinGame();

View File

@@ -47,7 +47,7 @@ namespace Content.Server.AI.Commands
ent.RemoveComponent<IMoverComponent>();
}
var comp = ent.AddComponent<UtilityAi>();
var comp = IoCManager.Resolve<IEntityManager>().AddComponent<UtilityAi>(ent);
var behaviorManager = IoCManager.Resolve<INpcBehaviorManager>();
for (var i = 1; i < args.Length; i++)

View File

@@ -53,7 +53,7 @@ namespace Content.Server.Atmos.Commands
return;
}
grid.AddComponent<GridAtmosphereComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<GridAtmosphereComponent>(grid);
shell.WriteLine($"Added atmosphere to grid {id}.");
}

View File

@@ -53,7 +53,7 @@ namespace Content.Server.Atmos.Commands
return;
}
grid.AddComponent<UnsimulatedGridAtmosphereComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<UnsimulatedGridAtmosphereComponent>(grid);
shell.WriteLine($"Added unsimulated atmosphere to grid {id}.");
}

View File

@@ -50,7 +50,7 @@ namespace Content.Server.Chemistry.Components
return;
Amount = amount;
var inception = Owner.AddComponent<SolutionAreaEffectInceptionComponent>();
var inception = IoCManager.Resolve<IEntityManager>().AddComponent<SolutionAreaEffectInceptionComponent>(Owner);
inception.Add(this);
inception.Setup(amount, duration, spreadDelay, removeDelay);

View File

@@ -141,7 +141,7 @@ namespace Content.Server.Cloning.Components
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(mob.Uid, dna.Profile);
mob.Name = dna.Profile.Name;
var cloneMindReturn = mob.AddComponent<BeingClonedComponent>();
var cloneMindReturn = IoCManager.Resolve<IEntityManager>().AddComponent<BeingClonedComponent>(mob);
cloneMindReturn.Mind = mind;
cloneMindReturn.Parent = Owner.Uid;

View File

@@ -123,7 +123,7 @@ namespace Content.Server.GameTicking
if (player.UserId == new Guid("{e887eb93-f503-4b65-95b6-2f282c014192}"))
{
mob.AddComponent<OwOAccentComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<OwOAccentComponent>(mob);
}
AddManifestEntry(character.Name, jobId);

View File

@@ -117,7 +117,7 @@ namespace Content.Server.GameTicking.Presets
var pda = newPDA.GetComponent<PDAComponent>();
_entityManager.EntitySysManager.GetEntitySystem<PDASystem>()
.SetOwner(pda, mind.OwnedEntity.Name);
newPDA.AddComponent<TraitorDeathMatchReliableOwnerTagComponent>().UserId = mind.UserId;
IoCManager.Resolve<IEntityManager>().AddComponent<TraitorDeathMatchReliableOwnerTagComponent>(newPDA).UserId = mind.UserId;
}
// Finally, it would be preferrable if they spawned as far away from other players as reasonably possible.

View File

@@ -357,7 +357,7 @@ namespace Content.Server.Mind
Session?.AttachToEntity(entity);
VisitingEntity = entity;
var comp = entity.AddComponent<VisitingMindComponent>();
var comp = IoCManager.Resolve<IEntityManager>().AddComponent<VisitingMindComponent>(entity);
comp.Mind = this;
Logger.Info($"Session {Session?.Name} visiting entity {entity}.");

View File

@@ -1,6 +1,7 @@
using Content.Shared.Pointing.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
@@ -76,7 +77,7 @@ namespace Content.Server.Pointing.Components
if (_rogue)
{
Owner.RemoveComponent<PointingArrowComponent>();
Owner.AddComponent<RoguePointingArrowComponent>();
IoCManager.Resolve<IEntityManager>().AddComponent<RoguePointingArrowComponent>(Owner);
return;
}