Fix thirst errors in tests (#20481)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.IntegrationTests.Tests.Interaction;
|
using Content.IntegrationTests.Tests.Interaction;
|
||||||
|
using Content.Shared.Movement.Components;
|
||||||
using Content.Shared.Slippery;
|
using Content.Shared.Slippery;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -31,6 +32,9 @@ public sealed class SlippingTest : MovementTest
|
|||||||
var sys = SEntMan.System<SlipTestSystem>();
|
var sys = SEntMan.System<SlipTestSystem>();
|
||||||
await SpawnTarget("TrashBananaPeel");
|
await SpawnTarget("TrashBananaPeel");
|
||||||
|
|
||||||
|
var modifier = Comp<MovementSpeedModifierComponent>(Player).SprintSpeedModifier;
|
||||||
|
Assert.That(modifier, Is.EqualTo(1), "Player is not moving at full speed.");
|
||||||
|
|
||||||
// Player is to the left of the banana peel and has not slipped.
|
// Player is to the left of the banana peel and has not slipped.
|
||||||
#pragma warning disable NUnit2045
|
#pragma warning disable NUnit2045
|
||||||
Assert.That(Delta(), Is.GreaterThan(0.5f));
|
Assert.That(Delta(), Is.GreaterThan(0.5f));
|
||||||
|
|||||||
@@ -19,13 +19,10 @@ public sealed partial class ThirstComponent : Component
|
|||||||
[AutoNetworkedField]
|
[AutoNetworkedField]
|
||||||
public float ActualDecayRate;
|
public float ActualDecayRate;
|
||||||
|
|
||||||
// Thirst
|
[DataField, AutoNetworkedField]
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
|
||||||
[AutoNetworkedField]
|
|
||||||
public ThirstThreshold CurrentThirstThreshold;
|
public ThirstThreshold CurrentThirstThreshold;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[DataField, AutoNetworkedField]
|
||||||
[AutoNetworkedField]
|
|
||||||
public ThirstThreshold LastThirstThreshold;
|
public ThirstThreshold LastThirstThreshold;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
@@ -38,13 +35,13 @@ public sealed partial class ThirstComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("nextUpdateTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
|
[DataField("nextUpdateTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
|
||||||
[AutoNetworkedField]
|
[AutoNetworkedField]
|
||||||
public TimeSpan NextUpdateTime;
|
public TimeSpan NextUpdateTime = TimeSpan.MaxValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time between each update.
|
/// The time between each update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public TimeSpan UpdateRate = TimeSpan.FromSeconds(1);
|
public TimeSpan UpdateRate = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
[DataField("thresholds")]
|
[DataField("thresholds")]
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ public sealed class ThirstSystem : EntitySystem
|
|||||||
component.LastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
component.LastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
||||||
// TODO: Check all thresholds make sense and throw if they don't.
|
// TODO: Check all thresholds make sense and throw if they don't.
|
||||||
UpdateEffects(uid, component);
|
UpdateEffects(uid, component);
|
||||||
|
|
||||||
|
TryComp(uid, out MovementSpeedModifierComponent? moveMod);
|
||||||
|
_movement.RefreshMovementSpeedModifiers(uid, moveMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRefreshMovespeed(EntityUid uid, ThirstComponent component, RefreshMovementSpeedModifiersEvent args)
|
private void OnRefreshMovespeed(EntityUid uid, ThirstComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||||
@@ -179,7 +182,6 @@ public sealed class ThirstSystem : EntitySystem
|
|||||||
|
|
||||||
thirst.CurrentThirstThreshold = calculatedThirstThreshold;
|
thirst.CurrentThirstThreshold = calculatedThirstThreshold;
|
||||||
UpdateEffects(uid, thirst);
|
UpdateEffects(uid, thirst);
|
||||||
Dirty(uid, thirst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user