Skip to content

Commit

Permalink
Added delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornado-Technology committed Dec 30, 2024
1 parent fbb3a06 commit 323746b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Content.Server/_CorvaxNext/AutoCryoSleep/AutoCryoSleepSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public sealed class AutoCryoSleepSystem : EntitySystem

private bool _enabled;
private TimeSpan _disconnectedTime;
private TimeSpan _updateTime;

private TimeSpan _nextUpdate = TimeSpan.Zero;

public override void Initialize()
{
Expand All @@ -33,14 +36,20 @@ public override void Initialize()

Subs.CVar(_config, NextVars.AutoCryoSleepEnabled, value => _enabled = value, true);
Subs.CVar(_config, NextVars.AutoCryoSleepTime, value => _disconnectedTime = TimeSpan.FromSeconds(value), true);
Subs.CVar(_config, NextVars.AutoCryoSleepUpdateTime, value => _updateTime = TimeSpan.FromSeconds(value), true);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

if (!_enabled)
return;

base.Update(frameTime);
if (_timing.CurTime < _nextUpdate)
return;

_nextUpdate = _timing.CurTime + _updateTime;

var disconnectedQuery = EntityQueryEnumerator<AutoCryoSleepComponent>();
while (disconnectedQuery.MoveNext(out var uid, out var component))
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/_CorvaxNext/NextVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public sealed class NextVars
public static readonly CVarDef<int> AutoCryoSleepTime =
CVarDef.Create("auto_cryo_sleep.time", 500, CVar.SERVER);

public static readonly CVarDef<int> AutoCryoSleepUpdateTime =
CVarDef.Create("auto_cryo_sleep.update_time", 120, CVar.SERVER);

/// <summary>
/// Offer item.
/// </summary>
Expand Down

0 comments on commit 323746b

Please sign in to comment.