Checkpoint 5 & Checkpoint 6:

- SimulationWorld 只做逻辑计算与数据输出,不再直接写 Transform
- 在 ShowEntitySuccess 中接入 Pickup/Projectile 占位注册:
	- Drop 走 UpsertPickup(...)
	- Bullet/Projectile 走 UpsertProjectile(...)
- 在 HideEntityComplete 中接入对应回收:
	- Drop 走 RemovePickupByEntityId(...)
	- Bullet/Projectile 走 RemoveProjectileByEntityId(...)
- 新增占位数据构造:
	- CreatePickupSimData(...)
	- CreateProjectileSimData(...)
- 调整 EnemyManagerComponent 职责,现在只管“敌人相关”:
	- 敌人刷怪节奏
	- 敌人列表缓存与计数
	- 玩家引用与 enemy.SetTarget(...)
- 新增嵌套类 SimulationWorld.Presentation,专门消费 EnemySimData 并回写 position/rotation
- 新增嵌套类 SimulationWorld.EntitySync 负责“Simulation 同步”:
	- 监听 ShowEntitySuccess/HideEntityComplete
	- 同步 Enemy/Drop/Projectile 到 SimulationWorld
	- 敌人 SimData 构建、Pickup/Projectile 占位数据构建
This commit is contained in:
SepComet
2026-02-20 20:41:22 +08:00
parent 6494ebc5fd
commit 31fe7a4d61
16 changed files with 339 additions and 98 deletions
@@ -1,12 +1,10 @@
using System.Collections.Generic;
using Components;
using DataTable;
using Definition.Enum;
using Entity;
using Entity.EntityData;
using GameFramework.Event;
using Procedure;
using Simulation;
using StarForce;
using UnityEngine;
using UnityGameFramework.Runtime;
@@ -17,6 +15,7 @@ namespace CustomComponent
public class EnemyManagerComponent : GameFrameworkComponent
{
private const float MinSpawnRateScale = 0.1f;
private const string EnemyGroupName = "Enemy";
private EntityComponent _entity;
@@ -211,21 +210,14 @@ namespace CustomComponent
{
if (!(e is ShowEntitySuccessEventArgs ne)) return;
if (ne.Entity.Logic is EnemyBase enemy)
string entityGroupName = ne.Entity?.EntityGroup?.Name;
if (entityGroupName == EnemyGroupName && ne.Entity.Logic is EnemyBase enemy)
{
_currentEnemyCount++;
enemy.SetTarget(_player);
RemoveEnemyFromCache(enemy.Id);
_enemies.Add(enemy);
if (ne.UserData is EnemyData enemyData)
{
GameEntry.SimulationWorld?.UpsertEnemy(CreateEnemySimData(enemy, enemyData));
}
else
{
GameEntry.SimulationWorld?.UpsertEnemy(CreateEnemySimData(enemy, null));
}
}
if (ne.EntityLogicType == typeof(Player))
@@ -238,7 +230,8 @@ namespace CustomComponent
{
if (e is HideEntityCompleteEventArgs ne)
{
if (ne.EntityGroup.Name == "Enemy")
string entityGroupName = ne.EntityGroup.Name;
if (entityGroupName == EnemyGroupName)
{
if (_currentEnemyCount > 0)
{
@@ -246,30 +239,10 @@ namespace CustomComponent
}
RemoveEnemyFromCache(ne.EntityId);
GameEntry.SimulationWorld?.RemoveEnemyByEntityId(ne.EntityId);
}
}
}
private static EnemySimData CreateEnemySimData(EnemyBase enemy, EnemyData enemyData)
{
MovementComponent movementComponent = enemy != null ? enemy.GetComponent<MovementComponent>() : null;
return new EnemySimData
{
EntityId = enemy.Id,
Position = enemy.CachedTransform.position,
Forward = enemy.CachedTransform.forward,
Speed = enemyData != null ? enemyData.SpeedBase : 0f,
AttackRange = 1f,
AvoidEnemyOverlap = movementComponent != null && movementComponent.AvoidEnemyOverlap,
EnemyBodyRadius = movementComponent != null ? movementComponent.EnemyBodyRadius : 0.45f,
SeparationIterations = movementComponent != null ? movementComponent.SeparationIterations : 2,
TargetType = 0,
State = 0
};
}
private void RemoveEnemyFromCache(int entityId)
{
for (int i = _enemies.Count - 1; i >= 0; i--)