mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 10:46:17 +00:00
提交
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GAS.Runtime;
|
||||
using JNGame.GAS;
|
||||
using JNGame.Math;
|
||||
using JNGame.Runtime.GAS.Runtime;
|
||||
using JNGame.Serialization;
|
||||
using JNGame.Sync.System;
|
||||
using UnityEngine;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace JNGame.Runtime.Sync.System.Logic
|
||||
{
|
||||
/// <summary>
|
||||
/// GAS 系统
|
||||
/// </summary>
|
||||
public class JNGASSystem : SLogicSystem
|
||||
public class JNGASSystem : SLogicSystem,IGASResourceService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@@ -16,6 +22,29 @@ namespace JNGame.Runtime.Sync.System.Logic
|
||||
/// </summary>
|
||||
private JexGasManager _gas = new();
|
||||
public JexGasManager GAS => _gas;
|
||||
|
||||
/// <summary>
|
||||
/// 所有的GE配置数据
|
||||
/// </summary>
|
||||
private Dictionary<string, IGameplayEffectData> m_AllGEAssets;
|
||||
/// <summary>
|
||||
/// 所有的GA配置数据
|
||||
/// </summary>
|
||||
private Dictionary<string, PureTimelineAbilityAsset> m_AllAbilityAssets;
|
||||
/// <summary>
|
||||
/// 所有的ASC预设配置
|
||||
/// </summary>
|
||||
private Dictionary<string, PureASCPresetAsset> m_AllASCAssets;
|
||||
|
||||
public override void OnSyncStart()
|
||||
{
|
||||
base.OnSyncStart();
|
||||
OnInitAbilityAssetData();
|
||||
OnInitASCPresetAssetData();
|
||||
OnInitGameplayEffectData();
|
||||
GASBindAsset();
|
||||
}
|
||||
|
||||
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
@@ -32,6 +61,183 @@ namespace JNGame.Runtime.Sync.System.Logic
|
||||
return GAS.Unregister(abilitySystemComponent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 Ability 数据
|
||||
/// </summary>
|
||||
public virtual void OnInitAbilityAssetData()
|
||||
{
|
||||
m_AllGEAssets = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 ASC 数据
|
||||
/// </summary>
|
||||
public virtual void OnInitASCPresetAssetData()
|
||||
{
|
||||
m_AllAbilityAssets = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 GE 数据
|
||||
/// </summary>
|
||||
public virtual void OnInitGameplayEffectData()
|
||||
{
|
||||
m_AllASCAssets = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回属性类型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual Dictionary<string, Type> GetAttrSetTypeDict()
|
||||
{
|
||||
return new Dictionary<string, Type>();
|
||||
}
|
||||
|
||||
|
||||
public void GASBindAsset()
|
||||
{
|
||||
foreach (var iter in m_AllAbilityAssets)
|
||||
{
|
||||
iter.Value.BindLinkAsset(this);
|
||||
}
|
||||
foreach (var iter in m_AllGEAssets)
|
||||
{
|
||||
if (iter.Value is ILinkAssetBinder linkAssetBinder)
|
||||
{
|
||||
linkAssetBinder.BindLinkAsset(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGameplayEffectData(Dictionary<string, IGameplayEffectData> dictGEAssets)
|
||||
{
|
||||
m_AllGEAssets = dictGEAssets;
|
||||
}
|
||||
|
||||
public void SetAbilityAssetData(Dictionary<string, PureTimelineAbilityAsset> dictGAAssets)
|
||||
{
|
||||
m_AllAbilityAssets = dictGAAssets;
|
||||
}
|
||||
|
||||
public void SetASCPresetAssetData(Dictionary<string, PureASCPresetAsset> dictASCAssets)
|
||||
{
|
||||
m_AllASCAssets = dictASCAssets;
|
||||
}
|
||||
|
||||
public IGameplayEffectData GetGameplayEffectData(string geAssetLocation)
|
||||
{
|
||||
if (m_AllGEAssets.TryGetValue(geAssetLocation, out IGameplayEffectData geAssetData))
|
||||
{
|
||||
return geAssetData;
|
||||
}
|
||||
Debug.LogWarning($"没有找到GE资源,资源名:{geAssetLocation}");
|
||||
return null;
|
||||
}
|
||||
|
||||
public PureTimelineAbilityAsset GetTimelineAbilityAsset(string gaAssetLocation)
|
||||
{
|
||||
if (m_AllAbilityAssets.TryGetValue(gaAssetLocation, out PureTimelineAbilityAsset gaAssetData))
|
||||
{
|
||||
return gaAssetData;
|
||||
}
|
||||
Debug.LogWarning($"没有找到GA资源,资源名:{gaAssetLocation}");
|
||||
return null;
|
||||
}
|
||||
|
||||
public PureASCPresetAsset GetASCPresetAsset(string ascAssetLocation)
|
||||
{
|
||||
if (m_AllASCAssets.TryGetValue(ascAssetLocation, out PureASCPresetAsset ascPresetData))
|
||||
{
|
||||
return ascPresetData;
|
||||
}
|
||||
Debug.LogWarning($"没有找到ASC预设资源,资源名:{ascAssetLocation}");
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameplayEffect CreateRuntimeGE(string key)
|
||||
{
|
||||
IGameplayEffectData staticData = GetGameplayEffectData(key);
|
||||
if (staticData != null)
|
||||
{
|
||||
return new GameplayEffect(staticData, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameplayEffect CreateRuntimeGE(string key, LFloat value)
|
||||
{
|
||||
IGameplayEffectData staticData = GetGameplayEffectData(key);
|
||||
if (staticData != null)
|
||||
{
|
||||
var runtimeGE = new GameplayEffect(staticData, 0);
|
||||
runtimeGE.ModifiersValue[0] = value;
|
||||
return runtimeGE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameplayEffect CreateRuntimeGE(string key, int valueId)
|
||||
{
|
||||
IGameplayEffectData staticData = GetGameplayEffectData(key);
|
||||
if (staticData != null)
|
||||
{
|
||||
return new GameplayEffect(staticData, valueId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字节转GE
|
||||
/// </summary>
|
||||
public Dictionary<string, IGameplayEffectData> ByteToGE(byte[] byteData)
|
||||
{
|
||||
var geDic = new Dictionary<string, IGameplayEffectData>();
|
||||
var reader = new Deserializer(byteData);
|
||||
var size = reader.ReadUInt16();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
PureGameplayEffectAsset asset = new PureGameplayEffectAsset();
|
||||
asset.Deserialize(reader);
|
||||
geDic.Add(asset.Name, asset);
|
||||
}
|
||||
return geDic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字节转ASC
|
||||
/// </summary>
|
||||
public Dictionary<string, PureASCPresetAsset> ByteToASC(byte[] byteData)
|
||||
{
|
||||
var ascDic = new Dictionary<string, PureASCPresetAsset>();
|
||||
var reader = new Deserializer(byteData);
|
||||
var size = reader.ReadUInt16();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
PureASCPresetAsset asset = new PureASCPresetAsset();
|
||||
asset.Deserialize(reader);
|
||||
ascDic.Add(asset.Name, asset);
|
||||
}
|
||||
return ascDic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字节转Ability
|
||||
/// </summary>
|
||||
public Dictionary<string, PureTimelineAbilityAsset> ByteToAbility(byte[] byteData)
|
||||
{
|
||||
var abDic = new Dictionary<string, PureTimelineAbilityAsset>();
|
||||
Deserializer reader = new Deserializer(byteData);
|
||||
// Ability
|
||||
int size = reader.ReadUInt16();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
PureTimelineAbilityAsset asset = new PureTimelineAbilityAsset();
|
||||
asset.Deserialize(reader);
|
||||
abDic.Add(asset.Name, asset);
|
||||
}
|
||||
return abDic;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user