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.

DispatcherOnSet.cs 861B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using BetterWeakEvents;
  2. namespace Svelto.ECS
  3. {
  4. public class DispatchOnSet<T>
  5. {
  6. public DispatchOnSet(int senderID)
  7. {
  8. _senderID = senderID;
  9. _subscribers = new WeakEvent<int, T>();
  10. }
  11. public T value
  12. {
  13. set
  14. {
  15. _value = value;
  16. _subscribers.Invoke(_senderID, value);
  17. }
  18. get
  19. {
  20. return _value;
  21. }
  22. }
  23. public void NotifyOnValueSet(System.Action<int, T> action)
  24. {
  25. _subscribers += action;
  26. }
  27. public void StopNotify(System.Action<int, T> action)
  28. {
  29. _subscribers -= action;
  30. }
  31. protected T _value;
  32. protected int _senderID;
  33. protected WeakEvent<int, T> _subscribers;
  34. }
  35. }