LCOV - code coverage report
Current view: top level - world/query - active.go Coverage Total Hit
Test: coverage.lcov Lines: 100.0 % 8 8
Test Date: 2026-11-19 00:25:22 Functions: - 0 0

            Line data    Source code
       1              : package query
       2              : 
       3              : import (
       4              :         gc "github.com/kijimaD/ruins/internal/components"
       5              :         w "github.com/kijimaD/ruins/internal/world"
       6              :         "github.com/mlange-42/ark/ecs"
       7              : )
       8              : 
       9              : // ActiveFilterN は現ステージのエンティティだけを対象にするフィルタを返す。
      10              : //
      11              : // 共存方式では全ステージのエンティティが同一 world にいる。ステージ跨ぎのシステムが
      12              : // 退避中ステージのエンティティを巻き込むと、描画・視界・AI・座標索引が混ざる。
      13              : // この関数群は Suspended の除外を1箇所に集約し、各システムが付け忘れないようにする。
      14              : // 生の ecs.NewFilterN でなくこれを使う。付け忘れは silent な leak になる。
      15              : //
      16              : // 追加の除外は返り値へ Without を重ねればよい。ark の Without は除外を累積するので、
      17              : // Suspended に上乗せされる。例: ActiveFilter2[A, B](world).Without(ecs.C[gc.Dead]())。
      18              : //
      19              : // arity 1..4 の重複は ark 自身が Filter1..4 に分かれているのと同じ Go の制約による。
      20              : // 可変長の型パラメータが無いので1関数に畳めない。
      21              : 
      22              : // suspendedExclude は Suspended だけを除外する共有スライス。
      23              : // spread で渡すと毎フレームのホットパスでも再アロケーションを起こさない。
      24              : // Without は読み取り専用で受け取るため共有して安全
      25              : var suspendedExclude = []ecs.Comp{ecs.C[gc.Suspended]()}
      26              : 
      27              : // ActiveFilter1 は現ステージ限定の Filter1 を返す。
      28              : func ActiveFilter1[A any](world w.World) *ecs.Filter1[A] {
      29            1 :         return ecs.NewFilter1[A](world.ECS).Without(suspendedExclude...)
      30            1 : }
      31              : 
      32              : // ActiveFilter2 は現ステージ限定の Filter2 を返す。
      33              : func ActiveFilter2[A, B any](world w.World) *ecs.Filter2[A, B] {
      34            1 :         return ecs.NewFilter2[A, B](world.ECS).Without(suspendedExclude...)
      35            1 : }
      36              : 
      37              : // ActiveFilter3 は現ステージ限定の Filter3 を返す。
      38              : func ActiveFilter3[A, B, C any](world w.World) *ecs.Filter3[A, B, C] {
      39            1 :         return ecs.NewFilter3[A, B, C](world.ECS).Without(suspendedExclude...)
      40            1 : }
      41              : 
      42              : // ActiveFilter4 は現ステージ限定の Filter4 を返す。
      43              : func ActiveFilter4[A, B, C, D any](world w.World) *ecs.Filter4[A, B, C, D] {
      44            1 :         return ecs.NewFilter4[A, B, C, D](world.ECS).Without(suspendedExclude...)
      45            1 : }
        

Generated by: LCOV version 2.0-1