Small strange jackboots buff (#30586)
* Small strange jackboots buff * Update ClothingSlowOnDamageModifierComponent.cs
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Damage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for a clothing item that modifies the slowdown from taking damage.
|
||||
/// Used for entities with <see cref="SlowOnDamageComponent"/>
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SlowOnDamageSystem))]
|
||||
public sealed partial class ClothingSlowOnDamageModifierComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// A coefficient modifier for the slowdown
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float Modifier = 1;
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Movement.Systems;
|
||||
|
||||
namespace Content.Shared.Damage
|
||||
@@ -14,6 +17,11 @@ namespace Content.Shared.Damage
|
||||
|
||||
SubscribeLocalEvent<SlowOnDamageComponent, DamageChangedEvent>(OnDamageChanged);
|
||||
SubscribeLocalEvent<SlowOnDamageComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
||||
|
||||
SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, InventoryRelayedEvent<ModifySlowOnDamageSpeedEvent>>(OnModifySpeed);
|
||||
SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ClothingGotEquippedEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
|
||||
}
|
||||
|
||||
private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||
@@ -36,7 +44,10 @@ namespace Content.Shared.Damage
|
||||
if (closest != FixedPoint2.Zero)
|
||||
{
|
||||
var speed = component.SpeedModifierThresholds[closest];
|
||||
args.ModifySpeed(speed, speed);
|
||||
|
||||
var ev = new ModifySlowOnDamageSpeedEvent(speed);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
args.ModifySpeed(ev.Speed, ev.Speed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,5 +58,37 @@ namespace Content.Shared.Damage
|
||||
|
||||
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid);
|
||||
}
|
||||
|
||||
private void OnModifySpeed(Entity<ClothingSlowOnDamageModifierComponent> ent, ref InventoryRelayedEvent<ModifySlowOnDamageSpeedEvent> args)
|
||||
{
|
||||
var dif = 1 - args.Args.Speed;
|
||||
if (dif <= 0)
|
||||
return;
|
||||
|
||||
// reduces the slowness modifier by the given coefficient
|
||||
args.Args.Speed += dif * ent.Comp.Modifier;
|
||||
}
|
||||
|
||||
private void OnExamined(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ExaminedEvent args)
|
||||
{
|
||||
var msg = Loc.GetString("slow-on-damage-modifier-examine", ("mod", (1 - ent.Comp.Modifier) * 100));
|
||||
args.PushMarkup(msg);
|
||||
}
|
||||
|
||||
private void OnGotEquipped(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ClothingGotEquippedEvent args)
|
||||
{
|
||||
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
|
||||
}
|
||||
|
||||
private void OnGotUnequipped(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ClothingGotUnequippedEvent args)
|
||||
{
|
||||
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public record struct ModifySlowOnDamageSpeedEvent(float Speed) : IInventoryRelayEvent
|
||||
{
|
||||
public SlotFlags TargetSlots => SlotFlags.WITHOUT_POCKET;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public partial class InventorySystem
|
||||
// by-ref events
|
||||
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, IsWeightlessEvent>(RefRelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, ModifySlowOnDamageSpeedEvent>(RefRelayInventoryEvent);
|
||||
|
||||
// Eye/vision events
|
||||
SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
melee-stamina = Not enough stamina
|
||||
slow-on-damage-modifier-examine = Slowness from injuries is reduced by [color=yellow]{$mod}%[/color]
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
sprite: Clothing/Shoes/Boots/jackboots.rsi
|
||||
- type: Clothing
|
||||
sprite: Clothing/Shoes/Boots/jackboots.rsi
|
||||
- type: ClothingSlowOnDamageModifier
|
||||
modifier: 0.5
|
||||
|
||||
- type: entity
|
||||
parent: ClothingShoesBaseButcherable
|
||||
|
||||
@@ -993,7 +993,6 @@
|
||||
id: SecurityShoes
|
||||
name: loadout-group-security-shoes
|
||||
loadouts:
|
||||
- CombatBoots
|
||||
- JackBoots
|
||||
- SecurityWinterBoots
|
||||
|
||||
|
||||
Reference in New Issue
Block a user