Stun and Stamina Visuals (#37196)
* Stun animation * Commit 2 * Almost working commit * Best commit * Minor cleanup and value adjustments * Fix animation data getting wasted and cleaned up some stuff * Don't animate if dead * AppearanceSystem is for chumps * Cleanup * More cleanup * More cleanup * Half working commit * Documentation * Works * ComponentHandleState my beloved * AppearanceComp compatibility * Address review * Borgar * AND NOW THE END IS NEAR * AppearanceSystem compliance (Real) * Don't need to log missing there * I actually hate mob prototypes so much you don't even know --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a268a4aacc
commit
ac895a0db4
55
Content.Shared/Stunnable/SharedStunSystem.Visualizer.cs
Normal file
55
Content.Shared/Stunnable/SharedStunSystem.Visualizer.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user