mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
临时提交 我困了睡觉了
This commit is contained in:
@@ -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
|
||||
{
|
||||
@@ -7,23 +9,68 @@ namespace GAS.Runtime
|
||||
/// </summary>
|
||||
public class JexGasManager
|
||||
{
|
||||
|
||||
public List<AbilitySystemComponent> AbilitySystemComponents = new();
|
||||
|
||||
/// <summary>
|
||||
/// GAS 专用对象池 (只限制当前管理器)
|
||||
/// </summary>
|
||||
private JexGasObjectPool ObjectPool = new JexGasObjectPool();
|
||||
|
||||
public static void Awake()
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
public static void Destroy()
|
||||
/// <summary>
|
||||
/// 取消委托 AbilitySystemComponent
|
||||
/// </summary>
|
||||
public bool Unregister(AbilitySystemComponent abilitySystemComponent)
|
||||
{
|
||||
abilitySystemComponent.OnDisable();
|
||||
return AbilitySystemComponents.Remove(abilitySystemComponent);
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
/// <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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user