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>
This commit is contained in:
Xale 2026-10-01 18:20:10 +00:00 • committed by GitHub
parent 6a8d5454a0
commit 8efb13db22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -51,6 +51,12 @@ public sealed partial class TimedSpawnerComponent : Component, ISerializationHoo
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
public TimeSpan NextFire = TimeSpan.Zero;
/// <summary>
/// Determines whether to allow spawning entities in the spawner's container, or if they should always be outside.
/// </summary>
[DataField]
public bool AllowContainerPlacement = false;
void ISerializationHooks.AfterDeserialization()
{
if (MinimumEntitiesSpawned > MaximumEntitiesSpawned)

View file

@ -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);
}
}
}

View file

@ -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