LCOV - code coverage report
Current view: top level - world/lifecycle - cube.go Coverage Total Hit
Test: coverage.lcov Lines: 88.9 % 18 16
Test Date: 2026-11-19 00:25:22 Functions: - 0 0

            Line data    Source code
       1              : package lifecycle
       2              : 
       3              : import (
       4              :         "github.com/kijimaD/ruins/internal/consts"
       5              :         w "github.com/kijimaD/ruins/internal/world"
       6              :         "github.com/kijimaD/ruins/internal/world/query"
       7              :         "github.com/mlange-42/ark/ecs"
       8              : )
       9              : 
      10              : // AddCubeFuel は fuel の燃焼熱量を上限までキューブの燃料ポイントへ足して fuel を消す。満タンなら何もせず false を返す。
      11              : func AddCubeFuel(world w.World, cube ecs.Entity, fuel ecs.Entity) bool {
      12            1 :         if !world.Components.FuelTank.Has(cube) {
      13            0 :                 return false
      14            0 :         }
      15            1 :         tank := world.Components.FuelTank.Get(cube)
      16            1 :         if tank.Current >= tank.Max {
      17            1 :                 return false
      18            1 :         }
      19            1 :         tank.Current = min(tank.Max, tank.Current+query.HeatContent(world, fuel))
      20            1 :         world.ECS.RemoveEntity(fuel)
      21            1 :         return true
      22              : }
      23              : 
      24              : // ConsumeCubeFuel はキューブの燃料ポイントを amount 減らす。足りていれば減らして true、
      25              : // 足りなければ何も減らさず false を返す。
      26              : func ConsumeCubeFuel(world w.World, cube ecs.Entity, amount consts.Heat) bool {
      27            1 :         if amount <= 0 {
      28            1 :                 return true
      29            1 :         }
      30            1 :         if query.CubeFuelTotal(world, cube) < amount {
      31            1 :                 return false
      32            1 :         }
      33            1 :         world.Components.FuelTank.Get(cube).Current -= amount
      34            1 :         return true
      35              : }
        

Generated by: LCOV version 2.0-1