飞机场存档2
This commit is contained in:
@@ -159,10 +159,8 @@ public class SitPosData : MonoBehaviour
|
||||
currentTurret = found;
|
||||
currentTurretNumber = found.turretNumber;
|
||||
|
||||
Transform parent = turretParent != null ? turretParent : transform;
|
||||
tra_CurrTurret = currentTurret.transform.parent != parent
|
||||
? currentTurret.transform.parent
|
||||
: currentTurret.transform;
|
||||
// 缓存旋转节点:优先用 TurretData.tra_RotationPivot,否则回退父节点
|
||||
tra_CurrTurret = GetTurretRotationPivot(currentTurret);
|
||||
|
||||
OnStateChange = currentTurret.ChangeState;
|
||||
UpdateTurretWorldPos();
|
||||
@@ -259,6 +257,24 @@ public class SitPosData : MonoBehaviour
|
||||
|
||||
// ==================== 炮台加载 ====================
|
||||
|
||||
/// <summary>
|
||||
/// 获取炮台的旋转节点。
|
||||
/// - 若 TurretData.tra_RotationPivot 已赋值 → 用它(精确指定旋转中心)
|
||||
/// - 否则回退旧逻辑:炮台父节点(Normal 克隆的中间容器 / XJMH 子对象的父节点)
|
||||
/// </summary>
|
||||
private Transform GetTurretRotationPivot(TurretData turret)
|
||||
{
|
||||
if (turret == null) return null;
|
||||
|
||||
// 优先用 TurretData 上配置的旋转节点
|
||||
if (turret.tra_RotationPivot != null)
|
||||
return turret.tra_RotationPivot;
|
||||
|
||||
// 回退:用父节点(兼容旧逻辑)
|
||||
Transform parent = turret.transform.parent;
|
||||
return parent != null ? parent : turret.transform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据炮台编号加载炮台。
|
||||
/// Normal 模式:从 Addressables 加载预制体并克隆到 turretParent。
|
||||
@@ -319,8 +335,8 @@ public class SitPosData : MonoBehaviour
|
||||
|
||||
currentTurret.turretNumber = turretNumber;
|
||||
|
||||
// 缓存旋转节点
|
||||
tra_CurrTurret = currentTurret.transform.parent;
|
||||
// 缓存旋转节点:优先用 TurretData.tra_RotationPivot,否则回退父节点
|
||||
tra_CurrTurret = GetTurretRotationPivot(currentTurret);
|
||||
|
||||
// 绑定状态机入口
|
||||
OnStateChange = currentTurret.ChangeState;
|
||||
@@ -384,10 +400,8 @@ public class SitPosData : MonoBehaviour
|
||||
|
||||
currentTurretNumber = turretNumber;
|
||||
currentTurret = found;
|
||||
// 炮台若挂在中间旋转容器下,用容器作为旋转节点;否则用炮台自身
|
||||
tra_CurrTurret = currentTurret.transform.parent != parent
|
||||
? currentTurret.transform.parent
|
||||
: currentTurret.transform;
|
||||
// 缓存旋转节点:优先用 TurretData.tra_RotationPivot,否则回退父节点
|
||||
tra_CurrTurret = GetTurretRotationPivot(currentTurret);
|
||||
|
||||
OnStateChange = currentTurret.ChangeState;
|
||||
UpdateTurretWorldPos();
|
||||
|
||||
Reference in New Issue
Block a user