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