Entities now require a location when being spawned.

This commit is contained in:
Acruid
2019-12-16 21:44:24 -08:00
parent 12261c5b56
commit 1fe09c580c
17 changed files with 27 additions and 32 deletions

View File

@@ -252,7 +252,7 @@ namespace Content.Server.GameObjects.Components.Interactable
{
return;
}
var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper");
var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper", Owner.Transform.GridPosition);
_cellContainer.Insert(cell);
}
}

View File

@@ -43,8 +43,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId));
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/crowbar.ogg", Owner);
//Actually spawn the relevant tile item at the right position and give it some offset to the corner.
var tileItem = Owner.EntityManager.SpawnEntity(tileDef.ItemDropPrototypeName);
tileItem.Transform.GridPosition = coordinates;
var tileItem = Owner.EntityManager.SpawnEntity(tileDef.ItemDropPrototypeName, coordinates);
tileItem.Transform.WorldPosition += (0.2f, 0.2f);
}
}

View File

@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype));
storage.Insert(_entityManager.SpawnEntityAt(prototype, Owner.Transform.GridPosition));
}
Spawn("Brutepack");

View File

@@ -23,7 +23,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
}
if (random.Prob(0.4f))

View File

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

View File

@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
}
Spawn("Crowbar");

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
@@ -162,7 +162,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
if (_finishPrototype != null)
{
var finisher = Owner.EntityManager.SpawnEntity(_finishPrototype);
var finisher = Owner.EntityManager.SpawnEntity(_finishPrototype, Owner.Transform.GridPosition);
if (user.TryGetComponent(out HandsComponent handsComponent) && finisher.TryGetComponent(out ItemComponent itemComponent))
{
if (handsComponent.CanPutInHand(itemComponent))

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Sound;
@@ -148,7 +148,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
if (_availableSpawnCount > 0)
{
var prototypeName = _getProbItem(_prototypes);
item = Owner.EntityManager.SpawnEntity(prototypeName);
item = Owner.EntityManager.SpawnEntity(prototypeName, Owner.Transform.GridPosition);
_availableSpawnCount -= 1;
}
@@ -166,7 +166,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
// Ideally this takes priority to be put into inventory rather than the desired item
if (_finishPrototype != null)
{
var item = Owner.EntityManager.SpawnEntity(_finishPrototype);
var item = Owner.EntityManager.SpawnEntity(_finishPrototype, Owner.Transform.GridPosition);
item.Transform.GridPosition = Owner.Transform.GridPosition;
Owner.Delete();
if (user.TryGetComponent(out HandsComponent handsComponent) &&

View File

@@ -160,7 +160,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
if (_finishPrototype != null)
{
var finisher = Owner.EntityManager.SpawnEntity(_finishPrototype);
var finisher = Owner.EntityManager.SpawnEntity(_finishPrototype, Owner.Transform.GridPosition);
if (user.TryGetComponent(out HandsComponent handsComponent) && finisher.TryGetComponent(out ItemComponent itemComponent))
{
if (handsComponent.CanPutInHand(itemComponent))

View File

@@ -202,10 +202,10 @@ namespace Content.Server.GameObjects.Components.Power
switch (BulbType)
{
case LightBulbType.Tube:
_lightBulbContainer.Insert(Owner.EntityManager.SpawnEntity("LightTube"));
_lightBulbContainer.Insert(Owner.EntityManager.SpawnEntity("LightTube", Owner.Transform.GridPosition));
break;
case LightBulbType.Bulb:
_lightBulbContainer.Insert(Owner.EntityManager.SpawnEntity("LightBulb"));
_lightBulbContainer.Insert(Owner.EntityManager.SpawnEntity("LightBulb", Owner.Transform.GridPosition));
break;
}
}

View File

@@ -223,7 +223,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
}
_availableSpawnCount -= 1;
bullet = Owner.EntityManager.SpawnEntity(FillType);
bullet = Owner.EntityManager.SpawnEntity(FillType, Owner.Transform.GridPosition);
}
else
{

View File

@@ -114,7 +114,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
}
_availableSpawnCount -= 1;
bullet = Owner.EntityManager.SpawnEntity(FillType);
bullet = Owner.EntityManager.SpawnEntity(FillType, Owner.Transform.GridPosition);
}
else
{

View File

@@ -280,7 +280,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
{
if (_defaultMagazine != null)
{
var magazine = Owner.EntityManager.SpawnEntity(_defaultMagazine);
var magazine = Owner.EntityManager.SpawnEntity(_defaultMagazine, Owner.Transform.GridPosition);
InsertMagazine(magazine, false);
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Content.Server.GameObjects.Components.Sound;
using Robust.Server.GameObjects.Components.Container;
using Robust.Shared.Interfaces.GameObjects;
@@ -78,7 +78,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
return null;
}
var projectile = Owner.EntityManager.SpawnEntity(bullet.ProjectileType);
var projectile = Owner.EntityManager.SpawnEntity(bullet.ProjectileType, Owner.Transform.GridPosition);
bullet.Spent = true;
CycleChamberedBullet(0);

View File

@@ -278,7 +278,7 @@ namespace Content.Server.GameTicking
Logger.Error("{0} is an invalid equipment slot.", slotStr);
continue;
}
var equipmentEntity = _entityManager.SpawnEntity(equipmentStr);
var equipmentEntity = _entityManager.SpawnEntity(equipmentStr, entity.Transform.GridPosition);
inventory.Equip(slot, equipmentEntity.GetComponent<ClothingComponent>());
}
}

View File

@@ -14,18 +14,14 @@ namespace Content.Server.Placement
/// <summary>
/// Spawns a spotlight ground turret that will track any living entities in range.
/// </summary>
/// <param name="grid"></param>
/// <param name="localPosition"></param>
public static void SpawnLightTurret(IMapGrid grid, Vector2 localPosition)
/// <param name="position"></param>
public static void SpawnLightTurret(GridCoordinates position)
{
var entMan = IoCManager.Resolve<IServerEntityManager>();
var tBase = entMan.SpawnEntity("TurretBase");
tBase.GetComponent<ITransformComponent>().GridPosition = new GridCoordinates(localPosition, grid);
var tBase = entMan.SpawnEntity("TurretBase", position);
var tTop = entMan.SpawnEntity("TurretTopLight");
var topTransform = tTop.GetComponent<ITransformComponent>();
topTransform.GridPosition = new GridCoordinates(localPosition, grid);
topTransform.AttachParent(tBase);
var tTop = entMan.SpawnEntity("TurretTopLight", position);
tTop.Transform.AttachParent(tBase);
}
}
}