Balancing / LogicAI sync
This commit is contained in:
@@ -21,6 +21,7 @@ public class LogicAI extends AIController{
|
|||||||
public LUnitControl control = LUnitControl.stop;
|
public LUnitControl control = LUnitControl.stop;
|
||||||
public float moveX, moveY, moveRad;
|
public float moveX, moveY, moveRad;
|
||||||
public float itemTimer, payTimer, controlTimer = logicControlTimeout, targetTimer;
|
public float itemTimer, payTimer, controlTimer = logicControlTimeout, targetTimer;
|
||||||
|
@Nullable
|
||||||
public Building controller;
|
public Building controller;
|
||||||
public BuildPlan plan = new BuildPlan();
|
public BuildPlan plan = new BuildPlan();
|
||||||
|
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ public class Blocks implements ContentList{
|
|||||||
drawer = new DrawAnimation();
|
drawer = new DrawAnimation();
|
||||||
|
|
||||||
consumes.item(Items.sporePod, 1);
|
consumes.item(Items.sporePod, 1);
|
||||||
consumes.power(0.60f);
|
consumes.power(0.7f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
pulverizer = new GenericCrafter("pulverizer"){{
|
pulverizer = new GenericCrafter("pulverizer"){{
|
||||||
@@ -727,7 +727,7 @@ public class Blocks implements ContentList{
|
|||||||
hasPower = hasItems = hasLiquids = true;
|
hasPower = hasItems = hasLiquids = true;
|
||||||
|
|
||||||
consumes.liquid(Liquids.oil, 0.1f);
|
consumes.liquid(Liquids.oil, 0.1f);
|
||||||
consumes.power(0.5f);
|
consumes.power(0.7f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
incinerator = new Incinerator("incinerator"){{
|
incinerator = new Incinerator("incinerator"){{
|
||||||
@@ -1287,7 +1287,7 @@ public class Blocks implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
cultivator = new Cultivator("cultivator"){{
|
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);
|
outputItem = new ItemStack(Items.sporePod, 1);
|
||||||
craftTime = 140;
|
craftTime = 140;
|
||||||
size = 2;
|
size = 2;
|
||||||
@@ -1295,7 +1295,7 @@ public class Blocks implements ContentList{
|
|||||||
hasPower = true;
|
hasPower = true;
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
|
|
||||||
consumes.power(0.80f);
|
consumes.power(0.9f);
|
||||||
consumes.liquid(Liquids.water, 0.2f);
|
consumes.liquid(Liquids.water, 0.2f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class Logic implements ApplicationListener{
|
|||||||
state.rules.waves = true;
|
state.rules.waves = true;
|
||||||
|
|
||||||
//apply fractional damage based on how many turns have passed for this sector
|
//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
|
//TODO sector damage disabled for now
|
||||||
//if(state.rules.sector.hasWaves() && turnsPassed > 0 && state.rules.sector.hasBase()){
|
//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){
|
public static void writeController(Writes write, UnitController control){
|
||||||
//no real unit controller state is written, only the type
|
//no real unit controller state is written, only the type
|
||||||
if(control instanceof Player){
|
if(control instanceof Player p){
|
||||||
write.b(0);
|
write.b(0);
|
||||||
write.i(((Player)control).id);
|
write.i(p.id);
|
||||||
}else if(control instanceof FormationAI){
|
}else if(control instanceof FormationAI form){
|
||||||
write.b(1);
|
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{
|
}else{
|
||||||
write.b(2);
|
write.b(2);
|
||||||
}
|
}
|
||||||
@@ -312,6 +315,19 @@ public class TypeIO{
|
|||||||
}else if(type == 1){ //formation controller
|
}else if(type == 1){ //formation controller
|
||||||
int id = read.i();
|
int id = read.i();
|
||||||
return prev instanceof FormationAI ? prev : new FormationAI(Groups.unit.getByID(id), null);
|
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{
|
}else{
|
||||||
//there are two cases here:
|
//there are two cases here:
|
||||||
//1: prev controller was not a player, carry on
|
//1: prev controller was not a player, carry on
|
||||||
|
|||||||
Reference in New Issue
Block a user