changing accumulators to timespan targets (#12407)

* changing accumulators to timespan targets

* Update Content.Server/Abilities/Mime/MimePowersSystem.cs

Co-authored-by: 0x6273 <0x40@keemail.me>

* Update MimePowersSystem.cs

* serializing timespans and adding pausetime where applicable

* remove nullable

Co-authored-by: CommieFlowers <rasmus.cedergren@hotmail.com>
Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
rolfero
2022-11-08 20:59:34 +01:00
committed by GitHub
parent 3ec0202634
commit 1151ca42e5
11 changed files with 82 additions and 64 deletions

View File

@@ -1,5 +1,6 @@
using Content.Shared.Actions.ActionTypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
@@ -48,16 +49,15 @@ namespace Content.Server.Abilities.Mime
public bool ReadyToRepent = false;
/// <summary>
/// Accumulator for when the mime breaks their vows
/// Time when the mime can repent their vow
/// </summary>
[DataField("accumulator")]
public float Accumulator = 0f;
[DataField("vowRepentTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan VowRepentTime = TimeSpan.Zero;
/// <summary>
/// How long it takes the mime to get their powers back
[DataField("vowCooldown")]
[DataField("vowCooldown", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan VowCooldown = TimeSpan.FromMinutes(5);
}
}

View File

@@ -9,6 +9,7 @@ using Content.Shared.Maps;
using Content.Shared.MobState.Components;
using Robust.Shared.Player;
using Robust.Shared.Physics;
using Robust.Shared.Timing;
namespace Content.Server.Abilities.Mime
{
@@ -18,6 +19,8 @@ namespace Content.Server.Abilities.Mime
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
base.Initialize();
@@ -34,8 +37,7 @@ namespace Content.Server.Abilities.Mime
if (!mime.VowBroken || mime.ReadyToRepent)
continue;
mime.Accumulator += frameTime;
if (mime.Accumulator < mime.VowCooldown.TotalSeconds)
if (_timing.CurTime < mime.VowRepentTime)
continue;
mime.ReadyToRepent = true;
@@ -101,6 +103,7 @@ namespace Content.Server.Abilities.Mime
mimePowers.Enabled = false;
mimePowers.VowBroken = true;
mimePowers.VowRepentTime = _timing.CurTime + mimePowers.VowCooldown;
_alertsSystem.ClearAlert(uid, AlertType.VowOfSilence);
_alertsSystem.ShowAlert(uid, AlertType.VowBroken);
_actionsSystem.RemoveAction(uid, mimePowers.InvisibleWallAction);
@@ -123,7 +126,6 @@ namespace Content.Server.Abilities.Mime
mimePowers.Enabled = true;
mimePowers.ReadyToRepent = false;
mimePowers.VowBroken = false;
mimePowers.Accumulator = 0f;
_alertsSystem.ClearAlert(uid, AlertType.VowBroken);
_alertsSystem.ShowAlert(uid, AlertType.VowOfSilence);
_actionsSystem.AddAction(uid, mimePowers.InvisibleWallAction, uid);