Fixed infinite fire / Command center logic control
This commit is contained in:
@@ -1399,7 +1399,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
return switch(sensor){
|
return switch(sensor){
|
||||||
case type -> block;
|
case type -> block;
|
||||||
case firstItem -> items == null ? null : items.first();
|
case firstItem -> items == null ? null : items.first();
|
||||||
case config -> block.configurations.containsKey(Item.class) || block.configurations.containsKey(Liquid.class) ? config() : null;
|
case config -> block.configSenseable() ? config() : null;
|
||||||
case payloadType -> getPayload() instanceof UnitPayload p1 ? p1.unit.type : getPayload() instanceof BuildPayload p2 ? p2.block() : null;
|
case payloadType -> getPayload() instanceof UnitPayload p1 ? p1.unit.type : getPayload() instanceof BuildPayload p2 ? p2.block() : null;
|
||||||
default -> noSensed;
|
default -> noSensed;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ abstract class FireComp implements Timedc, Posc, Syncc, Drawc{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(time >= lifetime || tile == null){
|
if(time >= lifetime || tile == null || Float.isNaN(lifetime)){
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package mindustry.logic;
|
package mindustry.logic;
|
||||||
|
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
|
import mindustry.entities.units.*;
|
||||||
import mindustry.logic.LExecutor.*;
|
import mindustry.logic.LExecutor.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -55,6 +57,10 @@ public class GlobalConstants{
|
|||||||
for(LAccess sensor : LAccess.all){
|
for(LAccess sensor : LAccess.all){
|
||||||
put("@" + sensor.name(), sensor);
|
put("@" + sensor.name(), sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(UnitCommand cmd : UnitCommand.all){
|
||||||
|
put("@command" + Strings.capitalize(cmd.name()), cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return a constant ID > 0 if there is a constant with this name, otherwise -1. */
|
/** @return a constant ID > 0 if there is a constant with this name, otherwise -1. */
|
||||||
|
|||||||
@@ -922,6 +922,7 @@ public class LExecutor{
|
|||||||
v.objval instanceof Content ? "[content]" :
|
v.objval instanceof Content ? "[content]" :
|
||||||
v.objval instanceof Building build ? build.block.name :
|
v.objval instanceof Building build ? build.block.name :
|
||||||
v.objval instanceof Unit unit ? unit.type.name :
|
v.objval instanceof Unit unit ? unit.type.name :
|
||||||
|
v.objval instanceof Enum<?> e ? e.name() :
|
||||||
"[object]";
|
"[object]";
|
||||||
|
|
||||||
exec.textBuffer.append(strValue);
|
exec.textBuffer.append(strValue);
|
||||||
|
|||||||
@@ -451,6 +451,10 @@ public class Block extends UnlockableContent{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean configSenseable(){
|
||||||
|
return configurations.containsKey(Item.class) || configurations.containsKey(Liquid.class);
|
||||||
|
}
|
||||||
|
|
||||||
public Object nextConfig(){
|
public Object nextConfig(){
|
||||||
if(saveConfig && lastConfig != null){
|
if(saveConfig && lastConfig != null){
|
||||||
return lastConfig;
|
return lastConfig;
|
||||||
|
|||||||
@@ -119,11 +119,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
float result = 0f;
|
float result = 0f;
|
||||||
|
|
||||||
if(block.hasItems){
|
if(block.hasItems){
|
||||||
result += build.items.sum((item, amount) -> item.flammability * amount) / block.itemCapacity * Mathf.clamp(block.itemCapacity / 2.4f, 1f, 3f);
|
result += build.items.sum((item, amount) -> item.flammability * amount) / Math.max(block.itemCapacity, 1) * Mathf.clamp(block.itemCapacity / 2.4f, 1f, 3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block.hasLiquids){
|
if(block.hasLiquids){
|
||||||
result += build.liquids.sum((liquid, amount) -> liquid.flammability * amount / 1.6f) / block.liquidCapacity * Mathf.clamp(block.liquidCapacity / 30f, 1f, 2f);
|
result += build.liquids.sum((liquid, amount) -> liquid.flammability * amount / 1.6f) / Math.max(block.liquidCapacity, 1) * Mathf.clamp(block.liquidCapacity / 30f, 1f, 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import mindustry.world.*;
|
|||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
public class CommandCenter extends Block{
|
public class CommandCenter extends Block{
|
||||||
|
public final int timerEffect = timers ++;
|
||||||
|
|
||||||
public TextureRegionDrawable[] commandRegions = new TextureRegionDrawable[UnitCommand.all.length];
|
public TextureRegionDrawable[] commandRegions = new TextureRegionDrawable[UnitCommand.all.length];
|
||||||
public Color topColor = null, bottomColor = Color.valueOf("5e5e5e");
|
public Color topColor = null, bottomColor = Color.valueOf("5e5e5e");
|
||||||
public Effect effect = Fx.commandSend;
|
public Effect effect = Fx.commandSend;
|
||||||
@@ -33,11 +35,17 @@ public class CommandCenter extends Block{
|
|||||||
solid = true;
|
solid = true;
|
||||||
configurable = true;
|
configurable = true;
|
||||||
drawDisabled = false;
|
drawDisabled = false;
|
||||||
|
logicConfigurable = true;
|
||||||
|
|
||||||
config(UnitCommand.class, (CommandBuild build, UnitCommand command) -> {
|
config(UnitCommand.class, (CommandBuild build, UnitCommand command) -> {
|
||||||
build.team.data().command = command;
|
if(build.team.data().command != command){
|
||||||
effect.at(build, effectSize);
|
build.team.data().command = command;
|
||||||
Events.fire(new CommandIssueEvent(build, command));
|
//do not spam effect
|
||||||
|
if(build.timer(timerEffect, 60f)){
|
||||||
|
effect.at(build, effectSize);
|
||||||
|
}
|
||||||
|
Events.fire(new CommandIssueEvent(build, command));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +60,11 @@ public class CommandCenter extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean configSenseable(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public class CommandBuild extends Building{
|
public class CommandBuild extends Building{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user