private void OnInit(EntityUid uid, SleepingComponent component, ComponentInit args) { var ev = new SleepStateChangedEvent(true); RaiseLocalEvent(uid, ev, false); _blindingSystem.AdjustBlindSources(uid, true); }
private void OnShutdown(EntityUid uid, SleepingComponent component, ComponentShutdown args) { var ev = new SleepStateChangedEvent(false); RaiseLocalEvent(uid, ev, false); _blindingSystem.AdjustBlindSources(uid, false); }
private void OnExamined(EntityUid uid, SleepingComponent component, ExaminedEvent args) { if (args.IsInDetailsRange) { args.PushMarkup(Loc.GetString("sleep-examined", ("target", Identity.Entity(uid, EntityManager)))); } }
/// <summary> /// Wake up if we take an instance of more than 2 damage. /// </summary> private void OnDamageChanged(EntityUid uid, SleepingComponent component, DamageChangedEvent args) { if (!args.DamageIncreased || args.DamageDelta == null) { return; } if (args.DamageDelta.Total >= component.WakeThreshold) { TryWaking(uid); } }
/// <summary> /// In crit, we wake up if we are not being forced to sleep. /// And, you can't sleep when dead... /// </summary> private void OnMobStateChanged(EntityUid uid, SleepingComponent component, MobStateChangedEvent args) { if (_mobStateSystem.IsCritical(uid) && !HasComp <ForcedSleepingComponent>(uid)) { RemComp <SleepingComponent>(uid); return; } if (_mobStateSystem.IsDead(uid)) { RemComp <SleepingComponent>(uid); } }
private void AddWakeVerb(EntityUid uid, SleepingComponent component, GetVerbsEvent <AlternativeVerb> args) { if (!args.CanInteract || !args.CanAccess) { return; } AlternativeVerb verb = new() { Act = () => { TryWaking(args.Target, user: args.User); }, Text = Loc.GetString("action-name-wake"), Priority = 2 }; args.Verbs.Add(verb); }
private void OnSpeakAttempt(EntityUid uid, SleepingComponent component, SpeakAttemptEvent args) { args.Cancel(); }
/// <summary> /// When you click on a sleeping person with an empty hand, try to wake them. /// </summary> private void OnInteractHand(EntityUid uid, SleepingComponent component, InteractHandEvent args) { args.Handled = true; TryWaking(args.Target, user: args.User); }