< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BuilderInWorldPlugin()0%6200%
BuilderInWorldPlugin(...)0%2100%
Initialize()0%2100%
Dispose()0%6200%
Update()0%2100%
LateUpdate()0%2100%
OnGUI()0%2100%
UnregisterRuntimeComponents()0%2100%
RegisterRuntimeComponents()0%2100%
BuildComponent[T]()0%2100%

File(s)

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

#LineLine coverage
 1using DCL;
 2using DCL.Builder;
 3using DCL.Components;
 4using DCL.Models;
 5
 6public class BuilderInWorldPlugin : IPlugin
 7{
 8    private const string DEV_FLAG_NAME = "builder-dev";
 9    internal IBIWEditor editor;
 10    internal IBuilderMainPanelController panelController;
 11    internal IBuilderAPIController builderAPIController;
 12    internal ISceneManager sceneManager;
 13    internal ICameraController cameraController;
 14    internal IPublisher publisher;
 15    internal ICommonHUD commonHUD;
 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        RegisterRuntimeComponents();
 25
 026        panelController = new BuilderMainPanelController();
 027        editor = new BuilderInWorldEditor();
 028        builderAPIController = new BuilderAPIController();
 029        sceneManager = new SceneManager();
 030        cameraController = new CameraController();
 031        publisher = new Publisher();
 032        commonHUD = new CommonHUD();
 33
 034        context = new Context(editor,
 35            panelController,
 36            builderAPIController,
 37            sceneManager,
 38            cameraController,
 39            publisher,
 40            commonHUD,
 41            new BuilderEditorHUDController(),
 42            new BIWOutlinerController(),
 43            new BIWInputHandler(),
 44            new BIWInputWrapper(),
 45            new BIWPublishController(),
 46            new BIWCreatorController(),
 47            new BIWModeController(),
 48            new BIWFloorHandler(),
 49            new BIWEntityHandler(),
 50            new BIWActionController(),
 51            new BIWSaveController(),
 52            new BIWRaycastController(),
 53            new BIWGizmosController(),
 54            SceneReferences.i);
 55
 056        Initialize();
 057    }
 58
 059    public BuilderInWorldPlugin(IContext context)
 60    {
 061        this.context = context;
 062        sceneManager = context.sceneManager;
 063        panelController = context.panelHUD;
 064        editor = context.editor;
 065        builderAPIController = context.builderAPIController;
 066        cameraController = context.cameraController;
 067        publisher = context.publisher;
 068        commonHUD = context.commonHUD;
 69
 070        Initialize();
 071    }
 72
 73    private void Initialize()
 74    {
 75        //We init the lands so we don't have a null reference
 076        DataStore.i.builderInWorld.landsWithAccess.Set(new LandWithAccess[0]);
 77
 078        BIWCatalogManager.Init();
 79
 080        panelController.Initialize(context);
 081        editor.Initialize(context);
 082        builderAPIController.Initialize(context);
 083        sceneManager.Initialize(context);
 084        cameraController.Initialize(context);
 085        publisher.Initialize(context);
 086        commonHUD.Initialize(context);
 87
 088        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.Update, Update);
 089        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdate);
 090        DCL.Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.OnGui, OnGUI);
 91
 092        DataStore.i.builderInWorld.isInitialized.Set(true);
 093    }
 94
 95    public void Dispose()
 96    {
 097        if (DataStore.i.common.isApplicationQuitting.Get())
 098            return;
 99
 0100        editor.Dispose();
 0101        panelController.Dispose();
 0102        sceneManager.Dispose();
 0103        cameraController.Dispose();
 0104        publisher.Dispose();
 0105        commonHUD.Dispose();
 0106        context.Dispose();
 107
 0108        Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.Update, Update);
 0109        Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdate);
 0110        Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.OnGui, OnGUI);
 111
 0112        UnregisterRuntimeComponents();
 0113    }
 114
 115    public void Update()
 116    {
 0117        editor.Update();
 0118        sceneManager.Update();
 0119    }
 120
 0121    public void LateUpdate() { editor.LateUpdate(); }
 122
 0123    public void OnGUI() { editor.OnGUI(); }
 124
 125    public static void UnregisterRuntimeComponents()
 126    {
 127        // Builder in world
 0128        IRuntimeComponentFactory factory = Environment.i.world.componentFactory;
 0129        factory.UnregisterBuilder((int) CLASS_ID.NAME);
 0130        factory.UnregisterBuilder((int) CLASS_ID.LOCKED_ON_EDIT);
 0131        factory.UnregisterBuilder((int) CLASS_ID.VISIBLE_ON_EDIT);
 0132    }
 133
 134    public static void RegisterRuntimeComponents()
 135    {
 136        // Builder in world
 0137        IRuntimeComponentFactory factory = Environment.i.world.componentFactory;
 0138        factory.RegisterBuilder((int) CLASS_ID.NAME, BuildComponent<DCLName>);
 0139        factory.RegisterBuilder((int) CLASS_ID.LOCKED_ON_EDIT, BuildComponent<DCLLockedOnEdit>);
 0140        factory.RegisterBuilder((int) CLASS_ID.VISIBLE_ON_EDIT, BuildComponent<DCLVisibleOnEdit>);
 0141    }
 142
 143    private static T BuildComponent<T>()
 144        where T : IComponent, new()
 145    {
 0146        return new T();
 147    }
 148
 149}