use of org.terasology.entitySystem.event.internal.EventSystem in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testRemoveComponentEventSent.
@Test
public void testRemoveComponentEventSent() {
EventSystem eventSystem = mock(EventSystem.class);
EntityRef entity1 = entityManager.create();
StringComponent comp = entity1.addComponent(new StringComponent());
entityManager.setEventSystem(eventSystem);
entity1.removeComponent(StringComponent.class);
verify(eventSystem).send(entity1, BeforeDeactivateComponent.newInstance(), comp);
verify(eventSystem).send(entity1, BeforeRemoveComponent.newInstance(), comp);
}
use of org.terasology.entitySystem.event.internal.EventSystem in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testMassRemovedComponentEventSentOnDestroy.
@Test
public void testMassRemovedComponentEventSentOnDestroy() {
EventSystem eventSystem = mock(EventSystem.class);
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
entityManager.setEventSystem(eventSystem);
entity1.destroy();
verify(eventSystem).send(entity1, BeforeDeactivateComponent.newInstance());
verify(eventSystem).send(entity1, BeforeRemoveComponent.newInstance());
}
use of org.terasology.entitySystem.event.internal.EventSystem in project Terasology by MovingBlocks.
the class StateMainMenu method init.
@Override
public void init(GameEngine gameEngine) {
context = gameEngine.createChildContext();
CoreRegistry.setContext(context);
// let's get the entity event system running
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
entityManager = context.get(EngineEntityManager.class);
eventSystem = context.get(EventSystem.class);
console = new ConsoleImpl(context);
context.put(Console.class, console);
nuiManager = new NUIManagerInternal(context.get(CanvasRenderer.class), context);
context.put(NUIManager.class, nuiManager);
eventSystem.registerEventHandler(nuiManager);
componentSystemManager = new ComponentSystemManager(context);
context.put(ComponentSystemManager.class, componentSystemManager);
// TODO: Reduce coupling between Input system and CameraTargetSystem,
// TODO: potentially eliminating the following lines. See Issue #1126
CameraTargetSystem cameraTargetSystem = new CameraTargetSystem();
context.put(CameraTargetSystem.class, cameraTargetSystem);
componentSystemManager.register(cameraTargetSystem, "engine:CameraTargetSystem");
componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem");
componentSystemManager.register(new CoreCommands(), "engine:CoreCommands");
NUIEditorSystem nuiEditorSystem = new NUIEditorSystem();
context.put(NUIEditorSystem.class, nuiEditorSystem);
componentSystemManager.register(nuiEditorSystem, "engine:NUIEditorSystem");
NUISkinEditorSystem nuiSkinEditorSystem = new NUISkinEditorSystem();
context.put(NUISkinEditorSystem.class, nuiSkinEditorSystem);
componentSystemManager.register(nuiSkinEditorSystem, "engine:NUISkinEditorSystem");
inputSystem = context.get(InputSystem.class);
// TODO: REMOVE this and handle refreshing of core game state at the engine level - see Issue #1127
new RegisterInputSystem(context).step();
EntityRef localPlayerEntity = entityManager.create(new ClientComponent());
LocalPlayer localPlayer = new LocalPlayer();
context.put(LocalPlayer.class, localPlayer);
localPlayer.setClientEntity(localPlayerEntity);
componentSystemManager.initialise();
storageServiceWorker = context.get(StorageServiceWorker.class);
playBackgroundMusic();
// guiManager.openWindow("main");
context.get(NUIManager.class).pushScreen("engine:mainMenuScreen");
if (!messageOnLoad.isEmpty()) {
nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error", messageOnLoad);
}
// TODO: enable it when exposing the telemetry to users
// pushLaunchPopup();
}
use of org.terasology.entitySystem.event.internal.EventSystem in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testAddComponentEventSent.
@Test
public void testAddComponentEventSent() {
EventSystem eventSystem = mock(EventSystem.class);
entityManager.setEventSystem(eventSystem);
EntityRef entity1 = entityManager.create();
StringComponent comp = entity1.addComponent(new StringComponent());
verify(eventSystem).send(entity1, OnAddedComponent.newInstance(), comp);
verify(eventSystem).send(entity1, OnActivatedComponent.newInstance(), comp);
}
Aggregations