37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
// EnemyManagerCs — 敌人 SoA 热路径 C# 内核(S0 骨架)
|
|
// S0 范围:帧时间监控,完整 Boid 积分在 S1 展开
|
|
using Godot;
|
|
using System;
|
|
|
|
public partial class EnemyManagerCs : Node
|
|
{
|
|
private GodotObject _gdEnemyManager;
|
|
private double _accumMs;
|
|
private int _frames;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_gdEnemyManager = Engine.GetSingleton("EnemyManager");
|
|
// S0 骨架不接管积分,保持 _cs_node = null,让 GDScript fallback 运行
|
|
GD.Print("[EnemyManagerCs] S0 骨架就绪,GDScript fallback 活跞");
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
if (_gdEnemyManager is null) return;
|
|
var t0 = Time.GetTicksUsec();
|
|
|
|
var activeCount = _gdEnemyManager.Get("_active_count").AsInt32();
|
|
_ = activeCount;
|
|
|
|
_accumMs += (Time.GetTicksUsec() - t0) / 1000.0;
|
|
_frames++;
|
|
if (_frames >= 60)
|
|
{
|
|
GD.Print($"[EnemyManagerCs] 帧时间均倦: {_accumMs / _frames:F3} ms " +
|
|
$"(active={activeCount} TODO S1: 启用 Boid 热路径)");
|
|
_accumMs = 0; _frames = 0;
|
|
}
|
|
}
|
|
}
|