摄像机区域的架构改动
This commit is contained in:
38
Assets/_Game/Scripts/World/RoomController.cs
Normal file
38
Assets/_Game/Scripts/World/RoomController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using BaseGames.Camera;
|
||||
using BaseGames.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BaseGames.World
|
||||
{
|
||||
/// <summary>
|
||||
/// 房间控制器。挂在每个房间场景的 [RoomRoot] 下。
|
||||
/// Start 时切换摄像机到该房间的 RoomCamera,并提供出生点查询。
|
||||
/// </summary>
|
||||
public class RoomController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private string _roomId;
|
||||
[SerializeField] private PlayerSpawnPoint[] _spawnPoints;
|
||||
[SerializeField] private CameraArea _cameraArea; // 该房间默认的相机区域
|
||||
|
||||
public string RoomId => _roomId;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_cameraArea != null)
|
||||
ServiceLocator.GetOrDefault<ICameraService>()?.SwitchArea(_cameraArea);
|
||||
}
|
||||
|
||||
/// <summary>通过 transitionId 查找对应的出生点。</summary>
|
||||
public PlayerSpawnPoint GetSpawnPoint(string transitionId)
|
||||
{
|
||||
if (_spawnPoints == null) return null;
|
||||
foreach (var sp in _spawnPoints)
|
||||
{
|
||||
if (sp != null && sp.TransitionId == transitionId)
|
||||
return sp;
|
||||
}
|
||||
// Fallback:返回第一个出生点
|
||||
return _spawnPoints.Length > 0 ? _spawnPoints[0] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user