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;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
@@ -11,9 +9,6 @@ import mindustry.world.*;
import static mindustry.Vars.*;
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;
Item targetItem;
Tile ore;
@@ -39,7 +34,7 @@ public class MinerAI extends AIController{
}
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
if(targetItem != null && core.acceptStack(targetItem, 1, unit) == 0){

View File

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

View File

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

View File

@@ -5,8 +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.*;
@@ -153,6 +155,8 @@ public class Teams{
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;

View File

@@ -626,7 +626,7 @@ public class DesktopInput extends InputHandler{
}else if(!pay.hasPayload()){
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);
}
}

View File

@@ -83,22 +83,29 @@ public class LAssembler{
if(index++ > max) break;
try{
//yes, I am aware that this can be split with regex, but that's slow and even more incomprehensible
Seq<String> tokens = new Seq<>();
boolean inString = false;
int lastIdx = 0;
String[] arr;
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;
//yes, I am aware that this can be split with regex, but that's slow and even more incomprehensible
if(line.contains(" ")){
Seq<String> tokens = new Seq<>();
boolean inString = false;
int lastIdx = 0;
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);
if(st != null){
statements.add(st);

View File

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