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);
}
}
}
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;
}
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;
}
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));
}
});
}
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);
}
Aggregations