Search in sources :

Example 56 with ResourceUrn

use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.

the class CoreCommands method editScreen.

/**
 * Opens the NUI editor for a ui screen
 * @param uri String containing ui screen name
 * @return String containing final message
 */
@Command(shortDescription = "Opens the NUI editor for a ui screen", requiredPermission = PermissionManager.NO_PERMISSION)
public String editScreen(@CommandParam(value = "uri", suggester = ScreenSuggester.class) String uri) {
    if (!nuiEditorSystem.isEditorActive()) {
        nuiEditorSystem.toggleEditor();
    }
    Set<ResourceUrn> urns = assetManager.resolve(uri, UIElement.class);
    switch(urns.size()) {
        case 0:
            return String.format("No asset found for screen '%s'", uri);
        case 1:
            ResourceUrn urn = urns.iterator().next();
            ((NUIEditorScreen) nuiManager.getScreen(NUIEditorScreen.ASSET_URI)).selectAsset(urn);
            return "Success";
        default:
            return String.format("Multiple matches for screen '%s': {%s}", uri, Arrays.toString(urns.toArray()));
    }
}
Also used : ResourceUrn(org.terasology.assets.ResourceUrn) NUIEditorScreen(org.terasology.rendering.nui.editor.layers.NUIEditorScreen) Command(org.terasology.logic.console.commandSystem.annotations.Command) ConsoleCommand(org.terasology.logic.console.commandSystem.ConsoleCommand)

Example 57 with ResourceUrn

use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.

the class CoreCommands method editSkin.

/**
 * Opens the NUI editor for a ui skin
 * @param uri String containing name of ui skin
 * @return String containing final message
 */
@Command(shortDescription = "Opens the NUI editor for a ui skin", requiredPermission = PermissionManager.NO_PERMISSION)
public String editSkin(@CommandParam(value = "uri", suggester = SkinSuggester.class) String uri) {
    if (!nuiSkinEditorSystem.isEditorActive()) {
        nuiSkinEditorSystem.toggleEditor();
    }
    Set<ResourceUrn> urns = assetManager.resolve(uri, UISkin.class);
    switch(urns.size()) {
        case 0:
            return String.format("No asset found for screen '%s'", uri);
        case 1:
            ResourceUrn urn = urns.iterator().next();
            ((NUISkinEditorScreen) nuiManager.getScreen(NUISkinEditorScreen.ASSET_URI)).selectAsset(urn);
            return "Success";
        default:
            return String.format("Multiple matches for screen '%s': {%s}", uri, Arrays.toString(urns.toArray()));
    }
}
Also used : NUISkinEditorScreen(org.terasology.rendering.nui.editor.layers.NUISkinEditorScreen) ResourceUrn(org.terasology.assets.ResourceUrn) Command(org.terasology.logic.console.commandSystem.annotations.Command) ConsoleCommand(org.terasology.logic.console.commandSystem.ConsoleCommand)

Example 58 with ResourceUrn

use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.

the class MovementDebugCommands method restoreSpeed.

@Command(shortDescription = "Restore normal speed values", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String restoreSpeed(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    Optional<Prefab> prefab = Assets.get(new ResourceUrn("engine:player"), Prefab.class);
    CharacterMovementComponent moveDefault = prefab.get().getComponent(CharacterMovementComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null && moveDefault != null) {
        move.jumpSpeed = moveDefault.jumpSpeed;
        move.speedMultiplier = moveDefault.speedMultiplier;
        move.runFactor = moveDefault.runFactor;
        move.stepHeight = moveDefault.stepHeight;
        move.slopeFactor = moveDefault.slopeFactor;
        move.distanceBetweenFootsteps = moveDefault.distanceBetweenFootsteps;
        clientComp.character.saveComponent(move);
    }
    return "Normal speed values restored";
}
Also used : CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent) ResourceUrn(org.terasology.assets.ResourceUrn) ClientComponent(org.terasology.network.ClientComponent) Prefab(org.terasology.entitySystem.prefab.Prefab) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 59 with ResourceUrn

use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.

the class LocalPlayerSystem method onFrobButton.

@ReceiveEvent(components = { CharacterComponent.class })
public void onFrobButton(FrobButton event, EntityRef character) {
    if (event.getState() != ButtonState.DOWN) {
        return;
    }
    ResourceUrn activeInteractionScreenUri = InteractionUtil.getActiveInteractionScreenUri(character);
    if (activeInteractionScreenUri != null) {
        InteractionUtil.cancelInteractionAsClient(character);
        return;
    }
    boolean activeRequestSent = localPlayer.activateTargetAsClient();
    if (activeRequestSent) {
        event.consume();
    }
}
Also used : ResourceUrn(org.terasology.assets.ResourceUrn) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 60 with ResourceUrn

use of org.terasology.assets.ResourceUrn in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testPrefabPersistedRetainedCorrectly.

@Test
public void testPrefabPersistedRetainedCorrectly() {
    PrefabData protoPrefab = new PrefabData();
    protoPrefab.setPersisted(false);
    prefab = Assets.generateAsset(new ResourceUrn("unittest:nonpersistentPrefab"), protoPrefab, Prefab.class);
    EntityRef entity1 = entityManager.create(prefab);
    assertFalse(entity1.isPersistent());
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) ResourceUrn(org.terasology.assets.ResourceUrn) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Aggregations

ResourceUrn (org.terasology.assets.ResourceUrn)65 Before (org.junit.Before)10 BlockFamilyDefinitionData (org.terasology.world.block.loader.BlockFamilyDefinitionData)10 AssetManager (org.terasology.assets.management.AssetManager)9 Prefab (org.terasology.entitySystem.prefab.Prefab)9 SymmetricBlockFamilyFactory (org.terasology.world.block.family.SymmetricBlockFamilyFactory)9 Command (org.terasology.logic.console.commandSystem.annotations.Command)8 EntityRef (org.terasology.entitySystem.entity.EntityRef)7 PrefabData (org.terasology.entitySystem.prefab.PrefabData)7 BlockUri (org.terasology.world.block.BlockUri)7 Name (org.terasology.naming.Name)6 Texture (org.terasology.rendering.assets.texture.Texture)6 BlockManagerImpl (org.terasology.world.block.internal.BlockManagerImpl)6 NullWorldAtlas (org.terasology.world.block.tiles.NullWorldAtlas)6 ByteBuffer (java.nio.ByteBuffer)5 Test (org.junit.Test)5 SimpleUri (org.terasology.engine.SimpleUri)5 IOException (java.io.IOException)4 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)4 BiomeManager (org.terasology.world.biomes.BiomeManager)4