mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
临时提交
This commit is contained in:
parent
8cea537319
commit
31db916fec
@ -37,28 +37,41 @@ namespace Demo.Scripts.GAS.GameplayCue
|
|||||||
|
|
||||||
public class GameplayCueDurational_PlayerDemo01_Spec : GameplayCueDurationalSpec<GameplayCueDurational_PlayerDemo01>
|
public class GameplayCueDurational_PlayerDemo01_Spec : GameplayCueDurationalSpec<GameplayCueDurational_PlayerDemo01>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private GameplayCueDurational_PlayerDemo01 Cue;
|
||||||
|
|
||||||
public GameplayCueDurational_PlayerDemo01_Spec(GameplayCueDurational_PlayerDemo01 cue, GameplayCueParameters parameters) : base(cue, parameters)
|
public GameplayCueDurational_PlayerDemo01_Spec(GameplayCueDurational_PlayerDemo01 cue, GameplayCueParameters parameters) : base(cue, parameters)
|
||||||
{
|
{
|
||||||
|
Cue = cue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnAdd()
|
public override void OnAdd(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
|
Debug.Log("GameplayCueDurational_PlayerDemo01_Spec OnAdd");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
public override void OnRemove(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
|
Debug.Log("GameplayCueDurational_PlayerDemo01_Spec OnRemove");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGameplayEffectActivate()
|
public override void OnGameplayEffectActivate()
|
||||||
{
|
{
|
||||||
|
Debug.Log("GameplayCueDurational_PlayerDemo01_Spec OnGameplayEffectActivate");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGameplayEffectDeactivate()
|
public override void OnGameplayEffectDeactivate()
|
||||||
{
|
{
|
||||||
|
Debug.Log("GameplayCueDurational_PlayerDemo01_Spec OnGameplayEffectDeactivate");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnTick()
|
public override void OnTick(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
|
Debug.Log($"GameplayCueDurational_PlayerDemo01_Spec OnTick {frame}");
|
||||||
|
if (Owner.GetView() is not null)
|
||||||
|
{
|
||||||
|
Owner.GetView().transform.position = Vector3.Lerp(Cue.start, Cue.end, (float)(frame - startFrame) / endFrame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
JEX_GAS/Assets/Demo/Scripts/Gen/GAbilityLib.gen.cs
Normal file
28
JEX_GAS/Assets/Demo/Scripts/Gen/GAbilityLib.gen.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
///////////////////////////////////
|
||||||
|
//// This is a generated file. ////
|
||||||
|
//// Do not modify it. ////
|
||||||
|
///////////////////////////////////
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace GAS.Runtime
|
||||||
|
{
|
||||||
|
public static class GAbilityLib
|
||||||
|
{
|
||||||
|
public struct AbilityInfo
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public string AssetPath;
|
||||||
|
public Type AbilityClassType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AbilityInfo JisolDemo1 = new AbilityInfo { Name = "JisolDemo1", AssetPath = "Assets/Demo/GAS/Config/GameplayAbilityLib/JisolDemo1.asset",AbilityClassType = typeof(GAS.Runtime.TimelineAbility) };
|
||||||
|
|
||||||
|
|
||||||
|
public static Dictionary<string, AbilityInfo> AbilityMap = new Dictionary<string, AbilityInfo>
|
||||||
|
{
|
||||||
|
["JisolDemo1"] = JisolDemo1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
11
JEX_GAS/Assets/Demo/Scripts/Gen/GAbilityLib.gen.cs.meta
Normal file
11
JEX_GAS/Assets/Demo/Scripts/Gen/GAbilityLib.gen.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 79aaab94f725e0347b32b6383dc6361e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
18
JEX_GAS/Assets/Demo/Scripts/Main.cs
Normal file
18
JEX_GAS/Assets/Demo/Scripts/Main.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using GAS.Runtime;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Demo.Scripts
|
||||||
|
{
|
||||||
|
public class Main : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public AbilitySystemComponent player;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
player.InitWithPreset(1);
|
||||||
|
player.TryActivateAbility(GAbilityLib.JisolDemo1.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
JEX_GAS/Assets/Demo/Scripts/Main.cs.meta
Normal file
3
JEX_GAS/Assets/Demo/Scripts/Main.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0c3aa2f58b904ebe9fc64cc367c63d68
|
||||||
|
timeCreated: 1729236756
|
@ -134,7 +134,7 @@ namespace GAS.Editor
|
|||||||
{
|
{
|
||||||
if (IsPlaying)
|
if (IsPlaying)
|
||||||
{
|
{
|
||||||
if (_selected == null || _selected.gameObject == null)
|
if (_selected == null || _selected.GetView().gameObject == null)
|
||||||
{
|
{
|
||||||
_selected = GAS.GameplayAbilitySystem.GAS.AbilitySystemComponents.Count > 0
|
_selected = GAS.GameplayAbilitySystem.GAS.AbilitySystemComponents.Count > 0
|
||||||
? GAS.GameplayAbilitySystem.GAS.AbilitySystemComponents[0] as AbilitySystemComponent
|
? GAS.GameplayAbilitySystem.GAS.AbilitySystemComponents[0] as AbilitySystemComponent
|
||||||
@ -169,7 +169,7 @@ namespace GAS.Editor
|
|||||||
{
|
{
|
||||||
var asc = (AbilitySystemComponent)iasc;
|
var asc = (AbilitySystemComponent)iasc;
|
||||||
var presetName = asc.Preset != null ? asc.Preset.name : "NoPreset";
|
var presetName = asc.Preset != null ? asc.Preset.name : "NoPreset";
|
||||||
if (GUILayout.Button($"{presetName}#{asc.GetInstanceID()}"))
|
if (GUILayout.Button($"{presetName}#{asc.GetView().GetInstanceID()}"))
|
||||||
{
|
{
|
||||||
_selected = asc;
|
_selected = asc;
|
||||||
RefreshAscInfo();
|
RefreshAscInfo();
|
||||||
@ -194,8 +194,8 @@ namespace GAS.Editor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IID = _selected.GetInstanceID();
|
IID = _selected.GetView().GetInstanceID();
|
||||||
instance = _selected.gameObject;
|
instance = _selected.GetView().gameObject;
|
||||||
Level = _selected.Level;
|
Level = _selected.Level;
|
||||||
|
|
||||||
RefreshAbilityInfo();
|
RefreshAbilityInfo();
|
||||||
@ -278,13 +278,13 @@ namespace GAS.Editor
|
|||||||
case GameplayEffectSpec spec:
|
case GameplayEffectSpec spec:
|
||||||
{
|
{
|
||||||
DynamicTag.Add(
|
DynamicTag.Add(
|
||||||
$" - From: {spec.Owner.GetInstanceID()}'s GE: {spec.GameplayEffect.GameplayEffectName}");
|
$" - From: {spec.Owner.EntityId}'s GE: {spec.GameplayEffect.GameplayEffectName}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AbilitySpec ability:
|
case AbilitySpec ability:
|
||||||
{
|
{
|
||||||
DynamicTag.Add(
|
DynamicTag.Add(
|
||||||
$" - From: {ability.Owner.GetInstanceID()}'s Ability: {ability.Ability.Name}");
|
$" - From: {ability.Owner.EntityId}'s Ability: {ability.Ability.Name}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,27 @@ namespace GAS.General
|
|||||||
bool IsFromPool { get; set; }
|
bool IsFromPool { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ObjectPool
|
public class JexGasObjectPool
|
||||||
{
|
{
|
||||||
private static ObjectPool _singleton;
|
private static JexGasObjectPool _singleton;
|
||||||
public static ObjectPool Instance => _singleton ??= new ObjectPool();
|
|
||||||
|
public static JexGasObjectPool Instance => _singleton ??= new JexGasObjectPool();
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<Type, Pool> _objPool = new();
|
private readonly ConcurrentDictionary<Type, Pool> _objPool = new();
|
||||||
|
|
||||||
private readonly Func<Type, Pool> _addPoolFunc = type => new Pool(type, 1024);
|
private readonly Func<Type, Pool> _addPoolFunc = type => new Pool(type, 1024);
|
||||||
|
|
||||||
|
public static void Awake()
|
||||||
|
{
|
||||||
|
_singleton = null;
|
||||||
|
_singleton = new JexGasObjectPool();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Destroy()
|
||||||
|
{
|
||||||
|
_singleton = null;
|
||||||
|
}
|
||||||
|
|
||||||
public T Fetch<T>() where T : class
|
public T Fetch<T>() where T : class
|
||||||
{
|
{
|
||||||
var type = typeof(T);
|
var type = typeof(T);
|
@ -16,11 +16,11 @@ namespace GAS.Runtime
|
|||||||
public static Collider2D[] OverlapBox2D(this AbilitySystemComponent asc, Vector2 offset, Vector2 size,
|
public static Collider2D[] OverlapBox2D(this AbilitySystemComponent asc, Vector2 offset, Vector2 size,
|
||||||
float angle, int layerMask, Transform relativeTransform = null)
|
float angle, int layerMask, Transform relativeTransform = null)
|
||||||
{
|
{
|
||||||
relativeTransform ??= asc.transform;
|
relativeTransform ??= asc.GetView().transform;
|
||||||
var center = (Vector2)relativeTransform.position;
|
var center = (Vector2)relativeTransform.position;
|
||||||
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
||||||
center += offset;
|
center += offset;
|
||||||
angle += asc.transform.eulerAngles.z;
|
angle += asc.GetView().transform.eulerAngles.z;
|
||||||
|
|
||||||
return Physics2D.OverlapBoxAll(center, size, angle, layerMask);
|
return Physics2D.OverlapBoxAll(center, size, angle, layerMask);
|
||||||
}
|
}
|
||||||
@ -28,11 +28,11 @@ namespace GAS.Runtime
|
|||||||
public static int OverlapBox2DNonAlloc(this AbilitySystemComponent asc, Vector2 offset, Vector2 size,
|
public static int OverlapBox2DNonAlloc(this AbilitySystemComponent asc, Vector2 offset, Vector2 size,
|
||||||
float angle, Collider2D[] results, int layerMask, Transform relativeTransform = null)
|
float angle, Collider2D[] results, int layerMask, Transform relativeTransform = null)
|
||||||
{
|
{
|
||||||
relativeTransform ??= asc.transform;
|
relativeTransform ??= asc.GetView().transform;
|
||||||
var center = (Vector2)relativeTransform.position;
|
var center = (Vector2)relativeTransform.position;
|
||||||
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
||||||
center += offset;
|
center += offset;
|
||||||
angle += asc.transform.eulerAngles.z;
|
angle += asc.GetView().transform.eulerAngles.z;
|
||||||
|
|
||||||
var count = Physics2D.OverlapBoxNonAlloc(center, size, angle, results, layerMask);
|
var count = Physics2D.OverlapBoxNonAlloc(center, size, angle, results, layerMask);
|
||||||
return count;
|
return count;
|
||||||
@ -55,7 +55,7 @@ namespace GAS.Runtime
|
|||||||
public static Collider2D[] OverlapCircle2D(this AbilitySystemComponent asc, Vector2 offset, float radius,
|
public static Collider2D[] OverlapCircle2D(this AbilitySystemComponent asc, Vector2 offset, float radius,
|
||||||
int layerMask, Transform relativeTransform = null)
|
int layerMask, Transform relativeTransform = null)
|
||||||
{
|
{
|
||||||
relativeTransform ??= asc.transform;
|
relativeTransform ??= asc.GetView().transform;
|
||||||
var center = (Vector2)relativeTransform.position;
|
var center = (Vector2)relativeTransform.position;
|
||||||
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
||||||
center += offset;
|
center += offset;
|
||||||
@ -66,7 +66,7 @@ namespace GAS.Runtime
|
|||||||
public static int OverlapCircle2DNonAlloc(this AbilitySystemComponent asc, Vector2 offset, float radius,
|
public static int OverlapCircle2DNonAlloc(this AbilitySystemComponent asc, Vector2 offset, float radius,
|
||||||
Collider2D[] results, int layerMask, Transform relativeTransform = null)
|
Collider2D[] results, int layerMask, Transform relativeTransform = null)
|
||||||
{
|
{
|
||||||
relativeTransform ??= asc.transform;
|
relativeTransform ??= asc.GetView().transform;
|
||||||
var center = (Vector2)relativeTransform.position;
|
var center = (Vector2)relativeTransform.position;
|
||||||
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
offset.x *= relativeTransform.lossyScale.x > 0 ? 1 : -1;
|
||||||
center += offset;
|
center += offset;
|
||||||
|
@ -16,7 +16,7 @@ namespace GAS.Runtime
|
|||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
var abilitySpecs = ObjectPool.Instance.Fetch<List<AbilitySpec>>();
|
var abilitySpecs = JexGasObjectPool.Instance.Fetch<List<AbilitySpec>>();
|
||||||
abilitySpecs.AddRange(_abilities.Values);
|
abilitySpecs.AddRange(_abilities.Values);
|
||||||
|
|
||||||
foreach (var abilitySpec in abilitySpecs)
|
foreach (var abilitySpec in abilitySpecs)
|
||||||
@ -25,7 +25,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
abilitySpecs.Clear();
|
abilitySpecs.Clear();
|
||||||
ObjectPool.Instance.Recycle(abilitySpecs);
|
JexGasObjectPool.Instance.Recycle(abilitySpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GrantAbility(AbstractAbility ability)
|
public void GrantAbility(AbstractAbility ability)
|
||||||
@ -61,7 +61,7 @@ namespace GAS.Runtime
|
|||||||
// 这个输出可以删掉, 某些情况下确实会尝试激活不存在的技能(失败了也无所谓), 但是对开发期间的调试有帮助
|
// 这个输出可以删掉, 某些情况下确实会尝试激活不存在的技能(失败了也无所谓), 但是对开发期间的调试有帮助
|
||||||
Debug.LogWarning(
|
Debug.LogWarning(
|
||||||
$"you are trying to activate an ability that does not exist: " +
|
$"you are trying to activate an ability that does not exist: " +
|
||||||
$"abilityName=\"{abilityName}\", GameObject=\"{_owner.name}\", " +
|
$"abilityName=\"{abilityName}\", GameObject=\"{_owner.EntityId}\", " +
|
||||||
$"Preset={(_owner.Preset != null ? _owner.Preset.name : "null")}");
|
$"Preset={(_owner.Preset != null ? _owner.Preset.name : "null")}");
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
@ -218,7 +218,7 @@ namespace GAS.Runtime
|
|||||||
foreach (var clip in _cacheDurationalCueTrack)
|
foreach (var clip in _cacheDurationalCueTrack)
|
||||||
{
|
{
|
||||||
if (_currentFrame <= clip.endFrame)
|
if (_currentFrame <= clip.endFrame)
|
||||||
clip.cueSpec.OnRemove();
|
clip.cueSpec.OnRemove(_currentFrame,clip.startFrame,clip.endFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var clip in _cacheBuffGameplayEffectTrack)
|
foreach (var clip in _cacheBuffGameplayEffectTrack)
|
||||||
@ -345,17 +345,17 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
if (frame == cueClip.startFrame)
|
if (frame == cueClip.startFrame)
|
||||||
{
|
{
|
||||||
cueClip.cueSpec.OnAdd();
|
cueClip.cueSpec.OnAdd(frame,cueClip.startFrame,cueClip.endFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame >= cueClip.startFrame && frame <= cueClip.endFrame)
|
if (frame >= cueClip.startFrame && frame <= cueClip.endFrame)
|
||||||
{
|
{
|
||||||
cueClip.cueSpec.OnTick();
|
cueClip.cueSpec.OnTick(frame,cueClip.startFrame,cueClip.endFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame == cueClip.endFrame)
|
if (frame == cueClip.endFrame)
|
||||||
{
|
{
|
||||||
cueClip.cueSpec.OnRemove();
|
cueClip.cueSpec.OnRemove(frame,cueClip.startFrame,cueClip.endFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
if (modifier.AttributeName == _processedAttribute.Name)
|
if (modifier.AttributeName == _processedAttribute.Name)
|
||||||
{
|
{
|
||||||
var modifierSpec = ObjectPool.Instance.Fetch<ModifierSpec>();
|
var modifierSpec = JexGasObjectPool.Instance.Fetch<ModifierSpec>();
|
||||||
modifierSpec.Init(geSpec, modifier);
|
modifierSpec.Init(geSpec, modifier);
|
||||||
_modifierCache.Add(modifierSpec);
|
_modifierCache.Add(modifierSpec);
|
||||||
TryRegisterAttributeChangedListen(geSpec, modifier);
|
TryRegisterAttributeChangedListen(geSpec, modifier);
|
||||||
@ -104,7 +104,7 @@ namespace GAS.Runtime
|
|||||||
foreach (var modifierSpec in _modifierCache)
|
foreach (var modifierSpec in _modifierCache)
|
||||||
{
|
{
|
||||||
modifierSpec.Release();
|
modifierSpec.Release();
|
||||||
ObjectPool.Instance.Recycle(modifierSpec);
|
JexGasObjectPool.Instance.Recycle(modifierSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
_modifierCache.Clear();
|
_modifierCache.Clear();
|
||||||
|
@ -35,7 +35,7 @@ namespace GAS.Runtime
|
|||||||
if (!_attributeAggregators.ContainsKey(attrSet[attr]))
|
if (!_attributeAggregators.ContainsKey(attrSet[attr]))
|
||||||
{
|
{
|
||||||
var attrAggt = new AttributeAggregator(attrSet[attr], _owner);
|
var attrAggt = new AttributeAggregator(attrSet[attr], _owner);
|
||||||
if (_owner.enabled) attrAggt.OnEnable();
|
attrAggt.OnEnable();
|
||||||
_attributeAggregators.Add(attrSet[attr], attrAggt);
|
_attributeAggregators.Add(attrSet[attr], attrAggt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ namespace GAS.Runtime
|
|||||||
|
|
||||||
public Dictionary<string, float> Snapshot()
|
public Dictionary<string, float> Snapshot()
|
||||||
{
|
{
|
||||||
var snapshot = ObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
var snapshot = JexGasObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
||||||
foreach (var kv in _attributeSets)
|
foreach (var kv in _attributeSets)
|
||||||
{
|
{
|
||||||
var attributeSet = kv.Value;
|
var attributeSet = kv.Value;
|
||||||
|
@ -4,12 +4,13 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace GAS.Runtime
|
namespace GAS.Runtime
|
||||||
{
|
{
|
||||||
public class AbilitySystemComponent : MonoBehaviour, IAbilitySystemComponent
|
public class AbilitySystemComponent : IAbilitySystemComponent
|
||||||
{
|
{
|
||||||
[SerializeField]
|
|
||||||
private AbilitySystemComponentPreset preset;
|
private AbilitySystemComponentPreset preset;
|
||||||
|
|
||||||
public AbilitySystemComponentPreset Preset => preset;
|
public AbilitySystemComponentPreset Preset => preset;
|
||||||
|
|
||||||
|
public int EntityId { get; protected set; }
|
||||||
|
|
||||||
public int Level { get; protected set; }
|
public int Level { get; protected set; }
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ namespace GAS.Runtime
|
|||||||
if (gameplayEffectSpec == null)
|
if (gameplayEffectSpec == null)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Debug.LogError($"[EX] Try To Apply a invalid EntityRef of GameplayEffectSpec From {name} To {target.name}!");
|
Debug.LogError($"[EX] Try To Apply a invalid EntityRef of GameplayEffectSpec From {EntityId} To {target.EntityId}!");
|
||||||
#endif
|
#endif
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -203,7 +204,7 @@ namespace GAS.Runtime
|
|||||||
if (gameplayEffect == null)
|
if (gameplayEffect == null)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Debug.LogError($"[EX] Try To Apply a NULL GameplayEffect From {name} To {target.name}!");
|
Debug.LogError($"[EX] Try To Apply a NULL GameplayEffect From {EntityId} To {target.EntityId}!");
|
||||||
#endif
|
#endif
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -217,7 +218,7 @@ namespace GAS.Runtime
|
|||||||
if (gameplayEffect == null)
|
if (gameplayEffect == null)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Debug.LogError($"[EX] Try To Apply a NULL GameplayEffect From {name} To {target.name}!");
|
Debug.LogError($"[EX] Try To Apply a NULL GameplayEffect From {EntityId} To {target.EntityId}!");
|
||||||
#endif
|
#endif
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -398,5 +399,15 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
GameplayEffectContainer.ClearGameplayEffect();
|
GameplayEffectContainer.ClearGameplayEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回视图
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual GameObject GetView()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace GAS.Runtime
|
||||||
|
{
|
||||||
|
public class AbilitySystemPreviewComponent : AbilitySystemComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
private GameObject view;
|
||||||
|
|
||||||
|
public AbilitySystemPreviewComponent(GameObject view)
|
||||||
|
{
|
||||||
|
this.view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override GameObject GetView()
|
||||||
|
{
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d737dff4fee4418e997631c8d083de40
|
||||||
|
timeCreated: 1729243645
|
@ -82,7 +82,7 @@ namespace GAS
|
|||||||
{
|
{
|
||||||
Profiler.BeginSample($"{nameof(GameplayAbilitySystem)}::Tick()");
|
Profiler.BeginSample($"{nameof(GameplayAbilitySystem)}::Tick()");
|
||||||
|
|
||||||
var abilitySystemComponents = ObjectPool.Instance.Fetch<List<AbilitySystemComponent>>();
|
var abilitySystemComponents = JexGasObjectPool.Instance.Fetch<List<AbilitySystemComponent>>();
|
||||||
abilitySystemComponents.AddRange(AbilitySystemComponents);
|
abilitySystemComponents.AddRange(AbilitySystemComponents);
|
||||||
|
|
||||||
foreach (var abilitySystemComponent in abilitySystemComponents)
|
foreach (var abilitySystemComponent in abilitySystemComponents)
|
||||||
@ -91,7 +91,7 @@ namespace GAS
|
|||||||
}
|
}
|
||||||
|
|
||||||
abilitySystemComponents.Clear();
|
abilitySystemComponents.Clear();
|
||||||
ObjectPool.Instance.Recycle(abilitySystemComponents);
|
JexGasObjectPool.Instance.Recycle(abilitySystemComponents);
|
||||||
|
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,29 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void OnAdd();
|
/// <summary>
|
||||||
public abstract void OnRemove();
|
/// 添加
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="frame">当前帧(不是Timeline类型则返回-1)</param>
|
||||||
|
/// <param name="startFrame">开始帧(不是Timeline类型则返回-1)</param>
|
||||||
|
/// <param name="endFrame">结束帧(不是Timeline类型则返回-1)</param>
|
||||||
|
public abstract void OnAdd(int frame,int startFrame,int endFrame);
|
||||||
|
/// <summary>
|
||||||
|
/// 移除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="frame">当前帧(不是Timeline类型则返回-1)</param>
|
||||||
|
/// <param name="startFrame">开始帧(不是Timeline类型则返回-1)</param>
|
||||||
|
/// <param name="endFrame">结束帧(不是Timeline类型则返回-1)</param>
|
||||||
|
public abstract void OnRemove(int frame,int startFrame,int endFrame);
|
||||||
public abstract void OnGameplayEffectActivate();
|
public abstract void OnGameplayEffectActivate();
|
||||||
public abstract void OnGameplayEffectDeactivate();
|
public abstract void OnGameplayEffectDeactivate();
|
||||||
public abstract void OnTick();
|
/// <summary>
|
||||||
|
/// Tick
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="frame">当前帧(不是Timeline类型则返回-1)</param>
|
||||||
|
/// <param name="startFrame">开始帧(不是Timeline类型则返回-1)</param>
|
||||||
|
/// <param name="endFrame">结束帧(不是Timeline类型则返回-1)</param>
|
||||||
|
public abstract void OnTick(int frame,int startFrame,int endFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class GameplayCueDurationalSpec<T> : GameplayCueDurationalSpec where T : GameplayCueDurational
|
public abstract class GameplayCueDurationalSpec<T> : GameplayCueDurationalSpec where T : GameplayCueDurational
|
||||||
|
@ -70,7 +70,7 @@ namespace GAS.Runtime
|
|||||||
public CueAnimationSpec(CueAnimation cue, GameplayCueParameters parameters) : base(cue,
|
public CueAnimationSpec(CueAnimation cue, GameplayCueParameters parameters) : base(cue,
|
||||||
parameters)
|
parameters)
|
||||||
{
|
{
|
||||||
var transform = Owner.transform.Find(cue.AnimatorRelativePath);
|
var transform = Owner.GetView()?.transform.Find(cue.AnimatorRelativePath);
|
||||||
_animator = cue.IncludeChildrenAnimator ? transform.GetComponentInChildren<Animator>() : transform.GetComponent<Animator>();
|
_animator = cue.IncludeChildrenAnimator ? transform.GetComponentInChildren<Animator>() : transform.GetComponent<Animator>();
|
||||||
if (_animator == null)
|
if (_animator == null)
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnAdd()
|
public override void OnAdd(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
if (_animator != null)
|
if (_animator != null)
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
public override void OnRemove(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnTick()
|
public override void OnTick(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace GAS.Runtime
|
|||||||
public CueAnimationOneShotSpec(CueAnimationOneShot cue, GameplayCueParameters parameters)
|
public CueAnimationOneShotSpec(CueAnimationOneShot cue, GameplayCueParameters parameters)
|
||||||
: base(cue, parameters)
|
: base(cue, parameters)
|
||||||
{
|
{
|
||||||
var transform = Owner.transform.Find(cue.AnimatorRelativePath);
|
var transform = Owner.GetView()?.transform.Find(cue.AnimatorRelativePath);
|
||||||
if (transform != null)
|
if (transform != null)
|
||||||
{
|
{
|
||||||
_animator = cue.IncludeChildrenAnimator
|
_animator = cue.IncludeChildrenAnimator
|
||||||
|
@ -43,7 +43,7 @@ namespace GAS.Runtime
|
|||||||
public GCS_ChangeAnimationSpeed(CueAnimationSpeedModifier cue, GameplayCueParameters parameters)
|
public GCS_ChangeAnimationSpeed(CueAnimationSpeedModifier cue, GameplayCueParameters parameters)
|
||||||
: base(cue, parameters)
|
: base(cue, parameters)
|
||||||
{
|
{
|
||||||
var transform = Owner.transform.Find(cue.animatorRelativePath);
|
var transform = Owner.GetView()?.transform.Find(cue.animatorRelativePath);
|
||||||
if (transform != null)
|
if (transform != null)
|
||||||
{
|
{
|
||||||
_animator = cue.includeChildrenAnimator
|
_animator = cue.includeChildrenAnimator
|
||||||
@ -58,11 +58,11 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnAdd()
|
public override void OnAdd(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
public override void OnRemove(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnTick()
|
public override void OnTick(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,27 +31,32 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
if (cue.isAttachToOwner)
|
if (cue.isAttachToOwner)
|
||||||
{
|
{
|
||||||
_audioSource = Owner.gameObject.GetComponent<AudioSource>();
|
_audioSource = Owner.GetView()?.gameObject.GetComponent<AudioSource>();
|
||||||
if (_audioSource == null)
|
if (_audioSource == null)
|
||||||
{
|
{
|
||||||
_audioSource = Owner.gameObject.AddComponent<AudioSource>();
|
_audioSource = Owner.GetView()?.gameObject.AddComponent<AudioSource>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var soundRoot = new GameObject("SoundRoot");
|
var soundRoot = new GameObject("SoundRoot");
|
||||||
soundRoot.transform.position = Owner.transform.position;
|
|
||||||
|
if (Owner.GetView() is not null)
|
||||||
|
{
|
||||||
|
soundRoot.transform.position = Owner.GetView().transform.position;
|
||||||
|
}
|
||||||
|
|
||||||
_audioSource = soundRoot.AddComponent<AudioSource>();
|
_audioSource = soundRoot.AddComponent<AudioSource>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnAdd()
|
public override void OnAdd(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
_audioSource.clip = cue.soundEffect;
|
_audioSource.clip = cue.soundEffect;
|
||||||
_audioSource.Play();
|
_audioSource.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
public override void OnRemove(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
if (!cue.isAttachToOwner)
|
if (!cue.isAttachToOwner)
|
||||||
{
|
{
|
||||||
@ -71,7 +76,7 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnTick()
|
public override void OnTick(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,18 +86,21 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnAdd()
|
public override void OnAdd(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
if (cue.VfxPrefab != null)
|
if (cue.VfxPrefab != null)
|
||||||
{
|
{
|
||||||
_vfxInstance = cue.IsAttachToTarget
|
if (Owner.GetView() is not null)
|
||||||
? Object.Instantiate(cue.VfxPrefab, Owner.transform)
|
{
|
||||||
: Object.Instantiate(cue.VfxPrefab, Owner.transform.position, Quaternion.identity);
|
_vfxInstance = cue.IsAttachToTarget
|
||||||
|
? Object.Instantiate(cue.VfxPrefab, Owner.GetView().transform)
|
||||||
|
: Object.Instantiate(cue.VfxPrefab, Owner.GetView().transform.position, Quaternion.identity);
|
||||||
|
|
||||||
_vfxInstance.transform.localPosition = cue.Offset;
|
_vfxInstance.transform.localPosition = cue.Offset;
|
||||||
_vfxInstance.transform.localEulerAngles = cue.Rotation;
|
_vfxInstance.transform.localEulerAngles = cue.Rotation;
|
||||||
_vfxInstance.transform.localScale = cue.Scale;
|
_vfxInstance.transform.localScale = cue.Scale;
|
||||||
_vfxInstance.SetActive(cue.ActiveWhenAdded);
|
_vfxInstance.SetActive(cue.ActiveWhenAdded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -107,7 +110,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
public override void OnRemove(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
if (_vfxInstance != null)
|
if (_vfxInstance != null)
|
||||||
{
|
{
|
||||||
@ -131,7 +134,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnTick()
|
public override void OnTick(int frame,int startFrame,int endFrame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace GAS.Runtime
|
|||||||
float level = 1,
|
float level = 1,
|
||||||
object userData = null)
|
object userData = null)
|
||||||
{
|
{
|
||||||
var spec = ObjectPool.Instance.Fetch<GameplayEffectSpec>();
|
var spec = JexGasObjectPool.Instance.Fetch<GameplayEffectSpec>();
|
||||||
spec.Awake(this, userData);
|
spec.Awake(this, userData);
|
||||||
spec.Init(creator, owner, level);
|
spec.Init(creator, owner, level);
|
||||||
return spec;
|
return spec;
|
||||||
@ -86,7 +86,7 @@ namespace GAS.Runtime
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public EntityRef<GameplayEffectSpec> CreateSpec(object userData = null)
|
public EntityRef<GameplayEffectSpec> CreateSpec(object userData = null)
|
||||||
{
|
{
|
||||||
var spec = ObjectPool.Instance.Fetch<GameplayEffectSpec>();
|
var spec = JexGasObjectPool.Instance.Fetch<GameplayEffectSpec>();
|
||||||
spec.Awake(this, userData);
|
spec.Awake(this, userData);
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ namespace GAS.Runtime
|
|||||||
return Array.Empty<GrantedAbilityFromEffect>();
|
return Array.Empty<GrantedAbilityFromEffect>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var grantedAbilityFromEffects = ObjectPool.Instance.Fetch<List<GrantedAbilityFromEffect>>();
|
var grantedAbilityFromEffects = JexGasObjectPool.Instance.Fetch<List<GrantedAbilityFromEffect>>();
|
||||||
foreach (var grantedAbilityConfig in grantedAbilities)
|
foreach (var grantedAbilityConfig in grantedAbilities)
|
||||||
{
|
{
|
||||||
if (grantedAbilityConfig.AbilityAsset != null)
|
if (grantedAbilityConfig.AbilityAsset != null)
|
||||||
@ -150,7 +150,7 @@ namespace GAS.Runtime
|
|||||||
var ret = GrantedAbilityFromEffectArrayPool.Fetch(grantedAbilityFromEffects.Count);
|
var ret = GrantedAbilityFromEffectArrayPool.Fetch(grantedAbilityFromEffects.Count);
|
||||||
grantedAbilityFromEffects.CopyTo(ret);
|
grantedAbilityFromEffects.CopyTo(ret);
|
||||||
grantedAbilityFromEffects.Clear();
|
grantedAbilityFromEffects.Clear();
|
||||||
ObjectPool.Instance.Recycle(grantedAbilityFromEffects);
|
JexGasObjectPool.Instance.Recycle(grantedAbilityFromEffects);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace GAS.Runtime
|
|||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
var gameplayEffectSpecs = ObjectPool.Instance.Fetch<List<GameplayEffectSpec>>();
|
var gameplayEffectSpecs = JexGasObjectPool.Instance.Fetch<List<GameplayEffectSpec>>();
|
||||||
gameplayEffectSpecs.AddRange(_gameplayEffectSpecs);
|
gameplayEffectSpecs.AddRange(_gameplayEffectSpecs);
|
||||||
|
|
||||||
foreach (var gameplayEffectSpec in gameplayEffectSpecs)
|
foreach (var gameplayEffectSpec in gameplayEffectSpecs)
|
||||||
@ -36,7 +36,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
gameplayEffectSpecs.Clear();
|
gameplayEffectSpecs.Clear();
|
||||||
ObjectPool.Instance.Recycle(gameplayEffectSpecs);
|
JexGasObjectPool.Instance.Recycle(gameplayEffectSpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterOnGameplayEffectContainerIsDirty(Action action)
|
public void RegisterOnGameplayEffectContainerIsDirty(Action action)
|
||||||
@ -53,7 +53,7 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
if (tags.Empty) return;
|
if (tags.Empty) return;
|
||||||
|
|
||||||
var removeList = ObjectPool.Instance.Fetch<List<GameplayEffectSpec>>();
|
var removeList = JexGasObjectPool.Instance.Fetch<List<GameplayEffectSpec>>();
|
||||||
|
|
||||||
foreach (var gameplayEffectSpec in _gameplayEffectSpecs)
|
foreach (var gameplayEffectSpec in _gameplayEffectSpecs)
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ namespace GAS.Runtime
|
|||||||
foreach (var gameplayEffectSpec in removeList) RemoveGameplayEffectSpec(gameplayEffectSpec);
|
foreach (var gameplayEffectSpec in removeList) RemoveGameplayEffectSpec(gameplayEffectSpec);
|
||||||
|
|
||||||
removeList.Clear();
|
removeList.Clear();
|
||||||
ObjectPool.Instance.Recycle(removeList);
|
JexGasObjectPool.Instance.Recycle(removeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -36,7 +36,7 @@ namespace GAS.Runtime
|
|||||||
Modifiers = GameplayEffect.Modifiers;
|
Modifiers = GameplayEffect.Modifiers;
|
||||||
if (gameplayEffect.DurationPolicy != EffectsDurationPolicy.Instant)
|
if (gameplayEffect.DurationPolicy != EffectsDurationPolicy.Instant)
|
||||||
{
|
{
|
||||||
var periodTicker = ObjectPool.Instance.Fetch<GameplayEffectPeriodTicker>();
|
var periodTicker = JexGasObjectPool.Instance.Fetch<GameplayEffectPeriodTicker>();
|
||||||
periodTicker.Awake(this);
|
periodTicker.Awake(this);
|
||||||
// EntityRef之前必须确定InstanceId的值
|
// EntityRef之前必须确定InstanceId的值
|
||||||
PeriodTicker = periodTicker;
|
PeriodTicker = periodTicker;
|
||||||
@ -61,7 +61,7 @@ namespace GAS.Runtime
|
|||||||
if (gameplayEffectPeriodTicker != null)
|
if (gameplayEffectPeriodTicker != null)
|
||||||
{
|
{
|
||||||
gameplayEffectPeriodTicker.Release();
|
gameplayEffectPeriodTicker.Release();
|
||||||
ObjectPool.Instance.Recycle(gameplayEffectPeriodTicker);
|
JexGasObjectPool.Instance.Recycle(gameplayEffectPeriodTicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeriodTicker = default;
|
PeriodTicker = default;
|
||||||
@ -79,12 +79,12 @@ namespace GAS.Runtime
|
|||||||
if (grantedAbilitySpecFromEffect != null)
|
if (grantedAbilitySpecFromEffect != null)
|
||||||
{
|
{
|
||||||
grantedAbilitySpecFromEffect.Release();
|
grantedAbilitySpecFromEffect.Release();
|
||||||
ObjectPool.Instance.Recycle(grantedAbilitySpecFromEffect);
|
JexGasObjectPool.Instance.Recycle(grantedAbilitySpecFromEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GrantedAbilitiesSpecFromEffect.Clear();
|
GrantedAbilitiesSpecFromEffect.Clear();
|
||||||
ObjectPool.Instance.Recycle(GrantedAbilitiesSpecFromEffect);
|
JexGasObjectPool.Instance.Recycle(GrantedAbilitiesSpecFromEffect);
|
||||||
GrantedAbilitiesSpecFromEffect = default;
|
GrantedAbilitiesSpecFromEffect = default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,13 +94,13 @@ namespace GAS.Runtime
|
|||||||
if (SnapshotSourceAttributes != null)
|
if (SnapshotSourceAttributes != null)
|
||||||
{
|
{
|
||||||
SnapshotSourceAttributes.Clear();
|
SnapshotSourceAttributes.Clear();
|
||||||
ObjectPool.Instance.Recycle(SnapshotSourceAttributes);
|
JexGasObjectPool.Instance.Recycle(SnapshotSourceAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SnapshotTargetAttributes != null && SnapshotSourceAttributes != SnapshotTargetAttributes)
|
if (SnapshotTargetAttributes != null && SnapshotSourceAttributes != SnapshotTargetAttributes)
|
||||||
{
|
{
|
||||||
SnapshotTargetAttributes.Clear();
|
SnapshotTargetAttributes.Clear();
|
||||||
ObjectPool.Instance.Recycle(SnapshotTargetAttributes);
|
JexGasObjectPool.Instance.Recycle(SnapshotTargetAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapshotSourceAttributes = null;
|
SnapshotSourceAttributes = null;
|
||||||
@ -111,14 +111,14 @@ namespace GAS.Runtime
|
|||||||
if (_valueMapWithTag != null)
|
if (_valueMapWithTag != null)
|
||||||
{
|
{
|
||||||
_valueMapWithTag.Clear();
|
_valueMapWithTag.Clear();
|
||||||
ObjectPool.Instance.Recycle(_valueMapWithTag);
|
JexGasObjectPool.Instance.Recycle(_valueMapWithTag);
|
||||||
_valueMapWithTag = null;
|
_valueMapWithTag = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_valueMapWithName != null)
|
if (_valueMapWithName != null)
|
||||||
{
|
{
|
||||||
_valueMapWithName.Clear();
|
_valueMapWithName.Clear();
|
||||||
ObjectPool.Instance.Recycle(_valueMapWithName);
|
JexGasObjectPool.Instance.Recycle(_valueMapWithName);
|
||||||
_valueMapWithName = null;
|
_valueMapWithName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ namespace GAS.Runtime
|
|||||||
OnStackChanged = default;
|
OnStackChanged = default;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectPool.Instance.Recycle(this);
|
JexGasObjectPool.Instance.Recycle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(AbilitySystemComponent source, AbilitySystemComponent owner, float level = 1)
|
public void Init(AbilitySystemComponent source, AbilitySystemComponent owner, float level = 1)
|
||||||
@ -220,7 +220,7 @@ namespace GAS.Runtime
|
|||||||
if (grantedAbilityFromEffects is null) return;
|
if (grantedAbilityFromEffects is null) return;
|
||||||
if (grantedAbilityFromEffects.Length == 0) return;
|
if (grantedAbilityFromEffects.Length == 0) return;
|
||||||
|
|
||||||
GrantedAbilitiesSpecFromEffect = ObjectPool.Instance.Fetch<List<EntityRef<GrantedAbilitySpecFromEffect>>>();
|
GrantedAbilitiesSpecFromEffect = JexGasObjectPool.Instance.Fetch<List<EntityRef<GrantedAbilitySpecFromEffect>>>();
|
||||||
foreach (var grantedAbilityFromEffect in grantedAbilityFromEffects)
|
foreach (var grantedAbilityFromEffect in grantedAbilityFromEffects)
|
||||||
{
|
{
|
||||||
GrantedAbilitiesSpecFromEffect.Add(grantedAbilityFromEffect.CreateSpec(this));
|
GrantedAbilitiesSpecFromEffect.Add(grantedAbilityFromEffect.CreateSpec(this));
|
||||||
@ -236,12 +236,12 @@ namespace GAS.Runtime
|
|||||||
if (grantedAbilitySpecFromEffect != null)
|
if (grantedAbilitySpecFromEffect != null)
|
||||||
{
|
{
|
||||||
grantedAbilitySpecFromEffect.Release();
|
grantedAbilitySpecFromEffect.Release();
|
||||||
ObjectPool.Instance.Recycle(grantedAbilitySpecFromEffect);
|
JexGasObjectPool.Instance.Recycle(grantedAbilitySpecFromEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GrantedAbilitiesSpecFromEffect.Clear();
|
GrantedAbilitiesSpecFromEffect.Clear();
|
||||||
ObjectPool.Instance.Recycle(GrantedAbilitiesSpecFromEffect);
|
JexGasObjectPool.Instance.Recycle(GrantedAbilitiesSpecFromEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStacking(GameplayEffectStacking stacking)
|
public void SetStacking(GameplayEffectStacking stacking)
|
||||||
@ -315,7 +315,7 @@ namespace GAS.Runtime
|
|||||||
ReleaseCueDurationalSpecs();
|
ReleaseCueDurationalSpecs();
|
||||||
if (GameplayEffect.CueDurational is { Length: > 0 })
|
if (GameplayEffect.CueDurational is { Length: > 0 })
|
||||||
{
|
{
|
||||||
_cueDurationalSpecs = ObjectPool.Instance.Fetch<List<GameplayCueDurationalSpec>>();
|
_cueDurationalSpecs = JexGasObjectPool.Instance.Fetch<List<GameplayCueDurationalSpec>>();
|
||||||
foreach (var cueDurational in GameplayEffect.CueDurational)
|
foreach (var cueDurational in GameplayEffect.CueDurational)
|
||||||
{
|
{
|
||||||
var cueSpec = cueDurational.ApplyFrom(this);
|
var cueSpec = cueDurational.ApplyFrom(this);
|
||||||
@ -323,7 +323,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (var cue in _cueDurationalSpecs)
|
foreach (var cue in _cueDurationalSpecs)
|
||||||
cue.OnAdd();
|
cue.OnAdd(-1,-1,-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -342,7 +342,7 @@ namespace GAS.Runtime
|
|||||||
if (_cueDurationalSpecs != null)
|
if (_cueDurationalSpecs != null)
|
||||||
{
|
{
|
||||||
foreach (var cue in _cueDurationalSpecs)
|
foreach (var cue in _cueDurationalSpecs)
|
||||||
cue.OnRemove();
|
cue.OnRemove(-1,-1,-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -401,7 +401,7 @@ namespace GAS.Runtime
|
|||||||
if (_cueDurationalSpecs != null)
|
if (_cueDurationalSpecs != null)
|
||||||
{
|
{
|
||||||
foreach (var cue in _cueDurationalSpecs)
|
foreach (var cue in _cueDurationalSpecs)
|
||||||
cue.OnTick();
|
cue.OnTick(-1,-1,-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -487,7 +487,7 @@ namespace GAS.Runtime
|
|||||||
{
|
{
|
||||||
case GameplayEffectSpecifiedSnapshotConfig.ESnapshotTarget.Source:
|
case GameplayEffectSpecifiedSnapshotConfig.ESnapshotTarget.Source:
|
||||||
{
|
{
|
||||||
SnapshotSourceAttributes ??= ObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
SnapshotSourceAttributes ??= JexGasObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
||||||
var attribute = Source.AttributeSetContainer.GetAttributeAttributeValue(config.AttributeSetName, config.AttributeShortName);
|
var attribute = Source.AttributeSetContainer.GetAttributeAttributeValue(config.AttributeSetName, config.AttributeShortName);
|
||||||
if (attribute != null)
|
if (attribute != null)
|
||||||
{
|
{
|
||||||
@ -502,7 +502,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
case GameplayEffectSpecifiedSnapshotConfig.ESnapshotTarget.Target:
|
case GameplayEffectSpecifiedSnapshotConfig.ESnapshotTarget.Target:
|
||||||
{
|
{
|
||||||
SnapshotTargetAttributes ??= ObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
SnapshotTargetAttributes ??= JexGasObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
||||||
var attribute = Owner.AttributeSetContainer.GetAttributeAttributeValue(config.AttributeSetName, config.AttributeShortName);
|
var attribute = Owner.AttributeSetContainer.GetAttributeAttributeValue(config.AttributeSetName, config.AttributeShortName);
|
||||||
if (attribute != null)
|
if (attribute != null)
|
||||||
{
|
{
|
||||||
@ -540,13 +540,13 @@ namespace GAS.Runtime
|
|||||||
|
|
||||||
public void RegisterValue(in GameplayTag tag, float value)
|
public void RegisterValue(in GameplayTag tag, float value)
|
||||||
{
|
{
|
||||||
_valueMapWithTag ??= ObjectPool.Instance.Fetch<Dictionary<GameplayTag, float>>();
|
_valueMapWithTag ??= JexGasObjectPool.Instance.Fetch<Dictionary<GameplayTag, float>>();
|
||||||
_valueMapWithTag[tag] = value;
|
_valueMapWithTag[tag] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterValue(string name, float value)
|
public void RegisterValue(string name, float value)
|
||||||
{
|
{
|
||||||
_valueMapWithName ??= ObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
_valueMapWithName ??= JexGasObjectPool.Instance.Fetch<Dictionary<string, float>>();
|
||||||
_valueMapWithName[name] = value;
|
_valueMapWithName[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +616,7 @@ namespace GAS.Runtime
|
|||||||
if (_cueDurationalSpecs != null)
|
if (_cueDurationalSpecs != null)
|
||||||
{
|
{
|
||||||
_cueDurationalSpecs.Clear();
|
_cueDurationalSpecs.Clear();
|
||||||
ObjectPool.Instance.Recycle(_cueDurationalSpecs);
|
JexGasObjectPool.Instance.Recycle(_cueDurationalSpecs);
|
||||||
_cueDurationalSpecs = null;
|
_cueDurationalSpecs = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ namespace GAS.Runtime
|
|||||||
|
|
||||||
public GrantedAbilitySpecFromEffect CreateSpec(GameplayEffectSpec sourceEffectSpec)
|
public GrantedAbilitySpecFromEffect CreateSpec(GameplayEffectSpec sourceEffectSpec)
|
||||||
{
|
{
|
||||||
var grantedAbilitySpecFromEffect = ObjectPool.Instance.Fetch<GrantedAbilitySpecFromEffect>();
|
var grantedAbilitySpecFromEffect = JexGasObjectPool.Instance.Fetch<GrantedAbilitySpecFromEffect>();
|
||||||
grantedAbilitySpecFromEffect.Awake(this, sourceEffectSpec);
|
grantedAbilitySpecFromEffect.Awake(this, sourceEffectSpec);
|
||||||
return grantedAbilitySpecFromEffect;
|
return grantedAbilitySpecFromEffect;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ namespace GAS.Runtime
|
|||||||
Owner = SourceEffectSpec.Owner;
|
Owner = SourceEffectSpec.Owner;
|
||||||
if (Owner.AbilityContainer.HasAbility(AbilityName))
|
if (Owner.AbilityContainer.HasAbility(AbilityName))
|
||||||
{
|
{
|
||||||
Debug.LogError($"GrantedAbilitySpecFromEffect: {Owner.name} already has ability {AbilityName}");
|
Debug.LogError($"GrantedAbilitySpecFromEffect: {Owner.EntityId} already has ability {AbilityName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Owner.GrantAbility(GrantedAbility.Ability);
|
Owner.GrantAbility(GrantedAbility.Ability);
|
||||||
|
29
JEX_GAS/Assets/GAS/Runtime/JexGasManager.cs
Normal file
29
JEX_GAS/Assets/GAS/Runtime/JexGasManager.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using GAS.General;
|
||||||
|
|
||||||
|
namespace GAS.Runtime
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 帧同步 EX_GAS 管理器 每次游戏开始和结束必须调用 Awake Destroy
|
||||||
|
/// </summary>
|
||||||
|
public class JexGasManager
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void Awake()
|
||||||
|
{
|
||||||
|
//初始化 GAS 对象池
|
||||||
|
JexGasObjectPool.Awake();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Destroy()
|
||||||
|
{
|
||||||
|
//销毁 GAS 对象池
|
||||||
|
JexGasObjectPool.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
3
JEX_GAS/Assets/GAS/Runtime/JexGasManager.cs.meta
Normal file
3
JEX_GAS/Assets/GAS/Runtime/JexGasManager.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b0b041f9937946109449a4143e1072a7
|
||||||
|
timeCreated: 1729241013
|
@ -157,7 +157,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var list = ObjectPool.Instance.Fetch<List<object>>();
|
var list = JexGasObjectPool.Instance.Fetch<List<object>>();
|
||||||
list.Add(source);
|
list.Add(source);
|
||||||
_dynamicAddedTags.Add(tag, list);
|
_dynamicAddedTags.Add(tag, list);
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ namespace GAS.Runtime
|
|||||||
if (_dynamicAddedTags.TryGetValue(tag, out var addedTag))
|
if (_dynamicAddedTags.TryGetValue(tag, out var addedTag))
|
||||||
{
|
{
|
||||||
addedTag.Clear();
|
addedTag.Clear();
|
||||||
ObjectPool.Instance.Recycle(addedTag);
|
JexGasObjectPool.Instance.Recycle(addedTag);
|
||||||
dirty = _dynamicAddedTags.Remove(tag);
|
dirty = _dynamicAddedTags.Remove(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ namespace GAS.Runtime
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var list = ObjectPool.Instance.Fetch<List<object>>();
|
var list = JexGasObjectPool.Instance.Fetch<List<object>>();
|
||||||
list.Add(source);
|
list.Add(source);
|
||||||
_dynamicRemovedTags.Add(tag, list);
|
_dynamicRemovedTags.Add(tag, list);
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ namespace GAS.Runtime
|
|||||||
dirty = tagList.Count == 0;
|
dirty = tagList.Count == 0;
|
||||||
if (dirty)
|
if (dirty)
|
||||||
{
|
{
|
||||||
ObjectPool.Instance.Recycle(tagList);
|
JexGasObjectPool.Instance.Recycle(tagList);
|
||||||
dynamicTag.Remove(tag);
|
dynamicTag.Remove(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,6 @@ GameObject:
|
|||||||
- component: {fileID: 857251292}
|
- component: {fileID: 857251292}
|
||||||
- component: {fileID: 857251291}
|
- component: {fileID: 857251291}
|
||||||
- component: {fileID: 857251290}
|
- component: {fileID: 857251290}
|
||||||
- component: {fileID: 857251294}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Cube
|
m_Name: Cube
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -316,26 +315,57 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 857251289}
|
m_GameObject: {fileID: 857251289}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 1, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &857251294
|
--- !u!1 &1745439352
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1745439354}
|
||||||
|
- component: {fileID: 1745439353}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Main
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1745439353
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 857251289}
|
m_GameObject: {fileID: 1745439352}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 183fdb9275244e99bf882bd2e9cb85d5, type: 3}
|
m_Script: {fileID: 11500000, guid: 0c3aa2f58b904ebe9fc64cc367c63d68, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
preset: {fileID: 11400000, guid: 7692a8d07949a5c46b6b5325ebb9a422, type: 2}
|
--- !u!4 &1745439354
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1745439352}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &2104190881
|
--- !u!1 &2104190881
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user