Slipping tweaks + remove EffectBlocker (#4955)
* Slipping tweaks + remove EffectBlocker * mfw failed merge conflict resolution Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.EffectBlocker;
|
||||
using Content.Shared.Emoting;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory.Events;
|
||||
@@ -15,7 +14,6 @@ namespace Content.Shared.ActionBlocker
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility methods to check if a specific entity is allowed to perform an action.
|
||||
/// For effects see <see cref="EffectBlockerSystem"/>
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class ActionBlockerSystem : EntitySystem
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.EffectBlocker;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -11,7 +10,7 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Shared.Buckle.Components
|
||||
{
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedBuckleComponent : Component, IEffectBlocker, IDraggable
|
||||
public abstract class SharedBuckleComponent : Component, IDraggable
|
||||
{
|
||||
public sealed override string Name => "Buckle";
|
||||
|
||||
@@ -35,8 +34,6 @@ namespace Content.Shared.Buckle.Components
|
||||
|
||||
public abstract bool TryBuckle(IEntity? user, IEntity to);
|
||||
|
||||
bool IEffectBlocker.CanFall() => !Buckled;
|
||||
|
||||
bool IDraggable.CanDrop(CanDropEvent args)
|
||||
{
|
||||
return args.Target.HasComponent<SharedStrapComponent>();
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.EffectBlocker
|
||||
{
|
||||
public static class EffectBlockerExtensions
|
||||
{
|
||||
public static bool CanFall(this IEntity entity)
|
||||
{
|
||||
return EffectBlockerSystem.CanFall(entity);
|
||||
}
|
||||
|
||||
public static bool CanSlip(this IEntity entity)
|
||||
{
|
||||
return EffectBlockerSystem.CanSlip(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.EffectBlocker
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility methods to check if an effect is allowed to affect a specific entity.
|
||||
/// For actions see <see cref="ActionBlockerSystem"/>
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class EffectBlockerSystem : EntitySystem
|
||||
{
|
||||
// TODO: Make these methods not static. Maybe move them to their relevant EntitySystems?
|
||||
// TODO: Add EntityUid overloads.
|
||||
|
||||
public static bool CanFall(IEntity entity)
|
||||
{
|
||||
var canFall = true;
|
||||
|
||||
foreach (var blocker in entity.GetAllComponents<IEffectBlocker>())
|
||||
{
|
||||
canFall &= blocker.CanFall(); // Sets var to false if false
|
||||
}
|
||||
|
||||
return canFall;
|
||||
}
|
||||
|
||||
public static bool CanSlip(IEntity entity)
|
||||
{
|
||||
var canSlip = true;
|
||||
|
||||
foreach (var blocker in entity.GetAllComponents<IEffectBlocker>())
|
||||
{
|
||||
canSlip &= blocker.CanSlip(); // Sets var to false if false
|
||||
}
|
||||
|
||||
return canSlip;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
|
||||
namespace Content.Shared.EffectBlocker
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components the ability to block certain effects
|
||||
/// from affecting the owning entity.
|
||||
/// </summary>
|
||||
public interface IEffectBlocker
|
||||
{
|
||||
bool CanFall() => true;
|
||||
bool CanSlip() => true;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
using Content.Shared.EffectBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Slippery
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class NoSlipComponent : Component, IEffectBlocker
|
||||
public class NoSlipComponent : Component
|
||||
{
|
||||
public override string Name => "NoSlip";
|
||||
|
||||
bool IEffectBlocker.CanSlip() => false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.EffectBlocker;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Stunnable;
|
||||
using JetBrains.Annotations;
|
||||
@@ -26,6 +25,7 @@ namespace Content.Shared.Slippery
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SlipperyComponent, StartCollideEvent>(HandleCollide);
|
||||
SubscribeLocalEvent<NoSlipComponent, SlipAttemptEvent>(OnNoSlipAttempt);
|
||||
}
|
||||
|
||||
private void HandleCollide(EntityUid uid, SlipperyComponent component, StartCollideEvent args)
|
||||
@@ -40,6 +40,11 @@ namespace Content.Shared.Slippery
|
||||
component.Colliding.Add(otherUid);
|
||||
}
|
||||
|
||||
private void OnNoSlipAttempt(EntityUid uid, NoSlipComponent component, SlipAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
@@ -80,10 +85,10 @@ namespace Content.Shared.Slippery
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EffectBlockerSystem.CanSlip(otherBody.Owner))
|
||||
{
|
||||
var ev = new SlipAttemptEvent();
|
||||
RaiseLocalEvent(otherBody.Owner.Uid, ev, false);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
}
|
||||
|
||||
otherBody.LinearVelocity *= component.LaunchForwardsMultiplier;
|
||||
|
||||
@@ -136,4 +141,11 @@ namespace Content.Shared.Slippery
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised on an entity to determine if it can slip or not.
|
||||
/// </summary>
|
||||
public class SlipAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Content.Shared.Slippery
|
||||
|
||||
private float _paralyzeTime = 3f;
|
||||
private float _intersectPercentage = 0.3f;
|
||||
private float _requiredSlipSpeed = 0.1f;
|
||||
private float _requiredSlipSpeed = 5f;
|
||||
private float _launchForwardsMultiplier = 1f;
|
||||
private bool _slippery = true;
|
||||
private SoundSpecifier _slipSound = new SoundPathSpecifier("/Audio/Effects/slip.ogg");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Content.Shared.EffectBlocker;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -13,7 +12,7 @@ namespace Content.Shared.Standing
|
||||
{
|
||||
[Friend(typeof(StandingStateSystem))]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class StandingStateComponent : Component, IEffectBlocker
|
||||
public sealed class StandingStateComponent : Component
|
||||
{
|
||||
public override string Name => "StandingState";
|
||||
|
||||
@@ -25,8 +24,6 @@ namespace Content.Shared.Standing
|
||||
[DataField("standing")]
|
||||
public bool Standing { get; set; } = true;
|
||||
|
||||
public bool CanFall() => Standing;
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new StandingComponentState(Standing);
|
||||
|
||||
Reference in New Issue
Block a user