基础案例 准备改帧同步了

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-10-21 02:09:30 +08:00
parent 44e2735899
commit cbacd5a501
117 changed files with 17049 additions and 4808 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -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)]

View File

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

View File

@@ -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)
{
}

View File

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

View File

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

View File

@@ -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)

View File

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

View File

@@ -31,7 +31,7 @@ namespace GAS.Runtime
void RemoveGameplayEffect(GameplayEffectSpec spec);
void Tick();
void Tick(int dt);
Dictionary<string, float> DataSnapshot();

View File

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

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 98a325bbe54441739d7e05e89817e9a5
timeCreated: 1701861619

View File

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

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c17e2cf434ca2f549b2fbd2dc0ecc4c8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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)

View File

@@ -4,8 +4,8 @@
{
string GetDisplayName();
EffectsDurationPolicy GetDurationPolicy();
float GetDuration();
float GetPeriod();
int GetDuration();
int GetPeriod();
GameplayEffectSnapshotPolicy GetSnapshotPolicy();
GameplayEffectSpecifiedSnapshotConfig[] GetSpecifiedSnapshotConfigs();

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 49241b5db40b450f934fb9de0841b2fc
timeCreated: 1729415696

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7f1317ff9b314419b0e48ae76657c960
timeCreated: 1729415730

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bfdfa8bae636419282b29d0cfb4d9239
timeCreated: 1729415750

View File

@@ -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)
{

View File

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

View File

@@ -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)
{

View File

@@ -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,

View File

@@ -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)

View File

@@ -123,6 +123,63 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &4168632
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1449950259}
m_Modifications:
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalPosition.x
value: 10
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7403693568755579174, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
propertyPath: m_Name
value: Cube
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
--- !u!1 &28019073
GameObject:
m_ObjectHideFlags: 0
@@ -217,6 +274,38 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1449950258
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1449950259}
m_Layer: 0
m_Name: EditorPreview
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &1449950259
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1449950258}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1872085155}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1745439352
GameObject:
m_ObjectHideFlags: 0
@@ -248,6 +337,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
World: {fileID: 2144549411}
Box: {fileID: 7403693568755579174, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
Preset: {fileID: 11400000, guid: 7692a8d07949a5c46b6b5325ebb9a422, type: 2}
GE_JisolDemo1: {fileID: 11400000, guid: 25ef9a2206b693c4f9b93af896a038a8, type: 2}
--- !u!4 &1745439354
Transform:
m_ObjectHideFlags: 0
@@ -263,6 +354,11 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1872085155 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 1418229812123219311, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
m_PrefabInstance: {fileID: 4168632}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2104190881
GameObject:
m_ObjectHideFlags: 0
@@ -394,3 +490,4 @@ SceneRoots:
- {fileID: 2104190884}
- {fileID: 2144549412}
- {fileID: 1745439354}
- {fileID: 1449950259}

View File

@@ -13,7 +13,8 @@ MonoBehaviour:
m_Name: ASC_Player
m_EditorClassIdentifier:
Description:
AttributeSets: []
AttributeSets:
- BaseAttribute
BaseTags: []
BaseAbilities:
- {fileID: 11400000, guid: b78ae002fbbf510419a39987f22201f1, type: 2}

View File

@@ -29,18 +29,25 @@ MonoBehaviour:
DurationalCues:
- trackName: "\u6301\u7EEDGameplayCue\u8F68\u9053"
clipEvents:
- startFrame: 6
durationFrame: 34
- startFrame: 0
durationFrame: 53
cue: {fileID: 11400000, guid: 0a77e9c8e20008944a99814e0b5a4aed, type: 2}
InstantCues:
- trackName: "\u5373\u65F6Cue\u8F68\u9053"
markEvents: []
markEvents:
- startFrame: 55
cues:
- {fileID: 11400000, guid: 041f193225d7b1e49a75af0003a4111b, type: 2}
ReleaseGameplayEffect:
- trackName: "GameplayEffect\u91CA\u653E\u8F68\u9053"
markEvents: []
BuffGameplayEffects:
- trackName: Buff
clipEvents: []
clipEvents:
- startFrame: 8
durationFrame: 30
buffTarget: 0
gameplayEffect: {fileID: 11400000, guid: 25ef9a2206b693c4f9b93af896a038a8, type: 2}
InstantTasks:
- trackName: "\u5373\u65F6Task\u8F68\u9053"
markEvents: []

View File

@@ -15,5 +15,11 @@ MonoBehaviour:
Description:
RequiredTags: []
ImmunityTags: []
start: {x: 0, y: 0, z: 0}
end: {x: 10, y: 0, z: 0}
start:
X: 0
Y: 0
Z: 0
end:
X: 10000
Y: 0
Z: 0

View File

@@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 725500c3ce824f8daa3a4be247f4f131, type: 3}
m_Name: GCue_PlayerDemo02
m_EditorClassIdentifier:
Description:
RequiredTags: []
ImmunityTags: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2aa1d58fb62dc104484f4f2bf1673303
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b9395a0be3e547f48bd1c8320edc6c58, type: 3}
m_Name: GE_JisolDemo1
m_EditorClassIdentifier:
Description: "\u7B80\u5355\u65BD\u52A0 debuff \u548C \u6263\u8840"
DurationPolicy: 3
Duration: 10000
Period: 0
PeriodExecution: {fileID: 0}
Stacking:
stackingType: 0
stackingCodeName:
limitCount: 0
durationRefreshPolicy: 0
periodResetPolicy: 0
expirationPolicy: 0
denyOverflowApplication: 0
clearStackOnOverflow: 0
overflowEffects: []
GrantedAbilities: []
Modifiers:
- AttributeName: AS_BaseAttribute.HP
AttributeSetName: AS_BaseAttribute
AttributeShortName: HP
ModiferMagnitude: 10
Operation: 3
MMC: {fileID: 11400000, guid: 331222964d02d1349b1a9c717605c8e9, type: 2}
AssetTags:
- _name: DeBuff
_hashCode: -251087900
_shortName: DeBuff
_ancestorHashCodes:
_ancestorNames: []
- _name: Buff
_hashCode: 937056111
_shortName: Buff
_ancestorHashCodes:
_ancestorNames: []
GrantedTags:
- _name: Buff
_hashCode: 937056111
_shortName: Buff
_ancestorHashCodes:
_ancestorNames: []
- _name: DeBuff
_hashCode: -251087900
_shortName: DeBuff
_ancestorHashCodes:
_ancestorNames: []
ApplicationRequiredTags: []
OngoingRequiredTags: []
RemoveGameplayEffectsWithTags: []
ApplicationImmunityTags: []
CueOnExecute: []
CueDurational: []
CueOnAdd:
- {fileID: 11400000, guid: 041f193225d7b1e49a75af0003a4111b, type: 2}
CueOnRemove:
- {fileID: 11400000, guid: 2aa1d58fb62dc104484f4f2bf1673303, type: 2}
CueOnActivate: []
CueOnDeactivate: []
SnapshotPolicy: 0
SpecifiedSnapshotConfigs: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 25ef9a2206b693c4f9b93af896a038a8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b964e9ee395740d6b0f8e42978c1ba35, type: 3}
m_Name: MMC_AttrModCalculation
m_EditorClassIdentifier:
Description: "\u57FA\u7840\u8FD0\u7B97"

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 331222964d02d1349b1a9c717605c8e9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,17 +0,0 @@
using GAS.Runtime;
using JNGame.Sync.Entity;
namespace GASSamples.Scripts
{
public class AbilitySystemSamplesComponent : AbilitySystemComponent
{
public JNEntity Entity { get; protected set; }
public AbilitySystemSamplesComponent(JNEntity entity)
{
Entity = entity;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 1384fe4e23ec4d718ac4df20198da171
timeCreated: 1729247365

View File

@@ -1,5 +1,9 @@
using GAS.General;
using GAS.Runtime;
using GASSamples.Scripts;
using GASSamples.Scripts.Game.GAS;
using JNGame.Math;
using JNGame.Runtime.Odin.TypeCustomize;
using Sirenix.OdinInspector;
using UnityEngine;
@@ -10,10 +14,10 @@ namespace Demo.Scripts.GAS.GameplayCue
[BoxGroup]
[LabelText("开始位置")]
public Vector3 start;
public OdinLVector3 start;
[BoxGroup]
[LabelText("结束位置")]
public Vector3 end;
public OdinLVector3 end;
public override GameplayCueDurationalSpec CreateSpec(GameplayCueParameters parameters)
{
@@ -23,11 +27,11 @@ namespace Demo.Scripts.GAS.GameplayCue
#if UNITY_EDITOR
public override void OnEditorPreview(GameObject previewObject, int frameIndex, int startFrame, int endFrame)
{
Debug.Log($"GameplayCue_PlayerDemo01 {previewObject} {frameIndex}");
Debug.Log($"GameplayCueDurational_PlayerDemo01 {previewObject} {frameIndex}");
if (frameIndex >= startFrame && frameIndex <= endFrame)
{
previewObject.transform.position = Vector3.Lerp(start, end, (float)(frameIndex - startFrame) / endFrame);
previewObject.transform.position = Vector3.Lerp(start.ToVector3(), end.ToVector3(), (float)(frameIndex - startFrame) / endFrame);
}
}
@@ -38,13 +42,10 @@ namespace Demo.Scripts.GAS.GameplayCue
public class GameplayCueDurational_PlayerDemo01_Spec : GameplayCueDurationalSpec<GameplayCueDurational_PlayerDemo01>
{
private GameplayCueDurational_PlayerDemo01 Cue;
public GameplayCueDurational_PlayerDemo01_Spec(GameplayCueDurational_PlayerDemo01 cue, GameplayCueParameters parameters) : base(cue, parameters)
{
Cue = cue;
}
public override void OnAdd(int frame,int startFrame,int endFrame)
{
Debug.Log("GameplayCueDurational_PlayerDemo01_Spec OnAdd");
@@ -67,7 +68,10 @@ namespace Demo.Scripts.GAS.GameplayCue
public override void OnTick(int frame,int startFrame,int endFrame)
{
Debug.Log($"GameplayCueDurational_PlayerDemo01_Spec OnTick {frame}");
((GAbilitySystemComponent)Owner).Entity.Transform.Position = LVector3.Lerp(cue.start.ToLVector3(), cue.end.ToLVector3(), (LFloat)(frame - startFrame) / endFrame);
}
}

View File

@@ -1,4 +1,6 @@
using GAS.Runtime;
using GASSamples.Scripts.Game.GAS;
using JNGame.Math;
using UnityEngine;
namespace Demo.Scripts.GAS.GameplayCue
@@ -10,14 +12,6 @@ namespace Demo.Scripts.GAS.GameplayCue
Debug.Log($"GameplayCue_PlayerDemo01 CreateSpec");
return new GameplayCue_PlayerDemo01_Spec(this,parameters);
}
#if UNITY_EDITOR
public override void OnEditorPreview(GameObject previewObject, int frame, int startFrame)
{
Debug.Log($"GameplayCue_PlayerDemo01 {previewObject}");
}
#endif
}
public class GameplayCue_PlayerDemo01_Spec : GameplayCueInstantSpec
@@ -29,6 +23,7 @@ namespace Demo.Scripts.GAS.GameplayCue
public override void Trigger()
{
((GAbilitySystemComponent)Owner).Entity.Transform.Scale = new LVector3(LFloat.L05,LFloat.L05,LFloat.L05);
}
}

View File

@@ -0,0 +1,32 @@
using GAS.Runtime;
using GASSamples.Scripts.Game.GAS;
using JNGame.Math;
using UnityEngine;
namespace Demo.Scripts.GAS.GameplayCue
{
public class GameplayCue_PlayerDemo02 : GameplayCueInstant
{
public override GameplayCueInstantSpec CreateSpec(GameplayCueParameters parameters)
{
Debug.Log($"GameplayCue_PlayerDemo02 CreateSpec");
return new GameplayCue_PlayerDemo02_Spec(this,parameters);
}
}
public class GameplayCue_PlayerDemo02_Spec : GameplayCueInstantSpec
{
public GameplayCue_PlayerDemo02_Spec(GameplayCueInstant cue, GameplayCueParameters parameters) : base(cue, parameters)
{
}
public override void Trigger()
{
((GAbilitySystemComponent)Owner).Entity.Transform.Scale = new LVector3(1,1,1);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 725500c3ce824f8daa3a4be247f4f131
timeCreated: 1729419424

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dd4c4a195812409f935d57313ac16614
timeCreated: 1729418595

View File

@@ -0,0 +1,19 @@
using GAS.Runtime;
using JNGame.Math;
using UnityEngine;
namespace GASSamples.Scripts.GAS.MMC
{
/// <summary>
/// 基础运算
/// </summary>
[CreateAssetMenu(fileName = "AttrModCalculation", menuName = "GAS/MMC/AttrModCalculation")]
public class AttrModCalculation : ModifierMagnitudeCalculation
{
public override float CalculateMagnitude(GameplayEffectSpec spec, float modifierMagnitude)
{
return modifierMagnitude;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b964e9ee395740d6b0f8e42978c1ba35
timeCreated: 1729418602

View File

@@ -4,6 +4,7 @@ using GASSamples.Scripts.Game.Entity.Contexts;
using JNGame.Sync.System;
using JNGame.Sync.System.Data;
using JNGame.Sync.System.Data.Type;
using UnityEngine.Serialization;
using NotImplementedException = System.NotImplementedException;
namespace GASSamples.Scripts.Game.Logic.Data
@@ -17,7 +18,8 @@ namespace GASSamples.Scripts.Game.Logic.Data
[Serializable]
public class JNGASBoxValue
{
public DValuePosition Position = null;
public NDataLVector3 Position = null;
public NDataLVector3 Scale = null;
}
public class JNGASBoxData : ISData
@@ -47,7 +49,8 @@ namespace GASSamples.Scripts.Game.Logic.Data
{
Value = new ()
{
Position = DValuePosition.Build(entity.Position)
Position = NDataLVector3.Build(entity.Position),
Scale = NDataLVector3.Build(entity.Scale)
}
});
}

View File

@@ -1,39 +0,0 @@
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);
}
}
}

View File

@@ -1,11 +0,0 @@
using GAS.Runtime;
namespace GASSamples.Scripts.Game.GAS
{
public class GAbilitySystemComponent : AbilitySystemComponent
{
}
}

View File

@@ -0,0 +1,54 @@
using GAS.Runtime;
using GASSamples.Scripts.Game.GAS;
using JNGame.Runtime.Sync.System.Logic;
using JNGame.Sync.Entity.Component;
using UnityEngine;
namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Components
{
public class JNGASComponent : JNComponent
{
private GAbilitySystemComponent _asc;
public GAbilitySystemComponent ASC => _asc;
public override void OnSyncStart()
{
base.OnSyncStart();
_asc = new (Entity);
//注册ASC
GetSystem<JNGASSystem>().Register(ASC);
}
public override void OnSyncDestroy()
{
base.OnSyncDestroy();
//取消注册ASC
GetSystem<JNGASSystem>().Unregister(ASC);
}
public void InitWithPreset(AbilitySystemComponentPreset ascPreset,int level)
{
ASC.SetPreset(ascPreset);
ASC.SetLevel(level);
ASC.InitWithPreset(ASC.Level,ASC.Preset);
}
/// <summary>
/// 附加效果给自己
/// </summary>
public void ApplyGameplayEffectToSelf(GameplayEffect gameplayEffect)
{
ASC.ApplyGameplayEffectToSelf(gameplayEffect);
}
/// <summary>
/// 激活技能
/// </summary>
public void TryActivateAbility(string name)
{
ASC.TryActivateAbility(name);
}
}
}

View File

@@ -1,4 +1,7 @@
using Game.Logic.System.Usual;
using GAS.Runtime;
using GASSamples.Scripts.Game.Entity.Nodes.Component.Components;
using JNGame.Runtime.Sync.System.Logic;
using JNGame.Sync.Entity.Component;
namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Controller
@@ -10,13 +13,19 @@ namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Controller
public override void OnSyncStart()
{
base.OnSyncStart();
//设置GAS 角色
// GAS.SetPreset();
GAS.InitWithPreset(GetSystem<DDataSystem>().Preset,1);
//附加效果测试
// GAS.ApplyGameplayEffectToSelf(new GameplayEffect(GetSystem<DDataSystem>().GE_JisolDemo1));
//释放技能
GAS.TryActivateAbility(GAbilityLib.JisolDemo1.Name);
}
}
}

View File

@@ -15,15 +15,15 @@ namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Lookup
protected override void BindIndex()
{
base.BindIndex();
Controller = Next();
GAS = Next();
Controller = Next();
}
protected override void BindType(KeyValue<int, Type> types)
{
base.BindType(types);
types.Add(Controller,typeof(JNGASBoxController));
types.Add(GAS,typeof(JNGASComponent));
types.Add(Controller,typeof(JNGASBoxController));
}
}

View File

@@ -1,4 +1,6 @@
using GASSamples.Scripts.Game.Entity.Nodes;
using GASSamples.Scripts.Game.Entity.Nodes.Component.Components;
using GASSamples.Scripts.Game.Entity.Nodes.Component.Controller;
using JNGame.Sync.Frame.Entity;
namespace GASSamples.Scripts.Game.Entity.Contexts
@@ -8,6 +10,8 @@ namespace GASSamples.Scripts.Game.Entity.Contexts
protected override JNGASBox BindComponent(JNGASBox entity)
{
base.BindComponent(entity);
entity.AddComponent<JNGASComponent>();
entity.AddComponent<JNGASBoxController>();
return entity;
}
}

View File

@@ -1,3 +1,4 @@
using GASSamples.Scripts.Game.Entity.Nodes.Component.Components;
using GASSamples.Scripts.Game.Entity.Nodes.Component.Controller;
using GASSamples.Scripts.Game.Entity.Nodes.Component.Lookup;
using JNGame.Sync.Entity;
@@ -8,6 +9,7 @@ namespace GASSamples.Scripts.Game.Entity.Nodes
public class JNGASBox : JNEntity
{
public JNGASComponent GAS => CLookup.Query<JNGASComponent>(this);
public JNGASBoxController Controller => CLookup.Query<JNGASBoxController>(this);
public override JNEntityLookup NewCLookup()

View File

@@ -0,0 +1,20 @@
using GAS.Runtime;
using JNGame.Sync.Entity;
namespace GASSamples.Scripts.Game.GAS
{
public class GAbilitySystemComponent : AbilitySystemComponent
{
public IJNEntity Entity { get; protected set; }
public GAbilitySystemComponent(IJNEntity entity)
{
Entity = entity;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 796b9c926a8f40ab9361c6955888747c
timeCreated: 1729410298

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ae051ac88cb04928b9d55f4e7c6fdc07
timeCreated: 1729410272

View File

@@ -0,0 +1,23 @@
using GAS.Runtime;
using GASSamples.Scripts;
using JNGame.Sync.System;
namespace Game.Logic.System.Usual
{
/// <summary>
/// 游戏数据
/// </summary>
public class DDataSystem : SLogicSystem
{
public AbilitySystemComponentPreset Preset { get; private set; }
public IGameplayEffectData GE_JisolDemo1 { get; private set; }
public override void OnSyncStart()
{
base.OnSyncStart();
Preset = App.Resource.Preset;
GE_JisolDemo1 = App.Resource.GE_JisolDemo1;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 743622b492f0406895154855d13ed6db
timeCreated: 1729410339

View File

@@ -19,12 +19,13 @@ namespace GASSamples.Scripts.Game.View.Entity
public override void ViewUpdate(JNGASBoxData data, GameObject view)
{
view.transform.DOMove(data.Value.Position.ToVector3(),0.5f);
view.transform.DOScale(data.Value.Scale.ToVector3(),0.5f);
}
public override GameObject NewView(JNGASBoxData data)
{
var view = Object.Instantiate(Box, World.transform);
view.name = $"Boss_{data.Id}";
view.name = $"Box_{data.Id}";
return view;
}

View File

@@ -17,7 +17,7 @@ namespace GAS.Runtime
public Type AbilityClassType;
}
public static AbilityInfo JisolDemo1 = new AbilityInfo { Name = "JisolDemo1", AssetPath = "Assets/Demo/GAS/Config/GameplayAbilityLib/JisolDemo1.asset",AbilityClassType = typeof(GAS.Runtime.TimelineAbility) };
public static AbilityInfo JisolDemo1 = new AbilityInfo { Name = "JisolDemo1", AssetPath = "Assets/Scripts/GASSamples/GAS/Config/GameplayAbilityLib/JisolDemo1.asset",AbilityClassType = typeof(GAS.Runtime.TimelineAbility) };
public static Dictionary<string, AbilityInfo> AbilityMap = new Dictionary<string, AbilityInfo>

View File

@@ -9,10 +9,13 @@ namespace GAS.Runtime
{
public static class GAttrLib
{
/// <summary>血量</summary>
public const string HP = "HP";
// For facilitating the creation of a Value Dropdown in the editor.
public static readonly IReadOnlyList<string> AttributeNames = new List<string>
{
HP,
};
}
}

View File

@@ -8,18 +8,68 @@ using System.Collections.Generic;
namespace GAS.Runtime
{
public class AS_BaseAttribute : AttributeSet
{
#region HP
/// <summary>血量</summary>
public AttributeBase HP { get; } = new("AS_BaseAttribute", "HP", 0f, CalculateMode.Stacking, (SupportedOperation)31, float.MinValue, float.MaxValue);
public void InitHP(float value) => HP.Init(value);
public void SetCurrentHP(float value) => HP.SetCurrentValue(value);
public void SetBaseHP(float value) => HP.SetBaseValue(value);
public void SetMinHP(float value) => HP.SetMinValue(value);
public void SetMaxHP(float value) => HP.SetMaxValue(value);
public void SetMinMaxHP(float min, float max) => HP.SetMinMaxValue(min, max);
#endregion HP
public override AttributeBase this[string key]
{
get
{
switch (key)
{
case "HP":
return HP;
}
return null;
}
}
public override string[] AttributeNames { get; } =
{
"HP",
};
public override void SetOwner(AbilitySystemComponent owner)
{
_owner = owner;
HP.SetOwner(owner);
}
public static class Lookup
{
public const string HP = "AS_BaseAttribute.HP";
}
}
public static class GAttrSetLib
{
public static readonly IReadOnlyDictionary<string, Type> AttrSetTypeDict = new Dictionary<string, Type>
{
{ "BaseAttribute", typeof(AS_BaseAttribute) },
};
public static readonly IReadOnlyDictionary<Type, string> TypeToName = new Dictionary<Type, string>
{
{ typeof(AS_BaseAttribute), nameof(AS_BaseAttribute) },
};
public static readonly IReadOnlyList<string> AttributeFullNames = new List<string>
{
"AS_BaseAttribute.HP",
};
}
}

View File

@@ -9,12 +9,16 @@ namespace GAS.Runtime
{
public static class GTagLib
{
/// <summary>Ability</summary>
public static GameplayTag Ability { get; } = new("Ability");
/// <summary>Buff</summary>
public static GameplayTag Buff { get; } = new("Buff");
/// <summary>DeBuff</summary>
public static GameplayTag DeBuff { get; } = new("DeBuff");
public static readonly IReadOnlyDictionary<string, GameplayTag> TagMap = new Dictionary<string, GameplayTag>
{
["Ability"] = Ability,
["Buff"] = Buff,
["DeBuff"] = DeBuff,
};
}
}

View File

@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using GAS.Runtime;
using JNGame.Network;
using UnityEngine;
@@ -11,11 +12,18 @@ namespace GASSamples.Scripts
//Box
public GameObject Box;
//Preset
public AbilitySystemComponentPreset Preset;
//GE_JisolDemo1
public IGameplayEffectData GE_JisolDemo1;
public override Task OnInit()
{
return base.OnInit();
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using DefaultNamespace;
using GAS.Runtime;
using JNGame.Runtime;
using UnityEngine;
@@ -10,7 +11,10 @@ namespace GASSamples.Scripts
public GameObject World;
public GameObject Box;
public AbilitySystemComponentPreset Preset;
public GameplayEffectAsset GE_JisolDemo1;
private JNGASFrameSystem _frameSystem;
private int _totalTime;
private int _frameIndex;
@@ -21,6 +25,8 @@ namespace GASSamples.Scripts
await JNetGame.Instance.Init(App.AllSystem());
App.Resource.World = World;
App.Resource.Box = Box;
App.Resource.Preset = Preset;
App.Resource.GE_JisolDemo1 = GE_JisolDemo1;
_frameSystem = new JNGASFrameSystem();
_frameSystem.Initialize();
@@ -35,6 +41,7 @@ namespace GASSamples.Scripts
//自动推帧
if (_totalTime >= _frameSystem.NSyncTime)
{
_totalTime -= _frameSystem.NSyncTime;
_frameSystem.AddFrame(new JNFrameInfo()
{
Index = _frameIndex++

View File

@@ -1,5 +1,6 @@
using Cysharp.Threading.Tasks;
using Game.Input;
using Game.Logic.System.Usual;
using GASSamples.Scripts.Game.Entity;
using GASSamples.Scripts.Game.Logic.Data;
using GASSamples.Scripts.Game.Logic.System;
@@ -19,8 +20,8 @@ namespace DefaultNamespace
{
return new SLogicSystem[]
{
//基础数据
new DInputSystem(), //游戏输入
new DDataSystem(), //数据 系统
new JNGASSystem(), //GAS 系统
new DWorldSystem(), //世界逻辑
};

View File

@@ -11,6 +11,7 @@ using JNGame.Sync.System.Data;
using JNGame.Network.Action;
using JNGame.Sync.System.Data.Type;
using TouchSocket.Core;
using UnityEngine.Serialization;
namespace Game.JNGState.Logic.Data
{
@@ -23,7 +24,7 @@ namespace Game.JNGState.Logic.Data
[Serializable]
public class GDataValue
{
public DValuePosition Position = null;
public NDataLVector3 Position = null;
}
public abstract class IGDataBase : ISTileData
@@ -58,7 +59,7 @@ namespace Game.JNGState.Logic.Data
public override void BindEntity(JNTileEntity entity)
{
base.BindEntity(entity);
Value.Position = new DValuePosition()
Value.Position = new NDataLVector3()
{
x = Node.Position.x.rawValue,
y = Node.Position.y.rawValue,