< Summary

Class:DCL.ECSRuntime.ECSComponentsGroupWithout[T1]
Assembly:DCL.ECSRuntime.ComponentsGroup
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/ECSRuntime/ComponentsGroup/ECSComponentsGroupWithoutSingle.cs
Covered lines:27
Uncovered lines:2
Coverable lines:29
Total lines:89
Line coverage:93.1% (27 of 29)
Covered branches:0
Total branches:0
Covered methods:10
Total methods:10
Method coverage:100% (10 of 10)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ECSComponentsGroupWithout(...)0%110100%
DCL.ECSRuntime.IECSReadOnlyComponentsGroup<T1>.get_group()0%110100%
MatchEntity(...)0%220100%
ShouldAddOnComponentAdd(...)0%110100%
ShouldRemoveOnComponentRemove(...)0%110100%
ShouldAddOnComponentRemove(...)0%110100%
ShouldRemoveOnComponentAdd(...)0%110100%
Add(...)0%110100%
Remove(...)0%3.143075%
Update(...)0%3.043083.33%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/ECSRuntime/ComponentsGroup/ECSComponentsGroupWithoutSingle.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Models;
 3using System.Collections.Generic;
 4using UnityEngine.Assertions;
 5
 6namespace DCL.ECSRuntime
 7{
 8    public class ECSComponentsGroupWithout<T1> : IECSComponentsGroup, IECSReadOnlyComponentsGroup<T1>
 9    {
 10        private readonly IECSComponent component1;
 11        private readonly IECSComponent excludedComponent;
 1612        private readonly List<ECSComponentsGroupData<T1>> list = new List<ECSComponentsGroupData<T1>>();
 13
 914        IReadOnlyList<ECSComponentsGroupData<T1>> IECSReadOnlyComponentsGroup<T1>.group => list;
 15
 1616        public ECSComponentsGroupWithout(IECSComponent component1, IECSComponent excludedComponent)
 17        {
 1618            Assert.IsNotNull(component1, $"component must not be null");
 1619            Assert.IsNotNull(excludedComponent, $"excludedComponent must not be null");
 1620            this.component1 = component1;
 1621            this.excludedComponent = excludedComponent;
 1622        }
 23
 24        bool IECSComponentsGroup.MatchEntity(IParcelScene scene, IDCLEntity entity)
 25        {
 1426            return component1.HasComponent(scene, entity) && !excludedComponent.HasComponent(scene, entity);
 27        }
 28
 29        bool IECSComponentsGroup.ShouldAddOnComponentAdd(IECSComponent component)
 30        {
 3431            return component == this.component1;
 32        }
 33
 34        bool IECSComponentsGroup.ShouldRemoveOnComponentRemove(IECSComponent component)
 35        {
 336            return component == this.component1;
 37        }
 38
 39        bool IECSComponentsGroup.ShouldAddOnComponentRemove(IECSComponent component)
 40        {
 641            return component == excludedComponent;
 42        }
 43
 44        bool IECSComponentsGroup.ShouldRemoveOnComponentAdd(IECSComponent component)
 45        {
 446            return component == excludedComponent;
 47        }
 48
 49        void IECSComponentsGroup.Add(IParcelScene scene, IDCLEntity entity)
 50        {
 951            ((ECSComponent<T1>)component1).TryGet(scene, entity.entityId, out var componentData);
 52
 953            ECSComponentsGroupData<T1> data = new ECSComponentsGroupData<T1>
 54            (
 55                scene: scene,
 56                entity: entity,
 57                componentData: componentData
 58            );
 59
 960            list.Add(data);
 961        }
 62
 63        bool IECSComponentsGroup.Remove(IDCLEntity entity)
 64        {
 1465            for (int i = 0; i < list.Count; i++)
 66            {
 767                ECSComponentsGroupData<T1> data = list[i];
 68
 769                if (data.entity != entity)
 70                    continue;
 71
 772                list.RemoveAt(i);
 773                return true;
 74            }
 75
 076            return false;
 77        }
 78
 79        void IECSComponentsGroup.Update(IParcelScene scene, IDCLEntity entity, IECSComponent component)
 80        {
 181            long entityId = entity.entityId;
 182            if (!Utils.TryGetDataIndex(list, entity, out int index))
 083                return;
 84
 185            if (Utils.TryGetComponentData<T1>(scene, entityId, component1, component, out var d1))
 186                list[index] = new ECSComponentsGroupData<T1>(scene, entity, d1);
 187        }
 88    }
 89}