WIP launch pad rework
This commit is contained in:
@@ -1748,7 +1748,7 @@ block.spectre.name = Spectre
|
|||||||
block.meltdown.name = Meltdown
|
block.meltdown.name = Meltdown
|
||||||
block.foreshadow.name = Foreshadow
|
block.foreshadow.name = Foreshadow
|
||||||
block.container.name = Container
|
block.container.name = Container
|
||||||
block.launch-pad.name = Launch Pad
|
block.launch-pad.name = Launch Pad (Legacy)
|
||||||
block.segment.name = Segment
|
block.segment.name = Segment
|
||||||
block.ground-factory.name = Ground Factory
|
block.ground-factory.name = Ground Factory
|
||||||
block.air-factory.name = Air Factory
|
block.air-factory.name = Air Factory
|
||||||
|
|||||||
@@ -163,7 +163,8 @@ public class Blocks{
|
|||||||
worldProcessor, worldCell, worldMessage, worldSwitch,
|
worldProcessor, worldCell, worldMessage, worldSwitch,
|
||||||
|
|
||||||
//campaign
|
//campaign
|
||||||
launchPad, interplanetaryAccelerator
|
launchPad, advancedLaunchPad, landingPad,
|
||||||
|
interplanetaryAccelerator
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -6353,14 +6354,36 @@ public class Blocks{
|
|||||||
//region campaign
|
//region campaign
|
||||||
|
|
||||||
launchPad = new LaunchPad("launch-pad"){{
|
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;
|
size = 3;
|
||||||
itemCapacity = 100;
|
itemCapacity = 100;
|
||||||
launchTime = 60f * 20;
|
launchTime = 60f * 20;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
|
acceptMultipleItems = true;
|
||||||
consumePower(4f);
|
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"){{
|
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));
|
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;
|
researchCostMultiplier = 0.1f;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class SerpuloTechTree{
|
|||||||
|
|
||||||
node(junction, () -> {
|
node(junction, () -> {
|
||||||
node(router, () -> {
|
node(router, () -> {
|
||||||
node(launchPad, Seq.with(new SectorComplete(extractionOutpost)), () -> {
|
node(advancedLaunchPad, Seq.with(new SectorComplete(extractionOutpost)), () -> {
|
||||||
node(interplanetaryAccelerator, Seq.with(new SectorComplete(planetaryTerminal)), () -> {
|
node(interplanetaryAccelerator, Seq.with(new SectorComplete(planetaryTerminal)), () -> {
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -522,7 +522,7 @@ public class SerpuloTechTree{
|
|||||||
new Research(sei),
|
new Research(sei),
|
||||||
new Research(omura),
|
new Research(omura),
|
||||||
new Research(spectre),
|
new Research(spectre),
|
||||||
new Research(launchPad),
|
new Research(advancedLaunchPad),
|
||||||
new Research(massDriver),
|
new Research(massDriver),
|
||||||
new Research(impactReactor),
|
new Research(impactReactor),
|
||||||
new Research(additiveReconstructor),
|
new Research(additiveReconstructor),
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
static final BuildTeamChangeEvent teamChangeEvent = new BuildTeamChangeEvent();
|
static final BuildTeamChangeEvent teamChangeEvent = new BuildTeamChangeEvent();
|
||||||
static final BuildDamageEvent bulletDamageEvent = new BuildDamageEvent();
|
static final BuildDamageEvent bulletDamageEvent = new BuildDamageEvent();
|
||||||
static int sleepingEntities = 0;
|
static int sleepingEntities = 0;
|
||||||
|
|
||||||
@Import float x, y, health, maxHealth;
|
@Import float x, y, health, maxHealth;
|
||||||
@Import Team team;
|
@Import Team team;
|
||||||
@Import boolean dead;
|
@Import boolean dead;
|
||||||
@@ -1029,10 +1029,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
int itemSize = allItems.size;
|
int itemSize = allItems.size;
|
||||||
Object[] itemArray = allItems.items;
|
Object[] itemArray = allItems.items;
|
||||||
|
|
||||||
for(int i = 0; i < proximity.size; i++){
|
if(todump == null){
|
||||||
Building other = proximity.get((i + dump) % proximity.size);
|
for(int i = 0; i < proximity.size; i++){
|
||||||
|
Building other = proximity.get((i + dump) % proximity.size);
|
||||||
if(todump == null){
|
|
||||||
|
|
||||||
for(int ii = 0; ii < itemSize; ii++){
|
for(int ii = 0; ii < itemSize; ii++){
|
||||||
if(!items.has(ii)) continue;
|
if(!items.has(ii)) continue;
|
||||||
@@ -1045,16 +1044,22 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
return true;
|
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)){
|
if(other.acceptItem(self(), todump) && canDump(other, todump)){
|
||||||
other.handleItem(self(), todump);
|
other.handleItem(self(), todump);
|
||||||
items.remove(todump, 1);
|
items.remove(todump, 1);
|
||||||
incrementDump(proximity.size);
|
incrementDump(proximity.size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
incrementDump(proximity.size);
|
incrementDump(proximity.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -1118,7 +1123,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
power.links.clear();
|
power.links.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean conductsTo(Building other){
|
public boolean conductsTo(Building other){
|
||||||
return !block.insulated;
|
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 Block) type = Block.class;
|
||||||
if(value instanceof Liquid) type = Liquid.class;
|
if(value instanceof Liquid) type = Liquid.class;
|
||||||
if(value instanceof UnitType) type = UnitType.class;
|
if(value instanceof UnitType) type = UnitType.class;
|
||||||
|
|
||||||
if(builder != null && builder.isPlayer()){
|
if(builder != null && builder.isPlayer()){
|
||||||
updateLastAccess(builder.getPlayer());
|
updateLastAccess(builder.getPlayer());
|
||||||
}
|
}
|
||||||
@@ -1727,7 +1732,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
public void updateProximity(){
|
public void updateProximity(){
|
||||||
tmpTiles.clear();
|
tmpTiles.clear();
|
||||||
proximity.clear();
|
proximity.clear();
|
||||||
|
|
||||||
Point2[] nearby = Edges.getEdges(block.size);
|
Point2[] nearby = Edges.getEdges(block.size);
|
||||||
for(Point2 point : nearby){
|
for(Point2 point : nearby){
|
||||||
Building other = world.build(tile.x + point.x, tile.y + point.y);
|
Building other = world.build(tile.x + point.x, tile.y + point.y);
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ public class SectorInfo{
|
|||||||
public int waveVersion = -1;
|
public int waveVersion = -1;
|
||||||
/** Whether this sector was indicated to the player or not. */
|
/** Whether this sector was indicated to the player or not. */
|
||||||
public boolean shown = false;
|
public boolean shown = false;
|
||||||
/** Temporary seq for last imported items. Do not use. */
|
|
||||||
public transient ItemSeq lastImported = new ItemSeq();
|
|
||||||
|
|
||||||
/** Special variables for simulation. */
|
/** Special variables for simulation. */
|
||||||
public float sumHealth, sumRps, sumDps, bossHealth, bossDps, curEnemyHealth, curEnemyDps;
|
public float sumHealth, sumRps, sumDps, bossHealth, bossDps, curEnemyHealth, curEnemyDps;
|
||||||
|
|||||||
@@ -163,31 +163,6 @@ public class Universe{
|
|||||||
continue;
|
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
|
//third pass: everything else
|
||||||
for(Sector sector : planet.sectors){
|
for(Sector sector : planet.sectors){
|
||||||
if(sector.hasBase()){
|
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
|
//increment seconds passed for this sector by the time that just passed with this turn
|
||||||
if(!sector.isBeingPlayed()){
|
if(!sector.isBeingPlayed()){
|
||||||
|
|
||||||
|
//TODO: if a planet has sectors under attack and simulation is OFF, just don't simulate it
|
||||||
|
|
||||||
//increment time if attacked
|
//increment time if attacked
|
||||||
if(sector.isAttacked()){
|
if(sector.isAttacked()){
|
||||||
sector.info.secondsPassed += turnDuration/60f;
|
sector.info.secondsPassed += turnDuration/60f;
|
||||||
@@ -247,7 +224,8 @@ public class Universe{
|
|||||||
sector.info.export.each((item, stat) -> {
|
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){
|
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.
|
//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.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class LaunchPad extends Block{
|
public class LaunchPad extends Block{
|
||||||
/** Time inbetween launches. */
|
/** Time between launches. */
|
||||||
public float launchTime = 1f;
|
public float launchTime = 1f;
|
||||||
public Sound launchSound = Sounds.none;
|
public Sound launchSound = Sounds.none;
|
||||||
|
|
||||||
public @Load("@-light") TextureRegion lightRegion;
|
public @Load("@-light") TextureRegion lightRegion;
|
||||||
public @Load(value = "@-pod", fallback = "launchpod") TextureRegion podRegion;
|
public @Load(value = "@-pod", fallback = "launchpod") TextureRegion podRegion;
|
||||||
public Color lightColor = Color.valueOf("eab678");
|
public Color lightColor = Color.valueOf("eab678");
|
||||||
|
public boolean acceptMultipleItems = false;
|
||||||
|
|
||||||
public LaunchPad(String name){
|
public LaunchPad(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -116,7 +117,7 @@ public class LaunchPad extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Building source, Item item){
|
public boolean acceptItem(Building source, Item item){
|
||||||
return items.total() < itemCapacity;
|
return items.total() < itemCapacity && (acceptMultipleItems || items.total() == 0 || items.first() == item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -159,7 +160,8 @@ public class LaunchPad extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
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();
|
deselect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import static mindustry.Vars.*;
|
|||||||
//TODO replace with ConsumeLiquids?
|
//TODO replace with ConsumeLiquids?
|
||||||
public class ConsumeLiquid extends ConsumeLiquidBase{
|
public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||||
public final Liquid liquid;
|
public final Liquid liquid;
|
||||||
|
public boolean trigger;
|
||||||
|
|
||||||
public ConsumeLiquid(Liquid liquid, float amount){
|
public ConsumeLiquid(Liquid liquid, float amount){
|
||||||
super(amount);
|
super(amount);
|
||||||
@@ -22,6 +23,11 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
|||||||
this(null, 0f);
|
this(null, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConsumeLiquid trigger(boolean trigger){
|
||||||
|
this.trigger = trigger;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(Block block){
|
public void apply(Block block){
|
||||||
super.apply(block);
|
super.apply(block);
|
||||||
@@ -38,6 +44,13 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
|||||||
build.liquids.remove(liquid, amount * build.edelta() * multiplier.get(build));
|
build.liquids.remove(liquid, amount * build.edelta() * multiplier.get(build));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trigger(Building build){
|
||||||
|
if(trigger){
|
||||||
|
build.liquids.remove(liquid, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float efficiency(Building build){
|
public float efficiency(Building build){
|
||||||
float ed = build.edelta() * build.efficiencyScale();
|
float ed = build.edelta() * build.efficiencyScale();
|
||||||
|
|||||||
Reference in New Issue
Block a user