| | 1 | | using System; |
| | 2 | | using DCL.Controllers; |
| | 3 | | using DCL.ECS7.InternalComponents; |
| | 4 | | using DCL.ECSRuntime; |
| | 5 | | using DCL.Models; |
| | 6 | |
|
| | 7 | | public class UiContainerHandler : IECSComponentHandler<InternalUiContainer> |
| | 8 | | { |
| | 9 | | private readonly IInternalECSComponent<InternalUiContainer> thisComponent; |
| | 10 | |
|
| 16 | 11 | | public UiContainerHandler(Func<IInternalECSComponent<InternalUiContainer>> componentGet) |
| | 12 | | { |
| 16 | 13 | | this.thisComponent = componentGet(); |
| 16 | 14 | | } |
| | 15 | |
|
| 16 | 16 | | public void OnComponentCreated(IParcelScene scene, IDCLEntity entity) { } |
| | 17 | |
|
| | 18 | | public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity) |
| | 19 | | { |
| 3 | 20 | | var containerData = thisComponent.GetFor(scene, entity); |
| 3 | 21 | | if (containerData != null) |
| | 22 | | { |
| 3 | 23 | | containerData.model.parentElement?.Remove(containerData.model.rootElement); |
| 3 | 24 | | containerData.model.parentElement = null; |
| | 25 | | } |
| 3 | 26 | | } |
| | 27 | |
|
| | 28 | | public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, InternalUiContainer model) |
| | 29 | | { |
| 32 | 30 | | if (model.rootElement.childCount == 0 && model.components.Count == 0 && entity.entityId != SpecialEntityId.SCENE |
| | 31 | | { |
| 1 | 32 | | thisComponent.RemoveFor(scene, entity); |
| | 33 | | } |
| 32 | 34 | | } |
| | 35 | | } |