CatStation/Content.Shared/EntityEffects/Effects/EntitySpawning/SpawnEntityEntityEffectSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

37 lines
1.2 KiB
C#

using Robust.Shared.Network;
namespace Content.Shared.EntityEffects.Effects.EntitySpawning;
/// <summary>
/// Spawns a number of entities of a given prototype at the coordinates of this entity.
/// Amount is modified by scale.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T,TEffect}"/>
public sealed partial class SpawnEntityEntityEffectSystem : EntityEffectSystem<TransformComponent, SpawnEntity>
{
[Dependency] private INetManager _net = default!;
protected override void Effect(Entity<TransformComponent> entity, ref EntityEffectEvent<SpawnEntity> args)
{
var quantity = args.Effect.Number * (int)Math.Floor(args.Scale);
var proto = args.Effect.Entity;
if (args.Effect.Predicted)
{
for (var i = 0; i < quantity; i++)
{
PredictedSpawnNextToOrDrop(proto, entity, entity.Comp);
}
}
else if (_net.IsServer)
{
for (var i = 0; i < quantity; i++)
{
SpawnNextToOrDrop(proto, entity, entity.Comp);
}
}
}
}
/// <inheritdoc cref="BaseSpawnEntityEntityEffect{T}"/>
public sealed partial class SpawnEntity : BaseSpawnEntityEntityEffect<SpawnEntity>;