From 8efb13db225ed3ef264b2da18453ac1d33da6207 Mon Sep 17 00:00:00 2001 From: Xale <73114897+XaleMCY@users.noreply.github.com> Date: Thu, 1 Oct 2026 18:20:10 +0000 Subject: [PATCH] TimedSpawner can spawn objects in containers (#46212) * TimedSpawner can spawn objects in containers * Hatch ducks and chickens into containers * Update Content.Server/Spawners/EntitySystems/SpawnerSystem.cs --------- Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> --- Content.Server/Spawners/Components/TimedSpawnerComponent.cs | 6 ++++++ Content.Server/Spawners/EntitySystems/SpawnerSystem.cs | 5 ++++- Resources/Prototypes/Entities/Mobs/NPCs/animals.yml | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Content.Server/Spawners/Components/TimedSpawnerComponent.cs b/Content.Server/Spawners/Components/TimedSpawnerComponent.cs index a96060f74b..9b7d14bedd 100644 --- a/Content.Server/Spawners/Components/TimedSpawnerComponent.cs +++ b/Content.Server/Spawners/Components/TimedSpawnerComponent.cs @@ -51,6 +51,12 @@ public sealed partial class TimedSpawnerComponent : Component, ISerializationHoo [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] public TimeSpan NextFire = TimeSpan.Zero; + /// + /// Determines whether to allow spawning entities in the spawner's container, or if they should always be outside. + /// + [DataField] + public bool AllowContainerPlacement = false; + void ISerializationHooks.AfterDeserialization() { if (MinimumEntitiesSpawned > MaximumEntitiesSpawned) diff --git a/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs b/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs index bcbfdb626e..710672f17c 100644 --- a/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs +++ b/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs @@ -49,7 +49,10 @@ public sealed partial class SpawnerSystem : EntitySystem for (var i = 0; i < number; i++) { var entity = _random.Pick(component.Prototypes); - SpawnAtPosition(entity, coordinates); + if (component.AllowContainerPlacement) + SpawnNextToOrDrop(entity, uid); + else + SpawnAtPosition(entity, coordinates); } } } diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index b5c777fcb6..db09880ffa 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -357,6 +357,7 @@ - MobChicken1 - MobChicken2 intervalSeconds: 20 + allowContainerPlacement: true - type: TimedDespawn #delete the egg after the chicken spawns lifetime: 21 @@ -813,6 +814,7 @@ - MobDuckWhite - MobDuckBrown intervalSeconds: 20 + allowContainerPlacement: true - type: TimedDespawn #delete the egg after the chicken spawns lifetime: 21