Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
593B

  1. using System;
  2. namespace Svelto.ECS
  3. {
  4. public class DispatchOnChange<T> : DispatchOnSet<T> where T:IEquatable<T>
  5. {
  6. public DispatchOnChange(EGID senderID, T initialValue = default(T)) : base(senderID)
  7. {
  8. _value = initialValue;
  9. }
  10. public DispatchOnChange(EGID senderID, Action<EGID, T> callback) : base(senderID, callback) {}
  11. public new T value
  12. {
  13. set
  14. {
  15. if (value.Equals(_value) == false)
  16. base.value = value;
  17. }
  18. get => _value;
  19. }
  20. }
  21. }