mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-22 05:38:19 +07:00
Added spawner grace period
This commit is contained in:
@ -46,6 +46,9 @@ public class FortressGenerator{
|
||||
//tungsten duo and drone outpost
|
||||
new Structure(0.02f, Items.tungsten, "BgEADXR1bmdzdGVuLXdhbGwEAA1jYXJiaWRlLWRyaWxsAwADZHVvAgATdHVuZ3N0ZW4td2FsbC1sYXJnZQAAA2FpcgUACWRyb25lLXBhZAUHAAAAAAEDAQMCAgAAAAAAAAAAAQADAAADAAMBAgAAAAABAAQBBQAAAAECAAAAAAEAAwAAAAAAAQIAAAAAAQABAQEBAQEBAg=="),
|
||||
|
||||
//resupply point
|
||||
new Structure(0.03f, Items.lead, "BgEADXR1bmdzdGVuLXdhbGwCAAtzb2xhci1wYW5lbAUAA2R1bwMADnJlc3VwcGx5LXBvaW50AAADYWlyBAANY2FyYmlkZS1kcmlsbAUFAQABAAEAAAAAAAEAAgMBAQEBAQABAAMDBAEFAQEAAQACAwEBAQEBAAEBAQEBAQAAAAA="),
|
||||
|
||||
//lead storage
|
||||
new Structure(0.02f, Items.lead, vaults),
|
||||
|
||||
@ -64,6 +67,9 @@ public class FortressGenerator{
|
||||
//2x interceptor outpost
|
||||
new Structure(0.02f, Items.lead, "CgMAEXNvbGFyLXBhbmVsLWxhcmdlBgADZHVvAgAPaW50ZXJjZXB0b3ItcGFkBAASY2FyYmlkZS13YWxsLWxhcmdlBwAOcmVzdXBwbHktcG9pbnQAAANhaXIFAAtzb2xhci1wYW5lbAEADGNhcmJpZGUtd2FsbAkAC2Rpc3RyaWJ1dG9yCAALbGFzZXItZHJpbGwKCAEAAQMBAwEDAQMBAwECAAABAAIDAAAAAAAAAAABAgAAAQAAAAAAAAADAQAAAQIBAgQDAAAFAAAAAAAAAAYCAQMAAAAABwAIAAAACQAAAAECBAMAAAEAAAAAAAABAAABAgAAAAAFAAAAAAAAAAYCAQIBAAIDAAAAAAMBAAABAgECAQAAAAAAAAAAAAAAAQIAAAEAAQEBAQEBAQEBAQEBAAA="),
|
||||
|
||||
//resupply point (again)
|
||||
new Structure(0.02f, Items.lead, "BgEADXR1bmdzdGVuLXdhbGwCAAtzb2xhci1wYW5lbAUAA2R1bwMADnJlc3VwcGx5LXBvaW50AAADYWlyBAANY2FyYmlkZS1kcmlsbAUFAQABAAEAAAAAAAEAAgMBAQEBAQABAAMDBAEFAQEAAQACAwEBAQEBAAEBAQEBAQAAAAA="),
|
||||
|
||||
//coal laser outpost
|
||||
new Structure(0.03f, null, "BgEADHRob3JpdW0td2FsbAMABmxhbmNlcgUAFGNvbWJ1c3Rpb24tZ2VuZXJhdG9yBAANY2FyYmlkZS1kcmlsbAAAA2FpcgIAC3NvbGFyLXBhbmVsBwcAAAEAAQABAQEBAQEBAAAAAQACAgMAAAACAAEAAAABAAICAAAAAAIAAQAAAAEAAQAEAQUAAQABAAAAAQACAAMBAAMCAAEAAAABAAIAAAMAAwIAAQAAAAEAAQABAwEDAQABAA=="),
|
||||
|
||||
@ -123,7 +129,6 @@ public class FortressGenerator{
|
||||
void genOutposts(){
|
||||
int padding = 10;
|
||||
int maxDifficulty = 13;
|
||||
float baseChance = 0.4f;
|
||||
Array<Structure> selected = new Array<>();
|
||||
Array<Rectangle> used = new Array<>();
|
||||
Rectangle rect = new Rectangle();
|
||||
@ -135,6 +140,8 @@ public class FortressGenerator{
|
||||
selected.add(structures[i]);
|
||||
}
|
||||
|
||||
float baseChance = 0.8f / selected.size;
|
||||
|
||||
used.add(new Rectangle(enemyX - base.width()/2, enemyY - base.height()/2, base.width(), base.height()));
|
||||
int elev = gen.tiles[enemyX][enemyY].getElevation();
|
||||
for(int x = 0; x < base.width(); x++){
|
||||
|
@ -36,6 +36,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class UnitPad extends Block{
|
||||
protected float gracePeriodMultiplier = 8f;
|
||||
protected UnitType type;
|
||||
protected float produceTime = 1000f;
|
||||
protected float openDuration = 50f;
|
||||
@ -101,8 +102,8 @@ public class UnitPad extends Block{
|
||||
@Override
|
||||
public TextureRegion[] getIcon(){
|
||||
return new TextureRegion[]{
|
||||
Draw.region(name),
|
||||
Draw.region(name + "-top")
|
||||
Draw.region(name),
|
||||
Draw.region(name + "-top")
|
||||
};
|
||||
}
|
||||
|
||||
@ -159,6 +160,10 @@ public class UnitPad extends Block{
|
||||
|
||||
boolean isEnemy = tile.getTeam() == Team.red;
|
||||
|
||||
if(isEnemy){
|
||||
entity.warmup += Timers.delta();
|
||||
}
|
||||
|
||||
if(!isEnemy){
|
||||
//player-made spawners have default behavior
|
||||
|
||||
@ -170,7 +175,8 @@ public class UnitPad extends Block{
|
||||
}else{
|
||||
if(!entity.open) entity.speedScl = Mathf.lerpDelta(entity.speedScl, 0f, 0.05f);
|
||||
}
|
||||
}else if(!entity.hasSpawned){
|
||||
//check if grace period had passed
|
||||
}else if(!entity.hasSpawned && entity.warmup > produceTime*gracePeriodMultiplier){
|
||||
//otherwise, it's an enemy, cheat by not requiring resources
|
||||
entity.buildTime += Timers.delta() / 4f;
|
||||
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.05f);
|
||||
@ -233,16 +239,19 @@ public class UnitPad extends Block{
|
||||
public float time;
|
||||
public float speedScl;
|
||||
public boolean hasSpawned;
|
||||
public float warmup; //only for enemy spawners
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException{
|
||||
stream.writeFloat(buildTime);
|
||||
stream.writeFloat(warmup);
|
||||
stream.writeBoolean(hasSpawned);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException{
|
||||
buildTime = stream.readFloat();
|
||||
warmup = stream.readFloat();
|
||||
hasSpawned = stream.readBoolean();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user