| | 1 | | using DCL; |
| | 2 | | using DCL.Controllers; |
| | 3 | | using DCL.ECSComponents; |
| | 4 | | using DCL.ECSRuntime; |
| | 5 | | using DCL.Models; |
| | 6 | | using DCLPlugins.UUIDEventComponentsPlugin.UUIDComponent.Interfaces; |
| | 7 | |
|
| | 8 | | namespace DCLPlugins.ECSComponents.OnPointerDown |
| | 9 | | { |
| | 10 | | public class OnPointerDownComponentHandler : IECSComponentHandler<PBOnPointerDown> |
| | 11 | | { |
| | 12 | | private PointerInputRepresentantion representantion; |
| | 13 | | private IECSComponentWriter componentWriter; |
| | 14 | | private DataStore_ECS7 dataStore; |
| | 15 | |
|
| | 16 | | private bool isAdded = false; |
| | 17 | |
|
| 4 | 18 | | public OnPointerDownComponentHandler(IECSComponentWriter componentWriter, DataStore_ECS7 dataStore) |
| | 19 | | { |
| 4 | 20 | | this.dataStore = dataStore; |
| 4 | 21 | | this.componentWriter = componentWriter; |
| 4 | 22 | | } |
| | 23 | |
|
| | 24 | | public void OnComponentCreated(IParcelScene scene, IDCLEntity entity) |
| | 25 | | { |
| 4 | 26 | | if(representantion != null) |
| 0 | 27 | | representantion.Dispose(); |
| | 28 | |
|
| 4 | 29 | | representantion = new PointerInputRepresentantion(entity, dataStore, PointerInputEventType.DOWN, componentWr |
| 4 | 30 | | isAdded = false; |
| 4 | 31 | | } |
| | 32 | |
|
| | 33 | | public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity) |
| | 34 | | { |
| 0 | 35 | | dataStore.RemovePointerEvent(entity.entityId, representantion); |
| 0 | 36 | | representantion?.Dispose(); |
| 0 | 37 | | isAdded = false; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, PBOnPointerDown model) |
| | 41 | | { |
| 4 | 42 | | representantion.SetData(scene, entity, model.GetShowFeedback(), model.GetButton(), model.GetMaxDistance(), m |
| 4 | 43 | | if (!isAdded) |
| | 44 | | { |
| 4 | 45 | | isAdded = true; |
| 4 | 46 | | dataStore.AddPointerEvent(entity.entityId, representantion); |
| | 47 | | } |
| 4 | 48 | | } |
| | 49 | | } |
| | 50 | | } |