Files
ss14-wl/Content.Server/DeviceLinking/Systems/RandomGateSystem.cs
T
Pieter-Jan BriersandGitHub 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

33 lines
1023 B
C#

using Content.Shared.DeviceLinking.Components;
using Content.Shared.DeviceLinking.Events;
using Content.Shared.DeviceLinking.Systems;
using Robust.Shared.Random;
namespace Content.Server.DeviceLinking.Systems;
public sealed partial class RandomGateSystem : SharedRandomGateSystem
{
[Dependency] private DeviceLinkSystem _deviceLink = default!;
[Dependency] private IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RandomGateComponent, SignalReceivedEvent>(OnSignalReceived);
}
private void OnSignalReceived(Entity<RandomGateComponent> ent, ref SignalReceivedEvent args)
{
if (args.Port != ent.Comp.InputPort)
return;
var output = _random.Prob(ent.Comp.SuccessProbability);
if (output != ent.Comp.LastOutput)
{
ent.Comp.LastOutput = output;
Dirty(ent);
_deviceLink.SendSignal(ent.Owner, ent.Comp.OutputPort, output);
}
}
}