Skip to content

Commit 1b74927

Browse files
committed
fix(tutorial): refined tutorial text and fixed controller input
1 parent 00cf6fa commit 1b74927

File tree

7 files changed

+90
-477
lines changed

7 files changed

+90
-477
lines changed

engine/src/main/java/org/destinationsol/SolGameServiceRegistry.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,15 @@
4646
import org.destinationsol.game.planet.PlanetManager;
4747
import org.destinationsol.game.screens.GameScreens;
4848
import org.destinationsol.game.ship.ShipBuilder;
49-
import org.destinationsol.game.tutorial.NewTutorialManager;
50-
import org.destinationsol.ui.TutorialManager;
49+
import org.destinationsol.game.tutorial.TutorialManager;
5150
import org.terasology.context.Lifetime;
5251
import org.terasology.gestalt.di.ServiceRegistry;
5352

5453
public class SolGameServiceRegistry extends ServiceRegistry {
5554
public SolGameServiceRegistry(boolean isTutorial) {
5655
this.with(SolGame.class).lifetime(Lifetime.Singleton);
5756
if (isTutorial) {
58-
// this.with(TutorialManager.class).lifetime(Lifetime.Singleton);
59-
this.with(NewTutorialManager.class).lifetime(Lifetime.Singleton);
57+
this.with(TutorialManager.class).lifetime(Lifetime.Singleton);
6058
}
6159

6260
this.with(EntitySystemManager.class);

engine/src/main/java/org/destinationsol/game/SolGame.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@
5858
import org.destinationsol.game.ship.ShipBuilder;
5959
import org.destinationsol.game.ship.SloMo;
6060
import org.destinationsol.game.ship.hulls.HullConfig;
61-
import org.destinationsol.game.tutorial.NewTutorialManager;
61+
import org.destinationsol.game.tutorial.TutorialManager;
6262
import org.destinationsol.mercenary.MercenaryUtils;
6363
import org.destinationsol.modules.ModuleManager;
6464
import org.destinationsol.ui.DebugCollector;
65-
import org.destinationsol.ui.TutorialManager;
6665
import org.destinationsol.ui.UiDrawer;
6766
import org.destinationsol.ui.Waypoint;
6867
import org.destinationsol.ui.nui.screens.MainGameScreen;
@@ -140,8 +139,6 @@ public class SolGame {
140139
@Inject
141140
protected Optional<TutorialManager> tutorialManager;
142141
@Inject
143-
protected Optional<NewTutorialManager> newTutorialManager;
144-
@Inject
145142
protected BeanContext beanContext;
146143
@Inject
147144
protected GalaxyBuilder galaxyBuilder;
@@ -194,7 +191,6 @@ public void createUpdateSystems() {
194191
updateSystems = new TreeMap<>();
195192
List<UpdateAwareSystem> defaultSystems = new ArrayList<>(Arrays.asList(planetManager, solCam, chunkManager, mountDetectDrawer, objectManager, mapDrawer, soundManager, beaconHandler, drawableDebugger));
196193
tutorialManager.ifPresent(defaultSystems::add);
197-
newTutorialManager.ifPresent(defaultSystems::add);
198194
updateSystems.put(0, defaultSystems);
199195

200196
List<UpdateAwareSystem> defaultPausedSystems = new ArrayList<UpdateAwareSystem>();
@@ -269,7 +265,6 @@ public void run() {
269265
gameScreens.consoleScreen.init(this);
270266
solApplication.getNuiManager().pushScreen(gameScreens.mainGameScreen);
271267
tutorialManager.ifPresent(TutorialManager::start);
272-
newTutorialManager.ifPresent(NewTutorialManager::start);
273268
}
274269

275270
private void addObjectsToPlanetManager() {
@@ -343,7 +338,7 @@ public void onGameEnd(Context context) {
343338
e.printStackTrace();
344339
}
345340
} else {
346-
newTutorialManager.ifPresent(NewTutorialManager::onGameEnd);
341+
tutorialManager.ifPresent(TutorialManager::onGameEnd);
347342
}
348343

349344
// TODO: Remove this when context is reset after each game
@@ -639,7 +634,7 @@ public void setRespawnState() {
639634
}
640635

641636
public boolean isTutorial() {
642-
return tutorialManager.isPresent() || newTutorialManager.isPresent();
637+
return tutorialManager.isPresent();
643638
}
644639

645640
public SolApplication getSolApplication() {

engine/src/main/java/org/destinationsol/game/tutorial/NewTutorialManager.java renamed to engine/src/main/java/org/destinationsol/game/tutorial/TutorialManager.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@
4747
import org.destinationsol.game.tutorial.steps.SelectEquippedWeaponStep;
4848
import org.destinationsol.game.tutorial.steps.SlowVelocityStep;
4949
import org.destinationsol.game.tutorial.steps.ThrustForwardsStep;
50+
import org.destinationsol.game.tutorial.steps.TravelThroughStarPortStep;
5051
import org.destinationsol.game.tutorial.steps.TurnLeftRightStep;
5152
import org.destinationsol.game.tutorial.steps.UseAbilityStep;
5253
import org.destinationsol.game.tutorial.steps.WaitUntilFullyRepairedStep;
5354
import org.destinationsol.ui.nui.NUIManager;
5455
import org.destinationsol.ui.nui.screens.MainGameScreen;
5556
import org.destinationsol.ui.nui.screens.TutorialScreen;
56-
import org.slf4j.Logger;
57-
import org.slf4j.LoggerFactory;
5857
import org.terasology.context.exception.BeanNotFoundException;
5958
import org.terasology.gestalt.di.BeanContext;
6059

@@ -71,7 +70,7 @@
7170
* instances.
7271
* @see TutorialStep
7372
*/
74-
public class NewTutorialManager implements UpdateAwareSystem {
73+
public class TutorialManager implements UpdateAwareSystem {
7574
private final NUIManager nuiManager;
7675
private final TutorialScreen tutorialScreen;
7776
private final SolApplication solApplication;
@@ -81,7 +80,7 @@ public class NewTutorialManager implements UpdateAwareSystem {
8180
private int stepNo;
8281

8382
@Inject
84-
public NewTutorialManager(NUIManager nuiManager, SolApplication solApplication, Provider<SolGame> game, BeanContext beanContext) {
83+
public TutorialManager(NUIManager nuiManager, SolApplication solApplication, Provider<SolGame> game, BeanContext beanContext) {
8584
this.nuiManager = nuiManager;
8685
this.tutorialScreen = (TutorialScreen) nuiManager.createScreen("engine:tutorialScreen");
8786
this.solApplication = solApplication;
@@ -101,8 +100,7 @@ public void start() {
101100
GameOptions gameOptions = solApplication.getOptions();
102101
GameOptions.ControlType controlType = gameOptions.controlType;
103102
boolean isMobile = solApplication.isMobile();
104-
boolean usesKeyboard = !isMobile &&
105-
(controlType != GameOptions.ControlType.MOUSE);
103+
boolean usesKeyboard = !isMobile && (controlType != GameOptions.ControlType.MOUSE);
106104

107105
// A lot of input names will vary by control type. In some control types, the inputs are also hard-coded.
108106
// Rather than a lot of messy conditional statements in-line with the step definitions, we'll set things up here.
@@ -220,7 +218,7 @@ public void start() {
220218
isMobile ? "Open the map." : "Open the map (" + gameOptions.getKeyMapName() + ")."),
221219
new ButtonPressStep(solGame.get().getScreens().mapScreen.getZoomInButton(), "Zoom In"),
222220
new ButtonPressStep(solGame.get().getScreens().mapScreen.getZoomOutButton(), "Zoom Out"),
223-
new MapDragStep("You can move around the map by clicking/tapping and dragging."),
221+
new MapDragStep("You can drag the map to move around."),
224222
new CreateWaypointStep("Create a waypoint near your ship."),
225223
new CloseScreenStep(
226224
solGame.get().getScreens().mapScreen.getCloseButton(),
@@ -237,11 +235,7 @@ public void start() {
237235
new BuyMercenaryStep(1000,
238236
usesKeyboard ? "Select Hire (" + gameOptions.getKeyHireShipMenuName() + ")." : "Select Hire.",
239237
"Try hiring a mercenary."),
240-
new MessageStep("Let's see how your mercenary fights."),
241-
new DestroySpawnedShipsStep(1, "core:pirateSmall",
242-
"core:blaster core:smallShield", "Destroy the targeted ship.",
243-
"Enemy ships can be tough.\nOpen the pause menu and select Respawn."),
244-
new MessageStep("Mercenaries will keep any money they collect as part of their payment."),
238+
new MessageStep("Mercenaries will fight for you. They keep any money they collect as part of their payment."),
245239
new MessageStep("Section 11 - Managing Mercenaries"),
246240
new OpenScreenStep(
247241
solGame.get().getScreens().mainGameScreen.getMercsButton(),
@@ -254,7 +248,8 @@ public void start() {
254248
"Here you can manage your mercenary's equipment."),
255249
new FlyToNearestStarPortStep("Fly to the marked star lane."),
256250
new MessageStep("For a small fee, star lanes allow you to travel quickly between planets."),
257-
new MessageStep("The tutorial is finished. You will be returned to the main menu.")
251+
new TravelThroughStarPortStep("Fly into the centre to travel across the star lane."),
252+
new MessageStep("That's it! The tutorial is finished. You will be returned to the main menu.")
258253
));
259254

260255
for (TutorialStep step : steps) {
@@ -299,28 +294,28 @@ public void update(SolGame game, float timeStep) {
299294
}
300295

301296
TutorialStep currentStep = steps.get(stepNo);
302-
tutorialScreen.setTutorialText(currentStep.getTutorialText(), currentStep.getTutorialBoxPosition());
303-
if (currentStep.getRequiredInput() != null) {
304-
tutorialScreen.setInteractHintInput(currentStep.getTutorialBoxPosition(), currentStep.getRequiredInput());
305-
tutorialScreen.setInteractEvent(currentStep.getTutorialBoxPosition(), currentStep.getInputHandler());
306-
}
297+
setUpTutorialBox(currentStep);
307298
if (currentStep.checkComplete(timeStep)) {
308299
stepNo++;
309300
tutorialScreen.clearAllTutorialBoxes();
310301
if (stepNo < steps.size()) {
311302
TutorialStep newStep = steps.get(stepNo);
312303
newStep.start();
313-
tutorialScreen.setTutorialText(newStep.getTutorialText(), newStep.getTutorialBoxPosition());
314-
if (newStep.getRequiredInput() != null) {
315-
tutorialScreen.setInteractHintInput(newStep.getTutorialBoxPosition(), newStep.getRequiredInput());
316-
tutorialScreen.setInteractEvent(newStep.getTutorialBoxPosition(), newStep.getInputHandler());
317-
}
304+
setUpTutorialBox(newStep);
318305
} else {
319306
solApplication.finishGame();
320307
}
321308
}
322309
}
323310

311+
private void setUpTutorialBox(TutorialStep tutorialStep) {
312+
tutorialScreen.setTutorialText(tutorialStep.getTutorialText(), tutorialStep.getTutorialBoxPosition());
313+
if (tutorialStep.getRequiredInput() != null) {
314+
tutorialScreen.setInteractHintInput(tutorialStep.getTutorialBoxPosition(), tutorialStep.getRequiredInput());
315+
tutorialScreen.setInteractEvent(tutorialStep.getTutorialBoxPosition(), tutorialStep.getInputHandler());
316+
}
317+
}
318+
324319
/**
325320
* This method should be called when either the game or the tutorial ends. It cleans-up the UI changes made for the tutorial.
326321
*/

engine/src/main/java/org/destinationsol/game/tutorial/steps/MessageStep.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.destinationsol.GameOptions;
2020
import org.destinationsol.SolApplication;
21+
import org.destinationsol.game.SolGame;
2122
import org.destinationsol.game.tutorial.TutorialStep;
2223
import org.terasology.input.ControllerInput;
2324
import org.terasology.input.InputType;
@@ -35,6 +36,8 @@ public class MessageStep extends TutorialStep {
3536
protected static final float MIN_STEP_DURATION = 0.5f;
3637
@Inject
3738
protected SolApplication solApplication;
39+
@Inject
40+
protected SolGame game;
3841
protected final String message;
3942
protected float stepTimer;
4043
protected boolean interactComplete;
@@ -81,6 +84,11 @@ public void start() {
8184

8285
@Override
8386
public boolean checkComplete(float timeStep) {
87+
if (solApplication.getOptions().controlType == GameOptions.ControlType.CONTROLLER && game.getHero().getPilot().isShoot()) {
88+
// TODO: NUI doesn't support controller input at the moment, so we detect completion here.
89+
interactComplete = true;
90+
}
91+
8492
stepTimer += timeStep;
8593
return stepTimer >= MIN_STEP_DURATION && interactComplete;
8694
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2023 The Terasology Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.destinationsol.game.tutorial.steps;
18+
19+
import org.destinationsol.game.Hero;
20+
import org.destinationsol.game.SolGame;
21+
import org.destinationsol.game.tutorial.TutorialStep;
22+
23+
import javax.inject.Inject;
24+
25+
/**
26+
* A tutorial step that completes once the player has travelled across a star lane.
27+
*/
28+
public class TravelThroughStarPortStep extends TutorialStep {
29+
@Inject
30+
protected SolGame game;
31+
private final String message;
32+
private boolean wasTranscendent;
33+
34+
@Inject
35+
protected TravelThroughStarPortStep() {
36+
throw new RuntimeException("Attempted to instantiate TutorialStep via DI. This is not supported.");
37+
}
38+
39+
public TravelThroughStarPortStep(String message) {
40+
this.message = message;
41+
}
42+
43+
@Override
44+
public void start() {
45+
setTutorialText(message);
46+
}
47+
48+
@Override
49+
public boolean checkComplete(float timeStep) {
50+
Hero hero = game.getHero();
51+
if (wasTranscendent && !hero.isTranscendent()) {
52+
return true;
53+
}
54+
wasTranscendent = hero.isTranscendent();
55+
return false;
56+
}
57+
}

0 commit comments

Comments
 (0)