コード例 #1
0
        /// <summary>
        ///     Schedule an action that repeatedly fires after a delay specified in milliseconds.
        /// </summary>
        /// <param name="entity">The entity to add the timer to.</param>
        /// <param name="milliseconds">The length of time, in milliseconds, to delay before firing the repeated action.</param>
        /// <param name="onFired">The action to fire.</param>
        /// <param name="cancellationToken">The CancellationToken for stopping the Timer.</param>
        public static void SpawnRepeatingTimer(this EntityUid entity, int milliseconds, Action onFired, CancellationToken cancellationToken)
        {
            var entMan = IoCManager.Resolve <IEntityManager>();

            entity
            .EnsureTimerComponent()
            .SpawnRepeating(milliseconds, onFired, cancellationToken);
        }
コード例 #2
0
 /// <summary>
 ///     Schedule an action to be fired after a certain delay.
 ///     The action will be resumed on the main game logic thread.
 /// </summary>
 /// <param name="entity">The entity to add the timer to.</param>
 /// <param name="duration">The length of time, to wait before firing the action.</param>
 /// <param name="onFired">The action to fire.</param>
 /// <param name="cancellationToken"></param>
 public static void SpawnTimer(this EntityUid entity, TimeSpan duration, Action onFired, CancellationToken cancellationToken = default)
 {
     entity
     .EnsureTimerComponent()
     .Spawn((int)duration.TotalMilliseconds, onFired, cancellationToken);
 }
コード例 #3
0
 /// <summary>
 ///     Schedule an action to be fired after a certain delay.
 ///     The action will be resumed on the main game logic thread.
 /// </summary>
 /// <param name="entity">The entity to add the timer to.</param>
 /// <param name="milliseconds">The length of time, in milliseconds, to wait before firing the action.</param>
 /// <param name="onFired">The action to fire.</param>
 /// <param name="cancellationToken"></param>
 public static void SpawnTimer(this EntityUid entity, int milliseconds, Action onFired, CancellationToken cancellationToken = default)
 {
     entity
     .EnsureTimerComponent()
     .Spawn(milliseconds, onFired, cancellationToken);
 }
コード例 #4
0
 /// <summary>
 ///     Creates a task that will complete after a given delay.
 ///     The task is resumed on the main game logic thread.
 /// </summary>
 /// <param name="entity">The entity to add the timer to.</param>
 /// <param name="duration">The length of time to delay for.</param>
 /// <param name="cancellationToken"></param>
 /// <returns>The task that can be awaited.</returns>
 public static Task DelayTask(this EntityUid entity, TimeSpan duration, CancellationToken cancellationToken = default)
 {
     return(entity
            .EnsureTimerComponent()
            .Delay((int)duration.TotalMilliseconds, cancellationToken));
 }
コード例 #5
0
 /// <summary>
 ///     Creates a task that will complete after a given delay.
 ///     The task is resumed on the main game logic thread.
 /// </summary>
 /// <param name="entity">The entity to add the timer to.</param>
 /// <param name="milliseconds">The length of time, in milliseconds, to delay for.</param>
 /// <param name="cancellationToken"></param>
 /// <returns>The task that can be awaited.</returns>
 public static Task DelayTask(this EntityUid entity, int milliseconds, CancellationToken cancellationToken = default)
 {
     return(entity
            .EnsureTimerComponent()
            .Delay(milliseconds, cancellationToken));
 }
コード例 #6
0
 public static void AddTimer(this EntityUid entity, Timer timer, CancellationToken cancellationToken = default)
 {
     entity
     .EnsureTimerComponent()
     .AddTimer(timer, cancellationToken);
 }
コード例 #7
0
 /// <summary>
 ///     Schedule an action that repeatedly fires after a delay.
 /// </summary>
 /// <param name="entity">The entity to add the timer to.</param>
 /// <param name="duration">The length of time to delay before firing the repeated action.</param>
 /// <param name="onFired">The action to fire.</param>
 /// <param name="cancellationToken">The CancellationToken for stopping the Timer.</param>
 public static void SpawnRepeatingTimer(this EntityUid entity, TimeSpan duration, Action onFired, CancellationToken cancellationToken)
 {
     entity
     .EnsureTimerComponent()
     .SpawnRepeating(duration, onFired, cancellationToken);
 }