diff --git a/encompass-cs/Collections/ComponentDeltaStore.cs b/encompass-cs/Collections/ComponentDeltaStore.cs index 48d44c4..75a3b75 100644 --- a/encompass-cs/Collections/ComponentDeltaStore.cs +++ b/encompass-cs/Collections/ComponentDeltaStore.cs @@ -74,7 +74,7 @@ namespace Encompass } } - public Span AllEntities() where TComponent : struct + public ReadOnlySpan AllEntities() where TComponent : struct { return _store.AllEntities(); } diff --git a/encompass-cs/Collections/ComponentStore.cs b/encompass-cs/Collections/ComponentStore.cs index bfbc8af..986a5b0 100644 --- a/encompass-cs/Collections/ComponentStore.cs +++ b/encompass-cs/Collections/ComponentStore.cs @@ -113,12 +113,12 @@ namespace Encompass return Lookup().Count > 0; } - public Span All() where TComponent : struct + public ReadOnlySpan All() where TComponent : struct { return Lookup().AllComponents(); } - public Span AllEntities() where TComponent : struct + public ReadOnlySpan AllEntities() where TComponent : struct { return Lookup().AllEntities(); } diff --git a/encompass-cs/Collections/MessageStore.cs b/encompass-cs/Collections/MessageStore.cs index 3f57158..196dc7f 100644 --- a/encompass-cs/Collections/MessageStore.cs +++ b/encompass-cs/Collections/MessageStore.cs @@ -41,7 +41,7 @@ namespace Encompass return ref Lookup().First(); } - public Span All() where TMessage : struct, IMessage + public ReadOnlySpan All() where TMessage : struct, IMessage { return Lookup().All(); } diff --git a/encompass-cs/Collections/TypedComponentStore.cs b/encompass-cs/Collections/TypedComponentStore.cs index 232fa2b..83cd785 100644 --- a/encompass-cs/Collections/TypedComponentStore.cs +++ b/encompass-cs/Collections/TypedComponentStore.cs @@ -127,14 +127,14 @@ namespace Encompass _priorities.Clear(); } - public Span AllEntities() + public ReadOnlySpan AllEntities() { - return new Span(_storageIndexToEntities, 0, _nextID); + return new ReadOnlySpan(_storageIndexToEntities, 0, _nextID); } - public Span AllComponents() + public ReadOnlySpan AllComponents() { - return new Span(_components, 0, _nextID); + return new ReadOnlySpan(_components, 0, _nextID); } } } diff --git a/encompass-cs/Collections/TypedMessageStore.cs b/encompass-cs/Collections/TypedMessageStore.cs index c8a263e..a9f222b 100644 --- a/encompass-cs/Collections/TypedMessageStore.cs +++ b/encompass-cs/Collections/TypedMessageStore.cs @@ -92,9 +92,9 @@ namespace Encompass return _nextIndex != 0; } - public Span All() + public ReadOnlySpan All() { - return new Span(_store, 0, _nextIndex); + return new ReadOnlySpan(_store, 0, _nextIndex); } public IEnumerable WithEntity(int entityID) diff --git a/encompass-cs/ComponentManager.cs b/encompass-cs/ComponentManager.cs index 49fe78d..868ba05 100644 --- a/encompass-cs/ComponentManager.cs +++ b/encompass-cs/ComponentManager.cs @@ -98,7 +98,7 @@ namespace Encompass // existing or immediate reads - internal Span ReadExistingAndImmediateComponentsByType() where TComponent : struct + internal ReadOnlySpan ReadExistingAndImmediateComponentsByType() where TComponent : struct { return _upToDateComponentStore.All(); } @@ -108,7 +108,7 @@ namespace Encompass return ref _upToDateComponentStore.Singular(); } - internal Span GetExistingAndImmediateEntities() where TComponent : struct + internal ReadOnlySpan GetExistingAndImmediateEntities() where TComponent : struct { return _upToDateComponentStore.AllEntities(); } @@ -125,7 +125,7 @@ namespace Encompass // existing reads - internal Span GetExistingComponents() where TComponent : struct + internal ReadOnlySpan GetExistingComponents() where TComponent : struct { return _existingComponentStore.All(); } @@ -135,7 +135,7 @@ namespace Encompass return ref _existingComponentStore.Singular(); } - internal Span GetExistingEntities() where TComponent : struct + internal ReadOnlySpan GetExistingEntities() where TComponent : struct { return _existingComponentStore.AllEntities(); } @@ -152,7 +152,7 @@ namespace Encompass // immediate reads - internal Span ReadImmediateComponentsByType() where TComponent : struct + internal ReadOnlySpan ReadImmediateComponentsByType() where TComponent : struct { return _immediateComponentStore.All(); } @@ -162,7 +162,7 @@ namespace Encompass return ref _immediateComponentStore.Singular(); } - internal Span GetImmediateEntities() where TComponent : struct + internal ReadOnlySpan GetImmediateEntities() where TComponent : struct { return _immediateComponentStore.AllEntities(); } @@ -226,7 +226,7 @@ namespace Encompass return _immediateComponentStore.Has(type, entityID); } - internal Span GetComponentsByType() where TComponent : struct + internal ReadOnlySpan GetComponentsByType() where TComponent : struct { return _existingComponentStore.All(); } diff --git a/encompass-cs/Engine.cs b/encompass-cs/Engine.cs index 548d7f6..46abe4d 100644 --- a/encompass-cs/Engine.cs +++ b/encompass-cs/Engine.cs @@ -223,7 +223,7 @@ namespace Encompass /// /// Returns all Entities containing the specified Component type. /// - protected Span ReadEntities() where TComponent : struct, IComponent + protected ReadOnlySpan ReadEntities() where TComponent : struct, IComponent { var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent)); var existingRead = ReadTypes.Contains(typeof(TComponent)); @@ -273,7 +273,7 @@ namespace Encompass /// /// Returns all of the Components with the specified Component Type. /// - protected Span ReadComponents() where TComponent : struct, IComponent + protected ReadOnlySpan ReadComponents() where TComponent : struct, IComponent { var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent)); var existingRead = ReadTypes.Contains(typeof(TComponent)); @@ -550,7 +550,7 @@ namespace Encompass /// /// Thrown when the Engine does not declare that it Receives the specified Message Type. /// - protected Span ReadMessages() where TMessage : struct, IMessage + protected ReadOnlySpan ReadMessages() where TMessage : struct, IMessage { CheckMessageRead(); return _messageManager.GetMessagesByType(); diff --git a/encompass-cs/MessageManager.cs b/encompass-cs/MessageManager.cs index 234f46f..73f4c20 100644 --- a/encompass-cs/MessageManager.cs +++ b/encompass-cs/MessageManager.cs @@ -38,7 +38,7 @@ namespace Encompass _messageStore.ProcessDelayedMessages(dt * _timeManager.TimeDilationFactor, dt); } - internal Span GetMessagesByType() where TMessage : struct, IMessage + internal ReadOnlySpan GetMessagesByType() where TMessage : struct, IMessage { return _messageStore.All(); } diff --git a/encompass-cs/Renderer.cs b/encompass-cs/Renderer.cs index 85b5489..697e377 100644 --- a/encompass-cs/Renderer.cs +++ b/encompass-cs/Renderer.cs @@ -18,7 +18,7 @@ namespace Encompass _componentManager = componentManager; } - protected Span ReadEntities() where TComponent : struct, IComponent + protected ReadOnlySpan ReadEntities() where TComponent : struct, IComponent { return _componentManager.GetExistingEntities(); } @@ -28,7 +28,7 @@ namespace Encompass return ref _componentManager.ExistingSingularEntity(); } - protected Span ReadComponents() where TComponent : struct, IComponent + protected ReadOnlySpan ReadComponents() where TComponent : struct, IComponent { return _componentManager.GetComponentsByType(); }