Port boxer from Nyano (#9080)
This commit is contained in:
23
Content.Server/Abilities/Boxer/Boxer/BoxerComponent.cs
Normal file
23
Content.Server/Abilities/Boxer/Boxer/BoxerComponent.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.Abilities.Boxer
|
||||
{
|
||||
/// <summary>
|
||||
/// Added to the boxer on spawn.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class BoxerComponent : Component
|
||||
{
|
||||
[DataField("modifiers", required: true)]
|
||||
public DamageModifierSet UnarmedModifiers = default!;
|
||||
|
||||
[DataField("rangeBonus")]
|
||||
public float RangeBonus = 1.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Damage modifier with boxing glove stam damage.
|
||||
/// </summary>
|
||||
[DataField("boxingGlovesModifier")]
|
||||
public float BoxingGlovesModifier = 1.75f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.Abilities.Boxer
|
||||
{
|
||||
/// <summary>
|
||||
/// Boxer gets a bonus for these, and their fists, but not other unarmed weapons.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class BoxingGlovesComponent : Component
|
||||
{}
|
||||
}
|
||||
51
Content.Server/Abilities/Boxer/BoxingSystem.cs
Normal file
51
Content.Server/Abilities/Boxer/BoxingSystem.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Content.Server.Weapon.Melee;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Server.Weapon.Melee.Components;
|
||||
using Content.Server.Clothing.Components;
|
||||
using Content.Server.Damage.Components;
|
||||
using Content.Server.Damage.Events;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Abilities.Boxer
|
||||
{
|
||||
public sealed class BoxingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<BoxerComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<BoxerComponent, MeleeHitEvent>(ApplyBoxerModifiers);
|
||||
SubscribeLocalEvent<BoxingGlovesComponent, StaminaMeleeHitEvent>(OnStamHit);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, BoxerComponent boxer, ComponentInit args)
|
||||
{
|
||||
if (TryComp<MeleeWeaponComponent>(uid, out var meleeComp))
|
||||
meleeComp.Range *= boxer.RangeBonus;
|
||||
}
|
||||
private void ApplyBoxerModifiers(EntityUid uid, BoxerComponent component, MeleeHitEvent args)
|
||||
{
|
||||
if (component.UnarmedModifiers == default!)
|
||||
{
|
||||
Logger.Warning("BoxerComponent on " + uid + " couldn't get damage modifiers. Know that adding components with damage modifiers through VV or similar is unsupported.");
|
||||
return;
|
||||
}
|
||||
|
||||
args.ModifiersList.Add(component.UnarmedModifiers);
|
||||
}
|
||||
private void OnStamHit(EntityUid uid, BoxingGlovesComponent component, StaminaMeleeHitEvent args)
|
||||
{
|
||||
_containerSystem.TryGetContainingContainer(uid, out var equipee);
|
||||
if (TryComp<BoxerComponent>(equipee?.Owner, out var boxer))
|
||||
args.Multiplier *= boxer.BoxingGlovesModifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user