Skip to content

Commit

Permalink
Campaign hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Slotterleet committed Apr 23, 2024
1 parent 4ad4415 commit 166d038
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"subtitle": "See you later!",
"description": "A mod focused on space exploration.",
"version": "1.1 beta build-1",
"minGameVersion": 146,
"minGameVersion": 145,
"java": true,
"hidden": false
}
5 changes: 4 additions & 1 deletion res/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,7 @@ cl.placeturbines = Place Wind Turbines, then connect them all to the Upgrade Cen
cl.researchoredetectors = Weapons made in the Upgrade Center require materials to be constructed.\nYou can find even more ores underground outside the core's scanning zone.\nResearch Ore Detectors and begin scanning the territory.
cl.bugsapproaching = The insects are approaching in a few minutes.
cl.bugstimer = Insects approaching in {0}
cl.defendfrommorebugs = [red]Warning![] A large wave of insects is incoming! Protect the core at all costs!
cl.defendfrommorebugs = [red]Warning![] A large wave of insects is incoming! Protect the core at all costs!

hint.fos-sandUnderground = You can get [accent]sand[] by placing an [accent]underground drill[] on a place without ores under it.
hint.fos-detonatorIntro = Surface drills are more efficient than underground drills. You can place the [accent]Surface Detonator[] next to an underground ore to expose it, then mine it with a [accent]surface drill[].
5 changes: 4 additions & 1 deletion res/bundles/bundle_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,7 @@ cl.placeturbines = Поставьте ветряные турбины, зате
cl.researchoredetectors = Оружие, изготовляемое в Центре улучшения, требует сырье.\nВне зоны сканирования ядра можно найти еще больше руды под землей.\nИсследуйте Детекторы руды и начните сканировать территорию.
cl.bugsapproaching = Насекомые прибудут через несколько минут.
cl.bugstimer = Насекомые прибудут через {0}
cl.defendfrommorebugs = [red]Внимание![] Большая волна насекомых на подходе! Защитите ядро любой ценой!
cl.defendfrommorebugs = [red]Внимание![] Большая волна насекомых на подходе! Защитите ядро любой ценой!

hint.fos-sandUnderground = Вы можете добыть [accent]песок[], поставив [accent]подземный бур[] на месте, где под ним нет руды.
hint.fos-detonatorIntro = Поверхностные буры более эффективны, чем подземные. Вы можете поставить [accent]Детонатор поверхности[] около подземной руды, чтобы вскрыть ее, затем добывать [accent]поверхностным буром[].
2 changes: 1 addition & 1 deletion settings/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"dependencies": {
"useJitpackForMindustryDependency": false,
"mindustryVersion": "v146",
"mindustryVersion": "v145",

"list": [
{ "multi-crafter-lib": "com.github.liplum:MultiCrafterLib:v1.7" },
Expand Down
3 changes: 3 additions & 0 deletions src/fos/core/FOSMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ public void draw() {
if (bg != null) {
FOSVars.menuRenderer.changeBackground(bg);
}

// add modded hints
FOSVars.hints.load();
}

public void constructSettings() {
Expand Down
5 changes: 4 additions & 1 deletion src/fos/core/FOSVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import fos.controllers.*;
import fos.files.InternalFileTree;
import fos.graphics.FOSOreRenderer;
import fos.ui.ResearchCoreDialog;
import fos.ui.*;
import fos.ui.menus.FOSMenuRenderer;
import mindustry.ai.Pathfinder;
import mindustry.content.TechTree;
Expand Down Expand Up @@ -72,6 +72,9 @@ public class FOSVars {
/** Insect evolution controller. */
public static EvolutionController evoController = new EvolutionController();

/** Hint handler. */
public static FOSHints hints = new FOSHints();

public static void load() {
if (!headless) researchCoreDialog = new ResearchCoreDialog();

Expand Down
111 changes: 111 additions & 0 deletions src/fos/ui/FOSHints.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package fos.ui;

import arc.*;
import arc.func.Boolp;
import arc.struct.ObjectSet;
import arc.util.*;
import fos.type.blocks.production.UndergroundDrill;
import mindustry.Vars;
import mindustry.game.EventType;
import mindustry.gen.Groups;
import mindustry.ui.fragments.HintsFragment;
import mindustry.world.Block;

import static fos.content.FOSBlocks.*;
import static mindustry.Vars.*;
import static mindustry.content.Items.sand;

public class FOSHints {
static ObjectSet<Block> placedBlocks = new ObjectSet<>();

public void load() {
ui.hints.hints.addAll(FOSHint.values());

Events.on(EventType.BlockBuildEndEvent.class, e -> {
if(!e.breaking && e.unit == player.unit()){
placedBlocks.add(e.tile.block());
}
});
}

public enum FOSHint implements HintsFragment.Hint {
sandUnderground(
() -> control.input.block == siliconSynthesizer || placedBlocks.contains(siliconSynthesizer),
() -> Groups.build.contains(b -> b.team == Vars.player.team() && b instanceof UndergroundDrill.UndergroundDrillBuild ud && ud.dominantItem == sand)
),
detonatorIntro(
() -> surfaceDetonator.unlocked(),
() -> placedBlocks.contains(surfaceDetonator)
);

@Nullable
String text;
int visibility = visibleAll;
HintsFragment.Hint[] dependencies = {};
boolean finished, cached;
Boolp complete, shown = () -> true;

FOSHint(Boolp complete){
this.complete = complete;
}

FOSHint(int visibility, Boolp complete){
this(complete);
this.visibility = visibility;
}

FOSHint(Boolp shown, Boolp complete){
this(complete);
this.shown = shown;
}

FOSHint(int visibility, Boolp shown, Boolp complete){
this(complete);
this.shown = shown;
this.visibility = visibility;
}

@Override
public boolean finished(){
if(!cached){
cached = true;
finished = Core.settings.getBool("fos-" + name() + "-hint-done", false);
}
return finished;
}

@Override
public void finish(){
Core.settings.put("fos-" + name() + "-hint-done", finished = true);
}

@Override
public String text(){
if(text == null){
text = Vars.mobile && Core.bundle.has("hint.fos-" + name() + ".mobile") ? Core.bundle.get("hint.fos-" + name() + ".mobile") : Core.bundle.get("hint.fos-" + name());
if(!Vars.mobile) text = text.replace("tap", "click").replace("Tap", "Click");
}
return text;
}

@Override
public boolean complete(){
return complete.get();
}

@Override
public boolean show(){
return shown.get() && (dependencies.length == 0 || !Structs.contains(dependencies, d -> !d.finished()));
}

@Override
public int order(){
return ordinal();
}

@Override
public boolean valid(){
return (Vars.mobile && (visibility & visibleMobile) != 0) || (!Vars.mobile && (visibility & visibleDesktop) != 0);
}
}
}

0 comments on commit 166d038

Please sign in to comment.