mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
GameServerScene
GameServerScene
This commit is contained in:
@@ -26,5 +26,14 @@ namespace TEngine
|
||||
}
|
||||
return (T)Enum.Parse(typeof(T), str);
|
||||
}
|
||||
|
||||
public static T Parse<T>(this string str)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(T), str))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
return (T)Enum.Parse(typeof(T), str);
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,6 +3,16 @@ using TEngine.Core.Network;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
[Flags]
|
||||
public enum SceneType: long
|
||||
{
|
||||
None = 0,
|
||||
Gate = 1, // Gate
|
||||
Addressable = 1 << 2, // 负责进程间消息通信
|
||||
Map = 1 << 3, // 游戏场景服
|
||||
Chat = 1 << 4, // 游戏聊天服
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景创建回调。
|
||||
/// <remarks>常用于定义场景需要添加的组件。</remarks>
|
||||
@@ -17,14 +27,14 @@ public class OnCreateScene : AsyncEventSystem<TEngine.OnCreateScene>
|
||||
// 比如Map下你需要一些自定义组件、你也可以在这里操作
|
||||
var sceneConfigInfo = self.SceneInfo;
|
||||
|
||||
switch (sceneConfigInfo.SceneType)
|
||||
switch (sceneConfigInfo.SceneType.Parse<SceneType>())
|
||||
{
|
||||
case "Addressable":
|
||||
case SceneType.Addressable:
|
||||
{
|
||||
sceneConfigInfo.Scene.AddComponent<AddressableManageComponent>();
|
||||
break;
|
||||
}
|
||||
case "Gate":
|
||||
case SceneType.Gate:
|
||||
{
|
||||
sceneConfigInfo.Scene.AddComponent<AccountComponent>();
|
||||
break;
|
||||
|
Reference in New Issue
Block a user