mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Compare commits
10 Commits
TEngine3.1
...
TEngine3.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
04a43a3f11 | ||
![]() |
54214cdd0b | ||
![]() |
fa870b6228 | ||
![]() |
8a49d3437b | ||
![]() |
f19b889deb | ||
![]() |
d55f6e29d9 | ||
![]() |
8e4af31f26 | ||
![]() |
58a4b3e043 | ||
![]() |
576bf3bb48 | ||
![]() |
d282b81546 |
@@ -1,6 +1,7 @@
|
|||||||
#if TENGINE_NET
|
#if TENGINE_NET
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using TEngine.Core.Network;
|
using TEngine.Core.Network;
|
||||||
|
|
||||||
#pragma warning disable CS8604
|
#pragma warning disable CS8604
|
||||||
#pragma warning disable CS8602
|
#pragma warning disable CS8602
|
||||||
#pragma warning disable CS8600
|
#pragma warning disable CS8600
|
||||||
@@ -49,6 +50,21 @@ public sealed class ProtoBufExporter
|
|||||||
Directory.CreateDirectory(Define.ProtoBufClientDirectory);
|
Directory.CreateDirectory(Define.ProtoBufClientDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists($"{Define.ProtoBufDirectory}Outer"))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory($"{Define.ProtoBufDirectory}Outer");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists($"{Define.ProtoBufDirectory}Inner"))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory($"{Define.ProtoBufDirectory}Inner");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists($"{Define.ProtoBufDirectory}Bson"))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory($"{Define.ProtoBufDirectory}Bson");
|
||||||
|
}
|
||||||
|
|
||||||
var tasks = new Task[2];
|
var tasks = new Task[2];
|
||||||
tasks[0] = Task.Run(RouteType);
|
tasks[0] = Task.Run(RouteType);
|
||||||
tasks[1] = Task.Run(async () =>
|
tasks[1] = Task.Run(async () =>
|
||||||
@@ -63,17 +79,12 @@ public sealed class ProtoBufExporter
|
|||||||
|
|
||||||
private async Task Start(ProtoBufOpCodeType opCodeType)
|
private async Task Start(ProtoBufOpCodeType opCodeType)
|
||||||
{
|
{
|
||||||
var protoFile = "";
|
List<string> files = new List<string>();
|
||||||
var opCodeName = "";
|
var opCodeName = "";
|
||||||
var parameter = "";
|
|
||||||
var className = "";
|
|
||||||
var isMsgHead = false;
|
|
||||||
OpcodeInfo opcodeInfo = null;
|
OpcodeInfo opcodeInfo = null;
|
||||||
string responseTypeStr = null;
|
|
||||||
string customRouteType = null;
|
|
||||||
_opcodes.Clear();
|
_opcodes.Clear();
|
||||||
var file = new StringBuilder();
|
var file = new StringBuilder();
|
||||||
var saveDirectory = new Dictionary<string,string>();
|
var saveDirectory = new Dictionary<string, string>();
|
||||||
|
|
||||||
switch (opCodeType)
|
switch (opCodeType)
|
||||||
{
|
{
|
||||||
@@ -86,9 +97,10 @@ public sealed class ProtoBufExporter
|
|||||||
_aRouteRequest = Opcode.OuterRouteRequest;
|
_aRouteRequest = Opcode.OuterRouteRequest;
|
||||||
_aRouteResponse = Opcode.OuterRouteResponse;
|
_aRouteResponse = Opcode.OuterRouteResponse;
|
||||||
opCodeName = "OuterOpcode";
|
opCodeName = "OuterOpcode";
|
||||||
protoFile = $"{Define.ProtoBufDirectory}OuterMessage.proto";
|
|
||||||
saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate);
|
saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate);
|
||||||
saveDirectory.Add(Define.ProtoBufClientDirectory, _clientTemplate);
|
saveDirectory.Add(Define.ProtoBufClientDirectory, _clientTemplate);
|
||||||
|
files.Add($"{Define.ProtoBufDirectory}OuterMessage.proto");
|
||||||
|
files.AddRange(Directory.GetFiles($"{Define.ProtoBufDirectory}Outer").ToList());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ProtoBufOpCodeType.Inner:
|
case ProtoBufOpCodeType.Inner:
|
||||||
@@ -101,8 +113,9 @@ public sealed class ProtoBufExporter
|
|||||||
_aRouteRequest = Opcode.InnerRouteRequest + 1000;
|
_aRouteRequest = Opcode.InnerRouteRequest + 1000;
|
||||||
_aRouteResponse = Opcode.InnerRouteResponse + 1000;
|
_aRouteResponse = Opcode.InnerRouteResponse + 1000;
|
||||||
opCodeName = "InnerOpcode";
|
opCodeName = "InnerOpcode";
|
||||||
protoFile = $"{Define.ProtoBufDirectory}InnerMessage.proto";
|
|
||||||
saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate);
|
saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate);
|
||||||
|
files.Add($"{Define.ProtoBufDirectory}InnerMessage.proto");
|
||||||
|
files.AddRange(Directory.GetFiles($"{Define.ProtoBufDirectory}Inner").ToList());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ProtoBufOpCodeType.InnerBson:
|
case ProtoBufOpCodeType.InnerBson:
|
||||||
@@ -115,204 +128,217 @@ public sealed class ProtoBufExporter
|
|||||||
_aRouteRequest = Opcode.InnerBsonRouteRequest + 1000;
|
_aRouteRequest = Opcode.InnerBsonRouteRequest + 1000;
|
||||||
_aRouteResponse = Opcode.InnerBsonRouteResponse + 1000;
|
_aRouteResponse = Opcode.InnerBsonRouteResponse + 1000;
|
||||||
opCodeName = "InnerBsonOpcode";
|
opCodeName = "InnerBsonOpcode";
|
||||||
protoFile = $"{Define.ProtoBufDirectory}InnerBsonMessage.proto";
|
|
||||||
saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate);
|
saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate);
|
||||||
|
files.Add($"{Define.ProtoBufDirectory}InnerBsonMessage.proto");
|
||||||
|
files.AddRange(Directory.GetFiles($"{Define.ProtoBufDirectory}Bson").ToList());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var protoFileText = await File.ReadAllTextAsync(protoFile);
|
#region GenerateProtoFiles
|
||||||
|
foreach (var filePath in files)
|
||||||
foreach (var line in protoFileText.Split('\n'))
|
|
||||||
{
|
{
|
||||||
var currentLine = line.Trim();
|
var parameter = "";
|
||||||
|
var className = "";
|
||||||
|
var isMsgHead = false;
|
||||||
|
string responseTypeStr = null;
|
||||||
|
string customRouteType = null;
|
||||||
|
var protoFileText = await File.ReadAllTextAsync(filePath);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(currentLine))
|
foreach (var line in protoFileText.Split('\n'))
|
||||||
{
|
{
|
||||||
continue;
|
var currentLine = line.Trim();
|
||||||
}
|
|
||||||
|
|
||||||
if (currentLine.StartsWith("///"))
|
if (string.IsNullOrWhiteSpace(currentLine))
|
||||||
{
|
|
||||||
file.AppendFormat(" /// <summary>\r\n" + " /// {0}\r\n" + " /// </summary>\r\n", currentLine.TrimStart(new[] {'/', '/', '/'}));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentLine.StartsWith("message"))
|
|
||||||
{
|
|
||||||
isMsgHead = true;
|
|
||||||
opcodeInfo = new OpcodeInfo();
|
|
||||||
file.AppendLine("\t[ProtoContract]");
|
|
||||||
className = currentLine.Split(Define.SplitChars, StringSplitOptions.RemoveEmptyEntries)[1];
|
|
||||||
var splits = currentLine.Split(new[] {"//"}, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
|
|
||||||
if (splits.Length > 1)
|
|
||||||
{
|
{
|
||||||
var parameterArray = currentLine.Split(new[] {"//"}, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Split(',');
|
continue;
|
||||||
parameter = parameterArray[0].Trim();
|
}
|
||||||
|
|
||||||
switch (parameterArray.Length)
|
if (currentLine.StartsWith("///"))
|
||||||
|
{
|
||||||
|
file.AppendFormat(" /// <summary>\r\n" + " /// {0}\r\n" + " /// </summary>\r\n", currentLine.TrimStart(new[] { '/', '/', '/' }));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine.StartsWith("message"))
|
||||||
|
{
|
||||||
|
isMsgHead = true;
|
||||||
|
opcodeInfo = new OpcodeInfo();
|
||||||
|
file.AppendLine("\t[ProtoContract]");
|
||||||
|
className = currentLine.Split(Define.SplitChars, StringSplitOptions.RemoveEmptyEntries)[1];
|
||||||
|
var splits = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
if (splits.Length > 1)
|
||||||
{
|
{
|
||||||
case 2:
|
var parameterArray = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Split(',');
|
||||||
responseTypeStr = parameterArray[1].Trim();
|
parameter = parameterArray[0].Trim();
|
||||||
break;
|
|
||||||
case 3:
|
switch (parameterArray.Length)
|
||||||
{
|
{
|
||||||
customRouteType = parameterArray[1].Trim();
|
case 2:
|
||||||
|
responseTypeStr = parameterArray[1].Trim();
|
||||||
if (parameterArray.Length == 3)
|
break;
|
||||||
|
case 3:
|
||||||
{
|
{
|
||||||
responseTypeStr = parameterArray[2].Trim();
|
customRouteType = parameterArray[1].Trim();
|
||||||
|
|
||||||
|
if (parameterArray.Length == 3)
|
||||||
|
{
|
||||||
|
responseTypeStr = parameterArray[2].Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parameter = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
file.Append(string.IsNullOrWhiteSpace(parameter)
|
|
||||||
? $"\tpublic partial class {className} : AProto"
|
|
||||||
: $"\tpublic partial class {className} : AProto, {parameter}");
|
|
||||||
opcodeInfo.Name = className;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isMsgHead)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (currentLine)
|
|
||||||
{
|
|
||||||
case "{":
|
|
||||||
{
|
|
||||||
file.AppendLine("\n\t{");
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(parameter) || parameter == "IMessage")
|
|
||||||
{
|
|
||||||
opcodeInfo.Code += ++_aMessage;
|
|
||||||
file.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (responseTypeStr != null)
|
parameter = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
file.Append(string.IsNullOrWhiteSpace(parameter)
|
||||||
|
? $"\tpublic partial class {className} : AProto"
|
||||||
|
: $"\tpublic partial class {className} : AProto, {parameter}");
|
||||||
|
opcodeInfo.Name = className;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isMsgHead)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (currentLine)
|
||||||
|
{
|
||||||
|
case "{":
|
||||||
|
{
|
||||||
|
file.AppendLine("\n\t{");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(parameter) || parameter == "IMessage")
|
||||||
{
|
{
|
||||||
file.AppendLine("\t\t[ProtoIgnore]");
|
opcodeInfo.Code += ++_aMessage;
|
||||||
file.AppendLine($"\t\tpublic {responseTypeStr} ResponseType {{ get; set; }}");
|
file.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}");
|
||||||
responseTypeStr = null;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (parameter.Contains("RouteRequest"))
|
if (responseTypeStr != null)
|
||||||
{
|
{
|
||||||
Exporter.LogError($"{opcodeInfo.Name} 没指定ResponseType");
|
file.AppendLine("\t\t[ProtoIgnore]");
|
||||||
|
file.AppendLine($"\t\tpublic {responseTypeStr} ResponseType {{ get; set; }}");
|
||||||
|
responseTypeStr = null;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
file.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}");
|
|
||||||
|
|
||||||
if (customRouteType != null)
|
|
||||||
{
|
|
||||||
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return (long)RouteType.{customRouteType}; }}");
|
|
||||||
customRouteType = null;
|
|
||||||
}
|
|
||||||
else if (parameter is "IAddressableRouteRequest" or "IAddressableRouteMessage")
|
|
||||||
{
|
|
||||||
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.Addressable; }}");
|
|
||||||
}
|
|
||||||
else if (parameter.EndsWith("BsonRouteMessage") || parameter.EndsWith("BsonRouteRequest"))
|
|
||||||
{
|
|
||||||
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.BsonRoute; }}");
|
|
||||||
}
|
|
||||||
else if (parameter is "IRouteMessage" or "IRouteRequest")
|
|
||||||
{
|
|
||||||
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.Route; }}");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (parameter)
|
|
||||||
{
|
|
||||||
case "IRequest":
|
|
||||||
case "IBsonRequest":
|
|
||||||
{
|
{
|
||||||
opcodeInfo.Code += ++_aRequest;
|
if (parameter.Contains("RouteRequest"))
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "IResponse":
|
|
||||||
case "IBsonResponse":
|
|
||||||
{
|
|
||||||
opcodeInfo.Code += ++_aResponse;
|
|
||||||
file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]");
|
|
||||||
file.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
if (parameter.EndsWith("RouteMessage") || parameter == "IRouteMessage")
|
|
||||||
{
|
{
|
||||||
opcodeInfo.Code += ++_aRouteMessage;
|
Exporter.LogError($"{opcodeInfo.Name} 没指定ResponseType");
|
||||||
}
|
}
|
||||||
else if (parameter.EndsWith("RouteRequest") || parameter == "IRouteRequest")
|
}
|
||||||
|
|
||||||
|
file.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}");
|
||||||
|
|
||||||
|
if (customRouteType != null)
|
||||||
|
{
|
||||||
|
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return (long)RouteType.{customRouteType}; }}");
|
||||||
|
customRouteType = null;
|
||||||
|
}
|
||||||
|
else if (parameter is "IAddressableRouteRequest" or "IAddressableRouteMessage")
|
||||||
|
{
|
||||||
|
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.Addressable; }}");
|
||||||
|
}
|
||||||
|
else if (parameter.EndsWith("BsonRouteMessage") || parameter.EndsWith("BsonRouteRequest"))
|
||||||
|
{
|
||||||
|
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.BsonRoute; }}");
|
||||||
|
}
|
||||||
|
else if (parameter is "IRouteMessage" or "IRouteRequest")
|
||||||
|
{
|
||||||
|
file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.Route; }}");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (parameter)
|
||||||
|
{
|
||||||
|
case "IRequest":
|
||||||
|
case "IBsonRequest":
|
||||||
{
|
{
|
||||||
opcodeInfo.Code += ++_aRouteRequest;
|
opcodeInfo.Code += ++_aRequest;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (parameter.EndsWith("RouteResponse") || parameter == "IRouteResponse")
|
case "IResponse":
|
||||||
|
case "IBsonResponse":
|
||||||
{
|
{
|
||||||
opcodeInfo.Code += ++_aRouteResponse;
|
opcodeInfo.Code += ++_aResponse;
|
||||||
file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]");
|
file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]");
|
||||||
file.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
file.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if (parameter.EndsWith("RouteMessage") || parameter == "IRouteMessage")
|
||||||
|
{
|
||||||
|
opcodeInfo.Code += ++_aRouteMessage;
|
||||||
|
}
|
||||||
|
else if (parameter.EndsWith("RouteRequest") || parameter == "IRouteRequest")
|
||||||
|
{
|
||||||
|
opcodeInfo.Code += ++_aRouteRequest;
|
||||||
|
}
|
||||||
|
else if (parameter.EndsWith("RouteResponse") || parameter == "IRouteResponse")
|
||||||
|
{
|
||||||
|
opcodeInfo.Code += ++_aRouteResponse;
|
||||||
|
file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]");
|
||||||
|
file.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_opcodes.Add(opcodeInfo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case "}":
|
||||||
|
{
|
||||||
|
isMsgHead = false;
|
||||||
|
file.AppendLine("\t}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case "":
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_opcodes.Add(opcodeInfo);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
case "}":
|
|
||||||
|
if (currentLine.StartsWith("//"))
|
||||||
{
|
{
|
||||||
isMsgHead = false;
|
file.AppendFormat("\t\t///<summary>\r\n" + "\t\t/// {0}\r\n" + "\t\t///</summary>\r\n", currentLine.TrimStart('/', '/'));
|
||||||
file.AppendLine("\t}");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case "":
|
|
||||||
|
if (currentLine.StartsWith("repeated"))
|
||||||
{
|
{
|
||||||
continue;
|
Repeated(file, currentLine);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Members(file, currentLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLine.StartsWith("//"))
|
var csName = $"{Path.GetFileNameWithoutExtension(filePath)}.cs";
|
||||||
|
|
||||||
|
foreach (var (directory, template) in saveDirectory)
|
||||||
{
|
{
|
||||||
file.AppendFormat("\t\t///<summary>\r\n" + "\t\t/// {0}\r\n" + "\t\t///</summary>\r\n", currentLine.TrimStart('/', '/'));
|
var csFile = Path.Combine(directory, csName);
|
||||||
continue;
|
var content = template.Replace("(Content)", file.ToString());
|
||||||
|
await File.WriteAllTextAsync(csFile, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLine.StartsWith("repeated"))
|
file.Clear();
|
||||||
{
|
|
||||||
Repeated(file, currentLine);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Members(file, currentLine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var csName = $"{Path.GetFileNameWithoutExtension(protoFile)}.cs";
|
|
||||||
|
|
||||||
foreach (var (directory, template) in saveDirectory)
|
|
||||||
{
|
|
||||||
var csFile = Path.Combine(directory, csName);
|
|
||||||
var content = template.Replace("(Content)", file.ToString());
|
|
||||||
await File.WriteAllTextAsync(csFile, content);
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GenerateOpCode
|
||||||
file.Clear();
|
file.Clear();
|
||||||
|
|
||||||
file.AppendLine("namespace TEngine");
|
file.AppendLine("namespace TEngine");
|
||||||
file.AppendLine("{");
|
file.AppendLine("{");
|
||||||
file.AppendLine($"\tpublic static partial class {opCodeName}");
|
file.AppendLine($"\tpublic static partial class {opCodeName}");
|
||||||
@@ -333,6 +359,8 @@ public sealed class ProtoBufExporter
|
|||||||
var csFile = Path.Combine(directory, $"{opCodeName}.cs");
|
var csFile = Path.Combine(directory, $"{opCodeName}.cs");
|
||||||
await File.WriteAllTextAsync(csFile, file.ToString());
|
await File.WriteAllTextAsync(csFile, file.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RouteType()
|
private async Task RouteType()
|
||||||
@@ -353,7 +381,7 @@ public sealed class ProtoBufExporter
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var splits = currentLine.Split(new[] {"//"}, StringSplitOptions.RemoveEmptyEntries);
|
var splits = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
var routeTypeStr = splits[0].Split("=", StringSplitOptions.RemoveEmptyEntries);
|
var routeTypeStr = splits[0].Split("=", StringSplitOptions.RemoveEmptyEntries);
|
||||||
routeTypeFileSb.Append($"\t\t{routeTypeStr[0].Trim()} = {routeTypeStr[1].Trim()},");
|
routeTypeFileSb.Append($"\t\t{routeTypeStr[0].Trim()} = {routeTypeStr[1].Trim()},");
|
||||||
|
|
||||||
@@ -468,12 +496,12 @@ public sealed class ProtoBufExporter
|
|||||||
flag = 1;
|
flag = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(trim.StartsWith("#else"))
|
else if (trim.StartsWith("#else"))
|
||||||
{
|
{
|
||||||
flag = 2;
|
flag = 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(trim.StartsWith($"#endif"))
|
else if (trim.StartsWith($"#endif"))
|
||||||
{
|
{
|
||||||
flag = 0;
|
flag = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@@ -24,6 +24,7 @@ public partial class GameApp:Singleton<GameApp>
|
|||||||
Utility.Unity.AddDestroyListener(Instance.OnDestroy);
|
Utility.Unity.AddDestroyListener(Instance.OnDestroy);
|
||||||
Utility.Unity.AddOnDrawGizmosListener(Instance.OnDrawGizmos);
|
Utility.Unity.AddOnDrawGizmosListener(Instance.OnDrawGizmos);
|
||||||
Utility.Unity.AddOnApplicationPauseListener(Instance.OnApplicationPause);
|
Utility.Unity.AddOnApplicationPauseListener(Instance.OnApplicationPause);
|
||||||
|
GameModule.Procedure.RestartProcedure(new GameLogic.OnEnterGameAppProcedure());
|
||||||
Instance.StartGameLogic();
|
Instance.StartGameLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
using TEngine;
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
public class OnEnterGameAppProcedure : ProcedureBase
|
||||||
|
{
|
||||||
|
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||||
|
{
|
||||||
|
base.OnEnter(procedureOwner);
|
||||||
|
Log.Debug("OnEnter GameApp Procedure");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 415b43b274b541a0a2312417644452b0
|
||||||
|
timeCreated: 1692956662
|
@@ -116,6 +116,7 @@ namespace GameMain
|
|||||||
|
|
||||||
private void AllAssemblyLoadComplete()
|
private void AllAssemblyLoadComplete()
|
||||||
{
|
{
|
||||||
|
ChangeState<ProcedureStartGame>(m_procedureOwner);
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
m_MainLogicAssembly = AppDomain.CurrentDomain.GetAssemblies().
|
m_MainLogicAssembly = AppDomain.CurrentDomain.GetAssemblies().
|
||||||
First(assembly => $"{assembly.GetName().Name}.dll" == SettingsUtils.HybridCLRCustomGlobalSettings.LogicMainDllName);
|
First(assembly => $"{assembly.GetName().Name}.dll" == SettingsUtils.HybridCLRCustomGlobalSettings.LogicMainDllName);
|
||||||
@@ -139,7 +140,6 @@ namespace GameMain
|
|||||||
}
|
}
|
||||||
object[] objects = new object[] { new object[] { m_HotfixAssemblys } };
|
object[] objects = new object[] { new object[] { m_HotfixAssemblys } };
|
||||||
entryMethod.Invoke(appType, objects);
|
entryMethod.Invoke(appType, objects);
|
||||||
ChangeState<ProcedureStartGame>(m_procedureOwner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Assembly GetMainLogicAssembly()
|
private Assembly GetMainLogicAssembly()
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
<Collector CollectPath="Assets/AssetRaw/Shaders" CollectGUID="2a4bceb84ed685447ace957f497eb810" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectShaderVariants" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/AssetRaw/Shaders" CollectGUID="2a4bceb84ed685447ace957f497eb810" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectShaderVariants" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="UI" GroupDesc="UI面板" AssetTags="UI">
|
<Group GroupActiveRule="EnableGroup" GroupName="UI" GroupDesc="UI面板" AssetTags="UI">
|
||||||
<Collector CollectPath="Assets/AssetRaw/UI" CollectGUID="27e87d83814156648b58f380b834e046" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/AssetRaw/UI" CollectGUID="27e87d83814156648b58f380b834e046" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Fonts" GroupDesc="字体" AssetTags="Fonts">
|
<Group GroupActiveRule="EnableGroup" GroupName="Fonts" GroupDesc="字体" AssetTags="Fonts">
|
||||||
<Collector CollectPath="Assets/AssetRaw/Fonts" CollectGUID="2473375c9ee163a4b861278b38091455" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/AssetRaw/Fonts" CollectGUID="2473375c9ee163a4b861278b38091455" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
@@ -154,7 +154,7 @@ MonoBehaviour:
|
|||||||
CollectorGUID: 27e87d83814156648b58f380b834e046
|
CollectorGUID: 27e87d83814156648b58f380b834e046
|
||||||
CollectorType: 0
|
CollectorType: 0
|
||||||
AddressRuleName: AddressByFileName
|
AddressRuleName: AddressByFileName
|
||||||
PackRuleName: PackDirectory
|
PackRuleName: PackSeparately
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
|
138
Assets/TEngine/Editor/Resource/YooAsset/PackageCompareWindow.cs
Normal file
138
Assets/TEngine/Editor/Resource/YooAsset/PackageCompareWindow.cs
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class PackageCompareWindow : EditorWindow
|
||||||
|
{
|
||||||
|
static PackageCompareWindow _thisInstance;
|
||||||
|
|
||||||
|
[MenuItem("YooAsset/补丁包比对工具", false, 302)]
|
||||||
|
static void ShowWindow()
|
||||||
|
{
|
||||||
|
if (_thisInstance == null)
|
||||||
|
{
|
||||||
|
_thisInstance = EditorWindow.GetWindow(typeof(PackageCompareWindow), false, "补丁包比对工具", true) as PackageCompareWindow;
|
||||||
|
_thisInstance.minSize = new Vector2(800, 600);
|
||||||
|
}
|
||||||
|
_thisInstance.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _manifestPath1 = string.Empty;
|
||||||
|
private string _manifestPath2 = string.Empty;
|
||||||
|
private readonly List<PackageBundle> _changeList = new List<PackageBundle>();
|
||||||
|
private readonly List<PackageBundle> _newList = new List<PackageBundle>();
|
||||||
|
private Vector2 _scrollPos1;
|
||||||
|
private Vector2 _scrollPos2;
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.Space(10);
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
if (GUILayout.Button("选择补丁包1", GUILayout.MaxWidth(150)))
|
||||||
|
{
|
||||||
|
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||||
|
if (string.IsNullOrEmpty(resultPath))
|
||||||
|
return;
|
||||||
|
_manifestPath1 = resultPath;
|
||||||
|
}
|
||||||
|
EditorGUILayout.LabelField(_manifestPath1);
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.Space(10);
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
if (GUILayout.Button("选择补丁包2", GUILayout.MaxWidth(150)))
|
||||||
|
{
|
||||||
|
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||||
|
if (string.IsNullOrEmpty(resultPath))
|
||||||
|
return;
|
||||||
|
_manifestPath2 = resultPath;
|
||||||
|
}
|
||||||
|
EditorGUILayout.LabelField(_manifestPath2);
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_manifestPath1) == false && string.IsNullOrEmpty(_manifestPath2) == false)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("比对差异", GUILayout.MaxWidth(150)))
|
||||||
|
{
|
||||||
|
ComparePackage(_changeList, _newList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
using (new EditorGUI.DisabledScope(false))
|
||||||
|
{
|
||||||
|
int totalCount = _changeList.Count;
|
||||||
|
EditorGUILayout.Foldout(true, $"差异列表 ( {totalCount} )");
|
||||||
|
|
||||||
|
EditorGUI.indentLevel = 1;
|
||||||
|
_scrollPos1 = EditorGUILayout.BeginScrollView(_scrollPos1);
|
||||||
|
{
|
||||||
|
foreach (var bundle in _changeList)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField($"{bundle.BundleName} | {(bundle.FileSize / 1024)}K");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndScrollView();
|
||||||
|
EditorGUI.indentLevel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
using (new EditorGUI.DisabledScope(false))
|
||||||
|
{
|
||||||
|
int totalCount = _newList.Count;
|
||||||
|
EditorGUILayout.Foldout(true, $"新增列表 ( {totalCount} )");
|
||||||
|
|
||||||
|
EditorGUI.indentLevel = 1;
|
||||||
|
_scrollPos2 = EditorGUILayout.BeginScrollView(_scrollPos2);
|
||||||
|
{
|
||||||
|
foreach (var bundle in _newList)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField($"{bundle.BundleName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndScrollView();
|
||||||
|
EditorGUI.indentLevel = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComparePackage(List<PackageBundle> changeList, List<PackageBundle> newList)
|
||||||
|
{
|
||||||
|
changeList.Clear();
|
||||||
|
newList.Clear();
|
||||||
|
|
||||||
|
// 加载补丁清单1
|
||||||
|
byte[] bytesData1 = FileUtility.ReadAllBytes(_manifestPath1);
|
||||||
|
PackageManifest manifest1 = ManifestTools.DeserializeFromBinary(bytesData1);
|
||||||
|
|
||||||
|
// 加载补丁清单1
|
||||||
|
byte[] bytesData2 = FileUtility.ReadAllBytes(_manifestPath2);
|
||||||
|
PackageManifest manifest2 = ManifestTools.DeserializeFromBinary(bytesData2);
|
||||||
|
|
||||||
|
// 拷贝文件列表
|
||||||
|
foreach (var bundle2 in manifest2.BundleList)
|
||||||
|
{
|
||||||
|
if (manifest1.TryGetPackageBundle(bundle2.BundleName, out PackageBundle bundle1))
|
||||||
|
{
|
||||||
|
if (bundle2.FileHash != bundle1.FileHash)
|
||||||
|
{
|
||||||
|
changeList.Add(bundle2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newList.Add(bundle2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按字母重新排序
|
||||||
|
changeList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
|
||||||
|
newList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
|
||||||
|
|
||||||
|
Debug.Log("资源包差异比对完成!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 46962b0d15f63264bb45fe5be11f48cb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -0,0 +1,89 @@
|
|||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class PackageImportWindow : EditorWindow
|
||||||
|
{
|
||||||
|
static PackageImportWindow _thisInstance;
|
||||||
|
|
||||||
|
[MenuItem("YooAsset/补丁包导入工具", false, 301)]
|
||||||
|
static void ShowWindow()
|
||||||
|
{
|
||||||
|
if (_thisInstance == null)
|
||||||
|
{
|
||||||
|
_thisInstance = EditorWindow.GetWindow(typeof(PackageImportWindow), false, "补丁包导入工具", true) as PackageImportWindow;
|
||||||
|
_thisInstance.minSize = new Vector2(800, 600);
|
||||||
|
}
|
||||||
|
_thisInstance.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _manifestPath = string.Empty;
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.Space(10);
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
if (GUILayout.Button("选择补丁包", GUILayout.MaxWidth(150)))
|
||||||
|
{
|
||||||
|
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||||
|
if (string.IsNullOrEmpty(resultPath))
|
||||||
|
return;
|
||||||
|
_manifestPath = resultPath;
|
||||||
|
}
|
||||||
|
EditorGUILayout.LabelField(_manifestPath);
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_manifestPath) == false)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150)))
|
||||||
|
{
|
||||||
|
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||||
|
CopyPackageFiles(_manifestPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopyPackageFiles(string manifestFilePath)
|
||||||
|
{
|
||||||
|
string manifestFileName = Path.GetFileNameWithoutExtension(manifestFilePath);
|
||||||
|
string outputDirectory = Path.GetDirectoryName(manifestFilePath);
|
||||||
|
|
||||||
|
// 加载补丁清单
|
||||||
|
byte[] bytesData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||||
|
PackageManifest manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||||
|
|
||||||
|
// 拷贝核心文件
|
||||||
|
{
|
||||||
|
string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes";
|
||||||
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{manifestFileName}.bytes";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
string sourcePath = $"{outputDirectory}/{manifestFileName}.hash";
|
||||||
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{manifestFileName}.hash";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName);
|
||||||
|
string sourcePath = $"{outputDirectory}/{fileName}";
|
||||||
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{fileName}";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拷贝文件列表
|
||||||
|
int fileCount = 0;
|
||||||
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
|
{
|
||||||
|
fileCount++;
|
||||||
|
string sourcePath = $"{outputDirectory}/{packageBundle.FileName}";
|
||||||
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{packageBundle.FileName}";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log($"补丁包拷贝完成,一共拷贝了{fileCount}个资源文件");
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9054ed6f15278064aa817961e48878d5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -13,11 +13,9 @@ namespace TEngine
|
|||||||
private IProcedureManager m_ProcedureManager = null;
|
private IProcedureManager m_ProcedureManager = null;
|
||||||
private ProcedureBase m_EntranceProcedure = null;
|
private ProcedureBase m_EntranceProcedure = null;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField] private string[] m_AvailableProcedureTypeNames = null;
|
||||||
private string[] m_AvailableProcedureTypeNames = null;
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField] private string m_EntranceProcedureTypeName = null;
|
||||||
private string m_EntranceProcedureTypeName = null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前流程。
|
/// 获取当前流程。
|
||||||
@@ -30,6 +28,7 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_ProcedureManager.CurrentProcedure;
|
return m_ProcedureManager.CurrentProcedure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,6 +44,7 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_ProcedureManager.CurrentProcedureTime;
|
return m_ProcedureManager.CurrentProcedureTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,5 +140,31 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
return m_ProcedureManager.GetProcedure(procedureType);
|
return m_ProcedureManager.GetProcedure(procedureType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重启流程。
|
||||||
|
/// <remarks>默认使用第一个流程作为启动流程。</remarks>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="procedures">新的的流程。</param>
|
||||||
|
/// <returns>是否重启成功。</returns>
|
||||||
|
/// <exception cref="GameFrameworkException">重启异常。</exception>
|
||||||
|
public bool RestartProcedure(params ProcedureBase[] procedures)
|
||||||
|
{
|
||||||
|
if (procedures == null || procedures.Length <= 0)
|
||||||
|
{
|
||||||
|
throw new GameFrameworkException("RestartProcedure Failed procedures is invalid.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GameModule.Fsm.DestroyFsm<IProcedureManager>())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_ProcedureManager = null;
|
||||||
|
m_ProcedureManager = GameFrameworkModuleSystem.GetModule<IProcedureManager>();
|
||||||
|
IFsmManager fsmManager = GameFrameworkModuleSystem.GetModule<IFsmManager>();
|
||||||
|
m_ProcedureManager.Initialize(fsmManager, procedures);
|
||||||
|
m_ProcedureManager.StartProcedure(procedures[0].GetType());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -262,7 +262,7 @@ namespace TEngine
|
|||||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
||||||
{
|
{
|
||||||
var package = YooAssets.GetPackage(packageName);
|
var package = YooAssets.GetPackage(packageName);
|
||||||
return package.UpdatePackageManifestAsync(packageVersion,autoSaveVersion, timeout);
|
return package.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -473,29 +473,6 @@ namespace TEngine
|
|||||||
handle.Completed += callback;
|
handle.Completed += callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载资源。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetName">要加载资源的名称。</param>
|
|
||||||
/// <param name="cancellationToken">取消操作Token。</param>
|
|
||||||
/// <typeparam name="T">要加载资源的类型。</typeparam>
|
|
||||||
/// <returns>异步资源实例。</returns>
|
|
||||||
public async UniTask<T> LoadAssetAsync<T>(string assetName, CancellationToken cancellationToken) where T : UnityEngine.Object
|
|
||||||
{
|
|
||||||
return await m_ResourceManager.LoadAssetAsync<T>(assetName, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载游戏物体。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetName">要加载的游戏物体名称。</param>
|
|
||||||
/// <param name="cancellationToken">取消操作Token。</param>
|
|
||||||
/// <returns>异步游戏物体实例。</returns>
|
|
||||||
public async UniTask<GameObject> LoadGameObjectAsync(string assetName, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return await m_ResourceManager.LoadAssetAsync<GameObject>(assetName, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步加载资源并获取句柄。
|
/// 同步加载资源并获取句柄。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -551,6 +528,7 @@ namespace TEngine
|
|||||||
Log.Fatal($"AssetsInfo is null");
|
Log.Fatal($"AssetsInfo is null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_ResourceManager.LoadSubAssetsSync(assetInfo);
|
return m_ResourceManager.LoadSubAssetsSync(assetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,7 +540,8 @@ namespace TEngine
|
|||||||
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
/// <returns>异步加载场景句柄。</returns>
|
/// <returns>异步加载场景句柄。</returns>
|
||||||
public SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
public SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true,
|
||||||
|
int priority = 100)
|
||||||
{
|
{
|
||||||
return m_ResourceManager.LoadSceneAsync(location, sceneMode, activateOnLoad, priority);
|
return m_ResourceManager.LoadSceneAsync(location, sceneMode, activateOnLoad, priority);
|
||||||
}
|
}
|
||||||
@@ -575,9 +554,96 @@ namespace TEngine
|
|||||||
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
/// <returns>异步加载场景句柄。</returns>
|
/// <returns>异步加载场景句柄。</returns>
|
||||||
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true,
|
||||||
|
int priority = 100)
|
||||||
{
|
{
|
||||||
return m_ResourceManager.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
return m_ResourceManager.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetName">要加载资源的名称。</param>
|
||||||
|
/// <param name="cancellationToken">取消操作Token。</param>
|
||||||
|
/// <typeparam name="T">要加载资源的类型。</typeparam>
|
||||||
|
/// <returns>异步资源实例。</returns>
|
||||||
|
public async UniTask<T> LoadAssetAsync<T>(string assetName, CancellationToken cancellationToken) where T : UnityEngine.Object
|
||||||
|
{
|
||||||
|
return await m_ResourceManager.LoadAssetAsync<T>(assetName, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载游戏物体。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetName">要加载的游戏物体名称。</param>
|
||||||
|
/// <param name="cancellationToken">取消操作Token。</param>
|
||||||
|
/// <returns>异步游戏物体实例。</returns>
|
||||||
|
public async UniTask<GameObject> LoadGameObjectAsync(string assetName, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return await m_ResourceManager.LoadGameObjectAsync(assetName, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载游戏物体。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源定位地址。</param>
|
||||||
|
/// <param name="parent">父节点位置。</param>
|
||||||
|
/// <param name="cancellationToken">取消操作Token。</param>
|
||||||
|
/// <returns>异步游戏物体实例。</returns>
|
||||||
|
public async UniTask<GameObject> LoadGameObjectAsync(string location, Transform parent, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return await m_ResourceManager.LoadGameObjectAsync(location, parent, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载原生文件。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源定位地址。</param>
|
||||||
|
/// <param name="cancellationToken">取消操作Token。</param>
|
||||||
|
/// <returns>原生文件资源实例。</returns>
|
||||||
|
public async UniTask<RawFileOperationHandle> LoadRawAssetAsync(string location, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return await m_ResourceManager.LoadRawAssetAsync(location, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载子文件。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源定位地址。</param>
|
||||||
|
/// <param name="assetName">资源名称。</param>
|
||||||
|
/// <param name="cancellationToken">取消操作Token。</param>
|
||||||
|
/// <typeparam name="T">资源实例类型。</typeparam>
|
||||||
|
/// <returns>原生文件资源实例。</returns>
|
||||||
|
public async UniTask<T> LoadSubAssetAsync<T>(string location, string assetName, CancellationToken cancellationToken) where T : UnityEngine.Object
|
||||||
|
{
|
||||||
|
return await m_ResourceManager.LoadSubAssetAsync<T>(location, assetName, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载所有子文件。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源定位地址。</param>
|
||||||
|
/// <param name="cancellationToken">取消操作Token。</param>
|
||||||
|
/// <typeparam name="T">资源实例类型。</typeparam>
|
||||||
|
/// <returns>原生文件资源实例。</returns>
|
||||||
|
public async UniTask<T[]> LoadAllSubAssetAsync<T>(string location, CancellationToken cancellationToken) where T : UnityEngine.Object
|
||||||
|
{
|
||||||
|
return await m_ResourceManager.LoadAllSubAssetAsync<T>(location, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载场景。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">场景的定位地址。</param>
|
||||||
|
/// <param name="cancellationToken">取消操作Token。</param>
|
||||||
|
/// <param name="sceneMode">场景加载模式。</param>
|
||||||
|
/// <param name="activateOnLoad">加载完毕时是否主动激活。</param>
|
||||||
|
/// <param name="priority">优先级。</param>
|
||||||
|
/// <returns>场景资源实例。</returns>
|
||||||
|
public async UniTask<Scene> LoadSceneAsyncByUniTask(string location, CancellationToken cancellationToken,
|
||||||
|
LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
|
{
|
||||||
|
return await m_ResourceManager.LoadSceneAsyncByUniTask(location, cancellationToken, sceneMode, activateOnLoad, priority);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -113,8 +113,6 @@ namespace TEngine
|
|||||||
BuglyManager.Instance.Init(Resources.Load<BuglyConfig>("BuglyConfig"));
|
BuglyManager.Instance.Init(Resources.Load<BuglyConfig>("BuglyConfig"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GameTime.StartFrame();
|
|
||||||
|
|
||||||
InitTextHelper();
|
InitTextHelper();
|
||||||
InitVersionHelper();
|
InitVersionHelper();
|
||||||
InitLogHelper();
|
InitLogHelper();
|
||||||
@@ -141,7 +139,6 @@ namespace TEngine
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
GameTime.StartFrame();
|
|
||||||
GameFrameworkModuleSystem.Update(Time.deltaTime, Time.unscaledDeltaTime);
|
GameFrameworkModuleSystem.Update(Time.deltaTime, Time.unscaledDeltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,6 +41,16 @@
|
|||||||
"name": "com.unity.modules.particlesystem",
|
"name": "com.unity.modules.particlesystem",
|
||||||
"expression": "",
|
"expression": "",
|
||||||
"define": "UNITASK_PARTICLESYSTEM_SUPPORT"
|
"define": "UNITASK_PARTICLESYSTEM_SUPPORT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "com.unity.textmeshpro",
|
||||||
|
"expression": "",
|
||||||
|
"define": "UNITASK_TEXTMESHPRO_SUPPORT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "com.demigiant.dotween",
|
||||||
|
"expression": "",
|
||||||
|
"define": "UNITASK_DOTWEEN_SUPPORT"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"noEngineReferences": false
|
"noEngineReferences": false
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
// asmdef Version Defines, enabled when com.demigiant.dotween is imported.
|
// asmdef Version Defines, enabled when com.demigiant.dotween is imported.
|
||||||
|
|
||||||
#if UNITASK_DOTWEEN_SUPPORT
|
#if true || UNITASK_DOTWEEN_SUPPORT
|
||||||
|
|
||||||
using Cysharp.Threading.Tasks.Internal;
|
using Cysharp.Threading.Tasks.Internal;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
37
Assets/TEngine/Runtime/Utility/NewtonsoftJsonHelper.cs
Normal file
37
Assets/TEngine/Runtime/Utility/NewtonsoftJsonHelper.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
namespace TEngine
|
||||||
|
{
|
||||||
|
public class NewtonsoftJsonHelper : Utility.Json.IJsonHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 将对象序列化为 JSON 字符串。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">要序列化的对象。</param>
|
||||||
|
/// <returns>序列化后的 JSON 字符串。</returns>
|
||||||
|
public string ToJson(object obj)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将 JSON 字符串反序列化为对象。
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">对象类型。</typeparam>
|
||||||
|
/// <param name="json">要反序列化的 JSON 字符串。</param>
|
||||||
|
/// <returns>反序列化后的对象。</returns>
|
||||||
|
public T ToObject<T>(string json)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将 JSON 字符串反序列化为对象。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objectType">对象类型。</param>
|
||||||
|
/// <param name="json">要反序列化的 JSON 字符串。</param>
|
||||||
|
/// <returns>反序列化后的对象。</returns>
|
||||||
|
public object ToObject(System.Type objectType, string json)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.DeserializeObject(json, objectType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 38484765ede44acc840c664a828ca6ff
|
||||||
|
timeCreated: 1687360419
|
@@ -1,20 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package TEngine.Network.Message;
|
|
||||||
import "google/protobuf/struct.proto";
|
|
||||||
|
|
||||||
|
|
||||||
message AccountInfo
|
|
||||||
{
|
|
||||||
int64 UnitId = 1;
|
|
||||||
int64 UserId = 2;
|
|
||||||
int64 CharaId = 3;
|
|
||||||
repeated int32 Ks = 4;
|
|
||||||
repeated int64 Vs = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ItemInfo
|
|
||||||
{
|
|
||||||
int32 ItemGId = 1;
|
|
||||||
int32 ItemId = 2;
|
|
||||||
int32 Count = 3;
|
|
||||||
}
|
|
Reference in New Issue
Block a user