OnChangeModelEvent.cs 671 B

1234567891011121314151617181920212223
  1. using ET;
  2. using ET.Client;
  3. [Event]
  4. public class ChangeModelEventHandler : BEvent<ET.EventType.ChangeModeEvent>
  5. {
  6. protected override async ETTask OnEvent(ET.EventType.ChangeModeEvent args)
  7. {
  8. var unitid = args.ObjectId;
  9. if (!UnitMgr.Instance.HasUnit(unitid))
  10. {
  11. Log.Debug($"ignore change event @{unitid}, unit not exist");
  12. return;
  13. }
  14. if (ModelViewComponent.Instance != null)
  15. {
  16. ModelViewComponent.Instance.RemoveChild(unitid);
  17. }
  18. EventSystem.Instance.Publish(ET.EventType.OnNewZoneObject.Clone(unitid, args.ModelName));
  19. await ETTask.CompletedTask;
  20. }
  21. }