A game about forced loneliness, made by TACStudios
1using System.Collections; 2using UnityEngine; 3 4namespace Unity.VisualScripting 5{ 6 /// <summary> 7 /// Delays flow by waiting a specified number of seconds. 8 /// </summary> 9 [UnitTitle("Wait For Seconds")] 10 [UnitOrder(1)] 11 public class WaitForSecondsUnit : WaitUnit 12 { 13 /// <summary> 14 /// The number of seconds to await. 15 /// </summary> 16 [DoNotSerialize] 17 [PortLabel("Delay")] 18 public ValueInput seconds { get; private set; } 19 20 /// <summary> 21 /// Whether to ignore the time scale. 22 /// </summary> 23 [DoNotSerialize] 24 [PortLabel("Unscaled")] 25 public ValueInput unscaledTime { get; private set; } 26 27 protected override void Definition() 28 { 29 base.Definition(); 30 31 seconds = ValueInput(nameof(seconds), 0f); 32 unscaledTime = ValueInput(nameof(unscaledTime), false); 33 34 Requirement(seconds, enter); 35 Requirement(unscaledTime, enter); 36 } 37 38 protected override IEnumerator Await(Flow flow) 39 { 40 var seconds = flow.GetValue<float>(this.seconds); 41 42 if (flow.GetValue<bool>(unscaledTime)) 43 { 44 yield return new WaitForSecondsRealtime(seconds); 45 } 46 else 47 { 48 yield return new WaitForSeconds(seconds); 49 } 50 51 yield return exit; 52 } 53 } 54}