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; return;
} }
var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper"); var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper", Owner.Transform.GridPosition);
_cellContainer.Insert(cell); _cellContainer.Insert(cell);
} }
} }

View File

@@ -43,8 +43,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId)); mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId));
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/crowbar.ogg", Owner); _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. //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); var tileItem = Owner.EntityManager.SpawnEntity(tileDef.ItemDropPrototypeName, coordinates);
tileItem.Transform.GridPosition = coordinates;
tileItem.Transform.WorldPosition += (0.2f, 0.2f); 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) void Spawn(string prototype)
{ {
storage.Insert(_entityManager.SpawnEntity(prototype)); storage.Insert(_entityManager.SpawnEntityAt(prototype, Owner.Transform.GridPosition));
} }
Spawn("Brutepack"); Spawn("Brutepack");

View File

@@ -23,7 +23,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype) void Spawn(string prototype)
{ {
storage.Insert(_entityManager.SpawnEntity(prototype)); storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
} }
if (random.Prob(0.4f)) 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.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
@@ -23,7 +23,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype) void Spawn(string prototype)
{ {
storage.Insert(_entityManager.SpawnEntity(prototype)); storage.Insert(_entityManager.SpawnEntityAt(prototype, Owner.Transform.GridPosition));
} }
Spawn("Screwdriver"); Spawn("Screwdriver");

View File

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

View File

@@ -1,4 +1,4 @@
using System; using System;
using Content.Server.GameObjects.Components.Chemistry; using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.GameObjects.Components.Sound; using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
@@ -162,7 +162,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
if (_finishPrototype != null) 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 (user.TryGetComponent(out HandsComponent handsComponent) && finisher.TryGetComponent(out ItemComponent itemComponent))
{ {
if (handsComponent.CanPutInHand(itemComponent)) if (handsComponent.CanPutInHand(itemComponent))

View File

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

View File

@@ -160,7 +160,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
if (_finishPrototype != null) 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 (user.TryGetComponent(out HandsComponent handsComponent) && finisher.TryGetComponent(out ItemComponent itemComponent))
{ {
if (handsComponent.CanPutInHand(itemComponent)) if (handsComponent.CanPutInHand(itemComponent))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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