提交GAS 打算做一个帧同步的GAS

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-10-18 03:16:09 +08:00
parent b0a2e4a900
commit d9b0c78827
726 changed files with 76601 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
using System.Linq;
using GAS.General;
using Sirenix.OdinInspector;
using UnityEngine;
namespace GAS.Runtime
{
public abstract class GameplayCue : ScriptableObject
{
protected const int WIDTH_LABEL = 70;
[TitleGroup("Base")]
[HorizontalGroup("Base/H1")]
[TabGroup("Base/H1/V1", "Summary", SdfIconType.InfoSquareFill, TextColor = "#0BFFC5", Order = 1)]
[HideLabel]
[MultiLineProperty(10)]
public string Description;
#if UNITY_EDITOR
[TabGroup("Base/H1/V2", "General", SdfIconType.AwardFill, TextColor = "#FF7F00", Order = 2)]
[TabGroup("Base/H1/V2", "Detail", SdfIconType.TicketDetailedFill, TextColor = "#BC2FDE")]
[LabelText("类型名称", SdfIconType.FileCodeFill)]
[LabelWidth(WIDTH_LABEL)]
[ShowInInspector]
[PropertyOrder(-1)]
public string TypeName => GetType().Name;
[TabGroup("Base/H1/V2", "Detail")]
[LabelText("类型全名", SdfIconType.FileCodeFill)]
[LabelWidth(WIDTH_LABEL)]
[ShowInInspector]
[PropertyOrder(-1)]
public string TypeFullName => GetType().FullName;
[TabGroup("Base/H1/V2", "Detail")]
[ListDrawerSettings(ShowFoldout = true, ShowItemCount = false, ShowPaging = false)]
[ShowInInspector]
[LabelText("继承关系")]
[LabelWidth(WIDTH_LABEL)]
[PropertyOrder(-1)]
public string[] InheritanceChain => GetType().GetInheritanceChain().Reverse().ToArray();
#endif
// Tags
[TabGroup("Base/H1/V3", "Tags", SdfIconType.TagsFill, TextColor = "#45B1FF", Order = 3)]
[ValueDropdown("@ValueDropdownHelper.GameplayTagChoices", IsUniqueList = true, HideChildProperties = true)]
[ListDrawerSettings(ShowFoldout = true, ShowItemCount = false, DraggableItems = false)]
[DisableContextMenu(disableForMember: false, disableCollectionElements: true)]
[CustomContextMenu("排序", "@RequiredTags = TagHelper.Sort($value)")]
[LabelText("RequiredTags - 持有所有标签才可触发")]
public GameplayTag[] RequiredTags;
[TabGroup("Base/H1/V3", "Tags")]
[ValueDropdown("@ValueDropdownHelper.GameplayTagChoices", IsUniqueList = true, HideChildProperties = true)]
[ListDrawerSettings(ShowFoldout = true, ShowItemCount = false, DraggableItems = false)]
[DisableContextMenu(disableForMember: false, disableCollectionElements: true)]
[CustomContextMenu("排序", "@ImmunityTags = TagHelper.Sort($value)")]
[LabelText("ImmunityTags - 持有任意标签不可触发")]
public GameplayTag[] ImmunityTags;
public virtual bool Triggerable(AbilitySystemComponent owner)
{
if (owner == null) return false;
// 持有【所有】RequiredTags才可触发
if (!owner.HasAllTags(new GameplayTagSet(RequiredTags)))
return false;
// 持有【任意】ImmunityTags不可触发
if (owner.HasAnyTags(new GameplayTagSet(ImmunityTags)))
return false;
return true;
}
}
public abstract class GameplayCue<T> : GameplayCue where T : GameplayCueSpec
{
public abstract T CreateSpec(GameplayCueParameters parameters);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 24a60d4a49b842c28e848c52adb587e4
timeCreated: 1702536571

View File

@@ -0,0 +1,53 @@
using UnityEngine;
namespace GAS.Runtime
{
public abstract class GameplayCueDurational : GameplayCue<GameplayCueDurationalSpec>
{
public GameplayCueDurationalSpec ApplyFrom(GameplayEffectSpec gameplayEffectSpec)
{
if (!Triggerable(gameplayEffectSpec.Owner)) return null;
var durationalCue = CreateSpec(new GameplayCueParameters
{ sourceGameplayEffectSpec = gameplayEffectSpec });
return durationalCue;
}
public GameplayCueDurationalSpec ApplyFrom(AbilitySpec abilitySpec,params object[] customArguments)
{
if (!Triggerable(abilitySpec.Owner)) return null;
var durationalCue = CreateSpec(new GameplayCueParameters
{ sourceAbilitySpec = abilitySpec, customArguments = customArguments});
return durationalCue;
}
#if UNITY_EDITOR
public virtual void OnEditorPreview(GameObject previewObject,int frameIndex,int startFrame,int endFrame)
{
}
#endif
}
public abstract class GameplayCueDurationalSpec : GameplayCueSpec
{
protected GameplayCueDurationalSpec(GameplayCueDurational cue, GameplayCueParameters parameters) :
base(cue, parameters)
{
}
public abstract void OnAdd();
public abstract void OnRemove();
public abstract void OnGameplayEffectActivate();
public abstract void OnGameplayEffectDeactivate();
public abstract void OnTick();
}
public abstract class GameplayCueDurationalSpec<T> : GameplayCueDurationalSpec where T : GameplayCueDurational
{
public readonly T cue;
protected GameplayCueDurationalSpec(T cue, GameplayCueParameters parameters) : base(cue, parameters)
{
this.cue = cue;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cfc27df4bdc54282b3e7540eef7f4679
timeCreated: 1705027856

View File

@@ -0,0 +1,53 @@
using UnityEngine;
namespace GAS.Runtime
{
public abstract class GameplayCueInstant : GameplayCue<GameplayCueInstantSpec>
{
public virtual void ApplyFrom(GameplayEffectSpec gameplayEffectSpec)
{
if (Triggerable(gameplayEffectSpec.Owner))
{
var instantCue = CreateSpec(new GameplayCueParameters
{ sourceGameplayEffectSpec = gameplayEffectSpec });
instantCue?.Trigger();
}
}
public virtual void ApplyFrom(AbilitySpec abilitySpec, params object[] customArguments)
{
if (Triggerable(abilitySpec.Owner))
{
var instantCue = CreateSpec(new GameplayCueParameters
{ sourceAbilitySpec = abilitySpec, customArguments = customArguments });
instantCue?.Trigger();
}
}
#if UNITY_EDITOR
public virtual void OnEditorPreview(GameObject previewObject, int frame, int startFrame)
{
}
#endif
}
public abstract class GameplayCueInstantSpec : GameplayCueSpec
{
public GameplayCueInstantSpec(GameplayCueInstant cue, GameplayCueParameters parameters) : base(cue,
parameters)
{
}
public abstract void Trigger();
}
public abstract class GameplayCueInstantSpec<T>:GameplayCueInstantSpec where T:GameplayCueInstant
{
public readonly T cue;
public GameplayCueInstantSpec(T cue, GameplayCueParameters parameters) : base(cue, parameters)
{
this.cue = cue;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2483d9a3b6064679b6ec7cf5fc2831b6
timeCreated: 1705027797

View File

@@ -0,0 +1,15 @@
namespace GAS.Runtime
{
public struct GameplayCueParameters
{
public GameplayEffectSpec sourceGameplayEffectSpec;
public AbilitySpec sourceAbilitySpec;
public object[] customArguments;
// AggregatedSourceTags
// AggregatedTargetTags
// EffectContext
// Magnitude
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 71478534541e4560a993cd0ead34edc3
timeCreated: 1705915979

View File

@@ -0,0 +1,29 @@

namespace GAS.Runtime
{
public abstract class GameplayCueSpec
{
protected readonly GameplayCue _cue;
protected readonly GameplayCueParameters _parameters;
public AbilitySystemComponent Owner { get; protected set; }
public virtual bool Triggerable()
{
return _cue.Triggerable(Owner);
}
public GameplayCueSpec(GameplayCue cue, GameplayCueParameters cueParameters)
{
_cue = cue;
_parameters = cueParameters;
if (_parameters.sourceGameplayEffectSpec != null)
{
Owner = _parameters.sourceGameplayEffectSpec.Owner;
}
else if (_parameters.sourceAbilitySpec != null)
{
Owner = _parameters.sourceAbilitySpec.Owner;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d2c7719fe70c46e98344f1d9d8ebb9e6
timeCreated: 1705042515