Reduce knocked down players tile friction (#11035)
This commit is contained in:
@@ -15,75 +15,29 @@ namespace Content.Shared.Slippery
|
||||
[NetworkedComponent]
|
||||
public sealed class SlipperyComponent : Component
|
||||
{
|
||||
private float _paralyzeTime = 3f;
|
||||
private float _launchForwardsMultiplier = 1f;
|
||||
private SoundSpecifier _slipSound = new SoundPathSpecifier("/Audio/Effects/slip.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// Path to the sound to be played when a mob slips.
|
||||
/// Path to the sound to be played when a mob slips.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("slipSound")]
|
||||
public SoundSpecifier SlipSound
|
||||
{
|
||||
get => _slipSound;
|
||||
set
|
||||
{
|
||||
if (value == _slipSound)
|
||||
return;
|
||||
|
||||
_slipSound = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
[Access(Other = AccessPermissions.ReadWriteExecute)]
|
||||
public SoundSpecifier SlipSound = new SoundPathSpecifier("/Audio/Effects/slip.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// How many seconds the mob will be paralyzed for.
|
||||
/// How many seconds the mob will be paralyzed for.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("paralyzeTime")]
|
||||
public float ParalyzeTime
|
||||
{
|
||||
get => _paralyzeTime;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(_paralyzeTime, value)) return;
|
||||
|
||||
_paralyzeTime = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
[Access(Other = AccessPermissions.ReadWrite)]
|
||||
public float ParalyzeTime = 3f;
|
||||
|
||||
/// <summary>
|
||||
/// The entity's speed will be multiplied by this to slip it forwards.
|
||||
/// The entity's speed will be multiplied by this to slip it forwards.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("launchForwardsMultiplier")]
|
||||
public float LaunchForwardsMultiplier
|
||||
{
|
||||
get => _launchForwardsMultiplier;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseToPercent(_launchForwardsMultiplier, value)) return;
|
||||
|
||||
_launchForwardsMultiplier = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new SlipperyComponentState(ParalyzeTime, LaunchForwardsMultiplier, SlipSound.GetSound());
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is not SlipperyComponentState state) return;
|
||||
|
||||
_paralyzeTime = state.ParalyzeTime;
|
||||
_launchForwardsMultiplier = state.LaunchForwardsMultiplier;
|
||||
_slipSound = new SoundPathSpecifier(state.SlipSound);
|
||||
}
|
||||
[Access(Other = AccessPermissions.ReadWrite)]
|
||||
public float LaunchForwardsMultiplier = 1f;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -5,14 +5,17 @@ using Content.Shared.StatusEffect;
|
||||
using Content.Shared.StepTrigger.Systems;
|
||||
using Content.Shared.Stunnable;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Slippery
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public abstract class SharedSlipperySystem : EntitySystem
|
||||
public sealed class SlipperySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
@@ -24,6 +27,22 @@ namespace Content.Shared.Slippery
|
||||
SubscribeLocalEvent<SlipperyComponent, StepTriggerAttemptEvent>(HandleAttemptCollide);
|
||||
SubscribeLocalEvent<SlipperyComponent, StepTriggeredEvent>(HandleStepTrigger);
|
||||
SubscribeLocalEvent<NoSlipComponent, SlipAttemptEvent>(OnNoSlipAttempt);
|
||||
SubscribeLocalEvent<SlipperyComponent, ComponentGetState>(OnSlipperyGetState);
|
||||
SubscribeLocalEvent<SlipperyComponent, ComponentHandleState>(OnSlipperyHandleState);
|
||||
}
|
||||
|
||||
private void OnSlipperyHandleState(EntityUid uid, SlipperyComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not SlipperyComponentState state) return;
|
||||
|
||||
component.ParalyzeTime = state.ParalyzeTime;
|
||||
component.LaunchForwardsMultiplier = state.LaunchForwardsMultiplier;
|
||||
component.SlipSound = new SoundPathSpecifier(state.SlipSound);
|
||||
}
|
||||
|
||||
private void OnSlipperyGetState(EntityUid uid, SlipperyComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new SlipperyComponentState(component.ParalyzeTime, component.LaunchForwardsMultiplier, component.SlipSound.GetSound());
|
||||
}
|
||||
|
||||
private void HandleStepTrigger(EntityUid uid, SlipperyComponent component, ref StepTriggeredEvent args)
|
||||
@@ -69,14 +88,13 @@ namespace Content.Shared.Slippery
|
||||
|
||||
// Preventing from playing the slip sound when you are already knocked down.
|
||||
if (playSound)
|
||||
PlaySound(component);
|
||||
{
|
||||
_audio.PlayPredicted(component.SlipSound, other, other);
|
||||
}
|
||||
|
||||
_adminLogger.Add(LogType.Slip, LogImpact.Low,
|
||||
$"{ToPrettyString(other):mob} slipped on collision with {ToPrettyString(component.Owner):entity}");
|
||||
}
|
||||
|
||||
// Until we get predicted slip sounds TM?
|
||||
protected abstract void PlaySound(SlipperyComponent component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
Reference in New Issue
Block a user