public bool AffectedByGhostBoo(InstantActionEventArgs args) { if (_ignoreGhostsBoo) { return(false); } // check cooldown first to prevent abuse var time = _gameTiming.CurTime; if (_lastGhostBlink != null) { if (time <= _lastGhostBlink + ghostBlinkingCooldown) { return(false); } } _lastGhostBlink = time; ToggleBlinkingLight(true); Owner.SpawnTimer(ghostBlinkingTime, () => { ToggleBlinkingLight(false); }); return(true); }
public void DoInstantAction(InstantActionEventArgs args) { if (!args.Performer.TryGetComponent <SharedActionsComponent>(out var actions)) { return; } // find all IGhostBooAffected nearby and do boo on them var ents = IoCManager.Resolve <IEntityLookup>().GetEntitiesInRange(args.Performer, _radius, false); var booCounter = 0; foreach (var ent in ents) { var boos = ent.GetAllComponents <IGhostBooAffected>().ToList(); foreach (var boo in boos) { if (boo.AffectedByGhostBoo(args)) { booCounter++; } } if (booCounter >= _maxTargets) { break; } } actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown)); }
public void DoInstantAction(InstantActionEventArgs args) { if (!args.Performer.TryGetComponent <SharedActionsComponent>(out var actions)) { return; } // find all IGhostBooAffected nearby and do boo on them var ents = IoCManager.Resolve <IEntityLookup>().GetEntitiesInRange(args.Performer, _radius); var booCounter = 0; foreach (var ent in ents) { var ghostBoo = new GhostBooEvent(); ent.EntityManager.EventBus.RaiseLocalEvent(ent.Uid, ghostBoo); if (ghostBoo.Handled) { booCounter++; } if (booCounter >= _maxTargets) { break; } } actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown)); }
public void DoInstantAction(InstantActionEventArgs args) { if (!EntitySystem.Get <ActionBlockerSystem>().CanSpeak(args.Performer)) { return; } if (!args.Performer.TryGetComponent <HumanoidAppearanceComponent>(out var humanoid)) { return; } if (!args.Performer.TryGetComponent <SharedActionsComponent>(out var actions)) { return; } if (_random.Prob(.01f) && !string.IsNullOrWhiteSpace(_wilhelm)) { SoundSystem.Play(Filter.Pvs(args.Performer), _wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume)); } else { switch (humanoid.Sex) { case Sex.Male: if (_male == null) { break; } SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_male), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; case Sex.Female: if (_female == null) { break; } SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_female), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; default: throw new ArgumentOutOfRangeException(); } } actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown)); }
public void DoInstantAction(InstantActionEventArgs args) { var entManager = IoCManager.Resolve <IEntityManager>(); if (entManager.TryGetComponent(args.Performer, out GuardianHostComponent? hostComponent) && hostComponent.HostedGuardian != null) { EntitySystem.Get <GuardianSystem>().ToggleGuardian(hostComponent); args.PerformerActions?.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(Cooldown)); } else { args.Performer.PopupMessage(Loc.GetString("guardian-missing-invalid-action")); } }
//Rubber-band snapping items into player's hands, originally was a workaround, later found it works quite well with stuns //Not sure if needs fixing public void DoInstantAction(InstantActionEventArgs args) { var caster = args.Performer; if (!caster.TryGetComponent(out HandsComponent? handsComponent)) { caster.PopupMessage(Loc.GetString("spell-fail-no-hands")); return; } if (!EntitySystem.Get <ActionBlockerSystem>().CanInteract(caster)) { return; } // TODO: Nix when we get EntityPrototype serializers if (!IoCManager.Resolve <IPrototypeManager>().HasIndex <EntityPrototype>(ItemProto)) { Logger.Error($"Invalid prototype {ItemProto} supplied for {nameof(GiveItemSpell)}"); return; } // TODO: Look this is shitty and ideally a test would do it var spawnedProto = caster.EntityManager.SpawnEntity(ItemProto, caster.Transform.MapPosition); if (!spawnedProto.TryGetComponent(out ItemComponent? itemComponent)) { Logger.Error($"Tried to use {nameof(GiveItemSpell)} but prototype has no {nameof(ItemComponent)}?"); spawnedProto.Delete(); return; } args.PerformerActions?.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(CoolDown)); if (CastMessage != null) { caster.PopupMessageEveryone(CastMessage); } handsComponent.PutInHandOrDrop(itemComponent); if (CastSound != null) { SoundSystem.Play(Filter.Pvs(caster), CastSound, caster); } }
public void DoInstantAction(InstantActionEventArgs args) { var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetComponent <ServerUserInterfaceComponent?>(args.Performer, out var serverUi)) { return; } if (!entMan.TryGetComponent <ActorComponent?>(args.Performer, out var actor)) { return; } if (!serverUi.TryGetBoundUserInterface(InstrumentUiKey.Key, out var bui)) { return; } bui.Toggle(actor.PlayerSession); }
public void DoInstantAction(InstantActionEventArgs args) { args.Performer.PopupMessageEveryone(Message); args.PerformerActions?.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(Cooldown)); }