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:
committed by
GitHub
parent
3a4186f6f6
commit
42aaba9a5d
@@ -1,4 +1,6 @@
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Destructible.Thresholds;
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Damage;
|
||||
using JetBrains.Annotations;
|
||||
@@ -13,8 +15,12 @@ namespace Content.Server.Destructible
|
||||
public class DestructibleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] public readonly IRobustRandom Random = default!;
|
||||
[Dependency] public readonly AudioSystem AudioSystem = default!;
|
||||
public new IEntityManager EntityManager => base.EntityManager;
|
||||
|
||||
[Dependency] public readonly ActSystem ActSystem = default!;
|
||||
[Dependency] public readonly AudioSystem AudioSystem = default!;
|
||||
[Dependency] public readonly ConstructionSystem ConstructionSystem = default!;
|
||||
[Dependency] public readonly ExplosionSystem ExplosionSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Construction.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -13,12 +12,12 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
[DataField("node")]
|
||||
public string Node { get; private set; } = string.Empty;
|
||||
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Node) || !entityManager.TryGetComponent(owner, out ConstructionComponent? construction))
|
||||
if (string.IsNullOrEmpty(Node) || !system.EntityManager.TryGetComponent(owner, out ConstructionComponent? construction))
|
||||
return;
|
||||
|
||||
EntitySystem.Get<ConstructionSystem>().ChangeNode(owner, null, Node, true, construction);
|
||||
system.ConstructionSystem.ChangeNode(owner, null, Node, true, construction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
return (Acts & act) != 0;
|
||||
}
|
||||
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
if (HasAct(ThresholdActs.Breakage))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -8,13 +7,11 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
{
|
||||
[Serializable]
|
||||
[DataDefinition]
|
||||
public class DumpCanisterBehavior: IThresholdBehavior
|
||||
public class DumpCanisterBehavior : IThresholdBehavior
|
||||
{
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
var gasCanisterSystem = entityManager.EntitySysManager.GetEntitySystem<GasCanisterSystem>();
|
||||
|
||||
gasCanisterSystem.PurgeContents(owner);
|
||||
system.EntityManager.EntitySysManager.GetEntitySystem<GasCanisterSystem>().PurgeContents(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
[DataDefinition]
|
||||
public class EmptyAllContainersBehaviour : IThresholdBehavior
|
||||
{
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
if (!entityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
|
||||
if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
|
||||
return;
|
||||
|
||||
foreach (var container in containerManager.GetAllContainers())
|
||||
{
|
||||
container.EmptyContainer(true, entityManager.GetComponent<TransformComponent>(owner).Coordinates);
|
||||
container.EmptyContainer(true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Explosion;
|
||||
using Content.Server.Explosion.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -13,9 +12,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
[DataDefinition]
|
||||
public class ExplodeBehavior : IThresholdBehavior
|
||||
{
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
owner.SpawnExplosion(entityManager:entityManager);
|
||||
system.ExplosionSystem.SpawnExplosion(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
{
|
||||
[DataField("recursive")] private bool _recursive = true;
|
||||
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
if (entityManager.TryGetComponent(owner, out SharedBodyComponent? body))
|
||||
if (system.EntityManager.TryGetComponent(owner, out SharedBodyComponent? body))
|
||||
{
|
||||
body.Gib(_recursive);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
/// An instance of <see cref="DestructibleSystem"/> to pull dependencies
|
||||
/// and other systems from.
|
||||
/// </param>
|
||||
/// <param name="entityManager"></param>
|
||||
void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager);
|
||||
void Execute(EntityUid owner, DestructibleSystem system);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
/// </summary>
|
||||
[DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!;
|
||||
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
var pos = entityManager.GetComponent<TransformComponent>(owner).Coordinates;
|
||||
var pos = system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates;
|
||||
SoundSystem.Play(Filter.Pvs(pos), Sound.GetSound(), pos, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
/// <param name="owner">Entity on which behavior is executed</param>
|
||||
/// <param name="system">system calling the behavior</param>
|
||||
/// <param name="entityManager"></param>
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
|
||||
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||
{
|
||||
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
|
||||
|
||||
var coordinates = entityManager.GetComponent<TransformComponent>(owner).Coordinates;
|
||||
var coordinates = system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates;
|
||||
|
||||
if (entityManager.TryGetComponent(owner, out SpillableComponent? spillableComponent) &&
|
||||
if (system.EntityManager.TryGetComponent(owner, out SpillableComponent? spillableComponent) &&
|
||||
solutionContainerSystem.TryGetSolution(owner, spillableComponent.SolutionName,
|
||||
out var compSolution))
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Content.Server.Destructible.Thresholds
|
||||
if (!entityManager.EntityExists(owner))
|
||||
return;
|
||||
|
||||
behavior.Execute(owner, system, entityManager);
|
||||
behavior.Execute(owner, system);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user