/// <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); }
/// <summary> /// Creates a sidebar action for an entity to be able to polymorph at will /// </summary> /// <param name="id">The string of the id of the polymorph action</param> /// <param name="target">The entity that will be gaining the action</param> public void CreatePolymorphAction(string id, EntityUid target) { if (!_proto.TryIndex <PolymorphPrototype>(id, out var polyproto)) { _saw.Error("Invalid polymorph prototype"); return; } if (!TryComp <PolymorphableComponent>(target, out var polycomp)) { return; } var entproto = _proto.Index <EntityPrototype>(polyproto.Entity); var act = new InstantAction() { Event = new PolymorphActionEvent(polyproto), Name = Loc.GetString("polymorph-self-action-name", ("target", entproto.Name)), Description = Loc.GetString("polymorph-self-action-description", ("target", entproto.Name)), Icon = new SpriteSpecifier.EntityPrototype(polyproto.Entity), ItemIconStyle = ItemActionIconStyle.NoItem, }; if (polycomp.PolymorphActions == null) { polycomp.PolymorphActions = new(); } polycomp.PolymorphActions.Add(id, act); _actions.AddAction(target, act, target); }
private void OnComponentInit(EntityUid uid, EggLayerComponent component, ComponentInit args) { if (!_prototype.TryIndex <InstantActionPrototype>(component.EggLayAction, out var action)) { return; } _actions.AddAction(uid, new InstantAction(action), uid); component.CurrentEggLayCooldown = _random.NextFloat(component.EggLayCooldownMin, component.EggLayCooldownMax); }
private void OnGetActions(EntityUid uid, IntrinsicUIComponent component, ComponentStartup args) { if (!TryComp <ActionsComponent>(uid, out var actions)) { return; } foreach (var entry in component.UIs) { _actionsSystem.AddAction(uid, entry.ToggleAction, null, actions); } }
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 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; }
private void OnStartup(EntityUid uid, RatKingComponent component, ComponentStartup args) { _action.AddAction(uid, component.ActionRaiseArmy, null); _action.AddAction(uid, component.ActionDomain, null); }