12345678910111213141516171819202122232425262728293031323334353637383940 |
-
- namespace ET.Client
- {
- [ObjectSystem]
- public class UnitListComponentAwakeSystem : AwakeSystem<UnitListComponent>
- {
- protected override void Awake(UnitListComponent self)
- {
- UnitListComponent.Instance = self;
- self.RecycleUnits();
- self.UnitList = new();
- }
- }
- [ObjectSystem]
- public class UnitListComponentDestroySystem : DestroySystem<UnitListComponent>
- {
- protected override void Destroy(UnitListComponent self)
- {
- self.RecycleUnits();
- UnitListComponent.Instance = null;
- }
- }
- [FriendOf(typeof(UnitListComponent))]
- public static class UnitListComponentExt
- {
- public static void RecycleUnits(this UnitListComponent self)
- {
- if(self.UnitList != null)
- {
- foreach(var kp in self.UnitList)
- {
- kp.Value.OnSleep();
- }
- self.UnitList = null;
- }
- }
- }
- }
|