凍結至1.1.0

This commit is contained in:
Sahik committed 2026-11-25 21:35:17 +08:00
1 parent 4a72bd132a
commit 801dbad504
16 files changed
+627 -21

No files matched your search

@@ -2,7 +2,7 @@ using System.Collections.Generic;
using UnityEngine;
// 模擬 AI 視覺外掛的「眼睛」
// 1. 只在螢幕刷新時取樣 (外掛是擷取畫面,畫面一秒只更新刷新率那麼多次)
// 1. 自動配置 : 每一幀取樣一次 (固定 60 FPS,不因每個人的螢幕而不同) ; 自由 / 測試模式 : 依螢幕刷新率取樣
// 2. 敵人被擋住 25% 以上就偵測不到 (視覺辨識的特性) ; 比例依身體各部位的面積加權 : 頭 15%、身體 45%、腿 40%
// 3. 結果延遲一段時間才給輔助用 (擷取 → 辨識 → 輸出的鏈路延遲)
// 真值 (Truth) 和外掛實際拿到的結果 (Output) 都保留,之後記錄器兩個都存
@@ -36,10 +36,10 @@ public class EnemyPerceptor : MonoBehaviour
public bool showDebug = true;
public Detection Truth { get; private set; } // 每一幀的真值 (完美感知器)
public Detection Output { get; private set; } // 經過刷新率取樣與延遲,輔助真正拿到的結果
public Detection Output { get; private set; } // 經過取樣與延遲,輔助真正拿到的結果
public float DelayMs { get; private set; }
private float sampleInterval;
private float sampleInterval; // 0 = 每一幀
private float nextSampleTime;
private int baseDelayMs;
private int jitterMs;
@@ -65,7 +65,7 @@ public class EnemyPerceptor : MonoBehaviour
// 延遲與抖動由 Apply() 每回合套上,不在這裡讀
GameSettings settings = GameSettings.Load();
int refreshRate = settings.refreshRate > 0 ? settings.refreshRate : 60;
sampleInterval = 1f / refreshRate;
sampleInterval = SessionPlan.IsAuto(settings) ? 0f : 1f / refreshRate;
}
// 套用這一回合的延遲條件,並清掉上一回合的辨識結果 (BotSpawner 在通知記錄器之前呼叫)
@@ -85,7 +85,8 @@ public class EnemyPerceptor : MonoBehaviour
// LateUpdate : 等視角和敵人都更新完,才是這一幀畫面上的樣子
Truth = Perceive();
if (Time.time >= nextSampleTime)
// 暫停時 Time.time 不會前進,不取樣
if (!PauseMenu.IsPaused && Time.time >= nextSampleTime)
{
nextSampleTime = Time.time + sampleInterval;
@@ -196,7 +197,7 @@ public class EnemyPerceptor : MonoBehaviour
if (!showDebug) return;
GUI.Label(new Rect(10, 10, 600, 22),
$"真值 : {(Truth.detected ? "偵測到" : "沒偵測到")} 可見 {Truth.visibleRatio:P0} | 外掛拿到 : {(Output.detected ? "偵測到" : "沒偵測到")} 延遲 {DelayMs:F0}ms 刷新 {1f / sampleInterval:F0}Hz");
$"真值 : {(Truth.detected ? "偵測到" : "沒偵測到")} 可見 {Truth.visibleRatio:P0} | 外掛拿到 : {(Output.detected ? "偵測到" : "沒偵測到")} 延遲 {DelayMs:F0}ms");
if (!string.IsNullOrEmpty(lastBlocker))
{
GUI.Label(new Rect(10, 30, 600, 22), $"擋住最多的物件 : {lastBlocker}");