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:
@@ -4,12 +4,23 @@ using BaseGames.Combat;
|
||||
namespace BaseGames.Enemies
|
||||
{
|
||||
/// <summary>
|
||||
/// 飞行敌人。不依赖 PathBerserker2d 导航,直接通过 Rigidbody2D 向玩家移动。
|
||||
/// 接触玩家时造成伤害。
|
||||
/// 飞行敌人基类。
|
||||
///
|
||||
/// 导航由 <see cref="Navigation.FlyingDirectNavigator"/> 实现(IPathAgent),
|
||||
/// AI 行为逻辑由挂载的 Behavior Designer 树驱动。
|
||||
/// 本类仅负责:
|
||||
/// <list type="bullet">
|
||||
/// <item>Rigidbody2D 无重力初始化</item>
|
||||
/// <item>接触伤害(OnTriggerStay2D)</item>
|
||||
/// <item>StopMovement / MoveInDirection 的 Rigidbody2D 快速移动重写</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public class FlyingEnemy : EnemyBase
|
||||
{
|
||||
[SerializeField] private float _chaseSpeed = 3f;
|
||||
[Header("飞行移动(快速覆盖速度)")]
|
||||
[SerializeField] private float _moveSpeed = 3f;
|
||||
|
||||
[Header("接触伤害")]
|
||||
[SerializeField] private DamageSourceSO _contactDamageSource;
|
||||
|
||||
private Rigidbody2D _rb;
|
||||
@@ -20,26 +31,11 @@ namespace BaseGames.Enemies
|
||||
_rb = GetComponent<Rigidbody2D>();
|
||||
if (_rb != null)
|
||||
{
|
||||
_rb.gravityScale = 0f;
|
||||
_rb.constraints = RigidbodyConstraints2D.FreezeRotation;
|
||||
_rb.gravityScale = 0f;
|
||||
_rb.constraints = RigidbodyConstraints2D.FreezeRotation;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (_playerTransform == null || _rb == null) return;
|
||||
if (CurrentState == EnemyStateType.Dead ||
|
||||
CurrentState == EnemyStateType.Stagger) return;
|
||||
|
||||
// 向玩家移动
|
||||
Vector2 targetPos = _playerTransform.position;
|
||||
Vector2 myPos = _rb.position;
|
||||
Vector2 newPos = Vector2.MoveTowards(myPos, targetPos, _chaseSpeed * Time.deltaTime);
|
||||
_rb.MovePosition(newPos);
|
||||
}
|
||||
|
||||
public override void StopMovement()
|
||||
{
|
||||
if (_rb != null) _rb.velocity = Vector2.zero;
|
||||
@@ -47,13 +43,14 @@ namespace BaseGames.Enemies
|
||||
|
||||
public override void MoveInDirection(float dir)
|
||||
{
|
||||
if (_rb != null) _rb.velocity = new Vector2(dir, 0f) * _chaseSpeed;
|
||||
if (_rb != null) _rb.velocity = new Vector2(dir * _moveSpeed, 0f);
|
||||
}
|
||||
|
||||
private void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
if (_contactDamageSource == null) return;
|
||||
if (CurrentState == EnemyStateType.Dead) return;
|
||||
if (_rb == null) return;
|
||||
|
||||
var hurtBox = other.GetComponent<HurtBox>();
|
||||
if (hurtBox == null) return;
|
||||
|
||||
Reference in New Issue
Block a user