feat: Implement Room Streaming System
- Add RoomStreamingManager to manage room loading and unloading based on player proximity. - Create StreamingBudgetConfigSO for memory and performance budgeting of the streaming system. - Introduce TransitionDirector to handle seamless and atmospheric fade transitions between rooms. - Develop WorldGraph to represent room connectivity and facilitate neighbor queries and distance calculations. - Implement RoomNode and RoomEdge classes to structure room data and connections.
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using BaseGames.Core.Events;
|
||||
|
||||
namespace BaseGames.World.Map
|
||||
{
|
||||
@@ -32,6 +33,13 @@ namespace BaseGames.World.Map
|
||||
public bool IsSavePoint;
|
||||
public bool IsShop;
|
||||
public Sprite MapIconOverride; // null = 按 isXxx 自动选择图标
|
||||
|
||||
[Header("流式加载")]
|
||||
[Tooltip("此房间场景资产的预估内存(KB)。\n" +
|
||||
"在 Profiler 中测量场景实际内存后填入,供流式管理器执行内存预算检查使用。\n" +
|
||||
"建议在关卡内容基本定型后更新此值。0 = 未填写,将跳过内存预算检查。")]
|
||||
[Min(0)]
|
||||
public int EstimatedMemoryKB;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -40,6 +48,11 @@ namespace BaseGames.World.Map
|
||||
public string TargetRoomId; // 连接的目标房间 ID
|
||||
public Vector2Int ExitGridPos; // 出口在格子地图上的位置
|
||||
public ExitDirection Direction; // 出口方向
|
||||
|
||||
[Tooltip("此出口触发的过渡类型。\n" +
|
||||
"Seamless:无缝切换(同区域相邻房间首选);\n" +
|
||||
"AtmosphericFade:短暂淡出 + 区域名提示(跨大区域边界首选)。")]
|
||||
public TransitionType PreferredTransitionType;
|
||||
}
|
||||
|
||||
public enum ExitDirection { Up, Down, Left, Right }
|
||||
@@ -61,8 +74,11 @@ namespace BaseGames.World.Map
|
||||
public MapRoomDataSO GetRoom(string roomId)
|
||||
{
|
||||
if (_index == null)
|
||||
{
|
||||
if (AllRooms == null) return null;
|
||||
_index = AllRooms.Where(r => r != null)
|
||||
.ToDictionary(r => r.RoomId);
|
||||
}
|
||||
_index.TryGetValue(roomId, out var r);
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user