/// <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); }
protected override void OnComponentInit(EntityUid uid, SharedVendingMachineComponent sharedComponent, ComponentInit args) { base.OnComponentInit(uid, sharedComponent, args); var component = (VendingMachineComponent)sharedComponent; if (TryComp <ApcPowerReceiverComponent>(component.Owner, out var receiver)) { TryUpdateVisualState(uid, null, component); } if (component.Action != null) { var action = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(component.Action)); _action.AddAction(uid, action, uid); } }
private void OnComponentInit(EntityUid uid, VendingMachineComponent component, ComponentInit args) { base.Initialize(); if (TryComp <ApcPowerReceiverComponent>(component.Owner, out var receiver)) { TryUpdateVisualState(uid, null, component); } if (component.Action != null) { var action = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(component.Action)); _action.AddAction(uid, action, uid); } InitializeFromPrototype(uid, component); }
private void OnInit(EntityUid uid, PolymorphedEntityComponent component, PolymorphComponentSetupEvent args) { if (component.Prototype.Forced) { return; } var act = new InstantAction() { Event = new RevertPolymorphActionEvent(), EntityIcon = component.Parent, Name = Loc.GetString("polymorph-revert-action-name"), Description = Loc.GetString("polymorph-revert-action-description"), UseDelay = TimeSpan.FromSeconds(component.Prototype.Delay), }; _actions.AddAction(uid, act, null); }
private void OnInit(EntityUid uid, SpellbookComponent component, ComponentInit args) { //Negative charges means the spell can be used without it running out. foreach (var(id, charges) in component.WorldSpells) { var spell = new WorldTargetAction(_prototypeManager.Index <WorldTargetActionPrototype>(id)); _actionsSystem.SetCharges(spell, charges < 0 ? null : charges); component.Spells.Add(spell); } foreach (var(id, charges) in component.InstantSpells) { var spell = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(id)); _actionsSystem.SetCharges(spell, charges < 0 ? null : charges); component.Spells.Add(spell); } foreach (var(id, charges) in component.EntitySpells) { var spell = new EntityTargetAction(_prototypeManager.Index <EntityTargetActionPrototype>(id)); _actionsSystem.SetCharges(spell, charges < 0 ? null : charges); component.Spells.Add(spell); } }
public InstantAction(InstantAction toClone) { CopyFrom(toClone); }
public RequestPerformActionEvent(InstantAction action) { Action = action; }