singular message reads are ref readonly
continuous-integration/drone/push Build is passing Details

pull/3/head
Evan Hemsley 2020-03-22 14:20:22 -07:00
parent 0d969322ad
commit 26216a295f
3 changed files with 6 additions and 6 deletions

View File

@ -33,9 +33,9 @@ namespace Encompass
Lookup<TMessage>().AddIgnoringTimeDilation(message, time);
}
public TMessage First<TMessage>() where TMessage : struct, IMessage
public ref readonly TMessage First<TMessage>() where TMessage : struct, IMessage
{
return Lookup<TMessage>().First();
return ref Lookup<TMessage>().First();
}
public Span<TMessage> All<TMessage>() where TMessage : struct, IMessage

View File

@ -78,9 +78,9 @@ namespace Encompass
_delayedStoreIgnoringTimeDilation.Add((message, time));
}
public TMessage First()
public ref readonly TMessage First()
{
return _store[0];
return ref _store[0];
}
public bool Any()

View File

@ -731,10 +731,10 @@ namespace Encompass
/// Efficiently reads a single Message of a given type that references a given Entity.
/// It is recommended to use this method in conjunction with SomeMessageWithEntity to prevent errors.
/// </summary>
protected TMessage ReadMessageWithEntity<TMessage>(Entity entity) where TMessage : struct, IMessage, IHasEntity
protected ref readonly TMessage ReadMessageWithEntity<TMessage>(Entity entity) where TMessage : struct, IMessage, IHasEntity
{
CheckMessageRead<TMessage>();
return _messageManager.WithEntitySingular<TMessage>(entity.ID);
return ref _messageManager.WithEntitySingular<TMessage>(entity.ID);
}
/// <summary>