Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
4.8KB

  1. using System;
  2. using Svelto.Common;
  3. using Svelto.DataStructures;
  4. namespace Svelto.ECS.Internal
  5. {
  6. public interface ITypeSafeDictionary<TValue> : ITypeSafeDictionary where TValue : _IInternalEntityComponent
  7. {
  8. void Add(uint egidEntityId, in TValue entityComponent);
  9. bool TryGetValue(uint entityId, out TValue item);
  10. ref TValue GetOrAdd(uint idEntityId);
  11. IBuffer<TValue> GetValues(out uint count);
  12. ref TValue GetDirectValueByRef(uint key);
  13. ref TValue GetValueByRef(uint key);
  14. IEntityIDs entityIDs { get; }
  15. }
  16. public interface ITypeSafeDictionary : IDisposable
  17. {
  18. int count { get; }
  19. ITypeSafeDictionary Create();
  20. void AddEntitiesToDictionary
  21. (ITypeSafeDictionary toDictionary, ExclusiveGroupStruct groupId
  22. #if SLOW_SVELTO_SUBMISSION
  23. , in EnginesRoot.EntityReferenceMap entityLocator
  24. #endif
  25. );
  26. void RemoveEntitiesFromDictionary
  27. (FasterList<(uint, string)> infosToProcess, FasterList<uint> entityIDsAffectedByRemoval);
  28. void SwapEntitiesBetweenDictionaries
  29. (FasterList<(uint, uint, string)> infosToProcess, ExclusiveGroupStruct fromGroup, ExclusiveGroupStruct toGroup
  30. , ITypeSafeDictionary toComponentsDictionary, FasterList<uint> entityIDsAffectedByRemoval);
  31. //------------
  32. //This is now obsolete, but I cannot mark it as such because it's heavily used by legacy projects
  33. void ExecuteEnginesAddCallbacks
  34. (FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnAdd>>> entityComponentEnginesDb
  35. , ITypeSafeDictionary destinationDatabase, ExclusiveGroupStruct toGroup, in PlatformProfiler profiler);
  36. //Version to use
  37. void ExecuteEnginesAddEntityCallbacksFast(
  38. FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnAddEx>>> reactiveEnginesAdd,
  39. ExclusiveGroupStruct groupID, (uint, uint) rangeOfSubmittedEntitiesIndicies, in PlatformProfiler profiler);
  40. //------------
  41. //This is now obsolete, but I cannot mark it as such because it's heavily used by legacy projects
  42. void ExecuteEnginesSwapCallbacks(FasterList<(uint, uint, string)> infosToProcess,
  43. FasterList<ReactEngineContainer<IReactOnSwap>> reactiveEnginesSwap, ExclusiveGroupStruct fromGroup,
  44. ExclusiveGroupStruct toGroup, in PlatformProfiler sampler);
  45. //Version to use
  46. void ExecuteEnginesSwapCallbacksFast(FasterList<ReactEngineContainer<IReactOnSwapEx>> reactiveEnginesSwap,
  47. ExclusiveGroupStruct fromGroup, ExclusiveGroupStruct toGroup, (uint, uint) rangeOfSubmittedEntitiesIndicies,
  48. in PlatformProfiler sampler);
  49. //------------
  50. //This is now obsolete, but I cannot mark it as such because it's heavily used by legacy projects
  51. void ExecuteEnginesRemoveCallbacks(FasterList<(uint, string)> infosToProcess,
  52. FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnRemove>>> reactiveEnginesRemove,
  53. ExclusiveGroupStruct fromGroup, in PlatformProfiler sampler);
  54. //Version to use
  55. void ExecuteEnginesRemoveCallbacksFast(FasterList<ReactEngineContainer<IReactOnRemoveEx>> reactiveEnginesRemoveEx,
  56. ExclusiveGroupStruct fromGroup, (uint, uint) rangeOfSubmittedEntitiesIndicies,
  57. in PlatformProfiler sampler);
  58. //------------
  59. void ExecuteEnginesSwapCallbacks_Group(
  60. FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnSwap>>> reactiveEnginesSwap,
  61. FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnSwapEx>>> reactiveEnginesSwapEx,
  62. ITypeSafeDictionary toEntitiesDictionary, ExclusiveGroupStruct fromGroupId, ExclusiveGroupStruct toGroupId,
  63. in PlatformProfiler platformProfiler);
  64. void ExecuteEnginesRemoveCallbacks_Group(
  65. FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnRemove>>> engines,
  66. FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnRemoveEx>>> reactiveEnginesRemoveEx,
  67. ExclusiveGroupStruct @group, in PlatformProfiler profiler);
  68. void ExecuteEnginesDisposeCallbacks_Group
  69. (FasterDictionary<ComponentID, FasterList<ReactEngineContainer<IReactOnDispose>>> engines
  70. , ExclusiveGroupStruct group, in PlatformProfiler profiler);
  71. void IncreaseCapacityBy(uint size);
  72. void EnsureCapacity(uint size);
  73. void Trim();
  74. void Clear();
  75. bool Has(uint key);
  76. bool ContainsKey(uint egidEntityId);
  77. uint GetIndex(uint valueEntityId);
  78. bool TryFindIndex(uint entityGidEntityId, out uint index);
  79. void KeysEvaluator(Action<uint> action);
  80. }
  81. }