更新编辑器MenuItem导表与导出协议

更新编辑器MenuItem导表与导出协议
This commit is contained in:
ALEXTANGXIAO
2023-07-29 00:03:54 +08:00
parent 30192d52cf
commit 98dcb80942
29 changed files with 217 additions and 1018 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: afddbfe87a53e9049bf031ee18842f87
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8f3bcefaf67e76141a6d8edeb8354fea
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 25113973d38eb5a48b064863830539a4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ef51ed54e72f97a4ab530b932680e08b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 090163c612f34ac4fb80004ac5f057b4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -25,8 +25,8 @@ public sealed class Exporter
LogInfo("请输入你想要做的操作:");
LogInfo("1:导出网络协议ProtoBuf");
LogInfo("2:增量导出Excel包含常量枚举");
LogInfo("3:全量导出Excel包含常量枚举");
LogInfo("2:增量导出服务器启动Excel包含常量枚举");
LogInfo("3:全量导出服务器启动Excel包含常量枚举");
var keyChar = Console.ReadKey().KeyChar;

View File

@@ -7,46 +7,29 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
{
public sealed partial class BuffAttrConfig : Bright.Config.BeanBase
{
public BuffAttrConfig(JSONNode _json)
public BuffAttrConfig(ByteBuf _buf)
{
{ if(!_json["BuffID"].IsNumber) { throw new SerializationException(); } BuffID = _json["BuffID"]; }
{ if(!_json["name"].IsString) { throw new SerializationException(); } Name = _json["name"]; }
{ if(!_json["StackNum"].IsNumber) { throw new SerializationException(); } StackNum = _json["StackNum"]; }
{ if(!_json["DurTime"].IsNumber) { throw new SerializationException(); } DurTime = _json["DurTime"]; }
{ if(!_json["ResultType"].IsNumber) { throw new SerializationException(); } ResultType = (Battle.BuffResultType)_json["ResultType"].AsInt; }
{ if(!_json["RemoveWhenDie"].IsNumber) { throw new SerializationException(); } RemoveWhenDie = _json["RemoveWhenDie"]; }
{ if(!_json["DotDamageData"].IsObject) { throw new SerializationException(); } DotDamageData = Battle.SkillAttrDamageData.DeserializeSkillAttrDamageData(_json["DotDamageData"]); }
{ if(!_json["DotTickConfig"].IsObject) { throw new SerializationException(); } DotTickConfig = Battle.BuffDotTickConfig.DeserializeBuffDotTickConfig(_json["DotTickConfig"]); }
{ var __json0 = _json["AttrData"]; if(!__json0.IsArray) { throw new SerializationException(); } AttrData = new System.Collections.Generic.List<Battle.ResAttrImpactData>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { Battle.ResAttrImpactData __v0; { if(!__e0.IsObject) { throw new SerializationException(); } __v0 = Battle.ResAttrImpactData.DeserializeResAttrImpactData(__e0); } AttrData.Add(__v0); } }
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 BuffAttrConfig(int BuffID, string name, int StackNum, float DurTime, Battle.BuffResultType ResultType, int RemoveWhenDie, Battle.SkillAttrDamageData DotDamageData, Battle.BuffDotTickConfig DotTickConfig, System.Collections.Generic.List<Battle.ResAttrImpactData> AttrData )
public static BuffAttrConfig DeserializeBuffAttrConfig(ByteBuf _buf)
{
this.BuffID = BuffID;
this.Name = name;
this.StackNum = StackNum;
this.DurTime = DurTime;
this.ResultType = ResultType;
this.RemoveWhenDie = RemoveWhenDie;
this.DotDamageData = DotDamageData;
this.DotTickConfig = DotTickConfig;
this.AttrData = AttrData;
PostInit();
}
public static BuffAttrConfig DeserializeBuffAttrConfig(JSONNode _json)
{
return new Battle.BuffAttrConfig(_json);
return new Battle.BuffAttrConfig(_buf);
}
/// <summary>
@@ -113,4 +96,5 @@ public sealed partial class BuffAttrConfig : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,44 +7,28 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
{
public sealed partial class BuffConfig : Bright.Config.BeanBase
{
public BuffConfig(JSONNode _json)
public BuffConfig(ByteBuf _buf)
{
{ if(!_json["BuffID"].IsNumber) { throw new SerializationException(); } BuffID = _json["BuffID"]; }
{ if(!_json["name"].IsString) { throw new SerializationException(); } Name = _json["name"]; }
{ if(!_json["prefId"].IsNumber) { throw new SerializationException(); } PrefId = _json["prefId"]; }
{ if(!_json["desc"].IsString) { throw new SerializationException(); } Desc = _json["desc"]; }
{ if(!_json["icon"].IsString) { throw new SerializationException(); } Icon = _json["icon"]; }
{ if(!_json["TimeType"].IsNumber) { throw new SerializationException(); } TimeType = (Battle.BuffTimeType)_json["TimeType"].AsInt; }
{ if(!_json["ReplaceType"].IsNumber) { throw new SerializationException(); } ReplaceType = (Battle.BuffReplaceType)_json["ReplaceType"].AsInt; }
{ if(!_json["State"].IsObject) { throw new SerializationException(); } State = Battle.BuffTriggleState.DeserializeBuffTriggleState(_json["State"]); }
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 BuffConfig(int BuffID, string name, int prefId, string desc, string icon, Battle.BuffTimeType TimeType, Battle.BuffReplaceType ReplaceType, Battle.BuffTriggleState State )
public static BuffConfig DeserializeBuffConfig(ByteBuf _buf)
{
this.BuffID = BuffID;
this.Name = name;
this.PrefId = prefId;
this.Desc = desc;
this.Icon = icon;
this.TimeType = TimeType;
this.ReplaceType = ReplaceType;
this.State = State;
PostInit();
}
public static BuffConfig DeserializeBuffConfig(JSONNode _json)
{
return new Battle.BuffConfig(_json);
return new Battle.BuffConfig(_buf);
}
/// <summary>
@@ -108,4 +92,5 @@ public sealed partial class BuffConfig : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,32 +7,22 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
{
public sealed partial class BuffDotTickConfig : Bright.Config.BeanBase
{
public BuffDotTickConfig(JSONNode _json)
public BuffDotTickConfig(ByteBuf _buf)
{
{ if(!_json["TickTime"].IsNumber) { throw new SerializationException(); } TickTime = _json["TickTime"]; }
{ if(!_json["TickWhenAdd"].IsNumber) { throw new SerializationException(); } TickWhenAdd = _json["TickWhenAdd"]; }
TickTime = _buf.ReadFloat();
TickWhenAdd = _buf.ReadInt();
PostInit();
}
public BuffDotTickConfig(float TickTime, int TickWhenAdd )
public static BuffDotTickConfig DeserializeBuffDotTickConfig(ByteBuf _buf)
{
this.TickTime = TickTime;
this.TickWhenAdd = TickWhenAdd;
PostInit();
}
public static BuffDotTickConfig DeserializeBuffDotTickConfig(JSONNode _json)
{
return new Battle.BuffDotTickConfig(_json);
return new Battle.BuffDotTickConfig(_buf);
}
public float TickTime { get; private set; }
@@ -61,4 +51,5 @@ public sealed partial class BuffDotTickConfig : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,32 +7,22 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
{
public sealed partial class BuffTriggleState : Bright.Config.BeanBase
{
public BuffTriggleState(JSONNode _json)
public BuffTriggleState(ByteBuf _buf)
{
{ if(!_json["StateID"].IsNumber) { throw new SerializationException(); } StateID = (Battle.BuffStateID)_json["StateID"].AsInt; }
{ if(!_json["StateParam"].IsNumber) { throw new SerializationException(); } StateParam = _json["StateParam"]; }
StateID = (Battle.BuffStateID)_buf.ReadInt();
StateParam = _buf.ReadFloat();
PostInit();
}
public BuffTriggleState(Battle.BuffStateID StateID, float StateParam )
public static BuffTriggleState DeserializeBuffTriggleState(ByteBuf _buf)
{
this.StateID = StateID;
this.StateParam = StateParam;
PostInit();
}
public static BuffTriggleState DeserializeBuffTriggleState(JSONNode _json)
{
return new Battle.BuffTriggleState(_json);
return new Battle.BuffTriggleState(_buf);
}
public Battle.BuffStateID StateID { get; private set; }
@@ -61,4 +51,5 @@ public sealed partial class BuffTriggleState : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,34 +7,23 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
{
public sealed partial class ResAttrImpactData : Bright.Config.BeanBase
{
public ResAttrImpactData(JSONNode _json)
public ResAttrImpactData(ByteBuf _buf)
{
{ if(!_json["DataType"].IsNumber) { throw new SerializationException(); } DataType = (Battle.ActorAttrDataType)_json["DataType"].AsInt; }
{ if(!_json["AddType"].IsNumber) { throw new SerializationException(); } AddType = (Battle.ActorAttrAddType)_json["AddType"].AsInt; }
{ if(!_json["Value"].IsNumber) { throw new SerializationException(); } Value = _json["Value"]; }
DataType = (Battle.ActorAttrDataType)_buf.ReadInt();
AddType = (Battle.ActorAttrAddType)_buf.ReadInt();
Value = _buf.ReadFloat();
PostInit();
}
public ResAttrImpactData(Battle.ActorAttrDataType DataType, Battle.ActorAttrAddType AddType, float Value )
public static ResAttrImpactData DeserializeResAttrImpactData(ByteBuf _buf)
{
this.DataType = DataType;
this.AddType = AddType;
this.Value = Value;
PostInit();
}
public static ResAttrImpactData DeserializeResAttrImpactData(JSONNode _json)
{
return new Battle.ResAttrImpactData(_json);
return new Battle.ResAttrImpactData(_buf);
}
public Battle.ActorAttrDataType DataType { get; private set; }
@@ -65,4 +54,5 @@ public sealed partial class ResAttrImpactData : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,40 +7,26 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
{
public sealed partial class SkillAttrDamageData : Bright.Config.BeanBase
{
public SkillAttrDamageData(JSONNode _json)
public SkillAttrDamageData(ByteBuf _buf)
{
{ if(!_json["MagicType"].IsNumber) { throw new SerializationException(); } MagicType = (Battle.SkillMagicType)_json["MagicType"].AsInt; }
{ if(!_json["AttrType"].IsNumber) { throw new SerializationException(); } AttrType = (Battle.SkillAttrDamageType)_json["AttrType"].AsInt; }
{ if(!_json["Param1"].IsNumber) { throw new SerializationException(); } Param1 = _json["Param1"]; }
{ if(!_json["Param2"].IsNumber) { throw new SerializationException(); } Param2 = _json["Param2"]; }
{ if(!_json["Param3"].IsNumber) { throw new SerializationException(); } Param3 = _json["Param3"]; }
{ if(!_json["MaxLimit"].IsNumber) { throw new SerializationException(); } MaxLimit = _json["MaxLimit"]; }
MagicType = (Battle.SkillMagicType)_buf.ReadInt();
AttrType = (Battle.SkillAttrDamageType)_buf.ReadInt();
Param1 = _buf.ReadFloat();
Param2 = _buf.ReadFloat();
Param3 = _buf.ReadFloat();
MaxLimit = _buf.ReadFloat();
PostInit();
}
public SkillAttrDamageData(Battle.SkillMagicType MagicType, Battle.SkillAttrDamageType AttrType, float Param1, float Param2, float Param3, float MaxLimit )
public static SkillAttrDamageData DeserializeSkillAttrDamageData(ByteBuf _buf)
{
this.MagicType = MagicType;
this.AttrType = AttrType;
this.Param1 = Param1;
this.Param2 = Param2;
this.Param3 = Param3;
this.MaxLimit = MaxLimit;
PostInit();
}
public static SkillAttrDamageData DeserializeSkillAttrDamageData(JSONNode _json)
{
return new Battle.SkillAttrDamageData(_json);
return new Battle.SkillAttrDamageData(_buf);
}
public Battle.SkillMagicType MagicType { get; private set; }
@@ -77,4 +63,5 @@ public sealed partial class SkillAttrDamageData : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,50 +7,31 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
{
public sealed partial class SkillBaseConfig : Bright.Config.BeanBase
{
public SkillBaseConfig(JSONNode _json)
public SkillBaseConfig(ByteBuf _buf)
{
{ if(!_json["id"].IsNumber) { throw new SerializationException(); } Id = _json["id"]; }
{ if(!_json["name"].IsString) { throw new SerializationException(); } Name = _json["name"]; }
{ if(!_json["SkillDispID"].IsNumber) { throw new SerializationException(); } SkillDispID = _json["SkillDispID"]; }
{ if(!_json["SkillType"].IsNumber) { throw new SerializationException(); } SkillType = _json["SkillType"]; }
{ if(!_json["desc"].IsString) { throw new SerializationException(); } Desc = _json["desc"]; }
{ if(!_json["CostMP"].IsNumber) { throw new SerializationException(); } CostMP = _json["CostMP"]; }
{ if(!_json["GCDID"].IsNumber) { throw new SerializationException(); } GCDID = _json["GCDID"]; }
{ if(!_json["SkillCD"].IsNumber) { throw new SerializationException(); } SkillCD = _json["SkillCD"]; }
{ if(!_json["IsRepeatTrigger"].IsBoolean) { throw new SerializationException(); } IsRepeatTrigger = _json["IsRepeatTrigger"]; }
{ var __json0 = _json["BuffID"]; if(!__json0.IsArray) { throw new SerializationException(); } BuffID = new System.Collections.Generic.List<int>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { int __v0; { if(!__e0.IsNumber) { throw new SerializationException(); } __v0 = __e0; } BuffID.Add(__v0); } }
{ var __json0 = _json["AttrDamageData"]; if(!__json0.IsArray) { throw new SerializationException(); } AttrDamageData = new System.Collections.Generic.List<Battle.SkillAttrDamageData>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { Battle.SkillAttrDamageData __v0; { if(!__e0.IsObject) { throw new SerializationException(); } __v0 = Battle.SkillAttrDamageData.DeserializeSkillAttrDamageData(__e0); } AttrDamageData.Add(__v0); } }
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 SkillBaseConfig(int id, string name, int SkillDispID, int SkillType, string desc, int CostMP, int GCDID, float SkillCD, bool IsRepeatTrigger, System.Collections.Generic.List<int> BuffID, System.Collections.Generic.List<Battle.SkillAttrDamageData> AttrDamageData )
public static SkillBaseConfig DeserializeSkillBaseConfig(ByteBuf _buf)
{
this.Id = id;
this.Name = name;
this.SkillDispID = SkillDispID;
this.SkillType = SkillType;
this.Desc = desc;
this.CostMP = CostMP;
this.GCDID = GCDID;
this.SkillCD = SkillCD;
this.IsRepeatTrigger = IsRepeatTrigger;
this.BuffID = BuffID;
this.AttrDamageData = AttrDamageData;
PostInit();
}
public static SkillBaseConfig DeserializeSkillBaseConfig(JSONNode _json)
{
return new Battle.SkillBaseConfig(_json);
return new Battle.SkillBaseConfig(_buf);
}
/// <summary>
@@ -129,4 +110,5 @@ public sealed partial class SkillBaseConfig : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,26 +7,25 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class TbBuff
{
public partial class TbBuff
{
private readonly Dictionary<int, Battle.BuffConfig> _dataMap;
private readonly List<Battle.BuffConfig> _dataList;
public TbBuff(JSONNode _json)
public TbBuff(ByteBuf _buf)
{
_dataMap = new Dictionary<int, Battle.BuffConfig>();
_dataList = new List<Battle.BuffConfig>();
foreach(JSONNode _row in _json.Children)
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
var _v = Battle.BuffConfig.DeserializeBuffConfig(_row);
Battle.BuffConfig _v;
_v = Battle.BuffConfig.DeserializeBuffConfig(_buf);
_dataList.Add(_v);
_dataMap.Add(_v.BuffID, _v);
}
@@ -57,7 +56,6 @@ public sealed partial class TbBuff
}
}
partial void PostInit();
partial void PostResolve();
}

View File

@@ -7,26 +7,25 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class TbBuffAttr
{
public partial class TbBuffAttr
{
private readonly Dictionary<int, Battle.BuffAttrConfig> _dataMap;
private readonly List<Battle.BuffAttrConfig> _dataList;
public TbBuffAttr(JSONNode _json)
public TbBuffAttr(ByteBuf _buf)
{
_dataMap = new Dictionary<int, Battle.BuffAttrConfig>();
_dataList = new List<Battle.BuffAttrConfig>();
foreach(JSONNode _row in _json.Children)
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
var _v = Battle.BuffAttrConfig.DeserializeBuffAttrConfig(_row);
Battle.BuffAttrConfig _v;
_v = Battle.BuffAttrConfig.DeserializeBuffAttrConfig(_buf);
_dataList.Add(_v);
_dataMap.Add(_v.BuffID, _v);
}
@@ -57,7 +56,6 @@ public sealed partial class TbBuffAttr
}
}
partial void PostInit();
partial void PostResolve();
}

View File

@@ -7,26 +7,25 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class TbSkill
{
public partial class TbSkill
{
private readonly Dictionary<int, Battle.SkillBaseConfig> _dataMap;
private readonly List<Battle.SkillBaseConfig> _dataList;
public TbSkill(JSONNode _json)
public TbSkill(ByteBuf _buf)
{
_dataMap = new Dictionary<int, Battle.SkillBaseConfig>();
_dataList = new List<Battle.SkillBaseConfig>();
foreach(JSONNode _row in _json.Children)
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
var _v = Battle.SkillBaseConfig.DeserializeSkillBaseConfig(_row);
Battle.SkillBaseConfig _v;
_v = Battle.SkillBaseConfig.DeserializeSkillBaseConfig(_buf);
_dataList.Add(_v);
_dataMap.Add(_v.Id, _v);
}
@@ -57,7 +56,6 @@ public sealed partial class TbSkill
}
}
partial void PostInit();
partial void PostResolve();
}

View File

@@ -6,20 +6,19 @@
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using SimpleJSON;
namespace GameConfig
{
public sealed partial class Tables
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, JSONNode> loader)
public Tables(System.Func<string, ByteBuf> loader)
{
var tables = new System.Collections.Generic.Dictionary<string, object>();
TbItem = new item.TbItem(loader("item_tbitem"));
@@ -30,8 +29,8 @@ public sealed partial class Tables
tables.Add("Battle.TbBuff", TbBuff);
TbBuffAttr = new Battle.TbBuffAttr(loader("battle_tbbuffattr"));
tables.Add("Battle.TbBuffAttr", TbBuffAttr);
PostInit();
PostInit();
TbItem.Resolve(tables);
TbSkill.Resolve(tables);
TbBuff.Resolve(tables);

View File

@@ -7,50 +7,31 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.item
{
{
public sealed partial class Item : Bright.Config.BeanBase
{
public Item(JSONNode _json)
public Item(ByteBuf _buf)
{
{ if(!_json["id"].IsNumber) { throw new SerializationException(); } Id = _json["id"]; }
{ if(!_json["name"].IsString) { throw new SerializationException(); } Name = _json["name"]; }
{ if(!_json["desc"].IsString) { throw new SerializationException(); } Desc = _json["desc"]; }
{ if(!_json["price"].IsNumber) { throw new SerializationException(); } Price = _json["price"]; }
{ if(!_json["upgrade_to_item_id"].IsNumber) { throw new SerializationException(); } UpgradeToItemId = _json["upgrade_to_item_id"]; }
{ var _j = _json["expire_time"]; if (_j.Tag != JSONNodeType.None && _j.Tag != JSONNodeType.NullValue) { { if(!_j.IsNumber) { throw new SerializationException(); } ExpireTime = _j; } } else { ExpireTime = null; } }
{ if(!_json["batch_useable"].IsBoolean) { throw new SerializationException(); } BatchUseable = _json["batch_useable"]; }
{ if(!_json["quality"].IsNumber) { throw new SerializationException(); } Quality = (item.EQuality)_json["quality"].AsInt; }
{ if(!_json["exchange_stream"].IsObject) { throw new SerializationException(); } ExchangeStream = item.ItemExchange.DeserializeItemExchange(_json["exchange_stream"]); }
{ var __json0 = _json["exchange_list"]; if(!__json0.IsArray) { throw new SerializationException(); } ExchangeList = new System.Collections.Generic.List<item.ItemExchange>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { item.ItemExchange __v0; { if(!__e0.IsObject) { throw new SerializationException(); } __v0 = item.ItemExchange.DeserializeItemExchange(__e0); } ExchangeList.Add(__v0); } }
{ if(!_json["exchange_column"].IsObject) { throw new SerializationException(); } ExchangeColumn = item.ItemExchange.DeserializeItemExchange(_json["exchange_column"]); }
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 Item(int id, string name, string desc, int price, int upgrade_to_item_id, int? expire_time, bool batch_useable, item.EQuality quality, item.ItemExchange exchange_stream, System.Collections.Generic.List<item.ItemExchange> exchange_list, item.ItemExchange exchange_column )
public static Item DeserializeItem(ByteBuf _buf)
{
this.Id = id;
this.Name = name;
this.Desc = desc;
this.Price = price;
this.UpgradeToItemId = upgrade_to_item_id;
this.ExpireTime = expire_time;
this.BatchUseable = batch_useable;
this.Quality = quality;
this.ExchangeStream = exchange_stream;
this.ExchangeList = exchange_list;
this.ExchangeColumn = exchange_column;
PostInit();
}
public static Item DeserializeItem(JSONNode _json)
{
return new item.Item(_json);
return new item.Item(_buf);
}
/// <summary>
@@ -135,4 +116,5 @@ public sealed partial class Item : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,32 +7,22 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.item
{
{
public sealed partial class ItemExchange : Bright.Config.BeanBase
{
public ItemExchange(JSONNode _json)
public ItemExchange(ByteBuf _buf)
{
{ if(!_json["id"].IsNumber) { throw new SerializationException(); } Id = _json["id"]; }
{ if(!_json["num"].IsNumber) { throw new SerializationException(); } Num = _json["num"]; }
Id = _buf.ReadInt();
Num = _buf.ReadInt();
PostInit();
}
public ItemExchange(int id, int num )
public static ItemExchange DeserializeItemExchange(ByteBuf _buf)
{
this.Id = id;
this.Num = num;
PostInit();
}
public static ItemExchange DeserializeItemExchange(JSONNode _json)
{
return new item.ItemExchange(_json);
return new item.ItemExchange(_buf);
}
/// <summary>
@@ -67,4 +57,5 @@ public sealed partial class ItemExchange : Bright.Config.BeanBase
partial void PostInit();
partial void PostResolve();
}
}
}

View File

@@ -7,26 +7,25 @@
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.item
{
public sealed partial class TbItem
{
public partial class TbItem
{
private readonly Dictionary<int, item.Item> _dataMap;
private readonly List<item.Item> _dataList;
public TbItem(JSONNode _json)
public TbItem(ByteBuf _buf)
{
_dataMap = new Dictionary<int, item.Item>();
_dataList = new List<item.Item>();
foreach(JSONNode _row in _json.Children)
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
var _v = item.Item.DeserializeItem(_row);
item.Item _v;
_v = item.Item.DeserializeItem(_buf);
_dataList.Add(_v);
_dataMap.Add(_v.Id, _v);
}
@@ -57,7 +56,6 @@ public sealed partial class TbItem
}
}
partial void PostInit();
partial void PostResolve();
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace TEngine.Editor
{
public static class GenTools
{
public const string GenNetFirstTips = "ProtoGenTools.GenNetFirstTips";
[MenuItem("TEngine/导出网络Proto|Gen Proto", false, 100)]
public static void ExportProto()
{
var firstTips = EditorPrefs.GetBool(GenNetFirstTips, false);
if (!firstTips && EditorUtility.DisplayDialog("提示", "导出网络Proto依赖于DotNet下Server解决方案首次打开请编译", "不再提示", "继续"))
{
EditorPrefs.SetBool(GenNetFirstTips, true);
return;
}
Application.OpenURL(System.IO.Path.Combine(Application.dataPath,"../DotNet/start_export.bat"));
Debug.Log("proto2cs succeed!");
}
[MenuItem("TEngine/导出Config|Export Config", false, 100)]
public static void ExportConfig()
{
Application.OpenURL(System.IO.Path.Combine(Application.dataPath,"../Luban/gen_code_bin_to_project.bat"));
Debug.Log("proto2cs succeed!");
}
}
}

View File

@@ -1,291 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace TEngine.Editor
{
public static class ProtoGenTools
{
#if UNITY_EDITOR
[MenuItem("TEngine/生成Proto|Gen Proto", false, 10)]
#endif
public static void Export()
{
InnerProto2CS.Proto2CS();
Debug.Log("proto2cs succeed!");
}
}
public static class InnerProto2CS
{
private static string ProtoPath = UnityEngine.Application.dataPath + "/..\\Luban\\Proto\\pb_schemas\\";
private static string OutPutPath =
UnityEngine.Application.dataPath + "/..\\Luban\\Proto\\Gen\\";
private static readonly char[] splitChars = { ' ', '\t' };
public static void Proto2CS()
{
Proto2CS("GameProto", "ProtoBase.proto", OutPutPath,10001,false);
}
public static void Proto2CS(string nameSpace, string protoName, string outputPath, int startOpcode,bool useMemoryPool = false)
{
if (!Directory.Exists(outputPath))
{
Directory.CreateDirectory(outputPath);
}
string proto = Path.Combine(ProtoPath, protoName);
string csPath = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(proto) + ".cs");
string s = File.ReadAllText(proto);
StringBuilder sb = new StringBuilder();
sb.Append("//------------------------------------------------------------------------------\n");
sb.Append("// <auto-generated>\n");
sb.Append("// This code was generated by a tool.\n");
sb.Append("// Changes to this file may cause incorrect behavior and will be lost if\n");
sb.Append("// the code is regenerated.\n");
sb.Append("// </auto-generated>\n");
sb.Append("//------------------------------------------------------------------------------\n");
sb.Append("\n");
sb.Append("using System;\n");
sb.Append("using ProtoBuf;\n");
sb.Append("using TEngine;\n");
sb.Append("using System.Collections.Generic;\n");
sb.Append("\n");
sb.Append($"namespace {nameSpace}\n");
sb.Append("{\n");
bool isMsgStart = false;
bool isEnumStart = false;
foreach (string line in s.Split('\n'))
{
string newline = line.Trim();
if (newline == "")
{
continue;
}
if (newline.StartsWith("//ResponseType"))
{
string responseType = line.Split(' ')[1].TrimEnd('\r', '\n');
sb.AppendLine($"\t[ResponseType(nameof({responseType}))]");
continue;
}
if (newline.StartsWith("//"))
{
sb.Append($"\t{newline}\n");
continue;
}
if (newline.StartsWith("message"))
{
string parentClass = "";
isMsgStart = true;
string msgName = newline.Split(splitChars, StringSplitOptions.RemoveEmptyEntries)[1];
string[] ss = newline.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries);
if (ss.Length == 2)
{
parentClass = ss[1].Trim();
}
sb.Append($"\t[Serializable,global::ProtoBuf.ProtoContract(Name = @\"{msgName}\")]\n");
if (useMemoryPool)
{
sb.Append($"\tpublic partial class {msgName}: IMemory");
}
else
{
sb.Append($"\tpublic partial class {msgName}");
}
if (parentClass != "")
{
sb.Append($", {parentClass}\n");
}
else
{
sb.Append("\n");
}
continue;
}
if (isMsgStart)
{
if (newline == "{")
{
sb.Append("\t{\n");
continue;
}
if (newline == "}")
{
isMsgStart = false;
sb.Append("\t}\n\n");
continue;
}
if (newline.Trim().StartsWith("//"))
{
sb.AppendLine(newline);
continue;
}
if (newline.Trim() != "" && newline != "}")
{
if (newline.StartsWith("repeated"))
{
Repeated(sb, nameSpace, newline);
}
else
{
Members(sb, newline, true);
}
}
}
if (newline.StartsWith("enum"))
{
isEnumStart = true;
string enumName = newline.Split(splitChars, StringSplitOptions.RemoveEmptyEntries)[1];
sb.Append($"\t[global::ProtoBuf.ProtoContract()]\n");
sb.Append($"\tpublic enum {enumName}");
sb.Append("\n");
continue;
}
if (isEnumStart)
{
if (newline == "{")
{
sb.Append("\t{\n");
continue;
}
if (newline == "}")
{
isEnumStart = false;
sb.Append("\t}\n\n");
continue;
}
if (newline.Trim().StartsWith("//"))
{
sb.AppendLine(newline);
continue;
}
int index = newline.IndexOf(";");
newline = newline.Remove(index);
sb.Append($"\t\t{newline},\n\n");
}
}
sb.Append("}\n");
using (FileStream txt = new FileStream(csPath, FileMode.Create, FileAccess.ReadWrite))
{
using (StreamWriter sw = new StreamWriter(txt))
{
Debug.Log(sb.ToString());
sw.Write(sb.ToString());
}
}
}
private static void Repeated(StringBuilder sb, string ns, string newline)
{
try
{
int index = newline.IndexOf(";");
newline = newline.Remove(index);
string[] ss = newline.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
string type = ss[1];
type = ConvertType(type);
string name = ss[2];
int n = int.Parse(ss[4]);
sb.Append($"\t\t[global::ProtoBuf.ProtoMember({n})]\n");
sb.Append($"\t\tpublic List<{type}> {name} = new List<{type}>();\n\n");
}
catch (Exception e)
{
Console.WriteLine($"{newline}\n {e}");
}
}
private static string ConvertType(string type)
{
string typeCs = "";
switch (type)
{
case "int16":
typeCs = "short";
break;
case "int32":
typeCs = "int";
break;
case "bytes":
typeCs = "byte[]";
break;
case "uint32":
typeCs = "uint";
break;
case "long":
typeCs = "long";
break;
case "int64":
typeCs = "long";
break;
case "uint64":
typeCs = "ulong";
break;
case "uint16":
typeCs = "ushort";
break;
default:
typeCs = type;
break;
}
return typeCs;
}
private static void Members(StringBuilder sb, string newline, bool isRequired)
{
try
{
int index = newline.IndexOf(";");
newline = newline.Remove(index);
string[] ss = newline.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
string type = ss[0];
string name = ss[1];
int n = int.Parse(ss[3]);
string typeCs = ConvertType(type);
sb.Append($"\t\t[global::ProtoBuf.ProtoMember({n})]\n");
if (string.Equals(type,"string"))
{
sb.Append($"\t\t[global::System.ComponentModel.DefaultValue(\"\")]\n");
}
sb.Append($"\t\tpublic {typeCs} {name} {{ get; set; }}\n\n");
}
catch (Exception e)
{
Console.WriteLine($"{newline}\n {e}");
}
}
}
}

View File

@@ -1,448 +0,0 @@
using System;
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using TEngine;
using TEngine.Editor;
using Debug = UnityEngine.Debug;
class GenNetScriptWindow : EditorWindow
{
private static GenNetScriptWindow _window = null;
//绑定通知协议
private StringBuilder _strBindNotify;
//枚举对应协议号
private readonly Dictionary<string, int> _dicName2ID = new Dictionary<string, int>();
//xxx.xml下的协议枚举list
private readonly Dictionary<string, List<string>> _dicPath2Name = new Dictionary<string, List<string>>();
//协议号有没有被勾选
private readonly Dictionary<int, bool> _dicID2Select = new Dictionary<int, bool>();
//记录回包协议号
private readonly Dictionary<int, int> _dicID2ID = new Dictionary<int, int>();
private Vector2 _scrollPos;
private Vector2 _fileListScrollPos;
private string _path = @"G:\github\TEngine\Luban\Proto\pb_schemas\";
private readonly List<string> _filePathList = new List<string>();
private string _curSelectFile = string.Empty;
private string _filterFileName = string.Empty;
private string _filterProName = string.Empty;
[MenuItem("TEngine/协议生成工具|Protobuf Tools")]
static void OpenGenNetScriptWindow()
{
if (!_window)
{
_window = ScriptableObject.CreateInstance<GenNetScriptWindow>();
_window.maxSize = new Vector2(1000, 800);
_window.minSize = _window.maxSize / 2;
_window.LoadLastPath();
}
_window.ShowUtility();
}
void OnGUI()
{
EditorGUILayout.PrefixLabel("protoPath");
_path = EditorGUILayout.TextField(_path);
var r = EditorGUILayout.BeginHorizontal("Button");
if (GUI.Button(r, GUIContent.none))
{
ReadPath();
}
GUILayout.Label("Search");
EditorGUILayout.EndHorizontal();
//加个文件筛选
//EditorGUILayout.BeginHorizontal();
GUILayout.Label("filter file:");
_filterFileName = GUILayout.TextField(_filterFileName);
//EditorGUILayout.EndHorizontal();
//显示文件名部分
if (_filePathList.Count > 0)
{
_fileListScrollPos = EditorGUILayout.BeginScrollView(_fileListScrollPos, GUILayout.Width(r.width), GUILayout.Height(200));
for (int i = 0; i < _filePathList.Count; ++i)
{
var fileName = Path.GetFileNameWithoutExtension(_filePathList[i]);
if (!string.IsNullOrEmpty(_filterFileName) && fileName.IndexOf(_filterFileName, StringComparison.Ordinal) == -1)
{
continue;
}
if (GUILayout.Button(fileName))
{
_curSelectFile = _filePathList[i];
LoadSelectFile();
}
}
EditorGUILayout.EndScrollView();
}
GUILayout.Label("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
if (!string.IsNullOrEmpty(_curSelectFile))
{
//加个协议筛选
GUILayout.Label("filter proto:");
_filterProName = GUILayout.TextField(_filterProName);
_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Width(r.width), GUILayout.Height(200));
var fileName2 = Path.GetFileNameWithoutExtension(_curSelectFile);
List<string> list;
if (_dicPath2Name.TryGetValue(fileName2, out list))
{
EditorGUI.indentLevel++;
for (int i = 0; i < list.Count; ++i)
{
var cmdName = list[i];
//筛选一下,忽略大小写
if (!string.IsNullOrEmpty(_filterProName) && cmdName.ToLower().IndexOf(_filterProName.ToLower()) == -1)
continue;
var cmdID = _dicName2ID[cmdName];
EditorGUILayout.BeginHorizontal(GUIStyle.none);
//协议名
EditorGUILayout.LabelField(cmdName);
//toggle
if (!_dicID2Select.ContainsKey(cmdID))
_dicID2Select[cmdID] = false;
_dicID2Select[cmdID] = EditorGUILayout.Toggle(cmdID.ToString(),_dicID2Select[cmdID]);
//回包协议号
if (!_dicID2ID.ContainsKey(cmdID))
{
if (cmdName.EndsWith("REQ"))
_dicID2ID[cmdID] = cmdID + 1;
else
_dicID2ID[cmdID] = 0;
}
_dicID2ID[cmdID] = EditorGUILayout.IntField(_dicID2ID[cmdID]);
EditorGUILayout.EndHorizontal();
}
EditorGUI.indentLevel--;
}
EditorGUILayout.EndScrollView();
}
if (!string.IsNullOrEmpty(_curSelectFile))
{
if (GUILayout.Button("GenSelect"))
{
OnClickGenBtn(false);
}
if (GUILayout.Button("GenAll"))
{
OnClickGenBtn(true);
}
}
if (GUILayout.Button("导出Proto To Csharp|Export Proto To Csharp"))
{
ExportProto();
}
}
#region
private void LoadLastPath()
{
if (PlayerPrefs.HasKey("GenNetScriptWindow.Path"))
{
_path = PlayerPrefs.GetString("GenNetScriptWindow.Path");
}
ReadPath();
}
private void ReadPath()
{
PlayerPrefs.SetString("GenNetScriptWindow.Path", _path);
_filePathList.Clear();
_curSelectFile = String.Empty;
JustLoadFileList(_filePathList, _path);
}
private void JustLoadFileList(List<string> exportList, string folderPath, bool deep = false)
{
if (!LoadFoldChildFileList(exportList, folderPath, deep))
{
EditorUtility.DisplayDialog("folder not exist", "folder not exist:"+_path, "ok");
}
}
private void LoadSelectFile()
{
_dicID2Select.Clear();
_dicID2ID.Clear();
_dicName2ID.Clear();
var xmlFilePath = _curSelectFile;
var fileName = Path.GetFileNameWithoutExtension(xmlFilePath);
var protocolNameList = new List<string>();
//读xml
if (fileName.StartsWith("proto_cs"))
{
Debug.Log("load xml.name:" + fileName);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFilePath);
GenProtocolNameList(xmlDoc.ChildNodes, protocolNameList);
_dicPath2Name[fileName] = protocolNameList;
Debug.Log(fileName + " success.");
}
}
private bool LoadFoldChildFileList(List<string> exportList, string folderPath, bool deep = false)
{
if (!Directory.Exists(folderPath))
{
Log.Error("folder not exist: {0}", folderPath);
return false;
}
string[] subFile = Directory.GetFiles(folderPath);
foreach (string fileName in subFile)
{
//有些筛选条件,直接写死这里了。方便
var name = Path.GetFileNameWithoutExtension(fileName);
if (name.StartsWith("proto_cs"))
exportList.Add(fileName);
}
if (deep)
{
string[] subFolders = Directory.GetDirectories(folderPath);
foreach (string folderName in subFolders)
{
LoadFoldChildFileList(exportList, folderName);
}
}
return true;
}
//把macro里的协议号和协议枚举名对应起来
private void GenProtocolNameList(XmlNodeList nodeList, List<string> nameList)
{
foreach (XmlNode node in nodeList)
{
if (node.Attributes == null)
continue;
if (node.Name == "macro")
{
var name = node.Attributes.GetNamedItem("name").Value;
if (name.StartsWith("CS_CMD") || name.StartsWith("CS_NOTIFY"))
{
var id = Convert.ToInt32(node.Attributes.GetNamedItem("value").Value);
_dicName2ID[name] = id;
if (nameList != null)
nameList.Add(name);
}
}
GenProtocolNameList(node.ChildNodes, nameList);
}
}
#endregion
#region
private void OnClickGenBtn(bool genAll)
{
_strBindNotify = new StringBuilder();
bool needRegCmdHandle = false;
StringBuilder sb = new StringBuilder();
List<int> listGenId = new List<int>();
var iter = _dicID2Select.GetEnumerator();
while (iter.MoveNext())
{
if (iter.Current.Value || genAll)
{
int resId = iter.Current.Key;
int resID;
if (_dicID2ID.TryGetValue(resId, out resID))
{
if (resID != 0)
{
var oneStr = GenOneReq(resId, resID);
sb.Append(oneStr);
sb.Append("\n\n");
listGenId.Add(resId);
listGenId.Add(resID);
}
else if (!listGenId.Contains(resId))
{
needRegCmdHandle = true;
var oneStr = GenOneReq(0, resId);
sb.Append(oneStr);
sb.Append("\n\n");
listGenId.Add(resId);
}
}
}
}
if (needRegCmdHandle)
{
sb.Append("public void RegCmdHandle()\n");
sb.Append("{\n");
sb.Append(_strBindNotify);
sb.Append("}\n");
}
TextEditor te = new TextEditor();
te.text = sb.ToString();
te.SelectAll();
te.Copy();
}
private static readonly Dictionary<string, string> TempParamDic = new Dictionary<string, string>();
private static string _reqClassName = string.Empty;
private static string _resClassName = string.Empty;
private static string _reqEnumName = string.Empty;
private static string _resEnumName = string.Empty;
private static string _reqDesc = string.Empty;
private static bool _resResult;
private string GenOneReq(int reqId, int resId)
{
TempParamDic.Clear();
_reqClassName = string.Empty;
_resClassName = string.Empty;
_reqEnumName = string.Empty;
_resEnumName = string.Empty;
_resResult = false;
var xmlFilePath = _curSelectFile;
var fileName = Path.GetFileNameWithoutExtension(xmlFilePath);
//读xml
if (fileName.StartsWith("proto_cs"))
{
Debug.Log("load xml.name:" + fileName);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFilePath);
_GenOneReq(xmlDoc.ChildNodes, reqId,resId);
Debug.Log(fileName + " success.");
var sb = new StringBuilder();
sb.Append("#region ");
sb.Append(_reqDesc);
sb.Append(string.Format("\n//{0}\n", _reqDesc));
if (reqId != 0)
{
sb.Append("public void ");
sb.Append(_reqClassName.Substring(2));
sb.Append("(");
foreach (var item in TempParamDic)
{
sb.Append(string.Format("{0} {1}, ", item.Value, item.Key));
}
sb.Remove(sb.Length - 2, 2);//把多余的逗号和空格删了
sb.Append(")\n{\n");
sb.Append(string.Format("\tCSPkg reqPkg = ProtoUtil.BuildCSMsg(netMacros.{0});\n", _reqEnumName));
sb.Append(string.Format("\t{0} reqData = reqPkg.Body.{1};\n", _reqClassName, _reqClassName.Substring(2)));
foreach (var item in TempParamDic)
{
sb.Append(string.Format("\treqData.{0} = {0};\n", item.Key));
}
sb.Append("\n");
sb.Append(string.Format("\tGameClient.Instance.SendCSMsg(reqPkg, netMacros.{0}, {1});\n", _resEnumName,
_resClassName.Substring(2)));
sb.Append("}\n\n");
}
else
{
_strBindNotify.Append(string.Format("\t\tGameClient.Instance.RegCmdHandle(netMacros.{0}, {1});\n", _resEnumName, _resClassName.Substring(2)));
}
//回包
sb.Append(string.Format("private void {0}(CSMsgResult result, CSPkg msg)\n", _resClassName.Substring(2)));
sb.Append("{\n");
sb.Append(string.Format("\tif (DodUtil.CheckHaveError(result, msg, typeof({0})))\n", _resClassName));
sb.Append("\t\treturn;\n\n");
sb.Append(string.Format("\t{0} resData = msg.Body.{1};\n", _resClassName, _resClassName.Substring(2)));
if (_resResult)
{
sb.Append("\tif (resData.Result.Ret != 0)\n");
sb.Append("\t{\n");
sb.Append("\t\tUISys.Mgr.ShowTipMsg(resData.Result);\n");
sb.Append("\t\treturn;\n");
sb.Append("\t}\n");
}
sb.Append("\t//todo\n");
sb.Append("}\n#endregion");
return sb.ToString();
}
return null;
}
private void _GenOneReq(XmlNodeList nodeList, int reqId,int resId)
{
foreach (XmlNode node in nodeList)
{
if (node.Attributes == null)
continue;
if (node.Name.Equals("macro"))
{
var name = node.Attributes.GetNamedItem("name").Value;
if (name.StartsWith("CS_CMD") || name.StartsWith("CS_NOTIFY"))
{
var id = Convert.ToInt32(node.Attributes.GetNamedItem("value").Value);
if (id == reqId)
_reqEnumName = name;
if (id == resId)
_resEnumName = name;
}
}
if (node.Name.Equals("struct"))
{
if (node.Attributes.GetNamedItem("id") == null)
continue;
var enumName = node.Attributes.GetNamedItem("id").Value;
if (enumName.Equals(_reqEnumName))
{
var name = node.Attributes.GetNamedItem("name").Value;
_reqClassName = name;
if (node.Attributes.GetNamedItem("name") != null)
{
_reqDesc = node.Attributes.GetNamedItem("desc").Value;
}
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode != null && childNode.Name.Equals("entry"))
{
var paramName = childNode.Attributes.GetNamedItem("name").Value;
var paramType = childNode.Attributes.GetNamedItem("type").Value;
TempParamDic.Add(paramName, paramType);
}
}
}
if (enumName.Equals(_resEnumName))
{
var className = node.Attributes.GetNamedItem("name").Value;
_resClassName = className;
}
}
_GenOneReq(node.ChildNodes, reqId, resId);
}
}
#endregion
#region ToCsharp
private void ExportProto()
{
ProtoGenTools.Export();
}
#endregion
}

View File

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