using Content.Server.GameTicking.Events; using Content.Shared.Clock; using Content.Shared.Destructible; using Robust.Server.GameStates; using Robust.Shared.Random; namespace Content.Server.Clock; public sealed class ClockSystem : SharedClockSystem { [Dependency] private readonly PvsOverrideSystem _pvsOverride = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; /// public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnRoundStart); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnBreak); } private void OnRoundStart(RoundStartingEvent ev) { var manager = Spawn(); AddComp(manager); } private void OnMapInit(Entity ent, ref MapInitEvent args) { ent.Comp.TimeOffset = TimeSpan.FromHours(_robustRandom.NextFloat(0, 24)); _pvsOverride.AddGlobalOverride(ent); Dirty(ent); } private void OnBreak(Entity ent, ref BreakageEventArgs args) { ent.Comp.StuckTime = GetClockTime(ent); Dirty(ent, ent.Comp); } }