mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
合理化程序集,服务器Logic无需共享的代码存放解决方案目录,无需走Unity目录
合理化程序集,服务器Logic无需共享的代码存放解决方案目录,无需走Unity目录
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
{
|
||||
"List": [
|
||||
{
|
||||
"Id": 1,
|
||||
"OuterIP": "127.0.0.1",
|
||||
"OuterBindIP": "127.0.0.1",
|
||||
"InnerBindIP": "127.0.0.1",
|
||||
"ManagementPort": 20000
|
||||
}
|
||||
]
|
||||
}
|
||||
{"List":[
|
||||
{"Id":1,"OuterIP":"0.0.0.0","OuterBindIP":"0.0.0.0","InnerBindIP":"0.0.0.0","ManagementPort":20000}
|
||||
]}
|
||||
|
@@ -1,44 +1,10 @@
|
||||
{
|
||||
"List": [
|
||||
{
|
||||
"Id": 1,
|
||||
"EntityId": 17246978048,
|
||||
"RouteId": 1024,
|
||||
"WorldId": 0,
|
||||
"SceneType": "Gate",
|
||||
"Name": "Gate",
|
||||
"NetworkProtocol": "KCP",
|
||||
"OuterPort": 20000
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"EntityId": 34493956096,
|
||||
"RouteId": 2048,
|
||||
"WorldId": 0,
|
||||
"SceneType": "Addressable",
|
||||
"Name": "Addressable1",
|
||||
"NetworkProtocol": null,
|
||||
"OuterPort": 0
|
||||
},
|
||||
{
|
||||
"Id": 4,
|
||||
"EntityId": 68920803328,
|
||||
"RouteId": 3072,
|
||||
"WorldId": 0,
|
||||
"SceneType": "Map",
|
||||
"Name": "Map1",
|
||||
"NetworkProtocol": null,
|
||||
"OuterPort": 0
|
||||
},
|
||||
{
|
||||
"Id": 5,
|
||||
"EntityId": 86167781376,
|
||||
"RouteId": 4096,
|
||||
"WorldId": 0,
|
||||
"SceneType": "Chat",
|
||||
"Name": "Chat",
|
||||
"NetworkProtocol": null,
|
||||
"OuterPort": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
{"List":[
|
||||
{"Id":1,"EntityId":17246978048,"RouteId":1024,"WorldId":1,"SceneType":"Gate","Name":"Gate","NetworkProtocol":"KCP","OuterPort":20000},
|
||||
{"Id":2,"EntityId":34493956096,"RouteId":2048,"WorldId":1,"SceneType":"Addressable","Name":"Addressable1","NetworkProtocol":null,"OuterPort":0},
|
||||
{"Id":4,"EntityId":68920803328,"RouteId":3072,"WorldId":1,"SceneType":"Map","Name":"Map1","NetworkProtocol":null,"OuterPort":0},
|
||||
{"Id":5,"EntityId":86167781376,"RouteId":4096,"WorldId":1,"SceneType":"Chat","Name":"Chat","NetworkProtocol":null,"OuterPort":0},
|
||||
{"Id":6,"EntityId":103146389504,"RouteId":1025,"WorldId":1,"SceneType":"Gate","Name":"Gate","NetworkProtocol":"KCP","OuterPort":20000},
|
||||
{"Id":7,"EntityId":120393367552,"RouteId":2049,"WorldId":1,"SceneType":"Addressable","Name":"Addressable1","NetworkProtocol":null,"OuterPort":0},
|
||||
{"Id":8,"EntityId":137640345600,"RouteId":3073,"WorldId":1,"SceneType":"Map","Name":"Map1","NetworkProtocol":null,"OuterPort":0},
|
||||
{"Id":9,"EntityId":154887323648,"RouteId":4097,"WorldId":1,"SceneType":"Chat","Name":"Chat","NetworkProtocol":null,"OuterPort":0}
|
||||
]}
|
||||
|
@@ -1,28 +1,6 @@
|
||||
{
|
||||
"List": [
|
||||
{
|
||||
"Id": 1024,
|
||||
"MachineId": 1,
|
||||
"InnerPort": 11001,
|
||||
"ReleaseMode": false
|
||||
},
|
||||
{
|
||||
"Id": 2048,
|
||||
"MachineId": 1,
|
||||
"InnerPort": 11002,
|
||||
"ReleaseMode": false
|
||||
},
|
||||
{
|
||||
"Id": 3072,
|
||||
"MachineId": 1,
|
||||
"InnerPort": 11003,
|
||||
"ReleaseMode": false
|
||||
},
|
||||
{
|
||||
"Id": 4096,
|
||||
"MachineId": 1,
|
||||
"InnerPort": 11004,
|
||||
"ReleaseMode": false
|
||||
}
|
||||
]
|
||||
}
|
||||
{"List":[
|
||||
{"Id":1025,"MachineId":1,"InnerPort":11001,"ReleaseMode":false},
|
||||
{"Id":2049,"MachineId":1,"InnerPort":11002,"ReleaseMode":false},
|
||||
{"Id":3073,"MachineId":1,"InnerPort":11003,"ReleaseMode":false},
|
||||
{"Id":4097,"MachineId":1,"InnerPort":11004,"ReleaseMode":false}
|
||||
]}
|
||||
|
@@ -1,12 +1,3 @@
|
||||
{
|
||||
"List": [
|
||||
{
|
||||
"Id": 1,
|
||||
"WorldName": "测试服",
|
||||
"DbConnection": "mongodb://root:root@127.0.0.1",
|
||||
"DbName": "tengine_main",
|
||||
"DbType": "MongoDB",
|
||||
"IsGameWorld": true
|
||||
}
|
||||
]
|
||||
}
|
||||
{"List":[
|
||||
{"Id":1,"WorldName":"测试服","DbConnection":"mongodb://1.12.241.46:27017/","DbName":"tengine_test","DbType":"MongoDB","IsGameWorld":true}
|
||||
]}
|
||||
|
88
DotNet/Config/Server/Entity/MachineConfig.cs
Normal file
88
DotNet/Config/Server/Entity/MachineConfig.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class MachineConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<MachineConfig> List { get; set; } = new List<MachineConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, MachineConfig> _configs = new Dictionary<uint, MachineConfig>();
|
||||
private static MachineConfigData _instance;
|
||||
|
||||
public static MachineConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<MachineConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public MachineConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"MachineConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out MachineConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
MachineConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class MachineConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public string OuterIP { get; set; } // 外网IP
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public string OuterBindIP { get; set; } // 外网绑定IP
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public string InnerBindIP { get; set; } // 内网绑定IP
|
||||
[ProtoMember(5, IsRequired = true)]
|
||||
public int ManagementPort { get; set; } // 管理端口
|
||||
}
|
||||
}
|
94
DotNet/Config/Server/Entity/SceneConfig.cs
Normal file
94
DotNet/Config/Server/Entity/SceneConfig.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class SceneConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<SceneConfig> List { get; set; } = new List<SceneConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, SceneConfig> _configs = new Dictionary<uint, SceneConfig>();
|
||||
private static SceneConfigData _instance;
|
||||
|
||||
public static SceneConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<SceneConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public SceneConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"SceneConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out SceneConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
SceneConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class SceneConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // ID
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public long EntityId { get; set; } // 实体Id
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public uint RouteId { get; set; } // 路由Id
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public uint WorldId { get; set; } // 世界Id
|
||||
[ProtoMember(5, IsRequired = true)]
|
||||
public string SceneType { get; set; } // Scene类型
|
||||
[ProtoMember(6, IsRequired = true)]
|
||||
public string Name { get; set; } // 名称
|
||||
[ProtoMember(7, IsRequired = true)]
|
||||
public string NetworkProtocol { get; set; } // 协议类型
|
||||
[ProtoMember(8, IsRequired = true)]
|
||||
public int OuterPort { get; set; } // 外网端口
|
||||
}
|
||||
}
|
86
DotNet/Config/Server/Entity/ServerConfig.cs
Normal file
86
DotNet/Config/Server/Entity/ServerConfig.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class ServerConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<ServerConfig> List { get; set; } = new List<ServerConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, ServerConfig> _configs = new Dictionary<uint, ServerConfig>();
|
||||
private static ServerConfigData _instance;
|
||||
|
||||
public static ServerConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<ServerConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public ServerConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"ServerConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out ServerConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
ServerConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class ServerConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // 路由Id
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public uint MachineId { get; set; } // 机器ID
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public int InnerPort { get; set; } // 内网端口
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public bool ReleaseMode { get; set; } // Release下运行
|
||||
}
|
||||
}
|
90
DotNet/Config/Server/Entity/WorldConfig.cs
Normal file
90
DotNet/Config/Server/Entity/WorldConfig.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class WorldConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<WorldConfig> List { get; set; } = new List<WorldConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, WorldConfig> _configs = new Dictionary<uint, WorldConfig>();
|
||||
private static WorldConfigData _instance;
|
||||
|
||||
public static WorldConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<WorldConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public WorldConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"WorldConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out WorldConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
WorldConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class WorldConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public string WorldName { get; set; } // 名称
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public string DbConnection { get; set; } // 连接字符串
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public string DbName { get; set; } // 数据库名称
|
||||
[ProtoMember(5, IsRequired = true)]
|
||||
public string DbType { get; set; } // 数据库类型
|
||||
[ProtoMember(6, IsRequired = true)]
|
||||
public bool IsGameWorld { get; set; } // 是否游戏服
|
||||
}
|
||||
}
|
@@ -35,7 +35,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Assets\GameScripts\DotNet\Core\**\*.cs">
|
||||
<Link>Core\%(RecursiveDir)%(FileName)%(Extension)</Link>
|
||||
<Link>src\%(RecursiveDir)%(FileName)%(Extension)</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -23,14 +23,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Assets\GameScripts\DotNet\Logic\**\*.cs">
|
||||
<Link>Core\%(RecursiveDir)%(FileName)%(Extension)</Link>
|
||||
<Link>share\%(RecursiveDir)%(FileName)%(Extension)</Link>
|
||||
</Compile>
|
||||
<Compile Include="\src\**\*.cs">
|
||||
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="..\..\Assets\GameScripts\DotNet\Logic\Config~\GameConfig\Battle\">
|
||||
<Link>Core\Config~\GameConfig\Battle</Link>
|
||||
</Folder>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
56
DotNet/Logic/src/Config/ConfigLoader.cs
Normal file
56
DotNet/Logic/src/Config/ConfigLoader.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Bright.Serialization;
|
||||
using GameConfig;
|
||||
using TEngine;
|
||||
using TEngine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 配置加载器。
|
||||
/// </summary>
|
||||
public class ConfigLoader:Singleton<ConfigLoader>
|
||||
{
|
||||
private bool _init = false;
|
||||
|
||||
private Tables _tables = null!;
|
||||
|
||||
public ConfigLoader()
|
||||
{
|
||||
this.Load();
|
||||
}
|
||||
|
||||
public Tables Tables
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_init)
|
||||
{
|
||||
_init = true;
|
||||
Load();
|
||||
}
|
||||
return _tables;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置。
|
||||
/// </summary>
|
||||
public void Load()
|
||||
{
|
||||
var tablesCtor = typeof(Tables).GetConstructors()[0];
|
||||
var loaderReturnType = tablesCtor.GetParameters()[0].ParameterType.GetGenericArguments()[1];
|
||||
|
||||
System.Delegate loader = new System.Func<string, ByteBuf>(LoadByteBuf);
|
||||
_tables = (Tables)tablesCtor.Invoke(new object[] { loader });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载二进制配置。
|
||||
/// </summary>
|
||||
/// <param name="file">FileName</param>
|
||||
/// <returns>ByteBuf</returns>
|
||||
private ByteBuf LoadByteBuf(string file)
|
||||
{
|
||||
byte[]ret = File.ReadAllBytes($"../../../Config/GameConfig/{file}.bytes");
|
||||
return new ByteBuf(ret);
|
||||
}
|
||||
}
|
9
DotNet/Logic/src/Config/Core/BeanBase.cs
Normal file
9
DotNet/Logic/src/Config/Core/BeanBase.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Bright.Serialization;
|
||||
|
||||
namespace Bright.Config
|
||||
{
|
||||
public abstract class BeanBase : ITypeId
|
||||
{
|
||||
public abstract int GetTypeId();
|
||||
}
|
||||
}
|
1545
DotNet/Logic/src/Config/Core/ByteBuf.cs
Normal file
1545
DotNet/Logic/src/Config/Core/ByteBuf.cs
Normal file
File diff suppressed because it is too large
Load Diff
7
DotNet/Logic/src/Config/Core/ITypeId.cs
Normal file
7
DotNet/Logic/src/Config/Core/ITypeId.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Bright.Serialization
|
||||
{
|
||||
public interface ITypeId
|
||||
{
|
||||
int GetTypeId();
|
||||
}
|
||||
}
|
52
DotNet/Logic/src/Config/Core/StringUtil.cs
Normal file
52
DotNet/Logic/src/Config/Core/StringUtil.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Bright.Common
|
||||
{
|
||||
public static class StringUtil
|
||||
{
|
||||
public static string ToStr(object o)
|
||||
{
|
||||
return ToStr(o, new StringBuilder());
|
||||
}
|
||||
|
||||
public static string ToStr(object o, StringBuilder sb)
|
||||
{
|
||||
foreach (var p in o.GetType().GetFields())
|
||||
{
|
||||
|
||||
sb.Append($"{p.Name} = {p.GetValue(o)},");
|
||||
}
|
||||
|
||||
foreach (var p in o.GetType().GetProperties())
|
||||
{
|
||||
sb.Append($"{p.Name} = {p.GetValue(o)},");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string ArrayToString<T>(T[] arr)
|
||||
{
|
||||
return "[" + string.Join(",", arr) + "]";
|
||||
}
|
||||
|
||||
|
||||
public static string CollectionToString<T>(IEnumerable<T> arr)
|
||||
{
|
||||
return "[" + string.Join(",", arr) + "]";
|
||||
}
|
||||
|
||||
|
||||
public static string CollectionToString<TK, TV>(IDictionary<TK, TV> dic)
|
||||
{
|
||||
var sb = new StringBuilder('{');
|
||||
foreach (var e in dic)
|
||||
{
|
||||
sb.Append(e.Key).Append(':');
|
||||
sb.Append(e.Value).Append(',');
|
||||
}
|
||||
sb.Append('}');
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum ActorAttrAddType
|
||||
{
|
||||
/// <summary>
|
||||
/// 无效数据
|
||||
/// </summary>
|
||||
NONE = 0,
|
||||
/// <summary>
|
||||
/// 加法计算
|
||||
/// </summary>
|
||||
ABSOLUTE_VAL = 1,
|
||||
/// <summary>
|
||||
/// 多个项结果累加,然后对加法做乘法
|
||||
/// </summary>
|
||||
SUM_PERCENT_VAL = 2,
|
||||
/// <summary>
|
||||
/// 每一项都是对最终结果做乘法
|
||||
/// </summary>
|
||||
MUL_PERCENT_VAL = 3,
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum ActorAttrDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// 无效数据
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 最大血量
|
||||
/// </summary>
|
||||
MaxHp = 1,
|
||||
/// <summary>
|
||||
/// 攻击力
|
||||
/// </summary>
|
||||
Attack = 2,
|
||||
/// <summary>
|
||||
/// 物理伤害
|
||||
/// </summary>
|
||||
PhyDamage = 3,
|
||||
/// <summary>
|
||||
/// 物理防御
|
||||
/// </summary>
|
||||
PhyDef = 4,
|
||||
/// <summary>
|
||||
/// 法术伤害
|
||||
/// </summary>
|
||||
MagicDamage = 5,
|
||||
/// <summary>
|
||||
/// 法术防御
|
||||
/// </summary>
|
||||
MagicDef = 6,
|
||||
/// <summary>
|
||||
/// 移动速度
|
||||
/// </summary>
|
||||
MoveSpeed = 7,
|
||||
/// <summary>
|
||||
/// 攻击速度
|
||||
/// </summary>
|
||||
AttackSpeed = 8,
|
||||
/// <summary>
|
||||
/// 命中率
|
||||
/// </summary>
|
||||
Hit = 9,
|
||||
/// <summary>
|
||||
/// 闪避率
|
||||
/// </summary>
|
||||
Dodge = 10,
|
||||
/// <summary>
|
||||
/// 暴击率
|
||||
/// </summary>
|
||||
CriticalAtkRatio = 11,
|
||||
/// <summary>
|
||||
/// San值(疯狂值)
|
||||
/// </summary>
|
||||
SanValue = 12,
|
||||
/// <summary>
|
||||
/// 最大MP
|
||||
/// </summary>
|
||||
MaxMp = 13,
|
||||
/// <summary>
|
||||
/// 物理伤害倍率
|
||||
/// </summary>
|
||||
PhyDamageRatio = 14,
|
||||
/// <summary>
|
||||
/// 魔法伤害倍率
|
||||
/// </summary>
|
||||
MagicDamageRatio = 15,
|
||||
/// <summary>
|
||||
/// 暴击倍率
|
||||
/// </summary>
|
||||
CriticalRatio = 16,
|
||||
/// <summary>
|
||||
/// 暴击减免
|
||||
/// </summary>
|
||||
CriticalReduce = 17,
|
||||
}
|
||||
|
||||
}
|
100
DotNet/Logic/src/Config/GameConfig/Battle/BuffAttrConfig.cs
Normal file
100
DotNet/Logic/src/Config/GameConfig/Battle/BuffAttrConfig.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public sealed partial class BuffAttrConfig : Bright.Config.BeanBase
|
||||
{
|
||||
public BuffAttrConfig(ByteBuf _buf)
|
||||
{
|
||||
BuffID = _buf.ReadInt();
|
||||
Name = _buf.ReadString();
|
||||
StackNum = _buf.ReadInt();
|
||||
DurTime = _buf.ReadFloat();
|
||||
ResultType = (Battle.BuffResultType)_buf.ReadInt();
|
||||
RemoveWhenDie = _buf.ReadInt();
|
||||
DotDamageData = Battle.SkillAttrDamageData.DeserializeSkillAttrDamageData(_buf);
|
||||
DotTickConfig = Battle.BuffDotTickConfig.DeserializeBuffDotTickConfig(_buf);
|
||||
{int n0 = System.Math.Min(_buf.ReadSize(), _buf.Size);AttrData = new System.Collections.Generic.List<Battle.ResAttrImpactData>(n0);for(var i0 = 0 ; i0 < n0 ; i0++) { Battle.ResAttrImpactData _e0; _e0 = Battle.ResAttrImpactData.DeserializeResAttrImpactData(_buf); AttrData.Add(_e0);}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static BuffAttrConfig DeserializeBuffAttrConfig(ByteBuf _buf)
|
||||
{
|
||||
return new Battle.BuffAttrConfig(_buf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BuffID
|
||||
/// </summary>
|
||||
public int BuffID { get; private set; }
|
||||
/// <summary>
|
||||
/// 名字
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
/// <summary>
|
||||
/// 叠加次数
|
||||
/// </summary>
|
||||
public int StackNum { get; private set; }
|
||||
/// <summary>
|
||||
/// 持续时间
|
||||
/// </summary>
|
||||
public float DurTime { get; private set; }
|
||||
/// <summary>
|
||||
/// 数值效果类型
|
||||
/// </summary>
|
||||
public Battle.BuffResultType ResultType { get; private set; }
|
||||
/// <summary>
|
||||
/// 死亡消失
|
||||
/// </summary>
|
||||
public int RemoveWhenDie { get; private set; }
|
||||
public Battle.SkillAttrDamageData DotDamageData { get; private set; }
|
||||
public Battle.BuffDotTickConfig DotTickConfig { get; private set; }
|
||||
public System.Collections.Generic.List<Battle.ResAttrImpactData> AttrData { get; private set; }
|
||||
|
||||
public const int __ID__ = 1652935996;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
DotDamageData?.Resolve(_tables);
|
||||
DotTickConfig?.Resolve(_tables);
|
||||
foreach(var _e in AttrData) { _e?.Resolve(_tables); }
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
DotDamageData?.TranslateText(translator);
|
||||
DotTickConfig?.TranslateText(translator);
|
||||
foreach(var _e in AttrData) { _e?.TranslateText(translator); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "BuffID:" + BuffID + ","
|
||||
+ "Name:" + Name + ","
|
||||
+ "StackNum:" + StackNum + ","
|
||||
+ "DurTime:" + DurTime + ","
|
||||
+ "ResultType:" + ResultType + ","
|
||||
+ "RemoveWhenDie:" + RemoveWhenDie + ","
|
||||
+ "DotDamageData:" + DotDamageData + ","
|
||||
+ "DotTickConfig:" + DotTickConfig + ","
|
||||
+ "AttrData:" + Bright.Common.StringUtil.CollectionToString(AttrData) + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
96
DotNet/Logic/src/Config/GameConfig/Battle/BuffConfig.cs
Normal file
96
DotNet/Logic/src/Config/GameConfig/Battle/BuffConfig.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public sealed partial class BuffConfig : Bright.Config.BeanBase
|
||||
{
|
||||
public BuffConfig(ByteBuf _buf)
|
||||
{
|
||||
BuffID = _buf.ReadInt();
|
||||
Name = _buf.ReadString();
|
||||
PrefId = _buf.ReadInt();
|
||||
Desc = _buf.ReadString();
|
||||
Icon = _buf.ReadString();
|
||||
TimeType = (Battle.BuffTimeType)_buf.ReadInt();
|
||||
ReplaceType = (Battle.BuffReplaceType)_buf.ReadInt();
|
||||
State = Battle.BuffTriggleState.DeserializeBuffTriggleState(_buf);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static BuffConfig DeserializeBuffConfig(ByteBuf _buf)
|
||||
{
|
||||
return new Battle.BuffConfig(_buf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BuffID
|
||||
/// </summary>
|
||||
public int BuffID { get; private set; }
|
||||
/// <summary>
|
||||
/// 名字
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
/// <summary>
|
||||
/// 表现ID
|
||||
/// </summary>
|
||||
public int PrefId { get; private set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Desc { get; private set; }
|
||||
/// <summary>
|
||||
/// 图标
|
||||
/// </summary>
|
||||
public string Icon { get; private set; }
|
||||
/// <summary>
|
||||
/// 持续类型
|
||||
/// </summary>
|
||||
public Battle.BuffTimeType TimeType { get; private set; }
|
||||
/// <summary>
|
||||
/// 叠加类型
|
||||
/// </summary>
|
||||
public Battle.BuffReplaceType ReplaceType { get; private set; }
|
||||
public Battle.BuffTriggleState State { get; private set; }
|
||||
|
||||
public const int __ID__ = 1807662187;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
State?.Resolve(_tables);
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
State?.TranslateText(translator);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "BuffID:" + BuffID + ","
|
||||
+ "Name:" + Name + ","
|
||||
+ "PrefId:" + PrefId + ","
|
||||
+ "Desc:" + Desc + ","
|
||||
+ "Icon:" + Icon + ","
|
||||
+ "TimeType:" + TimeType + ","
|
||||
+ "ReplaceType:" + ReplaceType + ","
|
||||
+ "State:" + State + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public sealed partial class BuffDotTickConfig : Bright.Config.BeanBase
|
||||
{
|
||||
public BuffDotTickConfig(ByteBuf _buf)
|
||||
{
|
||||
TickTime = _buf.ReadFloat();
|
||||
TickWhenAdd = _buf.ReadInt();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static BuffDotTickConfig DeserializeBuffDotTickConfig(ByteBuf _buf)
|
||||
{
|
||||
return new Battle.BuffDotTickConfig(_buf);
|
||||
}
|
||||
|
||||
public float TickTime { get; private set; }
|
||||
public int TickWhenAdd { get; private set; }
|
||||
|
||||
public const int __ID__ = 2124630047;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "TickTime:" + TickTime + ","
|
||||
+ "TickWhenAdd:" + TickWhenAdd + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
36
DotNet/Logic/src/Config/GameConfig/Battle/BuffReplaceType.cs
Normal file
36
DotNet/Logic/src/Config/GameConfig/Battle/BuffReplaceType.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum BuffReplaceType
|
||||
{
|
||||
/// <summary>
|
||||
/// 更新时间范围
|
||||
/// </summary>
|
||||
BUFF_REPLACE_INSTEAD = 0,
|
||||
/// <summary>
|
||||
/// 不允许叠加
|
||||
/// </summary>
|
||||
BUFF_REPLACE_FORBIT = 1,
|
||||
/// <summary>
|
||||
/// 累加时间范围
|
||||
/// </summary>
|
||||
BUFF_REPLACE_ADD_TIME = 2,
|
||||
/// <summary>
|
||||
/// 叠加数值
|
||||
/// </summary>
|
||||
BUFF_REPLACE_ADD_ATTR = 3,
|
||||
/// <summary>
|
||||
/// 叠加种类
|
||||
/// </summary>
|
||||
BUFF_REPLACE_TYPE_COUNT = 4,
|
||||
}
|
||||
|
||||
}
|
100
DotNet/Logic/src/Config/GameConfig/Battle/BuffResultType.cs
Normal file
100
DotNet/Logic/src/Config/GameConfig/Battle/BuffResultType.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum BuffResultType
|
||||
{
|
||||
/// <summary>
|
||||
/// 无
|
||||
/// </summary>
|
||||
BUFF_RESULT_NONE = 0,
|
||||
/// <summary>
|
||||
/// 物理攻击提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_PHY_ATK_UP = 1,
|
||||
/// <summary>
|
||||
/// 物理攻击降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_PHY_ATK_DOWN = 2,
|
||||
/// <summary>
|
||||
/// 物理防御提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_PHY_DEF_UP = 3,
|
||||
/// <summary>
|
||||
/// 物理防御降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_PHY_DEF_DOWN = 4,
|
||||
/// <summary>
|
||||
/// 物理命中提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_PHY_HIT_UP = 5,
|
||||
/// <summary>
|
||||
/// 物理命中降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_PHY_HIT_DOWN = 6,
|
||||
/// <summary>
|
||||
/// 物理持续掉血
|
||||
/// </summary>
|
||||
BUFF_RESULT_PHY_LOSE_HP = 7,
|
||||
/// <summary>
|
||||
/// 法术攻击提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_MAG_ATK_UP = 8,
|
||||
/// <summary>
|
||||
/// 法术攻击降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_MAG_ATK_DOWN = 9,
|
||||
/// <summary>
|
||||
/// 法术防御提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_MAG_DEF_UP = 10,
|
||||
/// <summary>
|
||||
/// 法术防御降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_MAG_DEF_DOWN = 11,
|
||||
/// <summary>
|
||||
/// 法术命中提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_MAG_HIT_UP = 12,
|
||||
/// <summary>
|
||||
/// 法术命中降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_MAG_HIT_DOWN = 13,
|
||||
/// <summary>
|
||||
/// 法术持续掉血
|
||||
/// </summary>
|
||||
BUFF_RESULT_MAG_LOSE_HP = 14,
|
||||
/// <summary>
|
||||
/// 暴击率提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_CIRT_UP = 15,
|
||||
/// <summary>
|
||||
/// 暴击率降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_CIRT_DOWN = 16,
|
||||
/// <summary>
|
||||
/// 暴击倍率提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_CIRT_VALUE_UP = 17,
|
||||
/// <summary>
|
||||
/// 暴击倍率降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_CIRT_VALUE_DOWN = 18,
|
||||
/// <summary>
|
||||
/// 移速提升
|
||||
/// </summary>
|
||||
BUFF_RESULT_MOVE_SPEED_UP = 19,
|
||||
/// <summary>
|
||||
/// 移速降低
|
||||
/// </summary>
|
||||
BUFF_RESULT_MOVE_SPEED_DOWN = 20,
|
||||
}
|
||||
|
||||
}
|
60
DotNet/Logic/src/Config/GameConfig/Battle/BuffStateID.cs
Normal file
60
DotNet/Logic/src/Config/GameConfig/Battle/BuffStateID.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum BuffStateID
|
||||
{
|
||||
/// <summary>
|
||||
/// 无状态
|
||||
/// </summary>
|
||||
BUFF_STATE_NONE = 0,
|
||||
/// <summary>
|
||||
/// 眩晕状态
|
||||
/// </summary>
|
||||
BUFF_STATE_STUN = 1,
|
||||
/// <summary>
|
||||
/// 无敌状态
|
||||
/// </summary>
|
||||
BUFF_STATE_UNDEAD = 2,
|
||||
/// <summary>
|
||||
/// 隐身状态
|
||||
/// </summary>
|
||||
BUFF_STATE_INVISIBLE = 3,
|
||||
/// <summary>
|
||||
/// 体形变大
|
||||
/// </summary>
|
||||
BUFF_STATE_BIGGER = 4,
|
||||
/// <summary>
|
||||
/// 定身,不能移动
|
||||
/// </summary>
|
||||
BUFF_STATE_NO_MOVE = 5,
|
||||
/// <summary>
|
||||
/// 沉默,不能放技能
|
||||
/// </summary>
|
||||
BUFF_STATE_NO_SKILL = 6,
|
||||
/// <summary>
|
||||
/// 昏睡
|
||||
/// </summary>
|
||||
BUFF_STATE_SLEEP = 7,
|
||||
/// <summary>
|
||||
/// 强制开启阻挡
|
||||
/// </summary>
|
||||
BUFF_STATE_FORCE_COLLIDER = 8,
|
||||
/// <summary>
|
||||
/// 无视阻挡
|
||||
/// </summary>
|
||||
BUFF_STATE_IGNORE_COLLIDER = 9,
|
||||
/// <summary>
|
||||
/// 最大状态
|
||||
/// </summary>
|
||||
BUFF_STATE_MAX = 10,
|
||||
}
|
||||
|
||||
}
|
24
DotNet/Logic/src/Config/GameConfig/Battle/BuffTimeType.cs
Normal file
24
DotNet/Logic/src/Config/GameConfig/Battle/BuffTimeType.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum BuffTimeType
|
||||
{
|
||||
/// <summary>
|
||||
/// 指定持续时间
|
||||
/// </summary>
|
||||
BUFF_TIME_DURING = 0,
|
||||
/// <summary>
|
||||
/// 无尽时间
|
||||
/// </summary>
|
||||
BUFF_TIME_INFINIT = 1,
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public sealed partial class BuffTriggleState : Bright.Config.BeanBase
|
||||
{
|
||||
public BuffTriggleState(ByteBuf _buf)
|
||||
{
|
||||
StateID = (Battle.BuffStateID)_buf.ReadInt();
|
||||
StateParam = _buf.ReadFloat();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static BuffTriggleState DeserializeBuffTriggleState(ByteBuf _buf)
|
||||
{
|
||||
return new Battle.BuffTriggleState(_buf);
|
||||
}
|
||||
|
||||
public Battle.BuffStateID StateID { get; private set; }
|
||||
public float StateParam { get; private set; }
|
||||
|
||||
public const int __ID__ = 1328146134;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "StateID:" + StateID + ","
|
||||
+ "StateParam:" + StateParam + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public sealed partial class ResAttrImpactData : Bright.Config.BeanBase
|
||||
{
|
||||
public ResAttrImpactData(ByteBuf _buf)
|
||||
{
|
||||
DataType = (Battle.ActorAttrDataType)_buf.ReadInt();
|
||||
AddType = (Battle.ActorAttrAddType)_buf.ReadInt();
|
||||
Value = _buf.ReadFloat();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static ResAttrImpactData DeserializeResAttrImpactData(ByteBuf _buf)
|
||||
{
|
||||
return new Battle.ResAttrImpactData(_buf);
|
||||
}
|
||||
|
||||
public Battle.ActorAttrDataType DataType { get; private set; }
|
||||
public Battle.ActorAttrAddType AddType { get; private set; }
|
||||
public float Value { get; private set; }
|
||||
|
||||
public const int __ID__ = 1319292907;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "DataType:" + DataType + ","
|
||||
+ "AddType:" + AddType + ","
|
||||
+ "Value:" + Value + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public sealed partial class SkillAttrDamageData : Bright.Config.BeanBase
|
||||
{
|
||||
public SkillAttrDamageData(ByteBuf _buf)
|
||||
{
|
||||
MagicType = (Battle.SkillMagicType)_buf.ReadInt();
|
||||
AttrType = (Battle.SkillAttrDamageType)_buf.ReadInt();
|
||||
Param1 = _buf.ReadFloat();
|
||||
Param2 = _buf.ReadFloat();
|
||||
Param3 = _buf.ReadFloat();
|
||||
MaxLimit = _buf.ReadFloat();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static SkillAttrDamageData DeserializeSkillAttrDamageData(ByteBuf _buf)
|
||||
{
|
||||
return new Battle.SkillAttrDamageData(_buf);
|
||||
}
|
||||
|
||||
public Battle.SkillMagicType MagicType { get; private set; }
|
||||
public Battle.SkillAttrDamageType AttrType { get; private set; }
|
||||
public float Param1 { get; private set; }
|
||||
public float Param2 { get; private set; }
|
||||
public float Param3 { get; private set; }
|
||||
public float MaxLimit { get; private set; }
|
||||
|
||||
public const int __ID__ = -94519547;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "MagicType:" + MagicType + ","
|
||||
+ "AttrType:" + AttrType + ","
|
||||
+ "Param1:" + Param1 + ","
|
||||
+ "Param2:" + Param2 + ","
|
||||
+ "Param3:" + Param3 + ","
|
||||
+ "MaxLimit:" + MaxLimit + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum SkillAttrDamageType
|
||||
{
|
||||
/// <summary>
|
||||
/// 无数值
|
||||
/// </summary>
|
||||
ATTR_TYPE_NONE = 0,
|
||||
/// <summary>
|
||||
/// 按释放者的伤害类型*X%+固定值计算,目标有防御计算
|
||||
/// </summary>
|
||||
ATTR_TYPE_DMG_WEAPON = 1,
|
||||
/// <summary>
|
||||
/// 按释放者的伤害类型*X%+固定值计算(无视目标的防御)
|
||||
/// </summary>
|
||||
ATTR_TYPE_DMG_NO_DEFEND = 2,
|
||||
/// <summary>
|
||||
/// 按受击者的气血上限*X%+固定值计算(无视目标的防御)
|
||||
/// </summary>
|
||||
ATTR_TYPE_DMG_TARGET_HP_NO_DEFEND = 3,
|
||||
/// <summary>
|
||||
/// 按释放者的攻击类型*X%+固定值计算,恢复当前生命
|
||||
/// </summary>
|
||||
ATTR_TYPE_HP_AS_ATK = 4,
|
||||
/// <summary>
|
||||
/// 按受击者的HP上限*X%+固定值计算,恢复当前生命
|
||||
/// </summary>
|
||||
ATTR_TYPE_HP_RATIO = 5,
|
||||
}
|
||||
|
||||
}
|
114
DotNet/Logic/src/Config/GameConfig/Battle/SkillBaseConfig.cs
Normal file
114
DotNet/Logic/src/Config/GameConfig/Battle/SkillBaseConfig.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public sealed partial class SkillBaseConfig : Bright.Config.BeanBase
|
||||
{
|
||||
public SkillBaseConfig(ByteBuf _buf)
|
||||
{
|
||||
Id = _buf.ReadInt();
|
||||
Name = _buf.ReadString();
|
||||
SkillDispID = _buf.ReadInt();
|
||||
SkillType = _buf.ReadInt();
|
||||
Desc = _buf.ReadString();
|
||||
CostMP = _buf.ReadInt();
|
||||
GCDID = _buf.ReadInt();
|
||||
SkillCD = _buf.ReadFloat();
|
||||
IsRepeatTrigger = _buf.ReadBool();
|
||||
{int n0 = System.Math.Min(_buf.ReadSize(), _buf.Size);BuffID = new System.Collections.Generic.List<int>(n0);for(var i0 = 0 ; i0 < n0 ; i0++) { int _e0; _e0 = _buf.ReadInt(); BuffID.Add(_e0);}}
|
||||
{int n0 = System.Math.Min(_buf.ReadSize(), _buf.Size);AttrDamageData = new System.Collections.Generic.List<Battle.SkillAttrDamageData>(n0);for(var i0 = 0 ; i0 < n0 ; i0++) { Battle.SkillAttrDamageData _e0; _e0 = Battle.SkillAttrDamageData.DeserializeSkillAttrDamageData(_buf); AttrDamageData.Add(_e0);}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static SkillBaseConfig DeserializeSkillBaseConfig(ByteBuf _buf)
|
||||
{
|
||||
return new Battle.SkillBaseConfig(_buf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 技能ID
|
||||
/// </summary>
|
||||
public int Id { get; private set; }
|
||||
/// <summary>
|
||||
/// 名字
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
/// <summary>
|
||||
/// 表现ID
|
||||
/// </summary>
|
||||
public int SkillDispID { get; private set; }
|
||||
/// <summary>
|
||||
/// 技能类型SkillType
|
||||
/// </summary>
|
||||
public int SkillType { get; private set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Desc { get; private set; }
|
||||
/// <summary>
|
||||
/// 消耗MP
|
||||
/// </summary>
|
||||
public int CostMP { get; private set; }
|
||||
/// <summary>
|
||||
/// 所属公CD组ID
|
||||
/// </summary>
|
||||
public int GCDID { get; private set; }
|
||||
/// <summary>
|
||||
/// 技能CD
|
||||
/// </summary>
|
||||
public float SkillCD { get; private set; }
|
||||
/// <summary>
|
||||
/// 是否重复触发
|
||||
/// </summary>
|
||||
public bool IsRepeatTrigger { get; private set; }
|
||||
/// <summary>
|
||||
/// BuffIDList
|
||||
/// </summary>
|
||||
public System.Collections.Generic.List<int> BuffID { get; private set; }
|
||||
public System.Collections.Generic.List<Battle.SkillAttrDamageData> AttrDamageData { get; private set; }
|
||||
|
||||
public const int __ID__ = 2067672430;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var _e in AttrDamageData) { _e?.Resolve(_tables); }
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var _e in AttrDamageData) { _e?.TranslateText(translator); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "Id:" + Id + ","
|
||||
+ "Name:" + Name + ","
|
||||
+ "SkillDispID:" + SkillDispID + ","
|
||||
+ "SkillType:" + SkillType + ","
|
||||
+ "Desc:" + Desc + ","
|
||||
+ "CostMP:" + CostMP + ","
|
||||
+ "GCDID:" + GCDID + ","
|
||||
+ "SkillCD:" + SkillCD + ","
|
||||
+ "IsRepeatTrigger:" + IsRepeatTrigger + ","
|
||||
+ "BuffID:" + Bright.Common.StringUtil.CollectionToString(BuffID) + ","
|
||||
+ "AttrDamageData:" + Bright.Common.StringUtil.CollectionToString(AttrDamageData) + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
28
DotNet/Logic/src/Config/GameConfig/Battle/SkillMagicType.cs
Normal file
28
DotNet/Logic/src/Config/GameConfig/Battle/SkillMagicType.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
public enum SkillMagicType
|
||||
{
|
||||
/// <summary>
|
||||
/// 无类型
|
||||
/// </summary>
|
||||
SKILL_TYPE_NONE = 0,
|
||||
/// <summary>
|
||||
/// 物理伤害属性
|
||||
/// </summary>
|
||||
SKILL_TYPE_DMG_PHY = 1,
|
||||
/// <summary>
|
||||
/// 魔法伤害属性
|
||||
/// </summary>
|
||||
SKILL_TYPE_DMG_MAGIC = 2,
|
||||
}
|
||||
|
||||
}
|
63
DotNet/Logic/src/Config/GameConfig/Battle/TbBuff.cs
Normal file
63
DotNet/Logic/src/Config/GameConfig/Battle/TbBuff.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
|
||||
public partial class TbBuff
|
||||
{
|
||||
private readonly Dictionary<int, Battle.BuffConfig> _dataMap;
|
||||
private readonly List<Battle.BuffConfig> _dataList;
|
||||
|
||||
public TbBuff(ByteBuf _buf)
|
||||
{
|
||||
_dataMap = new Dictionary<int, Battle.BuffConfig>();
|
||||
_dataList = new List<Battle.BuffConfig>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
{
|
||||
Battle.BuffConfig _v;
|
||||
_v = Battle.BuffConfig.DeserializeBuffConfig(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.BuffID, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, Battle.BuffConfig> DataMap => _dataMap;
|
||||
public List<Battle.BuffConfig> DataList => _dataList;
|
||||
|
||||
public Battle.BuffConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public Battle.BuffConfig Get(int key) => _dataMap[key];
|
||||
public Battle.BuffConfig this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
63
DotNet/Logic/src/Config/GameConfig/Battle/TbBuffAttr.cs
Normal file
63
DotNet/Logic/src/Config/GameConfig/Battle/TbBuffAttr.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
|
||||
public partial class TbBuffAttr
|
||||
{
|
||||
private readonly Dictionary<int, Battle.BuffAttrConfig> _dataMap;
|
||||
private readonly List<Battle.BuffAttrConfig> _dataList;
|
||||
|
||||
public TbBuffAttr(ByteBuf _buf)
|
||||
{
|
||||
_dataMap = new Dictionary<int, Battle.BuffAttrConfig>();
|
||||
_dataList = new List<Battle.BuffAttrConfig>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
{
|
||||
Battle.BuffAttrConfig _v;
|
||||
_v = Battle.BuffAttrConfig.DeserializeBuffAttrConfig(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.BuffID, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, Battle.BuffAttrConfig> DataMap => _dataMap;
|
||||
public List<Battle.BuffAttrConfig> DataList => _dataList;
|
||||
|
||||
public Battle.BuffAttrConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public Battle.BuffAttrConfig Get(int key) => _dataMap[key];
|
||||
public Battle.BuffAttrConfig this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
63
DotNet/Logic/src/Config/GameConfig/Battle/TbSkill.cs
Normal file
63
DotNet/Logic/src/Config/GameConfig/Battle/TbSkill.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
|
||||
public partial class TbSkill
|
||||
{
|
||||
private readonly Dictionary<int, Battle.SkillBaseConfig> _dataMap;
|
||||
private readonly List<Battle.SkillBaseConfig> _dataList;
|
||||
|
||||
public TbSkill(ByteBuf _buf)
|
||||
{
|
||||
_dataMap = new Dictionary<int, Battle.SkillBaseConfig>();
|
||||
_dataList = new List<Battle.SkillBaseConfig>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
{
|
||||
Battle.SkillBaseConfig _v;
|
||||
_v = Battle.SkillBaseConfig.DeserializeSkillBaseConfig(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.Id, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, Battle.SkillBaseConfig> DataMap => _dataMap;
|
||||
public List<Battle.SkillBaseConfig> DataList => _dataList;
|
||||
|
||||
public Battle.SkillBaseConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public Battle.SkillBaseConfig Get(int key) => _dataMap[key];
|
||||
public Battle.SkillBaseConfig this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
53
DotNet/Logic/src/Config/GameConfig/Tables.cs
Normal file
53
DotNet/Logic/src/Config/GameConfig/Tables.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
|
||||
|
||||
|
||||
namespace GameConfig
|
||||
{
|
||||
public partial class Tables
|
||||
{
|
||||
public item.TbItem TbItem {get; }
|
||||
public Battle.TbSkill TbSkill {get; }
|
||||
public Battle.TbBuff TbBuff {get; }
|
||||
public Battle.TbBuffAttr TbBuffAttr {get; }
|
||||
|
||||
public Tables(System.Func<string, ByteBuf> loader)
|
||||
{
|
||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||
TbItem = new item.TbItem(loader("item_tbitem"));
|
||||
tables.Add("item.TbItem", TbItem);
|
||||
TbSkill = new Battle.TbSkill(loader("battle_tbskill"));
|
||||
tables.Add("Battle.TbSkill", TbSkill);
|
||||
TbBuff = new Battle.TbBuff(loader("battle_tbbuff"));
|
||||
tables.Add("Battle.TbBuff", TbBuff);
|
||||
TbBuffAttr = new Battle.TbBuffAttr(loader("battle_tbbuffattr"));
|
||||
tables.Add("Battle.TbBuffAttr", TbBuffAttr);
|
||||
|
||||
PostInit();
|
||||
TbItem.Resolve(tables);
|
||||
TbSkill.Resolve(tables);
|
||||
TbBuff.Resolve(tables);
|
||||
TbBuffAttr.Resolve(tables);
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
TbItem.TranslateText(translator);
|
||||
TbSkill.TranslateText(translator);
|
||||
TbBuff.TranslateText(translator);
|
||||
TbBuffAttr.TranslateText(translator);
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
32
DotNet/Logic/src/Config/GameConfig/item/EQuality.cs
Normal file
32
DotNet/Logic/src/Config/GameConfig/item/EQuality.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.item
|
||||
{
|
||||
public enum EQuality
|
||||
{
|
||||
/// <summary>
|
||||
/// 最差品质
|
||||
/// </summary>
|
||||
WHITE = 1,
|
||||
/// <summary>
|
||||
/// 蓝色的
|
||||
/// </summary>
|
||||
BLUE = 2,
|
||||
/// <summary>
|
||||
/// 紫色的
|
||||
/// </summary>
|
||||
PURPLE = 3,
|
||||
/// <summary>
|
||||
/// 最高品质
|
||||
/// </summary>
|
||||
RED = 4,
|
||||
}
|
||||
|
||||
}
|
120
DotNet/Logic/src/Config/GameConfig/item/Item.cs
Normal file
120
DotNet/Logic/src/Config/GameConfig/item/Item.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.item
|
||||
{
|
||||
public sealed partial class Item : Bright.Config.BeanBase
|
||||
{
|
||||
public Item(ByteBuf _buf)
|
||||
{
|
||||
Id = _buf.ReadInt();
|
||||
Name = _buf.ReadString();
|
||||
Desc = _buf.ReadString();
|
||||
Price = _buf.ReadInt();
|
||||
UpgradeToItemId = _buf.ReadInt();
|
||||
if(_buf.ReadBool()){ ExpireTime = _buf.ReadInt(); } else { ExpireTime = null; }
|
||||
BatchUseable = _buf.ReadBool();
|
||||
Quality = (item.EQuality)_buf.ReadInt();
|
||||
ExchangeStream = item.ItemExchange.DeserializeItemExchange(_buf);
|
||||
{int n0 = System.Math.Min(_buf.ReadSize(), _buf.Size);ExchangeList = new System.Collections.Generic.List<item.ItemExchange>(n0);for(var i0 = 0 ; i0 < n0 ; i0++) { item.ItemExchange _e0; _e0 = item.ItemExchange.DeserializeItemExchange(_buf); ExchangeList.Add(_e0);}}
|
||||
ExchangeColumn = item.ItemExchange.DeserializeItemExchange(_buf);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static Item DeserializeItem(ByteBuf _buf)
|
||||
{
|
||||
return new item.Item(_buf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 这是id
|
||||
/// </summary>
|
||||
public int Id { get; private set; }
|
||||
/// <summary>
|
||||
/// 名字
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Desc { get; private set; }
|
||||
/// <summary>
|
||||
/// 价格
|
||||
/// </summary>
|
||||
public int Price { get; private set; }
|
||||
/// <summary>
|
||||
/// 引用当前表
|
||||
/// </summary>
|
||||
public int UpgradeToItemId { get; private set; }
|
||||
public item.Item UpgradeToItemId_Ref { get; private set; }
|
||||
/// <summary>
|
||||
/// 过期时间
|
||||
/// </summary>
|
||||
public int? ExpireTime { get; private set; }
|
||||
/// <summary>
|
||||
/// 能否批量使用
|
||||
/// </summary>
|
||||
public bool BatchUseable { get; private set; }
|
||||
/// <summary>
|
||||
/// 品质
|
||||
/// </summary>
|
||||
public item.EQuality Quality { get; private set; }
|
||||
/// <summary>
|
||||
/// 道具兑换配置
|
||||
/// </summary>
|
||||
public item.ItemExchange ExchangeStream { get; private set; }
|
||||
public System.Collections.Generic.List<item.ItemExchange> ExchangeList { get; private set; }
|
||||
/// <summary>
|
||||
/// 道具兑换配置
|
||||
/// </summary>
|
||||
public item.ItemExchange ExchangeColumn { get; private set; }
|
||||
|
||||
public const int __ID__ = 2107285806;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
this.UpgradeToItemId_Ref = (_tables["item.TbItem"] as item.TbItem).GetOrDefault(UpgradeToItemId);
|
||||
ExchangeStream?.Resolve(_tables);
|
||||
foreach(var _e in ExchangeList) { _e?.Resolve(_tables); }
|
||||
ExchangeColumn?.Resolve(_tables);
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
ExchangeStream?.TranslateText(translator);
|
||||
foreach(var _e in ExchangeList) { _e?.TranslateText(translator); }
|
||||
ExchangeColumn?.TranslateText(translator);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "Id:" + Id + ","
|
||||
+ "Name:" + Name + ","
|
||||
+ "Desc:" + Desc + ","
|
||||
+ "Price:" + Price + ","
|
||||
+ "UpgradeToItemId:" + UpgradeToItemId + ","
|
||||
+ "ExpireTime:" + ExpireTime + ","
|
||||
+ "BatchUseable:" + BatchUseable + ","
|
||||
+ "Quality:" + Quality + ","
|
||||
+ "ExchangeStream:" + ExchangeStream + ","
|
||||
+ "ExchangeList:" + Bright.Common.StringUtil.CollectionToString(ExchangeList) + ","
|
||||
+ "ExchangeColumn:" + ExchangeColumn + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
61
DotNet/Logic/src/Config/GameConfig/item/ItemExchange.cs
Normal file
61
DotNet/Logic/src/Config/GameConfig/item/ItemExchange.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.item
|
||||
{
|
||||
public sealed partial class ItemExchange : Bright.Config.BeanBase
|
||||
{
|
||||
public ItemExchange(ByteBuf _buf)
|
||||
{
|
||||
Id = _buf.ReadInt();
|
||||
Num = _buf.ReadInt();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static ItemExchange DeserializeItemExchange(ByteBuf _buf)
|
||||
{
|
||||
return new item.ItemExchange(_buf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 道具id
|
||||
/// </summary>
|
||||
public int Id { get; private set; }
|
||||
/// <summary>
|
||||
/// 道具数量
|
||||
/// </summary>
|
||||
public int Num { get; private set; }
|
||||
|
||||
public const int __ID__ = 1814660465;
|
||||
public override int GetTypeId() => __ID__;
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{ "
|
||||
+ "Id:" + Id + ","
|
||||
+ "Num:" + Num + ","
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
63
DotNet/Logic/src/Config/GameConfig/item/TbItem.cs
Normal file
63
DotNet/Logic/src/Config/GameConfig/item/TbItem.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig.item
|
||||
{
|
||||
|
||||
public partial class TbItem
|
||||
{
|
||||
private readonly Dictionary<int, item.Item> _dataMap;
|
||||
private readonly List<item.Item> _dataList;
|
||||
|
||||
public TbItem(ByteBuf _buf)
|
||||
{
|
||||
_dataMap = new Dictionary<int, item.Item>();
|
||||
_dataList = new List<item.Item>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
{
|
||||
item.Item _v;
|
||||
_v = item.Item.DeserializeItem(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.Id, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, item.Item> DataMap => _dataMap;
|
||||
public List<item.Item> DataList => _dataList;
|
||||
|
||||
public item.Item GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public item.Item Get(int key) => _dataMap[key];
|
||||
public item.Item this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
25
DotNet/Logic/src/Config/GameConfig/test/AccessFlag.cs
Normal file
25
DotNet/Logic/src/Config/GameConfig/test/AccessFlag.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace GameConfig.test
|
||||
{
|
||||
[System.Flags]
|
||||
public enum AccessFlag
|
||||
{
|
||||
WRITE = 1,
|
||||
READ = 2,
|
||||
TRUNCATE = 4,
|
||||
NEW = 8,
|
||||
/// <summary>
|
||||
/// 位标记使用示例
|
||||
/// </summary>
|
||||
READ_WRITE = WRITE|READ,
|
||||
}
|
||||
|
||||
}
|
49
DotNet/Logic/src/CustomExport/SceneTypeConfigToEnum.cs
Normal file
49
DotNet/Logic/src/CustomExport/SceneTypeConfigToEnum.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
#if TENGINE_NET
|
||||
using System.Text;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Model;
|
||||
|
||||
public sealed class SceneTypeConfigToEnum : ACustomExport
|
||||
{
|
||||
public override void Run()
|
||||
{
|
||||
var serverSceneType = new HashSet<string>();
|
||||
var instanceList = SceneConfigData.Instance.List;
|
||||
|
||||
foreach (var sceneConfig in instanceList)
|
||||
{
|
||||
serverSceneType.Add(sceneConfig.SceneType);
|
||||
}
|
||||
|
||||
if (serverSceneType.Count > 0)
|
||||
{
|
||||
Write(CustomExportType.Server, serverSceneType);
|
||||
}
|
||||
}
|
||||
|
||||
private void Write(CustomExportType customExportType, HashSet<string> sceneTypes)
|
||||
{
|
||||
var index = 0;
|
||||
var strBuilder = new StringBuilder();
|
||||
var dicBuilder = new StringBuilder();
|
||||
|
||||
strBuilder.AppendLine("namespace TEngine\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑。");
|
||||
strBuilder.AppendLine("\tpublic class SceneType\n\t{");
|
||||
dicBuilder.AppendLine("\n\t\tpublic static readonly Dictionary<string, int> SceneDic = new Dictionary<string, int>()\n\t\t{");
|
||||
|
||||
foreach (var str in sceneTypes)
|
||||
{
|
||||
index++;
|
||||
dicBuilder.AppendLine($"\t\t\t{{ \"{str}\", {index} }},");
|
||||
strBuilder.AppendLine($"\t\tpublic const int {str} = {index};");
|
||||
}
|
||||
|
||||
dicBuilder.AppendLine("\t\t};");
|
||||
strBuilder.Append(dicBuilder);
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
Write("SceneType.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
}
|
||||
#endif
|
11
DotNet/Logic/src/Entry.cs
Normal file
11
DotNet/Logic/src/Entry.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
#if TENGINE_NET
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public static class Entry
|
||||
{
|
||||
public static async FTask Start()
|
||||
{
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class MachineConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<MachineConfig> List { get; set; } = new List<MachineConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, MachineConfig> _configs = new Dictionary<uint, MachineConfig>();
|
||||
private static MachineConfigData _instance;
|
||||
|
||||
public static MachineConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<MachineConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public MachineConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"MachineConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out MachineConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
MachineConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class MachineConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public string OuterIP { get; set; } // 外网IP
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public string OuterBindIP { get; set; } // 外网绑定IP
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public string InnerBindIP { get; set; } // 内网绑定IP
|
||||
[ProtoMember(5, IsRequired = true)]
|
||||
public int ManagementPort { get; set; } // 管理端口
|
||||
}
|
||||
}
|
94
DotNet/Logic/src/Generate/ConfigTable/Entity/SceneConfig.cs
Normal file
94
DotNet/Logic/src/Generate/ConfigTable/Entity/SceneConfig.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class SceneConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<SceneConfig> List { get; set; } = new List<SceneConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, SceneConfig> _configs = new Dictionary<uint, SceneConfig>();
|
||||
private static SceneConfigData _instance;
|
||||
|
||||
public static SceneConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<SceneConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public SceneConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"SceneConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out SceneConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
SceneConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class SceneConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // ID
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public long EntityId { get; set; } // 实体Id
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public uint RouteId { get; set; } // 路由Id
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public uint WorldId { get; set; } // 世界Id
|
||||
[ProtoMember(5, IsRequired = true)]
|
||||
public string SceneType { get; set; } // Scene类型
|
||||
[ProtoMember(6, IsRequired = true)]
|
||||
public string Name { get; set; } // 名称
|
||||
[ProtoMember(7, IsRequired = true)]
|
||||
public string NetworkProtocol { get; set; } // 协议类型
|
||||
[ProtoMember(8, IsRequired = true)]
|
||||
public int OuterPort { get; set; } // 外网端口
|
||||
}
|
||||
}
|
86
DotNet/Logic/src/Generate/ConfigTable/Entity/ServerConfig.cs
Normal file
86
DotNet/Logic/src/Generate/ConfigTable/Entity/ServerConfig.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class ServerConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<ServerConfig> List { get; set; } = new List<ServerConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, ServerConfig> _configs = new Dictionary<uint, ServerConfig>();
|
||||
private static ServerConfigData _instance;
|
||||
|
||||
public static ServerConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<ServerConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public ServerConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"ServerConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out ServerConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
ServerConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class ServerConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // 路由Id
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public uint MachineId { get; set; } // 机器ID
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public int InnerPort { get; set; } // 内网端口
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public bool ReleaseMode { get; set; } // Release下运行
|
||||
}
|
||||
}
|
90
DotNet/Logic/src/Generate/ConfigTable/Entity/WorldConfig.cs
Normal file
90
DotNet/Logic/src/Generate/ConfigTable/Entity/WorldConfig.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using TEngine.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class WorldConfigData : AProto, IConfigTable, IDisposable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<WorldConfig> List { get; set; } = new List<WorldConfig>();
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, WorldConfig> _configs = new Dictionary<uint, WorldConfig>();
|
||||
private static WorldConfigData _instance;
|
||||
|
||||
public static WorldConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableManage.Load<WorldConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public WorldConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"WorldConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out WorldConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
for (var i = 0; i < List.Count; i++)
|
||||
{
|
||||
WorldConfig config = List[i];
|
||||
_configs.Add(config.Id, config);
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
base.AfterDeserialization();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class WorldConfig : AProto
|
||||
{
|
||||
[ProtoMember(1, IsRequired = true)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public string WorldName { get; set; } // 名称
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public string DbConnection { get; set; } // 连接字符串
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public string DbName { get; set; } // 数据库名称
|
||||
[ProtoMember(5, IsRequired = true)]
|
||||
public string DbType { get; set; } // 数据库类型
|
||||
[ProtoMember(6, IsRequired = true)]
|
||||
public bool IsGameWorld { get; set; } // 是否游戏服
|
||||
}
|
||||
}
|
21
DotNet/Logic/src/Generate/CustomExport/SceneType.cs
Normal file
21
DotNet/Logic/src/Generate/CustomExport/SceneType.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
// 生成器自动生成,请不要手动编辑。
|
||||
public class SceneType
|
||||
{
|
||||
public const int Gate = 1;
|
||||
public const int Addressable = 2;
|
||||
public const int Map = 3;
|
||||
public const int Chat = 4;
|
||||
|
||||
public static readonly Dictionary<string, int> SceneDic = new Dictionary<string, int>()
|
||||
{
|
||||
{ "Gate", 1 },
|
||||
{ "Addressable", 2 },
|
||||
{ "Map", 3 },
|
||||
{ "Chat", 4 },
|
||||
};
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
using ProtoBuf;
|
||||
using Unity.Mathematics;
|
||||
using System.Collections.Generic;
|
||||
using TEngine.Core.Network;
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class InnerBsonOpcode
|
||||
{
|
||||
}
|
||||
}
|
31
DotNet/Logic/src/Generate/NetworkProtocol/InnerMessage.cs
Normal file
31
DotNet/Logic/src/Generate/NetworkProtocol/InnerMessage.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using ProtoBuf;
|
||||
using Unity.Mathematics;
|
||||
using System.Collections.Generic;
|
||||
using TEngine.Core.Network;
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Gate跟Map服务器进行通讯、注册Address协议
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class I_G2M_LoginAddressRequest : AProto, IRouteRequest
|
||||
{
|
||||
[ProtoIgnore]
|
||||
public I_M2G_LoginAddressResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return InnerOpcode.I_G2M_LoginAddressRequest; }
|
||||
public long RouteTypeOpCode() { return CoreRouteType.Route; }
|
||||
[ProtoMember(1)]
|
||||
public long AddressId { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public long GateRouteId { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class I_M2G_LoginAddressResponse : AProto, IRouteResponse
|
||||
{
|
||||
public uint OpCode() { return InnerOpcode.I_M2G_LoginAddressResponse; }
|
||||
[ProtoMember(91, IsRequired = true)]
|
||||
public int ErrorCode { get; set; }
|
||||
}
|
||||
}
|
8
DotNet/Logic/src/Generate/NetworkProtocol/InnerOpcode.cs
Normal file
8
DotNet/Logic/src/Generate/NetworkProtocol/InnerOpcode.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class InnerOpcode
|
||||
{
|
||||
public const int I_G2M_LoginAddressRequest = 220001001;
|
||||
public const int I_M2G_LoginAddressResponse = 260001001;
|
||||
}
|
||||
}
|
157
DotNet/Logic/src/Generate/NetworkProtocol/OuterMessage.cs
Normal file
157
DotNet/Logic/src/Generate/NetworkProtocol/OuterMessage.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using ProtoBuf;
|
||||
using Unity.Mathematics;
|
||||
using System.Collections.Generic;
|
||||
using TEngine.Core.Network;
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 发送一个消息到Gate服务器
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2G_Message : AProto, IMessage
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_C2G_Message; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送一个RPC消息到Gate服务器
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2G_MessageRequest : AProto, IRequest
|
||||
{
|
||||
[ProtoIgnore]
|
||||
public H_G2C_MessageResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.H_C2G_MessageRequest; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class H_G2C_MessageResponse : AProto, IResponse
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_G2C_MessageResponse; }
|
||||
[ProtoMember(91, IsRequired = true)]
|
||||
public int ErrorCode { get; set; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送一个消息通知服务器给客户端推送一个消息
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2G_PushMessageToClient : AProto, IMessage
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_C2G_PushMessageToClient; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 客户端接收服务器推送的一条消息
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_G2C_ReceiveMessageToServer : AProto, IMessage
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_G2C_ReceiveMessageToServer; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 注册Address消息
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2G_LoginAddressRequest : AProto, IRequest
|
||||
{
|
||||
[ProtoIgnore]
|
||||
public H_G2C_LoginAddressResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.H_C2G_LoginAddressRequest; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class H_G2C_LoginAddressResponse : AProto, IResponse
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_G2C_LoginAddressResponse; }
|
||||
[ProtoMember(91, IsRequired = true)]
|
||||
public int ErrorCode { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送一个Address消息给Map
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2M_Message : AProto, IAddressableRouteMessage
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_C2M_Message; }
|
||||
public long RouteTypeOpCode() { return CoreRouteType.Addressable; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送一个AddressRPC消息给Map
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2M_MessageRequest : AProto, IAddressableRouteRequest
|
||||
{
|
||||
[ProtoIgnore]
|
||||
public H_M2C_MessageResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.H_C2M_MessageRequest; }
|
||||
public long RouteTypeOpCode() { return CoreRouteType.Addressable; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class H_M2C_MessageResponse : AProto, IAddressableRouteResponse
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_M2C_MessageResponse; }
|
||||
[ProtoMember(91, IsRequired = true)]
|
||||
public int ErrorCode { get; set; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送一个消息通知服务器给客户端推送一个Address消息
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2M_PushAddressMessageToClient : AProto, IAddressableRouteMessage
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_C2M_PushAddressMessageToClient; }
|
||||
public long RouteTypeOpCode() { return CoreRouteType.Addressable; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 客户端接收服务器推送的一条Address消息
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_M2C_ReceiveAddressMessageToServer : AProto, IAddressableRouteMessage
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_M2C_ReceiveAddressMessageToServer; }
|
||||
public long RouteTypeOpCode() { return CoreRouteType.Addressable; }
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 客户端发送消息请求登录服务器
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class H_C2G_LoginRequest : AProto, IRequest
|
||||
{
|
||||
[ProtoIgnore]
|
||||
public H_G2C_LoginResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.H_C2G_LoginRequest; }
|
||||
[ProtoMember(1)]
|
||||
public string UserName { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public string Password { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class H_G2C_LoginResponse : AProto, IResponse
|
||||
{
|
||||
public uint OpCode() { return OuterOpcode.H_G2C_LoginResponse; }
|
||||
[ProtoMember(91, IsRequired = true)]
|
||||
public int ErrorCode { get; set; }
|
||||
[ProtoMember(1)]
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
20
DotNet/Logic/src/Generate/NetworkProtocol/OuterOpcode.cs
Normal file
20
DotNet/Logic/src/Generate/NetworkProtocol/OuterOpcode.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class OuterOpcode
|
||||
{
|
||||
public const int H_C2G_Message = 100000001;
|
||||
public const int H_C2G_MessageRequest = 110000001;
|
||||
public const int H_G2C_MessageResponse = 160000001;
|
||||
public const int H_C2G_PushMessageToClient = 100000002;
|
||||
public const int H_G2C_ReceiveMessageToServer = 100000003;
|
||||
public const int H_C2G_LoginAddressRequest = 110000002;
|
||||
public const int H_G2C_LoginAddressResponse = 160000002;
|
||||
public const int H_C2M_Message = 190000001;
|
||||
public const int H_C2M_MessageRequest = 200000001;
|
||||
public const int H_M2C_MessageResponse = 250000001;
|
||||
public const int H_C2M_PushAddressMessageToClient = 190000002;
|
||||
public const int H_M2C_ReceiveAddressMessageToServer = 190000003;
|
||||
public const int H_C2G_LoginRequest = 110000003;
|
||||
public const int H_G2C_LoginResponse = 160000003;
|
||||
}
|
||||
}
|
8
DotNet/Logic/src/Generate/NetworkProtocol/RouteType.cs
Normal file
8
DotNet/Logic/src/Generate/NetworkProtocol/RouteType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace TEngine.Core.Network
|
||||
{
|
||||
// Route协议定义(需要定义1000以上、因为1000以内的框架预留)
|
||||
public enum RouteType : long
|
||||
{
|
||||
ChatRoute = 1001, // 聊天服协议
|
||||
}
|
||||
}
|
15
DotNet/Logic/src/Handler/Address/H_C2M_MessageHandler.cs
Normal file
15
DotNet/Logic/src/Handler/Address/H_C2M_MessageHandler.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public class H_C2M_MessageHandler : Addressable<Unit,H_C2M_Message>
|
||||
{
|
||||
protected override async FTask Run(Unit unit, H_C2M_Message message)
|
||||
{
|
||||
Log.Debug($"接收到一个Address消息 Unit:{unit.Id} message:{message.ToJson()}");
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,16 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public class H_C2M_MessageRequestHandler : AddressableRPC<Unit, H_C2M_MessageRequest, H_M2C_MessageResponse>
|
||||
{
|
||||
protected override async FTask Run(Unit unit, H_C2M_MessageRequest request, H_M2C_MessageResponse response, Action reply)
|
||||
{
|
||||
Log.Debug($"接收到一个AddressRPC消息 Unit:{unit.Id} message:{request.ToJson()}");
|
||||
response.Message = "来自MAP服务器发送的消息";
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,21 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public class H_C2M_PushAddressMessageToClientHandler : Addressable<Unit, H_C2M_PushAddressMessageToClient>
|
||||
{
|
||||
protected override async FTask Run(Unit unit, H_C2M_PushAddressMessageToClient message)
|
||||
{
|
||||
Log.Debug($"接收到一个Address消息 Unit:{unit.Id} message:{message.ToJson()}");
|
||||
// 发过主动推送给客户端、首先要只要Unit在Gate的RouteId、然后才可以发送
|
||||
// 这个Route在I_G2M_LoginAddressRequest、也就是注册Address的时候已经记录了
|
||||
MessageHelper.SendInnerRoute(unit.Scene, unit.GateRouteId, new H_M2C_ReceiveAddressMessageToServer()
|
||||
{
|
||||
Message = message.Message
|
||||
});
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
#endif
|
55
DotNet/Logic/src/Handler/H_C2G_LoginAddressRequestHandler.cs
Normal file
55
DotNet/Logic/src/Handler/H_C2G_LoginAddressRequestHandler.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public class H_C2G_LoginAddressRequestHandler : MessageRPC<H_C2G_LoginAddressRequest, H_G2C_LoginAddressResponse>
|
||||
{
|
||||
protected override async FTask Run(Session session, H_C2G_LoginAddressRequest request, H_G2C_LoginAddressResponse response, Action reply)
|
||||
{
|
||||
// 什么是可寻址消息
|
||||
// 此服务器是一个分布式框架、所以肯定会有多个服务器相互通信
|
||||
// 游戏里一个玩家这里统称Unit、随着游戏场景的越来越多、为了让游戏服务器能承载更多人
|
||||
// 所以大家都会把服务器给分成多个、比如一个地图一个服务器、从而能提升服务器的负载能力、也更方便开发、类似微服务
|
||||
// 但这样就会有几个问题出现了:
|
||||
// 1、客户端是直接连接到服务器、如果切换服务器的时候客户端就会掉线、怎么解决不让用户掉线
|
||||
// 2、从A服务器到B服务器后、如果能正常发送到B服务器而不是发送到A服务器中
|
||||
// 为了解决上面的问题、大多服务器架构都采用了一个中专服务器(Gate)来收发消息
|
||||
// 比如客户端一直连接的一个服务器这里统称Gate
|
||||
// 那网络通讯的管道模型是客户端->Gate->其他服务器、客户端接收消息是其他服务器->Gate->客户端
|
||||
// 这样的好处是无论玩家在什么服务器只需要改变Gate到其他服务器的连接就可以了、中间客户端是一直连接到Gate的所以客户端不会掉线
|
||||
// 这个问题解决了、但还有一个问题就是Gate跟其他服务器的连接会随着玩家的逻辑变动
|
||||
// 所以框架提供的可寻址消息(Address)消息、使用Address消息后会自动寻找到Unit的正确位置并发送到、不需要开发者再处理这个逻辑了
|
||||
// 下面就是一个例子
|
||||
// 1、首选分配一个可用、负载比较低的服务器给这个Unit、我这里就在ServerConfig.xsl表里拿一个MAP了、但实际开发过程可能比这个要复杂
|
||||
// 我这里就简单些一个做为演示、其实这些逻辑开发者完全可以自己封装一个接口来做。
|
||||
// 在ServerConfig.xsl里找到MAP的进程、看到ID是3072通过这个Id在SceneConfig.xsl里找到对应的Scene的EntityId
|
||||
var sceneEntityId = 0L;
|
||||
foreach (var sceneConfig in SceneConfigData.Instance.List)
|
||||
{
|
||||
if (sceneConfig.RouteId == 3072)
|
||||
{
|
||||
sceneEntityId = sceneConfig.EntityId;
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
// 2、在InnerMessage里定义一个协议、用于Gate跟Map通讯的协议I_G2M_LoginAddress
|
||||
var loginAddressResponse = (I_M2G_LoginAddressResponse)await MessageHelper.CallInnerRoute(session.Scene,
|
||||
sceneEntityId,
|
||||
new I_G2M_LoginAddressRequest()
|
||||
{
|
||||
AddressId = session.Id,
|
||||
GateRouteId = session.RuntimeId,
|
||||
});
|
||||
if (loginAddressResponse.ErrorCode != 0)
|
||||
{
|
||||
Log.Error($"注册到Map的Address发生错误 ErrorCode:{loginAddressResponse.ErrorCode}");
|
||||
return;
|
||||
}
|
||||
// 3、可寻址消息组件、挂载了这个组件可以接收和发送Addressable消息
|
||||
session.AddComponent<AddressableRouteComponent>();
|
||||
}
|
||||
}
|
||||
#endif
|
18
DotNet/Logic/src/Handler/H_C2G_LoginRequestHandler.cs
Normal file
18
DotNet/Logic/src/Handler/H_C2G_LoginRequestHandler.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#if TENGINE_NET
|
||||
using System;
|
||||
using TEngine.Core.Network;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Logic
|
||||
{
|
||||
public class H_C2G_LoginRequestHandler : MessageRPC<H_C2G_LoginRequest,H_G2C_LoginResponse>
|
||||
{
|
||||
protected override async FTask Run(Session session, H_C2G_LoginRequest request, H_G2C_LoginResponse response, Action reply)
|
||||
{
|
||||
Log.Debug($"收到请求登录的消息 request:{request.ToJson()}");
|
||||
response.Text = "登录成功";
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
16
DotNet/Logic/src/Handler/H_C2G_MessageHandler.cs
Normal file
16
DotNet/Logic/src/Handler/H_C2G_MessageHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Logic
|
||||
{
|
||||
public class H_C2G_MessageHandler : Message<H_C2G_Message>
|
||||
{
|
||||
protected override async FTask Run(Session session, H_C2G_Message message)
|
||||
{
|
||||
Log.Debug($"接收到消息 H_C2G_Message:{message.ToJson()}");
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
18
DotNet/Logic/src/Handler/H_C2G_MessageRequestHandler.cs
Normal file
18
DotNet/Logic/src/Handler/H_C2G_MessageRequestHandler.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public class H_C2G_MessageRequestHandler : MessageRPC<H_C2G_MessageRequest,H_G2C_MessageResponse>
|
||||
{
|
||||
protected override async FTask Run(Session session, H_C2G_MessageRequest request, H_G2C_MessageResponse response, Action reply)
|
||||
{
|
||||
// 这里是接收到客户端发送的消息
|
||||
Log.Debug($"接收到RPC消息 H_C2G_MessageRequest:{request.ToJson()}");
|
||||
// response是要给客户端返回的消息、数据结构是在proto文件里定义的
|
||||
response.Message = "Hello world,您现在收到的消息是一个RPC消息";
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
#endif
|
20
DotNet/Logic/src/Handler/H_C2G_PushMessageToClientHandler.cs
Normal file
20
DotNet/Logic/src/Handler/H_C2G_PushMessageToClientHandler.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
using TEngine.Core;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public class H_C2G_PushMessageToClientHandler : Message<H_C2G_PushMessageToClient>
|
||||
{
|
||||
protected override async FTask Run(Session session, H_C2G_PushMessageToClient message)
|
||||
{
|
||||
Log.Debug($"接收到客户端发送给服务器的请求推送消息:{message.ToJson()}");
|
||||
// 服务器主动推送给客户端消息
|
||||
session.Send(new H_G2C_ReceiveMessageToServer()
|
||||
{
|
||||
Message = "这个是服务器推送给客户端的消息"
|
||||
});
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
#endif
|
46
DotNet/Logic/src/Handler/I_G2M_LoginAddressRequestHandler.cs
Normal file
46
DotNet/Logic/src/Handler/I_G2M_LoginAddressRequestHandler.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
#if TENGINE_NET
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TEngine.Core.Network;
|
||||
|
||||
namespace TEngine.Logic
|
||||
{
|
||||
public class Unit : Entity
|
||||
{
|
||||
public long GateRouteId;
|
||||
}
|
||||
|
||||
public static class AddressManage
|
||||
{
|
||||
public static readonly Dictionary<long, Unit> Units = new Dictionary<long, Unit>();
|
||||
|
||||
public static Unit Add(Scene scene, long addressId, long gateRouteId)
|
||||
{
|
||||
var unit = Entity.Create<Unit>(scene, addressId);
|
||||
unit.GateRouteId = gateRouteId;
|
||||
Units.Add(unit.Id, unit);
|
||||
return unit;
|
||||
}
|
||||
|
||||
public static Unit? Get(long addressId)
|
||||
{
|
||||
return Units.TryGetValue(addressId, out var unit) ? unit : null;
|
||||
}
|
||||
}
|
||||
|
||||
public class I_G2M_LoginAddressRequestHandler : RouteRPC<Scene,I_G2M_LoginAddressRequest,I_M2G_LoginAddressResponse>
|
||||
{
|
||||
protected override async FTask Run(Scene scene, I_G2M_LoginAddressRequest request, I_M2G_LoginAddressResponse response, Action reply)
|
||||
{
|
||||
// 现在这里是MAP服务器了、玩家进入这里如果是首次进入会有玩家的所有信息
|
||||
// 一般这个信息是数据库里拿到或者其他服务器给传递过来了、这里主要演示怎么注册Address、所以这些步骤这里就不做了
|
||||
// 这里我就模拟一个假的Unit数据使用
|
||||
// 1、首先创建一个Unit
|
||||
var unit = AddressManage.Add(scene, request.AddressId, request.GateRouteId);
|
||||
// 2、挂在AddressableMessageComponent组件、让这个Unit支持Address、并且会自动注册到网格中
|
||||
await unit.AddComponent<AddressableMessageComponent>().Register();
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
27
DotNet/Logic/src/Helper/AssemblySystem.cs
Normal file
27
DotNet/Logic/src/Helper/AssemblySystem.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core;
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 整个框架使用的程序集、有几个程序集就定义集。这里定义是为了后面方面使用
|
||||
/// </summary>
|
||||
public static class AssemblyName
|
||||
{
|
||||
public const int Hotfix = 1;
|
||||
}
|
||||
|
||||
public static class AssemblySystem
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
LoadHotfix();
|
||||
}
|
||||
|
||||
public static void LoadHotfix()
|
||||
{
|
||||
AssemblyManager.Load(AssemblyName.Hotfix, typeof(AssemblySystem).Assembly);
|
||||
}
|
||||
}
|
||||
#endif
|
139
DotNet/Logic/src/Helper/ConfigTableSystem.cs
Normal file
139
DotNet/Logic/src/Helper/ConfigTableSystem.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core;
|
||||
using TEngine.Core.DataBase;
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
public static class ConfigTableSystem
|
||||
{
|
||||
public static void Bind()
|
||||
{
|
||||
// 框架需要一些的配置文件来启动服务器和创建网络服务所以需要ServerConfig.xlsx和MachineConfig.xlsx的配置
|
||||
// 由于配置表的代码是生成在框架外面的、框架没办法直接获取到配置文件
|
||||
// 考虑到这两个配置文件开发者可能会修改结构、所以提供了一个委托来让开发者开自己定义如何获取框架需要的东西
|
||||
// 本来想提供一个接口让玩家把ServerConfig和MachineConfig添加到框架中、但这样就不支持热更
|
||||
// 提供委托方式就可以支持配置表热更。因为配置表读取本就是支持热更的
|
||||
// 虽然这块稍微麻烦点、但好在配置一次以后基本不会改动、后面有更好的办法我会把这个给去掉
|
||||
ConfigTableManage.ServerConfig = serverId =>
|
||||
{
|
||||
if (!ServerConfigData.Instance.TryGet(serverId, out var serverConfig))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ServerConfigInfo()
|
||||
{
|
||||
Id = serverConfig.Id,
|
||||
InnerPort = serverConfig.InnerPort,
|
||||
MachineId = serverConfig.MachineId
|
||||
};
|
||||
};
|
||||
ConfigTableManage.MachineConfig = machineId =>
|
||||
{
|
||||
if (!MachineConfigData.Instance.TryGet(machineId, out var machineConfig))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new MachineConfigInfo()
|
||||
{
|
||||
Id = machineConfig.Id,
|
||||
OuterIP = machineConfig.OuterIP,
|
||||
OuterBindIP = machineConfig.OuterBindIP,
|
||||
InnerBindIP = machineConfig.InnerBindIP,
|
||||
ManagementPort = machineConfig.ManagementPort
|
||||
};
|
||||
};
|
||||
ConfigTableManage.WorldConfigInfo = worldId =>
|
||||
{
|
||||
if (!WorldConfigData.Instance.TryGet(worldId, out var worldConfig))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new WorldConfigInfo()
|
||||
{
|
||||
Id = worldConfig.Id,
|
||||
WorldName = worldConfig.WorldName,
|
||||
DbConnection = worldConfig.DbConnection,
|
||||
DbName = worldConfig.DbName,
|
||||
DbType = worldConfig.DbType
|
||||
};
|
||||
};
|
||||
ConfigTableManage.SceneConfig = sceneId =>
|
||||
{
|
||||
if (!SceneConfigData.Instance.TryGet(sceneId, out var sceneConfig))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new SceneConfigInfo()
|
||||
{
|
||||
Id = sceneConfig.Id,
|
||||
SceneType = sceneConfig.SceneType,
|
||||
Name = sceneConfig.Name,
|
||||
NetworkProtocol = sceneConfig.NetworkProtocol,
|
||||
RouteId = sceneConfig.RouteId,
|
||||
WorldId = sceneConfig.WorldId,
|
||||
OuterPort = sceneConfig.OuterPort
|
||||
};
|
||||
};
|
||||
ConfigTableManage.AllServerConfig = () =>
|
||||
{
|
||||
var list = new List<ServerConfigInfo>();
|
||||
|
||||
foreach (var serverConfig in ServerConfigData.Instance.List)
|
||||
{
|
||||
list.Add(new ServerConfigInfo()
|
||||
{
|
||||
Id = serverConfig.Id,
|
||||
InnerPort = serverConfig.InnerPort,
|
||||
MachineId = serverConfig.MachineId
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
};
|
||||
ConfigTableManage.AllMachineConfig = () =>
|
||||
{
|
||||
var list = new List<MachineConfigInfo>();
|
||||
|
||||
foreach (var machineConfig in MachineConfigData.Instance.List)
|
||||
{
|
||||
list.Add(new MachineConfigInfo()
|
||||
{
|
||||
Id = machineConfig.Id,
|
||||
OuterIP = machineConfig.OuterIP,
|
||||
OuterBindIP = machineConfig.OuterBindIP,
|
||||
InnerBindIP = machineConfig.InnerBindIP,
|
||||
ManagementPort = machineConfig.ManagementPort
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
};
|
||||
ConfigTableManage.AllSceneConfig = () =>
|
||||
{
|
||||
var list = new List<SceneConfigInfo>();
|
||||
|
||||
foreach (var sceneConfig in SceneConfigData.Instance.List)
|
||||
{
|
||||
list.Add(new SceneConfigInfo()
|
||||
{
|
||||
Id = sceneConfig.Id,
|
||||
EntityId = sceneConfig.EntityId,
|
||||
SceneType = sceneConfig.SceneType,
|
||||
Name = sceneConfig.Name,
|
||||
NetworkProtocol = sceneConfig.NetworkProtocol,
|
||||
RouteId = sceneConfig.RouteId,
|
||||
WorldId = sceneConfig.WorldId,
|
||||
OuterPort = sceneConfig.OuterPort
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
32
DotNet/Logic/src/OnCreateScene.cs
Normal file
32
DotNet/Logic/src/OnCreateScene.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#if TENGINE_NET
|
||||
using TEngine.Core.Network;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
/// <summary>
|
||||
/// 当Scene创建时需要干什么
|
||||
/// </summary>
|
||||
public class OnCreateScene : AsyncEventSystem<TEngine.OnCreateScene>
|
||||
{
|
||||
public override async FTask Handler(TEngine.OnCreateScene self)
|
||||
{
|
||||
// 服务器是以Scene为单位的、所以Scene下有什么组件都可以自己添加定义
|
||||
// OnCreateScene这个事件就是给开发者使用的
|
||||
// 比如Address协议这里、我就是做了一个管理Address地址的一个组件挂在到Address这个Scene下面了
|
||||
// 比如Map下你需要一些自定义组件、你也可以在这里操作
|
||||
var sceneConfigInfo = self.SceneInfo;
|
||||
|
||||
switch (sceneConfigInfo.SceneType)
|
||||
{
|
||||
case "Addressable":
|
||||
{
|
||||
sceneConfigInfo.Scene.AddComponent<AddressableManageComponent>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log.Info($"scene create: {self.SceneInfo.SceneType} {self.SceneInfo.Name} SceneId:{self.SceneInfo.Id} ServerId:{self.SceneInfo.RouteId} WorldId:{self.SceneInfo.WorldId}");
|
||||
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user