fix componentmessage self-cycle and rename WorldBuilder.EmitMessage
parent
42a9934d65
commit
80effc06dc
|
@ -40,7 +40,7 @@ namespace Encompass
|
||||||
return entityManager.CreateEntity();
|
return entityManager.CreateEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EmitMessage<TMessage>(TMessage message) where TMessage : struct, IMessage
|
public void SendMessage<TMessage>(TMessage message) where TMessage : struct, IMessage
|
||||||
{
|
{
|
||||||
messageManager.AddMessage(message);
|
messageManager.AddMessage(message);
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,8 @@ namespace Encompass
|
||||||
if (typeToReaders.ContainsKey(messageType))
|
if (typeToReaders.ContainsKey(messageType))
|
||||||
{
|
{
|
||||||
foreach (var readerEngine in typeToReaders[messageType])
|
foreach (var readerEngine in typeToReaders[messageType])
|
||||||
|
{
|
||||||
|
if (senderEngine != readerEngine)
|
||||||
{
|
{
|
||||||
engineGraph.AddEdge(senderEngine, readerEngine);
|
engineGraph.AddEdge(senderEngine, readerEngine);
|
||||||
}
|
}
|
||||||
|
@ -161,6 +163,7 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public World Build()
|
public World Build()
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Tests
|
||||||
AddComponentTestMessage addComponentTestMessage;
|
AddComponentTestMessage addComponentTestMessage;
|
||||||
addComponentTestMessage.entity = entity;
|
addComponentTestMessage.entity = entity;
|
||||||
addComponentTestMessage.mockComponent = mockComponent;
|
addComponentTestMessage.mockComponent = mockComponent;
|
||||||
worldBuilder.EmitMessage(addComponentTestMessage);
|
worldBuilder.SendMessage(addComponentTestMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ namespace Tests
|
||||||
|
|
||||||
EntityMessage entityMessage;
|
EntityMessage entityMessage;
|
||||||
entityMessage.entity = entity;
|
entityMessage.entity = entity;
|
||||||
worldBuilder.EmitMessage(entityMessage);
|
worldBuilder.SendMessage(entityMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ namespace Tests
|
||||||
|
|
||||||
EntityMessage entityMessage;
|
EntityMessage entityMessage;
|
||||||
entityMessage.entity = entity;
|
entityMessage.entity = entity;
|
||||||
worldBuilder.EmitMessage(entityMessage);
|
worldBuilder.SendMessage(entityMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ namespace Tests
|
||||||
|
|
||||||
HasComponentTestMessage hasComponentTestMessage;
|
HasComponentTestMessage hasComponentTestMessage;
|
||||||
hasComponentTestMessage.entity = entity;
|
hasComponentTestMessage.entity = entity;
|
||||||
worldBuilder.EmitMessage(hasComponentTestMessage);
|
worldBuilder.SendMessage(hasComponentTestMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ namespace Tests
|
||||||
|
|
||||||
HasComponentWhenInactiveTestMessage testMessage;
|
HasComponentWhenInactiveTestMessage testMessage;
|
||||||
testMessage.entity = entity;
|
testMessage.entity = entity;
|
||||||
worldBuilder.EmitMessage(testMessage);
|
worldBuilder.SendMessage(testMessage);
|
||||||
|
|
||||||
worldBuilder.DeactivateComponent(componentID);
|
worldBuilder.DeactivateComponent(componentID);
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ namespace Tests
|
||||||
RemoveComponentTestMessage removeComponentMessage;
|
RemoveComponentTestMessage removeComponentMessage;
|
||||||
removeComponentMessage.entity = entity;
|
removeComponentMessage.entity = entity;
|
||||||
removeComponentMessage.componentID = componentID;
|
removeComponentMessage.componentID = componentID;
|
||||||
worldBuilder.EmitMessage(removeComponentMessage);
|
worldBuilder.SendMessage(removeComponentMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ namespace Tests
|
||||||
ActivateComponentMessage activateMessage;
|
ActivateComponentMessage activateMessage;
|
||||||
activateMessage.entity = entity;
|
activateMessage.entity = entity;
|
||||||
activateMessage.componentID = componentID;
|
activateMessage.componentID = componentID;
|
||||||
worldBuilder.EmitMessage(activateMessage);
|
worldBuilder.SendMessage(activateMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ namespace Tests
|
||||||
DeactivateComponentMessage deactivateComponentMessage;
|
DeactivateComponentMessage deactivateComponentMessage;
|
||||||
deactivateComponentMessage.entity = entity;
|
deactivateComponentMessage.entity = entity;
|
||||||
deactivateComponentMessage.componentID = componentID;
|
deactivateComponentMessage.componentID = componentID;
|
||||||
worldBuilder.EmitMessage(deactivateComponentMessage);
|
worldBuilder.SendMessage(deactivateComponentMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
|
|
||||||
|
|
|
@ -697,7 +697,7 @@ namespace Tests
|
||||||
MockComponentUpdateMessage mockComponentUpdateMessage;
|
MockComponentUpdateMessage mockComponentUpdateMessage;
|
||||||
mockComponentUpdateMessage.componentID = mockComponentID;
|
mockComponentUpdateMessage.componentID = mockComponentID;
|
||||||
mockComponentUpdateMessage.mockComponent = mockComponent;
|
mockComponentUpdateMessage.mockComponent = mockComponent;
|
||||||
worldBuilder.EmitMessage(mockComponentUpdateMessage);
|
worldBuilder.SendMessage(mockComponentUpdateMessage);
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
Assert.Throws<RepeatUpdateComponentException>(() => world.Update(0.01));
|
Assert.Throws<RepeatUpdateComponentException>(() => world.Update(0.01));
|
||||||
|
|
Loading…
Reference in New Issue