Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features

This commit is contained in:
Anuken
2021-10-31 13:33:46 -04:00
16 changed files with 80 additions and 20 deletions

View File

@@ -18,7 +18,7 @@ See [CONTRIBUTING](CONTRIBUTING.md).
Bleeding-edge builds are generated automatically for every commit. You can see them [here](https://github.com/Anuken/MindustryBuilds/releases). Bleeding-edge builds are generated automatically for every commit. You can see them [here](https://github.com/Anuken/MindustryBuilds/releases).
If you'd rather compile on your own, follow these instructions. If you'd rather compile on your own, follow these instructions.
First, make sure you have [JDK 16-17](https://adoptopenjdk.net/archive.html?variant=openjdk16&jvmVariant=hotspot) installed. **Other JDK versions will not work.** Open a terminal in the Mindustry directory and run the following commands: First, make sure you have [JDK 16-17](https://adoptium.net/archive.html?variant=openjdk17&jvmVariant=hotspot) installed. **Other JDK versions will not work.** Open a terminal in the Mindustry directory and run the following commands:
### Windows ### Windows

View File

@@ -54,9 +54,9 @@ public class Pathfinder implements Runnable{
(PathTile.solid(tile) ? 5 : 0), (PathTile.solid(tile) ? 5 : 0),
//water //water
(team, tile) -> PathTile.solid(tile) || !PathTile.liquid(tile) ? 200 : 2 + (team, tile) -> (PathTile.solid(tile) || !PathTile.liquid(tile) ? 6000 : 1) +
(PathTile.nearGround(tile) || PathTile.nearSolid(tile) ? 14 : 0) + (PathTile.nearGround(tile) || PathTile.nearSolid(tile) ? 14 : 0) +
(PathTile.deep(tile) ? -1 : 0) + (PathTile.deep(tile) ? 0 : 1) +
(PathTile.damages(tile) ? 35 : 0) (PathTile.damages(tile) ? 35 : 0)
); );

View File

@@ -757,6 +757,8 @@ public class NetServer implements ApplicationListener{
player.add(); player.add();
Events.fire(new PlayerConnectionConfirmed(player));
if(player.con == null || player.con.hasConnected) return; if(player.con == null || player.con.hasConnected) return;
player.con.hasConnected = true; player.con.hasConnected = true;

View File

@@ -35,7 +35,7 @@ public class Effect{
/** Amount added to rotation */ /** Amount added to rotation */
public float baseRotation; public float baseRotation;
/** If true, parent unit is data are followed. */ /** If true, parent unit is data are followed. */
public boolean followParent; public boolean followParent = true;
/** If this and followParent are true, the effect will offset and rotate with the parent's rotation. */ /** If this and followParent are true, the effect will offset and rotate with the parent's rotation. */
public boolean rotWithParent; public boolean rotWithParent;

View File

@@ -359,8 +359,9 @@ public class BulletType extends Content implements Cloneable{
//home in on allies if possible //home in on allies if possible
if(healPercent > 0){ if(healPercent > 0){
target = Units.closestTarget(null, b.x, b.y, homingRange, target = Units.closestTarget(null, b.x, b.y, homingRange,
e -> e.checkTarget(collidesAir, collidesGround) && e.team != b.team, e -> e.checkTarget(collidesAir, collidesGround) && e.team != b.team && !b.hasCollided(e.id),
t -> collidesGround && (t.team != b.team || t.damaged())); t -> collidesGround && (t.team != b.team || t.damaged()) && !b.hasCollided(t.id)
);
}else{ }else{
target = Units.closestTarget(b.team, b.x, b.y, homingRange, e -> e.checkTarget(collidesAir, collidesGround) && !b.hasCollided(e.id), t -> collidesGround && !b.hasCollided(t.id)); target = Units.closestTarget(b.team, b.x, b.y, homingRange, e -> e.checkTarget(collidesAir, collidesGround) && !b.hasCollided(e.id), t -> collidesGround && !b.hasCollided(t.id));
} }

View File

@@ -1294,6 +1294,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
} }
public void pickedUp(){ public void pickedUp(){
if(power != null){
if(power.graph != null){
power.graph.removeList(self());
power.graph = new PowerGraph();
}
power.links.clear();
power.status = 0f;
}
} }

View File

@@ -480,7 +480,19 @@ public class EventType{
} }
} }
/** Called after connecting; when a player receives world data and is ready to play.*/ /**
* Called after player confirmed it has received world data and is ready to play.
* Note that if this is the first world receival, then player.con.hasConnected is false.
*/
public static class PlayerConnectionConfirmed{
public final Player player;
public PlayerConnectionConfirmed(Player player){
this.player = player;
}
}
/** Called after connecting; when a player receives world data and is ready to play. Fired only once, after initial connection. */
public static class PlayerJoin{ public static class PlayerJoin{
public final Player player; public final Player player;

View File

@@ -62,7 +62,7 @@ public class Layer{
//flying units //flying units
flyingUnit = 115, flyingUnit = 115,
//overlaied UI, like block config guides //overlaid UI, like block config guides
overlayUI = 120, overlayUI = 120,
//build beam effects //build beam effects

View File

@@ -696,9 +696,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}); });
//flip rotation //flip rotation
if(x == (req.rotation % 2 == 0)){ req.block.flipRotation(req, x);
req.rotation = Mathf.mod(req.rotation + 2, 4);
}
}); });
} }
@@ -1113,7 +1111,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
Building build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y); Building build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
if(build instanceof ControlBlock cont && cont.canControl() && build.team == player.team()){ if(build instanceof ControlBlock cont && cont.canControl() && build.team == player.team() && cont.unit() != player.unit()){
return cont.unit(); return cont.unit();
} }

View File

@@ -196,6 +196,18 @@ public class ContentParser{
} }
} }
//try to parse env bits
if((type == int.class || type == Integer.class) && jsonData.isArray()){
int value = 0;
for(var str : jsonData){
if(!str.isString()) throw new SerializationException("Integer bitfield values must all be strings. Found: " + str);
String field = str.asString();
value |= Reflect.<Integer>get(Env.class, field);
}
return (T)(Integer)value;
}
//try to parse "item/amount" syntax //try to parse "item/amount" syntax
if(type == ItemStack.class && jsonData.isString() && jsonData.asString().contains("/")){ if(type == ItemStack.class && jsonData.isString() && jsonData.asString().contains("/")){
String[] split = jsonData.asString().split("/"); String[] split = jsonData.asString().split("/");

View File

@@ -8,6 +8,7 @@ import arc.util.*;
import arc.util.io.*; import arc.util.io.*;
import mindustry.*; import mindustry.*;
import mindustry.core.*; import mindustry.core.*;
import mindustry.mod.Mods.*;
import java.io.*; import java.io.*;
import java.text.*; import java.text.*;
@@ -27,7 +28,7 @@ public class CrashSender{
+ "Version: " + Version.combined() + (Vars.headless ? " (Server)" : "") + "\n" + "Version: " + Version.combined() + (Vars.headless ? " (Server)" : "") + "\n"
+ "OS: " + OS.osName + " x" + (OS.osArchBits) + " (" + OS.osArch + ")\n" + "OS: " + OS.osName + " x" + (OS.osArchBits) + " (" + OS.osArch + ")\n"
+ "Java Version: " + OS.javaVersion + "\n" + "Java Version: " + OS.javaVersion + "\n"
+ (mods == null ? "<no mod init>" : mods.list().size + " Mods" + (mods.list().isEmpty() ? "" : ": " + mods.list().toString(", ", mod -> mod.name + ":" + mod.meta.version))) + (mods == null ? "<no mod init>" : "Mods: " + (!mods.list().contains(LoadedMod::shouldBeEnabled) ? "none (vanilla)" : mods.list().select(LoadedMod::shouldBeEnabled).toString(", ", mod -> mod.name + ":" + mod.meta.version)))
+ "\n\n" + error; + "\n\n" + error;
} }

View File

@@ -152,8 +152,7 @@ public class UnitType extends UnlockableContent{
public TextureRegion[] segmentRegions, segmentOutlineRegions; public TextureRegion[] segmentRegions, segmentOutlineRegions;
protected float buildTime = -1f; protected float buildTime = -1f;
protected @Nullable ItemStack[] cachedRequirements; protected @Nullable ItemStack[] totalRequirements, cachedRequirements, firstRequirements;
protected @Nullable ItemStack[] totalRequirements;
public UnitType(String name){ public UnitType(String name){
super(name); super(name);
@@ -318,6 +317,12 @@ public class UnitType extends UnlockableContent{
stats.add(Stat.payloadCapacity, (payloadCapacity / (tilesize * tilesize)), StatUnit.blocksSquared); stats.add(Stat.payloadCapacity, (payloadCapacity / (tilesize * tilesize)), StatUnit.blocksSquared);
} }
var reqs = getFirstRequirements();
if(reqs != null){
stats.add(Stat.buildCost, StatValues.items(reqs));
}
if(weapons.any()){ if(weapons.any()){
stats.add(Stat.weapons, StatValues.weapons(this, weapons)); stats.add(Stat.weapons, StatValues.weapons(this, weapons));
} }
@@ -565,6 +570,13 @@ public class UnitType extends UnlockableContent{
return null; return null;
} }
public @Nullable ItemStack[] getFirstRequirements(){
if(firstRequirements == null){
firstRequirements = getRequirements(null, null);
}
return firstRequirements;
}
@Override @Override
public ItemStack[] researchRequirements(){ public ItemStack[] researchRequirements(){
if(cachedRequirements != null){ if(cachedRequirements != null){

View File

@@ -31,11 +31,13 @@ public class Menus{
@Remote(targets = Loc.both, called = Loc.both) @Remote(targets = Loc.both, called = Loc.both)
public static void menuChoose(@Nullable Player player, int menuId, int option){ public static void menuChoose(@Nullable Player player, int menuId, int option){
if(player != null && menuId >= 0 && menuId < menuListeners.size){ if(player != null){
Events.fire(new MenuOptionChooseEvent(player, menuId, option)); Events.fire(new MenuOptionChooseEvent(player, menuId, option));
if(menuId >= 0 && menuId < menuListeners.size){
menuListeners.get(menuId).get(player, option); menuListeners.get(menuId).get(player, option);
} }
} }
}
@Remote(variants = Variant.both, unreliable = true) @Remote(variants = Variant.both, unreliable = true)
public static void setHudText(String message){ public static void setHudText(String message){

View File

@@ -989,4 +989,9 @@ public class Block extends UnlockableContent{
packer.add(PageType.editor, name + "-icon-editor", editorBase); packer.add(PageType.editor, name + "-icon-editor", editorBase);
} }
public void flipRotation(BuildPlan req, boolean x){
if(x == (req.rotation % 2 == 0)){
req.rotation = Mathf.mod(req.rotation + 2, 4);
}
}
} }

View File

@@ -122,6 +122,12 @@ public class ForceProjector extends Block{
super.onRemoved(); super.onRemoved();
} }
@Override
public void pickedUp(){
super.pickedUp();
radscl = warmup = 0f;
}
@Override @Override
public void updateTile(){ public void updateTile(){
boolean phaseValid = consumes.get(ConsumeType.item).valid(this); boolean phaseValid = consumes.get(ConsumeType.item).valid(this);

View File

@@ -91,10 +91,11 @@ public class BuildPayload implements Payload{
public void draw(){ public void draw(){
drawShadow(1f); drawShadow(1f);
float prevZ = Draw.z(); float prevZ = Draw.z();
Draw.zTransform(z -> 0.0011f + Mathf.clamp(z, prevZ - 0.001f, prevZ + 0.9f)); Draw.zTransform(z -> z >= Layer.flyingUnitLow ? z : 0.0011f + Mathf.clamp(z, prevZ - 0.001f, prevZ + 0.9f));
build.tile = emptyTile; build.tile = emptyTile;
build.payloadDraw(); build.payloadDraw();
Draw.zTransform(); Draw.zTransform();
Draw.z(prevZ);
} }
@Override @Override