use of io.github.voidzombie.nhglib.runtime.messaging.Message in project nhglib by VoidZombie.
the class Main method onKeyInput.
@Override
public void onKeyInput(NhgInput input) {
if (scene != null) {
NodeComponent nodeComponent = cameraNode;
switch(input.getName()) {
case "strafeRight":
nodeComponent.translate(0.1f * Gdx.graphics.getDeltaTime(), 0, 0);
break;
case "strafeLeft":
nodeComponent.translate(-0.1f * Gdx.graphics.getDeltaTime(), 0, 0);
break;
case "forward":
nodeComponent.translate(0, 0, -0.1f * Gdx.graphics.getDeltaTime());
break;
case "backward":
nodeComponent.translate(0, 0, 0.1f * Gdx.graphics.getDeltaTime());
break;
case "jump":
cameraNode.rotate(0, 0, 0.1f);
break;
case "sprint":
cameraNode.rotate(0, 0, -0.1f);
break;
case "exit":
nhg.messaging.send(new Message(Strings.Events.engineDestroy));
break;
}
nodeComponent.applyTransforms();
}
}
use of io.github.voidzombie.nhglib.runtime.messaging.Message in project nhglib by VoidZombie.
the class TestNodeSystem method process.
@Override
protected void process(int entityId) {
NodeComponent nodeComponent = nodeMapper.get(entityId);
MessageComponent messageComponent = messageMapper.get(entityId);
Array<Message> messages = messageComponent.getMessages();
for (Message message : messages) {
if (message.is("printNode")) {
Logger.log(this, "id: %d, x: %f, y: %f, z: %f", nodeComponent.id, nodeComponent.getX(), nodeComponent.getY(), nodeComponent.getZ());
messageComponent.consume(message);
}
}
}
use of io.github.voidzombie.nhglib.runtime.messaging.Message in project nhglib by VoidZombie.
the class GraphicsSystem method inserted.
@Override
protected void inserted(int entityId) {
super.inserted(entityId);
final ModelComponent modelComponent = modelMapper.get(entityId);
messaging.get(Strings.Events.assetLoaded).subscribe(new Consumer<Message>() {
@Override
public void accept(Message message) throws Exception {
if (modelComponent.type == ModelComponent.Type.STATIC) {
Asset asset = (Asset) message.data.get(Strings.Defaults.assetKey);
if (asset.is(modelComponent.asset.alias)) {
rebuildCache(modelComponent.model);
}
}
}
});
}
use of io.github.voidzombie.nhglib.runtime.messaging.Message in project nhglib by VoidZombie.
the class Assets method assetLoaded.
public void assetLoaded(Asset asset) {
Bundle bundle = new Bundle();
bundle.put(Strings.Defaults.assetKey, asset);
messaging.send(new Message(Strings.Events.assetLoaded, bundle));
}
use of io.github.voidzombie.nhglib.runtime.messaging.Message in project nhglib by VoidZombie.
the class Assets method assetUnloaded.
public void assetUnloaded(Asset asset) {
Bundle bundle = new Bundle();
bundle.put(Strings.Defaults.assetKey, asset);
messaging.send(new Message(Strings.Events.assetUnloaded, bundle));
}
Aggregations