diff --git a/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/General/GASTimer.cs b/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/General/GASTimer.cs
index e8ac1c42..46a4a08e 100644
--- a/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/General/GASTimer.cs
+++ b/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/General/GASTimer.cs
@@ -26,7 +26,6 @@ namespace GAS.General
_startTimestamp = Timestamp();
}
-
private static long _pauseTimestamp;
public static void Pause()
{
diff --git a/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/Component/AbilitySystemComponent.cs b/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/Component/AbilitySystemComponent.cs
index 52c7d5a1..39729a54 100644
--- a/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/Component/AbilitySystemComponent.cs
+++ b/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/Component/AbilitySystemComponent.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using GAS.General;
using UnityEngine;
namespace GAS.Runtime
@@ -26,6 +27,29 @@ namespace GAS.Runtime
private bool _ready;
+ ///
+ /// 创建
+ ///
+ public virtual void OnCreate(){}
+
+ ///
+ /// 激活
+ ///
+ public virtual void OnEnable()
+ {
+ Prepare();
+ GameplayTagAggregator?.OnEnable();
+ Enable();
+ }
+
+ ///
+ /// 取消激活
+ ///
+ public virtual void OnDisable()
+ {
+ Disable();
+ }
+
private void Prepare()
{
if (_ready) return;
@@ -49,31 +73,6 @@ namespace GAS.Runtime
GameplayTagAggregator?.OnDisable();
}
- private void Awake()
- {
- Prepare();
- }
-
- private void OnDestroy()
- {
- AttributeSetContainer.OnDestroy();
- UserData = null;
- }
-
- private void OnEnable()
- {
- Prepare();
- GameplayAbilitySystem.GAS.Register(this);
- GameplayTagAggregator?.OnEnable();
- Enable();
- }
-
- private void OnDisable()
- {
- Disable();
- GameplayAbilitySystem.GAS.Unregister(this);
- }
-
public void SetPreset(AbilitySystemComponentPreset ascPreset)
{
preset = ascPreset;
@@ -399,6 +398,5 @@ namespace GAS.Runtime
{
GameplayEffectContainer.ClearGameplayEffect();
}
-
}
}
diff --git a/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/JexGasManager.cs b/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/JexGasManager.cs
index 42e61ba3..b91222c5 100644
--- a/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/JexGasManager.cs
+++ b/JNFrame2/Assets/HotScripts/JNGame/Runtime/GAS/Runtime/JexGasManager.cs
@@ -1,4 +1,6 @@
-using GAS.General;
+using System.Collections.Generic;
+using GAS.General;
+using UnityEngine.Profiling;
namespace GAS.Runtime
{
@@ -7,23 +9,68 @@ namespace GAS.Runtime
///
public class JexGasManager
{
+
+ public List AbilitySystemComponents = new();
///
/// GAS 专用对象池 (只限制当前管理器)
///
private JexGasObjectPool ObjectPool = new JexGasObjectPool();
-
- public static void Awake()
+
+ //GAS 更新
+ public void Update()
{
+
+ Profiler.BeginSample($"{nameof(JexGasManager)}::Tick()");
+
+ var abilitySystemComponents = JexGasObjectPool.Instance.Fetch>();
+ abilitySystemComponents.AddRange(AbilitySystemComponents);
+
+ foreach (var abilitySystemComponent in abilitySystemComponents)
+ {
+ abilitySystemComponent.Tick();
+ }
+
+ abilitySystemComponents.Clear();
+ JexGasObjectPool.Instance.Recycle(abilitySystemComponents);
+
+ Profiler.EndSample();
+
+ }
+
+ ///
+ /// 委托 AbilitySystemComponent
+ ///
+ public void Register(AbilitySystemComponent abilitySystemComponent)
+ {
+ if (AbilitySystemComponents.Contains(abilitySystemComponent)) return;
+ AbilitySystemComponents.Add(abilitySystemComponent);
+ abilitySystemComponent.OnEnable();
}
- public static void Destroy()
+ ///
+ /// 取消委托 AbilitySystemComponent
+ ///
+ public bool Unregister(AbilitySystemComponent abilitySystemComponent)
{
+ abilitySystemComponent.OnDisable();
+ return AbilitySystemComponents.Remove(abilitySystemComponent);
}
- public static void Update()
+ ///
+ /// 创建 AbilitySystemComponent
+ ///
+ ///
+ public T CreateAbilitySystemComponent(AbilitySystemComponentPreset ascPreset,int level = 1) where T : AbilitySystemComponent, new()
{
+ var asc = new T();
+ asc.OnCreate();
+ asc.SetPreset(ascPreset);
+ asc.SetLevel(level);
+ Register(asc);
+ return asc;
+
}
}
diff --git a/JNFrame2/Assets/HotScripts/JNGame/Runtime/Sync/System/Logic/JNGASSystem.cs b/JNFrame2/Assets/HotScripts/JNGame/Runtime/Sync/System/Logic/JNGASSystem.cs
index bc7f2a6d..0135efa1 100644
--- a/JNFrame2/Assets/HotScripts/JNGame/Runtime/Sync/System/Logic/JNGASSystem.cs
+++ b/JNFrame2/Assets/HotScripts/JNGame/Runtime/Sync/System/Logic/JNGASSystem.cs
@@ -12,13 +12,24 @@ namespace JNGame.Runtime.Sync.System.Logic
///
/// GAS 管理器
///
- private JexGasManager _gas = new JexGasManager();
+ private JexGasManager _gas = new();
public JexGasManager GAS => _gas;
- public override void OnSyncStart()
+ public override void OnSyncUpdate(int dt)
{
- base.OnSyncStart();
+ GAS.Update();
}
+ public void Register(AbilitySystemComponent abilitySystemComponent)
+ {
+ GAS.Register(abilitySystemComponent);
+ }
+
+ public bool Unregister(AbilitySystemComponent abilitySystemComponent)
+ {
+ return GAS.Unregister(abilitySystemComponent);
+ }
+
+
}
}
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components.meta
new file mode 100644
index 00000000..129cae26
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: c0b4adcd267e40ce862cac6801946216
+timeCreated: 1729283406
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components/JNGASComponent.cs b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components/JNGASComponent.cs
new file mode 100644
index 00000000..3d965c50
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components/JNGASComponent.cs
@@ -0,0 +1,39 @@
+using GAS.Runtime;
+using GASSamples.Scripts.Game.GAS;
+using JNGame.Runtime.Sync.System.Logic;
+using JNGame.Sync.Entity.Component;
+
+namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Components
+{
+ public class JNGASComponent : JNComponent
+ {
+
+ private GAbilitySystemComponent ASC = new ();
+
+ public override void OnSyncStart()
+ {
+ base.OnSyncStart();
+
+ //初始化ASC
+ GetSystem().Register(ASC);
+ }
+
+ public void SetPreset(AbilitySystemComponentPreset ascPreset)
+ {
+ ASC.SetPreset(ascPreset);
+ }
+
+ public void SetLevel(int level)
+ {
+ ASC.SetLevel(level);
+ }
+
+ public override void OnSyncDestroy()
+ {
+ base.OnSyncDestroy();
+
+ //销毁ASC
+ GetSystem().Unregister(ASC);
+ }
+ }
+}
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components/JNGASComponent.cs.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components/JNGASComponent.cs.meta
new file mode 100644
index 00000000..063d8ea3
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Components/JNGASComponent.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: acdb37e4e7c0494084eed1be8171efc6
+timeCreated: 1729283417
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller.meta
new file mode 100644
index 00000000..bf24db89
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: cef9fd36c2e54625bb161cf4062337b9
+timeCreated: 1729282849
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller/JNGASBoxController.cs b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller/JNGASBoxController.cs
new file mode 100644
index 00000000..5af44795
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller/JNGASBoxController.cs
@@ -0,0 +1,22 @@
+using GASSamples.Scripts.Game.Entity.Nodes.Component.Components;
+using JNGame.Sync.Entity.Component;
+
+namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Controller
+{
+ public class JNGASBoxController : JNComponent
+ {
+
+ public JNGASComponent GAS => Entity.GetComponent();
+
+ public override void OnSyncStart()
+ {
+
+ base.OnSyncStart();
+
+ //设置GAS 角色
+ // GAS.SetPreset();
+
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller/JNGASBoxController.cs.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller/JNGASBoxController.cs.meta
new file mode 100644
index 00000000..c8d7e06f
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Controller/JNGASBoxController.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 2ac7f2bb23fb47efb3a21d1160e962ac
+timeCreated: 1729282871
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Lookup/JNGASBoxLookup.cs b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Lookup/JNGASBoxLookup.cs
index 3851c7e6..8e22885e 100644
--- a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Lookup/JNGASBoxLookup.cs
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Component/Lookup/JNGASBoxLookup.cs
@@ -1,3 +1,7 @@
+using System;
+using GASSamples.Scripts.Game.Entity.Nodes.Component.Components;
+using GASSamples.Scripts.Game.Entity.Nodes.Component.Controller;
+using JNGame.Runtime.Util.Types;
using JNGame.Sync.Entity.Component;
namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Lookup
@@ -5,5 +9,22 @@ namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Lookup
public class JNGASBoxLookup : JNEntityLookup
{
+ public int Controller { get; set; }
+ public int GAS { get; set; }
+
+ protected override void BindIndex()
+ {
+ base.BindIndex();
+ Controller = Next();
+ GAS = Next();
+ }
+
+ protected override void BindType(KeyValue types)
+ {
+ base.BindType(types);
+ types.Add(Controller,typeof(JNGASBoxController));
+ types.Add(GAS,typeof(JNGASComponent));
+ }
+
}
}
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Contexts.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Contexts.meta
similarity index 100%
rename from JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Contexts.meta
rename to JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Contexts.meta
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Contexts/JNGASBoxContext.cs b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Contexts/JNGASBoxContext.cs
similarity index 100%
rename from JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Contexts/JNGASBoxContext.cs
rename to JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Contexts/JNGASBoxContext.cs
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Contexts/JNGASBoxContext.cs.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Contexts/JNGASBoxContext.cs.meta
similarity index 100%
rename from JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Contexts/JNGASBoxContext.cs.meta
rename to JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/Contexts/JNGASBoxContext.cs.meta
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/JNGASBox.cs b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/JNGASBox.cs
index ccef51ac..53b55190 100644
--- a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/JNGASBox.cs
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/Entity/Nodes/JNGASBox.cs
@@ -1,3 +1,4 @@
+using GASSamples.Scripts.Game.Entity.Nodes.Component.Controller;
using GASSamples.Scripts.Game.Entity.Nodes.Component.Lookup;
using JNGame.Sync.Entity;
using JNGame.Sync.Entity.Component;
@@ -6,9 +7,13 @@ namespace GASSamples.Scripts.Game.Entity.Nodes
{
public class JNGASBox : JNEntity
{
+
+ public JNGASBoxController Controller => CLookup.Query(this);
+
public override JNEntityLookup NewCLookup()
{
return new JNGASBoxLookup();
}
+
}
}
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS.meta
new file mode 100644
index 00000000..5ba7ed9a
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 09af0fe6bc634405a389bf3e8640507c
+timeCreated: 1729283193
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS/GAbilitySystemComponent.cs b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS/GAbilitySystemComponent.cs
new file mode 100644
index 00000000..c42bbdc8
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS/GAbilitySystemComponent.cs
@@ -0,0 +1,11 @@
+using GAS.Runtime;
+
+namespace GASSamples.Scripts.Game.GAS
+{
+
+ public class GAbilitySystemComponent : AbilitySystemComponent
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS/GAbilitySystemComponent.cs.meta b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS/GAbilitySystemComponent.cs.meta
new file mode 100644
index 00000000..41657a77
--- /dev/null
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS/GAbilitySystemComponent.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: f91a65c731e64bceb375e9f6eb571dd1
+timeCreated: 1729283247
\ No newline at end of file
diff --git a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Sync/JNGASFrameSystem.cs b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Sync/JNGASFrameSystem.cs
index d4d440dc..8b57d588 100644
--- a/JNFrame2/Assets/Scripts/GASSamples/Scripts/Sync/JNGASFrameSystem.cs
+++ b/JNFrame2/Assets/Scripts/GASSamples/Scripts/Sync/JNGASFrameSystem.cs
@@ -4,6 +4,7 @@ using GASSamples.Scripts.Game.Entity;
using GASSamples.Scripts.Game.Logic.Data;
using GASSamples.Scripts.Game.Logic.System;
using GASSamples.Scripts.Game.View;
+using JNGame.Runtime.Sync.System.Logic;
using JNGame.Sync.Entity;
using JNGame.Sync.Frame;
using JNGame.Sync.System;
@@ -20,6 +21,7 @@ namespace DefaultNamespace
{
//基础数据
new DInputSystem(), //游戏输入
+ new JNGASSystem(), //GAS 系统
new DWorldSystem(), //世界逻辑
};
}
diff --git a/JNFrame2/GASSamples.csproj b/JNFrame2/GASSamples.csproj
index 07116ae5..2e132e8c 100644
--- a/JNFrame2/GASSamples.csproj
+++ b/JNFrame2/GASSamples.csproj
@@ -74,8 +74,12 @@
+
+
+
+
+
-
@@ -87,7 +91,6 @@
-