using AOT; using CoreGame; using Sog; using UnityEngine; using YooAsset; namespace GAS.Runtime { /// /// 特化cue /// public class BeHitCue : GameplayCueDurational { public string matPath = "Assets/RawResources/Materals/CommonBeHit.mat"; public override GameplayCueDurationalSpec CreateSpec(in GameplayCueParameters param) { var beHitCueSpec = SptPool.Malloc(); beHitCueSpec.Awake(param); return beHitCueSpec; } public override void FreeSpec(ref GameplayCueDurationalSpec spec) { var beHitCueSpec = spec as BeHitCueSpec; SptPool.Free(ref beHitCueSpec); spec = null; } } public class BeHitCueSpec : GameplayCueDurationalSpec { public static Material beHitMat; public override void OnAdd() { var effectShowProxy = ownerEnt.effectShowProxy; if (effectShowProxy == null) { return; } if (beHitMat == null) { var ah = GameObjectUtil.LoadAssetAsync(cue.matPath, effectShowProxy.go, null); if (ah.IsDone) { OnMatLoaded(ah, ownerEnt.creationIndex); } else { int eid = ownerEnt.creationIndex; ah.Completed += handle => { OnMatLoaded(handle, eid); }; } } else { effectShowProxy.PushMat(beHitMat); } } private void OnMatLoaded(AssetHandle assetHandle, int eid) { if (beHitMat == null) { beHitMat = assetHandle.GetAssetObject(); } var combatEntity = Contexts.Combat.GetEntity(eid); if (combatEntity == null || combatEntity.IsValid == false) { return; } var effectShowProxy = combatEntity.effectShowProxy; if (effectShowProxy == null) { return; } effectShowProxy.PushMat(beHitMat); } public override void OnRemove() { var effectShowProxy = ownerEnt.effectShowProxy; if (effectShowProxy == null) { return; } effectShowProxy.PopMat(); } public override void OnGameplayEffectActivate() { throw new System.NotImplementedException(); } public override void OnGameplayEffectDeactivate() { } public override void OnTick(Fixed64 dt) { } } }