mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] 接入ET8服务端
[+] 接入ET8服务端
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace ET
|
||||
{
|
||||
public static class ConsoleMode
|
||||
{
|
||||
public const string ReloadDll = "R";
|
||||
public const string ReloadConfig = "C";
|
||||
public const string ShowMemory = "M";
|
||||
public const string Repl = "Repl";
|
||||
public const string Debugger = "Debugger";
|
||||
public const string CreateRobot = "CreateRobot";
|
||||
public const string Robot = "Robot";
|
||||
}
|
||||
|
||||
[ComponentOf(typeof(Scene))]
|
||||
public class ConsoleComponent: Entity, IAwake
|
||||
{
|
||||
public CancellationTokenSource CancellationTokenSource;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22534ff56546c094d904521502f2103f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ET
|
||||
{
|
||||
public class ConsoleDispatcher: SingletonLock<ConsoleDispatcher>, ISingletonAwake
|
||||
{
|
||||
private readonly Dictionary<string, IConsoleHandler> handlers = new();
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
World.Instance.AddSingleton<ConsoleDispatcher>(true);
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ConsoleHandlerAttribute));
|
||||
|
||||
foreach (Type type in types)
|
||||
{
|
||||
object[] attrs = type.GetCustomAttributes(typeof(ConsoleHandlerAttribute), false);
|
||||
if (attrs.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ConsoleHandlerAttribute consoleHandlerAttribute = (ConsoleHandlerAttribute)attrs[0];
|
||||
|
||||
object obj = Activator.CreateInstance(type);
|
||||
|
||||
IConsoleHandler iConsoleHandler = obj as IConsoleHandler;
|
||||
if (iConsoleHandler == null)
|
||||
{
|
||||
throw new Exception($"ConsoleHandler handler not inherit IConsoleHandler class: {obj.GetType().FullName}");
|
||||
}
|
||||
this.handlers.Add(consoleHandlerAttribute.Mode, iConsoleHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public IConsoleHandler Get(string key)
|
||||
{
|
||||
return this.handlers[key];
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cf505646a7016d40817dc8783f37ed1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,12 @@
|
||||
namespace ET
|
||||
{
|
||||
public class ConsoleHandlerAttribute: BaseAttribute
|
||||
{
|
||||
public string Mode { get; }
|
||||
|
||||
public ConsoleHandlerAttribute(string mode)
|
||||
{
|
||||
this.Mode = mode;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08c605182de1040469a4239c965f2694
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
||||
namespace ET
|
||||
{
|
||||
public interface IConsoleHandler
|
||||
{
|
||||
ETTask Run(Fiber fiber, ModeContex contex, string content);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0498d217572ef624cb2f066e11f028a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,27 @@
|
||||
namespace ET
|
||||
{
|
||||
[EntitySystemOf(typeof(ModeContex))]
|
||||
[FriendOf(typeof(ModeContex))]
|
||||
public static partial class ModeContexSystem
|
||||
{
|
||||
[EntitySystem]
|
||||
private static void Awake(this ModeContex self)
|
||||
{
|
||||
self.Mode = "";
|
||||
}
|
||||
|
||||
[EntitySystem]
|
||||
private static void Destroy(this ModeContex self)
|
||||
{
|
||||
self.Mode = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ComponentOf(typeof(ConsoleComponent))]
|
||||
public class ModeContex: Entity, IAwake, IDestroy
|
||||
{
|
||||
public string Mode = "";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 519865a57fe078d4b8b5989813e8c4ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user