Separated Bonk functionality and component from ClimbSystem and ClimbComponent (#13635)
This commit is contained in:
15
Content.Shared/Interaction/Components/ClumsyComponent.cs
Normal file
15
Content.Shared/Interaction/Components/ClumsyComponent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Shared.Interaction.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple clumsy tag-component.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class ClumsyComponent : Component
|
||||
{
|
||||
[DataField("clumsyDamage", required: true)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageSpecifier ClumsyDamage = default!;
|
||||
}
|
||||
}
|
||||
26
Content.Shared/Interaction/SharedInteractionSystem.Clumsy.cs
Normal file
26
Content.Shared/Interaction/SharedInteractionSystem.Clumsy.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared.Interaction
|
||||
{
|
||||
public partial class SharedInteractionSystem
|
||||
{
|
||||
public bool RollClumsy(ClumsyComponent component, float chance)
|
||||
{
|
||||
return component.Running && _random.Prob(chance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rolls a probability chance for a "bad action" if the target entity is clumsy.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity that the clumsy check is happening for.</param>
|
||||
/// <param name="chance">
|
||||
/// The chance that a "bad action" happens if the user is clumsy, between 0 and 1 inclusive.
|
||||
/// </param>
|
||||
/// <returns>True if a "bad action" happened, false if the normal action should happen.</returns>
|
||||
public bool TryRollClumsy(EntityUid entity, float chance, ClumsyComponent? component = null)
|
||||
{
|
||||
return Resolve(entity, ref component, false) && RollClumsy(component, chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -54,6 +55,7 @@ namespace Content.Shared.Interaction
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||
[Dependency] private readonly SharedPullingSystem _pullSystem = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private const CollisionGroup InRangeUnobstructedMask
|
||||
= CollisionGroup.Impassable | CollisionGroup.InteractImpassable;
|
||||
|
||||
Reference in New Issue
Block a user