mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 06:51:30 -08:00
Balancing / LogicAI sync
This commit is contained in:
parent
ad2bda8ec1
commit
af54de894c
4 changed files with 26 additions and 9 deletions
|
|
@ -21,6 +21,7 @@ public class LogicAI extends AIController{
|
|||
public LUnitControl control = LUnitControl.stop;
|
||||
public float moveX, moveY, moveRad;
|
||||
public float itemTimer, payTimer, controlTimer = logicControlTimeout, targetTimer;
|
||||
@Nullable
|
||||
public Building controller;
|
||||
public BuildPlan plan = new BuildPlan();
|
||||
|
||||
|
|
|
|||
|
|
@ -702,7 +702,7 @@ public class Blocks implements ContentList{
|
|||
drawer = new DrawAnimation();
|
||||
|
||||
consumes.item(Items.sporePod, 1);
|
||||
consumes.power(0.60f);
|
||||
consumes.power(0.7f);
|
||||
}};
|
||||
|
||||
pulverizer = new GenericCrafter("pulverizer"){{
|
||||
|
|
@ -727,7 +727,7 @@ public class Blocks implements ContentList{
|
|||
hasPower = hasItems = hasLiquids = true;
|
||||
|
||||
consumes.liquid(Liquids.oil, 0.1f);
|
||||
consumes.power(0.5f);
|
||||
consumes.power(0.7f);
|
||||
}};
|
||||
|
||||
incinerator = new Incinerator("incinerator"){{
|
||||
|
|
@ -1287,7 +1287,7 @@ public class Blocks implements ContentList{
|
|||
}};
|
||||
|
||||
cultivator = new Cultivator("cultivator"){{
|
||||
requirements(Category.production, with(Items.copper, 10, Items.lead, 25, Items.silicon, 10));
|
||||
requirements(Category.production, with(Items.copper, 25, Items.lead, 25, Items.silicon, 10));
|
||||
outputItem = new ItemStack(Items.sporePod, 1);
|
||||
craftTime = 140;
|
||||
size = 2;
|
||||
|
|
@ -1295,7 +1295,7 @@ public class Blocks implements ContentList{
|
|||
hasPower = true;
|
||||
hasItems = true;
|
||||
|
||||
consumes.power(0.80f);
|
||||
consumes.power(0.9f);
|
||||
consumes.liquid(Liquids.water, 0.2f);
|
||||
}};
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class Logic implements ApplicationListener{
|
|||
state.rules.waves = true;
|
||||
|
||||
//apply fractional damage based on how many turns have passed for this sector
|
||||
float turnsPassed = seconds / (turnDuration / 60f);
|
||||
//float turnsPassed = seconds / (turnDuration / 60f);
|
||||
|
||||
//TODO sector damage disabled for now
|
||||
//if(state.rules.sector.hasWaves() && turnsPassed > 0 && state.rules.sector.hasBase()){
|
||||
|
|
|
|||
|
|
@ -290,12 +290,15 @@ public class TypeIO{
|
|||
|
||||
public static void writeController(Writes write, UnitController control){
|
||||
//no real unit controller state is written, only the type
|
||||
if(control instanceof Player){
|
||||
if(control instanceof Player p){
|
||||
write.b(0);
|
||||
write.i(((Player)control).id);
|
||||
}else if(control instanceof FormationAI){
|
||||
write.i(p.id);
|
||||
}else if(control instanceof FormationAI form){
|
||||
write.b(1);
|
||||
write.i(((FormationAI)control).leader.id);
|
||||
write.i(form.leader.id);
|
||||
}else if(control instanceof LogicAI logic && logic.controller != null){
|
||||
write.b(3);
|
||||
write.i(logic.controller.pos());
|
||||
}else{
|
||||
write.b(2);
|
||||
}
|
||||
|
|
@ -312,6 +315,19 @@ public class TypeIO{
|
|||
}else if(type == 1){ //formation controller
|
||||
int id = read.i();
|
||||
return prev instanceof FormationAI ? prev : new FormationAI(Groups.unit.getByID(id), null);
|
||||
}else if(type == 3){
|
||||
int pos = read.i();
|
||||
if(prev instanceof LogicAI pai){
|
||||
pai.controller = world.build(pos);
|
||||
return pai;
|
||||
}else{
|
||||
//create new AI for assignment
|
||||
LogicAI out = new LogicAI();
|
||||
//instantly time out when updated.
|
||||
out.controlTimer = LogicAI.logicControlTimeout;
|
||||
out.controller = world.build(pos);
|
||||
return out;
|
||||
}
|
||||
}else{
|
||||
//there are two cases here:
|
||||
//1: prev controller was not a player, carry on
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue