This commit is contained in:
Anuken
2020-08-16 23:30:49 -04:00
parent 91c1c004c7
commit 0fe8836db4
7 changed files with 31 additions and 21 deletions

View File

@@ -1,7 +1,5 @@
package mindustry.ai.types; package mindustry.ai.types;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*; import mindustry.content.*;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
@@ -11,9 +9,6 @@ import mindustry.world.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class MinerAI extends AIController{ public class MinerAI extends AIController{
//miners are limited to copper and lead until further notice
Seq<Item> targets = Seq.with(Items.copper, Items.lead);
boolean mining = true; boolean mining = true;
Item targetItem; Item targetItem;
Tile ore; Tile ore;
@@ -39,7 +34,7 @@ public class MinerAI extends AIController{
} }
if(mining){ if(mining){
targetItem = Structs.findMin(targets, indexer::hasOre, Structs.comparingInt(i -> -core.items.get(i))); targetItem = unit.team.data().mineItems.min(i -> indexer.hasOre(i) && miner.canMine(i), i -> core.items.get(i));
//core full of the target item, do nothing //core full of the target item, do nothing
if(targetItem != null && core.acceptStack(targetItem, 1, unit) == 0){ if(targetItem != null && core.acceptStack(targetItem, 1, unit) == 0){

View File

@@ -68,6 +68,8 @@ public class PhysicsProcess implements AsyncProcess{
PhysicRef ref = entity.physref(); PhysicRef ref = entity.physref();
if(ref.wasGround != grounded){ if(ref.wasGround != grounded){
if(ref.body.getFixtureList().isEmpty()) continue;
//set correct filter //set correct filter
ref.body.getFixtureList().first().setFilterData(grounded ? ground : flying); ref.body.getFixtureList().first().setFilterData(grounded ? ground : flying);
ref.wasGround = grounded; ref.wasGround = grounded;

View File

@@ -139,7 +139,7 @@ public class Blocks implements ContentList{
speedMultiplier = 0.2f; speedMultiplier = 0.2f;
variants = 0; variants = 0;
liquidDrop = Liquids.water; liquidDrop = Liquids.water;
liquidMultiplier = 2f; liquidMultiplier = 1.5f;
isLiquid = true; isLiquid = true;
status = StatusEffects.wet; status = StatusEffects.wet;
statusDuration = 120f; statusDuration = 120f;

View File

@@ -5,8 +5,10 @@ import arc.math.geom.*;
import arc.struct.*; import arc.struct.*;
import arc.util.ArcAnnotate.*; import arc.util.ArcAnnotate.*;
import mindustry.ai.*; import mindustry.ai.*;
import mindustry.content.*;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.blocks.storage.CoreBlock.*; import mindustry.world.blocks.storage.CoreBlock.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@@ -153,6 +155,8 @@ public class Teams{
public Queue<BlockPlan> blocks = new Queue<>(); public Queue<BlockPlan> blocks = new Queue<>();
/** The current command for units to follow. */ /** The current command for units to follow. */
public UnitCommand command = UnitCommand.attack; 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){ public TeamData(Team team){
this.team = team; this.team = team;

View File

@@ -626,7 +626,7 @@ public class DesktopInput extends InputHandler{
}else if(!pay.hasPayload()){ }else if(!pay.hasPayload()){
Building tile = world.buildWorld(pay.x(), pay.y()); Building tile = world.buildWorld(pay.x(), pay.y());
if(tile != null && tile.team() == unit.team){ if(tile != null && tile.team == unit.team){
Call.pickupBlockPayload(player, tile); Call.pickupBlockPayload(player, tile);
} }
} }

View File

@@ -83,22 +83,29 @@ public class LAssembler{
if(index++ > max) break; if(index++ > max) break;
try{ try{
//yes, I am aware that this can be split with regex, but that's slow and even more incomprehensible String[] arr;
Seq<String> tokens = new Seq<>();
boolean inString = false;
int lastIdx = 0;
for(int i = 0; i < line.length() + 1; i++){ //yes, I am aware that this can be split with regex, but that's slow and even more incomprehensible
char c = i == line.length() ? ' ' : line.charAt(i); if(line.contains(" ")){
if(c == '"'){ Seq<String> tokens = new Seq<>();
inString = !inString; boolean inString = false;
}else if(c == ' ' && !inString){ int lastIdx = 0;
tokens.add(line.substring(lastIdx, i).replace("\\n", "\n"));
lastIdx = i + 1; for(int i = 0; i < line.length() + 1; i++){
char c = i == line.length() ? ' ' : line.charAt(i);
if(c == '"'){
inString = !inString;
}else if(c == ' ' && !inString){
tokens.add(line.substring(lastIdx, i).replace("\\n", "\n"));
lastIdx = i + 1;
}
} }
arr = tokens.toArray(String.class);
}else{
arr = new String[]{line};
} }
String[] arr = tokens.toArray(String.class);
LStatement st = LogicIO.read(arr); LStatement st = LogicIO.read(arr);
if(st != null){ if(st != null){
statements.add(st); statements.add(st);

View File

@@ -310,9 +310,11 @@ public class UnitType extends UnlockableContent{
if(abilities.size > 0){ if(abilities.size > 0){
for(Ability a : abilities){ for(Ability a : abilities){
a.draw(unit);
Draw.reset(); Draw.reset();
a.draw(unit);
} }
Draw.reset();
} }
} }