Costs for unit research
This commit is contained in:
@@ -801,7 +801,7 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
door = new Door("door"){{
|
||||
requirements(Category.defense, with(Items.graphite, 6, Items.silicon, 4));
|
||||
requirements(Category.defense, with(Items.titanium, 6, Items.silicon, 4));
|
||||
health = 100 * wallHealthMultiplier;
|
||||
}};
|
||||
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package mindustry.content;
|
||||
|
||||
import arc.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.Objectives.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.content.Blocks.*;
|
||||
import static mindustry.content.SectorPresets.*;
|
||||
import static mindustry.content.SectorPresets.craters;
|
||||
import static mindustry.content.SectorPresets.*;
|
||||
import static mindustry.content.UnitTypes.*;
|
||||
import static mindustry.type.ItemStack.*;
|
||||
|
||||
@@ -422,7 +419,11 @@ public class TechTree implements ContentList{
|
||||
node(risso, () -> {
|
||||
node(minke, () -> {
|
||||
node(bryde, () -> {
|
||||
node(sei, () -> {
|
||||
node(omura, () -> {
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -529,22 +530,7 @@ public class TechTree implements ContentList{
|
||||
}
|
||||
|
||||
public static TechNode node(UnlockableContent content, Runnable children){
|
||||
ItemStack[] requirements;
|
||||
|
||||
if(content instanceof Block){
|
||||
Block block = (Block)content;
|
||||
|
||||
requirements = new ItemStack[block.requirements.length];
|
||||
for(int i = 0; i < requirements.length; i++){
|
||||
int quantity = 40 + Mathf.round(Mathf.pow(block.requirements[i].amount, 1.25f) * 20, 10);
|
||||
|
||||
requirements[i] = new ItemStack(block.requirements[i].item, UI.roundAmount(quantity));
|
||||
}
|
||||
}else{
|
||||
requirements = ItemStack.empty;
|
||||
}
|
||||
|
||||
return node(content, requirements, children);
|
||||
return node(content, content.researchRequirements(), children);
|
||||
}
|
||||
|
||||
public static TechNode node(UnlockableContent content, ItemStack[] requirements, Runnable children){
|
||||
|
||||
@@ -8,6 +8,7 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@@ -43,6 +44,11 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
|
||||
}
|
||||
|
||||
/** @return items needed to research this content */
|
||||
public ItemStack[] researchRequirements(){
|
||||
return ItemStack.empty;
|
||||
}
|
||||
|
||||
public String emoji(){
|
||||
return Fonts.getUnicodeStr(name);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.ai.types.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.abilities.*;
|
||||
@@ -28,6 +29,7 @@ import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.units.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -299,6 +301,34 @@ public class UnitType extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] researchRequirements(){
|
||||
ItemStack[] stacks = null;
|
||||
|
||||
//calculate costs based on reconstructors or factories found
|
||||
Block rec = content.blocks().find(b -> b instanceof Reconstructor && Structs.contains(((Reconstructor)b).upgrades, u -> u[1] == this));
|
||||
|
||||
if(rec != null && rec.consumes.has(ConsumeType.item) && rec.consumes.get(ConsumeType.item) instanceof ConsumeItems){
|
||||
stacks = ((ConsumeItems)rec.consumes.get(ConsumeType.item)).items;
|
||||
}else{
|
||||
UnitFactory factory = (UnitFactory)content.blocks().find(u -> u instanceof UnitFactory && Structs.contains(((UnitFactory)u).plans, p -> p.unit == this));
|
||||
if(factory != null){
|
||||
stacks = Structs.find(factory.plans, p -> p.unit == this).requirements;
|
||||
}
|
||||
}
|
||||
|
||||
if(stacks != null){
|
||||
ItemStack[] out = new ItemStack[stacks.length];
|
||||
for(int i = 0; i < out.length; i++){
|
||||
out[i] = new ItemStack(stacks[i].item, UI.roundAmount((int)(Math.pow(stacks[i].amount, 1.1) * 50)));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
return super.researchRequirements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentType getContentType(){
|
||||
return ContentType.unit;
|
||||
|
||||
@@ -15,6 +15,7 @@ import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
@@ -615,6 +616,18 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] researchRequirements(){
|
||||
ItemStack[] out = new ItemStack[requirements.length];
|
||||
for(int i = 0; i < out.length; i++){
|
||||
int quantity = 40 + Mathf.round(Mathf.pow(requirements[i].amount, 1.25f) * 20, 10);
|
||||
|
||||
out[i] = new ItemStack(requirements[i].item, UI.roundAmount(quantity));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDependencies(Cons<UnlockableContent> cons){
|
||||
//just requires items
|
||||
|
||||
Reference in New Issue
Block a user