/// <summary> /// when sleeping component is added or removed, we do some stuff with other components. /// </summary> private void OnSleepStateChanged(EntityUid uid, MobStateComponent component, SleepStateChangedEvent args) { _prototypeManager.TryIndex <InstantActionPrototype>("Wake", out var wakeAction); if (args.FellAsleep) { EnsureComp <StunnedComponent>(uid); EnsureComp <KnockedDownComponent>(uid); var emitSound = EnsureComp <SpamEmitSoundComponent>(uid); emitSound.Sound = new SoundCollectionSpecifier("Snores"); emitSound.PlayChance = 0.33f; emitSound.RollInterval = 5f; emitSound.PopUp = "sleep-onomatopoeia"; emitSound.PitchVariation = 0.2f; if (wakeAction != null) { var wakeInstance = new InstantAction(wakeAction); wakeInstance.Cooldown = (_gameTiming.CurTime, _gameTiming.CurTime + TimeSpan.FromSeconds(15)); _actionsSystem.AddAction(uid, wakeInstance, null); } return; } if (wakeAction != null) { _actionsSystem.RemoveAction(uid, wakeAction); } RemComp <StunnedComponent>(uid); RemComp <KnockedDownComponent>(uid); RemComp <SpamEmitSoundComponent>(uid); }
public void RemovePolymorphAction(string id, EntityUid target) { if (!_proto.TryIndex <PolymorphPrototype>(id, out var polyproto)) { return; } if (!TryComp <PolymorphableComponent>(target, out var comp)) { return; } if (comp.PolymorphActions == null) { return; } comp.PolymorphActions.TryGetValue(id, out var val); if (val != null) { _actions.RemoveAction(target, val); } }
private void ManageUpdateList(EntityUid uid, HealOnBuckleComponent component, BuckleChangeEvent args) { _prototypeManager.TryIndex <InstantActionPrototype>("Sleep", out var sleepAction); if (args.Buckling) { AddComp <HealOnBuckleHealingComponent>(uid); if (sleepAction != null) { _actionsSystem.AddAction(args.BuckledEntity, new InstantAction(sleepAction), null); } return; } if (sleepAction != null) { _actionsSystem.RemoveAction(args.BuckledEntity, sleepAction, null); } _sleepingSystem.TryWaking(args.BuckledEntity); RemComp <HealOnBuckleHealingComponent>(uid); component.Accumulator = 0; }