You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.9 KiB
107 lines
2.9 KiB
using AOT;
|
|
using CoreGame;
|
|
using Sog;
|
|
using UnityEngine;
|
|
using YooAsset;
|
|
|
|
namespace GAS.Runtime
|
|
{
|
|
/// <summary>
|
|
/// 特化cue
|
|
/// </summary>
|
|
public class BeHitCue : GameplayCueDurational
|
|
{
|
|
public string matPath = "Assets/RawResources/Materals/CommonBeHit.mat";
|
|
public override GameplayCueDurationalSpec CreateSpec(in GameplayCueParameters param)
|
|
{
|
|
var beHitCueSpec = SptPool<BeHitCueSpec>.Malloc();
|
|
beHitCueSpec.Awake(param);
|
|
return beHitCueSpec;
|
|
}
|
|
|
|
public override void FreeSpec(ref GameplayCueDurationalSpec spec)
|
|
{
|
|
var beHitCueSpec = spec as BeHitCueSpec;
|
|
SptPool<BeHitCueSpec>.Free(ref beHitCueSpec);
|
|
spec = null;
|
|
}
|
|
}
|
|
|
|
public class BeHitCueSpec : GameplayCueDurationalSpec<BeHitCue>
|
|
{
|
|
public static Material beHitMat;
|
|
|
|
public override void OnAdd()
|
|
{
|
|
var effectShowProxy = ownerEnt.effectShowProxy;
|
|
if (effectShowProxy == null)
|
|
{
|
|
return;
|
|
}
|
|
if (beHitMat == null)
|
|
{
|
|
var ah = GameObjectUtil.LoadAssetAsync<Material>(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<Material>();
|
|
}
|
|
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)
|
|
{
|
|
}
|
|
}
|
|
}
|