Exemple #1
0
    /// <summary>
    /// Add a new custom managed event for this driver.  All params.
    /// </summary>
    /// <typeparam name="T">Driver type</typeparam>
    /// <param name="_thisDriver">This driver</param>
    /// <param name="_condition">Event condition</param>
    /// <param name="_action">Event action</param>
    /// <param name="_priority">Event priority</param>
    /// <param name="_fireCount">Event fire count</param>
    /// <param name="_id">Event ID</param>
    /// <param name="_desc">Event Description</param>
    /// <returns>This driver</returns>
    public static T SetAddEvent <T>(this T _thisDriver, ioDriver.Event.Condition <T> _condition,
                                    ioDriver.Event.Handler <T> _action, uint _priority, int _fireCount = 1, string _id = null, string _desc = null)
        where T : ioDriver.DBase
    {
        var evt = _thisDriver.AddEventUser(() => _condition(_thisDriver), _action, _id)
                  .SetFireCount(_fireCount)
                  .SetPriority(_priority);

        if (_desc != null)
        {
            evt.Description = _desc;
        }
        return(_thisDriver);
    }
Exemple #2
0
    /// <summary>
    /// Add a new timed event for this driver.  All params.
    /// </summary>
    /// <typeparam name="T">Driver type</typeparam>
    /// <param name="_thisDriver">This driver</param>
    /// <param name="_seconds">Time in seconds of this driver's elapsed time to fire event</param>
    /// <param name="_action">Event action</param>
    /// <param name="_priority">Event priority</param>
    /// <param name="_fireCount">Event fire count</param>
    /// <param name="_id">Event ID</param>
    /// <param name="_desc">Event Description</param>
    /// <returns>This driver</returns>
    public static T SetAddEvent <T>(this T _thisDriver, float _seconds, ioDriver.Event.Handler <T> _action,
                                    uint _priority, int _fireCount = 1, string _id = null, string _desc = null)
        where T : ioDriver.DBase
    {
        var evt = _thisDriver.AddEventTimed(_seconds, _action, _id)
                  .SetPriority(_priority)
                  .SetFireCount(_fireCount);

        if (_desc != null)
        {
            evt.Description = _desc;
        }
        return(_thisDriver);
    }
Exemple #3
0
    /// <summary>
    /// Extension method.  Add immediate mode loop event. <seealso cref="ioDriver.EventsLoop"/>
    /// </summary>
    /// <typeparam name="T">Event target type</typeparam>
    /// <param name="_thisDriver">Driver to add event to</param>
    /// <param name="_event">Event type</param>
    /// <param name="_action">Event action</param>
    /// <returns>This driver</returns>
    public static T SetAddEvent <T>(this T _thisDriver, ioDriver.EventsLoop _event, ioDriver.Event.Handler <T> _action)
        where T : ioDriver.ILoopable
    {
        switch (_event)
        {
        case ioDriver.EventsLoop.OnLoopCycleComplete:
            _thisDriver.OnLoopCycleComplete += () => _action(_thisDriver);
            break;

        case ioDriver.EventsLoop.OnLoopPingPongForeComplete:
            _thisDriver.OnLoopPingPongForeComplete += () => _action(_thisDriver);
            break;

        case ioDriver.EventsLoop.OnLoopPingPongBackComplete:
            _thisDriver.OnLoopPingPongBackComplete += () => _action(_thisDriver);
            break;

        default:
            throw new ArgumentOutOfRangeException("_event", _event, null);
        }
        return(_thisDriver);
    }
Exemple #4
0
    /// <summary>
    /// Add immediate mode base event. <seealso cref="ioDriver.Events"/>
    /// </summary>
    /// <typeparam name="T">Event target type</typeparam>
    /// <param name="_thisDriver">Driver to add event to</param>
    /// <param name="_event">Event type</param>
    /// <param name="_action">Event action</param>
    /// <returns>This driver</returns>
    public static T SetAddEvent <T>(this T _thisDriver, ioDriver.Events _event, ioDriver.Event.Handler <T> _action)
        where T : ioDriver.DBase
    {
        switch (_event)
        {
        case ioDriver.Events.OnStart:
            _thisDriver.OnStart += () => _action(_thisDriver);
            break;

        case ioDriver.Events.OnAfterDelay:
            _thisDriver.OnAfterDelay += () => _action(_thisDriver);
            break;

        case ioDriver.Events.OnFinish:
            _thisDriver.OnFinish += () => _action(_thisDriver);
            break;

        case ioDriver.Events.OnCancel:
            _thisDriver.OnCancel += () => _action(_thisDriver);
            break;

        case ioDriver.Events.OnPause:
            _thisDriver.OnPause += () => _action(_thisDriver);
            break;

        case ioDriver.Events.OnUnpause:
            _thisDriver.OnUnpause += () => _action(_thisDriver);
            break;

        case ioDriver.Events.OnPauseToggle:
            _thisDriver.OnPauseToggle += () => _action(_thisDriver);
            break;

        default:
            throw new ArgumentOutOfRangeException("_event", _event, null);
        }
        return(_thisDriver);
    }
Exemple #5
0
 /// <summary>
 /// Add a new custom managed event for this driver.  Defaults.
 /// </summary>
 /// <typeparam name="T">Driver type</typeparam>
 /// <param name="_thisDriver">This driver</param>
 /// <param name="_condition">Event condition</param>
 /// <param name="_action">Event action</param>
 /// <param name="_id">Event ID</param>
 /// <returns>This driver</returns>
 public static T SetAddEvent <T>(this T _thisDriver, ioDriver.Event.Condition <T> _condition, ioDriver.Event.Handler <T> _action, string _id = null)
     where T : ioDriver.DBase
 {
     _thisDriver.AddEventUser(() => _condition(_thisDriver), _action, _id);
     return(_thisDriver);
 }
Exemple #6
0
 /// <summary>
 /// Add a new timed event for this driver.  Default priority.
 /// </summary>
 /// <typeparam name="T">Driver type</typeparam>
 /// <param name="_thisDriver">This driver</param>
 /// <param name="_seconds">Time in seconds of this driver's elapsed time to fire event</param>
 /// <param name="_action">Event action</param>
 /// <param name="_id">Event ID</param>
 /// <returns>This driver</returns>
 public static T SetAddEvent <T>(this T _thisDriver, float _seconds, ioDriver.Event.Handler <T> _action, string _id = null)
     where T : ioDriver.DBase
 {
     _thisDriver.AddEventTimed(_seconds, _action, _id);
     return(_thisDriver);
 }