| | 1 | | using DCL.Controllers; |
| | 2 | | using DCL.ECSComponents; |
| | 3 | | using DCL.Models; |
| | 4 | |
|
| | 5 | | namespace DCL.ECS7.UI |
| | 6 | | { |
| | 7 | | public interface IUIDataContainer |
| | 8 | | { |
| | 9 | | void AddUIComponent(IParcelScene scene, IDCLEntity entity, PBUiTransform model); |
| | 10 | | void AddUIComponent(IParcelScene scene, IDCLEntity entity, PBUiText model); |
| | 11 | | void RemoveUITransform(IParcelScene scene, IDCLEntity entity); |
| | 12 | | void RemoveUIText(IParcelScene scene, IDCLEntity entity); |
| | 13 | | UISceneDataContainer GetDataContainer(IParcelScene scene); |
| | 14 | | } |
| | 15 | |
|
| | 16 | | public class UIDataContainer : IUIDataContainer |
| | 17 | | { |
| 556 | 18 | | public readonly BaseDictionary<string, UISceneDataContainer> sceneData = new BaseDictionary<string, UISceneDataC |
| | 19 | |
|
| | 20 | | public void AddUIComponent(IParcelScene scene, IDCLEntity entity, PBUiTransform model) |
| | 21 | | { |
| 17 | 22 | | GetDataContainer(scene).AddUIComponent(entity,model); |
| 17 | 23 | | } |
| | 24 | |
|
| | 25 | | public void AddUIComponent(IParcelScene scene, IDCLEntity entity, PBUiText model) |
| | 26 | | { |
| 0 | 27 | | GetDataContainer(scene).AddUIComponent(entity,model); |
| 0 | 28 | | } |
| | 29 | |
|
| | 30 | | public void RemoveUITransform(IParcelScene scene, IDCLEntity entity) |
| | 31 | | { |
| 0 | 32 | | GetDataContainer(scene).RemoveUITransform(entity); |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | public void RemoveUIText(IParcelScene scene, IDCLEntity entity) |
| | 36 | | { |
| 0 | 37 | | GetDataContainer(scene).RemoveUIText(entity); |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | public UISceneDataContainer GetDataContainer(IParcelScene scene) |
| | 41 | | { |
| 21 | 42 | | var sceneId = scene.sceneData.id; |
| | 43 | |
|
| 21 | 44 | | if(sceneData.TryGetValue(sceneId, out UISceneDataContainer sceneDataContainer)) |
| | 45 | | { |
| 17 | 46 | | return sceneDataContainer; |
| | 47 | | } |
| | 48 | | else |
| | 49 | | { |
| 4 | 50 | | UISceneDataContainer newSceneDataContainer = new UISceneDataContainer(); |
| 4 | 51 | | sceneData[sceneId] = newSceneDataContainer; |
| 4 | 52 | | return newSceneDataContainer; |
| | 53 | | } |
| | 54 | | } |
| | 55 | | } |
| | 56 | | } |