using Content.Server.Antag.Mimic; using Content.Shared.GameTicking.Components; using Content.Shared.GameTicking.Rules; using Content.Shared.VendingMachines.Components; using Robust.Shared.Map; using Robust.Shared.Random; namespace Content.Server.Antag; /// /// Game rule handler: replaces random vending machine entities with arbitrary prototypes. /// /// /// public sealed partial class MobReplacementRuleSystem : GameRuleSystem { [Dependency] private IRobustRandom _random = default!; protected override void Started(Entity ent, ref GameRuleStartedEvent args) { base.Started(ent, ref args); var query = AllEntityQuery(); var spawns = new List<(EntityUid Entity, EntityCoordinates Coordinates)>(); while (query.MoveNext(out var vendingUid, out _, out var xform)) { if (!_random.Prob(ent.Comp1.Chance)) continue; spawns.Add((vendingUid, xform.Coordinates)); } foreach (var entity in spawns) { var coordinates = entity.Coordinates; Del(entity.Entity); Spawn(ent.Comp1.Proto, coordinates); } } }