From 37bc06d14adbcc1f3c0d782e32a0ff88f6f028f1 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 28 Dec 2021 16:36:04 -0500 Subject: [PATCH] Research cost multipliers for Serpulo resources --- core/src/mindustry/content/Blocks.java | 6 ++--- .../src/mindustry/content/ErekirTechTree.java | 10 ++++---- core/src/mindustry/content/Items.java | 2 +- core/src/mindustry/content/TechTree.java | 25 ++++++++++++++++++- core/src/mindustry/type/ItemStack.java | 8 ++++++ core/src/mindustry/world/Block.java | 4 +-- .../blocks/defense/turrets/ItemTurret.java | 1 + 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 572aafbaa6..6ca4bfceb4 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -2891,7 +2891,7 @@ public class Blocks{ }}; breach = new ItemTurret("breach"){{ - requirements(Category.turret, with(Items.beryllium, 200, Items.silicon, 150, Items.graphite, 80)); + requirements(Category.turret, with(Items.beryllium, 300, Items.silicon, 150, Items.graphite, 100)); Effect sfe = new MultiEffect(Fx.shootBigColor, Fx.colorSparkBig); @@ -2929,7 +2929,7 @@ public class Blocks{ ); //TODO no coolant? - coolantUsage = 10f / 60f; + coolantUsage = 15f / 60f; coolantOverride = Liquids.water; coolantMultiplier = 6f; @@ -2954,7 +2954,7 @@ public class Blocks{ //TODO bad name sublimate = new ContinuousTurret("sublimate"){{ //TODO requirements - requirements(Category.turret, with(Items.tungsten, 120, Items.silicon, 160, Items.oxide, 50)); + requirements(Category.turret, with(Items.tungsten, 150, Items.silicon, 160, Items.oxide, 50)); draw = new DrawTurret("reinforced-"){{ liquidDraw = Liquids.ozone; diff --git a/core/src/mindustry/content/ErekirTechTree.java b/core/src/mindustry/content/ErekirTechTree.java index 72cbd4a736..089b4be942 100644 --- a/core/src/mindustry/content/ErekirTechTree.java +++ b/core/src/mindustry/content/ErekirTechTree.java @@ -12,14 +12,15 @@ public class ErekirTechTree{ public static void load(){ Seq erekirSector = Seq.with(new OnPlanet(Planets.erekir)); - //TODO use these multipliers! var costMultipliers = new ObjectFloatMap(); - costMultipliers.put(Items.silicon, 4); + costMultipliers.put(Items.silicon, 6); costMultipliers.put(Items.surgeAlloy, 4); - costMultipliers.put(Items.thorium, 6); - costMultipliers.put(Items.graphite, 5); + costMultipliers.put(Items.thorium, 7); + costMultipliers.put(Items.graphite, 6); Planets.erekir.techTree = nodeRoot("erekir", coreBastion, true, () -> { + context().researchCostMultipliers = costMultipliers; + node(duct, () -> { node(ductRouter, () -> { node(ductBridge, () -> { @@ -216,7 +217,6 @@ public class ErekirTechTree{ }); }); }); - }); } } diff --git a/core/src/mindustry/content/Items.java b/core/src/mindustry/content/Items.java index ae76f8916c..403271ebcf 100644 --- a/core/src/mindustry/content/Items.java +++ b/core/src/mindustry/content/Items.java @@ -97,7 +97,7 @@ public class Items{ beryllium = new Item("beryllium", Color.valueOf("3a8f64")){{ hardness = 4; - cost = 1.3f; + cost = 1.2f; healthScaling = 0.6f; }}; diff --git a/core/src/mindustry/content/TechTree.java b/core/src/mindustry/content/TechTree.java index 5c07be4701..76005bd62c 100644 --- a/core/src/mindustry/content/TechTree.java +++ b/core/src/mindustry/content/TechTree.java @@ -9,6 +9,8 @@ import mindustry.game.Objectives.*; import mindustry.gen.*; import mindustry.type.*; +import java.util.*; + /** Class for storing a list of TechNodes with some utility tree builder methods; context dependent. See {@link SerpuloTechTree#load} source for example usage. */ public class TechTree{ private static TechNode context = null; @@ -66,6 +68,10 @@ public class TechTree{ return nodeProduce(content, new Seq<>(), children); } + public static @Nullable TechNode context(){ + return context; + } + /** @deprecated use {@link UnlockableContent#techNode} instead. */ @Deprecated public static @Nullable TechNode get(UnlockableContent content){ @@ -90,6 +96,8 @@ public class TechTree{ public boolean requiresUnlock = false; /** Requirement node. */ public @Nullable TechNode parent; + /** Multipliers for research costs on a per-item basis. Inherits from parent. */ + public @Nullable ObjectFloatMap researchCostMultipliers; /** Content to be researched. */ public UnlockableContent content; /** Item requirements for this content. */ @@ -102,11 +110,26 @@ public class TechTree{ public final Seq children = new Seq<>(); public TechNode(@Nullable TechNode parent, UnlockableContent content, ItemStack[] requirements){ - if(parent != null) parent.children.add(this); + if(parent != null){ + parent.children.add(this); + researchCostMultipliers = parent.researchCostMultipliers; + }else if(researchCostMultipliers == null){ + researchCostMultipliers = new ObjectFloatMap<>(); + } this.parent = parent; this.content = content; this.depth = parent == null ? 0 : parent.depth + 1; + + if(researchCostMultipliers.size > 0){ + requirements = ItemStack.copy(requirements); + for(ItemStack requirement : requirements){ + requirement.amount = (int)(requirement.amount * researchCostMultipliers.get(requirement.item, 1)); + } + + Log.info("@ = @", content, Arrays.toString(requirements)); + } + setupRequirements(requirements); var used = new ObjectSet(); diff --git a/core/src/mindustry/type/ItemStack.java b/core/src/mindustry/type/ItemStack.java index 253d6d4033..1da2c72231 100644 --- a/core/src/mindustry/type/ItemStack.java +++ b/core/src/mindustry/type/ItemStack.java @@ -60,6 +60,14 @@ public class ItemStack implements Comparable{ return stacks; } + public static ItemStack[] copy(ItemStack[] stacks){ + var out = new ItemStack[stacks.length]; + for(int i = 0; i < out.length; i++){ + out[i] = stacks[i].copy(); + } + return out; + } + @Override public int compareTo(ItemStack itemStack){ return item.compareTo(itemStack.item); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index b81ef11dc8..c62b2e954b 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -271,8 +271,6 @@ public class Block extends UnlockableContent{ public Effect destroyEffect = Fx.dynamicExplosion; /** Multiplier for cost of research in tech tree. */ public float researchCostMultiplier = 1; - /** Multipliers for research costs on a per-item basis. Format: ID to multiplier. */ - public ObjectFloatMap researchCostMultipliers = new ObjectFloatMap<>(); /** Whether this block has instant transfer.*/ public boolean instantTransfer = false; /** Whether you can rotate this block after it is placed. */ @@ -869,7 +867,7 @@ public class Block extends UnlockableContent{ public ItemStack[] researchRequirements(){ ItemStack[] out = new ItemStack[requirements.length]; for(int i = 0; i < out.length; i++){ - int quantity = 60 + Mathf.round(Mathf.pow(requirements[i].amount, 1.1f) * 20 * researchCostMultiplier * researchCostMultipliers.get(requirements[i].item, 1f), 10); + int quantity = 60 + Mathf.round(Mathf.pow(requirements[i].amount, 1.1f) * 20 * researchCostMultiplier, 10); out[i] = new ItemStack(requirements[i].item, UI.roundAmount(quantity)); } diff --git a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java index 9e1051a14c..eb5ca36d2f 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java @@ -133,6 +133,7 @@ public class ItemTurret extends Turret{ @Override public void handleItem(Building source, Item item){ + //TODO instead of all this "entry" crap, turrets could just accept only one type of ammo at a time - simpler for both users and the code if(item == Items.pyratite){ Events.fire(Trigger.flameAmmo);