Remove most IEntity usages from explosions (#5240)

* Remove most IEntity usages from Destructible and Explosions

* Perform a minute amount of cleanup

* Fix build
This commit is contained in:
Javier Guardia Fernández
2021-11-09 21:24:35 +01:00
committed by GitHub
parent 3a4186f6f6
commit 42aaba9a5d
28 changed files with 294 additions and 277 deletions

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using Content.Server.Stack;
using Content.Shared.Prototypes;
using Content.Shared.Random.Helpers;
using Content.Shared.Stacks;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -19,9 +18,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataField("spawn")]
public Dictionary<string, MinMax> Spawn { get; set; } = new();
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
public void Execute(EntityUid owner, DestructibleSystem system)
{
var position = entityManager.GetComponent<TransformComponent>(owner).MapPosition;
var position = system.EntityManager.GetComponent<TransformComponent>(owner).MapPosition;
foreach (var (entityId, minMax) in Spawn)
{
@@ -33,7 +32,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
if (EntityPrototypeHelpers.HasComponent<StackComponent>(entityId))
{
var spawned = entityManager.SpawnEntity(entityId, position);
var spawned = system.EntityManager.SpawnEntity(entityId, position);
var stack = spawned.GetComponent<StackComponent>();
EntitySystem.Get<StackSystem>().SetCount(spawned.Uid, count, stack);
spawned.RandomOffset(0.5f);
@@ -42,7 +41,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
{
for (var i = 0; i < count; i++)
{
var spawned = entityManager.SpawnEntity(entityId, position);
var spawned = system.EntityManager.SpawnEntity(entityId, position);
spawned.RandomOffset(0.5f);
}
}