rename to ReadMessagesWithEntity

pull/5/head
Evan Hemsley 2019-12-29 23:55:48 -08:00
parent 9057228795
commit 926c05a4db
3 changed files with 12 additions and 2 deletions

View File

@ -647,7 +647,13 @@ namespace Encompass
timeManager.ActivateTimeDilation(factor, easeInTime, easeInFunction, activeTime, easeOutTime, easeOutFunction); timeManager.ActivateTimeDilation(factor, easeInTime, easeInFunction, activeTime, easeOutTime, easeOutFunction);
} }
protected IEnumerable<TMessage> MessagesWithEntity<TMessage>(Entity entity) where TMessage : struct, IMessage, IHasEntity /// <summary>
/// Efficiently reads Messages of a given type that all reference the same Entity.
/// </summary>
/// <typeparam name="TMessage">The Message subtype.</typeparam>
/// <param name="entity">The entity that all messages in the IEnumerable refer to.</param>
/// <returns></returns>
protected IEnumerable<TMessage> ReadMessagesWithEntity<TMessage>(Entity entity) where TMessage : struct, IMessage, IHasEntity
{ {
return messageManager.WithEntity<TMessage>(entity.ID); return messageManager.WithEntity<TMessage>(entity.ID);
} }

View File

@ -60,6 +60,10 @@ namespace Encompass
CallGenericMethod(type, "ReadMessage", null); CallGenericMethod(type, "ReadMessage", null);
CallGenericMethod(type, "ReadMessages", null); CallGenericMethod(type, "ReadMessages", null);
CallGenericMethod(type, "SomeMessage", null); CallGenericMethod(type, "SomeMessage", null);
if (typeof(IHasEntity).IsAssignableFrom(type))
{
CallGenericMethod(type, "ReadMessagesWithEntity", new Type[] { typeof(Entity) }, new object[] { Entity });
}
} }
} }

View File

@ -460,7 +460,7 @@ namespace Tests
public override void Update(double dt) public override void Update(double dt)
{ {
entityMessageResults = MessagesWithEntity<EntityMessage>(_entity).ToList(); entityMessageResults = ReadMessagesWithEntity<EntityMessage>(_entity).ToList();
} }
} }