mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交GAS 打算做一个帧同步的GAS
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 459d02062f69400c85df659d87d8ed9a
|
||||
timeCreated: 1701938994
|
@@ -0,0 +1,12 @@
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public abstract class AbilityTaskBase
|
||||
{
|
||||
protected AbilitySpec _spec;
|
||||
public AbilitySpec Spec => _spec;
|
||||
public virtual void Init(AbilitySpec spec)
|
||||
{
|
||||
_spec = spec;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4936b5b85e340a0ae770d010de0b8d6
|
||||
timeCreated: 1702888759
|
@@ -0,0 +1,21 @@
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public abstract class InstantAbilityTask : AbilityTaskBase
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// 编辑器预览用
|
||||
/// 【注意】 覆写时,记得用UNITY_EDITOR宏包裹,这是预览表现用的函数,不该被编译。
|
||||
/// </summary>
|
||||
public virtual void OnEditorPreview()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
public abstract void OnExecute();
|
||||
}
|
||||
|
||||
public abstract class InstantAbilityTaskT<T> : InstantAbilityTask where T : AbilitySpec
|
||||
{
|
||||
public new T Spec => (T)_spec;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1002d6c36c354bf1845dd82d12e4aca1
|
||||
timeCreated: 1702889566
|
@@ -0,0 +1,28 @@
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public abstract class OngoingAbilityTask : AbilityTaskBase
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// 编辑器预览用
|
||||
/// 【注意】 覆写时,记得用UNITY_EDITOR宏包裹,这是预览表现用的函数,不该被编译。
|
||||
/// </summary>
|
||||
/// <param name="frame"></param>
|
||||
/// <param name="startFrame"></param>
|
||||
/// <param name="endFrame"></param>
|
||||
public virtual void OnEditorPreview(int frame, int startFrame, int endFrame)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
public abstract void OnStart(int startFrame);
|
||||
|
||||
public abstract void OnEnd(int endFrame);
|
||||
|
||||
public abstract void OnTick(int frameIndex, int startFrame, int endFrame);
|
||||
}
|
||||
|
||||
public abstract class OngoingAbilityTaskT<T> : OngoingAbilityTask where T : AbilitySpec
|
||||
{
|
||||
public new T Spec => (T)_spec;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cdf6d03d4434baf93a42aaea7e839be
|
||||
timeCreated: 1702889536
|
@@ -0,0 +1,37 @@
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Ability激活期,总是执行的AbilityTask
|
||||
/// </summary>
|
||||
public abstract class PassiveAbilityTask : AbilityTaskBase
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// 编辑器预览用
|
||||
/// 【注意】 覆写时,记得用UNITY_EDITOR宏包裹,这是预览表现用的函数,不该被编译。
|
||||
/// </summary>
|
||||
/// <param name="frame"></param>
|
||||
/// <param name="startFrame"></param>
|
||||
/// <param name="endFrame"></param>
|
||||
public virtual void OnEditorPreview(int frame, int startFrame, int endFrame)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// 开始执行,仍是Timeline的触发点
|
||||
/// </summary>
|
||||
public abstract void OnStart();
|
||||
|
||||
/// <summary>
|
||||
/// 结束执行,Ability结束激活时,而非Timeline结束时
|
||||
/// </summary>
|
||||
public abstract void OnEnd();
|
||||
|
||||
/// <summary>
|
||||
/// 每帧Tick
|
||||
/// </summary>
|
||||
/// <param name="deltaTime"></param>
|
||||
public abstract void OnTick(int deltaTime);
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a9d88b958e546c7aaef67ab354c71a4
|
||||
timeCreated: 1729189790
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbeb02116afc4e53b4325da574d435c7
|
||||
timeCreated: 1709537763
|
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using GAS.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class AbilityTaskData
|
||||
{
|
||||
public JsonData TaskData;
|
||||
|
||||
public virtual AbilityTaskBase Create(AbilitySpec abilitySpec)
|
||||
{
|
||||
var task = Load();
|
||||
task.Init(abilitySpec);
|
||||
return task;
|
||||
}
|
||||
|
||||
public void Save(AbilityTaskBase task)
|
||||
{
|
||||
var jsonData = JsonUtility.ToJson(task);
|
||||
var dataType = task.GetType().FullName;
|
||||
TaskData = new JsonData
|
||||
{
|
||||
Type = dataType,
|
||||
Data = jsonData
|
||||
};
|
||||
}
|
||||
|
||||
public abstract AbilityTaskBase Load();
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94b0d93e175744309457ec20f699f54d
|
||||
timeCreated: 1709537306
|
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GAS.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class InstantTaskData : AbilityTaskData
|
||||
{
|
||||
public InstantTaskData()
|
||||
{
|
||||
TaskData = new JsonData()
|
||||
{
|
||||
Type = typeof(DefaultInstantAbilityTask).FullName,
|
||||
};
|
||||
}
|
||||
|
||||
public InstantAbilityTask CreateTask(AbilitySpec abilitySpec)
|
||||
{
|
||||
var task = base.Create(abilitySpec);
|
||||
var instantAbilityTask = task as InstantAbilityTask;
|
||||
return instantAbilityTask;
|
||||
}
|
||||
|
||||
public override AbilityTaskBase Load()
|
||||
{
|
||||
InstantAbilityTask task = null;
|
||||
var jsonData = TaskData.Data;
|
||||
var dataType = string.IsNullOrEmpty(TaskData.Type) ? typeof(DefaultInstantAbilityTask).FullName : TaskData.Type;
|
||||
|
||||
var type = InstantTaskSonTypes.FirstOrDefault(sonType => sonType.FullName == dataType);
|
||||
if (type == null)
|
||||
{
|
||||
Debug.LogError("[EX] InstantAbilityTask SonType not found: " + dataType);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
task = Activator.CreateInstance(type) as InstantAbilityTask;
|
||||
else
|
||||
task = JsonUtility.FromJson(jsonData, type) as InstantAbilityTask;
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
#region SonTypes
|
||||
|
||||
private static Type[] _instantTaskSonTypes;
|
||||
|
||||
public static Type[] InstantTaskSonTypes =>
|
||||
_instantTaskSonTypes ??= TypeUtil.GetAllSonTypesOf(typeof(InstantAbilityTask));
|
||||
|
||||
public static List<string> InstantTaskSonTypeChoices
|
||||
{
|
||||
get
|
||||
{
|
||||
return InstantTaskSonTypes.Select(sonType => sonType.FullName).ToList();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 474a7b1c8cea4801abb10dccf9a04a9a
|
||||
timeCreated: 1709537777
|
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GAS.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class OngoingTaskData : AbilityTaskData
|
||||
{
|
||||
public OngoingTaskData()
|
||||
{
|
||||
TaskData = new JsonData()
|
||||
{
|
||||
Type = typeof(DefaultOngoingAbilityTask).FullName,
|
||||
};
|
||||
}
|
||||
|
||||
public OngoingAbilityTask CreateTask(AbilitySpec abilitySpec)
|
||||
{
|
||||
var task = base.Create(abilitySpec);
|
||||
var ongoingAbilityTask = task as OngoingAbilityTask;
|
||||
return ongoingAbilityTask;
|
||||
}
|
||||
|
||||
public override AbilityTaskBase Load()
|
||||
{
|
||||
OngoingAbilityTask task = null;
|
||||
var jsonData = TaskData.Data;
|
||||
var dataType = string.IsNullOrEmpty(TaskData.Type) ? typeof(DefaultOngoingAbilityTask).FullName : TaskData.Type;
|
||||
|
||||
var type = OngoingTaskSonTypes.FirstOrDefault(sonType => sonType.FullName == dataType);
|
||||
if (type == null)
|
||||
{
|
||||
Debug.LogError("[EX] OngoingAbilityTask SonType not found: " + dataType);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
task = Activator.CreateInstance(type) as OngoingAbilityTask;
|
||||
else
|
||||
task = JsonUtility.FromJson(jsonData, type) as OngoingAbilityTask;
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
#region SonTypes
|
||||
|
||||
private static Type[] _ongoingTaskSonTypes;
|
||||
|
||||
public static Type[] OngoingTaskSonTypes =>
|
||||
_ongoingTaskSonTypes ??= TypeUtil.GetAllSonTypesOf(typeof(OngoingAbilityTask));
|
||||
|
||||
public static List<string> OngoingTaskSonTypeChoices
|
||||
{
|
||||
get
|
||||
{
|
||||
return OngoingTaskSonTypes.Select(sonType => sonType.FullName).ToList();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6237a13b66514fb98982b19e91b75259
|
||||
timeCreated: 1709538170
|
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.General;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GAS.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class PassiveTaskData : AbilityTaskData
|
||||
{
|
||||
public PassiveTaskData()
|
||||
{
|
||||
TaskData = new JsonData()
|
||||
{
|
||||
Type = typeof(DefaultPassiveAbilityTask).FullName,
|
||||
};
|
||||
}
|
||||
|
||||
public PassiveAbilityTask CreateTask(AbilitySpec abilitySpec)
|
||||
{
|
||||
var task = base.Create(abilitySpec);
|
||||
var passiveAbilityTask = task as PassiveAbilityTask;
|
||||
return passiveAbilityTask;
|
||||
}
|
||||
|
||||
public override AbilityTaskBase Load()
|
||||
{
|
||||
|
||||
|
||||
PassiveAbilityTask task = null;
|
||||
var jsonData = TaskData.Data;
|
||||
var dataType = string.IsNullOrEmpty(TaskData.Type) ? typeof(DefaultPassiveAbilityTask).FullName : TaskData.Type;
|
||||
|
||||
var type = PassiveTaskSonTypes.FirstOrDefault(sonType => sonType.FullName == dataType);
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
Debug.LogError("[EX] PassiveAbilityTask SonType not found: {0}" + dataType);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
task = Activator.CreateInstance(type) as PassiveAbilityTask;
|
||||
}
|
||||
else
|
||||
{
|
||||
task = JsonUtility.FromJson(jsonData, type) as PassiveAbilityTask;
|
||||
}
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
#region SonTypes
|
||||
|
||||
private static Type[] _passiveTaskSonTypes;
|
||||
|
||||
public static Type[] PassiveTaskSonTypes =>
|
||||
_passiveTaskSonTypes ??= TypeUtil.GetAllSonTypesOf(typeof(PassiveAbilityTask));
|
||||
|
||||
public static List<string> PassiveTaskSonTypeChoices
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = new List<String>();
|
||||
foreach (var sonType in PassiveTaskSonTypes)
|
||||
{
|
||||
list.Add(sonType.FullName);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dce896cd86840d68e56efd1948114f5
|
||||
timeCreated: 1729189740
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a388877ce48c4d0d80d3318fd7b9c0f6
|
||||
timeCreated: 1709277110
|
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class ApplyCostAndCoolDown : InstantAbilityTask
|
||||
{
|
||||
public override void OnExecute()
|
||||
{
|
||||
_spec.DoCost();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c8689e959d44db393a7821d0923f750
|
||||
timeCreated: 1709277143
|
@@ -0,0 +1,9 @@
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public class DefaultInstantAbilityTask : InstantAbilityTask
|
||||
{
|
||||
public override void OnExecute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a33a8f839e2749f3820f585110ffbd58
|
||||
timeCreated: 1709538427
|
@@ -0,0 +1,17 @@
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public class DefaultOngoingAbilityTask : OngoingAbilityTask
|
||||
{
|
||||
public override void OnStart(int startFrame)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnEnd(int endFrame)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnTick(int frameIndex, int startFrame, int endFrame)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb71402b7b0843079876bc5f37e12a11
|
||||
timeCreated: 1709538476
|
@@ -0,0 +1,18 @@
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public class DefaultPassiveAbilityTask : PassiveAbilityTask
|
||||
{
|
||||
public override void OnStart()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnEnd()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnTick(int deltaTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3826985009604c178d6623947f501916
|
||||
timeCreated: 1729189761
|
@@ -0,0 +1,91 @@
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public abstract class TimelineAbilityT<T> : AbstractAbility<T> where T : TimelineAbilityAssetBase
|
||||
{
|
||||
protected TimelineAbilityT(T abilityAsset) : base(abilityAsset)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class TimelineAbilitySpecT<AbilityT, AssetT> : AbilitySpec<AbilityT> where AbilityT : TimelineAbilityT<AssetT> where AssetT : TimelineAbilityAssetBase
|
||||
{
|
||||
protected TimelineAbilityPlayer<AbilityT, AssetT> _player;
|
||||
|
||||
public int FrameCount => _player.FrameCount;
|
||||
public int FrameRate => _player.FrameRate;
|
||||
|
||||
/// <summary>
|
||||
/// 不受播放速率影响的总时间
|
||||
/// </summary>
|
||||
public float TotalTime => _player.TotalTime;
|
||||
|
||||
/// <summary>
|
||||
/// 向性技能的作用目标
|
||||
/// </summary>
|
||||
public AbilitySystemComponent Target { get; private set; }
|
||||
|
||||
protected TimelineAbilitySpecT(AbilityT ability, AbilitySystemComponent owner) : base(ability, owner)
|
||||
{
|
||||
_player = new(this);
|
||||
}
|
||||
|
||||
public void SetAbilityTarget(AbilitySystemComponent mainTarget)
|
||||
{
|
||||
Target = mainTarget;
|
||||
}
|
||||
|
||||
public override void ActivateAbility()
|
||||
{
|
||||
_player.Play();
|
||||
}
|
||||
|
||||
public virtual float GetPlaySpeed()
|
||||
{
|
||||
return Data.AbilityAsset.Speed;
|
||||
}
|
||||
|
||||
public override void CancelAbility()
|
||||
{
|
||||
_player.Stop();
|
||||
}
|
||||
|
||||
public override void EndAbility()
|
||||
{
|
||||
_player.Stop();
|
||||
}
|
||||
|
||||
protected override void AbilityTick()
|
||||
{
|
||||
Profiler.BeginSample("TimelineAbilitySpecT<T>::AbilityTick()");
|
||||
_player.Tick();
|
||||
Profiler.EndSample();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 这是一个最朴素的TimelineAbility实现, 如果要实现更复杂的TimelineAbility, 请用TimelineAbilityT和TimelineAbilitySpecT为基类
|
||||
/// </summary>
|
||||
public sealed class TimelineAbility : TimelineAbilityT<TimelineAbilityAsset>
|
||||
{
|
||||
public TimelineAbility(TimelineAbilityAsset abilityAsset) : base(abilityAsset)
|
||||
{
|
||||
}
|
||||
|
||||
public override AbilitySpec CreateSpec(AbilitySystemComponent owner)
|
||||
{
|
||||
return new TimelineAbilitySpec(this, owner);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 这是一个最朴素的TimelineAbilitySpec实现, 如果要实现更复杂的TimelineAbility, 请用TimelineAbilityT和TimelineAbilitySpecT为基类
|
||||
/// </summary>
|
||||
public sealed class TimelineAbilitySpec : TimelineAbilitySpecT<TimelineAbilityT<TimelineAbilityAsset>, TimelineAbilityAsset>
|
||||
{
|
||||
public TimelineAbilitySpec(TimelineAbilityT<TimelineAbilityAsset> ability, AbilitySystemComponent owner) : base(ability, owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5e9c13b27a641ee81a8faa360da21e2
|
||||
timeCreated: 1708250442
|
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using GAS.General;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public abstract class TimelineAbilityAssetBase : AbilityAsset
|
||||
{
|
||||
[TitleGroup("Data")]
|
||||
[HorizontalGroup("Data/H1", 1 / 3f)]
|
||||
[TabGroup("Data/H1/V1", "Timeline", SdfIconType.ClockHistory, TextColor = "#00FF00")]
|
||||
[Button("查看/编辑能力时间轴", ButtonSizes.Large, Icon = SdfIconType.Hammer)]
|
||||
[PropertyOrder(-1)]
|
||||
private void EditAbilityTimeline()
|
||||
{
|
||||
try
|
||||
{
|
||||
var assembly = Assembly.Load("com.exhard.exgas.editor");
|
||||
var type = assembly.GetType("GAS.Editor.AbilityTimelineEditorWindow");
|
||||
var methodInfo = type.GetMethod("ShowWindow", BindingFlags.Public | BindingFlags.Static);
|
||||
methodInfo!.Invoke(null, new object[] { this });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(
|
||||
$"调用\"GAS.Editor.AbilityTimelineEditorWindow\"类的静态方法ShowWindow(TimelineAbilityAsset asset)失败, 代码可能被重构了: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放速率, 常用于加速或减速播放(例如基于攻击速度的技能, 播放速率随攻击速度变化)
|
||||
/// </summary>
|
||||
[TabGroup("Data/H1/V1", "Timeline")]
|
||||
[LabelText(GASTextDefine.ABILITY_PLAY_RATE)]
|
||||
[LabelWidth(100)]
|
||||
[MinValue(0)]
|
||||
public float Speed = 1.0f;
|
||||
|
||||
[TabGroup("Data/H1/V1", "Timeline")]
|
||||
[LabelText(GASTextDefine.ABILITY_MANUAL_ENDABILITY)]
|
||||
[LabelWidth(100)]
|
||||
[FormerlySerializedAs("manualEndAbility")]
|
||||
public bool ManualEndAbility;
|
||||
|
||||
[HideInInspector]
|
||||
public int FrameCount; // 能力结束时间
|
||||
|
||||
[HideInInspector]
|
||||
public List<DurationalCueTrackData> DurationalCues = new List<DurationalCueTrackData>();
|
||||
|
||||
[HideInInspector]
|
||||
public List<InstantCueTrackData> InstantCues = new List<InstantCueTrackData>();
|
||||
|
||||
[HideInInspector]
|
||||
public List<ReleaseGameplayEffectTrackData> ReleaseGameplayEffect = new List<ReleaseGameplayEffectTrackData>();
|
||||
|
||||
[HideInInspector]
|
||||
public List<BuffGameplayEffectTrackData> BuffGameplayEffects = new List<BuffGameplayEffectTrackData>();
|
||||
|
||||
[HideInInspector]
|
||||
public List<TaskMarkEventTrackData> InstantTasks = new List<TaskMarkEventTrackData>();
|
||||
|
||||
[HideInInspector]
|
||||
public List<TaskClipEventTrackData> OngoingTasks = new List<TaskClipEventTrackData>();
|
||||
|
||||
[HideInInspector]
|
||||
public List<PassiveGameplayEffectTrackData> PassiveGameplayEffects = new List<PassiveGameplayEffectTrackData>();
|
||||
|
||||
[HideInInspector]
|
||||
public List<PassiveTaskClipEventTrackData> PassiveTasks = new List<PassiveTaskClipEventTrackData>();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void Save()
|
||||
{
|
||||
EditorUtility.SetDirty(this);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public abstract class TimelineAbilityAssetT<T> : TimelineAbilityAssetBase where T : class
|
||||
{
|
||||
public sealed override Type AbilityType()
|
||||
{
|
||||
return typeof(T);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 这是一个最朴素的TimelineAbilityAsset实现, 如果要实现更复杂的TimelineAbilityAsset, 请用TimelineAbilityAssetBase或TimelineAbilityAssetT为基类
|
||||
/// </summary>
|
||||
public sealed class TimelineAbilityAsset : TimelineAbilityAssetT<TimelineAbility>
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d763af469c524557946c477b9bea3a46
|
||||
timeCreated: 1708250516
|
@@ -0,0 +1,428 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.General;
|
||||
using UnityEngine;
|
||||
|
||||
//using UnityEngine.Profiling;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
internal abstract class RuntimeClipInfo
|
||||
{
|
||||
public int endFrame;
|
||||
public int startFrame;
|
||||
}
|
||||
|
||||
internal class RuntimeDurationCueClip : RuntimeClipInfo
|
||||
{
|
||||
public GameplayCueDurationalSpec cueSpec;
|
||||
}
|
||||
|
||||
internal class RuntimeBuffClip : RuntimeClipInfo
|
||||
{
|
||||
public GameplayEffect buff;
|
||||
public EntityRef<GameplayEffectSpec> buffSpec;
|
||||
}
|
||||
|
||||
internal class RuntimeTaskClip : RuntimeClipInfo
|
||||
{
|
||||
public OngoingAbilityTask task;
|
||||
}
|
||||
|
||||
internal class RuntimeTaskMark
|
||||
{
|
||||
public int startFrame;
|
||||
public InstantAbilityTask task;
|
||||
}
|
||||
|
||||
public class TimelineAbilityPlayer<AbilityT, AssetT> where AssetT : TimelineAbilityAssetBase where AbilityT : TimelineAbilityT<AssetT>
|
||||
{
|
||||
private readonly TimelineAbilitySpecT<AbilityT, AssetT> _abilitySpec;
|
||||
private readonly List<RuntimeBuffClip> _cacheBuffGameplayEffectTrack = new();
|
||||
|
||||
private readonly List<RuntimeDurationCueClip> _cacheDurationalCueTrack = new();
|
||||
|
||||
private readonly List<InstantCueMarkEvent> _cacheInstantCues = new();
|
||||
|
||||
private readonly List<RuntimeTaskMark> _cacheInstantTasks = new();
|
||||
private readonly List<RuntimeTaskClip> _cacheOngoingTaskTrack = new();
|
||||
|
||||
private readonly List<ReleaseGameplayEffectMarkEvent> _cacheReleaseGameplayEffect = new();
|
||||
|
||||
// cache for target catcher, avoid new in TickFrame
|
||||
// 这个是一个泛型类, 这个变量就不作为static了
|
||||
private readonly List<AbilitySystemComponent> _targets = new();
|
||||
|
||||
private int _currentFrame;
|
||||
private float _playTotalTime;
|
||||
|
||||
public TimelineAbilityPlayer(TimelineAbilitySpecT<AbilityT, AssetT> abilitySpec)
|
||||
{
|
||||
_abilitySpec = abilitySpec;
|
||||
Cache();
|
||||
}
|
||||
|
||||
public bool IsPlaying { get; private set; }
|
||||
|
||||
public AssetT AbilityAsset => _abilitySpec.Data.AbilityAsset;
|
||||
public int FrameCount => AbilityAsset.FrameCount;
|
||||
public int FrameRate => GASTimer.FrameRate;
|
||||
|
||||
/// <summary>
|
||||
/// 不受播放速率影响的总时间
|
||||
/// </summary>
|
||||
public float TotalTime => (float)FrameCount / FrameRate;
|
||||
|
||||
private void Cache()
|
||||
{
|
||||
Cache_InstantCues();
|
||||
Cache_ReleaseGameplayEffects();
|
||||
Cache_InstantTasks();
|
||||
Cache_DurationalGameplayCues();
|
||||
Cache_BuffGameplayEffects();
|
||||
Cache_OngoingTasks();
|
||||
}
|
||||
|
||||
private void Cache_InstantCues()
|
||||
{
|
||||
_cacheInstantCues.Clear();
|
||||
foreach (var trackData in AbilityAsset.InstantCues)
|
||||
{
|
||||
_cacheInstantCues.AddRange(trackData.markEvents);
|
||||
}
|
||||
|
||||
_cacheInstantCues.Sort((a, b) => a.startFrame.CompareTo(b.startFrame));
|
||||
}
|
||||
|
||||
private void Cache_ReleaseGameplayEffects()
|
||||
{
|
||||
_cacheReleaseGameplayEffect.Clear();
|
||||
foreach (var trackData in AbilityAsset.ReleaseGameplayEffect)
|
||||
{
|
||||
_cacheReleaseGameplayEffect.AddRange(trackData.markEvents);
|
||||
}
|
||||
|
||||
_cacheReleaseGameplayEffect.Sort((a, b) => a.startFrame.CompareTo(b.startFrame));
|
||||
foreach (var releaseGameplayEffectMarkEvent in _cacheReleaseGameplayEffect)
|
||||
{
|
||||
releaseGameplayEffectMarkEvent.CacheTargetCatcher();
|
||||
}
|
||||
}
|
||||
|
||||
private void Cache_InstantTasks()
|
||||
{
|
||||
_cacheInstantTasks.Clear();
|
||||
foreach (var trackData in AbilityAsset.InstantTasks)
|
||||
{
|
||||
foreach (var markEvent in trackData.markEvents)
|
||||
{
|
||||
foreach (var taskData in markEvent.InstantTasks)
|
||||
{
|
||||
var runtimeTaskMark = new RuntimeTaskMark
|
||||
{
|
||||
startFrame = markEvent.startFrame,
|
||||
task = taskData.CreateTask(_abilitySpec)
|
||||
};
|
||||
_cacheInstantTasks.Add(runtimeTaskMark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_cacheInstantTasks.Sort((a, b) => a.startFrame.CompareTo(b.startFrame));
|
||||
}
|
||||
|
||||
private void Cache_DurationalGameplayCues()
|
||||
{
|
||||
_cacheDurationalCueTrack.Clear();
|
||||
foreach (var track in AbilityAsset.DurationalCues)
|
||||
{
|
||||
foreach (var clipEvent in track.clipEvents)
|
||||
{
|
||||
var cueSpec = clipEvent.cue.ApplyFrom(_abilitySpec);
|
||||
if (cueSpec == null) continue;
|
||||
var runtimeDurationCueClip = new RuntimeDurationCueClip
|
||||
{
|
||||
startFrame = clipEvent.startFrame,
|
||||
endFrame = clipEvent.EndFrame,
|
||||
cueSpec = cueSpec
|
||||
};
|
||||
_cacheDurationalCueTrack.Add(runtimeDurationCueClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Cache_BuffGameplayEffects()
|
||||
{
|
||||
_cacheBuffGameplayEffectTrack.Clear();
|
||||
foreach (var track in AbilityAsset.BuffGameplayEffects)
|
||||
{
|
||||
foreach (var clipEvent in track.clipEvents)
|
||||
{
|
||||
// 只有持续型的GameplayEffect可视作buff
|
||||
if (clipEvent.gameplayEffect.DurationPolicy is EffectsDurationPolicy.Duration
|
||||
or EffectsDurationPolicy.Infinite)
|
||||
{
|
||||
var runtimeBuffClip = new RuntimeBuffClip
|
||||
{
|
||||
startFrame = clipEvent.startFrame,
|
||||
endFrame = clipEvent.EndFrame,
|
||||
buff = clipEvent.gameplayEffect.SharedInstance,
|
||||
buffSpec = default
|
||||
};
|
||||
_cacheBuffGameplayEffectTrack.Add(runtimeBuffClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Cache_OngoingTasks()
|
||||
{
|
||||
_cacheOngoingTaskTrack.Clear();
|
||||
foreach (var track in AbilityAsset.OngoingTasks)
|
||||
{
|
||||
foreach (var clip in track.clipEvents)
|
||||
{
|
||||
var runtimeTaskClip = new RuntimeTaskClip
|
||||
{
|
||||
startFrame = clip.startFrame,
|
||||
endFrame = clip.EndFrame,
|
||||
task = clip.ongoingTask.CreateTask(_abilitySpec)
|
||||
};
|
||||
_cacheOngoingTaskTrack.Add(runtimeTaskClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Prepare()
|
||||
{
|
||||
foreach (var runtimeBuffClip in _cacheBuffGameplayEffectTrack)
|
||||
{
|
||||
runtimeBuffClip.buffSpec.Value?.Recycle();
|
||||
runtimeBuffClip.buffSpec = default;
|
||||
}
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
_currentFrame = -1; // 为了播放第0帧
|
||||
_playTotalTime = 0;
|
||||
IsPlaying = true;
|
||||
Prepare();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (!IsPlaying) return;
|
||||
|
||||
foreach (var clip in _cacheDurationalCueTrack)
|
||||
{
|
||||
if (_currentFrame <= clip.endFrame)
|
||||
clip.cueSpec.OnRemove();
|
||||
}
|
||||
|
||||
foreach (var clip in _cacheBuffGameplayEffectTrack)
|
||||
{
|
||||
var spec = clip.buffSpec.Value;
|
||||
if (spec != null)
|
||||
{
|
||||
_abilitySpec.Owner.RemoveGameplayEffect(spec);
|
||||
spec.Recycle();
|
||||
}
|
||||
|
||||
clip.buffSpec = default;
|
||||
}
|
||||
|
||||
foreach (var clip in _cacheOngoingTaskTrack)
|
||||
{
|
||||
clip.task.OnEnd(clip.endFrame);
|
||||
}
|
||||
|
||||
IsPlaying = false;
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if (!IsPlaying) return;
|
||||
|
||||
var speed = _abilitySpec.GetPlaySpeed();
|
||||
speed = Math.Max(0, speed);
|
||||
_playTotalTime += Time.deltaTime * speed;
|
||||
var targetFrame = (int)(_playTotalTime * FrameRate);
|
||||
|
||||
// 追帧
|
||||
while (_currentFrame < targetFrame)
|
||||
{
|
||||
_currentFrame++;
|
||||
TickFrame(_currentFrame);
|
||||
}
|
||||
|
||||
if (_currentFrame >= FrameCount)
|
||||
{
|
||||
_currentFrame++; //确保不重复触发cue的onRemove
|
||||
OnPlayEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放结束
|
||||
/// </summary>
|
||||
private void OnPlayEnd()
|
||||
{
|
||||
IsPlaying = false;
|
||||
|
||||
if (!AbilityAsset.ManualEndAbility)
|
||||
_abilitySpec.TryEndAbility();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前帧的事件
|
||||
/// </summary>
|
||||
/// <param name="frame"></param>
|
||||
private void TickFrame(int frame)
|
||||
{
|
||||
TickFrame_InstantGameplayCues(frame);
|
||||
TickFrame_ReleaseGameplayEffects(frame);
|
||||
TickFrame_InstantTasks(frame);
|
||||
TickFrame_DurationalGameplayCues(frame);
|
||||
TickFrame_BuffGameplayEffects(frame);
|
||||
TickFrame_OngoingTasks(frame);
|
||||
}
|
||||
|
||||
private void TickFrame_InstantGameplayCues(int frame)
|
||||
{
|
||||
foreach (var cueMark in _cacheInstantCues)
|
||||
{
|
||||
if (frame == cueMark.startFrame)
|
||||
{
|
||||
foreach (var cue in cueMark.cues)
|
||||
{
|
||||
cue.ApplyFrom(_abilitySpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TickFrame_ReleaseGameplayEffects(int frame)
|
||||
{
|
||||
foreach (var mark in _cacheReleaseGameplayEffect)
|
||||
{
|
||||
if (frame == mark.startFrame)
|
||||
{
|
||||
var catcher = mark.TargetCatcher;
|
||||
catcher.Init(_abilitySpec.Owner);
|
||||
|
||||
catcher.CatchTargetsNonAllocSafe(_abilitySpec.Target, _targets);
|
||||
|
||||
foreach (var asc in _targets)
|
||||
{
|
||||
foreach (var gea in mark.gameplayEffectAssets)
|
||||
{
|
||||
var ge = gea.SharedInstance;
|
||||
_abilitySpec.Owner.ApplyGameplayEffectTo(ge, asc);
|
||||
}
|
||||
}
|
||||
|
||||
_targets.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TickFrame_InstantTasks(int frame)
|
||||
{
|
||||
foreach (var instantTask in _cacheInstantTasks)
|
||||
{
|
||||
if (frame == instantTask.startFrame)
|
||||
{
|
||||
instantTask.task.OnExecute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TickFrame_DurationalGameplayCues(int frame)
|
||||
{
|
||||
foreach (var cueClip in _cacheDurationalCueTrack)
|
||||
{
|
||||
if (frame == cueClip.startFrame)
|
||||
{
|
||||
cueClip.cueSpec.OnAdd();
|
||||
}
|
||||
|
||||
if (frame >= cueClip.startFrame && frame <= cueClip.endFrame)
|
||||
{
|
||||
cueClip.cueSpec.OnTick();
|
||||
}
|
||||
|
||||
if (frame == cueClip.endFrame)
|
||||
{
|
||||
cueClip.cueSpec.OnRemove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TickFrame_BuffGameplayEffects(int frame)
|
||||
{
|
||||
// buff持续时间以Timeline配置时间为准(执行策略全部改为Infinite)
|
||||
// Profiler.BeginSample("TickFrame_BuffGameplayEffects");
|
||||
// {
|
||||
foreach (var buffClip in _cacheBuffGameplayEffectTrack)
|
||||
{
|
||||
if (frame == buffClip.startFrame)
|
||||
{
|
||||
//Profiler.BeginSample("buffGameplayEffect.Start");
|
||||
var buffSpec = _abilitySpec.Owner.ApplyGameplayEffectToSelf(buffClip.buff);
|
||||
buffSpec.Value.SetDurationPolicy(EffectsDurationPolicy.Infinite);
|
||||
buffClip.buffSpec = buffSpec;
|
||||
//Profiler.EndSample();
|
||||
}
|
||||
|
||||
if (frame == buffClip.endFrame)
|
||||
{
|
||||
var spec = buffClip.buffSpec.Value;
|
||||
if (spec != null)
|
||||
{
|
||||
//Profiler.BeginSample("buffGameplayEffect.End");
|
||||
_abilitySpec.Owner.RemoveGameplayEffect(spec);
|
||||
//Profiler.EndSample();
|
||||
spec.Recycle();
|
||||
}
|
||||
|
||||
buffClip.buffSpec = default;
|
||||
}
|
||||
}
|
||||
// }
|
||||
// Profiler.EndSample();
|
||||
}
|
||||
|
||||
private void TickFrame_OngoingTasks(int frame)
|
||||
{
|
||||
// Profiler.BeginSample("TickFrame_OngoingTasks");
|
||||
// {
|
||||
foreach (var taskClip in _cacheOngoingTaskTrack)
|
||||
{
|
||||
if (frame == taskClip.startFrame)
|
||||
{
|
||||
//Profiler.BeginSample("Ongoing Task.OnStart()");
|
||||
taskClip.task.OnStart(frame);
|
||||
//Profiler.EndSample();
|
||||
}
|
||||
|
||||
if (frame >= taskClip.startFrame && frame <= taskClip.endFrame)
|
||||
{
|
||||
//Profiler.BeginSample("Ongoing Task.OnTick()");
|
||||
taskClip.task.OnTick(frame, taskClip.startFrame, taskClip.endFrame);
|
||||
//Profiler.EndSample();
|
||||
}
|
||||
|
||||
if (frame == taskClip.endFrame)
|
||||
{
|
||||
//Profiler.BeginSample("Ongoing Task.OnEnd()");
|
||||
taskClip.task.OnEnd(frame);
|
||||
//Profiler.EndSample();
|
||||
}
|
||||
}
|
||||
// }
|
||||
// Profiler.EndSample();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b17a33afb534946b70239808a6015eb
|
||||
timeCreated: 1708672766
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3cfd0d21847f461d96661a737d97d32e
|
||||
timeCreated: 1708504113
|
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.Runtime;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class BuffGameplayEffectTrackData:TrackDataBase
|
||||
{
|
||||
public List<BuffGameplayEffectClipEvent> clipEvents = new List<BuffGameplayEffectClipEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.BuffGameplayEffects.Add(this);
|
||||
}
|
||||
|
||||
public override void DefaultInit()
|
||||
{
|
||||
base.DefaultInit();
|
||||
trackName = "Buff";
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class BuffGameplayEffectClipEvent : ClipEventBase
|
||||
{
|
||||
public BuffTarget buffTarget;
|
||||
[FormerlySerializedAs("gameplayEffects")] public GameplayEffectAsset gameplayEffect;
|
||||
}
|
||||
|
||||
public enum BuffTarget
|
||||
{
|
||||
Self,
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5742faeb4aee4f058f69e6b0922a540d
|
||||
timeCreated: 1709018398
|
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.Runtime;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class DurationalCueTrackData:TrackDataBase
|
||||
{
|
||||
public List<DurationalCueClipEvent> clipEvents = new List<DurationalCueClipEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.DurationalCues.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class DurationalCueClipEvent : ClipEventBase
|
||||
{
|
||||
public GameplayCueDurational cue;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eda585ff2c7143d8bfcb34857b7cc068
|
||||
timeCreated: 1709017864
|
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.Runtime;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class InstantCueTrackData:TrackDataBase
|
||||
{
|
||||
public List<InstantCueMarkEvent> markEvents = new List<InstantCueMarkEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.InstantCues.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class InstantCueMarkEvent:MarkEventBase
|
||||
{
|
||||
public List<GameplayCueInstant> cues = new List<GameplayCueInstant>();
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2f9017c20dc4fc5b36fa15ba97371df
|
||||
timeCreated: 1709106070
|
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class PassiveGameplayEffectTrackData : TrackDataBase
|
||||
{
|
||||
public List<PassiveGameplayEffectClipEvent> clipEvents = new List<PassiveGameplayEffectClipEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.PassiveGameplayEffects.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PassiveGameplayEffectClipEvent : ClipEventBase
|
||||
{
|
||||
[FormerlySerializedAs("GameplayEffectValueId")]
|
||||
public int gameplayEffectValueId;
|
||||
public GameplayEffectAsset gameplayEffect;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ece82d688852440699c4a50ee47a671e
|
||||
timeCreated: 1729189527
|
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class PassiveTaskClipEventTrackData : TrackDataBase
|
||||
{
|
||||
public List<PassiveTaskClipEvent> clipEvents = new List<PassiveTaskClipEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.PassiveTasks.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PassiveTaskClipEvent : ClipEventBase
|
||||
{
|
||||
public PassiveTaskData passiveTask;
|
||||
|
||||
public PassiveAbilityTask Load()
|
||||
{
|
||||
return passiveTask.Load() as PassiveAbilityTask;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6a98a9a0278441cada7de695771be21
|
||||
timeCreated: 1729189725
|
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class ReleaseGameplayEffectTrackData : TrackDataBase
|
||||
{
|
||||
public List<ReleaseGameplayEffectMarkEvent> markEvents = new List<ReleaseGameplayEffectMarkEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.ReleaseGameplayEffect.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ReleaseGameplayEffectMarkEvent : MarkEventBase
|
||||
{
|
||||
public JsonData jsonTargetCatcher = new JsonData()
|
||||
{
|
||||
Type = typeof(CatchSelf).FullName // 默认 CatchSelf
|
||||
};
|
||||
|
||||
public List<GameplayEffectAsset> gameplayEffectAssets = new List<GameplayEffectAsset>();
|
||||
|
||||
|
||||
private TargetCatcherBase _targetCatcher;
|
||||
public TargetCatcherBase TargetCatcher
|
||||
{
|
||||
get
|
||||
{
|
||||
// 如果是反序列化的数据,没有执行构造函数, 需要加载
|
||||
_targetCatcher ??= LoadTargetCatcher();
|
||||
return _targetCatcher;
|
||||
}
|
||||
}
|
||||
|
||||
public void CacheTargetCatcher()
|
||||
{
|
||||
_targetCatcher = LoadTargetCatcher();
|
||||
}
|
||||
|
||||
public void SaveTargetCatcher(TargetCatcherBase targetCatcher)
|
||||
{
|
||||
var jsonData = JsonUtility.ToJson(targetCatcher);
|
||||
var dataType = targetCatcher.GetType().FullName;
|
||||
jsonTargetCatcher = new JsonData
|
||||
{
|
||||
Type = dataType,
|
||||
Data = jsonData
|
||||
};
|
||||
}
|
||||
|
||||
public TargetCatcherBase LoadTargetCatcher()
|
||||
{
|
||||
TargetCatcherBase targetCatcher = null;
|
||||
var jsonData = jsonTargetCatcher.Data;
|
||||
var dataType = jsonTargetCatcher.Type;
|
||||
|
||||
Type type = null;
|
||||
foreach (var t in TargetCatcherSonTypes)
|
||||
{
|
||||
if (t.FullName == dataType)
|
||||
{
|
||||
type = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
Debug.LogError("[EX] TargetCatcherBase SonType not found: " + dataType);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
targetCatcher = Activator.CreateInstance(type) as TargetCatcherBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetCatcher = JsonUtility.FromJson(jsonData, type) as TargetCatcherBase;
|
||||
}
|
||||
}
|
||||
|
||||
return targetCatcher;
|
||||
}
|
||||
|
||||
#region TargetCatcher SonTypes
|
||||
|
||||
private static Type[] _targetCatcherSonTypes;
|
||||
|
||||
public static Type[] TargetCatcherSonTypes =>
|
||||
_targetCatcherSonTypes ??= TypeUtil.GetAllSonTypesOf(typeof(TargetCatcherBase));
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
// public enum LockMethod
|
||||
// {
|
||||
// Self,
|
||||
// Circle2D,
|
||||
// Box2D,
|
||||
// Sphere3D,
|
||||
// Box3D,
|
||||
// Custom
|
||||
// }
|
||||
//
|
||||
// public enum CenterType
|
||||
// {
|
||||
// Relative,
|
||||
// WorldSpace
|
||||
// }
|
||||
//
|
||||
// [Serializable]
|
||||
// public class LockOnTargetMethod
|
||||
// {
|
||||
// public LockMethod method;
|
||||
//
|
||||
// // 检测碰撞
|
||||
// public LayerMask checkLayer;
|
||||
// public CenterType centerType;
|
||||
//
|
||||
// public Vector3 center;
|
||||
//
|
||||
// // Circle2D,Sphere3D
|
||||
// public float radius;
|
||||
//
|
||||
// // Box2D,Box3D
|
||||
// public Vector3 size;
|
||||
//
|
||||
// // Custom
|
||||
// public string customMethodRegisterKey;
|
||||
// }
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd623f4d1cda4cca925861de81dec26a
|
||||
timeCreated: 1709134057
|
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.Runtime;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class TaskClipEventTrackData:TrackDataBase
|
||||
{
|
||||
public List<TaskClipEvent> clipEvents = new List<TaskClipEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.OngoingTasks.Add(this);
|
||||
}
|
||||
|
||||
public override void DefaultInit()
|
||||
{
|
||||
base.DefaultInit();
|
||||
trackName = "Task Clips";
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class TaskClipEvent : ClipEventBase
|
||||
{
|
||||
public OngoingTaskData ongoingTask;
|
||||
|
||||
public OngoingAbilityTask Load()
|
||||
{
|
||||
return ongoingTask.Load() as OngoingAbilityTask;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1768937addbc4d9f8d41e4fd0f8b244b
|
||||
timeCreated: 1709188720
|
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.Runtime;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class TaskMarkEventTrackData : TrackDataBase
|
||||
{
|
||||
public List<TaskMarkEvent> markEvents = new List<TaskMarkEvent>();
|
||||
|
||||
public override void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
base.AddToAbilityAsset(abilityAsset);
|
||||
abilityAsset.InstantTasks.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class TaskMarkEvent:MarkEventBase
|
||||
{
|
||||
public List<InstantTaskData> InstantTasks = new List<InstantTaskData>();
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af15d283c4a24926bc40197f96a859f6
|
||||
timeCreated: 1709188733
|
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class TrackDataBase
|
||||
{
|
||||
public string trackName;
|
||||
|
||||
public virtual void AddToAbilityAsset(TimelineAbilityAssetBase abilityAsset)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void DefaultInit()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a32efd9a68f4192a3531ed7c05576d5
|
||||
timeCreated: 1709018475
|
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class TrackEventBase
|
||||
{
|
||||
public int startFrame;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class MarkEventBase:TrackEventBase
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class ClipEventBase:TrackEventBase
|
||||
{
|
||||
public int durationFrame;
|
||||
public int EndFrame => startFrame + durationFrame;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8307d7f9f424132a2d448a75c22fa63
|
||||
timeCreated: 1708504213
|
Reference in New Issue
Block a user