-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from WWhiteDreamProject/knockdown
[Port/Feature] Knockdown / Сбитие С Ног
- Loading branch information
Showing
40 changed files
with
440 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
Content.Server/Stunnable/Components/KnockdownOnHitComponent.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Content.Server/_White/Flash/FlashSoundSuppressionComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Content.Server._White.Flash; | ||
|
||
[RegisterComponent] | ||
public sealed partial class FlashSoundSuppressionComponent : Component | ||
{ | ||
[DataField] | ||
public float MaxRange = 2f; | ||
} |
19 changes: 19 additions & 0 deletions
19
Content.Server/_White/Flash/FlashSoundSuppressionSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Content.Shared.Flash; | ||
using Content.Shared.Inventory; | ||
|
||
namespace Content.Server._White.Flash; | ||
|
||
public sealed class FlashSoundSuppressionSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<FlashSoundSuppressionComponent, InventoryRelayedEvent<FlashbangedEvent>>(OnFlashbanged); | ||
} | ||
|
||
private void OnFlashbanged(Entity<FlashSoundSuppressionComponent> ent, ref InventoryRelayedEvent<FlashbangedEvent> args) | ||
{ | ||
args.Args.MaxRange = MathF.Min(args.Args.MaxRange, ent.Comp.MaxRange); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Content.Server/_White/Knockdown/BaseKnockdownOnComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Content.Shared.Standing; | ||
|
||
|
||
namespace Content.Server._White.Knockdown; | ||
|
||
public abstract partial class BaseKnockdownOnComponent : Component | ||
{ | ||
[DataField] | ||
public TimeSpan Delay = TimeSpan.FromSeconds(2); | ||
|
||
[DataField] | ||
public TimeSpan KnockdownTime = TimeSpan.FromSeconds(5); | ||
|
||
[DataField] | ||
public DropHeldItemsBehavior DropHeldItemsBehavior = DropHeldItemsBehavior.DropIfStanding; | ||
|
||
[DataField] | ||
public TimeSpan JitterTime = TimeSpan.FromSeconds(15); | ||
|
||
[DataField] | ||
public TimeSpan StutterTime = TimeSpan.FromSeconds(15); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Content.Shared.Standing; | ||
|
||
|
||
namespace Content.Server._White.Knockdown; | ||
|
||
[RegisterComponent] | ||
public sealed partial class KnockComponent : Component | ||
{ | ||
[DataField] | ||
public TimeSpan Delay = TimeSpan.FromSeconds(2); | ||
|
||
[DataField] | ||
public TimeSpan KnockdownTime = TimeSpan.FromSeconds(5); | ||
|
||
[DataField] | ||
public DropHeldItemsBehavior DropHeldItemsBehavior = DropHeldItemsBehavior.DropIfStanding; | ||
} |
4 changes: 4 additions & 0 deletions
4
Content.Server/_White/Knockdown/KnockdownOnCollideComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Content.Server._White.Knockdown; | ||
|
||
[RegisterComponent] | ||
public sealed partial class KnockdownOnCollideComponent : BaseKnockdownOnComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Content.Server._White.Knockdown; | ||
|
||
[RegisterComponent] | ||
public sealed partial class KnockdownOnHitComponent : BaseKnockdownOnComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Content.Server.Jittering; | ||
using Content.Server.Speech.EntitySystems; | ||
using Content.Server.Stunnable; | ||
using Content.Shared.Projectiles; | ||
using Content.Shared.StatusEffect; | ||
using Content.Shared.Stunnable.Events; | ||
using Content.Shared.Throwing; | ||
using Content.Shared.Weapons.Melee.Events; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server._White.Knockdown; | ||
|
||
public sealed class KnockdownSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly StunSystem _sharedStun = default!; | ||
[Dependency] private readonly JitteringSystem _jitter = default!; | ||
[Dependency] private readonly StutteringSystem _stutter = default!; | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<KnockdownOnHitComponent, MeleeHitEvent>(OnMeleeHit); | ||
SubscribeLocalEvent<KnockdownOnCollideComponent, ProjectileHitEvent>(OnProjectileHit); | ||
SubscribeLocalEvent<KnockdownOnCollideComponent, ThrowDoHitEvent>(OnThrowDoHit); | ||
} | ||
|
||
private void OnMeleeHit(EntityUid uid, KnockdownOnHitComponent component, MeleeHitEvent args) | ||
{ | ||
var ev = new KnockdownOnHitAttemptEvent(); | ||
RaiseLocalEvent(uid, ref ev); | ||
if (ev.Cancelled) | ||
return; | ||
|
||
foreach (var hitEntity in args.HitEntities) | ||
Knockdown(hitEntity, component); | ||
} | ||
|
||
private void OnProjectileHit(EntityUid uid, KnockdownOnCollideComponent component, ProjectileHitEvent args) => Knockdown(args.Target, component); | ||
|
||
private void OnThrowDoHit(EntityUid uid, KnockdownOnCollideComponent component, ThrowDoHitEvent args) => Knockdown(args.Target, component); | ||
|
||
private void Knockdown(EntityUid target, BaseKnockdownOnComponent component) | ||
{ | ||
if (!TryComp<StatusEffectsComponent>(target, out var statusEffects)) | ||
return; | ||
|
||
if (component.JitterTime > TimeSpan.Zero) | ||
_jitter.DoJitter(target, component.JitterTime, true, status: statusEffects); | ||
|
||
if (component.StutterTime > TimeSpan.Zero) | ||
_stutter.DoStutter(target, component.StutterTime, true, statusEffects); | ||
|
||
if (component.Delay == TimeSpan.Zero) | ||
{ | ||
_sharedStun.TryKnockdown(target, component.KnockdownTime, true, statusEffects); | ||
return; | ||
} | ||
|
||
var knockdown = EnsureComp<KnockComponent>(target); | ||
knockdown.Delay = _timing.CurTime + component.Delay; | ||
knockdown.KnockdownTime = component.KnockdownTime; | ||
knockdown.DropHeldItemsBehavior = component.DropHeldItemsBehavior; | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
var query = EntityQueryEnumerator<KnockComponent>(); | ||
while (query.MoveNext(out var uid, out var delayedKnockdown)) | ||
{ | ||
if (delayedKnockdown.Delay > _timing.CurTime) | ||
continue; | ||
|
||
_sharedStun.TryKnockdown(uid, delayedKnockdown.KnockdownTime, true, delayedKnockdown.DropHeldItemsBehavior); | ||
RemCompDeferred<KnockComponent>(uid); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.