WIP launch pad rework
This commit is contained in:
@@ -163,7 +163,8 @@ public class Blocks{
|
||||
worldProcessor, worldCell, worldMessage, worldSwitch,
|
||||
|
||||
//campaign
|
||||
launchPad, interplanetaryAccelerator
|
||||
launchPad, advancedLaunchPad, landingPad,
|
||||
interplanetaryAccelerator
|
||||
|
||||
;
|
||||
|
||||
@@ -6353,14 +6354,36 @@ public class Blocks{
|
||||
//region campaign
|
||||
|
||||
launchPad = new LaunchPad("launch-pad"){{
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150));
|
||||
requirements(Category.effect, BuildVisibility.debugOnly, with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150));
|
||||
size = 3;
|
||||
itemCapacity = 100;
|
||||
launchTime = 60f * 20;
|
||||
hasPower = true;
|
||||
acceptMultipleItems = true;
|
||||
consumePower(4f);
|
||||
}};
|
||||
|
||||
advancedLaunchPad = new LaunchPad("advanced-launch-pad"){{
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150));
|
||||
size = 4;
|
||||
itemCapacity = 100;
|
||||
launchTime = 60f * 30;
|
||||
hasPower = true;
|
||||
consumeLiquid(Liquids.oil, 9f/60f);
|
||||
consumePower(8f);
|
||||
}};
|
||||
|
||||
landingPad = new LandingPad("landing-pad"){{
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150));
|
||||
size = 4;
|
||||
|
||||
itemCapacity = 100;
|
||||
|
||||
liquidCapacity = 2000;
|
||||
addLiquidBar(Liquids.water);
|
||||
consumeLiquid(Liquids.water, liquidCapacity).trigger(true).update(false);
|
||||
}};
|
||||
|
||||
interplanetaryAccelerator = new Accelerator("interplanetary-accelerator"){{
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, with(Items.copper, 16000, Items.silicon, 11000, Items.thorium, 13000, Items.titanium, 12000, Items.surgeAlloy, 6000, Items.phaseFabric, 5000));
|
||||
researchCostMultiplier = 0.1f;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SerpuloTechTree{
|
||||
|
||||
node(junction, () -> {
|
||||
node(router, () -> {
|
||||
node(launchPad, Seq.with(new SectorComplete(extractionOutpost)), () -> {
|
||||
node(advancedLaunchPad, Seq.with(new SectorComplete(extractionOutpost)), () -> {
|
||||
node(interplanetaryAccelerator, Seq.with(new SectorComplete(planetaryTerminal)), () -> {
|
||||
|
||||
});
|
||||
@@ -522,7 +522,7 @@ public class SerpuloTechTree{
|
||||
new Research(sei),
|
||||
new Research(omura),
|
||||
new Research(spectre),
|
||||
new Research(launchPad),
|
||||
new Research(advancedLaunchPad),
|
||||
new Research(massDriver),
|
||||
new Research(impactReactor),
|
||||
new Research(additiveReconstructor),
|
||||
|
||||
@@ -56,7 +56,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
static final BuildTeamChangeEvent teamChangeEvent = new BuildTeamChangeEvent();
|
||||
static final BuildDamageEvent bulletDamageEvent = new BuildDamageEvent();
|
||||
static int sleepingEntities = 0;
|
||||
|
||||
|
||||
@Import float x, y, health, maxHealth;
|
||||
@Import Team team;
|
||||
@Import boolean dead;
|
||||
@@ -1029,10 +1029,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
int itemSize = allItems.size;
|
||||
Object[] itemArray = allItems.items;
|
||||
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Building other = proximity.get((i + dump) % proximity.size);
|
||||
|
||||
if(todump == null){
|
||||
if(todump == null){
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Building other = proximity.get((i + dump) % proximity.size);
|
||||
|
||||
for(int ii = 0; ii < itemSize; ii++){
|
||||
if(!items.has(ii)) continue;
|
||||
@@ -1045,16 +1044,22 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
incrementDump(proximity.size);
|
||||
}
|
||||
}else{
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Building other = proximity.get((i + dump) % proximity.size);
|
||||
|
||||
if(other.acceptItem(self(), todump) && canDump(other, todump)){
|
||||
other.handleItem(self(), todump);
|
||||
items.remove(todump, 1);
|
||||
incrementDump(proximity.size);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
incrementDump(proximity.size);
|
||||
incrementDump(proximity.size);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1118,7 +1123,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
power.links.clear();
|
||||
}
|
||||
|
||||
|
||||
public boolean conductsTo(Building other){
|
||||
return !block.insulated;
|
||||
}
|
||||
@@ -1320,7 +1325,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
if(value instanceof Block) type = Block.class;
|
||||
if(value instanceof Liquid) type = Liquid.class;
|
||||
if(value instanceof UnitType) type = UnitType.class;
|
||||
|
||||
|
||||
if(builder != null && builder.isPlayer()){
|
||||
updateLastAccess(builder.getPlayer());
|
||||
}
|
||||
@@ -1727,7 +1732,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
public void updateProximity(){
|
||||
tmpTiles.clear();
|
||||
proximity.clear();
|
||||
|
||||
|
||||
Point2[] nearby = Edges.getEdges(block.size);
|
||||
for(Point2 point : nearby){
|
||||
Building other = world.build(tile.x + point.x, tile.y + point.y);
|
||||
|
||||
@@ -80,8 +80,6 @@ public class SectorInfo{
|
||||
public int waveVersion = -1;
|
||||
/** Whether this sector was indicated to the player or not. */
|
||||
public boolean shown = false;
|
||||
/** Temporary seq for last imported items. Do not use. */
|
||||
public transient ItemSeq lastImported = new ItemSeq();
|
||||
|
||||
/** Special variables for simulation. */
|
||||
public float sumHealth, sumRps, sumDps, bossHealth, bossDps, curEnemyHealth, curEnemyDps;
|
||||
|
||||
@@ -163,31 +163,6 @@ public class Universe{
|
||||
continue;
|
||||
}
|
||||
|
||||
//first pass: clear import stats
|
||||
for(Sector sector : planet.sectors){
|
||||
if(sector.hasBase() && !sector.isBeingPlayed()){
|
||||
sector.info.lastImported.clear();
|
||||
}
|
||||
}
|
||||
|
||||
//second pass: update export & import statistics
|
||||
for(Sector sector : planet.sectors){
|
||||
if(sector.hasBase() && !sector.isBeingPlayed()){
|
||||
|
||||
//export to another sector
|
||||
if(sector.info.destination != null){
|
||||
Sector to = sector.info.destination;
|
||||
if(to.hasBase() && to.planet == planet){
|
||||
ItemSeq items = new ItemSeq();
|
||||
//calculated exported items to this sector
|
||||
sector.info.export.each((item, stat) -> items.add(item, (int)(stat.mean * newSecondsPassed * sector.getProductionScale())));
|
||||
to.addItems(items);
|
||||
to.info.lastImported.add(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//third pass: everything else
|
||||
for(Sector sector : planet.sectors){
|
||||
if(sector.hasBase()){
|
||||
@@ -202,6 +177,8 @@ public class Universe{
|
||||
//increment seconds passed for this sector by the time that just passed with this turn
|
||||
if(!sector.isBeingPlayed()){
|
||||
|
||||
//TODO: if a planet has sectors under attack and simulation is OFF, just don't simulate it
|
||||
|
||||
//increment time if attacked
|
||||
if(sector.isAttacked()){
|
||||
sector.info.secondsPassed += turnDuration/60f;
|
||||
@@ -247,7 +224,8 @@ public class Universe{
|
||||
sector.info.export.each((item, stat) -> {
|
||||
if(sector.info.items.get(item) <= 0 && sector.info.production.get(item, ExportStat::new).mean < 0 && stat.mean > 0){
|
||||
//cap export by import when production is negative.
|
||||
stat.mean = Math.min(sector.info.lastImported.get(item) / (float)newSecondsPassed, stat.mean);
|
||||
//TODO remove
|
||||
stat.mean = Math.min(0f, stat.mean);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
70
core/src/mindustry/world/blocks/campaign/LandingPad.java
Normal file
70
core/src/mindustry/world/blocks/campaign/LandingPad.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package mindustry.world.blocks.campaign;
|
||||
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class LandingPad extends Block{
|
||||
|
||||
public LandingPad(String name){
|
||||
super(name);
|
||||
|
||||
hasItems = true;
|
||||
solid = true;
|
||||
update = true;
|
||||
configurable = true;
|
||||
acceptsItems = false;
|
||||
|
||||
config(Item.class, (LandingPadBuild build, Item item) -> build.config = item);
|
||||
configClear((LandingPadBuild build) -> build.config = null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean outputsItems(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public class LandingPadBuild extends Building{
|
||||
public @Nullable Item config;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(items.total() > 0){
|
||||
dumpAccumulate(config == null || items.get(config) != items.total() ? null : config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDump(Building to, Item item){
|
||||
//hack: canDump is only ever called right before item offload, so count the item as "produced" before that.
|
||||
//TODO: is this necessary?
|
||||
produced(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Object config(){
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
super.read(read, revision);
|
||||
config = TypeIO.readItem(read);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
TypeIO.writeItem(write, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,13 +27,14 @@ import mindustry.world.meta.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class LaunchPad extends Block{
|
||||
/** Time inbetween launches. */
|
||||
/** Time between launches. */
|
||||
public float launchTime = 1f;
|
||||
public Sound launchSound = Sounds.none;
|
||||
|
||||
public @Load("@-light") TextureRegion lightRegion;
|
||||
public @Load(value = "@-pod", fallback = "launchpod") TextureRegion podRegion;
|
||||
public Color lightColor = Color.valueOf("eab678");
|
||||
public boolean acceptMultipleItems = false;
|
||||
|
||||
public LaunchPad(String name){
|
||||
super(name);
|
||||
@@ -116,7 +117,7 @@ public class LaunchPad extends Block{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return items.total() < itemCapacity;
|
||||
return items.total() < itemCapacity && (acceptMultipleItems || items.total() == 0 || items.first() == item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,7 +160,8 @@ public class LaunchPad extends Block{
|
||||
|
||||
@Override
|
||||
public void buildConfiguration(Table table){
|
||||
if(!state.isCampaign() || net.client()){
|
||||
//TODO: this UI should be on landing pads
|
||||
if(!state.isCampaign() || net.client() || true){
|
||||
deselect();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import static mindustry.Vars.*;
|
||||
//TODO replace with ConsumeLiquids?
|
||||
public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
public final Liquid liquid;
|
||||
public boolean trigger;
|
||||
|
||||
public ConsumeLiquid(Liquid liquid, float amount){
|
||||
super(amount);
|
||||
@@ -22,6 +23,11 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
this(null, 0f);
|
||||
}
|
||||
|
||||
public ConsumeLiquid trigger(boolean trigger){
|
||||
this.trigger = trigger;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Block block){
|
||||
super.apply(block);
|
||||
@@ -38,6 +44,13 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
build.liquids.remove(liquid, amount * build.edelta() * multiplier.get(build));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trigger(Building build){
|
||||
if(trigger){
|
||||
build.liquids.remove(liquid, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float efficiency(Building build){
|
||||
float ed = build.edelta() * build.efficiencyScale();
|
||||
|
||||
Reference in New Issue
Block a user