Search in sources :

Example 36 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class EntitySystemSetupUtil method registerEvents.

private static void registerEvents(EventSystem eventSystem, ModuleEnvironment environment) {
    for (Class<? extends Event> type : environment.getSubtypesOf(Event.class)) {
        if (type.getAnnotation(DoNotAutoRegister.class) == null) {
            Name module = verifyNotNull(environment.getModuleProviding(type), "Environment has no module for %s", type.getSimpleName());
            eventSystem.registerEvent(new ResourceUrn(module.toString(), type.getSimpleName()), type);
        }
    }
}
Also used : DoNotAutoRegister(org.terasology.engine.entitySystem.systems.internal.DoNotAutoRegister) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Name(org.terasology.gestalt.naming.Name)

Example 37 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class CollectiveBehaviorSystem method createTree.

public BehaviorTree createTree(String name, BehaviorNode root) {
    BehaviorTreeData data = new BehaviorTreeData();
    data.setRoot(root);
    BehaviorTree behaviorTree = assetManager.loadAsset(new ResourceUrn(BEHAVIORS, new Name(name.replaceAll("\\W+", ""))), data, BehaviorTree.class);
    trees.add(behaviorTree);
    save(behaviorTree);
    return behaviorTree;
}
Also used : BehaviorTreeData(org.terasology.engine.logic.behavior.asset.BehaviorTreeData) BehaviorTree(org.terasology.engine.logic.behavior.asset.BehaviorTree) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Name(org.terasology.gestalt.naming.Name)

Example 38 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class BehaviorSystem method createTree.

public BehaviorTree createTree(String name, BehaviorNode root) {
    BehaviorTreeData data = new BehaviorTreeData();
    data.setRoot(root);
    BehaviorTree behaviorTree = assetManager.loadAsset(new ResourceUrn(BEHAVIORS, new Name(name.replaceAll("\\W+", ""))), data, BehaviorTree.class);
    trees.add(behaviorTree);
    save(behaviorTree);
    return behaviorTree;
}
Also used : BehaviorTreeData(org.terasology.engine.logic.behavior.asset.BehaviorTreeData) BehaviorTree(org.terasology.engine.logic.behavior.asset.BehaviorTree) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Name(org.terasology.gestalt.naming.Name)

Example 39 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class ChatScreen method initialise.

@Override
public void initialise() {
    final ScrollableArea scrollArea = find("scrollArea", ScrollableArea.class);
    scrollArea.moveToBottom();
    commandLine = find("commandLine", UIText.class);
    getManager().setFocus(commandLine);
    commandLine.subscribe(widget -> {
        String text = commandLine.getText();
        if (StringUtils.isNotBlank(text)) {
            String command = "say";
            List<String> params = Collections.singletonList(text);
            // TODO: move command execution to separate class
            console.execute(new Name(command), params, localPlayer.getClientEntity());
            commandLine.setText("");
            scrollArea.moveToBottom();
            NotificationOverlay overlay = nuiManager.addOverlay(NotificationOverlay.ASSET_URI, NotificationOverlay.class);
            overlay.setVisible(true);
            nuiManager.closeScreen(this);
        } else {
            commandLine.setText("");
            nuiManager.closeScreen(this);
        }
    });
    final UILabel history = find("messageHistory", UILabel.class);
    history.bindText(new ReadOnlyBinding<String>() {

        @Override
        public String get() {
            Iterable<Message> messageIterable = console.getMessages(CoreMessageType.CHAT, CoreMessageType.NOTIFICATION);
            Stream<Message> messageStream = StreamSupport.stream(messageIterable.spliterator(), false);
            return messageStream.map(Message::getMessage).collect(Collectors.joining(Console.NEW_LINE));
        }
    });
}
Also used : UILabel(org.terasology.nui.widgets.UILabel) Message(org.terasology.engine.logic.console.Message) ScrollableArea(org.terasology.nui.layouts.ScrollableArea) UIText(org.terasology.nui.widgets.UIText) Stream(java.util.stream.Stream) Name(org.terasology.gestalt.naming.Name)

Example 40 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class ConsoleImpl method execute.

@Override
public boolean execute(String rawCommand, EntityRef callingClient) {
    String commandName = processCommandName(rawCommand);
    List<String> processedParameters = processParameters(rawCommand);
    ClientComponent cc = callingClient.getComponent(ClientComponent.class);
    if (cc.local) {
        if (!rawCommand.isEmpty() && (localCommandHistory.isEmpty() || !localCommandHistory.getLast().equals(rawCommand))) {
            localCommandHistory.add(rawCommand);
        }
    }
    return execute(new Name(commandName), processedParameters, callingClient);
}
Also used : ClientComponent(org.terasology.engine.network.ClientComponent) Name(org.terasology.gestalt.naming.Name)

Aggregations

Name (org.terasology.gestalt.naming.Name)58 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)15 Module (org.terasology.gestalt.module.Module)14 SimpleUri (org.terasology.engine.core.SimpleUri)13 ModuleManager (org.terasology.engine.core.module.ModuleManager)10 DependencyResolver (org.terasology.gestalt.module.dependencyresolution.DependencyResolver)7 IOException (java.io.IOException)6 ResolutionResult (org.terasology.gestalt.module.dependencyresolution.ResolutionResult)6 List (java.util.List)5 GameEngine (org.terasology.engine.core.GameEngine)5 SubtextureData (org.terasology.engine.rendering.assets.texture.subtexture.SubtextureData)5 BlockUri (org.terasology.engine.world.block.BlockUri)5 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)5 UIText (org.terasology.nui.widgets.UIText)5 Map (java.util.Map)4 Set (java.util.Set)4 Config (org.terasology.engine.config.Config)4 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3