| | 1 | | using DCL.CRDT; |
| | 2 | | using DCL.ECS7.InternalComponents; |
| | 3 | | using DCL.ECSRuntime; |
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | |
|
| | 7 | | public class InternalECSComponents : IDisposable, IInternalECSComponents, IComponentDirtySystem |
| | 8 | | { |
| | 9 | | public event Action MarkComponentsAsDirty; |
| | 10 | | public event Action RemoveComponentsAsDirty; |
| | 11 | |
|
| 29 | 12 | | public IInternalECSComponent<InternalTexturizable> texturizableComponent { get; } |
| 8 | 13 | | public IInternalECSComponent<InternalMaterial> materialComponent { get; } |
| 8 | 14 | | public IInternalECSComponent<InternalVideoMaterial> videoMaterialComponent { get; } |
| 18 | 15 | | public IInternalECSComponent<InternalVideoPlayer> videoPlayerComponent { get; } |
| 306 | 16 | | public IInternalECSComponent<InternalColliders> onPointerColliderComponent { get; } |
| 322 | 17 | | public IInternalECSComponent<InternalColliders> physicColliderComponent { get; } |
| 252 | 18 | | public IInternalECSComponent<InternalColliders> customLayerColliderComponent { get; } |
| 67 | 19 | | public IInternalECSComponent<InternalInputEventResults> inputEventResultsComponent { get; } |
| 104 | 20 | | public IInternalECSComponent<InternalRenderers> renderersComponent { get; } |
| 11 | 21 | | public IInternalECSComponent<InternalVisibility> visibilityComponent { get; } |
| 90 | 22 | | public IInternalECSComponent<InternalUiContainer> uiContainerComponent { get; } |
| 6 | 23 | | public IInternalECSComponent<InternalUIInputResults> uiInputResultsComponent { get; } |
| 44 | 24 | | public IInternalECSComponent<InternalSceneBoundsCheck> sceneBoundsCheckComponent { get; } |
| 1 | 25 | | public IInternalECSComponent<InternalAudioSource> audioSourceComponent { get; } |
| 68 | 26 | | public IInternalECSComponent<InternalPointerEvents> PointerEventsComponent { get; } |
| 16 | 27 | | public IInternalECSComponent<InternalRegisteredUiPointerEvents> RegisteredUiPointerEventsComponent { get; } |
| 70 | 28 | | public IInternalECSComponent<InternalRaycast> raycastComponent { get; } |
| 47 | 29 | | public IInternalECSComponent<InternalGltfContainerLoadingState> GltfContainerLoadingStateComponent { get; } |
| 92 | 30 | | public IInternalECSComponent<InternalEngineInfo> EngineInfo { get; } |
| 4 | 31 | | public IInternalECSComponent<InternalAnimationPlayer> AnimationPlayer { get; } |
| 36 | 32 | | public IInternalECSComponent<InternalAnimation> Animation { get; } |
| 46 | 33 | | public IInternalECSComponent<InternalTween> TweenComponent { get; } |
| 31 | 34 | | public IInternalECSComponent<InternalAvatarModifierArea> AvatarModifierAreaComponent { get; } |
| | 35 | |
|
| 203 | 36 | | public InternalECSComponents(ECSComponentsManager componentsManager, ECSComponentsFactory componentsFactory, |
| | 37 | | IReadOnlyDictionary<int, ICRDTExecutor> crdtExecutors) |
| | 38 | | { |
| 203 | 39 | | texturizableComponent = new InternalECSComponent<InternalTexturizable>( |
| | 40 | | InternalECSComponentsId.TEXTURIZABLE, |
| | 41 | | componentsManager, |
| | 42 | | componentsFactory, |
| 14 | 43 | | () => new RemoveOnConditionHandler<InternalTexturizable>( |
| 47 | 44 | | () => texturizableComponent, model => model.renderers.Count == 0), |
| | 45 | | crdtExecutors, |
| | 46 | | this); |
| | 47 | |
|
| 203 | 48 | | materialComponent = new InternalECSComponent<InternalMaterial>( |
| | 49 | | InternalECSComponentsId.MATERIAL, |
| | 50 | | componentsManager, |
| | 51 | | componentsFactory, |
| | 52 | | null, |
| | 53 | | crdtExecutors, |
| | 54 | | this); |
| | 55 | |
|
| 203 | 56 | | onPointerColliderComponent = new InternalECSComponent<InternalColliders>( |
| | 57 | | InternalECSComponentsId.COLLIDER_POINTER, |
| | 58 | | componentsManager, |
| | 59 | | componentsFactory, |
| 118 | 60 | | () => new RemoveOnConditionHandler<InternalColliders>( |
| 270 | 61 | | () => onPointerColliderComponent, model => model.colliders.Count == 0), |
| | 62 | | crdtExecutors, |
| | 63 | | this); |
| | 64 | |
|
| 203 | 65 | | physicColliderComponent = new InternalECSComponent<InternalColliders>( |
| | 66 | | InternalECSComponentsId.COLLIDER_PHYSICAL, |
| | 67 | | componentsManager, |
| | 68 | | componentsFactory, |
| 81 | 69 | | () => new RemoveOnConditionHandler<InternalColliders>( |
| 197 | 70 | | () => physicColliderComponent, model => model.colliders.Count == 0), |
| | 71 | | crdtExecutors, |
| | 72 | | this); |
| | 73 | |
|
| 203 | 74 | | customLayerColliderComponent = new InternalECSComponent<InternalColliders>( |
| | 75 | | InternalECSComponentsId.COLLIDER_CUSTOM, |
| | 76 | | componentsManager, |
| | 77 | | componentsFactory, |
| 86 | 78 | | () => new RemoveOnConditionHandler<InternalColliders>( |
| 213 | 79 | | () => customLayerColliderComponent, model => model.colliders.Count == 0), |
| | 80 | | crdtExecutors, |
| | 81 | | this); |
| | 82 | |
|
| 203 | 83 | | renderersComponent = new InternalECSComponent<InternalRenderers>( |
| | 84 | | InternalECSComponentsId.RENDERERS, |
| | 85 | | componentsManager, |
| | 86 | | componentsFactory, |
| 50 | 87 | | () => new RemoveOnConditionHandler<InternalRenderers>( |
| 133 | 88 | | () => renderersComponent, model => model.renderers.Count == 0), |
| | 89 | | crdtExecutors, |
| | 90 | | this); |
| | 91 | |
|
| 203 | 92 | | visibilityComponent = new InternalECSComponent<InternalVisibility>( |
| | 93 | | InternalECSComponentsId.VISIBILITY, |
| | 94 | | componentsManager, |
| | 95 | | componentsFactory, |
| | 96 | | null, |
| | 97 | | crdtExecutors, |
| | 98 | | this); |
| | 99 | |
|
| 203 | 100 | | inputEventResultsComponent = new InternalECSComponent<InternalInputEventResults>( |
| | 101 | | InternalECSComponentsId.INPUT_EVENTS_RESULT, |
| | 102 | | componentsManager, |
| | 103 | | componentsFactory, |
| | 104 | | null, |
| | 105 | | crdtExecutors, |
| | 106 | | this); |
| | 107 | |
|
| 203 | 108 | | uiContainerComponent = new InternalECSComponent<InternalUiContainer>( |
| | 109 | | InternalECSComponentsId.UI_CONTAINER, |
| | 110 | | componentsManager, |
| | 111 | | componentsFactory, |
| 90 | 112 | | () => new UiContainerHandler(() => uiContainerComponent), |
| | 113 | | crdtExecutors, |
| | 114 | | this); |
| | 115 | |
|
| 203 | 116 | | uiInputResultsComponent = new InternalECSComponent<InternalUIInputResults>( |
| | 117 | | InternalECSComponentsId.UI_INPUT_EVENTS_RESULT, |
| | 118 | | componentsManager, |
| | 119 | | componentsFactory, |
| | 120 | | null, |
| | 121 | | crdtExecutors, |
| | 122 | | this |
| | 123 | | ); |
| | 124 | |
|
| 203 | 125 | | videoPlayerComponent = new InternalECSComponent<InternalVideoPlayer>( |
| | 126 | | InternalECSComponentsId.VIDEO_PLAYER, |
| | 127 | | componentsManager, |
| | 128 | | componentsFactory, |
| | 129 | | null, |
| | 130 | | crdtExecutors, |
| | 131 | | this); |
| | 132 | |
|
| 203 | 133 | | videoMaterialComponent = new InternalECSComponent<InternalVideoMaterial>( |
| | 134 | | InternalECSComponentsId.VIDEO_MATERIAL, |
| | 135 | | componentsManager, |
| | 136 | | componentsFactory, |
| | 137 | | null, |
| | 138 | | crdtExecutors, |
| | 139 | | this); |
| | 140 | |
|
| 203 | 141 | | sceneBoundsCheckComponent = new InternalECSComponent<InternalSceneBoundsCheck>( |
| | 142 | | InternalECSComponentsId.SCENE_BOUNDS_CHECK, |
| | 143 | | componentsManager, |
| | 144 | | componentsFactory, |
| | 145 | | null, |
| | 146 | | crdtExecutors, |
| | 147 | | this |
| | 148 | | ); |
| | 149 | |
|
| 203 | 150 | | audioSourceComponent = new InternalECSComponent<InternalAudioSource>( |
| | 151 | | InternalECSComponentsId.AUDIO_SOURCE, |
| | 152 | | componentsManager, |
| | 153 | | componentsFactory, |
| | 154 | | null, |
| | 155 | | crdtExecutors, |
| | 156 | | this |
| | 157 | | ); |
| | 158 | |
|
| 203 | 159 | | PointerEventsComponent = new InternalECSComponent<InternalPointerEvents>( |
| | 160 | | InternalECSComponentsId.POINTER_EVENTS, |
| | 161 | | componentsManager, |
| | 162 | | componentsFactory, |
| | 163 | | null, |
| | 164 | | crdtExecutors, |
| | 165 | | this |
| | 166 | | ); |
| | 167 | |
|
| 203 | 168 | | RegisteredUiPointerEventsComponent = new InternalECSComponent<InternalRegisteredUiPointerEvents>( |
| | 169 | | InternalECSComponentsId.REGISTERED_UI_POINTER_EVENTS, |
| | 170 | | componentsManager, |
| | 171 | | componentsFactory, |
| | 172 | | null, |
| | 173 | | crdtExecutors, |
| | 174 | | this |
| | 175 | | ); |
| | 176 | |
|
| 203 | 177 | | raycastComponent = new InternalECSComponent<InternalRaycast>( |
| | 178 | | InternalECSComponentsId.RAYCAST, |
| | 179 | | componentsManager, |
| | 180 | | componentsFactory, |
| | 181 | | null, |
| | 182 | | crdtExecutors, |
| | 183 | | this |
| | 184 | | ); |
| | 185 | |
|
| 203 | 186 | | GltfContainerLoadingStateComponent = new InternalECSComponent<InternalGltfContainerLoadingState>( |
| | 187 | | InternalECSComponentsId.GLTF_CONTAINER_LOADING_STATE, |
| | 188 | | componentsManager, |
| | 189 | | componentsFactory, |
| | 190 | | null, |
| | 191 | | crdtExecutors, |
| | 192 | | this |
| | 193 | | ); |
| | 194 | |
|
| 203 | 195 | | EngineInfo = new InternalECSComponent<InternalEngineInfo>( |
| | 196 | | InternalECSComponentsId.ENGINE_INFO, |
| | 197 | | componentsManager, |
| | 198 | | componentsFactory, |
| | 199 | | null, |
| | 200 | | crdtExecutors, |
| | 201 | | this |
| | 202 | | ); |
| | 203 | |
|
| 203 | 204 | | AnimationPlayer = new InternalECSComponent<InternalAnimationPlayer>( |
| | 205 | | InternalECSComponentsId.ANIMATION_PLAYER, |
| | 206 | | componentsManager, |
| | 207 | | componentsFactory, |
| | 208 | | null, |
| | 209 | | crdtExecutors, |
| | 210 | | this |
| | 211 | | ); |
| | 212 | |
|
| 203 | 213 | | Animation = new InternalECSComponent<InternalAnimation>( |
| | 214 | | InternalECSComponentsId.ANIMATION, |
| | 215 | | componentsManager, |
| | 216 | | componentsFactory, |
| | 217 | | null, |
| | 218 | | crdtExecutors, |
| | 219 | | this |
| | 220 | | ); |
| | 221 | |
|
| 203 | 222 | | TweenComponent = new InternalECSComponent<InternalTween>( |
| | 223 | | InternalECSComponentsId.TWEEN, |
| | 224 | | componentsManager, |
| | 225 | | componentsFactory, |
| | 226 | | null, |
| | 227 | | crdtExecutors, |
| | 228 | | this |
| | 229 | | ); |
| | 230 | |
|
| 203 | 231 | | AvatarModifierAreaComponent = new InternalECSComponent<InternalAvatarModifierArea>( |
| | 232 | | InternalECSComponentsId.AVATAR_MODIFIER_AREA, |
| | 233 | | componentsManager, |
| | 234 | | componentsFactory, |
| | 235 | | null, |
| | 236 | | crdtExecutors, |
| | 237 | | this |
| | 238 | | ); |
| 203 | 239 | | } |
| | 240 | |
|
| | 241 | | public void Dispose() |
| | 242 | | { |
| 1 | 243 | | texturizableComponent.Dispose(); |
| 1 | 244 | | materialComponent.Dispose(); |
| 1 | 245 | | onPointerColliderComponent.Dispose(); |
| 1 | 246 | | physicColliderComponent.Dispose(); |
| 1 | 247 | | renderersComponent.Dispose(); |
| 1 | 248 | | inputEventResultsComponent.Dispose(); |
| 1 | 249 | | videoPlayerComponent.Dispose(); |
| 1 | 250 | | videoMaterialComponent.Dispose(); |
| 1 | 251 | | visibilityComponent.Dispose(); |
| 1 | 252 | | uiContainerComponent.Dispose(); |
| 1 | 253 | | uiInputResultsComponent.Dispose(); |
| 1 | 254 | | sceneBoundsCheckComponent.Dispose(); |
| 1 | 255 | | audioSourceComponent.Dispose(); |
| 1 | 256 | | PointerEventsComponent.Dispose(); |
| 1 | 257 | | RegisteredUiPointerEventsComponent.Dispose(); |
| 1 | 258 | | GltfContainerLoadingStateComponent.Dispose(); |
| 1 | 259 | | EngineInfo.Dispose(); |
| 1 | 260 | | AnimationPlayer.Dispose(); |
| 1 | 261 | | Animation.Dispose(); |
| 1 | 262 | | TweenComponent.Dispose(); |
| 1 | 263 | | AvatarModifierAreaComponent.Dispose(); |
| 1 | 264 | | } |
| | 265 | |
|
| | 266 | | public void MarkDirtyComponentsUpdate() |
| | 267 | | { |
| 55 | 268 | | MarkComponentsAsDirty?.Invoke(); |
| 55 | 269 | | } |
| | 270 | |
|
| | 271 | | public void ResetDirtyComponentsUpdate() |
| | 272 | | { |
| 53 | 273 | | RemoveComponentsAsDirty?.Invoke(); |
| 53 | 274 | | } |
| | 275 | | } |