Files
tbd-station-14/Content.Server/Anomaly/Effects/SecretDataAnomalySystem.cs
Ed a4ec01d471 Anomalies behaviours (#24683)
* Added new anomaly particle

* Add basic anomaly behaviour

* +2 parametres

* add functional to new particle

* add components to behaviours

* big content

* add shuffle, moved thing to server

* clean up

* fixes

* random pick redo

* bonjour behavioUr

* fix AJCM

* fix

* add some new behaviours

* power modifier behaviour

* rmeove timer

* new event for update ui fix

* refactor!

* fixes

* enum

* Fix mapinit

* Minor touches

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-04-01 19:29:13 +11:00

41 lines
1.2 KiB
C#

using Content.Server.Anomaly.Components;
using Robust.Shared.Random;
namespace Content.Server.Anomaly.Effects;
public sealed class SecretDataAnomalySystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
private readonly List<AnomalySecretData> _deita = new();
public override void Initialize()
{
SubscribeLocalEvent<SecretDataAnomalyComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, SecretDataAnomalyComponent anomaly, MapInitEvent args)
{
RandomizeSecret(uid,_random.Next(anomaly.RandomStartSecretMin, anomaly.RandomStartSecretMax), anomaly);
}
public void RandomizeSecret(EntityUid uid, int count, SecretDataAnomalyComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
component.Secret.Clear();
// I also considered just adding all the enum values and pruning but that seems more wasteful.
_deita.Clear();
_deita.AddRange(Enum.GetValues<AnomalySecretData>());
var actualCount = Math.Min(count, _deita.Count);
for (int i = 0; i < actualCount; i++)
{
component.Secret.Add(_random.PickAndTake(_deita));
}
}
}