Files
tbd-station-14/Content.Server/Stunnable/Systems/StunOnCollideSystem.cs
Princess Cheeseballs da23bc9dcc Crawling Fixes Part 4: Can't crawl when weightless. (#39099)
* Init Commit

* Typos

* Commit 2

* Save Interaction Test Mob from failing

* ssss

* Confident I've gotten all the correct prototypes

* Whoops forgot to edit those

* aaaaa

* Better solution

* Test fail fixes

* Yaml fix

* THE FINAL TEST FIX

* Final fix(?)

* whoops

* Added a WeightlessnessChangedEvent

* Check out this diff

* Wait I'm dumb

* Final optimization and don't duplicate code

* Death to IsWeightless

* Moth directed targeted attack

* A

* Bugfixes and such

* Grrr

* Death

* Cleanup

* Cleanup 2

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2025-08-19 12:18:05 -07:00

64 lines
2.1 KiB
C#

using Content.Server.Stunnable.Components;
using Content.Shared.Movement.Systems;
using JetBrains.Annotations;
using Content.Shared.Throwing;
using Robust.Shared.Physics.Events;
namespace Content.Server.Stunnable.Systems;
[UsedImplicitly]
internal sealed class StunOnCollideSystem : EntitySystem
{
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly MovementModStatusSystem _movementMod = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StunOnCollideComponent, StartCollideEvent>(HandleCollide);
SubscribeLocalEvent<StunOnCollideComponent, ThrowDoHitEvent>(HandleThrow);
}
private void TryDoCollideStun(Entity<StunOnCollideComponent> ent, EntityUid target)
{
_stunSystem.TryKnockdown(target, ent.Comp.KnockdownAmount, ent.Comp.Refresh, ent.Comp.AutoStand, ent.Comp.Drop, true);
if (ent.Comp.Refresh)
{
_stunSystem.TryUpdateStunDuration(target, ent.Comp.StunAmount);
_movementMod.TryUpdateMovementSpeedModDuration(
target,
MovementModStatusSystem.TaserSlowdown,
ent.Comp.SlowdownAmount,
ent.Comp.WalkSpeedModifier,
ent.Comp.SprintSpeedModifier
);
}
else
{
_stunSystem.TryAddStunDuration(target, ent.Comp.StunAmount);
_movementMod.TryAddMovementSpeedModDuration(
target,
MovementModStatusSystem.TaserSlowdown,
ent.Comp.SlowdownAmount,
ent.Comp.WalkSpeedModifier,
ent.Comp.SprintSpeedModifier
);
}
}
private void HandleCollide(Entity<StunOnCollideComponent> ent, ref StartCollideEvent args)
{
if (args.OurFixtureId != ent.Comp.FixtureID)
return;
TryDoCollideStun(ent, args.OtherEntity);
}
private void HandleThrow(Entity<StunOnCollideComponent> ent, ref ThrowDoHitEvent args)
{
TryDoCollideStun(ent, args.Target);
}
}