修复编译错误

This commit is contained in:
2026-05-12 21:50:49 +08:00
parent 2b2a74da42
commit 458f344e83
28 changed files with 122 additions and 54 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections; using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Audio; using UnityEngine.Audio;
using BaseGames.Core; using BaseGames.Core;

View File

@@ -18,7 +18,8 @@ namespace BaseGames.Combat
[SerializeField] private VoidEventChannelSO _onShieldRestoredChannel; // 护盾恢复 → 播放恢复 VFX [SerializeField] private VoidEventChannelSO _onShieldRestoredChannel; // 护盾恢复 → 播放恢复 VFX
// ── 运行时属性 ──────────────────────────────────────────────────────── // ── 运行时属性 ────────────────────────────────────────────────────────
public int MaxShieldHP => _config.MaxShieldHP; private int _maxShieldHP;
public int MaxShieldHP => _maxShieldHP;
public int CurrentShieldHP { get; private set; } public int CurrentShieldHP { get; private set; }
/// <summary>当前是否能吸收伤害(护盾 HP > 0 且不在破碎惩罚期)。</summary> /// <summary>当前是否能吸收伤害(护盾 HP > 0 且不在破碎惩罚期)。</summary>
public bool HasShield => CurrentShieldHP > 0 && _brokenPenaltyTimer <= 0f; public bool HasShield => CurrentShieldHP > 0 && _brokenPenaltyTimer <= 0f;
@@ -38,6 +39,7 @@ namespace BaseGames.Combat
private void Awake() private void Awake()
{ {
Debug.Assert(_config != null, "[ShieldComponent] _config 未赋值,请在 Inspector 中指定 ShieldConfigSO。", this); Debug.Assert(_config != null, "[ShieldComponent] _config 未赋值,请在 Inspector 中指定 ShieldConfigSO。", this);
_maxShieldHP = _config != null ? _config.MaxShieldHP : 0;
CurrentShieldHP = MaxShieldHP; CurrentShieldHP = MaxShieldHP;
} }

View File

@@ -1,3 +1,5 @@
using BaseGames.Core.Events;
namespace BaseGames.Core namespace BaseGames.Core
{ {
/// <summary> /// <summary>

View File

@@ -1,4 +1,4 @@
namespace BaseGames.Quest namespace BaseGames.Core.Events
{ {
/// <summary> /// <summary>
/// 奖励接收目标接口(架构 22_QuestChallengeModule §4 /// 奖励接收目标接口(架构 22_QuestChallengeModule §4

View File

@@ -27,6 +27,7 @@ namespace BaseGames.Core.Save
private SaveData _current; private SaveData _current;
private int _currentSlot = 0; private int _currentSlot = 0;
public int CurrentSlot => _currentSlot; public int CurrentSlot => _currentSlot;
public SaveData Data => _current;
public string LastCheckpointScene { get; private set; } public string LastCheckpointScene { get; private set; }
public string LastCheckpointSpawnId { get; private set; } public string LastCheckpointSpawnId { get; private set; }

View File

@@ -1,3 +1,4 @@
using System.Reflection;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using PathBerserker2d; using PathBerserker2d;
@@ -11,6 +12,12 @@ namespace BaseGames.Editor
/// </summary> /// </summary>
public static class NavSurfaceBakeShortcut public static class NavSurfaceBakeShortcut
{ {
// NavSurface.StartBakeJob() 和 NavSurface.BakeJob 均为 internal通过反射访问。
private static readonly MethodInfo s_startBakeJobMethod =
typeof(NavSurface).GetMethod("StartBakeJob", BindingFlags.NonPublic | BindingFlags.Instance);
private static readonly PropertyInfo s_bakeJobProp =
typeof(NavSurface).GetProperty("BakeJob", BindingFlags.NonPublic | BindingFlags.Instance);
[MenuItem("BaseGames/Tools/Bake All NavSurfaces %#b", priority = 100)] [MenuItem("BaseGames/Tools/Bake All NavSurfaces %#b", priority = 100)]
public static void BakeAll() public static void BakeAll()
{ {
@@ -26,7 +33,7 @@ namespace BaseGames.Editor
{ {
if (surface == null) continue; if (surface == null) continue;
surface.StartBakeJob(); s_startBakeJobMethod?.Invoke(surface, null);
EditorApplication.update -= MakeWatcher(surface); EditorApplication.update -= MakeWatcher(surface);
EditorApplication.update += MakeWatcher(surface); EditorApplication.update += MakeWatcher(surface);
count++; count++;
@@ -49,16 +56,28 @@ namespace BaseGames.Editor
EditorApplication.CallbackFunction watcher = null; EditorApplication.CallbackFunction watcher = null;
watcher = () => watcher = () =>
{ {
if (surface == null || surface.BakeJob == null) if (surface == null)
{ {
EditorApplication.update -= watcher; EditorApplication.update -= watcher;
return; return;
} }
if (surface.BakeJob.IsFinished)
var bakeJob = s_bakeJobProp?.GetValue(surface);
if (bakeJob == null)
{
EditorApplication.update -= watcher;
return;
}
bool isFinished = (bool)bakeJob.GetType()
.GetProperty("IsFinished")!.GetValue(bakeJob);
if (isFinished)
{ {
EditorApplication.update -= watcher; EditorApplication.update -= watcher;
EditorUtility.SetDirty(surface); EditorUtility.SetDirty(surface);
Debug.Log($"[NavSurfaceBake] ✓ {surface.name} 烘焙完成({surface.BakeJob.TotalBakeTime} ms"); float totalTime = (float)bakeJob.GetType()
.GetProperty("TotalBakeTime")!.GetValue(bakeJob);
Debug.Log($"[NavSurfaceBake] ✓ {surface.name} 烘焙完成({totalTime} ms");
} }
}; };
return watcher; return watcher;

View File

@@ -10,6 +10,7 @@ using BaseGames.Enemies;
using BaseGames.Input; using BaseGames.Input;
using BaseGames.Player; using BaseGames.Player;
using BaseGames.Player.States; using BaseGames.Player.States;
using BaseGames.Skills;
using BaseGames.UI; using BaseGames.UI;
using BaseGames.UI.HUD; using BaseGames.UI.HUD;
using BaseGames.UI.Menus; using BaseGames.UI.Menus;

View File

@@ -8,9 +8,12 @@
"versionDefines": [], "versionDefines": [],
"rootNamespace": "BaseGames.Enemies.AI", "rootNamespace": "BaseGames.Enemies.AI",
"references": [ "references": [
"BaseGames.Core",
"BaseGames.Core.Events",
"BaseGames.Enemies", "BaseGames.Enemies",
"BaseGames.Enemies.Boss.Patterns", "BaseGames.Enemies.Boss.Patterns",
"Opsive.BehaviorDesigner.Runtime" "Opsive.BehaviorDesigner.Runtime",
"Kybernetik.Animancer"
], ],
"autoReferenced": true, "autoReferenced": true,
"overrideReferences": false, "overrideReferences": false,

View File

@@ -1,27 +0,0 @@
using UnityEngine;
namespace BaseGames.Enemies
{
/// <summary>
/// BatchLOSSystem 的注册接口(架构 07_EnemyModule §12
/// 实现此接口的 EnemyBase 子类可以注册到 BatchLOSSystem
/// 以批处理方式接收 LOSLine of Sight检测结果。
/// </summary>
public interface ILOSRequester
{
/// <summary>射线起点(通常是眼部位置)。</summary>
Vector2 LOSOrigin { get; }
/// <summary>射线终点(通常是玩家位置)。</summary>
Vector2 LOSTarget { get; }
/// <summary>遮挡 LOS 的物理图层。</summary>
LayerMask LOSBlockingMask { get; }
/// <summary>
/// 接收 LOS 检测结果。
/// <paramref name="hasLineOfSight"/>: true = 有视线false = 被遮挡。
/// </summary>
void ReceiveLOSResult(bool hasLineOfSight);
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c504654ba79100742a30b448b0233d63
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -8,6 +8,8 @@
"versionDefines": [], "versionDefines": [],
"rootNamespace": "BaseGames.Enemies.Boss.Patterns", "rootNamespace": "BaseGames.Enemies.Boss.Patterns",
"references": [ "references": [
"BaseGames.Core",
"BaseGames.Core.Events",
"BaseGames.Enemies", "BaseGames.Enemies",
"BaseGames.Combat" "BaseGames.Combat"
], ],

View File

@@ -28,7 +28,7 @@ namespace BaseGames.Equipment
public float chance; // 触发概率0~1 public float chance; // 触发概率0~1
private HitConfirmedEventChannelSO _onHitChannel; private HitConfirmedEventChannelSO _onHitChannel;
private EventSubscription _sub; private EventSubscription? _sub;
public void OnEquip(EquipmentContext ctx) public void OnEquip(EquipmentContext ctx)
{ {

View File

@@ -1,4 +1,5 @@
using System; using System;
using BaseGames.Player;
namespace BaseGames.Equipment namespace BaseGames.Equipment
{ {

View File

@@ -8,7 +8,8 @@
"versionDefines": [], "versionDefines": [],
"rootNamespace": "BaseGames.Localization", "rootNamespace": "BaseGames.Localization",
"references": [ "references": [
"BaseGames.Core.Events" "BaseGames.Core.Events",
"BaseGames.Core.Save"
], ],
"autoReferenced": true, "autoReferenced": true,
"overrideReferences": false, "overrideReferences": false,

View File

@@ -84,10 +84,10 @@ namespace BaseGames.Localization
} }
/// <summary> /// <summary>
/// 获取本地化字符串(实例方法)。 /// 获取本地化字符串(显式接口实现)。
/// 查找顺序:当前语言 → 回退语言English→ 直接返回 key。 /// 查找顺序:当前语言 → 回退语言English→ 直接返回 key。
/// </summary> /// </summary>
public string Get(string key, string table = "UI") string ILocalizationService.Get(string key, string table)
{ {
if (string.IsNullOrEmpty(key)) return string.Empty; if (string.IsNullOrEmpty(key)) return string.Empty;
@@ -134,7 +134,9 @@ namespace BaseGames.Localization
dict = LoadTable(language, table); dict = LoadTable(language, table);
_cache[cacheKey] = dict; // 即使加载失败也存入空字典,避免每帧重试 _cache[cacheKey] = dict; // 即使加载失败也存入空字典,避免每帧重试
} }
return dict != null && dict.TryGetValue(key, out value); if (dict != null && dict.TryGetValue(key, out value)) return true;
value = null;
return false;
} }
/// <summary> /// <summary>

View File

@@ -3,7 +3,6 @@ using UnityEngine;
using BaseGames.Core; using BaseGames.Core;
using BaseGames.Core.Events; using BaseGames.Core.Events;
using BaseGames.Core.Save; using BaseGames.Core.Save;
using BaseGames.Quest;
namespace BaseGames.Player namespace BaseGames.Player
{ {

View File

@@ -8,13 +8,15 @@
"versionDefines": [], "versionDefines": [],
"rootNamespace": "BaseGames.Quest", "rootNamespace": "BaseGames.Quest",
"references": [ "references": [
"BaseGames.Core",
"BaseGames.Core.Events", "BaseGames.Core.Events",
"BaseGames.Core.Save", "BaseGames.Core.Save",
"BaseGames.Player", "BaseGames.Player",
"BaseGames.World", "BaseGames.World",
"BaseGames.Enemies", "BaseGames.Enemies",
"BaseGames.Dialogue", "BaseGames.Dialogue",
"Unity.Addressables" "Unity.Addressables",
"Unity.ResourceManager"
], ],
"autoReferenced": true, "autoReferenced": true,
"overrideReferences": false, "overrideReferences": false,

View File

@@ -1,3 +1,4 @@
using BaseGames.Core.Events;
using QuestStateEnum = BaseGames.Core.Events.QuestState; using QuestStateEnum = BaseGames.Core.Events.QuestState;
namespace BaseGames.Quest namespace BaseGames.Quest

View File

@@ -12,6 +12,7 @@
"BaseGames.Input", "BaseGames.Input",
"BaseGames.Player", "BaseGames.Player",
"BaseGames.Combat", "BaseGames.Combat",
"BaseGames.Skills",
"Kybernetik.Animancer" "Kybernetik.Animancer"
], ],
"autoReferenced": true, "autoReferenced": true,

View File

@@ -66,7 +66,7 @@ namespace BaseGames.Support.AntiSoftlock
if (_player == null || !_player.Stats.IsAlive) return; if (_player == null || !_player.Stats.IsAlive) return;
Vector2 pos = _player.transform.position; Vector2 pos = _player.transform.position;
float vel = _playerRb != null ? _playerRb.linearVelocity.magnitude : Vector2.Distance(pos, _lastPos) / Time.deltaTime; float vel = _playerRb != null ? _playerRb.velocity.magnitude : Vector2.Distance(pos, _lastPos) / Time.deltaTime;
if (vel > _minVelocityThreshold) if (vel > _minVelocityThreshold)
{ {

View File

@@ -14,7 +14,8 @@
"BaseGames.Progression", "BaseGames.Progression",
"BaseGames.Platform", "BaseGames.Platform",
"Unity.TextMeshPro", "Unity.TextMeshPro",
"Unity.RenderPipelines.Universal.Runtime" "Unity.RenderPipelines.Universal.Runtime",
"Unity.RenderPipelines.Core.Runtime"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@@ -12,7 +12,9 @@ namespace BaseGames.Tutorial
{ {
[SerializeField] private GameObject _panel; [SerializeField] private GameObject _panel;
[SerializeField] private TMP_Text _label; [SerializeField] private TMP_Text _label;
#pragma warning disable CS0414
[SerializeField] private float _fadeSpeed = 4f; [SerializeField] private float _fadeSpeed = 4f;
#pragma warning restore CS0414
private Coroutine _autoHideCoroutine; private Coroutine _autoHideCoroutine;

View File

@@ -8,7 +8,9 @@ namespace BaseGames.World
/// </summary> /// </summary>
public class DestructibleTile : MonoBehaviour, IDamageable public class DestructibleTile : MonoBehaviour, IDamageable
{ {
#pragma warning disable CS0414
[SerializeField] private int _maxHP = 1; [SerializeField] private int _maxHP = 1;
#pragma warning restore CS0414
[SerializeField] private string _destructedId; [SerializeField] private string _destructedId;
/// <summary> /// <summary>
/// ScriptableObject 注入(非静态 Instance /// ScriptableObject 注入(非静态 Instance

View File

@@ -13,7 +13,9 @@ namespace BaseGames.World
[SerializeField] private bool _isInstantKill = true; [SerializeField] private bool _isInstantKill = true;
[SerializeField] private int _damage = 9999; [SerializeField] private int _damage = 9999;
#pragma warning disable CS0414
[SerializeField] private RespawnType _respawnType = RespawnType.AtLastSavePoint; [SerializeField] private RespawnType _respawnType = RespawnType.AtLastSavePoint;
#pragma warning restore CS0414
private void OnTriggerEnter2D(Collider2D other) private void OnTriggerEnter2D(Collider2D other)
{ {

View File

@@ -19,8 +19,10 @@ namespace BaseGames.World.Liquid
[SerializeField] private string _zoneId; [SerializeField] private string _zoneId;
[Header("伤害Water 类型专用Acid/Lava 由子节点 HazardZone 处理)")] [Header("伤害Water 类型专用Acid/Lava 由子节点 HazardZone 处理)")]
#pragma warning disable CS0414
[SerializeField] private bool _dealsDrowningDamage = false; [SerializeField] private bool _dealsDrowningDamage = false;
[SerializeField] private float _drowningDamagePerSecond = 5f; [SerializeField] private float _drowningDamagePerSecond = 5f;
#pragma warning restore CS0414
[Header("物理配置")] [Header("物理配置")]
[SerializeField] private LiquidPhysicsConfigSO _physicsConfig; [SerializeField] private LiquidPhysicsConfigSO _physicsConfig;

View File

@@ -235,6 +235,15 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
""processors"": """", ""processors"": """",
""interactions"": """", ""interactions"": """",
""initialStateCheck"": false ""initialStateCheck"": false
},
{
""name"": ""Spell"",
""type"": ""Button"",
""id"": ""7fa3801f-a2db-4ea0-a8f4-2ed90f7ecd8f"",
""expectedControlType"": """",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
} }
], ],
""bindings"": [ ""bindings"": [
@@ -556,6 +565,17 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
""action"": ""Pause"", ""action"": ""Pause"",
""isComposite"": false, ""isComposite"": false,
""isPartOfComposite"": false ""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""d10abe98-84d1-4c7f-a6d2-5f1919026dd5"",
""path"": """",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Spell"",
""isComposite"": false,
""isPartOfComposite"": false
} }
] ]
}, },
@@ -804,6 +824,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
m_Gameplay_SpiritSkill2 = m_Gameplay.FindAction("SpiritSkill2", throwIfNotFound: true); m_Gameplay_SpiritSkill2 = m_Gameplay.FindAction("SpiritSkill2", throwIfNotFound: true);
m_Gameplay_Interact = m_Gameplay.FindAction("Interact", throwIfNotFound: true); m_Gameplay_Interact = m_Gameplay.FindAction("Interact", throwIfNotFound: true);
m_Gameplay_Pause = m_Gameplay.FindAction("Pause", throwIfNotFound: true); m_Gameplay_Pause = m_Gameplay.FindAction("Pause", throwIfNotFound: true);
m_Gameplay_Spell = m_Gameplay.FindAction("Spell", throwIfNotFound: true);
// UI // UI
m_UI = asset.FindActionMap("UI", throwIfNotFound: true); m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
m_UI_Navigate = m_UI.FindAction("Navigate", throwIfNotFound: true); m_UI_Navigate = m_UI.FindAction("Navigate", throwIfNotFound: true);
@@ -908,6 +929,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
private readonly InputAction m_Gameplay_SpiritSkill2; private readonly InputAction m_Gameplay_SpiritSkill2;
private readonly InputAction m_Gameplay_Interact; private readonly InputAction m_Gameplay_Interact;
private readonly InputAction m_Gameplay_Pause; private readonly InputAction m_Gameplay_Pause;
private readonly InputAction m_Gameplay_Spell;
/// <summary> /// <summary>
/// Provides access to input actions defined in input action map "Gameplay". /// Provides access to input actions defined in input action map "Gameplay".
/// </summary> /// </summary>
@@ -984,6 +1006,10 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
/// </summary> /// </summary>
public InputAction @Pause => m_Wrapper.m_Gameplay_Pause; public InputAction @Pause => m_Wrapper.m_Gameplay_Pause;
/// <summary> /// <summary>
/// Provides access to the underlying input action "Gameplay/Spell".
/// </summary>
public InputAction @Spell => m_Wrapper.m_Gameplay_Spell;
/// <summary>
/// Provides access to the underlying input action map instance. /// Provides access to the underlying input action map instance.
/// </summary> /// </summary>
public InputActionMap Get() { return m_Wrapper.m_Gameplay; } public InputActionMap Get() { return m_Wrapper.m_Gameplay; }
@@ -1057,6 +1083,9 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
@Pause.started += instance.OnPause; @Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause; @Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause; @Pause.canceled += instance.OnPause;
@Spell.started += instance.OnSpell;
@Spell.performed += instance.OnSpell;
@Spell.canceled += instance.OnSpell;
} }
/// <summary> /// <summary>
@@ -1116,6 +1145,9 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
@Pause.started -= instance.OnPause; @Pause.started -= instance.OnPause;
@Pause.performed -= instance.OnPause; @Pause.performed -= instance.OnPause;
@Pause.canceled -= instance.OnPause; @Pause.canceled -= instance.OnPause;
@Spell.started -= instance.OnSpell;
@Spell.performed -= instance.OnSpell;
@Spell.canceled -= instance.OnSpell;
} }
/// <summary> /// <summary>
@@ -1434,6 +1466,13 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" /> /// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" /> /// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnPause(InputAction.CallbackContext context); void OnPause(InputAction.CallbackContext context);
/// <summary>
/// Method invoked when associated input action "Spell" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnSpell(InputAction.CallbackContext context);
} }
/// <summary> /// <summary>
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "UI" which allows adding and removing callbacks. /// Interface to implement callback methods for all input action callbacks associated with input actions defined by "UI" which allows adding and removing callbacks.

View File

@@ -149,6 +149,15 @@
"processors": "", "processors": "",
"interactions": "", "interactions": "",
"initialStateCheck": false "initialStateCheck": false
},
{
"name": "Spell",
"type": "Button",
"id": "7fa3801f-a2db-4ea0-a8f4-2ed90f7ecd8f",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
} }
], ],
"bindings": [ "bindings": [
@@ -470,6 +479,17 @@
"action": "Pause", "action": "Pause",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
},
{
"name": "",
"id": "d10abe98-84d1-4c7f-a6d2-5f1919026dd5",
"path": "",
"interactions": "",
"processors": "",
"groups": "",
"action": "Spell",
"isComposite": false,
"isPartOfComposite": false
} }
] ]
}, },