* data initalizing * modular assembling * grips and blades sprites * first prototypes * jewerly decoration * disassemble modular weapon * grip start stats * blade modifiers * inhand sprites generation * resprites inhand, add sickle, add attempt modify size * auto inhand sprite parsing * icon default parsing * spear blade * mace ball * sword blade * sharedization + autonetwork hotswipe * wielding sprite support! * iron long grip * wielded sickle, fix ERROR sprite if state not added * Update grips.yml * wielded spear + ruby rework * wielding damage bonus modifier * modular size fix * fix storedOffset rotation * parts offset * fix inheriting modifiers * some bugfix and balance tweaks * DPS Meter * fix dividing by zero * rebalance * replace baseknife to modular knife. Delete ice knife spell * sickle and mace modular replace * modular spear & sword replacement. add wielded icons * Update CP14DPSMeterSystem.cs * back to serverization * grip disassemble drop again * clothing sprite generation code * back slot long grips and mace * remove jewerly slot, add more clothing states * finish clothing states * shovel modular * YEEEEE * anvil modular craft * bugfixes * more integration check fixes
64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
using Content.Shared._CP14.MeleeWeapon.Components;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Throwing;
|
|
using Content.Shared.Weapons.Melee.Events;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared._CP14.MeleeWeapon.EntitySystems;
|
|
|
|
public sealed class CP14MeleeParrySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<CP14MeleeParryComponent, MeleeHitEvent>(OnMeleeHit);
|
|
SubscribeLocalEvent<CP14MeleeParriableComponent, AttemptMeleeEvent>(OnMeleeParriableHitAttempt);
|
|
}
|
|
|
|
private void OnMeleeParriableHitAttempt(Entity<CP14MeleeParriableComponent> ent, ref AttemptMeleeEvent args)
|
|
{
|
|
ent.Comp.LastMeleeHit = _timing.CurTime;
|
|
}
|
|
|
|
private void OnMeleeHit(Entity<CP14MeleeParryComponent> ent, ref MeleeHitEvent args)
|
|
{
|
|
if (args.HitEntities.Count != 1)
|
|
return;
|
|
|
|
var target = args.HitEntities[0];
|
|
|
|
var activeTargetHand = _hands.GetActiveHand(target);
|
|
|
|
if (activeTargetHand?.HeldEntity is null)
|
|
return;
|
|
|
|
var parriedWeapon = activeTargetHand.HeldEntity.Value;
|
|
|
|
if (!TryComp<CP14MeleeParriableComponent>(parriedWeapon, out var meleeParriable))
|
|
return;
|
|
|
|
if (ent.Comp.ParryPower < meleeParriable.NeedParryPower)
|
|
return;
|
|
|
|
if (_timing.CurTime > meleeParriable.LastMeleeHit + ent.Comp.ParryWindow)
|
|
return;
|
|
|
|
_hands.TryDrop(target, parriedWeapon);
|
|
_throwing.TryThrow(parriedWeapon, _random.NextAngle().ToWorldVec(), ent.Comp.ParryPower, target);
|
|
_popup.PopupEntity( Loc.GetString("cp14-successful-parry"), args.User, args.User);
|
|
_popup.PopupEntity( Loc.GetString("cp14-successful-parry"), args.HitEntities[0], args.HitEntities[0]);
|
|
_audio.PlayPvs(meleeParriable.ParrySound, parriedWeapon);
|
|
}
|
|
}
|