diff --git a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs index 4c6c7ede55..94c8d49230 100644 --- a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs @@ -337,7 +337,8 @@ namespace Content.Server.GameObjects.Components.Buckle Appearance?.SetData(BuckleVisuals.Buckled, false); - if (_stunnable != null && _stunnable.KnockedDown) + if (_stunnable != null && _stunnable.KnockedDown + || (_mobState?.IsIncapacitated() ?? false)) { EntitySystem.Get().Down(Owner); } diff --git a/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs b/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs index a2c2cb25ff..e20089dffb 100644 --- a/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs +++ b/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs @@ -353,13 +353,16 @@ namespace Content.Server.GameObjects.Components.Instruments UserInterface?.CloseAll(); - if(Handheld) - EntitySystem.Get().DropAllItemsInHands(mob, false); - - if (mob != null && mob.TryGetComponent(out StunnableComponent? stun)) + if (mob != null) { - stun.Stun(1); - Clean(); + if (Handheld) + EntitySystem.Get().DropAllItemsInHands(mob, false); + + if (mob.TryGetComponent(out StunnableComponent? stun)) + { + stun.Stun(1); + Clean(); + } } InstrumentPlayer = null; diff --git a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs index 4e5ed66067..5c8593ff7d 100644 --- a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs @@ -1,9 +1,11 @@ -using Content.Server.GameObjects.EntitySystems; +#nullable enable +using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects; using Content.Server.Utility; using Content.Shared.Alert; using Content.Shared.Audio; using Content.Shared.GameObjects.Components.Mobs; +using Content.Shared.GameObjects.Components.Mobs.State; using Content.Shared.GameObjects.Components.Movement; using Content.Shared.Interfaces; using Robust.Server.GameObjects; @@ -39,7 +41,8 @@ namespace Content.Server.GameObjects.Components.Mobs StunnedTimer = 0f; SlowdownTimer = 0f; - if (KnockedDown) + if (KnockedDown && + Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated()) { EntitySystem.Get().Standing(Owner); } @@ -65,7 +68,8 @@ namespace Content.Server.GameObjects.Components.Mobs { KnockdownTimer -= delta; - if (KnockdownTimer <= 0f) + if (KnockdownTimer <= 0f + && Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated()) { EntitySystem.Get().Standing(Owner); @@ -82,7 +86,7 @@ namespace Content.Server.GameObjects.Components.Mobs { SlowdownTimer = 0f; - if (Owner.TryGetComponent(out MovementSpeedModifierComponent movement)) + if (Owner.TryGetComponent(out MovementSpeedModifierComponent? movement)) { movement.RefreshMovementSpeedModifiers(); } @@ -92,7 +96,7 @@ namespace Content.Server.GameObjects.Components.Mobs } if (!StunStart.HasValue || !StunEnd.HasValue || - !Owner.TryGetComponent(out ServerAlertsComponent status)) + !Owner.TryGetComponent(out ServerAlertsComponent? status)) { return; } diff --git a/Content.Server/GameObjects/EntitySystems/StandingStateSystem.cs b/Content.Server/GameObjects/EntitySystems/StandingStateSystem.cs index 87230a7ebe..d137c68a70 100644 --- a/Content.Server/GameObjects/EntitySystems/StandingStateSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StandingStateSystem.cs @@ -1,5 +1,7 @@ -using Content.Server.Interfaces.GameObjects.Components.Items; +#nullable enable +using Content.Server.Interfaces.GameObjects.Components.Items; using Content.Shared.Audio; +using Content.Shared.GameObjects.Components.Mobs.State; using Content.Shared.GameObjects.Components.Rotation; using Content.Shared.GameObjects.EntitySystems; using JetBrains.Annotations; @@ -13,7 +15,7 @@ namespace Content.Server.GameObjects.EntitySystems { protected override bool OnDown(IEntity entity, bool playSound = true, bool dropItems = true, bool force = false) { - if (!entity.TryGetComponent(out AppearanceComponent appearance)) + if (!entity.TryGetComponent(out AppearanceComponent? appearance)) { return false; } @@ -37,7 +39,7 @@ namespace Content.Server.GameObjects.EntitySystems protected override bool OnStand(IEntity entity) { - if (!entity.TryGetComponent(out AppearanceComponent appearance)) return false; + if (!entity.TryGetComponent(out AppearanceComponent? appearance)) return false; appearance.TryGetData(RotationVisuals.RotationState, out var oldState); var newState = RotationState.Vertical; @@ -53,7 +55,7 @@ namespace Content.Server.GameObjects.EntitySystems { base.DropAllItemsInHands(entity, doMobChecks); - if (!entity.TryGetComponent(out IHandsComponent hands)) return; + if (!entity.TryGetComponent(out IHandsComponent? hands)) return; foreach (var heldItem in hands.GetAllHeldItems()) {