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