合理化服务器命名,使开发者更容易理解。

Scene的routeId更名为locationId
This commit is contained in:
ALEXTANGXIAO
2023-07-27 00:33:39 +08:00
parent d1c93f15d6
commit b7b2262d53
19 changed files with 134 additions and 150 deletions

View File

@@ -29,9 +29,9 @@ namespace TEngine
public SceneConfig Get(uint id, bool check = true)
{
if (this._configs.TryGetValue(id, out SceneConfig? config))
if (_configs.ContainsKey(id))
{
return config;
return _configs[id];
}
if (check)
@@ -79,7 +79,7 @@ namespace TEngine
[ProtoMember(2, IsRequired = true)]
public long EntityId { get; set; } // 实体Id
[ProtoMember(3, IsRequired = true)]
public uint RouteId { get; set; } // 路由Id
public uint ServerConfigId { get; set; } // 服务配置Id
[ProtoMember(4, IsRequired = true)]
public uint WorldId { get; set; } // 世界Id
[ProtoMember(5, IsRequired = true)]

View File

@@ -7,7 +7,6 @@ namespace TEngine
public const int Addressable = 2;
public const int Map = 3;
public const int Chat = 4;
public const int Gameplay = 5;
public static readonly Dictionary<string, int> SceneDic = new Dictionary<string, int>()
{
@@ -15,7 +14,6 @@ namespace TEngine
{ "Addressable", 2 },
{ "Map", 3 },
{ "Chat", 4 },
{ "Gameplay", 5 },
};
}
}

View File

@@ -10,7 +10,7 @@ public static class AddressableSceneHelper
var sceneEntityId = 0L;
foreach (var sceneConfig in SceneConfigData.Instance.List)
{
if (sceneConfig.RouteId == 3072)
if (sceneConfig.ServerConfigId == 3072)
{
sceneEntityId = sceneConfig.EntityId;
break;

View File

@@ -74,7 +74,7 @@ public static class ConfigTableSystem
SceneType = sceneConfig.SceneType,
Name = sceneConfig.Name,
NetworkProtocol = sceneConfig.NetworkProtocol,
RouteId = sceneConfig.RouteId,
ServerConfigId = sceneConfig.ServerConfigId,
WorldId = sceneConfig.WorldId,
OuterPort = sceneConfig.OuterPort
};
@@ -126,7 +126,7 @@ public static class ConfigTableSystem
SceneType = sceneConfig.SceneType,
Name = sceneConfig.Name,
NetworkProtocol = sceneConfig.NetworkProtocol,
RouteId = sceneConfig.RouteId,
ServerConfigId = sceneConfig.ServerConfigId,
WorldId = sceneConfig.WorldId,
OuterPort = sceneConfig.OuterPort
});

View File

@@ -22,21 +22,15 @@ public enum SceneType: long
/// </summary>
Addressable = 1 << 2,
/// <summary>
/// 场景GamePlay
/// <remarks>游戏玩法服。</remarks>
/// </summary>
Gameplay = 1 << 3,
/// <summary>
/// 游戏场景服。
/// </summary>
Map = 1 << 4,
Map = 1 << 3,
/// <summary>
/// 游戏聊天服。
/// </summary>
Chat = 1 << 5,
Chat = 1 << 4,
}
/// <summary>
@@ -51,24 +45,16 @@ public class OnCreateScene : AsyncEventSystem<TEngine.OnCreateScene>
// OnCreateScene这个事件就是给开发者使用的
// 比如Address协议这里、我就是做了一个管理Address地址的一个组件挂在到Address这个Scene下面了
// 比如Map下你需要一些自定义组件、你也可以在这里操作
var sceneConfigInfo = self.SceneInfo;
switch (sceneConfigInfo.SceneType.Parse<SceneType>())
var scene = self.Scene;
switch (scene.SceneType.Parse<SceneType>())
{
case SceneType.Addressable:
{
sceneConfigInfo.Scene.AddComponent<AddressableManageComponent>();
break;
}
case SceneType.Gate:
{
sceneConfigInfo.Scene.AddComponent<AccountComponent>();
self.Scene.AddComponent<AccountComponent>();
break;
}
case SceneType.Gameplay:
break;
}
Log.Info($"scene create: {self.SceneInfo.SceneType} {self.SceneInfo.Name} SceneId:{self.SceneInfo.Id} ServerId:{self.SceneInfo.RouteId} WorldId:{self.SceneInfo.WorldId}");
Log.Info($"scene create: {self.Scene.SceneType} {self.Scene.Name} SceneId:{self.Scene.Id} LocationId:{self.Scene.LocationId} WorldId:{self.Scene.World?.Id}");
await FTask.CompletedTask;
}