PRevent the forever sleep. (#40366)
* Fix * Rejuvenate --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
cc4c7f5ada
commit
3ac94ea7f5
@@ -59,6 +59,8 @@ public sealed partial class SleepingSystem : EntitySystem
|
||||
SubscribeLocalEvent<SleepingComponent, EntityZombifiedEvent>(OnZombified);
|
||||
SubscribeLocalEvent<SleepingComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
SubscribeLocalEvent<SleepingComponent, ComponentInit>(OnCompInit);
|
||||
SubscribeLocalEvent<SleepingComponent, ComponentRemove>(OnComponentRemoved);
|
||||
SubscribeLocalEvent<SleepingComponent, RejuvenateEvent>(OnRejuvenate);
|
||||
SubscribeLocalEvent<SleepingComponent, SpeakAttemptEvent>(OnSpeakAttempt);
|
||||
SubscribeLocalEvent<SleepingComponent, CanSeeAttemptEvent>(OnSeeAttempt);
|
||||
SubscribeLocalEvent<SleepingComponent, PointAttemptEvent>(OnPointAttempt);
|
||||
@@ -69,7 +71,6 @@ public sealed partial class SleepingSystem : EntitySystem
|
||||
SubscribeLocalEvent<SleepingComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<SleepingComponent, StunEndAttemptEvent>(OnStunEndAttempt);
|
||||
SubscribeLocalEvent<SleepingComponent, StandUpAttemptEvent>(OnStandUpAttempt);
|
||||
SubscribeLocalEvent<SleepingComponent, RejuvenateEvent>(OnRejuvenate);
|
||||
|
||||
SubscribeLocalEvent<ForcedSleepingStatusEffectComponent, StatusEffectAppliedEvent>(OnStatusEffectApplied);
|
||||
SubscribeLocalEvent<SleepingComponent, UnbuckleAttemptEvent>(OnUnbuckleAttempt);
|
||||
@@ -102,6 +103,12 @@ public sealed partial class SleepingSystem : EntitySystem
|
||||
TrySleeping((ent, ent.Comp));
|
||||
}
|
||||
|
||||
private void OnRejuvenate(Entity<SleepingComponent> ent, ref RejuvenateEvent args)
|
||||
{
|
||||
// WAKE UP!!!
|
||||
RemComp<SleepingComponent>(ent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// when sleeping component is added or removed, we do some stuff with other components.
|
||||
/// </summary>
|
||||
@@ -143,6 +150,16 @@ public sealed partial class SleepingSystem : EntitySystem
|
||||
_actionsSystem.AddAction(ent, ref ent.Comp.WakeAction, WakeActionId, ent);
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(Entity<SleepingComponent> ent, ref ComponentRemove args)
|
||||
{
|
||||
_actionsSystem.RemoveAction(ent.Owner, ent.Comp.WakeAction);
|
||||
|
||||
var ev = new SleepStateChangedEvent(false);
|
||||
RaiseLocalEvent(ent, ref ev);
|
||||
|
||||
_blindableSystem.UpdateIsBlind(ent.Owner);
|
||||
}
|
||||
|
||||
private void OnSpeakAttempt(Entity<SleepingComponent> ent, ref SpeakAttemptEvent args)
|
||||
{
|
||||
// TODO reduce duplication of this behavior with MobStateSystem somehow
|
||||
@@ -187,11 +204,6 @@ public sealed partial class SleepingSystem : EntitySystem
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnRejuvenate(Entity<SleepingComponent> ent, ref RejuvenateEvent args)
|
||||
{
|
||||
TryWaking((ent.Owner, ent.Comp), true);
|
||||
}
|
||||
|
||||
private void OnExamined(Entity<SleepingComponent> ent, ref ExaminedEvent args)
|
||||
{
|
||||
if (args.IsInDetailsRange)
|
||||
@@ -275,17 +287,6 @@ public sealed partial class SleepingSystem : EntitySystem
|
||||
TrySleeping(args.Target);
|
||||
}
|
||||
|
||||
private void Wake(Entity<SleepingComponent> ent)
|
||||
{
|
||||
RemComp<SleepingComponent>(ent);
|
||||
_actionsSystem.RemoveAction(ent.Owner, ent.Comp.WakeAction);
|
||||
|
||||
var ev = new SleepStateChangedEvent(false);
|
||||
RaiseLocalEvent(ent, ref ev);
|
||||
|
||||
_blindableSystem.UpdateIsBlind(ent.Owner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try sleeping. Only mobs can sleep.
|
||||
/// </summary>
|
||||
@@ -345,8 +346,7 @@ public sealed partial class SleepingSystem : EntitySystem
|
||||
_popupSystem.PopupClient(Loc.GetString("wake-other-success", ("target", Identity.Entity(ent, EntityManager))), ent, user);
|
||||
}
|
||||
|
||||
Wake((ent, ent.Comp));
|
||||
return true;
|
||||
return RemComp<SleepingComponent>(ent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user