mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Merge branch 'campaign'
# Conflicts: # core/src/mindustry/world/consumers/ConsumeItemFilter.java
This commit is contained in:
commit
c1970b4da5
@ -87,8 +87,8 @@ public class BuilderAI extends AIController{
|
||||
}
|
||||
|
||||
//find new request
|
||||
if(!unit.team().data().blocks.isEmpty() && following == null && timer.get(timerTarget3, 60 * 2f)){
|
||||
Queue<BlockPlan> blocks = unit.team().data().blocks;
|
||||
if(!unit.team.data().blocks.isEmpty() && following == null && timer.get(timerTarget3, 60 * 2f)){
|
||||
Queue<BlockPlan> blocks = unit.team.data().blocks;
|
||||
BlockPlan block = blocks.first();
|
||||
|
||||
//check if it's already been placed
|
||||
|
@ -1580,13 +1580,13 @@ public class Blocks implements ContentList{
|
||||
requirements(Category.turret, with(Items.silicon, 130, Items.thorium, 80, Items.phasefabric, 40));
|
||||
|
||||
health = 250 * size * size;
|
||||
range = 140f;
|
||||
range = 160f;
|
||||
hasPower = true;
|
||||
consumes.powerCond(8f, (PointDefenseBuild b) -> b.target != null);
|
||||
size = 2;
|
||||
shootLength = 5f;
|
||||
bulletDamage = 25f;
|
||||
reloadTime = 10f;
|
||||
reloadTime = 9f;
|
||||
}};
|
||||
|
||||
tsunami = new LiquidTurret("tsunami"){{
|
||||
@ -1701,7 +1701,7 @@ public class Blocks implements ContentList{
|
||||
trailEffect = Fx.instTrail;
|
||||
despawnEffect = Fx.instBomb;
|
||||
trailSpacing = 20f;
|
||||
damage = 1250;
|
||||
damage = 1350;
|
||||
tileDamageMultiplier = 0.5f;
|
||||
speed = brange;
|
||||
hitShake = 6f;
|
||||
|
@ -519,7 +519,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
platform.updateRPC();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.pause) && !state.isOutOfTime() && !scene.hasDialog() && !scene.hasKeyboard() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
|
||||
if(Core.input.keyTap(Binding.pause) && !scene.hasDialog() && !scene.hasKeyboard() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
|
||||
state.set(state.is(State.playing) ? State.paused : State.playing);
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,6 @@ public class GameState{
|
||||
return rules.sector != null;
|
||||
}
|
||||
|
||||
/** @return whether the player is in a campaign and they are out of sector time */
|
||||
public boolean isOutOfTime(){
|
||||
return isCampaign() && isGame() && getSector().getTimeSpent() >= turnDuration && !net.active();
|
||||
}
|
||||
|
||||
public boolean hasSector(){
|
||||
return rules.sector != null;
|
||||
}
|
||||
|
@ -282,18 +282,6 @@ public class Logic implements ApplicationListener{
|
||||
state.enemies = Groups.unit.count(u -> u.team() == state.rules.waveTeam && u.type().isCounted);
|
||||
}
|
||||
|
||||
//force pausing when the player is out of sector time
|
||||
if(state.isOutOfTime()){
|
||||
if(!state.wasTimeout){
|
||||
universe.displayTimeEnd();
|
||||
state.wasTimeout = true;
|
||||
}
|
||||
//if no turn was run.
|
||||
if(state.isOutOfTime()){
|
||||
state.set(State.paused);
|
||||
}
|
||||
}
|
||||
|
||||
if(!state.isPaused()){
|
||||
if(state.isCampaign()){
|
||||
state.secinfo.update();
|
||||
|
@ -24,7 +24,7 @@ public class SectorInfo{
|
||||
/** Export statistics. */
|
||||
public ObjectMap<Item, ExportStat> export = new ObjectMap<>();
|
||||
/** Items stored in all cores. */
|
||||
public ObjectIntMap<Item> coreItems = new ObjectIntMap<>();
|
||||
public ItemSeq coreItems = new ItemSeq();
|
||||
/** The best available core type. */
|
||||
public Block bestCoreType = Blocks.air;
|
||||
/** Max storage capacity. */
|
||||
@ -80,7 +80,7 @@ public class SectorInfo{
|
||||
if(entity != null){
|
||||
ItemModule items = entity.items;
|
||||
for(int i = 0; i < items.length(); i++){
|
||||
coreItems.put(content.item(i), items.get(i));
|
||||
coreItems.set(content.item(i), items.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class SectorInfo{
|
||||
bestCoreType = !hasCore ? Blocks.air : state.rules.defaultTeam.cores().max(e -> e.block.size).block;
|
||||
storageCapacity = entity != null ? entity.storageCapacity : 0;
|
||||
|
||||
//update sector's internal time spent counter1
|
||||
//update sector's internal time spent counter
|
||||
state.rules.sector.setTimeSpent(internalTimeSpent);
|
||||
}
|
||||
|
||||
@ -100,6 +100,12 @@ public class SectorInfo{
|
||||
|
||||
internalTimeSpent += Time.delta;
|
||||
|
||||
//autorun turns
|
||||
if(internalTimeSpent >= turnDuration){
|
||||
internalTimeSpent = 0;
|
||||
universe.runTurn();
|
||||
}
|
||||
|
||||
//create last stored core items
|
||||
if(lastCoreItems == null){
|
||||
lastCoreItems = new int[content.items().size];
|
||||
|
@ -5,7 +5,6 @@ import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
@ -54,25 +53,9 @@ public class Universe{
|
||||
}
|
||||
}
|
||||
|
||||
public void displayTimeEnd(){
|
||||
if(!headless){
|
||||
//check if any sectors are under attack to display this
|
||||
Seq<Sector> attacked = state.getSector().planet.sectors.select(s -> s.hasWaves() && s.hasBase() && !s.isBeingPlayed() && s.getSecondsPassed() > 1);
|
||||
|
||||
if(attacked.any()){
|
||||
state.set(State.paused);
|
||||
|
||||
//TODO localize
|
||||
String text = attacked.size > 1 ? attacked.size + " sectors attacked." : "Sector " + attacked.first().id + " under attack.";
|
||||
|
||||
ui.hudfrag.sectorText = text;
|
||||
ui.hudfrag.attackedSectors = attacked;
|
||||
ui.announce(text);
|
||||
}else{
|
||||
//autorun next turn
|
||||
universe.runTurn();
|
||||
}
|
||||
}
|
||||
/** @return sectors attacked on the current planet, minus the ones that are being played on right now. */
|
||||
public Seq<Sector> getAttacked(Planet planet){
|
||||
return planet.sectors.select(s -> s.hasWaves() && s.hasBase() && !s.isBeingPlayed() && s.getSecondsPassed() > 1);
|
||||
}
|
||||
|
||||
/** Update planet rotations, global time and relevant state. */
|
||||
|
@ -98,8 +98,10 @@ public class ItemSeq implements Iterable<ItemStack>, Serializable{
|
||||
|
||||
@Override
|
||||
public void read(Json json, JsonValue jsonData){
|
||||
total = 0;
|
||||
for(Item item : Vars.content.items()){
|
||||
values[item.id] = jsonData.getInt(item.name, 0);
|
||||
total += values[item.id];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package mindustry.type;
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.ObjectIntMap.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
@ -152,6 +151,26 @@ public class Sector{
|
||||
}else{
|
||||
ItemSeq recv = getExtraItems();
|
||||
|
||||
if(save != null){
|
||||
//"shave off" extra items
|
||||
|
||||
ItemSeq count = new ItemSeq();
|
||||
|
||||
//add items already present
|
||||
count.add(save.meta.secinfo.coreItems);
|
||||
|
||||
count.add(calculateReceivedItems());
|
||||
|
||||
int capacity = save.meta.secinfo.storageCapacity;
|
||||
|
||||
//when over capacity, add that to the extra items
|
||||
count.each((i, a) -> {
|
||||
if(a > capacity){
|
||||
recv.remove(i, (a - capacity));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
recv.remove(item, amount);
|
||||
|
||||
setExtraItems(recv);
|
||||
@ -166,21 +185,19 @@ public class Sector{
|
||||
count.add(state.rules.defaultTeam.items());
|
||||
}else if(save != null){
|
||||
//add items already present
|
||||
for(Entry<Item> ent : save.meta.secinfo.coreItems){
|
||||
count.add(ent.key, ent.value);
|
||||
}
|
||||
count.add(save.meta.secinfo.coreItems);
|
||||
|
||||
count.add(calculateReceivedItems());
|
||||
|
||||
int capacity = save.meta.secinfo.storageCapacity;
|
||||
|
||||
//validation
|
||||
for(Item item : content.items()){
|
||||
count.each((item, amount) -> {
|
||||
//ensure positive items
|
||||
if(count.get(item) < 0) count.set(item, 0);
|
||||
if(amount < 0) count.set(item, 0);
|
||||
//cap the items
|
||||
if(count.get(item) > capacity) count.set(item, capacity);
|
||||
}
|
||||
if(amount > capacity) count.set(item, capacity);
|
||||
});
|
||||
}
|
||||
|
||||
return count;
|
||||
@ -196,7 +213,7 @@ public class Sector{
|
||||
save.meta.secinfo.production.each((item, stat) -> count.add(item, (int)(stat.mean * seconds)));
|
||||
|
||||
//add received items
|
||||
getExtraItems().each(count::add);
|
||||
count.add(getExtraItems());
|
||||
}
|
||||
|
||||
return count;
|
||||
@ -244,14 +261,14 @@ public class Sector{
|
||||
return Core.settings.getFloat(key("time-spent"));
|
||||
}
|
||||
|
||||
public void setSecondsPassed(long number){
|
||||
put("seconds-passed", number);
|
||||
public void setSecondsPassed(int number){
|
||||
put("secondsi-passed", number);
|
||||
}
|
||||
|
||||
/** @return how much time has passed in this sector without the player resuming here.
|
||||
* Used for resource production calculations. */
|
||||
public long getSecondsPassed(){
|
||||
return Core.settings.getLong(key("seconds-passed"));
|
||||
public int getSecondsPassed(){
|
||||
return Core.settings.getInt(key("secondsi-passed"));
|
||||
}
|
||||
|
||||
private String key(String key){
|
||||
|
@ -381,7 +381,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
|
||||
//stored resources
|
||||
if(sector.hasBase() && sector.save.meta.secinfo.coreItems.size > 0){
|
||||
if(sector.hasBase() && sector.save.meta.secinfo.coreItems.total > 0){
|
||||
stable.add("@sectors.stored").row();
|
||||
stable.table(t -> {
|
||||
t.left();
|
||||
|
@ -33,10 +33,6 @@ public class HudFragment extends Fragment{
|
||||
|
||||
public final PlacementFragment blockfrag = new PlacementFragment();
|
||||
|
||||
//TODO localize
|
||||
public String sectorText = "Out of sector time.";
|
||||
public Seq<Sector> attackedSectors = new Seq<>();
|
||||
|
||||
private ImageButton flip;
|
||||
private Table lastUnlockTable;
|
||||
private Table lastUnlockLayout;
|
||||
@ -68,9 +64,23 @@ public class HudFragment extends Fragment{
|
||||
coreItems.clear();
|
||||
});
|
||||
|
||||
Events.on(TurnEvent.class, e -> {
|
||||
Seq<Sector> attacked = universe.getAttacked(state.getSector().planet);
|
||||
|
||||
if(attacked.any()){
|
||||
|
||||
//TODO localize
|
||||
String text = attacked.size > 1 ? attacked.size + " sectors attacked." : "Sector " + attacked.first().id + " under attack.";
|
||||
|
||||
showToast(Icon.warning, text);
|
||||
}
|
||||
|
||||
//ui.announce("[accent][[ Turn " + universe.turn() + " ]\n[scarlet]" + attackedSectors.size + "[lightgray] sector(s) attacked.");
|
||||
});
|
||||
|
||||
//paused table
|
||||
parent.fill(t -> {
|
||||
t.top().visible(() -> state.isPaused() && !state.isOutOfTime()).touchable = Touchable.disabled;
|
||||
t.top().visible(() -> state.isPaused()).touchable = Touchable.disabled;
|
||||
t.table(Styles.black5, top -> top.add("@paused").style(Styles.outlineLabel).pad(8f)).growX();
|
||||
});
|
||||
|
||||
@ -273,37 +283,6 @@ public class HudFragment extends Fragment{
|
||||
.update(label -> label.color.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled);
|
||||
});
|
||||
|
||||
//paused table for when the player is out of time
|
||||
parent.fill(t -> {
|
||||
t.top().visible(() -> state.isOutOfTime());
|
||||
t.table(Styles.black5, top -> {
|
||||
//TODO localize
|
||||
top.add(sectorText).style(Styles.outlineLabel).color(Pal.accent).update(l -> {
|
||||
l.color.a = Mathf.absin(Time.globalTime(), 7f, 1f);
|
||||
l.setText(sectorText);
|
||||
}).colspan(2);
|
||||
top.row();
|
||||
|
||||
top.defaults().pad(2).size(150f, 54f);
|
||||
//TODO localize
|
||||
top.button("Skip", () -> {
|
||||
universe.runTurn();
|
||||
state.set(State.playing);
|
||||
|
||||
//announce turn info only when something is skipped.
|
||||
ui.announce("[accent][[ Turn " + universe.turn() + " ]\n[scarlet]" + attackedSectors.size + "[lightgray] sector(s) attacked.");
|
||||
});
|
||||
|
||||
//TODO localize
|
||||
top.button("Switch Sectors", () -> {
|
||||
ui.paused.runExitSave();
|
||||
|
||||
//switch to first attacked sector
|
||||
control.playSector(attackedSectors.first());
|
||||
}).disabled(b -> attackedSectors.isEmpty());
|
||||
}).margin(8).growX();
|
||||
});
|
||||
|
||||
//tutorial text
|
||||
parent.fill(t -> {
|
||||
Runnable resize = () -> {
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=f4e823e80a634226c617e30f2d67d61562b8faaa
|
||||
archash=8278e148026dab6b5f74ded2ed2be76a22418c76
|
||||
|
Loading…
Reference in New Issue
Block a user