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

@@ -54,9 +54,9 @@ public class Pathfinder implements Runnable{
(PathTile.solid(tile) ? 5 : 0),
//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.deep(tile) ? -1 : 0) +
(PathTile.deep(tile) ? 0 : 1) +
(PathTile.damages(tile) ? 35 : 0)
);

View File

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

View File

@@ -35,7 +35,7 @@ public class Effect{
/** Amount added to rotation */
public float baseRotation;
/** 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. */
public boolean rotWithParent;

View File

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

View File

@@ -1294,6 +1294,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
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 final Player player;

View File

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

View File

@@ -696,9 +696,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
});
//flip rotation
if(x == (req.rotation % 2 == 0)){
req.rotation = Mathf.mod(req.rotation + 2, 4);
}
req.block.flipRotation(req, x);
});
}
@@ -1113,7 +1111,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
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();
}

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
if(type == ItemStack.class && jsonData.isString() && jsonData.asString().contains("/")){
String[] split = jsonData.asString().split("/");

View File

@@ -8,6 +8,7 @@ import arc.util.*;
import arc.util.io.*;
import mindustry.*;
import mindustry.core.*;
import mindustry.mod.Mods.*;
import java.io.*;
import java.text.*;
@@ -27,7 +28,7 @@ public class CrashSender{
+ "Version: " + Version.combined() + (Vars.headless ? " (Server)" : "") + "\n"
+ "OS: " + OS.osName + " x" + (OS.osArchBits) + " (" + OS.osArch + ")\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;
}

View File

@@ -152,8 +152,7 @@ public class UnitType extends UnlockableContent{
public TextureRegion[] segmentRegions, segmentOutlineRegions;
protected float buildTime = -1f;
protected @Nullable ItemStack[] cachedRequirements;
protected @Nullable ItemStack[] totalRequirements;
protected @Nullable ItemStack[] totalRequirements, cachedRequirements, firstRequirements;
public UnitType(String name){
super(name);
@@ -318,6 +317,12 @@ public class UnitType extends UnlockableContent{
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()){
stats.add(Stat.weapons, StatValues.weapons(this, weapons));
}
@@ -565,6 +570,13 @@ public class UnitType extends UnlockableContent{
return null;
}
public @Nullable ItemStack[] getFirstRequirements(){
if(firstRequirements == null){
firstRequirements = getRequirements(null, null);
}
return firstRequirements;
}
@Override
public ItemStack[] researchRequirements(){
if(cachedRequirements != null){

View File

@@ -31,9 +31,11 @@ public class Menus{
@Remote(targets = Loc.both, called = Loc.both)
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));
menuListeners.get(menuId).get(player, option);
if(menuId >= 0 && menuId < menuListeners.size){
menuListeners.get(menuId).get(player, option);
}
}
}

View File

@@ -468,7 +468,7 @@ public class Block extends UnlockableContent{
if(hasItems && configurable){
bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items.total()), () -> Pal.items, () -> (float)entity.items.total() / itemCapacity));
}
if(unitCapModifier != 0){
stats.add(Stat.maxUnits, (unitCapModifier < 0 ? "-" : "+") + Math.abs(unitCapModifier));
}
@@ -824,7 +824,7 @@ public class Block extends UnlockableContent{
}
clipSize = Math.max(clipSize, size * tilesize);
//only kept to ensure compatibility with v6 mods.
if(expanded){
clipSize += tilesize * 10f;
@@ -989,4 +989,9 @@ public class Block extends UnlockableContent{
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();
}
@Override
public void pickedUp(){
super.pickedUp();
radscl = warmup = 0f;
}
@Override
public void updateTile(){
boolean phaseValid = consumes.get(ConsumeType.item).valid(this);

View File

@@ -91,10 +91,11 @@ public class BuildPayload implements Payload{
public void draw(){
drawShadow(1f);
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.payloadDraw();
Draw.zTransform();
Draw.z(prevZ);
}
@Override