Mirror of Svelto.ECS because we're a fan of it
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EntitySubmitOperation.cs 1.9KB

Svelto.ECS 2.9 changes (random order of importance): New Serialization framework more thorough disposing of the EnginesRoot an EnginesRoot reference should never be held, unless it’s a weak reference. The code changed to stick to this rule IReactOnAddAndRemove callbacks are now guaranteed to be called after all the entity structs generated by the same entity have been added and before any is removed. both functions pass the EGID of the analysing entity by parameter now, so that the entity struct won’t need to implement INeedEGID for this sole purpose. The IReactOnSwap MovedFrom method has been removed, it is now redundant. Entities built or removed during the IReactOnAddAndRemove callbacks are now added and removed immediately and not on the next submission like used to happen. This avoid some awkward checks that were previously needed inside engines. EntityStreams can get (optionally) the EGID of the entity published, so that the EntityStruct won’t need an INeedEGID for this sole purpose. Groups are not trimmed anymore when they are emptied to avoid allocations. Removed a bunch of run-time allocations that weren’t supposed to happen in Release and/or when the Profile define is used in editor (for debugging reasons Svelto.ECS may need to use strings at run-time, but Svelto.ECS is allocation zero in Release and when the Profile keyword is used) A improved the DynamicEntityDescriptor and ExtendibleEntityDescriptor code and more notably, introduced the new method ExtendedWith<> to facilitate the writing of modular and reusable entity descriptors. Several minor code design improvements/optimisations
4 년 전
Svelto.ECS 2.9 changes (random order of importance): New Serialization framework more thorough disposing of the EnginesRoot an EnginesRoot reference should never be held, unless it’s a weak reference. The code changed to stick to this rule IReactOnAddAndRemove callbacks are now guaranteed to be called after all the entity structs generated by the same entity have been added and before any is removed. both functions pass the EGID of the analysing entity by parameter now, so that the entity struct won’t need to implement INeedEGID for this sole purpose. The IReactOnSwap MovedFrom method has been removed, it is now redundant. Entities built or removed during the IReactOnAddAndRemove callbacks are now added and removed immediately and not on the next submission like used to happen. This avoid some awkward checks that were previously needed inside engines. EntityStreams can get (optionally) the EGID of the entity published, so that the EntityStruct won’t need an INeedEGID for this sole purpose. Groups are not trimmed anymore when they are emptied to avoid allocations. Removed a bunch of run-time allocations that weren’t supposed to happen in Release and/or when the Profile define is used in editor (for debugging reasons Svelto.ECS may need to use strings at run-time, but Svelto.ECS is allocation zero in Release and when the Profile keyword is used) A improved the DynamicEntityDescriptor and ExtendibleEntityDescriptor code and more notably, introduced the new method ExtendedWith<> to facilitate the writing of modular and reusable entity descriptors. Several minor code design improvements/optimisations
4 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. namespace Svelto.ECS
  3. {
  4. #pragma warning disable 660,661
  5. struct EntitySubmitOperation
  6. #pragma warning restore 660,661
  7. : IEquatable<EntitySubmitOperation>
  8. {
  9. public readonly EntitySubmitOperationType type;
  10. public readonly IComponentBuilder[] builders;
  11. public readonly EGID fromID;
  12. public readonly EGID toID;
  13. #if DEBUG && !PROFILE_SVELTO
  14. public System.Diagnostics.StackFrame trace;
  15. #endif
  16. public EntitySubmitOperation(EntitySubmitOperationType operation, EGID from, EGID to,
  17. IComponentBuilder[] builders = null)
  18. {
  19. type = operation;
  20. this.builders = builders;
  21. fromID = from;
  22. toID = to;
  23. #if DEBUG && !PROFILE_SVELTO
  24. trace = default;
  25. #endif
  26. }
  27. public EntitySubmitOperation
  28. (EntitySubmitOperationType operation, ExclusiveGroupStruct @group
  29. , IComponentBuilder[] descriptorComponentsToBuild):this()
  30. {
  31. type = operation;
  32. this.builders = descriptorComponentsToBuild;
  33. fromID = new EGID(0, group);
  34. #if DEBUG && !PROFILE_SVELTO
  35. trace = default;
  36. #endif
  37. }
  38. public static bool operator ==(EntitySubmitOperation obj1, EntitySubmitOperation obj2)
  39. {
  40. return obj1.Equals(obj2);
  41. }
  42. public static bool operator !=(EntitySubmitOperation obj1, EntitySubmitOperation obj2)
  43. {
  44. return obj1.Equals(obj2) == false;
  45. }
  46. public bool Equals(EntitySubmitOperation other)
  47. {
  48. return type == other.type && fromID == other.fromID && toID == other.toID;
  49. }
  50. }
  51. enum EntitySubmitOperationType
  52. {
  53. Swap,
  54. Remove,
  55. RemoveGroup,
  56. SwapGroup
  57. }
  58. }