Search in sources :

Example 1 with MessageComponent

use of io.github.voidzombie.nhglib.runtime.ecs.components.common.MessageComponent 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 2 with MessageComponent

use of io.github.voidzombie.nhglib.runtime.ecs.components.common.MessageComponent in project nhglib by VoidZombie.

the class MessageComponentJson method parse.

@Override
public void parse(JsonValue jsonValue) {
    MessageComponent messageComponent = entities.createComponent(entity, MessageComponent.class);
    JsonValue filters = jsonValue.get("filters");
    messageComponent.subscribe(filters.asStringArray());
    output = messageComponent;
}
Also used : JsonValue(com.badlogic.gdx.utils.JsonValue) MessageComponent(io.github.voidzombie.nhglib.runtime.ecs.components.common.MessageComponent)

Aggregations

MessageComponent (io.github.voidzombie.nhglib.runtime.ecs.components.common.MessageComponent)2 JsonValue (com.badlogic.gdx.utils.JsonValue)1 NodeComponent (io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent)1 Message (io.github.voidzombie.nhglib.runtime.messaging.Message)1