diff --git a/Content.Server/Destructible/DestructibleSystem.cs b/Content.Server/Destructible/DestructibleSystem.cs index e67c405d2b..ed4c91775f 100644 --- a/Content.Server/Destructible/DestructibleSystem.cs +++ b/Content.Server/Destructible/DestructibleSystem.cs @@ -1,12 +1,12 @@ using Content.Server.Construction; using Content.Server.Destructible.Thresholds; using Content.Server.Explosion.EntitySystems; +using Content.Server.Stack; using Content.Shared.Acts; using Content.Shared.Damage; using JetBrains.Annotations; using Robust.Server.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; +using Robust.Shared.Prototypes; using Robust.Shared.Random; namespace Content.Server.Destructible @@ -21,6 +21,9 @@ namespace Content.Server.Destructible [Dependency] public readonly AudioSystem AudioSystem = default!; [Dependency] public readonly ConstructionSystem ConstructionSystem = default!; [Dependency] public readonly ExplosionSystem ExplosionSystem = default!; + [Dependency] public readonly StackSystem StackSystem = default!; + [Dependency] public readonly IPrototypeManager PrototypeManager = default!; + [Dependency] public readonly IComponentFactory ComponentFactory = default!; public override void Initialize() { diff --git a/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs index df0a295536..82cacfce3d 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; using Content.Server.Stack; using Content.Shared.Prototypes; -using Content.Shared.Random.Helpers; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Destructible.Thresholds.Behaviors { @@ -26,6 +20,8 @@ namespace Content.Server.Destructible.Thresholds.Behaviors { var position = system.EntityManager.GetComponent(owner).MapPosition; + var getRandomVector = () => new Vector2(system.Random.NextFloat(-Offset, Offset), system.Random.NextFloat(-Offset, Offset)); + foreach (var (entityId, minMax) in Spawn) { var count = minMax.Min >= minMax.Max @@ -34,19 +30,16 @@ namespace Content.Server.Destructible.Thresholds.Behaviors if (count == 0) continue; - if (EntityPrototypeHelpers.HasComponent(entityId)) + if (EntityPrototypeHelpers.HasComponent(entityId, system.PrototypeManager, system.ComponentFactory)) { - var spawned = system.EntityManager.SpawnEntity(entityId, position); - var stack = IoCManager.Resolve().GetComponent(spawned); - EntitySystem.Get().SetCount(spawned, count, stack); - spawned.RandomOffset(Offset); + var spawned = system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector())); + system.StackSystem.SetCount(spawned, count); } else { for (var i = 0; i < count; i++) { - var spawned = system.EntityManager.SpawnEntity(entityId, position); - spawned.RandomOffset(Offset); + system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector())); } } } diff --git a/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml b/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml index bc375d0fc8..3c137e1bce 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml @@ -59,6 +59,12 @@ damageModifierSet: Metallic - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: #excess damage (nuke?). avoid computational cost of spawning entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 15 @@ -89,6 +95,12 @@ sprite: Structures/Furniture/Tables/reinforced.rsi - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 200 + behaviors: #excess damage (nuke?). avoid computational cost of spawning entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 75 @@ -165,6 +177,12 @@ Blunt: 40 - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: #excess damage (nuke?). avoid computational cost of spawning entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 20 @@ -207,6 +225,12 @@ Blunt: 100 - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 200 + behaviors: #excess damage (nuke?). avoid computational cost of spawning entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 50 @@ -244,6 +268,12 @@ damageModifierSet: Wood - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: #excess damage (nuke?). avoid computational cost of spawning entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 15 diff --git a/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml b/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml index b05773226d..94e6e70e6e 100644 --- a/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml +++ b/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml @@ -35,6 +35,12 @@ - MobImpassable - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 300 + behaviors: #excess damage (nuke?). avoid computational cost of spawning entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 100 diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml index 7ad9789d7e..1b1a5289d7 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml @@ -45,6 +45,12 @@ damageModifierSet: Metallic - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 200 + behaviors: #excess damage, don't spawn entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 50 @@ -198,6 +204,12 @@ damageContainer: Inorganic - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: #excess damage, don't spawn entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 25 diff --git a/Resources/Prototypes/Entities/Structures/Walls/girder.yml b/Resources/Prototypes/Entities/Structures/Walls/girder.yml index 96e5823364..d4433cc925 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/girder.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/girder.yml @@ -33,6 +33,12 @@ damageModifierSet: Metallic - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 200 + behaviors: #excess damage, don't spawn entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 50 diff --git a/Resources/Prototypes/Entities/Structures/Windows/rplasma.yml b/Resources/Prototypes/Entities/Structures/Windows/rplasma.yml index 04334807ed..b848c99e99 100644 --- a/Resources/Prototypes/Entities/Structures/Windows/rplasma.yml +++ b/Resources/Prototypes/Entities/Structures/Windows/rplasma.yml @@ -13,6 +13,12 @@ damageModifierSet: Glass - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 1000 + behaviors: #excess damage, don't spawn entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 600 @@ -66,6 +72,12 @@ node: plasmaReinforcedWindowDirectional - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 1000 + behaviors: #excess damage, don't spawn entities. + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 600 diff --git a/Resources/Prototypes/Entities/Structures/Windows/window.yml b/Resources/Prototypes/Entities/Structures/Windows/window.yml index 84c75e9990..2f44af65b2 100644 --- a/Resources/Prototypes/Entities/Structures/Windows/window.yml +++ b/Resources/Prototypes/Entities/Structures/Windows/window.yml @@ -131,6 +131,12 @@ messages: WindowMessages - type: Destructible thresholds: + - trigger: + !type:DamageTrigger + damage: 150 #excess damage (nuke?). avoid computational cost of spawning entities. + behaviors: + - !type:DoActsBehavior + acts: [ "Destruction" ] - trigger: !type:DamageTrigger damage: 50