Search in sources :

Example 1 with Message

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();
    }
}
Also used : Message(io.github.voidzombie.nhglib.runtime.messaging.Message) NodeComponent(io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent)

Example 2 with Message

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);
        }
    }
}
Also used : Message(io.github.voidzombie.nhglib.runtime.messaging.Message) NodeComponent(io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent) MessageComponent(io.github.voidzombie.nhglib.runtime.ecs.components.common.MessageComponent)

Example 3 with 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);
                }
            }
        }
    });
}
Also used : Message(io.github.voidzombie.nhglib.runtime.messaging.Message) ModelComponent(io.github.voidzombie.nhglib.runtime.ecs.components.graphics.ModelComponent) Asset(io.github.voidzombie.nhglib.assets.Asset)

Example 4 with Message

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));
}
Also used : Message(io.github.voidzombie.nhglib.runtime.messaging.Message) Bundle(io.github.voidzombie.nhglib.utils.data.Bundle)

Example 5 with Message

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));
}
Also used : Message(io.github.voidzombie.nhglib.runtime.messaging.Message) Bundle(io.github.voidzombie.nhglib.utils.data.Bundle)

Aggregations

Message (io.github.voidzombie.nhglib.runtime.messaging.Message)7 Asset (io.github.voidzombie.nhglib.assets.Asset)3 ModelComponent (io.github.voidzombie.nhglib.runtime.ecs.components.graphics.ModelComponent)3 NodeComponent (io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent)3 Bundle (io.github.voidzombie.nhglib.utils.data.Bundle)3 Model (com.badlogic.gdx.graphics.g3d.Model)2 FPSLogger (com.badlogic.gdx.graphics.FPSLogger)1 Environment (com.badlogic.gdx.graphics.g3d.Environment)1 Material (com.badlogic.gdx.graphics.g3d.Material)1 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)1 AnimationController (com.badlogic.gdx.graphics.g3d.utils.AnimationController)1 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)1 ImmediateModeRenderer20 (com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20)1 Array (com.badlogic.gdx.utils.Array)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 Scene (io.github.voidzombie.nhglib.graphics.scenes.Scene)1 GammaCorrectionAttribute (io.github.voidzombie.nhglib.graphics.shaders.attributes.GammaCorrectionAttribute)1 PbrMaterial (io.github.voidzombie.nhglib.graphics.utils.PbrMaterial)1 NhgWorld (io.github.voidzombie.nhglib.graphics.worlds.NhgWorld)1 DefaultWorldStrategy (io.github.voidzombie.nhglib.graphics.worlds.strategies.impl.DefaultWorldStrategy)1