Files
Delta-v/Content.Shared/Stunnable/SharedStunSystem.Visualizer.cs
Princess CheeseballsandPrincess Cheeseballs 287daf5141 SSD Players now properly stay asleep when being revived. (#39409)
* Fixes and API changes

* aaaaaaaaaa

* super shitcode

* cleanup

* fix admin logs

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2026-07-05 14:34:57 -05:00

56 lines
1.7 KiB
C#

using Content.Shared.Bed.Sleep;
using Content.Shared.Mobs;
using Robust.Shared.Serialization;
namespace Content.Shared.Stunnable;
public abstract partial class SharedStunSystem
{
public void InitializeAppearance()
{
SubscribeLocalEvent<StunVisualsComponent, MobStateChangedEvent>(OnStunMobStateChanged);
SubscribeLocalEvent<StunVisualsComponent, SleepStateChangedEvent>(OnSleepStateChanged);
}
private bool GetStarsData(Entity<StunVisualsComponent, StunnedComponent?> entity)
{
if (!Resolve(entity, ref entity.Comp2, false))
return false;
return Blocker.CanConsciouslyPerformAction(entity);
}
private void OnStunMobStateChanged(Entity<StunVisualsComponent> entity, ref MobStateChangedEvent args)
{
Appearance.SetData(entity, StunVisuals.SeeingStars, GetStarsData(entity));
}
private void OnSleepStateChanged(Entity<StunVisualsComponent> entity, ref SleepStateChangedEvent args)
{
Appearance.SetData(entity, StunVisuals.SeeingStars, GetStarsData(entity));
}
public void TrySeeingStars(Entity<AppearanceComponent?> entity)
{
if (!Resolve(entity, ref entity.Comp))
return;
// Here so server can tell the client to do things
// Don't dirty the component if we don't need to
if (Appearance.TryGetData<bool>(entity, StunVisuals.SeeingStars, out var stars, entity.Comp) && stars)
return;
if (!Blocker.CanConsciouslyPerformAction(entity))
return;
Appearance.SetData(entity, StunVisuals.SeeingStars, true);
Dirty(entity);
}
[Serializable, NetSerializable, Flags]
public enum StunVisuals
{
SeeingStars,
}
}