| | 1 | | using System.Collections.Generic; |
| | 2 | | using DCL.CRDT; |
| | 3 | | using DCL.ECSComponents; |
| | 4 | | using DCL.ECSRuntime; |
| | 5 | |
|
| | 6 | | namespace DCL.ECS7 |
| | 7 | | { |
| | 8 | | public class ECS7Plugin : IPlugin |
| | 9 | | { |
| | 10 | | private readonly ComponentCrdtWriteSystem crdtWriteSystem; |
| | 11 | | private readonly IECSComponentWriter componentWriter; |
| | 12 | | private readonly ECS7ComponentsComposer componentsComposer; |
| | 13 | | private readonly ECSSystemsController systemsController; |
| | 14 | | private readonly ECSComponentsFactory componentsFactory; |
| | 15 | | private readonly ECSComponentsManager componentsManager; |
| | 16 | | private readonly InternalECSComponents internalEcsComponents; |
| | 17 | | private readonly CrdtExecutorsManager crdtExecutorsManager; |
| | 18 | |
|
| 1 | 19 | | public ECS7Plugin() |
| | 20 | | { |
| 1 | 21 | | DataStore.i.ecs7.isEcs7Enabled = true; |
| | 22 | |
|
| 1 | 23 | | ISceneController sceneController = Environment.i.world.sceneController; |
| 1 | 24 | | Dictionary<string, ICRDTExecutor> crdtExecutors = new Dictionary<string, ICRDTExecutor>(10); |
| | 25 | |
|
| 1 | 26 | | componentsFactory = new ECSComponentsFactory(); |
| 1 | 27 | | componentsManager = new ECSComponentsManager(componentsFactory.componentBuilders); |
| 1 | 28 | | internalEcsComponents = new InternalECSComponents(componentsManager, componentsFactory); |
| 1 | 29 | | crdtExecutorsManager = new CrdtExecutorsManager(crdtExecutors, componentsManager, sceneController, |
| | 30 | | Environment.i.world.state, DataStore.i.rpcContext.context.crdtContext); |
| | 31 | |
|
| 1 | 32 | | crdtWriteSystem = new ComponentCrdtWriteSystem(Environment.i.world.state, sceneController, DataStore.i.rpcCo |
| 1 | 33 | | componentWriter = new ECSComponentWriter(crdtWriteSystem.WriteMessage); |
| | 34 | |
|
| 1 | 35 | | componentsComposer = new ECS7ComponentsComposer(componentsFactory, componentWriter, internalEcsComponents); |
| | 36 | |
|
| 1 | 37 | | SystemsContext systemsContext = new SystemsContext(componentWriter, |
| | 38 | | internalEcsComponents, |
| | 39 | | new ComponentGroups(componentsManager), |
| | 40 | | (ECSComponent<PBPointerHoverFeedback>)componentsManager.GetOrCreateComponent(ComponentID.POINTER_HOVER_F |
| | 41 | |
|
| 1 | 42 | | systemsController = new ECSSystemsController(crdtWriteSystem.LateUpdate, systemsContext); |
| 1 | 43 | | } |
| | 44 | |
|
| | 45 | | public void Dispose() |
| | 46 | | { |
| 1 | 47 | | componentsComposer.Dispose(); |
| 1 | 48 | | crdtWriteSystem.Dispose(); |
| 1 | 49 | | componentWriter.Dispose(); |
| 1 | 50 | | systemsController.Dispose(); |
| 1 | 51 | | internalEcsComponents.Dispose(); |
| 1 | 52 | | crdtExecutorsManager.Dispose(); |
| 1 | 53 | | } |
| | 54 | | } |
| | 55 | | } |