refactor(nui): remove CoreRegistry from DeathScreen
import org.terasology.nui.WidgetUtil;
import org.terasology.nui.widgets.UILabel;
import org.terasology.registry.CoreRegistry;
+import org.terasology.registry.In;
import org.terasology.rendering.nui.CoreScreenLayer;
/**
public class DeathScreen extends CoreScreenLayer {
private UILabel deathDetails;
+ @In
+ protected LocalPlayer localPlayer;
+ @In
+ protected GameEngine gameEngine;
+
@Override
protected boolean isEscapeToCloseAllowed() {
return false;
@@ -26,13 +32,13 @@ protected boolean isEscapeToCloseAllowed() {
public void initialise() {
deathDetails = find("deathDetails", UILabel.class);
WidgetUtil.trySubscribe(this, "respawn", widget -> {
- CoreRegistry.get(LocalPlayer.class).getClientEntity().send(new RespawnRequestEvent());
+ localPlayer.getClientEntity().send(new RespawnRequestEvent());
getManager().closeScreen(DeathScreen.this);
});
WidgetUtil.trySubscribe(this, "settings", widget -> getManager().pushScreen("settingsMenuScreen"));
WidgetUtil.trySubscribe(this, "mainMenu", widget -> {
- CoreRegistry.get(LocalPlayer.class).getClientEntity().send(new RespawnRequestEvent());
- CoreRegistry.get(GameEngine.class).changeState(new StateMainMenu());
+ localPlayer.getClientEntity().send(new RespawnRequestEvent());
+ gameEngine.changeState(new StateMainMenu());
});
WidgetUtil.trySubscribe(this, "exitGame", widget -> CoreRegistry.get(GameEngine.class).shutdown());
}
