< Summary

Class:InspectorController
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/Inspector/InspectorController.cs
Covered lines:31
Uncovered lines:7
Coverable lines:38
Total lines:129
Line coverage:81.5% (31 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize(...)0%110100%
Dispose()0%110100%
OpenEntityList()0%4.123050%
SetEntityList(...)0%4.254075%
ClearList()0%2.062075%
CloseList()0%2.062075%
EntityActionInvoked(...)0%990100%
EntityRename(...)0%220100%
SetCloseButtonsAction(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine.Events;
 4
 5public enum EntityAction
 6{
 7    SELECT = 0,
 8    LOCK = 1,
 9    DELETE = 2,
 10    SHOW = 3
 11}
 12
 13public interface IInspectorController
 14{
 15    event Action<BIWEntity> OnEntityClick;
 16    event Action<BIWEntity> OnEntityDelete;
 17    event Action<BIWEntity> OnEntityLock;
 18    event Action<BIWEntity> OnEntityChangeVisibility;
 19    event Action<BIWEntity, string> OnEntityRename;
 20
 21    ISceneLimitsController sceneLimitsController { get; }
 22
 23    void Initialize(IInspectorView inspectorView);
 24    void Dispose();
 25    void OpenEntityList();
 26    void SetEntityList(List<BIWEntity> sceneEntities);
 27    void ClearList();
 28    void CloseList();
 29    void EntityActionInvoked(EntityAction action, BIWEntity entityToApply, EntityListAdapter adapter);
 30    void EntityRename(BIWEntity entity, string newName);
 31    void SetCloseButtonsAction(UnityAction call);
 32}
 33
 34public class InspectorController : IInspectorController
 35{
 36    public event Action<BIWEntity> OnEntityClick;
 37    public event Action<BIWEntity> OnEntityDelete;
 38    public event Action<BIWEntity> OnEntityLock;
 39    public event Action<BIWEntity> OnEntityChangeVisibility;
 40    public event Action<BIWEntity, string> OnEntityRename;
 41
 042    public ISceneLimitsController sceneLimitsController => inspectorView.sceneLimitsController;
 43
 44    internal IInspectorView inspectorView;
 45
 46    public void Initialize(IInspectorView inspectorView)
 47    {
 1048        this.inspectorView = inspectorView;
 49
 1050        inspectorView.OnEntityActionInvoked += EntityActionInvoked;
 1051        inspectorView.OnEntityRename += EntityRename;
 52
 1053        inspectorView.ConfigureSceneLimits(new SceneLimitsController());
 1054        CloseList();
 1055    }
 56
 57    public void Dispose()
 58    {
 1059        inspectorView.OnEntityActionInvoked -= EntityActionInvoked;
 1060        inspectorView.OnEntityRename -= EntityRename;
 1061    }
 62
 63    public void OpenEntityList()
 64    {
 165        if (inspectorView.entityList != null)
 66        {
 067            if (inspectorView.entities != null)
 068                inspectorView.entityList.SetContent(inspectorView.entities);
 69
 070            inspectorView.entityList.SetActive(true);
 71        }
 72
 173        inspectorView.SetActive(true);
 174    }
 75
 76    public void SetEntityList(List<BIWEntity> sceneEntities)
 77    {
 178        inspectorView.SetEntitiesList(sceneEntities);
 79
 180        if (inspectorView.entityList != null &&
 81            inspectorView.entityList.isActive &&
 82            inspectorView.entities != null)
 83        {
 084            inspectorView.entityList.SetContent(inspectorView.entities);
 85        }
 186    }
 87
 88    public void ClearList()
 89    {
 190        inspectorView.ClearEntitiesList();
 91
 192        if (inspectorView.entityList != null)
 093            inspectorView.entityList.RemoveAdapters();
 194    }
 95
 96    public void CloseList()
 97    {
 1198        inspectorView.SetActive(false);
 99
 11100        if (inspectorView.entityList != null)
 0101            inspectorView.entityList.SetActive(false);
 11102    }
 103
 104    public void EntityActionInvoked(EntityAction action, BIWEntity entityToApply, EntityListAdapter adapter)
 105    {
 106        switch (action)
 107        {
 108            case EntityAction.SELECT:
 109
 1110                OnEntityClick?.Invoke(entityToApply);
 1111                break;
 112            case EntityAction.LOCK:
 113
 1114                OnEntityLock?.Invoke(entityToApply);
 1115                break;
 116            case EntityAction.DELETE:
 117
 1118                OnEntityDelete?.Invoke(entityToApply);
 1119                break;
 120            case EntityAction.SHOW:
 1121                OnEntityChangeVisibility?.Invoke(entityToApply);
 122                break;
 123        }
 1124    }
 125
 2126    public void EntityRename(BIWEntity entity, string newName) { OnEntityRename?.Invoke(entity, newName); }
 127
 2128    public void SetCloseButtonsAction(UnityAction call) { inspectorView.SetCloseButtonsAction(call); }
 129}