mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
临时提交 我困了睡觉了
This commit is contained in:
parent
1315802fa2
commit
44e2735899
@ -26,7 +26,6 @@ namespace GAS.General
|
||||
_startTimestamp = Timestamp();
|
||||
}
|
||||
|
||||
|
||||
private static long _pauseTimestamp;
|
||||
public static void Pause()
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 创建
|
||||
/// </summary>
|
||||
public virtual void OnCreate(){}
|
||||
|
||||
/// <summary>
|
||||
/// 激活
|
||||
/// </summary>
|
||||
public virtual void OnEnable()
|
||||
{
|
||||
Prepare();
|
||||
GameplayTagAggregator?.OnEnable();
|
||||
Enable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消激活
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using GAS.General;
|
||||
using System.Collections.Generic;
|
||||
using GAS.General;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
@ -8,22 +10,67 @@ namespace GAS.Runtime
|
||||
public class JexGasManager
|
||||
{
|
||||
|
||||
public List<AbilitySystemComponent> AbilitySystemComponents = new();
|
||||
|
||||
/// <summary>
|
||||
/// GAS 专用对象池 (只限制当前管理器)
|
||||
/// </summary>
|
||||
private JexGasObjectPool ObjectPool = new JexGasObjectPool();
|
||||
|
||||
public static void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Destroy()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
//GAS 更新
|
||||
public void Update()
|
||||
{
|
||||
|
||||
Profiler.BeginSample($"{nameof(JexGasManager)}::Tick()");
|
||||
|
||||
var abilitySystemComponents = JexGasObjectPool.Instance.Fetch<List<AbilitySystemComponent>>();
|
||||
abilitySystemComponents.AddRange(AbilitySystemComponents);
|
||||
|
||||
foreach (var abilitySystemComponent in abilitySystemComponents)
|
||||
{
|
||||
abilitySystemComponent.Tick();
|
||||
}
|
||||
|
||||
abilitySystemComponents.Clear();
|
||||
JexGasObjectPool.Instance.Recycle(abilitySystemComponents);
|
||||
|
||||
Profiler.EndSample();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 委托 AbilitySystemComponent
|
||||
/// </summary>
|
||||
public void Register(AbilitySystemComponent abilitySystemComponent)
|
||||
{
|
||||
if (AbilitySystemComponents.Contains(abilitySystemComponent)) return;
|
||||
AbilitySystemComponents.Add(abilitySystemComponent);
|
||||
abilitySystemComponent.OnEnable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消委托 AbilitySystemComponent
|
||||
/// </summary>
|
||||
public bool Unregister(AbilitySystemComponent abilitySystemComponent)
|
||||
{
|
||||
abilitySystemComponent.OnDisable();
|
||||
return AbilitySystemComponents.Remove(abilitySystemComponent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建 AbilitySystemComponent
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T CreateAbilitySystemComponent<T>(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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,13 +12,24 @@ namespace JNGame.Runtime.Sync.System.Logic
|
||||
/// <summary>
|
||||
/// GAS 管理器
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0b4adcd267e40ce862cac6801946216
|
||||
timeCreated: 1729283406
|
@ -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<JNGASSystem>().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<JNGASSystem>().Unregister(ASC);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acdb37e4e7c0494084eed1be8171efc6
|
||||
timeCreated: 1729283417
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cef9fd36c2e54625bb161cf4062337b9
|
||||
timeCreated: 1729282849
|
@ -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<JNGASComponent>();
|
||||
|
||||
public override void OnSyncStart()
|
||||
{
|
||||
|
||||
base.OnSyncStart();
|
||||
|
||||
//设置GAS 角色
|
||||
// GAS.SetPreset();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ac7f2bb23fb47efb3a21d1160e962ac
|
||||
timeCreated: 1729282871
|
@ -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<int, Type> types)
|
||||
{
|
||||
base.BindType(types);
|
||||
types.Add(Controller,typeof(JNGASBoxController));
|
||||
types.Add(GAS,typeof(JNGASComponent));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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<JNGASBoxController>(this);
|
||||
|
||||
public override JNEntityLookup NewCLookup()
|
||||
{
|
||||
return new JNGASBoxLookup();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
3
JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS.meta
Normal file
3
JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GAS.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09af0fe6bc634405a389bf3e8640507c
|
||||
timeCreated: 1729283193
|
@ -0,0 +1,11 @@
|
||||
using GAS.Runtime;
|
||||
|
||||
namespace GASSamples.Scripts.Game.GAS
|
||||
{
|
||||
|
||||
public class GAbilitySystemComponent : AbilitySystemComponent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f91a65c731e64bceb375e9f6eb571dd1
|
||||
timeCreated: 1729283247
|
@ -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(), //世界逻辑
|
||||
};
|
||||
}
|
||||
|
@ -74,8 +74,12 @@
|
||||
<Analyzer Include="C:\APP\UnityEdit\2022.3.16f1c1\Editor\Data\Tools\Unity.SourceGenerators\Unity.Properties.SourceGenerator.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\Entity\Nodes\Component\Components\JNGASComponent.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\Entity\Nodes\Component\Controller\JNGASBoxController.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\Entity\Nodes\Component\Lookup\JNGASBoxLookup.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\Entity\Nodes\Contexts\JNGASBoxContext.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\GAS\GAbilitySystemComponent.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\GAS\OngoingAbilityTasks\OngoingAbility_Debug.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\Entity\Contexts\JNGASBoxContext.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\View\DViewSystem.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Gen\GAttrLib.gen.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\GAS\GameplayCue\GameplayCue_PlayerDemo01.cs" />
|
||||
@ -87,7 +91,6 @@
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\Logic\System\DWorldSystem.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\App.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Gen\GTagLib.gen.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Game\Entity\Nodes\Component\Lookup\JNGASBoxLookup.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\AbilitySystemSamplesComponent.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Gen\AbilitySystemComponentExtension.gen.cs" />
|
||||
<Compile Include="Assets\Scripts\GASSamples\Scripts\Gen\GAbilityLib.gen.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user