< Summary

Information
Class: Lattice.ECS.Framework.Systems.LifetimeSystem
Assembly: Lattice
File(s): /home/runner/work/Sideline/Sideline/godot/scripts/lattice/ECS/Framework/Systems/LifetimeSystem.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 56
Line coverage: 100%
Branch coverage
90%
Covered branches: 9
Total branches: 10
Branch coverage: 90%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Contract()100%11100%
OnInit(...)100%11100%
OnUpdate(...)90%1010100%
OnDestroy(...)100%11100%

File(s)

/home/runner/work/Sideline/Sideline/godot/scripts/lattice/ECS/Framework/Systems/LifetimeSystem.cs

#LineLine coverage
 1using System;
 2using Lattice.Core;
 3using Lattice.ECS.Core;
 4using Lattice.Math;
 5
 6namespace Lattice.ECS.Framework.Systems
 7{
 8    /// <summary>
 9    /// 最小样例生命周期系统。
 10    /// </summary>
 11    public sealed class LifetimeSystem : ISystem
 12    {
 12813        public SystemAuthoringContract Contract => new(
 12814            SystemFrameAccess.ReadWrite,
 12815            SystemGlobalAccess.None,
 12816            SystemStructuralChangeAccess.Deferred);
 17
 18        public void OnInit(Frame frame)
 19        {
 920        }
 21
 22        public void OnUpdate(Frame frame, FP deltaTime)
 23        {
 11924            var query = frame.Query<Lifetime>();
 11925            int capacity = query.Count;
 11926            if (capacity <= 0)
 27            {
 928                return;
 29            }
 30
 11031            Span<EntityRef> expiredEntities = capacity <= 64
 11032                ? stackalloc EntityRef[capacity]
 11033                : new EntityRef[capacity];
 34
 11035            int expiredCount = 0;
 11036            var enumerator = query.GetEnumerator();
 65837            while (enumerator.MoveNext())
 38            {
 54839                enumerator.Component.Remaining -= deltaTime;
 54840                if (enumerator.Component.Remaining <= FP.Zero)
 41                {
 542                    expiredEntities[expiredCount++] = enumerator.CurrentEntity;
 43                }
 44            }
 45
 23046            for (int i = 0; i < expiredCount; i++)
 47            {
 548                frame.DestroyEntity(expiredEntities[i]);
 49            }
 11050        }
 51
 52        public void OnDestroy(Frame frame)
 53        {
 954        }
 55    }
 56}