ContainerTargetManager.cs 903 B

123456789101112131415161718192021222324252627282930313233
  1. // MIT License
  2. // https://gitlab.com/ilnprj
  3. // Copyright (c) 2020 ilnprj
  4. using UnityEngine;
  5. using System;
  6. namespace RadarComponents
  7. {
  8. /// <summary>
  9. /// Container stores the implementation of ITargetManager.
  10. /// In general, this must be done through injection
  11. /// </summary>
  12. public class ContainerTargetManager : MonoBehaviour
  13. {
  14. public ITargetManager TargetManager;
  15. public bool IsInited;
  16. public Action onInit = delegate { };
  17. private void Awake()
  18. {
  19. TargetManager = GetComponent<TargetManager>();
  20. IsInited = true;
  21. }
  22. //NOTE: Due to the fact that the interface is first defined via GetComponent, all targets do not have time to receive an instance, therefore, the status IsInited is required
  23. private void Start()
  24. {
  25. if (IsInited)
  26. onInit();
  27. }
  28. }
  29. }