예제 #1
0
    /// <summary>
    ///     Add an alt-click interaction that cycles through delays.
    /// </summary>
    private void OnGetAltVerbs(EntityUid uid, OnUseTimerTriggerComponent component, GetVerbsEvent <AlternativeVerb> args)
    {
        if (!args.CanInteract || !args.CanAccess)
        {
            return;
        }

        if (component.DelayOptions == null || component.DelayOptions.Count == 1)
        {
            return;
        }

        args.Verbs.Add(new AlternativeVerb()
        {
            Category = TimerOptions,
            Text     = Loc.GetString("verb-trigger-timer-cycle"),
            Act      = () => CycleDelay(component, args.User),
            Priority = 1
        });

        foreach (var option in component.DelayOptions)
        {
            if (MathHelper.CloseTo(option, component.Delay))
            {
                args.Verbs.Add(new AlternativeVerb()
                {
                    Category = TimerOptions,
                    Text     = Loc.GetString("verb-trigger-timer-set-current", ("time", option)),
                    Disabled = true,
                    Priority = (int)(-100 * option)
                });
예제 #2
0
 private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args)
 {
     if (args.IsInDetailsRange)
     {
         args.PushText(Loc.GetString("examine-trigger-timer", ("time", component.Delay)));
     }
 }
    // TODO: Need to split this out so it's a generic "OnUseTimerTrigger" component.
    private void Trigger(EntityUid uid, EntityUid user, OnUseTimerTriggerComponent component)
    {
        if (TryComp <AppearanceComponent>(uid, out var appearance))
        {
            appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
        }

        HandleTimerTrigger(TimeSpan.FromSeconds(component.Delay), uid, user);
    }
    private void OnTimerUse(EntityUid uid, OnUseTimerTriggerComponent component, UseInHandEvent args)
    {
        if (args.Handled)
        {
            return;
        }

        Trigger(uid, args.User, component);
        args.Handled = true;
    }
예제 #5
0
    private void OnStuck(EntityUid uid, OnUseTimerTriggerComponent component, EntityStuckEvent args)
    {
        if (!component.StartOnStick)
        {
            return;
        }

        HandleTimerTrigger(
            uid,
            args.User,
            component.Delay,
            component.BeepInterval,
            component.InitialBeepDelay,
            component.BeepSound,
            component.BeepParams);
    }