From 80effc06dc821c55acce6069de3169bb4af5225f Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Thu, 18 Jul 2019 21:07:26 -0700 Subject: [PATCH] fix componentmessage self-cycle and rename WorldBuilder.EmitMessage --- encompass-cs/WorldBuilder.cs | 7 +++++-- test/ComponentTest.cs | 16 ++++++++-------- test/EngineTest.cs | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/encompass-cs/WorldBuilder.cs b/encompass-cs/WorldBuilder.cs index bbf561f..6cd32c8 100644 --- a/encompass-cs/WorldBuilder.cs +++ b/encompass-cs/WorldBuilder.cs @@ -40,7 +40,7 @@ namespace Encompass return entityManager.CreateEntity(); } - public void EmitMessage(TMessage message) where TMessage : struct, IMessage + public void SendMessage(TMessage message) where TMessage : struct, IMessage { messageManager.AddMessage(message); } @@ -155,7 +155,10 @@ namespace Encompass { foreach (var readerEngine in typeToReaders[messageType]) { - engineGraph.AddEdge(senderEngine, readerEngine); + if (senderEngine != readerEngine) + { + engineGraph.AddEdge(senderEngine, readerEngine); + } } } } diff --git a/test/ComponentTest.cs b/test/ComponentTest.cs index 76ba357..e92750f 100644 --- a/test/ComponentTest.cs +++ b/test/ComponentTest.cs @@ -72,7 +72,7 @@ namespace Tests AddComponentTestMessage addComponentTestMessage; addComponentTestMessage.entity = entity; addComponentTestMessage.mockComponent = mockComponent; - worldBuilder.EmitMessage(addComponentTestMessage); + worldBuilder.SendMessage(addComponentTestMessage); var world = worldBuilder.Build(); @@ -227,7 +227,7 @@ namespace Tests EntityMessage entityMessage; entityMessage.entity = entity; - worldBuilder.EmitMessage(entityMessage); + worldBuilder.SendMessage(entityMessage); var world = worldBuilder.Build(); @@ -250,7 +250,7 @@ namespace Tests EntityMessage entityMessage; entityMessage.entity = entity; - worldBuilder.EmitMessage(entityMessage); + worldBuilder.SendMessage(entityMessage); var world = worldBuilder.Build(); @@ -292,7 +292,7 @@ namespace Tests HasComponentTestMessage hasComponentTestMessage; hasComponentTestMessage.entity = entity; - worldBuilder.EmitMessage(hasComponentTestMessage); + worldBuilder.SendMessage(hasComponentTestMessage); var world = worldBuilder.Build(); @@ -331,7 +331,7 @@ namespace Tests HasComponentWhenInactiveTestMessage testMessage; testMessage.entity = entity; - worldBuilder.EmitMessage(testMessage); + worldBuilder.SendMessage(testMessage); worldBuilder.DeactivateComponent(componentID); @@ -407,7 +407,7 @@ namespace Tests RemoveComponentTestMessage removeComponentMessage; removeComponentMessage.entity = entity; removeComponentMessage.componentID = componentID; - worldBuilder.EmitMessage(removeComponentMessage); + worldBuilder.SendMessage(removeComponentMessage); var world = worldBuilder.Build(); @@ -495,7 +495,7 @@ namespace Tests ActivateComponentMessage activateMessage; activateMessage.entity = entity; activateMessage.componentID = componentID; - worldBuilder.EmitMessage(activateMessage); + worldBuilder.SendMessage(activateMessage); var world = worldBuilder.Build(); @@ -569,7 +569,7 @@ namespace Tests DeactivateComponentMessage deactivateComponentMessage; deactivateComponentMessage.entity = entity; deactivateComponentMessage.componentID = componentID; - worldBuilder.EmitMessage(deactivateComponentMessage); + worldBuilder.SendMessage(deactivateComponentMessage); var world = worldBuilder.Build(); diff --git a/test/EngineTest.cs b/test/EngineTest.cs index ef882c1..5715380 100644 --- a/test/EngineTest.cs +++ b/test/EngineTest.cs @@ -697,7 +697,7 @@ namespace Tests MockComponentUpdateMessage mockComponentUpdateMessage; mockComponentUpdateMessage.componentID = mockComponentID; mockComponentUpdateMessage.mockComponent = mockComponent; - worldBuilder.EmitMessage(mockComponentUpdateMessage); + worldBuilder.SendMessage(mockComponentUpdateMessage); var world = worldBuilder.Build(); Assert.Throws(() => world.Update(0.01));