< Summary

Class:EntityListView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/Inspector/EntityListView.cs
Covered lines:1
Uncovered lines:22
Coverable lines:23
Total lines:53
Line coverage:4.3% (1 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AddAdapters()0%20400%
RemoveAdapters()0%20400%
EntityActionInvoked(...)0%6200%
EntityRename(...)0%6200%
SetActive(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/Inspector/EntityListView.cs

#LineLine coverage
 1using UnityEngine;
 2
 3public class EntityListView : ListView<BIWEntity>
 4{
 5    [SerializeField] internal EntityListAdapter entityListAdapter;
 6    [SerializeField] internal DynamicScrollSensitivity dynamicScrollSensitivity;
 7
 8    public System.Action<EntityAction, BIWEntity, EntityListAdapter> OnActionInvoked;
 9    public System.Action<BIWEntity, string> OnEntityRename;
 10
 111    public bool isActive => gameObject.activeSelf;
 12
 13    public override void AddAdapters()
 14    {
 015        base.AddAdapters();
 16
 017        foreach (BIWEntity entity in contentList)
 18        {
 019            if (entity.isFloor)
 20                continue;
 021            EntityListAdapter adapter = Instantiate(entityListAdapter, contentPanelTransform).GetComponent<EntityListAda
 022            adapter.SetContent(entity);
 023            adapter.OnActionInvoked += EntityActionInvoked;
 024            adapter.OnEntityRename += EntityRename;
 25        }
 26
 027        if (dynamicScrollSensitivity != null)
 028            dynamicScrollSensitivity.RecalculateSensitivity();
 029    }
 30
 31    public override void RemoveAdapters()
 32    {
 033        for (int i = 0; i < contentPanelTransform.transform.childCount; i++)
 34        {
 035            EntityListAdapter toRemove = contentPanelTransform.transform.GetChild(i).gameObject.GetComponent<EntityListA
 036            if (toRemove != null)
 37            {
 038                toRemove.OnActionInvoked -= EntityActionInvoked;
 039                toRemove.OnEntityRename -= EntityRename;
 40            }
 041            Destroy(toRemove.gameObject);
 42        }
 43
 044        if (dynamicScrollSensitivity != null)
 045            dynamicScrollSensitivity.RecalculateSensitivity();
 046    }
 47
 048    public void EntityActionInvoked(EntityAction action, BIWEntity entityToApply, EntityListAdapter adapter) { OnActionI
 49
 050    public void EntityRename(BIWEntity entity, string newName) { OnEntityRename?.Invoke(entity, newName); }
 51
 052    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 53}