< Summary

Class:BuilderInWorldPlugin
Assembly:BIWPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Plugin/BuilderInWorldPlugin.cs
Covered lines:41
Uncovered lines:15
Coverable lines:56
Total lines:129
Line coverage:73.2% (41 of 56)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BuilderInWorldPlugin()0%6200%
BuilderInWorldPlugin(...)0%110100%
Initialize()0%33093.33%
TaskBarCreated()0%2100%
Dispose()0%220100%
Update()0%110100%
LateUpdate()0%110100%
OnGUI()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Plugin/BuilderInWorldPlugin.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using DCL;
 5using DCL.Builder;
 6using UnityEngine;
 7
 8public class BuilderInWorldPlugin : IPlugin
 9{
 10    private const string DEV_FLAG_NAME = "builder-dev";
 11    internal IBIWEditor editor;
 12    internal IBuilderMainPanelController panelController;
 13    internal IBuilderAPIController builderAPIController;
 14    internal ISceneManager sceneManager;
 15    internal ICameraController cameraController;
 16
 17    internal IContext context;
 18
 019    public BuilderInWorldPlugin()
 20    {
 021        if (DataStore.i.featureFlags.flags.Get().IsFeatureEnabled(DEV_FLAG_NAME))
 022            DataStore.i.builderInWorld.isDevBuild.Set(true);
 23
 024        panelController = new BuilderMainPanelController();
 025        editor = new BuilderInWorldEditor();
 026        builderAPIController = new BuilderAPIController();
 027        sceneManager = new SceneManager();
 028        cameraController = new CameraController();
 29
 030        context = new Context(editor,
 31            panelController,
 32            builderAPIController,
 33            sceneManager,
 34            cameraController,
 35            new BuilderEditorHUDController(),
 36            new BIWOutlinerController(),
 37            new BIWInputHandler(),
 38            new BIWInputWrapper(),
 39            new BIWPublishController(),
 40            new BIWCreatorController(),
 41            new BIWModeController(),
 42            new BIWFloorHandler(),
 43            new BIWEntityHandler(),
 44            new BIWActionController(),
 45            new BIWSaveController(),
 46            new BIWRaycastController(),
 47            new BIWGizmosController(),
 48            SceneReferences.i);
 49
 050        Initialize();
 051    }
 52
 753    public BuilderInWorldPlugin(IContext context)
 54    {
 755        this.context = context;
 756        this.sceneManager = context.sceneManager;
 757        panelController = context.panelHUD;
 758        editor = context.editor;
 759        builderAPIController = context.builderAPIController;
 760        cameraController = context.cameraController;
 61
 762        Initialize();
 763    }
 64
 65    private void Initialize()
 66    {
 67        //We init the lands so we don't have a null reference
 768        DataStore.i.builderInWorld.landsWithAccess.Set(new LandWithAccess[0]);
 69
 770        BIWCatalogManager.Init();
 71
 772        panelController.Initialize(context);
 773        editor.Initialize(context);
 774        builderAPIController.Initialize(context);
 775        sceneManager.Initialize(context);
 776        cameraController.Initialize(context);
 77
 778        if (HUDController.i != null)
 79        {
 780            if (HUDController.i.taskbarHud != null)
 081                HUDController.i.taskbarHud.SetBuilderInWorldStatus(true);
 82            else
 783                HUDController.i.OnTaskbarCreation += TaskBarCreated;
 84        }
 85
 786        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.Update, Update);
 787        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdate);
 788        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.OnGui, OnGUI);
 789    }
 90
 91
 92    private void TaskBarCreated()
 93    {
 094        HUDController.i.OnTaskbarCreation -= TaskBarCreated;
 095        HUDController.i.taskbarHud.SetBuilderInWorldStatus(true);
 096    }
 97
 98    public void Dispose()
 99    {
 7100        if (HUDController.i != null)
 7101            HUDController.i.OnTaskbarCreation -= TaskBarCreated;
 102
 7103        editor.Dispose();
 7104        panelController.Dispose();
 7105        sceneManager.Dispose();
 7106        cameraController.Dispose();
 7107        context.Dispose();
 108
 7109        DCL.Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.Update, Update);
 7110        DCL.Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdat
 7111        DCL.Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.OnGui, OnGUI);
 7112    }
 113
 114    public void Update()
 115    {
 1116        editor.Update();
 1117        sceneManager.Update();
 1118    }
 119
 120    public void LateUpdate()
 121    {
 1122        editor.LateUpdate();
 1123    }
 124
 125    public void OnGUI()
 126    {
 1127        editor.OnGUI();
 1128    }
 129}