Extra mod field parsing (untested)

This commit is contained in:
Anuken
2020-10-07 11:00:02 -04:00
parent d4513fab19
commit be66a15287
10 changed files with 215 additions and 134 deletions

View File

@@ -3,6 +3,7 @@ package mindustry.content;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.struct.*;
import mindustry.ctype.*;
import mindustry.entities.bullet.*;
import mindustry.gen.*;
@@ -1801,30 +1802,30 @@ public class Blocks implements ContentList{
groundFactory = new UnitFactory("ground-factory"){{
requirements(Category.units, with(Items.copper, 50, Items.lead, 120, Items.silicon, 80));
plans = new UnitPlan[]{
plans = Seq.with(
new UnitPlan(UnitTypes.dagger, 60f * 15, with(Items.silicon, 10, Items.lead, 10)),
new UnitPlan(UnitTypes.crawler, 60f * 12, with(Items.silicon, 10, Items.coal, 20)),
new UnitPlan(UnitTypes.nova, 60f * 40, with(Items.silicon, 30, Items.lead, 20, Items.titanium, 20)),
};
new UnitPlan(UnitTypes.nova, 60f * 40, with(Items.silicon, 30, Items.lead, 20, Items.titanium, 20))
);
size = 3;
consumes.power(1.2f);
}};
airFactory = new UnitFactory("air-factory"){{
requirements(Category.units, with(Items.copper, 60, Items.lead, 70));
plans = new UnitPlan[]{
plans = Seq.with(
new UnitPlan(UnitTypes.flare, 60f * 15, with(Items.silicon, 15)),
new UnitPlan(UnitTypes.mono, 60f * 35, with(Items.silicon, 30, Items.lead, 15)),
};
new UnitPlan(UnitTypes.mono, 60f * 35, with(Items.silicon, 30, Items.lead, 15))
);
size = 3;
consumes.power(1.2f);
}};
navalFactory = new UnitFactory("naval-factory"){{
requirements(Category.units, with(Items.copper, 150, Items.lead, 130, Items.metaglass, 120));
plans = new UnitPlan[]{
new UnitPlan(UnitTypes.risso, 60f * 45f, with(Items.silicon, 20, Items.metaglass, 35)),
};
plans = Seq.with(
new UnitPlan(UnitTypes.risso, 60f * 45f, with(Items.silicon, 20, Items.metaglass, 35))
);
size = 3;
consumes.power(1.2f);
floating = true;
@@ -1839,14 +1840,14 @@ public class Blocks implements ContentList{
constructTime = 60f * 10f;
upgrades = new UnitType[][]{
{UnitTypes.nova, UnitTypes.pulsar},
{UnitTypes.dagger, UnitTypes.mace},
{UnitTypes.crawler, UnitTypes.atrax},
{UnitTypes.flare, UnitTypes.horizon},
{UnitTypes.mono, UnitTypes.poly},
{UnitTypes.risso, UnitTypes.minke},
};
upgrades.addAll(
new UnitType[]{UnitTypes.nova, UnitTypes.pulsar},
new UnitType[]{UnitTypes.dagger, UnitTypes.mace},
new UnitType[]{UnitTypes.crawler, UnitTypes.atrax},
new UnitType[]{UnitTypes.flare, UnitTypes.horizon},
new UnitType[]{UnitTypes.mono, UnitTypes.poly},
new UnitType[]{UnitTypes.risso, UnitTypes.minke}
);
}};
multiplicativeReconstructor = new Reconstructor("multiplicative-reconstructor"){{
@@ -1858,14 +1859,14 @@ public class Blocks implements ContentList{
constructTime = 60f * 30f;
upgrades = new UnitType[][]{
{UnitTypes.horizon, UnitTypes.zenith},
{UnitTypes.mace, UnitTypes.fortress},
{UnitTypes.poly, UnitTypes.mega},
{UnitTypes.minke, UnitTypes.bryde},
{UnitTypes.pulsar, UnitTypes.quasar},
{UnitTypes.atrax, UnitTypes.spiroct},
};
upgrades.addAll(
new UnitType[]{UnitTypes.horizon, UnitTypes.zenith},
new UnitType[]{UnitTypes.mace, UnitTypes.fortress},
new UnitType[]{UnitTypes.poly, UnitTypes.mega},
new UnitType[]{UnitTypes.minke, UnitTypes.bryde},
new UnitType[]{UnitTypes.pulsar, UnitTypes.quasar},
new UnitType[]{UnitTypes.atrax, UnitTypes.spiroct}
);
}};
exponentialReconstructor = new Reconstructor("exponential-reconstructor"){{
@@ -1879,14 +1880,14 @@ public class Blocks implements ContentList{
constructTime = 60f * 60f * 1.5f;
liquidCapacity = 60f;
upgrades = new UnitType[][]{
{UnitTypes.zenith, UnitTypes.antumbra},
{UnitTypes.spiroct, UnitTypes.arkyid},
{UnitTypes.fortress, UnitTypes.scepter},
{UnitTypes.bryde, UnitTypes.sei},
{UnitTypes.mega, UnitTypes.quad},
{UnitTypes.quasar, UnitTypes.vela},
};
upgrades.addAll(
new UnitType[]{UnitTypes.zenith, UnitTypes.antumbra},
new UnitType[]{UnitTypes.spiroct, UnitTypes.arkyid},
new UnitType[]{UnitTypes.fortress, UnitTypes.scepter},
new UnitType[]{UnitTypes.bryde, UnitTypes.sei},
new UnitType[]{UnitTypes.mega, UnitTypes.quad},
new UnitType[]{UnitTypes.quasar, UnitTypes.vela}
);
}};
tetrativeReconstructor = new Reconstructor("tetrative-reconstructor"){{
@@ -1900,14 +1901,14 @@ public class Blocks implements ContentList{
constructTime = 60f * 60f * 4;
liquidCapacity = 180f;
upgrades = new UnitType[][]{
{UnitTypes.antumbra, UnitTypes.eclipse},
{UnitTypes.arkyid, UnitTypes.toxopid},
{UnitTypes.scepter, UnitTypes.reign},
{UnitTypes.sei, UnitTypes.omura},
{UnitTypes.quad, UnitTypes.oct},
{UnitTypes.vela, UnitTypes.corvus}
};
upgrades.addAll(
new UnitType[]{UnitTypes.antumbra, UnitTypes.eclipse},
new UnitType[]{UnitTypes.arkyid, UnitTypes.toxopid},
new UnitType[]{UnitTypes.scepter, UnitTypes.reign},
new UnitType[] {UnitTypes.sei, UnitTypes.omura},
new UnitType[]{UnitTypes.quad, UnitTypes.oct},
new UnitType[]{UnitTypes.vela, UnitTypes.corvus}
);
}};
repairPoint = new RepairPoint("repair-point"){{

View File

@@ -15,6 +15,7 @@ import static mindustry.type.ItemStack.*;
public class TechTree implements ContentList{
static ObjectMap<UnlockableContent, TechNode> map = new ObjectMap<>();
static TechNode context = null;
public static Seq<TechNode> all;
public static TechNode root;
@@ -543,36 +544,46 @@ public class TechTree implements ContentList{
}
public static void setup(){
TechNode.context = null;
context = null;
map = new ObjectMap<>();
all = new Seq<>();
}
public static TechNode node(UnlockableContent content, Runnable children){
//all the "node" methods are hidden, because they are for internal context-dependent use only
//for custom research, just use the TechNode constructor
static TechNode node(UnlockableContent content, Runnable children){
return node(content, content.researchRequirements(), children);
}
public static TechNode node(UnlockableContent content, ItemStack[] requirements, Runnable children){
return new TechNode(content, requirements, children);
static TechNode node(UnlockableContent content, ItemStack[] requirements, Runnable children){
return node(content, requirements, null, children);
}
public static TechNode node(UnlockableContent content, Seq<Objective> objectives, Runnable children){
TechNode node = new TechNode(content, content.researchRequirements(), children);
node.objectives = objectives;
static TechNode node(UnlockableContent content, ItemStack[] requirements, Seq<Objective> objectives, Runnable children){
TechNode node = new TechNode(context, content, requirements);
if(objectives != null){
node.objectives = objectives;
}
TechNode prev = context;
context = node;
children.run();
context = prev;
return node;
}
public static TechNode node(UnlockableContent block){
static TechNode node(UnlockableContent content, Seq<Objective> objectives, Runnable children){
return node(content, content.researchRequirements(), objectives, children);
}
static TechNode node(UnlockableContent block){
return node(block, () -> {});
}
public static TechNode create(UnlockableContent parent, UnlockableContent block){
TechNode.context = all.find(t -> t.content == parent);
return node(block, () -> {});
}
public static @Nullable
TechNode get(UnlockableContent content){
@Nullable
public static TechNode get(UnlockableContent content){
return map.get(content);
}
@@ -581,8 +592,6 @@ public class TechTree implements ContentList{
}
public static class TechNode{
static TechNode context;
/** Depth in tech tree. */
public int depth;
/** Requirement node. */
@@ -600,10 +609,10 @@ public class TechTree implements ContentList{
/** Nodes that depend on this node. */
public final Seq<TechNode> children = new Seq<>();
TechNode(@Nullable TechNode ccontext, UnlockableContent content, ItemStack[] requirements, Runnable children){
if(ccontext != null) ccontext.children.add(this);
public TechNode(@Nullable TechNode parent, UnlockableContent content, ItemStack[] requirements){
if(parent != null) parent.children.add(this);
this.parent = ccontext;
this.parent = parent;
this.content = content;
this.requirements = requirements;
this.depth = parent == null ? 0 : parent.depth + 1;
@@ -619,14 +628,15 @@ public class TechTree implements ContentList{
content.getDependencies(d -> objectives.add(new Research(d)));
map.put(content, this);
context = this;
children.run();
context = ccontext;
all.add(this);
}
TechNode(UnlockableContent content, ItemStack[] requirements, Runnable children){
this(context, content, requirements, children);
/** Removes this node from the tech tree. */
public void remove(){
all.remove(this);
if(parent != null){
parent.children.remove(this);
}
}
/** Flushes research progress to settings. */