| | 1 | | using System.Collections.Generic; |
| | 2 | | using DCLPlugins.UUIDEventComponentsPlugin.UUIDComponent.Interfaces; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public static class DataStore_ECS7_Extensions |
| | 8 | | { |
| | 9 | | public static void AddPointerEvent( this DataStore_ECS7 self, long entityId, IPointerInputEvent pointerEvent ) |
| | 10 | | { |
| 8 | 11 | | if (self.entityEvents.TryGetValue(entityId, out List<IPointerInputEvent> events)) |
| | 12 | | { |
| 6 | 13 | | events.Add(pointerEvent); |
| 6 | 14 | | } |
| | 15 | | else |
| | 16 | | { |
| 2 | 17 | | events = new List<IPointerInputEvent>() |
| | 18 | | { |
| | 19 | | pointerEvent |
| | 20 | | }; |
| 2 | 21 | | self.entityEvents.Add(entityId,events); |
| | 22 | | } |
| 2 | 23 | | } |
| | 24 | |
|
| | 25 | | public static void RemovePointerEvent( this DataStore_ECS7 self, long entityId, IPointerInputEvent pointerEvent |
| | 26 | | { |
| 0 | 27 | | if (self.entityEvents.TryGetValue(entityId, out List<IPointerInputEvent> events)) |
| | 28 | | { |
| 0 | 29 | | events.Remove(pointerEvent); |
| 0 | 30 | | if (events.Count == 0) |
| 0 | 31 | | self.entityEvents.Remove(entityId); |
| | 32 | | } |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | public static void AddPendingResource( this DataStore_ECS7 self, string sceneId, object model ) |
| | 36 | | { |
| 77 | 37 | | if (self.pendingSceneResources.TryGetValue(sceneId, out BaseRefCountedCollection<object> pendingResoruces)) |
| | 38 | | { |
| 69 | 39 | | pendingResoruces.IncreaseRefCount(model); |
| 69 | 40 | | } |
| | 41 | | else |
| | 42 | | { |
| 8 | 43 | | BaseRefCountedCollection<object> newCountedCollection = new BaseRefCountedCollection<object>(); |
| 8 | 44 | | newCountedCollection.IncreaseRefCount(model); |
| 8 | 45 | | self.pendingSceneResources.Add(sceneId,newCountedCollection); |
| | 46 | | } |
| 8 | 47 | | } |
| | 48 | |
|
| | 49 | | public static void RemovePendingResource( this DataStore_ECS7 self, string sceneId, object model) |
| | 50 | | { |
| 148 | 51 | | if (self.pendingSceneResources.TryGetValue(sceneId, out BaseRefCountedCollection<object> pendingResoruces)) |
| | 52 | | { |
| 147 | 53 | | pendingResoruces.DecreaseRefCount(model); |
| | 54 | | } |
| 148 | 55 | | } |
| | 56 | |
|
| | 57 | | public static void AddShapeReady( this DataStore_ECS7 self, long entityId, GameObject gameObject ) |
| | 58 | | { |
| 60 | 59 | | self.shapesReady.AddOrSet(entityId,gameObject); |
| 60 | 60 | | } |
| | 61 | |
|
| | 62 | | public static void RemoveShapeReady( this DataStore_ECS7 self, long entityId) |
| | 63 | | { |
| 67 | 64 | | if(self.shapesReady.ContainsKey(entityId)) |
| 51 | 65 | | self.shapesReady.Remove(entityId); |
| 67 | 66 | | } |
| | 67 | | } |
| | 68 | | } |