Refactors stunnable to be ECS. (#4819)
Also cleans up StandingStatesystem.
This commit is contained in:
committed by
GitHub
parent
19a588a70a
commit
6eee256b11
@@ -1,6 +1,14 @@
|
||||
using System;
|
||||
using Content.Server.Alert;
|
||||
using Content.Server.Stunnable.Components;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Standing;
|
||||
using Content.Shared.Stunnable;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.Server.Stunnable
|
||||
@@ -8,6 +16,8 @@ namespace Content.Server.Stunnable
|
||||
[UsedImplicitly]
|
||||
internal sealed class StunOnCollideSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -16,11 +26,25 @@ namespace Content.Server.Stunnable
|
||||
|
||||
private void HandleCollide(EntityUid uid, StunOnCollideComponent component, StartCollideEvent args)
|
||||
{
|
||||
if (args.OtherFixture.Body.Owner.TryGetComponent(out StunnableComponent? stunnableComponent))
|
||||
var otherUid = args.OtherFixture.Body.Owner.Uid;
|
||||
|
||||
if (EntityManager.TryGetComponent(otherUid, out StunnableComponent? stunnableComponent))
|
||||
{
|
||||
stunnableComponent.Stun(component.StunAmount);
|
||||
stunnableComponent.Knockdown(component.KnockdownAmount);
|
||||
stunnableComponent.Slowdown(component.SlowdownAmount);
|
||||
ServerAlertsComponent? alerts = null;
|
||||
StandingStateComponent? standingState = null;
|
||||
AppearanceComponent? appearance = null;
|
||||
MovementSpeedModifierComponent? speedModifier = null;
|
||||
|
||||
// Let the actual methods log errors for these.
|
||||
Resolve(otherUid, ref alerts, ref standingState, ref appearance, ref speedModifier, false);
|
||||
|
||||
_stunSystem.Stun(otherUid, TimeSpan.FromSeconds(component.StunAmount), stunnableComponent, alerts);
|
||||
|
||||
_stunSystem.Knockdown(otherUid, TimeSpan.FromSeconds(component.KnockdownAmount), stunnableComponent,
|
||||
alerts, standingState, appearance);
|
||||
|
||||
_stunSystem.Slowdown(otherUid, TimeSpan.FromSeconds(component.SlowdownAmount),
|
||||
component.WalkSpeedMultiplier, component.RunSpeedMultiplier, stunnableComponent, speedModifier, alerts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user