using Cal.DataTable; using ET.EventType; using System; using System.Collections.Generic; using UnityEngine; namespace ET { public class SwitchPetDisplayEvent : AEvent { public override async ETTask Run(SwitchPetDisplay args) { var zoneScene = args.zoneScene; Pet pet = args.unit.GetComponent(); if (args.isShow) { if (pet.petUnitId != 0) { zoneScene.GetComponent().Remove(pet.petUnitId ); } pet.petUnitId = Game.IdGenerater.GenerateId(); Unit petUnit = await UnitFactory.CreatePet(zoneScene, pet.petUnitId); PetConfig petConfig = PetConfigCategory.Instance.Get(pet.petId); if (petConfig == null) return; Transform go = await ResourceViewHelper.LoadPrefabAsync(petConfig.PrefabId); petUnit.AddComponent(go.gameObject); petUnit.Position = args.unit.Position; HudComponent.Instance.Init(petUnit); Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter { zoneScene = zoneScene, jobType = 0, level = pet.level, name=pet.name, unit=petUnit }) ; } else { long petUnitId = pet.petUnitId; pet.petUnitId = 0; zoneScene.GetComponent().Remove(petUnitId); } await ETTask.CompletedTask; } } }