From 95e4dd93a8ccdb21e014bcd2981b675b81818721 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Thu, 13 Jul 2023 19:05:40 +0800 Subject: [PATCH] Update Update --- .gitignore | 5 +- .../DotNet/Logic/Config~/ConfigLoader.cs | 56 + .../DotNet/Logic/Config~/Core/BeanBase.cs | 9 + .../DotNet/Logic/Config~/Core/ByteBuf.cs | 1545 +++++++++++++++++ .../DotNet/Logic/Config~/Core/ITypeId.cs | 7 + .../DotNet/Logic/Config~/Core/StringUtil.cs | 52 + .../GameConfig/Battle/ActorAttrAddType.cs | 32 + .../GameConfig/Battle/ActorAttrDataType.cs | 88 + .../GameConfig/Battle/BuffAttrConfig.cs | 100 ++ .../Config~/GameConfig/Battle/BuffConfig.cs | 96 + .../GameConfig/Battle/BuffDotTickConfig.cs | 55 + .../GameConfig/Battle/BuffReplaceType.cs | 36 + .../GameConfig/Battle/BuffResultType.cs | 100 ++ .../Config~/GameConfig/Battle/BuffStateID.cs | 60 + .../Config~/GameConfig/Battle/BuffTimeType.cs | 24 + .../GameConfig/Battle/BuffTriggleState.cs | 55 + .../GameConfig/Battle/ResAttrImpactData.cs | 58 + .../GameConfig/Battle/SkillAttrDamageData.cs | 67 + .../GameConfig/Battle/SkillAttrDamageType.cs | 40 + .../GameConfig/Battle/SkillBaseConfig.cs | 114 ++ .../GameConfig/Battle/SkillMagicType.cs | 28 + .../Logic/Config~/GameConfig/Battle/TbBuff.cs | 63 + .../Config~/GameConfig/Battle/TbBuffAttr.cs | 63 + .../Config~/GameConfig/Battle/TbSkill.cs | 63 + .../DotNet/Logic/Config~/GameConfig/Tables.cs | 53 + .../Logic/Config~/GameConfig/item/EQuality.cs | 32 + .../Logic/Config~/GameConfig/item/Item.cs | 120 ++ .../Config~/GameConfig/item/ItemExchange.cs | 61 + .../Logic/Config~/GameConfig/item/TbItem.cs | 63 + .../Config~/GameConfig/test/AccessFlag.cs | 25 + DotNet/Logic/Logic.csproj | 8 + Luban/gen_code_bin_to_server.bat | 17 + 32 files changed, 3194 insertions(+), 1 deletion(-) create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/ConfigLoader.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/Core/BeanBase.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/Core/ByteBuf.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/Core/ITypeId.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/Core/StringUtil.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrAddType.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrDataType.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffAttrConfig.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffConfig.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffDotTickConfig.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffReplaceType.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffResultType.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffStateID.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTimeType.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTriggleState.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ResAttrImpactData.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageData.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageType.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillBaseConfig.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillMagicType.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuff.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuffAttr.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbSkill.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Tables.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/EQuality.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/Item.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/ItemExchange.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/TbItem.cs create mode 100644 Assets/GameScripts/DotNet/Logic/Config~/GameConfig/test/AccessFlag.cs create mode 100644 Luban/gen_code_bin_to_server.bat diff --git a/.gitignore b/.gitignore index 4d3ebdf0..9c630850 100644 --- a/.gitignore +++ b/.gitignore @@ -126,4 +126,7 @@ DotNet/Core/obj/ DotNet/Logic/obj/ DotNet/ThirdParty/obj/ -Bin/ \ No newline at end of file +Bin/ + +#Server_Config +DotNet/Config/GameConfig \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/ConfigLoader.cs b/Assets/GameScripts/DotNet/Logic/Config~/ConfigLoader.cs new file mode 100644 index 00000000..6cb73946 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/ConfigLoader.cs @@ -0,0 +1,56 @@ +using Bright.Serialization; +using GameConfig; +using TEngine; +using TEngine.Core; + +/// +/// 配置加载器。 +/// +public class ConfigLoader:Singleton +{ + private bool _init = false; + + private Tables _tables = null!; + + public ConfigLoader() + { + this.Load(); + } + + public Tables Tables + { + get + { + if (!_init) + { + _init = true; + Load(); + } + return _tables; + } + } + + /// + /// 加载配置。 + /// + public void Load() + { + var tablesCtor = typeof(Tables).GetConstructors()[0]; + var loaderReturnType = tablesCtor.GetParameters()[0].ParameterType.GetGenericArguments()[1]; + + System.Delegate loader = new System.Func(LoadByteBuf); + _tables = (Tables)tablesCtor.Invoke(new object[] { loader }); + } + + + /// + /// 加载二进制配置。 + /// + /// FileName + /// ByteBuf + private ByteBuf LoadByteBuf(string file) + { + byte[]ret = File.ReadAllBytes($"../../../Config/GameConfig/{file}.bytes"); + return new ByteBuf(ret); + } +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/Core/BeanBase.cs b/Assets/GameScripts/DotNet/Logic/Config~/Core/BeanBase.cs new file mode 100644 index 00000000..74e956f7 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/Core/BeanBase.cs @@ -0,0 +1,9 @@ +using Bright.Serialization; + +namespace Bright.Config +{ + public abstract class BeanBase : ITypeId + { + public abstract int GetTypeId(); + } +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/Core/ByteBuf.cs b/Assets/GameScripts/DotNet/Logic/Config~/Core/ByteBuf.cs new file mode 100644 index 00000000..2a4a5236 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/Core/ByteBuf.cs @@ -0,0 +1,1545 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Bright.Serialization +{ + + public enum EDeserializeError + { + OK, + NOT_ENOUGH, + EXCEED_SIZE, + // UNMARSHAL_ERR, + } + + public class SerializationException : Exception + { + public SerializationException() { } + public SerializationException(string msg) : base(msg) { } + + public SerializationException(string message, Exception innerException) : base(message, innerException) + { + } + } + + public readonly struct SegmentSaveState + { + public SegmentSaveState(int readerIndex, int writerIndex) + { + ReaderIndex = readerIndex; + WriterIndex = writerIndex; + } + + public int ReaderIndex { get; } + + public int WriterIndex { get; } + } + + public sealed class ByteBuf : ICloneable, IEquatable + { + public ByteBuf() + { + Bytes = Array.Empty(); + ReaderIndex = WriterIndex = 0; + } + + public ByteBuf(int capacity) + { + Bytes = capacity > 0 ? new byte[capacity] : Array.Empty(); + ReaderIndex = 0; + WriterIndex = 0; + } + + public ByteBuf(byte[] bytes) + { + Bytes = bytes; + ReaderIndex = 0; + WriterIndex = Capacity; + } + + public ByteBuf(byte[] bytes, int readIndex, int writeIndex) + { + Bytes = bytes; + ReaderIndex = readIndex; + WriterIndex = writeIndex; + } + + public ByteBuf(int capacity, Action releaser) : this(capacity) + { + _releaser = releaser; + } + + public static ByteBuf Wrap(byte[] bytes) + { + return new ByteBuf(bytes, 0, bytes.Length); + } + + public void Replace(byte[] bytes) + { + Bytes = bytes; + ReaderIndex = 0; + WriterIndex = Capacity; + } + + public void Replace(byte[] bytes, int beginPos, int endPos) + { + Bytes = bytes; + ReaderIndex = beginPos; + WriterIndex = endPos; + } + + public int ReaderIndex { get; set; } + + public int WriterIndex { get; set; } + + private readonly Action _releaser; + + public int Capacity => Bytes.Length; + + public int Size { get { return WriterIndex - ReaderIndex; } } + + public bool Empty => WriterIndex <= ReaderIndex; + + public bool NotEmpty => WriterIndex > ReaderIndex; + + + public void AddWriteIndex(int add) + { + WriterIndex += add; + } + + public void AddReadIndex(int add) + { + ReaderIndex += add; + } + +#pragma warning disable CA1819 // 属性不应返回数组 + public byte[] Bytes { get; private set; } +#pragma warning restore CA1819 // 属性不应返回数组 + + public byte[] CopyData() + { + var n = Remaining; + if (n > 0) + { + var arr = new byte[n]; + Buffer.BlockCopy(Bytes, ReaderIndex, arr, 0, n); + return arr; + } + else + { + return Array.Empty(); + } + } + + public int Remaining { get { return WriterIndex - ReaderIndex; } } + + public void DiscardReadBytes() + { + WriterIndex -= ReaderIndex; + Array.Copy(Bytes, ReaderIndex, Bytes, 0, WriterIndex); + ReaderIndex = 0; + } + + public int NotCompactWritable { get { return Capacity - WriterIndex; } } + + public void WriteBytesWithoutSize(byte[] bs) + { + WriteBytesWithoutSize(bs, 0, bs.Length); + } + + public void WriteBytesWithoutSize(byte[] bs, int offset, int len) + { + EnsureWrite(len); + Buffer.BlockCopy(bs, offset, Bytes, WriterIndex, len); + WriterIndex += len; + } + + public void Clear() + { + ReaderIndex = WriterIndex = 0; + } + + private const int MIN_CAPACITY = 16; + + private static int PropSize(int initSize, int needSize) + { + for (int i = Math.Max(initSize, MIN_CAPACITY); ; i <<= 1) + { + if (i >= needSize) + { + return i; + } + } + } + + private void EnsureWrite0(int size) + { + var needSize = WriterIndex + size - ReaderIndex; + if (needSize < Capacity) + { + WriterIndex -= ReaderIndex; + Array.Copy(Bytes, ReaderIndex, Bytes, 0, WriterIndex); + ReaderIndex = 0; + } + else + { + int newCapacity = PropSize(Capacity, needSize); + var newBytes = new byte[newCapacity]; + WriterIndex -= ReaderIndex; + Buffer.BlockCopy(Bytes, ReaderIndex, newBytes, 0, WriterIndex); + ReaderIndex = 0; + Bytes = newBytes; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void EnsureWrite(int size) + { + if (WriterIndex + size > Capacity) + { + EnsureWrite0(size); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void EnsureRead(int size) + { + if (ReaderIndex + size > WriterIndex) + { + throw new SerializationException(); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private bool CanRead(int size) + { + return (ReaderIndex + size <= WriterIndex); + } + + public void Append(byte x) + { + EnsureWrite(1); + Bytes[WriterIndex++] = x; + } + + public void WriteBool(bool b) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)(b ? 1 : 0); + } + + public bool ReadBool() + { + EnsureRead(1); + return Bytes[ReaderIndex++] != 0; + } + + public void WriteByte(byte x) + { + EnsureWrite(1); + Bytes[WriterIndex++] = x; + } + + public byte ReadByte() + { + EnsureRead(1); + return Bytes[ReaderIndex++]; + } + + + public void WriteShort(short x) + { + if (x >= 0) + { + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)x; + return; + } + else if (x < 0x4000) + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = (byte)x; + Bytes[WriterIndex] = (byte)((x >> 8) | 0x80); + WriterIndex += 2; + return; + } + } + EnsureWrite(3); + Bytes[WriterIndex] = 0xff; + Bytes[WriterIndex + 2] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + WriterIndex += 3; + } + + public short ReadShort() + { + EnsureRead(1); + int h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + return (short)h; + } + else if (h < 0xc0) + { + EnsureRead(2); + int x = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + return (short)x; + } + else if ((h == 0xff)) + { + EnsureRead(3); + int x = (Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + return (short)x; + } + else + { + throw new SerializationException(); + } + } + + public short ReadFshort() + { + EnsureRead(2); + short x; +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { + x = *(short*)b; + } + } +#else + x = (short)((Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex]); + +#endif + ReaderIndex += 2; + return x; + } + + public void WriteFshort(short x) + { + EnsureWrite(2); +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { + *(short*)b = x; + } + } +#else + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); +#endif + WriterIndex += 2; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void WriteInt(int x) + { + WriteUint((uint)x); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int ReadInt() + { + return (int)ReadUint(); + } + + + public void WriteUint(uint x) + { + // 如果有修改,记得也把 EndWriteSegment改了 + // 0 111 1111 + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)x; + } + else if (x < 0x4000) // 10 11 1111, - + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = (byte)x; + Bytes[WriterIndex] = (byte)((x >> 8) | 0x80); + WriterIndex += 2; + } + else if (x < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(3); + Bytes[WriterIndex + 2] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex] = (byte)((x >> 16) | 0xc0); + WriterIndex += 3; + } + else if (x < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(4); + Bytes[WriterIndex + 3] = (byte)x; + Bytes[WriterIndex + 2] = (byte)(x >> 8); + Bytes[WriterIndex + 1] = (byte)(x >> 16); + Bytes[WriterIndex] = (byte)((x >> 24) | 0xe0); + WriterIndex += 4; + } + else + { + EnsureWrite(5); + Bytes[WriterIndex] = 0xf0; + Bytes[WriterIndex + 4] = (byte)x; + Bytes[WriterIndex + 3] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 1] = (byte)(x >> 24); + WriterIndex += 5; + } + } + + public uint ReadUint() + { + /// + /// 警告! 如有修改,记得调整 TryDeserializeInplaceOctets + EnsureRead(1); + uint h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + return h; + } + else if (h < 0xc0) + { + EnsureRead(2); + uint x = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + return x; + } + else if (h < 0xe0) + { + EnsureRead(3); + uint x = ((h & 0x1f) << 16) | ((uint)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + return x; + } + else if (h < 0xf0) + { + + EnsureRead(4); + uint x = ((h & 0x0f) << 24) | ((uint)Bytes[ReaderIndex + 1] << 16) | ((uint)Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 4; + return x; + } + else + { + EnsureRead(5); + uint x = ((uint)Bytes[ReaderIndex + 1] << 24) | ((uint)(Bytes[ReaderIndex + 2] << 16)) | ((uint)Bytes[ReaderIndex + 3] << 8) | Bytes[ReaderIndex + 4]; + ReaderIndex += 5; + return x; + } + } + + public unsafe void WriteUint_Unsafe(uint x) + { + // 0 111 1111 + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)(x << 1); + } + else if (x < 0x4000)// 10 11 1111, - + { + EnsureWrite(2); + + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 2 | 0b01); + } + + WriterIndex += 2; + } + else if (x < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(3); + + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 3 | 0b011); + } + WriterIndex += 3; + } + else if (x < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(4); + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 4 | 0b0111); + } + WriterIndex += 4; + } + else + { + EnsureWrite(5); + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 5 | 0b01111); + } + WriterIndex += 5; + } + } + + public unsafe uint ReadUint_Unsafe() + { + /// + /// 警告! 如有修改,记得调整 TryDeserializeInplaceOctets + EnsureRead(1); + uint h = Bytes[ReaderIndex]; + if ((h & 0b1) == 0b0) + { + ReaderIndex++; + return (h >> 1); + } + else if ((h & 0b11) == 0b01) + { + EnsureRead(2); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 2; + return (*(uint*)rb) >> 2; + } + } + else if ((h & 0b111) == 0b011) + { + EnsureRead(3); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 3; + return (*(uint*)rb) >> 3; + } + } + else if ((h & 0b1111) == 0b0111) + { + EnsureRead(4); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 4; + return (*(uint*)rb) >> 4; + } + } + else + { + EnsureRead(5); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 5; + return (*(uint*)rb) >> 5; + } + } + } + + public int ReadFint() + { + EnsureRead(4); + int x; +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { + x = *(int*)b; + } + } +#else + x = (Bytes[ReaderIndex + 3] << 24) | (Bytes[ReaderIndex + 2] << 16) | (Bytes[ReaderIndex + 1] << 8) | (Bytes[ReaderIndex]); + +#endif + ReaderIndex += 4; + return x; + } + + + public void WriteFint(int x) + { + EnsureWrite(4); +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { + *(int*)b = x; + } + } +#else + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); +#endif + WriterIndex += 4; + } + + public int ReadFint_Safe() + { + EnsureRead(4); + int x; + + x = (Bytes[ReaderIndex + 3] << 24) | (Bytes[ReaderIndex + 2] << 16) | (Bytes[ReaderIndex + 1] << 8) | (Bytes[ReaderIndex]); + + ReaderIndex += 4; + return x; + } + + + public void WriteFint_Safe(int x) + { + EnsureWrite(4); + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); + WriterIndex += 4; + } + + public void WriteLong(long x) + { + WriteUlong((ulong)x); + } + + public long ReadLong() + { + return (long)ReadUlong(); + } + + private void WriteUlong(ulong x) + { + // 0 111 1111 + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)x; + } + else if (x < 0x4000) // 10 11 1111, - + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = (byte)x; + Bytes[WriterIndex] = (byte)((x >> 8) | 0x80); + WriterIndex += 2; + } + else if (x < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(3); + Bytes[WriterIndex + 2] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex] = (byte)((x >> 16) | 0xc0); + WriterIndex += 3; + } + else if (x < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(4); + Bytes[WriterIndex + 3] = (byte)x; + Bytes[WriterIndex + 2] = (byte)(x >> 8); + Bytes[WriterIndex + 1] = (byte)(x >> 16); + Bytes[WriterIndex] = (byte)((x >> 24) | 0xe0); + WriterIndex += 4; + } + else if (x < 0x800000000L) // 1111 0xxx,-,-,-,- + { + EnsureWrite(5); + Bytes[WriterIndex + 4] = (byte)x; + Bytes[WriterIndex + 3] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 1] = (byte)(x >> 24); + Bytes[WriterIndex] = (byte)((x >> 32) | 0xf0); + WriterIndex += 5; + } + else if (x < 0x40000000000L) // 1111 10xx, + { + EnsureWrite(6); + Bytes[WriterIndex + 5] = (byte)x; + Bytes[WriterIndex + 4] = (byte)(x >> 8); + Bytes[WriterIndex + 3] = (byte)(x >> 16); + Bytes[WriterIndex + 2] = (byte)(x >> 24); + Bytes[WriterIndex + 1] = (byte)(x >> 32); + Bytes[WriterIndex] = (byte)((x >> 40) | 0xf8); + WriterIndex += 6; + } + else if (x < 0x200000000000L) // 1111 110x, + { + EnsureWrite(7); + Bytes[WriterIndex + 6] = (byte)x; + Bytes[WriterIndex + 5] = (byte)(x >> 8); + Bytes[WriterIndex + 4] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); + Bytes[WriterIndex + 2] = (byte)(x >> 32); + Bytes[WriterIndex + 1] = (byte)(x >> 40); + Bytes[WriterIndex] = (byte)((x >> 48) | 0xfc); + WriterIndex += 7; + } + else if (x < 0x100000000000000L) // 1111 1110 + { + EnsureWrite(8); + Bytes[WriterIndex + 7] = (byte)x; + Bytes[WriterIndex + 6] = (byte)(x >> 8); + Bytes[WriterIndex + 5] = (byte)(x >> 16); + Bytes[WriterIndex + 4] = (byte)(x >> 24); + Bytes[WriterIndex + 3] = (byte)(x >> 32); + Bytes[WriterIndex + 2] = (byte)(x >> 40); + Bytes[WriterIndex + 1] = (byte)(x >> 48); + Bytes[WriterIndex] = 0xfe; + WriterIndex += 8; + } + else // 1111 1111 + { + EnsureWrite(9); + Bytes[WriterIndex] = 0xff; + Bytes[WriterIndex + 8] = (byte)x; + Bytes[WriterIndex + 7] = (byte)(x >> 8); + Bytes[WriterIndex + 6] = (byte)(x >> 16); + Bytes[WriterIndex + 5] = (byte)(x >> 24); + Bytes[WriterIndex + 4] = (byte)(x >> 32); + Bytes[WriterIndex + 3] = (byte)(x >> 40); + Bytes[WriterIndex + 2] = (byte)(x >> 48); + Bytes[WriterIndex + 1] = (byte)(x >> 56); + WriterIndex += 9; + } + } + + public ulong ReadUlong() + { + EnsureRead(1); + uint h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + return h; + } + else if (h < 0xc0) + { + EnsureRead(2); + uint x = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + return x; + } + else if (h < 0xe0) + { + EnsureRead(3); + uint x = ((h & 0x1f) << 16) | ((uint)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + return x; + } + else if (h < 0xf0) + { + EnsureRead(4); + uint x = ((h & 0x0f) << 24) | ((uint)Bytes[ReaderIndex + 1] << 16) | ((uint)Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 4; + return x; + } + else if (h < 0xf8) + { + EnsureRead(5); + uint xl = ((uint)Bytes[ReaderIndex + 1] << 24) | ((uint)(Bytes[ReaderIndex + 2] << 16)) | ((uint)Bytes[ReaderIndex + 3] << 8) | (Bytes[ReaderIndex + 4]); + uint xh = h & 0x07; + ReaderIndex += 5; + return ((ulong)xh << 32) | xl; + } + else if (h < 0xfc) + { + EnsureRead(6); + uint xl = ((uint)Bytes[ReaderIndex + 2] << 24) | ((uint)(Bytes[ReaderIndex + 3] << 16)) | ((uint)Bytes[ReaderIndex + 4] << 8) | (Bytes[ReaderIndex + 5]); + uint xh = ((h & 0x03) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 6; + return ((ulong)xh << 32) | xl; + } + else if (h < 0xfe) + { + EnsureRead(7); + uint xl = ((uint)Bytes[ReaderIndex + 3] << 24) | ((uint)(Bytes[ReaderIndex + 4] << 16)) | ((uint)Bytes[ReaderIndex + 5] << 8) | (Bytes[ReaderIndex + 6]); + uint xh = ((h & 0x01) << 16) | ((uint)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 7; + return ((ulong)xh << 32) | xl; + } + else if (h < 0xff) + { + EnsureRead(8); + uint xl = ((uint)Bytes[ReaderIndex + 4] << 24) | ((uint)(Bytes[ReaderIndex + 5] << 16)) | ((uint)Bytes[ReaderIndex + 6] << 8) | (Bytes[ReaderIndex + 7]); + uint xh = /*((h & 0x01) << 24) |*/ ((uint)Bytes[ReaderIndex + 1] << 16) | ((uint)Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 8; + return ((ulong)xh << 32) | xl; + } + else + { + EnsureRead(9); + uint xl = ((uint)Bytes[ReaderIndex + 5] << 24) | ((uint)(Bytes[ReaderIndex + 6] << 16)) | ((uint)Bytes[ReaderIndex + 7] << 8) | (Bytes[ReaderIndex + 8]); + uint xh = ((uint)Bytes[ReaderIndex + 1] << 24) | ((uint)Bytes[ReaderIndex + 2] << 16) | ((uint)Bytes[ReaderIndex + 3] << 8) | Bytes[ReaderIndex + 4]; + ReaderIndex += 9; + return ((ulong)xh << 32) | xl; + } + } + + + public void WriteFlong(long x) + { + EnsureWrite(8); +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { + *(long*)b = x; + } + } +#else + + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); + Bytes[WriterIndex + 4] = (byte)(x >> 32); + Bytes[WriterIndex + 5] = (byte)(x >> 40); + Bytes[WriterIndex + 6] = (byte)(x >> 48); + Bytes[WriterIndex + 7] = (byte)(x >> 56); +#endif + WriterIndex += 8; + } + + public long ReadFlong() + { + EnsureRead(8); + long x; +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { + x = *(long*)b; + } + } +#else + int xl = (Bytes[ReaderIndex + 3] << 24) | ((Bytes[ReaderIndex + 2] << 16)) | (Bytes[ReaderIndex + 1] << 8) | (Bytes[ReaderIndex]); + int xh = (Bytes[ReaderIndex + 7] << 24) | (Bytes[ReaderIndex + 6] << 16) | (Bytes[ReaderIndex + 5] << 8) | Bytes[ReaderIndex + 4]; + x = ((long)xh << 32) | (long)xl; +#endif + ReaderIndex += 8; + return x; + } + + private static unsafe void Copy8(byte* dst, byte* src) + { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + dst[4] = src[4]; + dst[5] = src[5]; + dst[6] = src[6]; + dst[7] = src[7]; + } + + private static unsafe void Copy4(byte* dst, byte* src) + { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + } + + + //const bool isLittleEndian = true; + public void WriteFloat(float x) + { + EnsureWrite(4); + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 4 == 0) + { + *(float*)b = x; + } + else + { + Copy4(b, (byte*)&x); + } +#else + *(float*)b = x; +#endif + } + } + + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, endPos, 4); + //} + WriterIndex += 4; + } + + public float ReadFloat() + { + EnsureRead(4); + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, beginPos, 4); + //} + float x; + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 4 == 0) + { + x = *(float*)b; + } + else + { + *((int*)&x) = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); + } +#else + x = *(float*)b; +#endif + } + } + + ReaderIndex += 4; + return x; + } + + public void WriteDouble(double x) + { + EnsureWrite(8); + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 8 == 0) + { + *(double*)b = x; + } + else + { + Copy8(b, (byte*)&x); + } +#else + *(double*)b = x; +#endif + } + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, endPos, 8); + //} + } + + WriterIndex += 8; + } + + public double ReadDouble() + { + EnsureRead(8); + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, beginPos, 8); + //} + double x; + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 8 == 0) + { + x = *(double*)b; + } + else + { + int low = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); + int high = (b[4]) | (b[5] << 8) | (b[6] << 16) | (b[7] << 24); + *((long*)&x) = ((long)high << 32) | (uint)low; + } +#else + x = *(double*)b; +#endif + } + } + + ReaderIndex += 8; + return x; + } + + public void WriteSize(int n) + { + WriteUint((uint)n); + } + + public int ReadSize() + { + return (int)ReadUint(); + } + + // marshal int + // n -> (n << 1) ^ (n >> 31) + // Read + // (x >>> 1) ^ ((x << 31) >> 31) + // (x >>> 1) ^ -(n&1) + public void WriteSint(int x) + { + WriteUint(((uint)x << 1) ^ ((uint)x >> 31)); + } + + public int ReadSint() + { + uint x = ReadUint(); + return (int)((x >> 1) ^ ((x & 1) << 31)); + } + + + // marshal long + // n -> (n << 1) ^ (n >> 63) + // Read + // (x >>> 1) ^((x << 63) >> 63) + // (x >>> 1) ^ -(n&1L) + public void WriteSlong(long x) + { + WriteUlong(((ulong)x << 1) ^ ((ulong)x >> 63)); + } + + public long ReadSlong() + { + long x = ReadLong(); + return ((long)((ulong)x >> 1) ^ ((x & 1) << 63)); + } + + public void WriteString(string x) + { + var n = x != null ? Encoding.UTF8.GetByteCount(x) : 0; + WriteSize(n); + if (n > 0) + { + EnsureWrite(n); + Encoding.UTF8.GetBytes(x, 0, x.Length, Bytes, WriterIndex); + WriterIndex += n; + } + } + + // byte[], [start, end) + public static Func StringCacheFinder { get; set; } + + public string ReadString() + { + var n = ReadSize(); + if (n > 0) + { + EnsureRead(n); + string s; + + if (StringCacheFinder == null) + { + s = Encoding.UTF8.GetString(Bytes, ReaderIndex, n); + } + else + { + // 只缓存比较小的字符串 + s = StringCacheFinder(Bytes, ReaderIndex, n); + } + ReaderIndex += n; + return s; + } + else + { + return ""; + } + } + + public void WriteBytes(byte[] x) + { + var n = x != null ? x.Length : 0; + WriteSize(n); + if (n > 0) + { + EnsureWrite(n); + x.CopyTo(Bytes, WriterIndex); + WriterIndex += n; + } + } + + public byte[] ReadBytes() + { + var n = ReadSize(); + if (n > 0) + { + EnsureRead(n); + var x = new byte[n]; + Buffer.BlockCopy(Bytes, ReaderIndex, x, 0, n); + ReaderIndex += n; + return x; + } + else + { + return Array.Empty(); + } + } + + // 以下是一些特殊类型 + + public void WriteComplex(Complex x) + { + WriteDouble(x.Real); + WriteDouble(x.Imaginary); + } + + public Complex ReadComplex() + { + var x = ReadDouble(); + var y = ReadDouble(); + return new Complex(x, y); + } + + public void WriteVector2(Vector2 x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + } + + public Vector2 ReadVector2() + { + float x = ReadFloat(); + float y = ReadFloat(); + return new Vector2(x, y); + } + + public void WriteVector3(Vector3 x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + WriteFloat(x.Z); + } + + public Vector3 ReadVector3() + { + float x = ReadFloat(); + float y = ReadFloat(); + float z = ReadFloat(); + return new Vector3(x, y, z); + } + + public void WriteVector4(Vector4 x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + WriteFloat(x.Z); + WriteFloat(x.W); + } + + public Vector4 ReadVector4() + { + float x = ReadFloat(); + float y = ReadFloat(); + float z = ReadFloat(); + float w = ReadFloat(); + return new Vector4(x, y, z, w); + } + + + public void WriteQuaternion(Quaternion x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + WriteFloat(x.Z); + WriteFloat(x.W); + } + + public Quaternion ReadQuaternion() + { + float x = ReadFloat(); + float y = ReadFloat(); + float z = ReadFloat(); + float w = ReadFloat(); + return new Quaternion(x, y, z, w); + } + + + public void WriteMatrix4x4(Matrix4x4 x) + { + WriteFloat(x.M11); + WriteFloat(x.M12); + WriteFloat(x.M13); + WriteFloat(x.M14); + WriteFloat(x.M21); + WriteFloat(x.M22); + WriteFloat(x.M23); + WriteFloat(x.M24); + WriteFloat(x.M31); + WriteFloat(x.M32); + WriteFloat(x.M33); + WriteFloat(x.M34); + WriteFloat(x.M41); + WriteFloat(x.M42); + WriteFloat(x.M43); + WriteFloat(x.M44); + } + + public Matrix4x4 ReadMatrix4x4() + { + float m11 = ReadFloat(); + float m12 = ReadFloat(); + float m13 = ReadFloat(); + float m14 = ReadFloat(); + float m21 = ReadFloat(); + float m22 = ReadFloat(); + float m23 = ReadFloat(); + float m24 = ReadFloat(); + float m31 = ReadFloat(); + float m32 = ReadFloat(); + float m33 = ReadFloat(); + float m34 = ReadFloat(); + float m41 = ReadFloat(); + float m42 = ReadFloat(); + float m43 = ReadFloat(); + float m44 = ReadFloat(); + return new Matrix4x4(m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44); + } + + internal void SkipBytes() + { + int n = ReadSize(); + EnsureRead(n); + ReaderIndex += n; + } + + + public void WriteByteBufWithSize(ByteBuf o) + { + int n = o.Size; + if (n > 0) + { + WriteSize(n); + WriteBytesWithoutSize(o.Bytes, o.ReaderIndex, n); + } + else + { + WriteByte(0); + } + } + + public void WriteByteBufWithoutSize(ByteBuf o) + { + int n = o.Size; + if (n > 0) + { + WriteBytesWithoutSize(o.Bytes, o.ReaderIndex, n); + } + } + + public bool TryReadByte(out byte x) + { + if (CanRead(1)) + { + x = Bytes[ReaderIndex++]; + return true; + } + else + { + x = 0; + return false; + } + } + + public EDeserializeError TryDeserializeInplaceByteBuf(int maxSize, ByteBuf inplaceTempBody) + { + //if (!CanRead(1)) { return EDeserializeError.NOT_ENOUGH; } + int oldReadIndex = ReaderIndex; + bool commit = false; + try + { + int n; + int h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + n = h; + } + else if (h < 0xc0) + { + if (!CanRead(2)) { return EDeserializeError.NOT_ENOUGH; } + n = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + } + else if (h < 0xe0) + { + if (!CanRead(3)) { return EDeserializeError.NOT_ENOUGH; } + n = ((h & 0x1f) << 16) | (Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + } + else if (h < 0xf0) + { + if (!CanRead(4)) { return EDeserializeError.NOT_ENOUGH; } + n = ((h & 0x0f) << 24) | (Bytes[ReaderIndex + 1] << 16) | (Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 4; + } + else + { + return EDeserializeError.EXCEED_SIZE; + } + + if (n > maxSize) + { + return EDeserializeError.EXCEED_SIZE; + } + if (Remaining < n) + { + return EDeserializeError.NOT_ENOUGH; + } + + int inplaceReadIndex = ReaderIndex; + ReaderIndex += n; + + inplaceTempBody.Replace(Bytes, inplaceReadIndex, ReaderIndex); + commit = true; + } + finally + { + if (!commit) + { + ReaderIndex = oldReadIndex; + } + } + + return EDeserializeError.OK; + } + + public void WriteRawTag(byte b1) + { + EnsureWrite(1); + Bytes[WriterIndex++] = b1; + } + + public void WriteRawTag(byte b1, byte b2) + { + EnsureWrite(2); + Bytes[WriterIndex] = b1; + Bytes[WriterIndex + 1] = b2; + WriterIndex += 2; + } + + public void WriteRawTag(byte b1, byte b2, byte b3) + { + EnsureWrite(3); + Bytes[WriterIndex] = b1; + Bytes[WriterIndex + 1] = b2; + Bytes[WriterIndex + 2] = b3; + WriterIndex += 3; + } + + #region segment + + + public void BeginWriteSegment(out int oldSize) + { + oldSize = Size; + EnsureWrite(1); + WriterIndex += 1; + } + + public void EndWriteSegment(int oldSize) + { + int startPos = ReaderIndex + oldSize; + int segmentSize = WriterIndex - startPos - 1; + + // 0 111 1111 + if (segmentSize < 0x80) + { + Bytes[startPos] = (byte)segmentSize; + } + else if (segmentSize < 0x4000) // 10 11 1111, - + { + EnsureWrite(1); + Bytes[WriterIndex] = Bytes[startPos + 1]; + Bytes[startPos + 1] = (byte)segmentSize; + + Bytes[startPos] = (byte)((segmentSize >> 8) | 0x80); + WriterIndex += 1; + } + else if (segmentSize < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = Bytes[startPos + 2]; + Bytes[startPos + 2] = (byte)segmentSize; + + Bytes[WriterIndex] = Bytes[startPos + 1]; + Bytes[startPos + 1] = (byte)(segmentSize >> 8); + + Bytes[startPos] = (byte)((segmentSize >> 16) | 0xc0); + WriterIndex += 2; + } + else if (segmentSize < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(3); + Bytes[WriterIndex + 2] = Bytes[startPos + 3]; + Bytes[startPos + 3] = (byte)segmentSize; + + Bytes[WriterIndex + 1] = Bytes[startPos + 2]; + Bytes[startPos + 2] = (byte)(segmentSize >> 8); + + Bytes[WriterIndex] = Bytes[startPos + 1]; + Bytes[startPos + 1] = (byte)(segmentSize >> 16); + + Bytes[startPos] = (byte)((segmentSize >> 24) | 0xe0); + WriterIndex += 3; + } + else + { + throw new SerializationException("exceed max segment size"); + } + } + + public void ReadSegment(out int startIndex, out int segmentSize) + { + EnsureRead(1); + int h = Bytes[ReaderIndex++]; + + startIndex = ReaderIndex; + + if (h < 0x80) + { + segmentSize = h; + ReaderIndex += segmentSize; + } + else if (h < 0xc0) + { + EnsureRead(1); + segmentSize = ((h & 0x3f) << 8) | Bytes[ReaderIndex]; + int endPos = ReaderIndex + segmentSize; + Bytes[ReaderIndex] = Bytes[endPos]; + ReaderIndex += segmentSize + 1; + } + else if (h < 0xe0) + { + EnsureRead(2); + segmentSize = ((h & 0x1f) << 16) | ((int)Bytes[ReaderIndex] << 8) | Bytes[ReaderIndex + 1]; + int endPos = ReaderIndex + segmentSize; + Bytes[ReaderIndex] = Bytes[endPos]; + Bytes[ReaderIndex + 1] = Bytes[endPos + 1]; + ReaderIndex += segmentSize + 2; + } + else if (h < 0xf0) + { + EnsureRead(3); + segmentSize = ((h & 0x0f) << 24) | ((int)Bytes[ReaderIndex] << 16) | ((int)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + int endPos = ReaderIndex + segmentSize; + Bytes[ReaderIndex] = Bytes[endPos]; + Bytes[ReaderIndex + 1] = Bytes[endPos + 1]; + Bytes[ReaderIndex + 2] = Bytes[endPos + 2]; + ReaderIndex += segmentSize + 3; + } + else + { + throw new SerializationException("exceed max size"); + } + if (ReaderIndex > WriterIndex) + { + throw new SerializationException("segment data not enough"); + } + } + + public void ReadSegment(ByteBuf buf) + { + ReadSegment(out int startPos, out var size); + buf.Bytes = Bytes; + buf.ReaderIndex = startPos; + buf.WriterIndex = startPos + size; + } + + public void EnterSegment(out SegmentSaveState saveState) + { + ReadSegment(out int startPos, out int size); + + saveState = new SegmentSaveState(ReaderIndex, WriterIndex); + ReaderIndex = startPos; + WriterIndex = startPos + size; + } + + public void LeaveSegment(SegmentSaveState saveState) + { + ReaderIndex = saveState.ReaderIndex; + WriterIndex = saveState.WriterIndex; + } + + #endregion + + public override string ToString() + { + string[] datas = new string[WriterIndex - ReaderIndex]; + for (var i = ReaderIndex; i < WriterIndex; i++) + { + datas[i - ReaderIndex] = Bytes[i].ToString("X2"); + } + return string.Join(".", datas); + } + + public override bool Equals(object obj) + { + return (obj is ByteBuf other) && Equals(other); + } + + public bool Equals(ByteBuf other) + { + if (other == null) + { + return false; + } + if (Size != other.Size) + { + return false; + } + for (int i = 0, n = Size; i < n; i++) + { + if (Bytes[ReaderIndex + i] != other.Bytes[other.ReaderIndex + i]) + { + return false; + } + } + return true; + } + + public object Clone() + { + return new ByteBuf(CopyData()); + } + + + public static ByteBuf FromString(string value) + { + var ss = value.Split(','); + byte[] data = new byte[ss.Length]; + for (int i = 0; i < data.Length; i++) + { + data[i] = byte.Parse(ss[i]); + } + return new ByteBuf(data); + } + + public override int GetHashCode() + { + int hash = 17; + for (int i = ReaderIndex; i < WriterIndex; i++) + { + hash = hash * 23 + Bytes[i]; + } + return hash; + } + + public void Release() + { + _releaser?.Invoke(this); + } + } +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/Core/ITypeId.cs b/Assets/GameScripts/DotNet/Logic/Config~/Core/ITypeId.cs new file mode 100644 index 00000000..2b8d71a6 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/Core/ITypeId.cs @@ -0,0 +1,7 @@ +namespace Bright.Serialization +{ + public interface ITypeId + { + int GetTypeId(); + } +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/Core/StringUtil.cs b/Assets/GameScripts/DotNet/Logic/Config~/Core/StringUtil.cs new file mode 100644 index 00000000..c91f2a11 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/Core/StringUtil.cs @@ -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[] arr) + { + return "[" + string.Join(",", arr) + "]"; + } + + + public static string CollectionToString(IEnumerable arr) + { + return "[" + string.Join(",", arr) + "]"; + } + + + public static string CollectionToString(IDictionary 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(); + } + } +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrAddType.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrAddType.cs new file mode 100644 index 00000000..d3794e78 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrAddType.cs @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum ActorAttrAddType + { + /// + /// 无效数据 + /// + NONE = 0, + /// + /// 加法计算 + /// + ABSOLUTE_VAL = 1, + /// + /// 多个项结果累加,然后对加法做乘法 + /// + SUM_PERCENT_VAL = 2, + /// + /// 每一项都是对最终结果做乘法 + /// + MUL_PERCENT_VAL = 3, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrDataType.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrDataType.cs new file mode 100644 index 00000000..035a3060 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ActorAttrDataType.cs @@ -0,0 +1,88 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum ActorAttrDataType + { + /// + /// 无效数据 + /// + None = 0, + /// + /// 最大血量 + /// + MaxHp = 1, + /// + /// 攻击力 + /// + Attack = 2, + /// + /// 物理伤害 + /// + PhyDamage = 3, + /// + /// 物理防御 + /// + PhyDef = 4, + /// + /// 法术伤害 + /// + MagicDamage = 5, + /// + /// 法术防御 + /// + MagicDef = 6, + /// + /// 移动速度 + /// + MoveSpeed = 7, + /// + /// 攻击速度 + /// + AttackSpeed = 8, + /// + /// 命中率 + /// + Hit = 9, + /// + /// 闪避率 + /// + Dodge = 10, + /// + /// 暴击率 + /// + CriticalAtkRatio = 11, + /// + /// San值(疯狂值) + /// + SanValue = 12, + /// + /// 最大MP + /// + MaxMp = 13, + /// + /// 物理伤害倍率 + /// + PhyDamageRatio = 14, + /// + /// 魔法伤害倍率 + /// + MagicDamageRatio = 15, + /// + /// 暴击倍率 + /// + CriticalRatio = 16, + /// + /// 暴击减免 + /// + CriticalReduce = 17, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffAttrConfig.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffAttrConfig.cs new file mode 100644 index 00000000..56ae6d6d --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffAttrConfig.cs @@ -0,0 +1,100 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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(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); + } + + /// + /// BuffID + /// + public int BuffID { get; private set; } + /// + /// 名字 + /// + public string Name { get; private set; } + /// + /// 叠加次数 + /// + public int StackNum { get; private set; } + /// + /// 持续时间 + /// + public float DurTime { get; private set; } + /// + /// 数值效果类型 + /// + public Battle.BuffResultType ResultType { get; private set; } + /// + /// 死亡消失 + /// + 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 AttrData { get; private set; } + + public const int __ID__ = 1652935996; + public override int GetTypeId() => __ID__; + + public void Resolve(Dictionary _tables) + { + DotDamageData?.Resolve(_tables); + DotTickConfig?.Resolve(_tables); + foreach(var _e in AttrData) { _e?.Resolve(_tables); } + PostResolve(); + } + + public void TranslateText(System.Func 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(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffConfig.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffConfig.cs new file mode 100644 index 00000000..8cc5dc93 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffConfig.cs @@ -0,0 +1,96 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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); + } + + /// + /// BuffID + /// + public int BuffID { get; private set; } + /// + /// 名字 + /// + public string Name { get; private set; } + /// + /// 表现ID + /// + public int PrefId { get; private set; } + /// + /// 描述 + /// + public string Desc { get; private set; } + /// + /// 图标 + /// + public string Icon { get; private set; } + /// + /// 持续类型 + /// + public Battle.BuffTimeType TimeType { get; private set; } + /// + /// 叠加类型 + /// + 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 _tables) + { + State?.Resolve(_tables); + PostResolve(); + } + + public void TranslateText(System.Func 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(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffDotTickConfig.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffDotTickConfig.cs new file mode 100644 index 00000000..6d9d66bc --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffDotTickConfig.cs @@ -0,0 +1,55 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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 _tables) + { + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + } + + public override string ToString() + { + return "{ " + + "TickTime:" + TickTime + "," + + "TickWhenAdd:" + TickWhenAdd + "," + + "}"; + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffReplaceType.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffReplaceType.cs new file mode 100644 index 00000000..558554ce --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffReplaceType.cs @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum BuffReplaceType + { + /// + /// 更新时间范围 + /// + BUFF_REPLACE_INSTEAD = 0, + /// + /// 不允许叠加 + /// + BUFF_REPLACE_FORBIT = 1, + /// + /// 累加时间范围 + /// + BUFF_REPLACE_ADD_TIME = 2, + /// + /// 叠加数值 + /// + BUFF_REPLACE_ADD_ATTR = 3, + /// + /// 叠加种类 + /// + BUFF_REPLACE_TYPE_COUNT = 4, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffResultType.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffResultType.cs new file mode 100644 index 00000000..9545d379 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffResultType.cs @@ -0,0 +1,100 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum BuffResultType + { + /// + /// 无 + /// + BUFF_RESULT_NONE = 0, + /// + /// 物理攻击提升 + /// + BUFF_RESULT_PHY_ATK_UP = 1, + /// + /// 物理攻击降低 + /// + BUFF_RESULT_PHY_ATK_DOWN = 2, + /// + /// 物理防御提升 + /// + BUFF_RESULT_PHY_DEF_UP = 3, + /// + /// 物理防御降低 + /// + BUFF_RESULT_PHY_DEF_DOWN = 4, + /// + /// 物理命中提升 + /// + BUFF_RESULT_PHY_HIT_UP = 5, + /// + /// 物理命中降低 + /// + BUFF_RESULT_PHY_HIT_DOWN = 6, + /// + /// 物理持续掉血 + /// + BUFF_RESULT_PHY_LOSE_HP = 7, + /// + /// 法术攻击提升 + /// + BUFF_RESULT_MAG_ATK_UP = 8, + /// + /// 法术攻击降低 + /// + BUFF_RESULT_MAG_ATK_DOWN = 9, + /// + /// 法术防御提升 + /// + BUFF_RESULT_MAG_DEF_UP = 10, + /// + /// 法术防御降低 + /// + BUFF_RESULT_MAG_DEF_DOWN = 11, + /// + /// 法术命中提升 + /// + BUFF_RESULT_MAG_HIT_UP = 12, + /// + /// 法术命中降低 + /// + BUFF_RESULT_MAG_HIT_DOWN = 13, + /// + /// 法术持续掉血 + /// + BUFF_RESULT_MAG_LOSE_HP = 14, + /// + /// 暴击率提升 + /// + BUFF_RESULT_CIRT_UP = 15, + /// + /// 暴击率降低 + /// + BUFF_RESULT_CIRT_DOWN = 16, + /// + /// 暴击倍率提升 + /// + BUFF_RESULT_CIRT_VALUE_UP = 17, + /// + /// 暴击倍率降低 + /// + BUFF_RESULT_CIRT_VALUE_DOWN = 18, + /// + /// 移速提升 + /// + BUFF_RESULT_MOVE_SPEED_UP = 19, + /// + /// 移速降低 + /// + BUFF_RESULT_MOVE_SPEED_DOWN = 20, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffStateID.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffStateID.cs new file mode 100644 index 00000000..bedf850f --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffStateID.cs @@ -0,0 +1,60 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum BuffStateID + { + /// + /// 无状态 + /// + BUFF_STATE_NONE = 0, + /// + /// 眩晕状态 + /// + BUFF_STATE_STUN = 1, + /// + /// 无敌状态 + /// + BUFF_STATE_UNDEAD = 2, + /// + /// 隐身状态 + /// + BUFF_STATE_INVISIBLE = 3, + /// + /// 体形变大 + /// + BUFF_STATE_BIGGER = 4, + /// + /// 定身,不能移动 + /// + BUFF_STATE_NO_MOVE = 5, + /// + /// 沉默,不能放技能 + /// + BUFF_STATE_NO_SKILL = 6, + /// + /// 昏睡 + /// + BUFF_STATE_SLEEP = 7, + /// + /// 强制开启阻挡 + /// + BUFF_STATE_FORCE_COLLIDER = 8, + /// + /// 无视阻挡 + /// + BUFF_STATE_IGNORE_COLLIDER = 9, + /// + /// 最大状态 + /// + BUFF_STATE_MAX = 10, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTimeType.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTimeType.cs new file mode 100644 index 00000000..5b4db5d3 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTimeType.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum BuffTimeType + { + /// + /// 指定持续时间 + /// + BUFF_TIME_DURING = 0, + /// + /// 无尽时间 + /// + BUFF_TIME_INFINIT = 1, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTriggleState.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTriggleState.cs new file mode 100644 index 00000000..0cb38e5e --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/BuffTriggleState.cs @@ -0,0 +1,55 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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 _tables) + { + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + } + + public override string ToString() + { + return "{ " + + "StateID:" + StateID + "," + + "StateParam:" + StateParam + "," + + "}"; + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ResAttrImpactData.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ResAttrImpactData.cs new file mode 100644 index 00000000..5f92a8a9 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/ResAttrImpactData.cs @@ -0,0 +1,58 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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 _tables) + { + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + } + + public override string ToString() + { + return "{ " + + "DataType:" + DataType + "," + + "AddType:" + AddType + "," + + "Value:" + Value + "," + + "}"; + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageData.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageData.cs new file mode 100644 index 00000000..bf3d02f6 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageData.cs @@ -0,0 +1,67 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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 _tables) + { + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + } + + public override string ToString() + { + return "{ " + + "MagicType:" + MagicType + "," + + "AttrType:" + AttrType + "," + + "Param1:" + Param1 + "," + + "Param2:" + Param2 + "," + + "Param3:" + Param3 + "," + + "MaxLimit:" + MaxLimit + "," + + "}"; + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageType.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageType.cs new file mode 100644 index 00000000..13d58d51 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillAttrDamageType.cs @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum SkillAttrDamageType + { + /// + /// 无数值 + /// + ATTR_TYPE_NONE = 0, + /// + /// 按释放者的伤害类型*X%+固定值计算,目标有防御计算 + /// + ATTR_TYPE_DMG_WEAPON = 1, + /// + /// 按释放者的伤害类型*X%+固定值计算(无视目标的防御) + /// + ATTR_TYPE_DMG_NO_DEFEND = 2, + /// + /// 按受击者的气血上限*X%+固定值计算(无视目标的防御) + /// + ATTR_TYPE_DMG_TARGET_HP_NO_DEFEND = 3, + /// + /// 按释放者的攻击类型*X%+固定值计算,恢复当前生命 + /// + ATTR_TYPE_HP_AS_ATK = 4, + /// + /// 按受击者的HP上限*X%+固定值计算,恢复当前生命 + /// + ATTR_TYPE_HP_RATIO = 5, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillBaseConfig.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillBaseConfig.cs new file mode 100644 index 00000000..c04e6a12 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillBaseConfig.cs @@ -0,0 +1,114 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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(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(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); + } + + /// + /// 技能ID + /// + public int Id { get; private set; } + /// + /// 名字 + /// + public string Name { get; private set; } + /// + /// 表现ID + /// + public int SkillDispID { get; private set; } + /// + /// 技能类型SkillType + /// + public int SkillType { get; private set; } + /// + /// 描述 + /// + public string Desc { get; private set; } + /// + /// 消耗MP + /// + public int CostMP { get; private set; } + /// + /// 所属公CD组ID + /// + public int GCDID { get; private set; } + /// + /// 技能CD + /// + public float SkillCD { get; private set; } + /// + /// 是否重复触发 + /// + public bool IsRepeatTrigger { get; private set; } + /// + /// BuffIDList + /// + public System.Collections.Generic.List BuffID { get; private set; } + public System.Collections.Generic.List AttrDamageData { get; private set; } + + public const int __ID__ = 2067672430; + public override int GetTypeId() => __ID__; + + public void Resolve(Dictionary _tables) + { + foreach(var _e in AttrDamageData) { _e?.Resolve(_tables); } + PostResolve(); + } + + public void TranslateText(System.Func 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(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillMagicType.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillMagicType.cs new file mode 100644 index 00000000..54088689 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/SkillMagicType.cs @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.Battle +{ + public enum SkillMagicType + { + /// + /// 无类型 + /// + SKILL_TYPE_NONE = 0, + /// + /// 物理伤害属性 + /// + SKILL_TYPE_DMG_PHY = 1, + /// + /// 魔法伤害属性 + /// + SKILL_TYPE_DMG_MAGIC = 2, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuff.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuff.cs new file mode 100644 index 00000000..45b50559 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuff.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using Bright.Serialization; +using System.Collections.Generic; + + +namespace GameConfig.Battle +{ + +public partial class TbBuff +{ + private readonly Dictionary _dataMap; + private readonly List _dataList; + + public TbBuff(ByteBuf _buf) + { + _dataMap = new Dictionary(); + _dataList = new List(); + + 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 DataMap => _dataMap; + public List 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 _tables) + { + foreach(var v in _dataList) + { + v.Resolve(_tables); + } + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + foreach(var v in _dataList) + { + v.TranslateText(translator); + } + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuffAttr.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuffAttr.cs new file mode 100644 index 00000000..5841b95e --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbBuffAttr.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using Bright.Serialization; +using System.Collections.Generic; + + +namespace GameConfig.Battle +{ + +public partial class TbBuffAttr +{ + private readonly Dictionary _dataMap; + private readonly List _dataList; + + public TbBuffAttr(ByteBuf _buf) + { + _dataMap = new Dictionary(); + _dataList = new List(); + + 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 DataMap => _dataMap; + public List 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 _tables) + { + foreach(var v in _dataList) + { + v.Resolve(_tables); + } + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + foreach(var v in _dataList) + { + v.TranslateText(translator); + } + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbSkill.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbSkill.cs new file mode 100644 index 00000000..9b59613f --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Battle/TbSkill.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using Bright.Serialization; +using System.Collections.Generic; + + +namespace GameConfig.Battle +{ + +public partial class TbSkill +{ + private readonly Dictionary _dataMap; + private readonly List _dataList; + + public TbSkill(ByteBuf _buf) + { + _dataMap = new Dictionary(); + _dataList = new List(); + + 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 DataMap => _dataMap; + public List 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 _tables) + { + foreach(var v in _dataList) + { + v.Resolve(_tables); + } + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + foreach(var v in _dataList) + { + v.TranslateText(translator); + } + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Tables.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Tables.cs new file mode 100644 index 00000000..fc20ad45 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/Tables.cs @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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 loader) + { + var tables = new System.Collections.Generic.Dictionary(); + 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 translator) + { + TbItem.TranslateText(translator); + TbSkill.TranslateText(translator); + TbBuff.TranslateText(translator); + TbBuffAttr.TranslateText(translator); + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/EQuality.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/EQuality.cs new file mode 100644 index 00000000..0b92406c --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/EQuality.cs @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.item +{ + public enum EQuality + { + /// + /// 最差品质 + /// + WHITE = 1, + /// + /// 蓝色的 + /// + BLUE = 2, + /// + /// 紫色的 + /// + PURPLE = 3, + /// + /// 最高品质 + /// + RED = 4, + } + +} diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/Item.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/Item.cs new file mode 100644 index 00000000..11d2813a --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/Item.cs @@ -0,0 +1,120 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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(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); + } + + /// + /// 这是id + /// + public int Id { get; private set; } + /// + /// 名字 + /// + public string Name { get; private set; } + /// + /// 描述 + /// + public string Desc { get; private set; } + /// + /// 价格 + /// + public int Price { get; private set; } + /// + /// 引用当前表 + /// + public int UpgradeToItemId { get; private set; } + public item.Item UpgradeToItemId_Ref { get; private set; } + /// + /// 过期时间 + /// + public int? ExpireTime { get; private set; } + /// + /// 能否批量使用 + /// + public bool BatchUseable { get; private set; } + /// + /// 品质 + /// + public item.EQuality Quality { get; private set; } + /// + /// 道具兑换配置 + /// + public item.ItemExchange ExchangeStream { get; private set; } + public System.Collections.Generic.List ExchangeList { get; private set; } + /// + /// 道具兑换配置 + /// + public item.ItemExchange ExchangeColumn { get; private set; } + + public const int __ID__ = 2107285806; + public override int GetTypeId() => __ID__; + + public void Resolve(Dictionary _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 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(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/ItemExchange.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/ItemExchange.cs new file mode 100644 index 00000000..ad1b3a42 --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/ItemExchange.cs @@ -0,0 +1,61 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +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); + } + + /// + /// 道具id + /// + public int Id { get; private set; } + /// + /// 道具数量 + /// + public int Num { get; private set; } + + public const int __ID__ = 1814660465; + public override int GetTypeId() => __ID__; + + public void Resolve(Dictionary _tables) + { + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + } + + public override string ToString() + { + return "{ " + + "Id:" + Id + "," + + "Num:" + Num + "," + + "}"; + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/TbItem.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/TbItem.cs new file mode 100644 index 00000000..7386009b --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/item/TbItem.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using Bright.Serialization; +using System.Collections.Generic; + + +namespace GameConfig.item +{ + +public partial class TbItem +{ + private readonly Dictionary _dataMap; + private readonly List _dataList; + + public TbItem(ByteBuf _buf) + { + _dataMap = new Dictionary(); + _dataList = new List(); + + 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 DataMap => _dataMap; + public List 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 _tables) + { + foreach(var v in _dataList) + { + v.Resolve(_tables); + } + PostResolve(); + } + + public void TranslateText(System.Func translator) + { + foreach(var v in _dataList) + { + v.TranslateText(translator); + } + } + + partial void PostInit(); + partial void PostResolve(); +} + +} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/test/AccessFlag.cs b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/test/AccessFlag.cs new file mode 100644 index 00000000..800b278e --- /dev/null +++ b/Assets/GameScripts/DotNet/Logic/Config~/GameConfig/test/AccessFlag.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace GameConfig.test +{ + [System.Flags] + public enum AccessFlag + { + WRITE = 1, + READ = 2, + TRUNCATE = 4, + NEW = 8, + /// + /// 位标记使用示例 + /// + READ_WRITE = WRITE|READ, + } + +} diff --git a/DotNet/Logic/Logic.csproj b/DotNet/Logic/Logic.csproj index 4deaabfe..91201457 100644 --- a/DotNet/Logic/Logic.csproj +++ b/DotNet/Logic/Logic.csproj @@ -8,10 +8,12 @@ TRACE;TENGINE_NET + true TRACE;TENGINE_NET + true @@ -24,4 +26,10 @@ + + + Core\Config~\GameConfig\Battle + + + diff --git a/Luban/gen_code_bin_to_server.bat b/Luban/gen_code_bin_to_server.bat new file mode 100644 index 00000000..817bfb8c --- /dev/null +++ b/Luban/gen_code_bin_to_server.bat @@ -0,0 +1,17 @@ +set WORKSPACE=.. + +set GEN_CLIENT=%WORKSPACE%\Luban\Luban.ClientServer\Luban.ClientServer.exe +set CONF_ROOT=%WORKSPACE%\Luban\Config +set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas + +%GEN_CLIENT% -j cfg --^ + -d %CONF_ROOT%\Defines\__root__.xml ^ + --input_data_dir %CONF_ROOT%\Datas ^ + --output_code_dir %WORKSPACE%/Assets/GameScripts/DotNet/Logic/Config~/GameConfig ^ + --output_data_dir ..\DotNet\Config\GameConfig ^ + --gen_types code_cs_unity_bin,data_bin ^ + -s all + +echo ======== 生成配置文件结束 ======== + +pause \ No newline at end of file