Merge branch 'master' into schematic

This commit is contained in:
J-VdS
2020-08-19 16:14:48 +02:00
420 changed files with 16090 additions and 10744 deletions

View File

@@ -5,6 +5,7 @@ import mindustry.core.GameState.*;
import mindustry.ctype.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.net.*;
import mindustry.type.*;
import mindustry.world.*;
@@ -87,6 +88,14 @@ public class EventType{
}
}
public static class ClientPreConnectEvent{
public final Host host;
public ClientPreConnectEvent(Host host){
this.host = host;
}
}
public static class PlayerChatEvent{
public final Player player;
public final String message;
@@ -157,24 +166,13 @@ public class EventType{
}
}
/** Called when the player taps a block. */
public static class TapEvent{
public final Building tile;
public final Player player;
public TapEvent(Building tile, Player player){
this.tile = tile;
this.player = player;
}
}
/** Called when the player sets a specific block. */
public static class TapConfigEvent{
/** Called when the configures sets a specific block. */
public static class ConfigEvent{
public final Building tile;
public final Player player;
public final Object value;
public TapConfigEvent(Building tile, Player player, Object value){
public ConfigEvent(Building tile, Player player, Object value){
this.tile = tile;
this.player = player;
this.value = value;

View File

@@ -29,46 +29,26 @@ public class Objectives{
}
}
public static class SectorWave extends SectorObjective{
public int wave;
public static class SectorComplete extends SectorObjective{
public SectorWave(SectorPreset zone, int wave){
public SectorComplete(SectorPreset zone){
this.preset = zone;
this.wave = wave;
}
protected SectorWave(){}
protected SectorComplete(){}
@Override
public boolean complete(){
return preset.bestWave() >= wave;
return preset.sector.isCaptured();
}
@Override
public String display(){
return Core.bundle.format("requirement.wave", wave, preset.localizedName);
}
}
public static class Launched extends SectorObjective{
public Launched(SectorPreset zone){
this.preset = zone;
}
protected Launched(){}
@Override
public boolean complete(){
return preset.hasLaunched();
}
@Override
public String display(){
return Core.bundle.format("requirement.core", preset.localizedName);
return Core.bundle.format("requirement.capture", preset.localizedName);
}
}
//TODO merge
public abstract static class SectorObjective implements Objective{
public @NonNull SectorPreset preset;
}

View File

@@ -94,6 +94,8 @@ public class Rules{
public Team defaultTeam = Team.sharded;
/** team of the enemy in waves/sectors */
public Team waveTeam = Team.crux;
/** name of the custom mode that this ruleset describes, or null. */
public @Nullable String modeName;
/** special tags for additional info */
public StringMap tags = new StringMap();

View File

@@ -165,9 +165,10 @@ public class Saves{
}
public void deleteAll(){
saves.clear();
for(Fi file : saveDirectory.list()){
file.delete();
for(SaveSlot slot : saves.copy()){
if(!slot.isSector()){
slot.delete();
}
}
}
@@ -187,7 +188,7 @@ public class Saves{
current = this;
totalPlaytime = meta.timePlayed;
savePreview();
}catch(Exception e){
}catch(Throwable e){
throw new SaveException(e);
}
}
@@ -270,7 +271,7 @@ public class Saves{
mods.removeAll(Vars.mods.getModStrings());
if(!mods.isEmpty()){
ui.showConfirm("$warning", Core.bundle.format("mod.missing", mods.toString("\n")), run);
ui.showConfirm("@warning", Core.bundle.format("mod.missing", mods.toString("\n")), run);
}else{
run.run();
}

View File

@@ -42,7 +42,6 @@ import static mindustry.Vars.*;
public class Schematics implements Loadable{
private static final Schematic tmpSchem = new Schematic(new Seq<>(), new StringMap(), 0, 0);
private static final Schematic tmpSchem2 = new Schematic(new Seq<>(), new StringMap(), 0, 0);
public static final String base64Header = "bXNjaAB";
private static final byte[] header = {'m', 's', 'c', 'h'};
private static final byte version = 1;
@@ -584,7 +583,7 @@ public class Schematics implements Loadable{
int ox = schem.width/2, oy = schem.height/2;
schem.tiles.each(req -> {
req.config = BuildPlan.pointConfig(req.config, p -> {
req.config = BuildPlan.pointConfig(req.block, req.config, p -> {
int cx = p.x, cy = p.y;
int lx = cx;

View File

@@ -64,7 +64,7 @@ public class SectorInfo{
//update core items
coreItems.clear();
CoreEntity entity = state.rules.defaultTeam.core();
CoreBuild entity = state.rules.defaultTeam.core();
if(entity != null){
ItemModule items = entity.items;
@@ -97,7 +97,7 @@ public class SectorInfo{
updateCoreDeltas();
}
CoreEntity ent = state.rules.defaultTeam.core();
CoreBuild ent = state.rules.defaultTeam.core();
//refresh throughput
if(time.get(refreshPeriod)){
@@ -141,7 +141,7 @@ public class SectorInfo{
}
private void updateCoreDeltas(){
CoreEntity ent = state.rules.defaultTeam.core();
CoreBuild ent = state.rules.defaultTeam.core();
for(int i = 0; i < lastCoreItems.length; i++){
lastCoreItems[i] = ent == null ? 0 : ent.items.get(i);
}
@@ -160,5 +160,9 @@ public class SectorInfo{
/** mean in terms of items produced per refresh rate (currently, per second) */
public float mean;
public String toString(){
return mean + "";
}
}
}

View File

@@ -36,12 +36,12 @@ public class Team implements Comparable<Team>{
blue = new Team(5, "blue", Color.royal.cpy());
static{
Mathf.random.setSeed(8);
Mathf.rand.setSeed(8);
//create the whole 256 placeholder teams
for(int i = 6; i < all.length; i++){
new Team(i, "team#" + i, Color.HSVtoRGB(360f * Mathf.random(), 100f * Mathf.random(0.6f, 1f), 100f * Mathf.random(0.8f, 1f), 1f));
}
Mathf.random.setSeed(new Rand().nextLong());
Mathf.rand.setSeed(new Rand().nextLong());
}
public static Team get(int id){
@@ -91,7 +91,7 @@ public class Team implements Comparable<Team>{
return state.teams.get(this);
}
public @Nullable CoreEntity core(){
public @Nullable CoreBuild core(){
return data().core();
}
@@ -103,7 +103,7 @@ public class Team implements Comparable<Team>{
return state.teams.areEnemies(this, other);
}
public Seq<CoreEntity> cores(){
public Seq<CoreBuild> cores(){
return state.teams.cores(this);
}

View File

@@ -5,7 +5,10 @@ import arc.math.geom.*;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import mindustry.ai.*;
import mindustry.content.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import static mindustry.Vars.*;
@@ -21,15 +24,15 @@ public class Teams{
active.add(get(Team.crux));
}
public @Nullable CoreEntity closestEnemyCore(float x, float y, Team team){
public @Nullable CoreBuild closestEnemyCore(float x, float y, Team team){
for(Team enemy : team.enemies()){
CoreEntity tile = Geometry.findClosest(x, y, enemy.cores());
CoreBuild tile = Geometry.findClosest(x, y, enemy.cores());
if(tile != null) return tile;
}
return null;
}
public @Nullable CoreEntity closestCore(float x, float y, Team team){
public @Nullable CoreBuild closestCore(float x, float y, Team team){
return Geometry.findClosest(x, y, get(team).cores);
}
@@ -37,10 +40,10 @@ public class Teams{
return get(team).enemies;
}
public boolean eachEnemyCore(Team team, Boolf<CoreEntity> ret){
public boolean eachEnemyCore(Team team, Boolf<CoreBuild> ret){
for(TeamData data : active){
if(areEnemies(team, data.team)){
for(CoreEntity tile : data.cores){
for(CoreBuild tile : data.cores){
if(ret.get(tile)){
return true;
}
@@ -68,12 +71,12 @@ public class Teams{
return map[team.id];
}
public Seq<CoreEntity> playerCores(){
public Seq<CoreBuild> playerCores(){
return get(state.rules.defaultTeam).cores;
}
/** Do not modify! */
public Seq<CoreEntity> cores(Team team){
public Seq<CoreBuild> cores(Team team){
return get(team).cores;
}
@@ -98,7 +101,7 @@ public class Teams{
return active;
}
public void registerCore(CoreEntity core){
public void registerCore(CoreBuild core){
TeamData data = get(core.team());
//add core if not present
if(!data.cores.contains(core)){
@@ -113,7 +116,7 @@ public class Teams{
}
}
public void unregisterCore(CoreEntity entity){
public void unregisterCore(CoreBuild entity){
TeamData data = get(entity.team());
//remove core
data.cores.remove(entity);
@@ -143,11 +146,17 @@ public class Teams{
}
public class TeamData{
public final Seq<CoreEntity> cores = new Seq<>();
public final Seq<CoreBuild> cores = new Seq<>();
public final Team team;
public final BaseAI ai;
public Team[] enemies = {};
/** Planned blocks for drones. This is usually only blocks that have been broken. */
public Queue<BlockPlan> blocks = new Queue<>();
/** The current command for units to follow. */
public UnitCommand command = UnitCommand.attack;
/** Target items to mine. */
public Seq<Item> mineItems = Seq.with(Items.copper, Items.lead, Items.titanium, Items.thorium);
public TeamData(Team team){
this.team = team;
@@ -166,7 +175,7 @@ public class Teams{
return cores.isEmpty();
}
public @Nullable CoreEntity core(){
public @Nullable CoreBuild core(){
return cores.isEmpty() ? null : cores.first();
}