RandomInstrumentArtifactSystem.cs 899 B

1234567891011121314151617181920212223
  1. using Content.Server.Instruments;
  2. using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
  3. using Content.Shared.Instruments;
  4. using Robust.Shared.Random;
  5. namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
  6. public sealed class RandomInstrumentArtifactSystem : EntitySystem
  7. {
  8. [Dependency] private readonly InstrumentSystem _instrument = default!;
  9. [Dependency] private readonly IRobustRandom _random = default!;
  10. /// <inheritdoc/>
  11. public override void Initialize()
  12. {
  13. SubscribeLocalEvent<RandomInstrumentArtifactComponent, ComponentStartup>(OnStartup);
  14. }
  15. private void OnStartup(EntityUid uid, RandomInstrumentArtifactComponent component, ComponentStartup args)
  16. {
  17. var instrument = EnsureComp<InstrumentComponent>(uid);
  18. _instrument.SetInstrumentProgram(uid, instrument, (byte) _random.Next(0, 127), 0);
  19. }
  20. }