Last active
August 29, 2015 14:18
-
-
Save muit/650a56ef29ab96c4211b to your computer and use it in GitHub Desktop.
Trigger util class on c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** If using Unity, remove this commentary | |
* [System.Serializable] | |
**/ | |
public class Trigger{ | |
public bool value; | |
public Trigger(bool value = true) { | |
this.value = value; | |
} | |
public bool get() | |
{ | |
bool _value = value; | |
value = false; | |
return _value; | |
} | |
public static bool operator true(Trigger x) | |
{ | |
return x.get(); | |
} | |
public static bool operator false(Trigger x) | |
{ | |
return !x.get(); | |
} | |
public static bool operator ==(Trigger x, bool y) | |
{ | |
return x.get() == y; | |
} | |
public static bool operator ==(Trigger x, Trigger y) | |
{ | |
return x.get() == y.get(); | |
} | |
public static bool operator !=(Trigger x, bool y) | |
{ | |
return x.get() != y; | |
} | |
public static bool operator !=(Trigger x, Trigger y) | |
{ | |
return x.get() != y.get(); | |
} | |
public static implicit operator Trigger(bool value) | |
{ | |
return new Trigger(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment