< Summary

Class:InspectorView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/Inspector/InspectorView.cs
Covered lines:21
Uncovered lines:5
Coverable lines:26
Total lines:88
Line coverage:80.7% (21 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%110100%
OnDestroy()0%220100%
OnEnable()0%110100%
OnDisable()0%110100%
EntityActionInvoked(...)0%220100%
EntityRename(...)0%220100%
IsActive()0%2100%
SetActive(...)0%110100%
SetEntitiesList(...)0%2100%
ClearEntitiesList()0%220100%
SetCloseButtonsAction(...)0%110100%
ConfigureSceneLimits(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.Events;
 5using UnityEngine.UI;
 6
 7public interface IInspectorView
 8{
 9    EntityListView entityList { get; set; }
 10    List<BIWEntity> entities { get; }
 11    ISceneLimitsController sceneLimitsController { get; }
 12
 13    event Action<EntityAction, BIWEntity, EntityListAdapter> OnEntityActionInvoked;
 14    event Action<BIWEntity, string> OnEntityRename;
 15
 16    void ClearEntitiesList();
 17    void ConfigureSceneLimits(ISceneLimitsController sceneLimitsController);
 18    void EntityActionInvoked(EntityAction action, BIWEntity entityToApply, EntityListAdapter adapter);
 19    void EntityRename(BIWEntity entity, string newName);
 20    void SetActive(bool isActive);
 21    void SetCloseButtonsAction(UnityAction call);
 22    void SetEntitiesList(List<BIWEntity> entities);
 23}
 24
 25public class InspectorView : MonoBehaviour, IInspectorView
 26{
 027    public EntityListView entityList { get { return entityListView; } set { entityListView = value; } }
 028    public List<BIWEntity> entities => entitiesList;
 029    public ISceneLimitsController sceneLimitsController { get; internal set; }
 30
 31    public event Action<EntityAction, BIWEntity, EntityListAdapter> OnEntityActionInvoked;
 32    public event Action<BIWEntity, string> OnEntityRename;
 33
 34    [SerializeField] internal EntityListView entityListView;
 35    [SerializeField] internal SceneLimitsView sceneLimitsView;
 36    [SerializeField] internal Button closeEntityListBtn;
 37
 38    internal List<BIWEntity> entitiesList;
 39
 40    private const string VIEW_PATH = "GodMode/Inspector/InspectorView";
 41
 42    internal static InspectorView Create()
 43    {
 844        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<InspectorView>();
 845        view.gameObject.name = "_InspectorView";
 46
 847        return view;
 48    }
 49
 50    private void Awake()
 51    {
 852        entityListView.OnActionInvoked += EntityActionInvoked;
 853        entityListView.OnEntityRename += EntityRename;
 854    }
 55
 56    private void OnDestroy()
 57    {
 858        entityListView.OnActionInvoked -= EntityActionInvoked;
 859        entityListView.OnEntityRename -= EntityRename;
 60
 861        if (sceneLimitsController != null)
 162            sceneLimitsController.Dispose();
 863    }
 64
 1865    private void OnEnable() { AudioScriptableObjects.dialogOpen.Play(); }
 66
 1867    private void OnDisable() { AudioScriptableObjects.dialogClose.Play(); }
 68
 269    public void EntityActionInvoked(EntityAction action, BIWEntity entityToApply, EntityListAdapter adapter) { OnEntityA
 70
 271    public void EntityRename(BIWEntity entity, string newName) { OnEntityRename?.Invoke(entity, newName); }
 72
 073    public bool IsActive() { return gameObject.activeSelf; }
 74
 475    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 76
 077    public void SetEntitiesList(List<BIWEntity> entities) { entitiesList = entities; }
 78
 279    public void ClearEntitiesList() { entitiesList?.Clear(); }
 80
 281    public void SetCloseButtonsAction(UnityAction call) { closeEntityListBtn.onClick.AddListener(call); }
 82
 83    public void ConfigureSceneLimits(ISceneLimitsController sceneLimitsController)
 84    {
 185        this.sceneLimitsController = sceneLimitsController;
 186        this.sceneLimitsController.Initialize(sceneLimitsView);
 187    }
 88}