fix bug when no messages existed for queried entity
parent
df7abf4cf3
commit
9057228795
|
@ -90,7 +90,7 @@ namespace Encompass
|
||||||
|
|
||||||
public IEnumerable<TMessage> WithEntity(int entityID)
|
public IEnumerable<TMessage> WithEntity(int entityID)
|
||||||
{
|
{
|
||||||
return entityToMessage[entityID];
|
return entityToMessage.ContainsKey(entityID) ? entityToMessage[entityID] : System.Linq.Enumerable.Empty<TMessage>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Clear()
|
public override void Clear()
|
||||||
|
|
|
@ -483,6 +483,20 @@ namespace Tests
|
||||||
entityMessageResults.Should().ContainEquivalentOf(new EntityMessage(entity, 5));
|
entityMessageResults.Should().ContainEquivalentOf(new EntityMessage(entity, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void NoMessagesWithEntity()
|
||||||
|
{
|
||||||
|
var worldBuilder = new WorldBuilder();
|
||||||
|
|
||||||
|
var entity = worldBuilder.CreateEntity();
|
||||||
|
worldBuilder.AddEngine(new EntityMessageReceiverEngine(entity));
|
||||||
|
|
||||||
|
var world = worldBuilder.Build();
|
||||||
|
world.Update(0.01);
|
||||||
|
|
||||||
|
entityMessageResults.Should().BeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
class SomeComponentTestEngine : Engine
|
class SomeComponentTestEngine : Engine
|
||||||
{
|
{
|
||||||
public override void Update(double dt)
|
public override void Update(double dt)
|
||||||
|
|
Loading…
Reference in New Issue