EffectManager.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. public class EffectManager : IManager
  6. {
  7. public const string header = "EFFECT";
  8. public const string footer = "END_EFFECT";
  9. private readonly Dictionary<Type, IEffectManager> EffectManagers = new Dictionary<Type, IEffectManager>();
  10. public T Get<T>() where T : IEffectManager
  11. => EffectManagers.ContainsKey(typeof(T)) ? (T)EffectManagers[typeof(T)] : default;
  12. public T AddManager<T>() where T : IEffectManager, new()
  13. {
  14. T manager = new T();
  15. EffectManagers[typeof(T)] = manager;
  16. manager.Activate();
  17. return manager;
  18. }
  19. public void Activate()
  20. {
  21. foreach (IEffectManager effectManager in EffectManagers.Values) effectManager.Activate();
  22. }
  23. public void Deactivate()
  24. {
  25. foreach (IEffectManager effectManager in EffectManagers.Values) effectManager.Deactivate();
  26. }
  27. public void Update() { }
  28. }
  29. }