< Summary

Class:DCL.ECS7.InternalComponents.InternalCollidersExtensions
Assembly:ECS7Plugin.InternalECSComponents.Interfaces
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/InternalECSComponents/Interfaces/Extensions/InternalCollidersExtensions.cs
Covered lines:21
Uncovered lines:2
Coverable lines:23
Total lines:59
Line coverage:91.3% (21 of 23)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:3
Method coverage:100% (3 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AddCollider(...)0%4.034087.5%
HasCollider(...)0%3.043083.33%
RemoveCollider(...)0%550100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/InternalECSComponents/Interfaces/Extensions/InternalCollidersExtensions.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Models;
 3using UnityEngine;
 4
 5namespace DCL.ECS7.InternalComponents
 6{
 7    public static class InternalCollidersExtensions
 8    {
 9        public static void AddCollider(this IInternalECSComponent<InternalColliders> colliderInternalComponent,
 10            IParcelScene scene, IDCLEntity entity, Collider collider, uint colliderLayer)
 11        {
 2212            if (collider is null)
 013                return;
 14
 2215            if (colliderInternalComponent.HasCollider(scene, entity, collider))
 216                return;
 17
 2018            var model = colliderInternalComponent.GetFor(scene, entity)?.model ?? new InternalColliders(new KeyValueSet<
 2019            model.colliders.Add(collider, colliderLayer);
 2020            colliderInternalComponent.PutFor(scene, entity, model);
 2021        }
 22
 23        public static bool HasCollider(this IInternalECSComponent<InternalColliders> colliderInternalComponent,
 24            IParcelScene scene, IDCLEntity entity, Collider collider)
 25        {
 2226            if (collider is null)
 027                return false;
 28
 2229            var compData = colliderInternalComponent.GetFor(scene, entity);
 2230            if (compData != null)
 31            {
 232                return compData.Value.model.colliders.ContainsKey(collider);
 33            }
 34
 2035            return false;
 36        }
 37
 38        public static bool RemoveCollider(this IInternalECSComponent<InternalColliders> colliderInternalComponent,
 39            IParcelScene scene, IDCLEntity entity, Collider collider)
 40        {
 7241            if (collider is null)
 1442                return false;
 43
 5844            var compData = colliderInternalComponent.GetFor(scene, entity);
 45
 5846            if (compData == null)
 1647                return false;
 48
 4249            bool ret = compData.Value.model.colliders.Remove(collider);
 50
 4251            if (ret && compData.Value.model.colliders.Count == 0)
 52            {
 3653                colliderInternalComponent.RemoveFor(scene, entity, new InternalColliders(new KeyValueSet<Collider, uint>
 54            }
 55
 4256            return ret;
 57        }
 58    }
 59}