EntityViewModel.cs 686 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using UnityEngine;
  3. using XGame.Framework.ObjectCollection;
  4. namespace XGame.Framework.Map
  5. {
  6. public abstract class EntityViewModel : IEntityViewModel, IDisposable
  7. {
  8. private EntityBehaviour _behaviour;
  9. public Transform Tr => _behaviour.transform;
  10. public void Init(EntityBehaviour behaviour)
  11. {
  12. _behaviour = behaviour;
  13. OnInit(behaviour.Collector);
  14. }
  15. void IDisposable.Dispose()
  16. {
  17. OnDispose();
  18. _behaviour = null;
  19. }
  20. protected abstract void OnInit(IObjectCollector collector);
  21. protected virtual void OnDispose()
  22. {
  23. }
  24. }
  25. }