Skip to content

Commit 0f6926b

Browse files
authored
Merge pull request #674 from BenjaminAmos/tutorial-rework
New Tutorial
2 parents 5a924de + 670b073 commit 0f6926b

File tree

60 files changed

+3594
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3594
-497
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
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.ui.TutorialManager;
49+
import org.destinationsol.game.tutorial.TutorialManager;
5050
import org.terasology.context.Lifetime;
5151
import org.terasology.gestalt.di.ServiceRegistry;
5252

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,14 @@ public void update(SolGame game, float timeStep) {
141141
}
142142
if (isNear(fod, camPos, timeStep)) {
143143
SolObject o = fo.toObject(game);
144-
// Ensure that StarPorts are added straight away so that we can see if they overlap
145-
if (o instanceof StarPort) {
146-
addObjNow(game, o);
147-
} else {
148-
addObjDelayed(o);
144+
// Rarely a far object can produce a null sol object because the instance it references no longer exists.
145+
if (o != null) {
146+
// Ensure that StarPorts are added straight away so that we can see if they overlap
147+
if (o instanceof StarPort) {
148+
addObjNow(game, o);
149+
} else {
150+
addObjDelayed(o);
151+
}
149152
}
150153
removeFo(it, fo);
151154
}

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ private void addAndEquipItems(Hero hero, RespawnState respawnState, SolGame game
6767
ItemContainer itemContainer = hero.getItemContainer();
6868
if (!respawnState.getRespawnItems().isEmpty()) {
6969
addAndEquipRespawnItems(hero, respawnState, itemContainer, game);
70-
} else if (game.isTutorial()) {
71-
addRandomTutorialItems(game, itemContainer);
7270
}
7371
itemContainer.markAllAsSeen();
7472
}
@@ -96,18 +94,6 @@ private void addWaypoints(Hero hero, String waypoints, RespawnState respawnState
9694
}
9795
}
9896

99-
private void addRandomTutorialItems(SolGame game, ItemContainer itemContainer) {
100-
for (int i = 0; i < NUMBER_OF_TUTORIAL_ITEM_ADD_ATTEMPTS; i++) {
101-
if (itemContainer.groupCount() > MAX_NUMBER_OF_TUTORIAL_ITEM_GROUPS) {
102-
return;
103-
}
104-
SolItem item = game.getItemMan().random();
105-
if (isNoGunAndHasIcon(item, game) && itemContainer.canAdd(item)) {
106-
itemContainer.add(item.copy());
107-
}
108-
}
109-
}
110-
11197
private boolean isNoGunAndHasIcon(SolItem it, SolGame game) {
11298
return !(it instanceof Gun) && it.getIcon(game) != null;
11399
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +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.TutorialManager;
6162
import org.destinationsol.mercenary.MercenaryUtils;
6263
import org.destinationsol.modules.ModuleManager;
6364
import org.destinationsol.ui.DebugCollector;
64-
import org.destinationsol.ui.TutorialManager;
6565
import org.destinationsol.ui.UiDrawer;
6666
import org.destinationsol.ui.Waypoint;
6767
import org.destinationsol.ui.nui.screens.MainGameScreen;
@@ -337,6 +337,8 @@ public void onGameEnd(Context context) {
337337
} catch (Exception e) {
338338
e.printStackTrace();
339339
}
340+
} else {
341+
tutorialManager.ifPresent(TutorialManager::onGameEnd);
340342
}
341343

342344
// TODO: Remove this when context is reset after each game

engine/src/main/java/org/destinationsol/game/screens/ChooseMercenaryScreen.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.destinationsol.ui.SolInputManager;
2525
import org.destinationsol.ui.nui.NUIManager;
2626
import org.destinationsol.ui.nui.screens.InventoryScreen;
27-
import org.destinationsol.ui.nui.widgets.KeyActivatedButton;
27+
import org.destinationsol.ui.nui.widgets.UIWarnButton;
2828
import org.terasology.nui.backends.libgdx.GDXInputUtil;
2929
import org.terasology.nui.widgets.UIButton;
3030

@@ -41,7 +41,7 @@ public ChooseMercenaryScreen() {
4141

4242
@Override
4343
public void initialise(SolApplication solApplication, InventoryScreen inventoryScreen) {
44-
KeyActivatedButton giveButton = new KeyActivatedButton();
44+
UIWarnButton giveButton = new UIWarnButton();
4545
giveButton.setText("Give Items");
4646
giveButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeyShoot()));
4747
giveButton.subscribe(button -> {
@@ -58,7 +58,7 @@ public void initialise(SolApplication solApplication, InventoryScreen inventoryS
5858
});
5959
actionButtons[0] = giveButton;
6060

61-
KeyActivatedButton takeButton = new KeyActivatedButton();
61+
UIWarnButton takeButton = new UIWarnButton();
6262
takeButton.setText("Take Items");
6363
takeButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeyShoot2()));
6464
takeButton.subscribe(button -> {
@@ -75,7 +75,7 @@ public void initialise(SolApplication solApplication, InventoryScreen inventoryS
7575
});
7676
actionButtons[1] = takeButton;
7777

78-
KeyActivatedButton equipButton = new KeyActivatedButton();
78+
UIWarnButton equipButton = new UIWarnButton();
7979
equipButton.setText("Equip Items");
8080
equipButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeyDrop()));
8181
equipButton.subscribe(button -> {
@@ -93,6 +93,18 @@ public void initialise(SolApplication solApplication, InventoryScreen inventoryS
9393
actionButtons[2] = equipButton;
9494
}
9595

96+
public UIWarnButton getGiveItemsButton() {
97+
return (UIWarnButton) actionButtons[0];
98+
}
99+
100+
public UIWarnButton getTakeItemsButton() {
101+
return (UIWarnButton) actionButtons[1];
102+
}
103+
104+
public UIWarnButton getEquipItemsButton() {
105+
return (UIWarnButton) actionButtons[2];
106+
}
107+
96108
@Override
97109
public void update(SolApplication solApplication, InventoryScreen inventoryScreen) {
98110
boolean selNull = inventoryScreen.getSelectedItem() != null;

engine/src/main/java/org/destinationsol/game/screens/HireShipsScreen.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.destinationsol.mercenary.MercenaryUtils;
2525
import org.destinationsol.ui.nui.screens.InventoryScreen;
2626
import org.destinationsol.ui.nui.screens.TalkScreen;
27-
import org.destinationsol.ui.nui.widgets.KeyActivatedButton;
27+
import org.destinationsol.ui.nui.widgets.UIWarnButton;
2828
import org.terasology.nui.backends.libgdx.GDXInputUtil;
2929
import org.terasology.nui.widgets.UIButton;
3030

@@ -36,7 +36,7 @@ public HireShipsScreen() {
3636

3737
@Override
3838
public void initialise(SolApplication solApplication, InventoryScreen inventoryScreen) {
39-
KeyActivatedButton hireButton = new KeyActivatedButton();
39+
UIWarnButton hireButton = new UIWarnButton();
4040
hireButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeyHireShip()));
4141
hireButton.subscribe(button -> {
4242
SolGame game = solApplication.getGame();
@@ -66,6 +66,10 @@ public UIButton[] getActionButtons() {
6666
return actionButtons;
6767
}
6868

69+
public UIWarnButton getHireControl() {
70+
return (UIWarnButton) actionButtons[0];
71+
}
72+
6973
@Override
7074
public void update(SolApplication solApplication, InventoryScreen inventoryScreen) {
7175
SolGame game = solApplication.getGame();

engine/src/main/java/org/destinationsol/game/screens/SellItems.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.destinationsol.ui.nui.screens.InventoryScreen;
2626
import org.destinationsol.ui.nui.screens.TalkScreen;
2727
import org.destinationsol.ui.nui.widgets.KeyActivatedButton;
28+
import org.destinationsol.ui.nui.widgets.UIWarnButton;
2829
import org.terasology.nui.backends.libgdx.GDXInputUtil;
2930
import org.terasology.nui.widgets.UIButton;
3031

@@ -42,7 +43,7 @@ public SellItems() {
4243

4344
@Override
4445
public void initialise(SolApplication solApplication, InventoryScreen inventoryScreen) {
45-
KeyActivatedButton sellButton = new KeyActivatedButton();
46+
UIWarnButton sellButton = new UIWarnButton();
4647
sellButton.setText("Sell");
4748
sellButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeySellItem()));
4849
sellButton.subscribe(button -> {
@@ -63,6 +64,10 @@ public void initialise(SolApplication solApplication, InventoryScreen inventoryS
6364
actionButtons[0] = sellButton;
6465
}
6566

67+
public UIWarnButton getSellControl() {
68+
return (UIWarnButton) actionButtons[0];
69+
}
70+
6671
@Override
6772
public ItemContainer getItems(SolGame game) {
6873
Hero hero = game.getHero();

engine/src/main/java/org/destinationsol/game/ship/FarShip.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ public HullConfig getHullConfig() {
147147
return hullConfig;
148148
}
149149

150+
public TradeContainer getTradeContainer() {
151+
return tradeContainer;
152+
}
153+
150154
public float getAngle() {
151155
return angle;
152156
}

engine/src/main/java/org/destinationsol/game/ship/KnockBack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public boolean update(SolGame game, SolShip owner, boolean tryToUse) {
8383
Vector2 toO = SolMath.distVec(ownerPos, oPos);
8484
float accLen = config.force * perc;
8585
toO.scl(accLen / dst);
86-
o.receiveForce(toO, game, false);
86+
o.receiveForce(toO, game, true);
8787
SolMath.free(toO);
8888
}
8989
DSParticleEmitter src = new DSParticleEmitter(config.cc.effect, MAX_RADIUS, DrawableLevel.PART_BG_0, new Vector2(), true, game, ownerPos, Vector2.Zero, 0);

0 commit comments

Comments
 (0)