基础案例 准备改帧同步了

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,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(), //世界逻辑
};