< Summary

Class:BuilderInWorldPlugin
Assembly:BIWPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Plugin/BuilderInWorldPlugin.cs
Covered lines:39
Uncovered lines:13
Coverable lines:52
Total lines:112
Line coverage:75% (39 of 52)
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%110100%
Dispose()0%22091.67%
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 DCL;
 2using DCL.Builder;
 3
 4public class BuilderInWorldPlugin : IPlugin
 5{
 6    private const string DEV_FLAG_NAME = "builder-dev";
 7    internal IBIWEditor editor;
 8    internal IBuilderMainPanelController panelController;
 9    internal IBuilderAPIController builderAPIController;
 10    internal ISceneManager sceneManager;
 11    internal ICameraController cameraController;
 12    internal IPublisher publisher;
 13
 14    internal IContext context;
 15
 016    public BuilderInWorldPlugin()
 17    {
 018        if (DataStore.i.featureFlags.flags.Get().IsFeatureEnabled(DEV_FLAG_NAME))
 019            DataStore.i.builderInWorld.isDevBuild.Set(true);
 20
 021        panelController = new BuilderMainPanelController();
 022        editor = new BuilderInWorldEditor();
 023        builderAPIController = new BuilderAPIController();
 024        sceneManager = new SceneManager();
 025        cameraController = new CameraController();
 026        publisher = new Publisher();
 27
 028        context = new Context(editor,
 29            panelController,
 30            builderAPIController,
 31            sceneManager,
 32            cameraController,
 33            publisher,
 34            new BuilderEditorHUDController(),
 35            new BIWOutlinerController(),
 36            new BIWInputHandler(),
 37            new BIWInputWrapper(),
 38            new BIWPublishController(),
 39            new BIWCreatorController(),
 40            new BIWModeController(),
 41            new BIWFloorHandler(),
 42            new BIWEntityHandler(),
 43            new BIWActionController(),
 44            new BIWSaveController(),
 45            new BIWRaycastController(),
 46            new BIWGizmosController(),
 47            SceneReferences.i);
 48
 049        Initialize();
 050    }
 51
 752    public BuilderInWorldPlugin(IContext context)
 53    {
 754        this.context = context;
 755        sceneManager = context.sceneManager;
 756        panelController = context.panelHUD;
 757        editor = context.editor;
 758        builderAPIController = context.builderAPIController;
 759        cameraController = context.cameraController;
 760        publisher = context.publisher;
 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);
 777        publisher.Initialize();
 78
 779        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.Update, Update);
 780        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdate);
 781        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.OnGui, OnGUI);
 82
 783        DataStore.i.builderInWorld.isInitialized.Set(true);
 784    }
 85
 86    public void Dispose()
 87    {
 788        if (DataStore.i.common.isApplicationQuitting.Get())
 089            return;
 90
 791        editor.Dispose();
 792        panelController.Dispose();
 793        sceneManager.Dispose();
 794        cameraController.Dispose();
 795        publisher.Dipose();
 796        context.Dispose();
 97
 798        Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.Update, Update);
 799        Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdate);
 7100        Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.OnGui, OnGUI);
 7101    }
 102
 103    public void Update()
 104    {
 2105        editor.Update();
 2106        sceneManager.Update();
 2107    }
 108
 4109    public void LateUpdate() { editor.LateUpdate(); }
 110
 2111    public void OnGUI() { editor.OnGUI(); }
 112}