| | 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 | |
|
| 45 | 11 | | public UiContainerHandler(Func<IInternalECSComponent<InternalUiContainer>> componentGet) |
| | 12 | | { |
| 45 | 13 | | this.thisComponent = componentGet(); |
| 45 | 14 | | } |
| | 15 | |
|
| 45 | 16 | | public void OnComponentCreated(IParcelScene scene, IDCLEntity entity) { } |
| | 17 | |
|
| | 18 | | public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity) |
| | 19 | | { |
| 45 | 20 | | var containerData = thisComponent.GetFor(scene, entity); |
| 45 | 21 | | if (containerData != null) |
| | 22 | | { |
| 45 | 23 | | containerData.Value.model.parentElement?.Remove(containerData.Value.model.rootElement); |
| | 24 | | } |
| 25 | 25 | | } |
| | 26 | |
|
| | 27 | | public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, InternalUiContainer model) |
| | 28 | | { |
| 111 | 29 | | if (model.rootElement.childCount == 0 && model.components.Count == 0 && entity.entityId != SpecialEntityId.SCENE |
| | 30 | | { |
| 1 | 31 | | thisComponent.RemoveFor(scene, entity); |
| | 32 | | } |
| 111 | 33 | | } |
| | 34 | | } |