mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
基础案例 准备改帧同步了
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using GAS.Runtime;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
namespace GAS.Editor
|
||||
{
|
||||
@@ -9,7 +11,7 @@ namespace GAS.Editor
|
||||
public const int StandardFrameUnitWidth = 1;
|
||||
public const int MaxFrameUnitLevel= 20;
|
||||
public const float MinTimerShaftFrameDrawStep = 5;
|
||||
public int DefaultFrameRate => GASTimer.FrameRate;
|
||||
public int DefaultFrameRate => JexGasManager.FrameRate;
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -136,8 +136,8 @@ namespace GAS.Editor
|
||||
{
|
||||
if (_selected == null || _selected.Id == 0)
|
||||
{
|
||||
_selected = GAS.GameplayAbilitySystem.GAS.AbilitySystemComponents.Count > 0
|
||||
? GAS.GameplayAbilitySystem.GAS.AbilitySystemComponents[0] as AbilitySystemComponent
|
||||
_selected = JexGasManager.Editor.AbilitySystemComponents.Count > 0
|
||||
? JexGasManager.Editor.AbilitySystemComponents[0] as AbilitySystemComponent
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace GAS.Editor
|
||||
if (!IsPlaying) return;
|
||||
|
||||
menuScrollPos = EditorGUILayout.BeginScrollView(menuScrollPos, GUI.skin.box);
|
||||
foreach (var iasc in GAS.GameplayAbilitySystem.GAS.AbilitySystemComponents)
|
||||
foreach (var iasc in JexGasManager.Editor.AbilitySystemComponents)
|
||||
{
|
||||
var asc = (AbilitySystemComponent)iasc;
|
||||
var presetName = asc.Preset != null ? asc.Preset.name : "NoPreset";
|
||||
|
@@ -623,6 +623,11 @@ namespace JNGame.Math
|
||||
public static readonly LFloat EPS_1MS = new LFloat(null, 1L);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 10
|
||||
/// </summary>
|
||||
public static LFloat L05 => new("",500);
|
||||
|
||||
/// <summary>
|
||||
/// 10
|
||||
/// </summary>
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using GAS.Runtime;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS.General
|
||||
@@ -16,7 +17,7 @@ namespace GAS.General
|
||||
public static int CurrentFrameCount => _currentFrameCount;
|
||||
public static void UpdateCurrentFrameCount()
|
||||
{
|
||||
_currentFrameCount = Mathf.FloorToInt((Timestamp() - _startTimestamp) / 1000f * FrameRate);
|
||||
_currentFrameCount = Mathf.FloorToInt((Timestamp() - _startTimestamp) / 1000f * JexGasManager.FrameRate);
|
||||
}
|
||||
|
||||
private static long _startTimestamp;
|
||||
@@ -37,7 +38,5 @@ namespace GAS.General
|
||||
_deltaTime -= (int)(Timestamp() - _pauseTimestamp);
|
||||
}
|
||||
|
||||
private static int _frameRate = 60;
|
||||
public static int FrameRate => _frameRate;
|
||||
}
|
||||
}
|
@@ -78,8 +78,8 @@ namespace GAS.Runtime
|
||||
[TabGroup("Base/H1/V2", "General")]
|
||||
[LabelWidth(WIDTH_LABEL)]
|
||||
[LabelText(SdfIconType.ClockFill, Text = GASTextDefine.ABILITY_CD_TIME)]
|
||||
[Unit(Units.Second)]
|
||||
public float CooldownTime;
|
||||
[Unit(Units.Millisecond)]
|
||||
public int CooldownTime;
|
||||
|
||||
// Tags
|
||||
[TabGroup("Base/H1/V3", "Tags", SdfIconType.TagsFill, TextColor = "#45B1FF", Order = 3)]
|
||||
|
@@ -14,14 +14,14 @@ namespace GAS.Runtime
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick(int dt)
|
||||
{
|
||||
var abilitySpecs = JexGasObjectPool.Instance.Fetch<List<AbilitySpec>>();
|
||||
abilitySpecs.AddRange(_abilities.Values);
|
||||
|
||||
foreach (var abilitySpec in abilitySpecs)
|
||||
{
|
||||
abilitySpec.Tick();
|
||||
abilitySpec.Tick(dt);
|
||||
}
|
||||
|
||||
abilitySpecs.Clear();
|
||||
|
@@ -212,15 +212,15 @@ namespace GAS.Runtime
|
||||
_onCancelAbility?.Invoke();
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick(int dt)
|
||||
{
|
||||
if (IsActive)
|
||||
{
|
||||
AbilityTick();
|
||||
AbilityTick(dt);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void AbilityTick()
|
||||
protected virtual void AbilityTick(int dt)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ namespace GAS.Runtime
|
||||
|
||||
public GameplayEffect Cooldown { get; protected set; }
|
||||
|
||||
public float CooldownTime { get; protected set; }
|
||||
public int CooldownTime { get; protected set; }
|
||||
|
||||
public GameplayEffect Cost { get; protected set; }
|
||||
|
||||
|
@@ -56,10 +56,10 @@ namespace GAS.Runtime
|
||||
_player.Stop();
|
||||
}
|
||||
|
||||
protected override void AbilityTick()
|
||||
protected override void AbilityTick(int dt)
|
||||
{
|
||||
Profiler.BeginSample("TimelineAbilitySpecT<T>::AbilityTick()");
|
||||
_player.Tick();
|
||||
_player.Tick(dt);
|
||||
Profiler.EndSample();
|
||||
}
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ namespace GAS.Runtime
|
||||
|
||||
public AssetT AbilityAsset => _abilitySpec.Data.AbilityAsset;
|
||||
public int FrameCount => AbilityAsset.FrameCount;
|
||||
public int FrameRate => GASTimer.FrameRate;
|
||||
public int FrameRate => JexGasManager.FrameRate;
|
||||
|
||||
/// <summary>
|
||||
/// 不受播放速率影响的总时间
|
||||
@@ -241,14 +241,14 @@ namespace GAS.Runtime
|
||||
IsPlaying = false;
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick(int dt)
|
||||
{
|
||||
if (!IsPlaying) return;
|
||||
|
||||
var speed = _abilitySpec.GetPlaySpeed();
|
||||
speed = Math.Max(0, speed);
|
||||
_playTotalTime += Time.deltaTime * speed;
|
||||
var targetFrame = (int)(_playTotalTime * FrameRate);
|
||||
_playTotalTime += dt * speed;
|
||||
var targetFrame = ((int)(_playTotalTime * FrameRate)) / 1000;
|
||||
|
||||
// 追帧
|
||||
while (_currentFrame < targetFrame)
|
||||
|
@@ -282,10 +282,10 @@ namespace GAS.Runtime
|
||||
return value;
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick(int dt)
|
||||
{
|
||||
AbilityContainer.Tick();
|
||||
GameplayEffectContainer.Tick();
|
||||
AbilityContainer.Tick(dt);
|
||||
GameplayEffectContainer.Tick(dt);
|
||||
}
|
||||
|
||||
public Dictionary<string, float> DataSnapshot()
|
||||
|
@@ -31,7 +31,7 @@ namespace GAS.Runtime
|
||||
|
||||
void RemoveGameplayEffect(GameplayEffectSpec spec);
|
||||
|
||||
void Tick();
|
||||
void Tick(int dt);
|
||||
|
||||
Dictionary<string, float> DataSnapshot();
|
||||
|
||||
|
@@ -1,99 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using GAS.General;
|
||||
using GAS.Runtime;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace GAS
|
||||
{
|
||||
public class GameplayAbilitySystem
|
||||
{
|
||||
private static GameplayAbilitySystem _gas;
|
||||
|
||||
private GameplayAbilitySystem()
|
||||
{
|
||||
const int capacity = 1024;
|
||||
AbilitySystemComponents = new List<AbilitySystemComponent>(capacity);
|
||||
GASTimer.InitStartTimestamp();
|
||||
|
||||
GasHost = new GameObject("GAS Host").AddComponent<GasHost>();
|
||||
GasHost.hideFlags = HideFlags.HideAndDontSave;
|
||||
Object.DontDestroyOnLoad(GasHost.gameObject);
|
||||
GasHost.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public List<AbilitySystemComponent> AbilitySystemComponents { get; }
|
||||
|
||||
private GasHost GasHost { get; }
|
||||
|
||||
public static GameplayAbilitySystem GAS
|
||||
{
|
||||
get
|
||||
{
|
||||
_gas ??= new GameplayAbilitySystem();
|
||||
return _gas;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPaused => !GasHost.enabled;
|
||||
|
||||
public void Register(AbilitySystemComponent abilitySystemComponent)
|
||||
{
|
||||
// if (!GasHost.enabled)
|
||||
// {
|
||||
// Debug.LogWarning("[EX] GAS is paused, can't register new ASC!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (AbilitySystemComponents.Contains(abilitySystemComponent)) return;
|
||||
AbilitySystemComponents.Add(abilitySystemComponent);
|
||||
}
|
||||
|
||||
public bool Unregister(AbilitySystemComponent abilitySystemComponent)
|
||||
{
|
||||
// if (!GasHost.enabled)
|
||||
// {
|
||||
// Debug.LogWarning("[EX] GAS is paused, can't unregister ASC!");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return AbilitySystemComponents.Remove(abilitySystemComponent);
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
GasHost.enabled = false;
|
||||
}
|
||||
|
||||
public void Unpause()
|
||||
{
|
||||
GasHost.enabled = true;
|
||||
}
|
||||
|
||||
public void ClearComponents()
|
||||
{
|
||||
foreach (var t in AbilitySystemComponents)
|
||||
t.Disable();
|
||||
|
||||
AbilitySystemComponents.Clear();
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
Profiler.BeginSample($"{nameof(GameplayAbilitySystem)}::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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98a325bbe54441739d7e05e89817e9a5
|
||||
timeCreated: 1701861619
|
@@ -1,21 +0,0 @@
|
||||
using GAS.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS
|
||||
{
|
||||
public class GasHost : MonoBehaviour
|
||||
{
|
||||
private GameplayAbilitySystem _gas => GameplayAbilitySystem.GAS;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
GASTimer.UpdateCurrentFrameCount();
|
||||
_gas.Tick();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_gas.ClearComponents();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c17e2cf434ca2f549b2fbd2dc0ecc4c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -37,7 +37,7 @@ namespace GAS.Runtime
|
||||
{
|
||||
public readonly string GameplayEffectName;
|
||||
public readonly EffectsDurationPolicy DurationPolicy;
|
||||
public readonly float Duration; // -1 represents infinite duration
|
||||
public readonly int Duration; // -1 represents infinite duration
|
||||
public readonly float Period;
|
||||
public readonly GameplayEffect PeriodExecution;
|
||||
public readonly GameplayEffectTagContainer TagContainer;
|
||||
|
@@ -55,9 +55,9 @@ namespace GAS.Runtime
|
||||
[LabelWidth(WIDTH_LABEL)]
|
||||
[LabelText(GASTextDefine.LABLE_GE_DURATION, SdfIconType.HourglassSplit)]
|
||||
[EnableIf("@DurationPolicy == EffectsDurationPolicy.Duration")]
|
||||
[Unit(Units.Second)]
|
||||
[Unit(Units.Millisecond)]
|
||||
[ValidateInput("@DurationPolicy != EffectsDurationPolicy.Duration || Duration > 0", ERROR_DURATION)]
|
||||
public float Duration;
|
||||
public int Duration;
|
||||
|
||||
[ShowIf("@DurationPolicy != EffectsDurationPolicy.Duration")]
|
||||
[TabGroup(GRP_BASE_H_RIGHT, "Policy")]
|
||||
@@ -65,9 +65,9 @@ namespace GAS.Runtime
|
||||
[LabelWidth(WIDTH_LABEL)]
|
||||
[LabelText(GASTextDefine.LABLE_GE_INTERVAL, SdfIconType.AlarmFill)]
|
||||
[EnableIf("IsDurationalPolicy")]
|
||||
[Unit(Units.Second)]
|
||||
[Unit(Units.Millisecond)]
|
||||
[ValidateInput("@DurationPolicy != EffectsDurationPolicy.Infinite || Period <= 0 || Period >= 0.01f", "Period < 0.01", InfoMessageType.Warning)]
|
||||
public float Period;
|
||||
public int Period;
|
||||
|
||||
[ShowIf("@DurationPolicy == EffectsDurationPolicy.Duration"),]
|
||||
[TabGroup(GRP_BASE_H_RIGHT, "Policy")]
|
||||
@@ -80,7 +80,7 @@ namespace GAS.Runtime
|
||||
[PropertyRange(0, "@Duration")]
|
||||
[ValidateInput("@DurationPolicy != EffectsDurationPolicy.Duration || Period <= 0 || Period >= 0.01f", "Period < 0.01", InfoMessageType.Warning)]
|
||||
// 这个Property是为了给"限时型"效果绘制一个范围滑动条
|
||||
public float PeriodForDurational
|
||||
public int PeriodForDurational
|
||||
{
|
||||
get => Period;
|
||||
set => Period = value;
|
||||
@@ -325,9 +325,9 @@ namespace GAS.Runtime
|
||||
|
||||
public EffectsDurationPolicy GetDurationPolicy() => DurationPolicy;
|
||||
|
||||
public float GetDuration() => Duration;
|
||||
public int GetDuration() => Duration;
|
||||
|
||||
public float GetPeriod() => Period;
|
||||
public int GetPeriod() => Period;
|
||||
|
||||
public IGameplayEffectData GetPeriodExecution() => PeriodExecution;
|
||||
|
||||
|
@@ -22,7 +22,7 @@ namespace GAS.Runtime
|
||||
return _gameplayEffectSpecs;
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick(int dt)
|
||||
{
|
||||
var gameplayEffectSpecs = JexGasObjectPool.Instance.Fetch<List<GameplayEffectSpec>>();
|
||||
gameplayEffectSpecs.AddRange(_gameplayEffectSpecs);
|
||||
@@ -31,7 +31,7 @@ namespace GAS.Runtime
|
||||
{
|
||||
if (gameplayEffectSpec.IsActive)
|
||||
{
|
||||
gameplayEffectSpec.Tick();
|
||||
gameplayEffectSpec.Tick(dt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,9 +21,9 @@ namespace GAS.Runtime
|
||||
|
||||
public virtual EffectsDurationPolicy GetDurationPolicy() => EffectsDurationPolicy.Instant;
|
||||
|
||||
public virtual float GetDuration() => -1;
|
||||
public virtual int GetDuration() => -1;
|
||||
|
||||
public virtual float GetPeriod() => 0;
|
||||
public virtual int GetPeriod() => 0;
|
||||
|
||||
public virtual IGameplayEffectData GetPeriodExecution() => null;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace GAS.Runtime
|
||||
|
||||
public class InfiniteGameplayEffectData : InstantGameplayEffectData
|
||||
{
|
||||
public float Period { get; }
|
||||
public int Period { get; }
|
||||
|
||||
public IGameplayEffectData PeriodExecution { get; set; } = null;
|
||||
|
||||
@@ -83,11 +83,11 @@ namespace GAS.Runtime
|
||||
public GrantedAbilityConfig[] GrantedAbilities { get; set; } = Array.Empty<GrantedAbilityConfig>();
|
||||
public GameplayEffectStacking Stacking { get; set; } = GameplayEffectStacking.None;
|
||||
|
||||
public InfiniteGameplayEffectData(string name, float period) : base(name) => Period = period;
|
||||
public InfiniteGameplayEffectData(string name, int period) : base(name) => Period = period;
|
||||
|
||||
public override EffectsDurationPolicy GetDurationPolicy() => EffectsDurationPolicy.Infinite;
|
||||
|
||||
public override float GetPeriod() => Period;
|
||||
public override int GetPeriod() => Period;
|
||||
|
||||
public override IGameplayEffectData GetPeriodExecution() => PeriodExecution;
|
||||
|
||||
@@ -114,14 +114,15 @@ namespace GAS.Runtime
|
||||
public override GameplayEffectStacking GetStacking() => Stacking;
|
||||
}
|
||||
|
||||
|
||||
public class DurationalGameplayEffectData : InfiniteGameplayEffectData
|
||||
{
|
||||
public float Duration { get; }
|
||||
public int Duration { get; }
|
||||
|
||||
public DurationalGameplayEffectData(string name, float period, float duration) : base(name, period) => Duration = duration;
|
||||
public DurationalGameplayEffectData(string name, int period, int duration) : base(name, period) => Duration = duration;
|
||||
|
||||
public override EffectsDurationPolicy GetDurationPolicy() => EffectsDurationPolicy.Duration;
|
||||
|
||||
public override float GetDuration() => Duration;
|
||||
public override int GetDuration() => Duration;
|
||||
}
|
||||
}
|
@@ -25,11 +25,11 @@ namespace GAS.Runtime
|
||||
|
||||
private float Period => _spec.GameplayEffect.Period;
|
||||
|
||||
public void Tick()
|
||||
public void Tick(int dt)
|
||||
{
|
||||
_spec.TriggerOnTick();
|
||||
|
||||
UpdatePeriod();
|
||||
UpdatePeriod(dt);
|
||||
|
||||
if (_spec.DurationPolicy == EffectsDurationPolicy.Duration && _spec.DurationRemaining() <= 0)
|
||||
{
|
||||
@@ -69,29 +69,26 @@ namespace GAS.Runtime
|
||||
/// <summary>
|
||||
/// 注意: Period 小于 0.01f 可能出现误差, 基本够用了
|
||||
/// </summary>
|
||||
private void UpdatePeriod()
|
||||
private void UpdatePeriod(int dt)
|
||||
{
|
||||
// 前提: Period不会动态修改
|
||||
if (Period <= 0) return;
|
||||
|
||||
var actualDuration = Time.time - _spec.ActivationTime;
|
||||
if (actualDuration < Mathf.Epsilon)
|
||||
if ( _spec.ActivationTime == 0)
|
||||
{
|
||||
// 第一次执行
|
||||
return;
|
||||
}
|
||||
|
||||
var dt = Time.deltaTime;
|
||||
|
||||
if (_spec.DurationPolicy == EffectsDurationPolicy.Duration)
|
||||
{
|
||||
var excessDuration = actualDuration - _spec.Duration;
|
||||
int excessDuration = _spec.ActivationTime - _spec.Duration;
|
||||
if (excessDuration >= 0)
|
||||
{
|
||||
// 如果超出了持续时间,就减去超出的时间, 此时应该是最后一次执行
|
||||
dt -= excessDuration;
|
||||
// 为了避免误差, 保证最后一次边界得到执行机会
|
||||
dt += 0.0001f;
|
||||
dt += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -150,14 +150,14 @@ namespace GAS.Runtime
|
||||
}
|
||||
|
||||
public GameplayEffect GameplayEffect { get; private set; }
|
||||
public float ActivationTime { get; private set; }
|
||||
public int ActivationTime { get; private set; }
|
||||
public float Level { get; private set; }
|
||||
public AbilitySystemComponent Source { get; private set; }
|
||||
public AbilitySystemComponent Owner { get; private set; }
|
||||
public bool IsApplied { get; private set; }
|
||||
public bool IsActive { get; private set; }
|
||||
internal EntityRef<GameplayEffectPeriodTicker> PeriodTicker { get; private set; }
|
||||
public float Duration { get; private set; }
|
||||
public int Duration { get; private set; }
|
||||
public EffectsDurationPolicy DurationPolicy { get; private set; }
|
||||
public EntityRef<GameplayEffectSpec> PeriodExecution { get; private set; }
|
||||
public GameplayEffectModifier[] Modifiers { get; private set; }
|
||||
@@ -173,13 +173,12 @@ namespace GAS.Runtime
|
||||
/// </summary>
|
||||
public int StackCount { get; private set; } = 1;
|
||||
|
||||
|
||||
public float DurationRemaining()
|
||||
{
|
||||
if (DurationPolicy == EffectsDurationPolicy.Infinite)
|
||||
return -1;
|
||||
|
||||
return Mathf.Max(0, Duration - (Time.time - ActivationTime));
|
||||
return Mathf.Max(0, Duration - ActivationTime);
|
||||
}
|
||||
|
||||
public void SetLevel(float level)
|
||||
@@ -187,12 +186,12 @@ namespace GAS.Runtime
|
||||
Level = level;
|
||||
}
|
||||
|
||||
public void SetActivationTime(float activationTime)
|
||||
public void SetActivationTime(int activationTime)
|
||||
{
|
||||
ActivationTime = activationTime;
|
||||
}
|
||||
|
||||
public void SetDuration(float duration)
|
||||
public void SetDuration(int duration)
|
||||
{
|
||||
Duration = duration;
|
||||
}
|
||||
@@ -271,7 +270,7 @@ namespace GAS.Runtime
|
||||
{
|
||||
if (IsActive) return;
|
||||
IsActive = true;
|
||||
ActivationTime = Time.time;
|
||||
ActivationTime = 0;
|
||||
TriggerOnActivation();
|
||||
}
|
||||
|
||||
@@ -282,9 +281,10 @@ namespace GAS.Runtime
|
||||
TriggerOnDeactivation();
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick(int dt)
|
||||
{
|
||||
PeriodTicker.Value?.Tick();
|
||||
ActivationTime += dt;
|
||||
PeriodTicker.Value?.Tick(dt);
|
||||
}
|
||||
|
||||
void TriggerInstantCues(GameplayCueInstant[] cues)
|
||||
@@ -679,7 +679,7 @@ namespace GAS.Runtime
|
||||
|
||||
public void RefreshDuration()
|
||||
{
|
||||
ActivationTime = Time.time;
|
||||
ActivationTime = 0;
|
||||
}
|
||||
|
||||
private void OnStackCountChange(int oldStackCount, int newStackCount)
|
||||
|
@@ -4,8 +4,8 @@
|
||||
{
|
||||
string GetDisplayName();
|
||||
EffectsDurationPolicy GetDurationPolicy();
|
||||
float GetDuration();
|
||||
float GetPeriod();
|
||||
int GetDuration();
|
||||
int GetPeriod();
|
||||
GameplayEffectSnapshotPolicy GetSnapshotPolicy();
|
||||
GameplayEffectSpecifiedSnapshotConfig[] GetSpecifiedSnapshotConfigs();
|
||||
|
||||
|
@@ -10,6 +10,22 @@ namespace GAS.Runtime
|
||||
public class JexGasManager
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
//编辑器专用的单例 用于预览GAS
|
||||
public static JexGasManager Editor = new JexGasManager();
|
||||
#endif
|
||||
|
||||
public JexGasManager()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
//预览GAS
|
||||
Editor = this;
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------- 全局信息 ------------------------------------------------------------------------------------------
|
||||
public static int FrameRate = 10; //每秒帧
|
||||
|
||||
public List<AbilitySystemComponent> AbilitySystemComponents = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -18,7 +34,7 @@ namespace GAS.Runtime
|
||||
private JexGasObjectPool ObjectPool = new JexGasObjectPool();
|
||||
|
||||
//GAS 更新
|
||||
public void Update()
|
||||
public void Update(int dt)
|
||||
{
|
||||
|
||||
Profiler.BeginSample($"{nameof(JexGasManager)}::Tick()");
|
||||
@@ -28,7 +44,7 @@ namespace GAS.Runtime
|
||||
|
||||
foreach (var abilitySystemComponent in abilitySystemComponents)
|
||||
{
|
||||
abilitySystemComponent.Tick();
|
||||
abilitySystemComponent.Tick(dt);
|
||||
}
|
||||
|
||||
abilitySystemComponents.Clear();
|
||||
|
3
JNFrame2/Assets/HotScripts/JNGame/Runtime/Odin.meta
Normal file
3
JNFrame2/Assets/HotScripts/JNGame/Runtime/Odin.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49241b5db40b450f934fb9de0841b2fc
|
||||
timeCreated: 1729415696
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f1317ff9b314419b0e48ae76657c960
|
||||
timeCreated: 1729415730
|
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using JNGame.Math;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Runtime.Odin.TypeCustomize
|
||||
{
|
||||
[Serializable]
|
||||
public class OdinLVector3
|
||||
{
|
||||
[LabelText("X (x1000)")]
|
||||
public int X;
|
||||
[LabelText("Y (x1000)")]
|
||||
public int Y;
|
||||
[LabelText("Z (x1000)")]
|
||||
public int Z;
|
||||
|
||||
public Vector3 ToVector3()
|
||||
{
|
||||
return (new LVector3(true, X * LFloat.RateOfOldPrecision, Y * LFloat.RateOfOldPrecision, Z * LFloat.RateOfOldPrecision)).ToVector3();
|
||||
}
|
||||
|
||||
public LVector3 ToLVector3()
|
||||
{
|
||||
return (new LVector3(true, X * LFloat.RateOfOldPrecision, Y * LFloat.RateOfOldPrecision, Z * LFloat.RateOfOldPrecision));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfdfa8bae636419282b29d0cfb4d9239
|
||||
timeCreated: 1729415750
|
@@ -7,6 +7,7 @@ namespace JNGame.Sync.Frame.Entity.Component.Components
|
||||
{
|
||||
|
||||
public LVector3 Position = new();
|
||||
public LVector3 Scale = new(1,1,1);
|
||||
|
||||
public bool IsRange(LVector3 target,LFloat len)
|
||||
{
|
||||
|
@@ -113,7 +113,9 @@ namespace JNGame.Sync.Frame.Entity
|
||||
}
|
||||
|
||||
//生命周期
|
||||
public virtual void OnSyncStart(){}
|
||||
public virtual void OnSyncStart()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnSyncUpdate(int dt)
|
||||
{
|
||||
@@ -128,7 +130,8 @@ namespace JNGame.Sync.Frame.Entity
|
||||
}
|
||||
|
||||
public virtual void OnSyncDestroy()
|
||||
{}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public interface IJNContext : IJNSyncCycle
|
||||
|
@@ -39,13 +39,17 @@ namespace JNGame.Sync.Entity
|
||||
public JNEntityLookup CLookup{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 坐标
|
||||
/// Transform 组件
|
||||
/// </summary>
|
||||
public JNTransformComponent Transform => CLookup.Query<JNTransformComponent>(this);
|
||||
/// <summary>
|
||||
/// 位置
|
||||
/// </summary>
|
||||
public LVector3 Position => Transform.Position;
|
||||
/// <summary>
|
||||
/// 大小
|
||||
/// </summary>
|
||||
public LVector3 Scale => Transform.Scale;
|
||||
|
||||
public bool IsDelayDestroy { get; private set; } = false;
|
||||
|
||||
@@ -142,7 +146,9 @@ namespace JNGame.Sync.Entity
|
||||
}
|
||||
|
||||
//生命周期
|
||||
public virtual void OnSyncStart(){}
|
||||
public virtual void OnSyncStart()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnSyncUpdate(int dt)
|
||||
{
|
||||
|
@@ -4,8 +4,11 @@ using UnityEngine;
|
||||
|
||||
namespace JNGame.Sync.System.Data.Type
|
||||
{
|
||||
/// <summary>
|
||||
/// 用于传输的 LVector3 类型
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DValuePosition
|
||||
public class NDataLVector3
|
||||
{
|
||||
public long x;
|
||||
public long y;
|
||||
@@ -23,7 +26,7 @@ namespace JNGame.Sync.System.Data.Type
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is not DValuePosition old) return false;
|
||||
if (obj is not NDataLVector3 old) return false;
|
||||
return old.x == x && old.y == y && old.z == z;
|
||||
}
|
||||
|
||||
@@ -32,9 +35,9 @@ namespace JNGame.Sync.System.Data.Type
|
||||
return new LVector3(new LFloat(true,x), new LFloat(true,y), new LFloat(true,z));
|
||||
}
|
||||
|
||||
public static DValuePosition Build(LVector3 vec3)
|
||||
public static NDataLVector3 Build(LVector3 vec3)
|
||||
{
|
||||
return new DValuePosition()
|
||||
return new NDataLVector3()
|
||||
{
|
||||
x = vec3.x.rawValue,
|
||||
y = vec3.y.rawValue,
|
@@ -1,5 +1,6 @@
|
||||
using GAS.Runtime;
|
||||
using JNGame.Sync.System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Runtime.Sync.System.Logic
|
||||
{
|
||||
@@ -14,10 +15,10 @@ namespace JNGame.Runtime.Sync.System.Logic
|
||||
/// </summary>
|
||||
private JexGasManager _gas = new();
|
||||
public JexGasManager GAS => _gas;
|
||||
|
||||
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
GAS.Update();
|
||||
GAS.Update(dt);
|
||||
}
|
||||
|
||||
public void Register(AbilitySystemComponent abilitySystemComponent)
|
||||
|
Reference in New Issue
Block a user