API changes, renamed SpawnEntityAt to SpawnEntity.

This commit is contained in:
Acruid
2020-01-24 16:10:48 -08:00
parent 4ab7f1dcb3
commit a86363a6d2
20 changed files with 44 additions and 30 deletions

View File

@@ -78,7 +78,7 @@ namespace Content.Client.GameObjects.Components.Construction
public void SpawnGhost(ConstructionPrototype prototype, GridCoordinates loc, Direction dir) public void SpawnGhost(ConstructionPrototype prototype, GridCoordinates loc, Direction dir)
{ {
var entMgr = IoCManager.Resolve<IClientEntityManager>(); var entMgr = IoCManager.Resolve<IClientEntityManager>();
var ghost = entMgr.SpawnEntityAt("constructionghost", loc); var ghost = entMgr.SpawnEntity("constructionghost", loc);
var comp = ghost.GetComponent<ConstructionGhostComponent>(); var comp = ghost.GetComponent<ConstructionGhostComponent>();
comp.Prototype = prototype; comp.Prototype = prototype;
comp.Master = this; comp.Master = this;

View File

@@ -1,4 +1,4 @@
using Content.Client.GameObjects.Components.Mobs; using Content.Client.GameObjects.Components.Mobs;
using Content.Client.GameObjects.Components.Weapons.Melee; using Content.Client.GameObjects.Components.Weapons.Melee;
using Content.Shared.GameObjects.Components.Weapons.Melee; using Content.Shared.GameObjects.Components.Weapons.Melee;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -71,7 +71,7 @@ namespace Content.Client.GameObjects.EntitySystems
var lunge = attacker.EnsureComponent<MeleeLungeComponent>(); var lunge = attacker.EnsureComponent<MeleeLungeComponent>();
lunge.SetData(msg.Angle); lunge.SetData(msg.Angle);
var entity = EntityManager.SpawnEntityAt("WeaponArc", attacker.Transform.GridPosition); var entity = EntityManager.SpawnEntity("WeaponArc", attacker.Transform.GridPosition);
entity.Transform.LocalRotation = msg.Angle; entity.Transform.LocalRotation = msg.Angle;
var weaponArcAnimation = entity.GetComponent<MeleeWeaponArcAnimationComponent>(); var weaponArcAnimation = entity.GetComponent<MeleeWeaponArcAnimationComponent>();

View File

@@ -209,7 +209,7 @@ namespace Content.Client.UserInterface
ButtonGroup group, ButtonGroup group,
ICharacterProfile profile) ICharacterProfile profile)
{ {
_previewDummy = entityManager.SpawnEntityAt("HumanMob_Dummy", MapCoordinates.Nullspace); _previewDummy = entityManager.SpawnEntity("HumanMob_Dummy", MapCoordinates.Nullspace);
_previewDummy.GetComponent<HumanoidAppearanceComponent>().UpdateFromProfile(profile); _previewDummy.GetComponent<HumanoidAppearanceComponent>().UpdateFromProfile(profile);
var humanoid = profile as HumanoidCharacterProfile; var humanoid = profile as HumanoidCharacterProfile;
if (humanoid != null) if (humanoid != null)

View File

@@ -28,7 +28,7 @@ namespace Content.Client.UserInterface
IClientPreferencesManager preferencesManager) IClientPreferencesManager preferencesManager)
{ {
_preferencesManager = preferencesManager; _preferencesManager = preferencesManager;
_previewDummy = entityManager.SpawnEntityAt("HumanMob_Dummy", MapCoordinates.Nullspace); _previewDummy = entityManager.SpawnEntity("HumanMob_Dummy", MapCoordinates.Nullspace);
var header = new NanoHeading var header = new NanoHeading
{ {
@@ -120,7 +120,7 @@ namespace Content.Client.UserInterface
foreach (var (slot, itemType) in gear.Equipment) foreach (var (slot, itemType) in gear.Equipment)
{ {
var item = entityMan.SpawnEntityAt(itemType, MapCoordinates.Nullspace); var item = entityMan.SpawnEntity(itemType, MapCoordinates.Nullspace);
inventory.SetSlotVisuals(slot, item); inventory.SetSlotVisuals(slot, item);

View File

@@ -36,11 +36,11 @@ namespace Content.IntegrationTests.Tests
var entityMan = IoCManager.Resolve<IEntityManager>(); var entityMan = IoCManager.Resolve<IEntityManager>();
human = entityMan.SpawnEntityAt("HumanMob_Content", MapCoordinates.Nullspace); human = entityMan.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);
uniform = entityMan.SpawnEntityAt("JanitorUniform", MapCoordinates.Nullspace); uniform = entityMan.SpawnEntity("JanitorUniform", MapCoordinates.Nullspace);
idCard = entityMan.SpawnEntityAt("IDCardStandard", MapCoordinates.Nullspace); idCard = entityMan.SpawnEntity("IDCardStandard", MapCoordinates.Nullspace);
pocketItem = entityMan.SpawnEntityAt("FlashlightLantern", MapCoordinates.Nullspace); pocketItem = entityMan.SpawnEntity("FlashlightLantern", MapCoordinates.Nullspace);
var tooBigItem = entityMan.SpawnEntityAt("RedToolboxItem", MapCoordinates.Nullspace); var tooBigItem = entityMan.SpawnEntity("RedToolboxItem", MapCoordinates.Nullspace);
inventory = human.GetComponent<InventoryComponent>(); inventory = human.GetComponent<InventoryComponent>();

View File

@@ -3,6 +3,7 @@ using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.Administration namespace Content.Server.Administration
{ {
@@ -30,8 +31,7 @@ namespace Content.Server.Administration
else else
{ {
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();
var ghost = entityManager.SpawnEntityAt("AdminObserver", var ghost = entityManager.SpawnEntity("AdminObserver", player.AttachedEntity.Transform.GridPosition);
player.AttachedEntity.Transform.GridPosition);
mind.Visit(ghost); mind.Visit(ghost);
} }

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Robust.Shared.Map;
namespace Content.Server.GameObjects.Components.Cargo namespace Content.Server.GameObjects.Components.Cargo
{ {
@@ -104,7 +105,7 @@ namespace Content.Server.GameObjects.Components.Cargo
continue; continue;
for (var i = 0; i < order.Amount; i++) for (var i = 0; i < order.Amount; i++)
{ {
Owner.EntityManager.SpawnEntityAt(product.Product, Owner.Transform.GridPosition); Owner.EntityManager.SpawnEntity(product.Product, Owner.Transform.GridPosition);
} }
} }
break; break;

View File

@@ -12,6 +12,7 @@ using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.Construction.ConstructionStepMaterial; using static Content.Shared.Construction.ConstructionStepMaterial;
using static Content.Shared.Construction.ConstructionStepTool; using static Content.Shared.Construction.ConstructionStepTool;
@@ -54,7 +55,7 @@ namespace Content.Server.GameObjects.Components.Construction
{ {
// Oh boy we get to finish construction! // Oh boy we get to finish construction!
var entMgr = IoCManager.Resolve<IServerEntityManager>(); var entMgr = IoCManager.Resolve<IServerEntityManager>();
var ent = entMgr.SpawnEntityAt(Prototype.Result, Transform.GridPosition); var ent = entMgr.SpawnEntity(Prototype.Result, Transform.GridPosition);
ent.GetComponent<ITransformComponent>().LocalRotation = Transform.LocalRotation; ent.GetComponent<ITransformComponent>().LocalRotation = Transform.LocalRotation;
Owner.Delete(); Owner.Delete();
return true; return true;

View File

@@ -82,12 +82,12 @@ namespace Content.Server.GameObjects.Components.Construction
if (prototype.Stages.Count == 2) if (prototype.Stages.Count == 2)
{ {
// Exactly 2 stages, so don't make an intermediate frame. // Exactly 2 stages, so don't make an intermediate frame.
var ent = _serverEntityManager.SpawnEntityAt(prototype.Result, loc); var ent = _serverEntityManager.SpawnEntity(prototype.Result, loc);
ent.Transform.LocalRotation = angle; ent.Transform.LocalRotation = angle;
} }
else else
{ {
var frame = _serverEntityManager.SpawnEntityAt("structureconstructionframe", loc); var frame = _serverEntityManager.SpawnEntity("structureconstructionframe", loc);
var construction = frame.GetComponent<ConstructionComponent>(); var construction = frame.GetComponent<ConstructionComponent>();
construction.Init(prototype); construction.Init(prototype);
frame.Transform.LocalRotation = angle; frame.Transform.LocalRotation = angle;

View File

@@ -7,6 +7,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -105,7 +106,7 @@ namespace Content.Server.GameObjects.Components.Destructible
{ {
if (!string.IsNullOrWhiteSpace(spawnOnDestroy) && eventArgs.IsSpawnWreck) if (!string.IsNullOrWhiteSpace(spawnOnDestroy) && eventArgs.IsSpawnWreck)
{ {
Owner.EntityManager.SpawnEntityAt(spawnOnDestroy, Owner.Transform.GridPosition); Owner.EntityManager.SpawnEntity(spawnOnDestroy, Owner.Transform.GridPosition);
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.GameObjects.Components.Items.Storage.Fill namespace Content.Server.GameObjects.Components.Items.Storage.Fill
{ {
@@ -21,7 +22,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype) void Spawn(string prototype)
{ {
storage.Insert(_entityManager.SpawnEntityAt(prototype, Owner.Transform.GridPosition)); storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
} }
Spawn("Brutepack"); Spawn("Brutepack");

View File

@@ -3,6 +3,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Random; using Robust.Shared.Random;
namespace Content.Server.GameObjects.Components.Items.Storage.Fill namespace Content.Server.GameObjects.Components.Items.Storage.Fill
@@ -23,7 +24,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype) void Spawn(string prototype)
{ {
storage.Insert(_entityManager.SpawnEntityAt(prototype, Owner.Transform.GridPosition)); storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
} }
Spawn("Screwdriver"); Spawn("Screwdriver");

View File

@@ -235,11 +235,11 @@ namespace Content.Server.GameObjects.Components.Movement
{ {
// Call Delete here as the teleporter should have control over portal longevity // Call Delete here as the teleporter should have control over portal longevity
// Departure portal // Departure portal
var departurePortal = _serverEntityManager.SpawnEntityAt("Portal", user.Transform.GridPosition); var departurePortal = _serverEntityManager.SpawnEntity("Portal", user.Transform.GridPosition);
departurePortal.TryGetComponent<ServerPortalComponent>(out var departureComponent); departurePortal.TryGetComponent<ServerPortalComponent>(out var departureComponent);
// Arrival portal // Arrival portal
var arrivalPortal = _serverEntityManager.SpawnEntityAt("Portal", targetGrid); var arrivalPortal = _serverEntityManager.SpawnEntity("Portal", targetGrid);
arrivalPortal.TryGetComponent<ServerPortalComponent>(out var arrivalComponent); arrivalPortal.TryGetComponent<ServerPortalComponent>(out var arrivalComponent);
// Connect. TODO: If the OnUpdate in ServerPortalComponent is changed this may need to change as well. // Connect. TODO: If the OnUpdate in ServerPortalComponent is changed this may need to change as well.

View File

@@ -4,8 +4,10 @@ using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Power namespace Content.Server.GameObjects.Components.Power
@@ -140,7 +142,7 @@ namespace Content.Server.GameObjects.Components.Power
if (eventArgs.AttackWith.TryGetComponent(out WirecutterComponent wirecutter)) if (eventArgs.AttackWith.TryGetComponent(out WirecutterComponent wirecutter))
{ {
Owner.Delete(); Owner.Delete();
var droppedEnt = Owner.EntityManager.SpawnEntityAt("CableStack", eventArgs.ClickLocation); var droppedEnt = Owner.EntityManager.SpawnEntity("CableStack", eventArgs.ClickLocation);
if (droppedEnt.TryGetComponent<StackComponent>(out var stackComp)) if (droppedEnt.TryGetComponent<StackComponent>(out var stackComp))
stackComp.Count = 1; stackComp.Count = 1;

View File

@@ -4,8 +4,10 @@ using Robust.Server.GameObjects;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.GameObjects.Components.Power namespace Content.Server.GameObjects.Components.Power
{ {
@@ -50,7 +52,8 @@ namespace Content.Server.GameObjects.Components.Power
if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1)) if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1))
return; return;
var newWire = _entityManager.SpawnEntityAt("Wire", grid.GridTileToLocal(snapPos)); GridCoordinates coordinates = grid.GridTileToLocal(snapPos);
var newWire = _entityManager.SpawnEntity("Wire", coordinates);
if (newWire.TryGetComponent(out SpriteComponent wireSpriteComp) && hasItemSpriteComp) if (newWire.TryGetComponent(out SpriteComponent wireSpriteComp) && hasItemSpriteComp)
{ {
wireSpriteComp.Color = itemSpriteComp.Color; wireSpriteComp.Color = itemSpriteComp.Color;

View File

@@ -12,6 +12,7 @@ using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Timers; using Robust.Shared.Timers;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -103,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Research
{ {
Producing = false; Producing = false;
_producingRecipe = null; _producingRecipe = null;
Owner.EntityManager.SpawnEntityAt(recipe.Result, Owner.Transform.GridPosition); Owner.EntityManager.SpawnEntity(recipe.Result, Owner.Transform.GridPosition);
_userInterface.SendMessage(new LatheStoppedProducingRecipeMessage()); _userInterface.SendMessage(new LatheStoppedProducingRecipeMessage());
}); });

View File

@@ -11,6 +11,7 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -167,7 +168,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines
{ {
TrySetVisualState(VendingMachineVisualState.Normal); TrySetVisualState(VendingMachineVisualState.Normal);
_ejecting = false; _ejecting = false;
Owner.EntityManager.SpawnEntityAt(id, Owner.Transform.GridPosition); Owner.EntityManager.SpawnEntity(id, Owner.Transform.GridPosition);
}); });
} }

View File

@@ -170,7 +170,7 @@ namespace Content.Server.GameObjects.EntitySystems
else else
{ {
stackComp.Use(1); stackComp.Use(1);
throwEnt = throwEnt.EntityManager.SpawnEntityAt(throwEnt.Prototype.ID, plyEnt.Transform.GridPosition); throwEnt = throwEnt.EntityManager.SpawnEntity(throwEnt.Prototype.ID, plyEnt.Transform.GridPosition);
// can only throw one item at a time, regardless of what the prototype stack size is. // can only throw one item at a time, regardless of what the prototype stack size is.
if (throwEnt.TryGetComponent<StackComponent>(out var newStackComp)) if (throwEnt.TryGetComponent<StackComponent>(out var newStackComp))

View File

@@ -260,7 +260,8 @@ namespace Content.Server.GameTicking
private IEntity _spawnPlayerMob(Job job, bool lateJoin = true) private IEntity _spawnPlayerMob(Job job, bool lateJoin = true)
{ {
var entity = _entityManager.SpawnEntityAt(PlayerPrototypeName, lateJoin ? _getLateJoinSpawnPoint() : _getJobSpawnPoint(job.Prototype.ID)); GridCoordinates coordinates = lateJoin ? _getLateJoinSpawnPoint() : _getJobSpawnPoint(job.Prototype.ID);
var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates);
if (entity.TryGetComponent(out InventoryComponent inventory)) if (entity.TryGetComponent(out InventoryComponent inventory))
{ {
var gear = _prototypeManager.Index<StartingGearPrototype>(job.StartingGear).Equipment; var gear = _prototypeManager.Index<StartingGearPrototype>(job.StartingGear).Equipment;
@@ -284,7 +285,8 @@ namespace Content.Server.GameTicking
private IEntity _spawnObserverMob() private IEntity _spawnObserverMob()
{ {
return _entityManager.SpawnEntityAt(ObserverPrototypeName, _getLateJoinSpawnPoint()); GridCoordinates coordinates = _getLateJoinSpawnPoint();
return _entityManager.SpawnEntity(ObserverPrototypeName, coordinates);
} }
private GridCoordinates _getLateJoinSpawnPoint() private GridCoordinates _getLateJoinSpawnPoint()