mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 14:32:06 -08:00
Costs for unit research
This commit is contained in:
parent
dcbfc2b7aa
commit
0bcb48ca31
7 changed files with 57 additions and 23 deletions
|
|
@ -1005,7 +1005,6 @@ block.dark-metal.name = Dark Metal
|
|||
block.basalt.name = Basalt
|
||||
block.hotrock.name = Hot Rock
|
||||
block.magmarock.name = Magma Rock
|
||||
block.cliffs.name = Cliffs
|
||||
block.copper-wall.name = Copper Wall
|
||||
block.copper-wall-large.name = Large Copper Wall
|
||||
block.titanium-wall.name = Titanium Wall
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ void main(){
|
|||
vec2 c = v_texCoords.xy;
|
||||
vec2 coords = vec2(c.x * u_resolution.x + u_campos.x, c.y * u_resolution.y + u_campos.y);
|
||||
|
||||
float btime = u_time / 7000000.0;
|
||||
float btime = u_time / 700000.0;
|
||||
float noise = sin((texture2D(u_noise, (coords) / NSCALE + vec2(btime) * vec2(-0.9, 0.8)).r + texture2D(u_noise, (coords) / NSCALE + vec2(abs(sin(btime)) * 1.1) * vec2(-0.8, -1.0)).r) / 2.0);
|
||||
vec4 color = texture2D(u_texture, c);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue