临时提交 我困了睡觉了

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-10-19 04:39:43 +08:00
parent 1315802fa2
commit 44e2735899
20 changed files with 213 additions and 37 deletions

View File

@@ -26,7 +26,6 @@ namespace GAS.General
_startTimestamp = Timestamp();
}
private static long _pauseTimestamp;
public static void Pause()
{

View File

@@ -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();
}
}
}

View File

@@ -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;
}
}