| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | namespace DCL.Builder |
| | 7 | | { |
| | 8 | | public class Context : IContext |
| | 9 | | { |
| | 10 | | private const string PROJECT_REFERENCES_PATH = "ScriptableObjects/ProjectReferences"; |
| | 11 | | private const string INPUTS_PATH = "ScriptableObjects/InputReferences"; |
| | 12 | |
|
| | 13 | | //Scriptable Objects |
| | 14 | | public BIWProjectReferences projectReferencesAsset { get; set; } |
| | 15 | | public BIWInputsReferences inputsReferencesAsset { get; set; } |
| | 16 | |
|
| | 17 | | //Builder Parts |
| | 18 | | public IBuilderMainPanelController panelHUD { get; internal set; } |
| | 19 | | public IBIWEditor editor { get; internal set; } |
| | 20 | | public IBuilderAPIController builderAPIController { get; internal set; } |
| | 21 | | public ISceneManager sceneManager { get; internal set; } |
| | 22 | | public ICameraController cameraController { get; internal set; } |
| | 23 | | public ISceneReferences sceneReferences { get; internal set; } |
| | 24 | | public IPublisher publisher { get; internal set; } |
| | 25 | |
|
| | 26 | | //Editor |
| | 27 | | public IEditorContext editorContext { get; internal set; } |
| | 28 | |
|
| | 29 | | public Context(IBIWEditor editor, |
| | 30 | | IBuilderMainPanelController panelHUD, |
| | 31 | | IBuilderAPIController builderAPIController, |
| | 32 | | ISceneManager sceneManager, |
| | 33 | | ICameraController cameraController, |
| | 34 | | IPublisher publisher, |
| | 35 | | IBuilderEditorHUDController editorHUD, |
| | 36 | | IBIWOutlinerController outlinerController, |
| | 37 | | IBIWInputHandler inputHandler, |
| | 38 | | IBIWInputWrapper inputWrapper, |
| | 39 | | IBIWPublishController publishController, |
| | 40 | | IBIWCreatorController creatorController, |
| | 41 | | IBIWModeController modeController, |
| | 42 | | IBIWFloorHandler floorHandler, |
| | 43 | | IBIWEntityHandler entityHandler, |
| | 44 | | IBIWActionController actionController, |
| | 45 | | IBIWSaveController saveController, |
| | 46 | | IBIWRaycastController raycastController, |
| | 47 | | IBIWGizmosController gizmosController, |
| | 48 | | ISceneReferences sceneReferences) |
| | 49 | | { |
| | 50 | | projectReferencesAsset = Resources.Load<BIWProjectReferences>(PROJECT_REFERENCES_PATH); |
| | 51 | | inputsReferencesAsset = Resources.Load<BIWInputsReferences>(INPUTS_PATH); |
| | 52 | |
|
| | 53 | | this.sceneReferences = sceneReferences; |
| | 54 | |
|
| | 55 | | //Builder parts |
| | 56 | | this.panelHUD = panelHUD; |
| | 57 | | this.editor = editor; |
| | 58 | | this.builderAPIController = builderAPIController; |
| | 59 | | this.sceneManager = sceneManager; |
| | 60 | | this.cameraController = cameraController; |
| | 61 | | this.publisher = publisher; |
| | 62 | |
|
| | 63 | | editorContext = new EditorContext(editorHUD, |
| | 64 | | outlinerController, |
| | 65 | | inputHandler, |
| | 66 | | inputWrapper, |
| | 67 | | publishController, |
| | 68 | | creatorController, |
| | 69 | | modeController, |
| | 70 | | floorHandler, |
| | 71 | | entityHandler, |
| | 72 | | actionController, |
| | 73 | | saveController, |
| | 74 | | raycastController, |
| | 75 | | gizmosController, |
| | 76 | | sceneReferences |
| | 77 | | ); |
| | 78 | | } |
| | 79 | |
|
| | 80 | | public void Dispose() |
| | 81 | | { |
| | 82 | | editorContext.Dispose(); |
| | 83 | | panelHUD.Dispose(); |
| | 84 | | projectReferencesAsset = null; |
| | 85 | | inputsReferencesAsset = null; |
| | 86 | | } |
| | 87 | | } |
| | 88 | |
|
| | 89 | | public class EditorContext : IEditorContext |
| | 90 | | { |
| | 91 | | private const string GOD_MODE_DYNAMIC_VARIABLE_PATH = "ScriptableObjects/GodModeVariables"; |
| | 92 | | private const string FIRST_PERSON_DYNAMIC_VARIABLE_PATH = "ScriptableObjects/FirstPersonVariables"; |
| | 93 | |
|
| 210 | 94 | | BIWGodModeDynamicVariables IEditorContext.godModeDynamicVariablesAsset => godModeDynamicVariablesAssetReference; |
| 272 | 95 | | BIWFirstPersonDynamicVariables IEditorContext.firstPersonDynamicVariablesAsset => firstPersonDynamicVariablesAss |
| | 96 | |
|
| | 97 | | //HUD |
| 1634 | 98 | | public IBuilderEditorHUDController editorHUD { get; private set; } |
| | 99 | |
|
| | 100 | | // BIW Controllers |
| 115 | 101 | | public IBIWOutlinerController outlinerController { get; private set; } |
| 8 | 102 | | public IBIWInputHandler inputHandler { get; private set; } |
| 8 | 103 | | public IBIWInputWrapper inputWrapper { get; private set; } |
| 8 | 104 | | public IBIWPublishController publishController { get; private set; } |
| 107 | 105 | | public IBIWCreatorController creatorController { get; private set; } |
| 134 | 106 | | public IBIWModeController modeController { get; private set; } |
| 48 | 107 | | public IBIWFloorHandler floorHandler => floorHandlerReference; |
| | 108 | |
|
| | 109 | | internal IBIWFloorHandler floorHandlerReference; |
| 206 | 110 | | public IBIWEntityHandler entityHandler { get; private set; } |
| 214 | 111 | | public IBIWActionController actionController { get; private set; } |
| 94 | 112 | | public IBIWSaveController saveController { get; private set; } |
| 206 | 113 | | public IBIWRaycastController raycastController { get; private set; } |
| 42 | 114 | | public IBIWGizmosController gizmosController { get; private set; } |
| 0 | 115 | | public ISceneReferences sceneReferences { get; private set; } |
| | 116 | |
|
| | 117 | | //Scriptable Objects |
| | 118 | | internal BIWGodModeDynamicVariables godModeDynamicVariablesAssetReference; |
| | 119 | | internal BIWFirstPersonDynamicVariables firstPersonDynamicVariablesAssetReference; |
| | 120 | |
|
| 220 | 121 | | public EditorContext(IBuilderEditorHUDController editorHUD, |
| | 122 | | IBIWOutlinerController outlinerController, |
| | 123 | | IBIWInputHandler inputHandler, |
| | 124 | | IBIWInputWrapper inputWrapper, |
| | 125 | | IBIWPublishController publishController, |
| | 126 | | IBIWCreatorController creatorController, |
| | 127 | | IBIWModeController modeController, |
| | 128 | | IBIWFloorHandler floorHandler, |
| | 129 | | IBIWEntityHandler entityHandler, |
| | 130 | | IBIWActionController actionController, |
| | 131 | | IBIWSaveController saveController, |
| | 132 | | IBIWRaycastController raycastController, |
| | 133 | | IBIWGizmosController gizmosController, |
| | 134 | | ISceneReferences sceneReferences) |
| | 135 | | { |
| 220 | 136 | | godModeDynamicVariablesAssetReference = Resources.Load<BIWGodModeDynamicVariables>(GOD_MODE_DYNAMIC_VARIABLE |
| 220 | 137 | | firstPersonDynamicVariablesAssetReference = Resources.Load<BIWFirstPersonDynamicVariables>(FIRST_PERSON_DYNA |
| | 138 | |
|
| 220 | 139 | | this.editorHUD = editorHUD; |
| | 140 | |
|
| 220 | 141 | | this.outlinerController = outlinerController; |
| 220 | 142 | | this.inputHandler = inputHandler; |
| 220 | 143 | | this.inputWrapper = inputWrapper; |
| 220 | 144 | | this.publishController = publishController; |
| 220 | 145 | | this.creatorController = creatorController; |
| 220 | 146 | | this.modeController = modeController; |
| 220 | 147 | | this.floorHandlerReference = floorHandler; |
| 220 | 148 | | this.entityHandler = entityHandler; |
| 220 | 149 | | this.actionController = actionController; |
| 220 | 150 | | this.saveController = saveController; |
| 220 | 151 | | this.raycastController = raycastController; |
| 220 | 152 | | this.gizmosController = gizmosController; |
| 220 | 153 | | this.sceneReferences = sceneReferences; |
| 220 | 154 | | } |
| | 155 | |
|
| | 156 | | public void Dispose() |
| | 157 | | { |
| 102 | 158 | | editorHUD.Dispose(); |
| 102 | 159 | | outlinerController.Dispose(); |
| 102 | 160 | | inputHandler.Dispose(); |
| 102 | 161 | | inputWrapper.Dispose(); |
| 102 | 162 | | publishController.Dispose(); |
| 102 | 163 | | creatorController.Dispose(); |
| 102 | 164 | | modeController.Dispose(); |
| 102 | 165 | | floorHandler.Dispose(); |
| 102 | 166 | | entityHandler.Dispose(); |
| 102 | 167 | | actionController.Dispose(); |
| 102 | 168 | | saveController.Dispose(); |
| 102 | 169 | | raycastController.Dispose(); |
| 102 | 170 | | gizmosController.Dispose(); |
| | 171 | |
|
| 102 | 172 | | sceneReferences.Dispose(); |
| | 173 | |
|
| | 174 | |
|
| 102 | 175 | | godModeDynamicVariablesAssetReference = null; |
| 102 | 176 | | firstPersonDynamicVariablesAssetReference = null; |
| 102 | 177 | | } |
| | 178 | | } |
| | 179 | | } |