mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
1、Scene.Create接口增加了一个泛型方法接口。 2、SceneConfig增加了SceneTypeConfig和SceneSubType
1、Scene.Create接口增加了一个泛型方法接口。 2、SceneConfig增加了SceneTypeConfig和SceneSubType
This commit is contained in:
@@ -79,13 +79,13 @@ namespace TEngine
|
||||
[ProtoMember(2, IsRequired = true)]
|
||||
public long EntityId { get; set; } // 实体Id
|
||||
[ProtoMember(3, IsRequired = true)]
|
||||
public uint ServerConfigId { get; set; } // 服务配置Id
|
||||
public uint ServerConfigId { get; set; } // 路由Id
|
||||
[ProtoMember(4, IsRequired = true)]
|
||||
public uint WorldId { get; set; } // 世界Id
|
||||
[ProtoMember(5, IsRequired = true)]
|
||||
public string SceneType { get; set; } // Scene类型
|
||||
[ProtoMember(6, IsRequired = true)]
|
||||
public string Name { get; set; } // 名称
|
||||
public string SceneSubType { get; set; } // Scene子类型
|
||||
[ProtoMember(7, IsRequired = true)]
|
||||
public string NetworkProtocol { get; set; } // 协议类型
|
||||
[ProtoMember(8, IsRequired = true)]
|
||||
|
@@ -1,14 +1,31 @@
|
||||
namespace TEngine
|
||||
{
|
||||
// 生成器自动生成,请不要手动编辑。
|
||||
public class SceneType
|
||||
public static class SceneType
|
||||
{
|
||||
public const int Gate = 1;
|
||||
public const int Addressable = 2;
|
||||
public const int Map = 3;
|
||||
public const int Chat = 4;
|
||||
|
||||
public static readonly Dictionary<string, int> SceneDic = new Dictionary<string, int>()
|
||||
public static readonly Dictionary<string, int> SceneTypeDic = new Dictionary<string, int>()
|
||||
{
|
||||
{ "Gate", 1 },
|
||||
{ "Addressable", 2 },
|
||||
{ "Map", 3 },
|
||||
{ "Chat", 4 },
|
||||
};
|
||||
}
|
||||
|
||||
// 生成器自动生成,请不要手动编辑。
|
||||
public static class SceneSubType
|
||||
{
|
||||
public const int Gate = 1;
|
||||
public const int Addressable = 2;
|
||||
public const int Map = 3;
|
||||
public const int Chat = 4;
|
||||
|
||||
public static readonly Dictionary<string, int> SceneSubTypeDic = new Dictionary<string, int>()
|
||||
{
|
||||
{ "Gate", 1 },
|
||||
{ "Addressable", 2 },
|
||||
|
@@ -19,12 +19,12 @@ public static class AddressableSceneHelper
|
||||
return sceneEntityId;
|
||||
}
|
||||
|
||||
public static long GetSceneEntityIdByType(Logic.SceneType sceneType)
|
||||
public static long GetSceneEntityIdByType(string sceneType)
|
||||
{
|
||||
var sceneEntityId = 0L;
|
||||
foreach (var sceneConfig in SceneConfigData.Instance.List)
|
||||
{
|
||||
if (sceneConfig.SceneType.Parse<Logic.SceneType>() == sceneType)
|
||||
if (sceneConfig.SceneType == sceneType)
|
||||
{
|
||||
sceneEntityId = sceneConfig.EntityId;
|
||||
break;
|
||||
|
@@ -71,8 +71,10 @@ public static class ConfigTableSystem
|
||||
return new SceneConfigInfo()
|
||||
{
|
||||
Id = sceneConfig.Id,
|
||||
SceneType = sceneConfig.SceneType,
|
||||
Name = sceneConfig.Name,
|
||||
SceneType = SceneType.SceneTypeDic[sceneConfig.SceneType],
|
||||
SceneSubType = SceneSubType.SceneSubTypeDic[sceneConfig.SceneSubType],
|
||||
SceneTypeStr = sceneConfig.SceneType,
|
||||
SceneSubTypeStr = sceneConfig.SceneSubType,
|
||||
NetworkProtocol = sceneConfig.NetworkProtocol,
|
||||
ServerConfigId = sceneConfig.ServerConfigId,
|
||||
WorldId = sceneConfig.WorldId,
|
||||
@@ -123,8 +125,10 @@ public static class ConfigTableSystem
|
||||
{
|
||||
Id = sceneConfig.Id,
|
||||
EntityId = sceneConfig.EntityId,
|
||||
SceneType = sceneConfig.SceneType,
|
||||
Name = sceneConfig.Name,
|
||||
SceneType = SceneType.SceneTypeDic[sceneConfig.SceneType],
|
||||
SceneSubType = SceneSubType.SceneSubTypeDic[sceneConfig.SceneSubType],
|
||||
SceneTypeStr = sceneConfig.SceneType,
|
||||
SceneSubTypeStr = sceneConfig.SceneSubType,
|
||||
NetworkProtocol = sceneConfig.NetworkProtocol,
|
||||
ServerConfigId = sceneConfig.ServerConfigId,
|
||||
WorldId = sceneConfig.WorldId,
|
||||
|
@@ -3,36 +3,6 @@ using TEngine.Core.Network;
|
||||
|
||||
namespace TEngine.Logic;
|
||||
|
||||
[Flags]
|
||||
public enum SceneType: long
|
||||
{
|
||||
/// <summary>
|
||||
/// 场景无。
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 场景Gate。
|
||||
/// </summary>
|
||||
Gate = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 场景Addressable。
|
||||
/// <remarks>负责进程间消息通信。</remarks>
|
||||
/// </summary>
|
||||
Addressable = 1 << 2,
|
||||
|
||||
/// <summary>
|
||||
/// 游戏场景服。
|
||||
/// </summary>
|
||||
Map = 1 << 3,
|
||||
|
||||
/// <summary>
|
||||
/// 游戏聊天服。
|
||||
/// </summary>
|
||||
Chat = 1 << 4,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景创建回调。
|
||||
/// <remarks>常用于定义场景需要添加的组件。</remarks>
|
||||
@@ -46,13 +16,19 @@ public class OnCreateScene : AsyncEventSystem<TEngine.OnCreateScene>
|
||||
// 比如Address协议这里、我就是做了一个管理Address地址的一个组件挂在到Address这个Scene下面了
|
||||
// 比如Map下你需要一些自定义组件、你也可以在这里操作
|
||||
var scene = self.Scene;
|
||||
switch (scene.SceneType.Parse<SceneType>())
|
||||
switch (scene.SceneType)
|
||||
{
|
||||
case SceneType.Gate:
|
||||
{
|
||||
self.Scene.AddComponent<AccountComponent>();
|
||||
break;
|
||||
}
|
||||
case SceneType.Addressable:
|
||||
{
|
||||
// 挂载管理Address地址组件
|
||||
scene.AddComponent<AddressableManageComponent>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log.Info($"scene create: {self.Scene.SceneType} {self.Scene.Name} SceneId:{self.Scene.Id} LocationId:{self.Scene.LocationId} WorldId:{self.Scene.World?.Id}");
|
||||
|
||||
|
Reference in New Issue
Block a user