Advertisement
Pro_Unit

Trigger

Jun 18th, 2021
1,279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1.     public class Trigger
  2.     {
  3.         private bool _value;
  4.  
  5.         public bool Value
  6.         {
  7.             get
  8.             {
  9.                 bool value = _value;
  10.                 if (_value)
  11.                     _value = false;
  12.                 return value;
  13.             }
  14.         }
  15.  
  16.         public Trigger(bool startValue = false) =>
  17.             _value = startValue;
  18.  
  19.         public void Set() => _value = true;
  20.  
  21.         public void Reset() => _value = false;
  22.  
  23.         public static implicit operator bool(Trigger trigger)
  24.             => trigger.Value;
  25.     }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement