From 1fe09c580c0920b20b5cbe3b78dea508f43dc224 Mon Sep 17 00:00:00 2001 From: Acruid Date: Mon, 16 Dec 2019 21:44:24 -0800 Subject: [PATCH] Entities now require a location when being spawned. --- .../Interactable/HandheldLightComponent.cs | 2 +- .../Interactable/Tools/CrowbarComponent.cs | 3 +-- .../Items/Storage/Fill/MedkitFillComponent.cs | 2 +- .../Items/Storage/Fill/ToolLockerFillComponent.cs | 2 +- .../Storage/Fill/ToolboxElectricalFillComponent.cs | 4 ++-- .../Fill/UtilityBeltClothingFillComponent.cs | 2 +- .../Components/Nutrition/DrinkComponent.cs | 4 ++-- .../Nutrition/DrinkFoodContainerComponent.cs | 6 +++--- .../Components/Nutrition/FoodComponent.cs | 2 +- .../Components/Power/PoweredLightComponent.cs | 4 ++-- .../Weapon/Ranged/Projectile/AmmoBoxComponent.cs | 2 +- .../Projectile/BallisticMagazineComponent.cs | 2 +- .../Projectile/BallisticMagazineWeaponComponent.cs | 2 +- .../Ranged/Projectile/BallisticWeaponComponent.cs | 4 ++-- Content.Server/GameTicking/GameTicker.cs | 2 +- Content.Server/Placement/SpawnHelpers.cs | 14 +++++--------- RobustToolbox | 2 +- 17 files changed, 27 insertions(+), 32 deletions(-) diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs index a2d11d706f..8ddcb10d65 100644 --- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs @@ -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); } } diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs index f3c81d020e..8d052c9680 100644 --- a/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs @@ -43,8 +43,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId)); _entitySystemManager.GetEntitySystem().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); } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs index e38d9f0b7b..bdfcc3149d 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs @@ -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"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs index 1b53d013fb..b6322c56e4 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs @@ -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)) diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs index b3aada08a4..77067b3f7f 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs @@ -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"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs index 1113f0cfa6..bda1fa3344 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs @@ -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"); diff --git a/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs b/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs index dda4ddeba2..503cabc722 100644 --- a/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs @@ -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)) diff --git a/Content.Server/GameObjects/Components/Nutrition/DrinkFoodContainerComponent.cs b/Content.Server/GameObjects/Components/Nutrition/DrinkFoodContainerComponent.cs index 7d9e053772..4c5dae3ba9 100644 --- a/Content.Server/GameObjects/Components/Nutrition/DrinkFoodContainerComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/DrinkFoodContainerComponent.cs @@ -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) && diff --git a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs index fb53626e59..7bb7888ff2 100644 --- a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs @@ -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)) diff --git a/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs b/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs index 5804722fc0..7b5bd39733 100644 --- a/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs +++ b/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs @@ -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; } } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/AmmoBoxComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/AmmoBoxComponent.cs index 125f936d8a..174d24a117 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/AmmoBoxComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/AmmoBoxComponent.cs @@ -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 { diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineComponent.cs index 51afdb4862..280628b2bb 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineComponent.cs @@ -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 { diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs index a1a5d5fab6..6c9c4996b5 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs @@ -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); } } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticWeaponComponent.cs index 670ec9b268..50bf07b847 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticWeaponComponent.cs @@ -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); diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index 811281cdb5..20fd66fcd6 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -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()); } } diff --git a/Content.Server/Placement/SpawnHelpers.cs b/Content.Server/Placement/SpawnHelpers.cs index 971d3cd6c3..e47d770aed 100644 --- a/Content.Server/Placement/SpawnHelpers.cs +++ b/Content.Server/Placement/SpawnHelpers.cs @@ -14,18 +14,14 @@ namespace Content.Server.Placement /// /// Spawns a spotlight ground turret that will track any living entities in range. /// - /// - /// - public static void SpawnLightTurret(IMapGrid grid, Vector2 localPosition) + /// + public static void SpawnLightTurret(GridCoordinates position) { var entMan = IoCManager.Resolve(); - var tBase = entMan.SpawnEntity("TurretBase"); - tBase.GetComponent().GridPosition = new GridCoordinates(localPosition, grid); + var tBase = entMan.SpawnEntity("TurretBase", position); - var tTop = entMan.SpawnEntity("TurretTopLight"); - var topTransform = tTop.GetComponent(); - topTransform.GridPosition = new GridCoordinates(localPosition, grid); - topTransform.AttachParent(tBase); + var tTop = entMan.SpawnEntity("TurretTopLight", position); + tTop.Transform.AttachParent(tBase); } } } diff --git a/RobustToolbox b/RobustToolbox index 5ff164e762..df34ce025a 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 5ff164e7628aa7f6517bb2b3c16dbb103df18220 +Subproject commit df34ce025a05a854af4eb5bf5bf64655e6697254