Skip to content

Commit

Permalink
Merge pull request #674 from BenjaminAmos/tutorial-rework
Browse files Browse the repository at this point in the history
New Tutorial
  • Loading branch information
BenjaminAmos authored Mar 31, 2023
2 parents 5a924de + 670b073 commit 0f6926b
Show file tree
Hide file tree
Showing 60 changed files with 3,594 additions and 497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.destinationsol.game.planet.PlanetManager;
import org.destinationsol.game.screens.GameScreens;
import org.destinationsol.game.ship.ShipBuilder;
import org.destinationsol.ui.TutorialManager;
import org.destinationsol.game.tutorial.TutorialManager;
import org.terasology.context.Lifetime;
import org.terasology.gestalt.di.ServiceRegistry;

Expand Down
13 changes: 8 additions & 5 deletions engine/src/main/java/org/destinationsol/game/ObjectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@ public void update(SolGame game, float timeStep) {
}
if (isNear(fod, camPos, timeStep)) {
SolObject o = fo.toObject(game);
// Ensure that StarPorts are added straight away so that we can see if they overlap
if (o instanceof StarPort) {
addObjNow(game, o);
} else {
addObjDelayed(o);
// Rarely a far object can produce a null sol object because the instance it references no longer exists.
if (o != null) {
// Ensure that StarPorts are added straight away so that we can see if they overlap
if (o instanceof StarPort) {
addObjNow(game, o);
} else {
addObjDelayed(o);
}
}
removeFo(it, fo);
}
Expand Down
14 changes: 0 additions & 14 deletions engine/src/main/java/org/destinationsol/game/PlayerCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ private void addAndEquipItems(Hero hero, RespawnState respawnState, SolGame game
ItemContainer itemContainer = hero.getItemContainer();
if (!respawnState.getRespawnItems().isEmpty()) {
addAndEquipRespawnItems(hero, respawnState, itemContainer, game);
} else if (game.isTutorial()) {
addRandomTutorialItems(game, itemContainer);
}
itemContainer.markAllAsSeen();
}
Expand Down Expand Up @@ -96,18 +94,6 @@ private void addWaypoints(Hero hero, String waypoints, RespawnState respawnState
}
}

private void addRandomTutorialItems(SolGame game, ItemContainer itemContainer) {
for (int i = 0; i < NUMBER_OF_TUTORIAL_ITEM_ADD_ATTEMPTS; i++) {
if (itemContainer.groupCount() > MAX_NUMBER_OF_TUTORIAL_ITEM_GROUPS) {
return;
}
SolItem item = game.getItemMan().random();
if (isNoGunAndHasIcon(item, game) && itemContainer.canAdd(item)) {
itemContainer.add(item.copy());
}
}
}

private boolean isNoGunAndHasIcon(SolItem it, SolGame game) {
return !(it instanceof Gun) && it.getIcon(game) != null;
}
Expand Down
4 changes: 3 additions & 1 deletion engine/src/main/java/org/destinationsol/game/SolGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
import org.destinationsol.game.ship.ShipBuilder;
import org.destinationsol.game.ship.SloMo;
import org.destinationsol.game.ship.hulls.HullConfig;
import org.destinationsol.game.tutorial.TutorialManager;
import org.destinationsol.mercenary.MercenaryUtils;
import org.destinationsol.modules.ModuleManager;
import org.destinationsol.ui.DebugCollector;
import org.destinationsol.ui.TutorialManager;
import org.destinationsol.ui.UiDrawer;
import org.destinationsol.ui.Waypoint;
import org.destinationsol.ui.nui.screens.MainGameScreen;
Expand Down Expand Up @@ -337,6 +337,8 @@ public void onGameEnd(Context context) {
} catch (Exception e) {
e.printStackTrace();
}
} else {
tutorialManager.ifPresent(TutorialManager::onGameEnd);
}

// TODO: Remove this when context is reset after each game
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.destinationsol.ui.SolInputManager;
import org.destinationsol.ui.nui.NUIManager;
import org.destinationsol.ui.nui.screens.InventoryScreen;
import org.destinationsol.ui.nui.widgets.KeyActivatedButton;
import org.destinationsol.ui.nui.widgets.UIWarnButton;
import org.terasology.nui.backends.libgdx.GDXInputUtil;
import org.terasology.nui.widgets.UIButton;

Expand All @@ -41,7 +41,7 @@ public ChooseMercenaryScreen() {

@Override
public void initialise(SolApplication solApplication, InventoryScreen inventoryScreen) {
KeyActivatedButton giveButton = new KeyActivatedButton();
UIWarnButton giveButton = new UIWarnButton();
giveButton.setText("Give Items");
giveButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeyShoot()));
giveButton.subscribe(button -> {
Expand All @@ -58,7 +58,7 @@ public void initialise(SolApplication solApplication, InventoryScreen inventoryS
});
actionButtons[0] = giveButton;

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

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

public UIWarnButton getGiveItemsButton() {
return (UIWarnButton) actionButtons[0];
}

public UIWarnButton getTakeItemsButton() {
return (UIWarnButton) actionButtons[1];
}

public UIWarnButton getEquipItemsButton() {
return (UIWarnButton) actionButtons[2];
}

@Override
public void update(SolApplication solApplication, InventoryScreen inventoryScreen) {
boolean selNull = inventoryScreen.getSelectedItem() != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.destinationsol.mercenary.MercenaryUtils;
import org.destinationsol.ui.nui.screens.InventoryScreen;
import org.destinationsol.ui.nui.screens.TalkScreen;
import org.destinationsol.ui.nui.widgets.KeyActivatedButton;
import org.destinationsol.ui.nui.widgets.UIWarnButton;
import org.terasology.nui.backends.libgdx.GDXInputUtil;
import org.terasology.nui.widgets.UIButton;

Expand All @@ -36,7 +36,7 @@ public HireShipsScreen() {

@Override
public void initialise(SolApplication solApplication, InventoryScreen inventoryScreen) {
KeyActivatedButton hireButton = new KeyActivatedButton();
UIWarnButton hireButton = new UIWarnButton();
hireButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeyHireShip()));
hireButton.subscribe(button -> {
SolGame game = solApplication.getGame();
Expand Down Expand Up @@ -66,6 +66,10 @@ public UIButton[] getActionButtons() {
return actionButtons;
}

public UIWarnButton getHireControl() {
return (UIWarnButton) actionButtons[0];
}

@Override
public void update(SolApplication solApplication, InventoryScreen inventoryScreen) {
SolGame game = solApplication.getGame();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.destinationsol.ui.nui.screens.InventoryScreen;
import org.destinationsol.ui.nui.screens.TalkScreen;
import org.destinationsol.ui.nui.widgets.KeyActivatedButton;
import org.destinationsol.ui.nui.widgets.UIWarnButton;
import org.terasology.nui.backends.libgdx.GDXInputUtil;
import org.terasology.nui.widgets.UIButton;

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

@Override
public void initialise(SolApplication solApplication, InventoryScreen inventoryScreen) {
KeyActivatedButton sellButton = new KeyActivatedButton();
UIWarnButton sellButton = new UIWarnButton();
sellButton.setText("Sell");
sellButton.setKey(GDXInputUtil.GDXToNuiKey(solApplication.getOptions().getKeySellItem()));
sellButton.subscribe(button -> {
Expand All @@ -63,6 +64,10 @@ public void initialise(SolApplication solApplication, InventoryScreen inventoryS
actionButtons[0] = sellButton;
}

public UIWarnButton getSellControl() {
return (UIWarnButton) actionButtons[0];
}

@Override
public ItemContainer getItems(SolGame game) {
Hero hero = game.getHero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public HullConfig getHullConfig() {
return hullConfig;
}

public TradeContainer getTradeContainer() {
return tradeContainer;
}

public float getAngle() {
return angle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean update(SolGame game, SolShip owner, boolean tryToUse) {
Vector2 toO = SolMath.distVec(ownerPos, oPos);
float accLen = config.force * perc;
toO.scl(accLen / dst);
o.receiveForce(toO, game, false);
o.receiveForce(toO, game, true);
SolMath.free(toO);
}
DSParticleEmitter src = new DSParticleEmitter(config.cc.effect, MAX_RADIUS, DrawableLevel.PART_BG_0, new Vector2(), true, game, ownerPos, Vector2.Zero, 0);
Expand Down
Loading

0 comments on commit 0f6926b

Please sign in to comment.