Cleanup mimic event (#23705)
* Cleanup mimic event Now it won't be forced on dev map or mapping mode. * Minor cleanup
This commit is contained in:
21
Content.Server/Antag/Mimic/MobReplacementRuleComponent.cs
Normal file
21
Content.Server/Antag/Mimic/MobReplacementRuleComponent.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Server.Antag.Mimic;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces the relevant entities with mobs when the game rule is started.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed partial class MobReplacementRuleComponent : Component
|
||||||
|
{
|
||||||
|
// If you want more components use generics, using a whitelist would probably kill the server iterating every single entity.
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public EntProtoId Proto = "MobMimic";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chance per-entity.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public float Chance = 0.001f;
|
||||||
|
}
|
||||||
37
Content.Server/Antag/MobReplacementRuleSystem.cs
Normal file
37
Content.Server/Antag/MobReplacementRuleSystem.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using Content.Server.Antag.Mimic;
|
||||||
|
using Content.Server.GameTicking.Rules;
|
||||||
|
using Content.Server.GameTicking.Rules.Components;
|
||||||
|
using Content.Shared.VendingMachines;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.Antag;
|
||||||
|
|
||||||
|
public sealed class MobReplacementRuleSystem : GameRuleSystem<MobReplacementRuleComponent>
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
|
||||||
|
protected override void Started(EntityUid uid, MobReplacementRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
||||||
|
{
|
||||||
|
base.Started(uid, component, gameRule, args);
|
||||||
|
|
||||||
|
var query = AllEntityQuery<VendingMachineComponent, TransformComponent>();
|
||||||
|
var spawns = new List<(EntityUid Entity, EntityCoordinates Coordinates)>();
|
||||||
|
|
||||||
|
while (query.MoveNext(out var vendingUid, out _, out var xform))
|
||||||
|
{
|
||||||
|
if (!_random.Prob(component.Chance))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
spawns.Add((vendingUid, xform.Coordinates));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var entity in spawns)
|
||||||
|
{
|
||||||
|
var coordinates = entity.Coordinates;
|
||||||
|
Del(entity.Entity);
|
||||||
|
|
||||||
|
Spawn(component.Proto, coordinates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,3 @@
|
|||||||
- VendingMachineStarkist
|
- VendingMachineStarkist
|
||||||
- VendingMachineSpaceUp
|
- VendingMachineSpaceUp
|
||||||
chance: 1
|
chance: 1
|
||||||
rarePrototypes:
|
|
||||||
- MobMimic
|
|
||||||
rareChance: 0.001
|
|
||||||
|
|||||||
@@ -23,6 +23,3 @@
|
|||||||
- VendingMachineStarkist
|
- VendingMachineStarkist
|
||||||
- VendingMachineSpaceUp
|
- VendingMachineSpaceUp
|
||||||
chance: 1
|
chance: 1
|
||||||
rarePrototypes:
|
|
||||||
- MobMimic
|
|
||||||
rareChance: 0.001
|
|
||||||
|
|||||||
@@ -20,6 +20,3 @@
|
|||||||
- VendingMachineChang
|
- VendingMachineChang
|
||||||
- VendingMachineDonut
|
- VendingMachineDonut
|
||||||
chance: 1
|
chance: 1
|
||||||
rarePrototypes:
|
|
||||||
- MobMimic
|
|
||||||
rareChance: 0.001
|
|
||||||
|
|||||||
@@ -441,3 +441,14 @@
|
|||||||
reoccurrenceDelay: 60
|
reoccurrenceDelay: 60
|
||||||
duration: 1
|
duration: 1
|
||||||
- type: IonStormRule
|
- type: IonStormRule
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
id: MimicVendorRule
|
||||||
|
parent: BaseGameRule
|
||||||
|
noSpawn: true
|
||||||
|
components:
|
||||||
|
- type: StationEvent
|
||||||
|
earliestStart: 0
|
||||||
|
minimumPlayers: 20
|
||||||
|
weight: 5
|
||||||
|
- type: MobReplacementRule
|
||||||
|
|||||||
Reference in New Issue
Block a user