mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-27 16:09:57 +07:00
Fixed infinite fire / Command center logic control
This commit is contained in:
parent
d0da46e715
commit
ade313fc1b
@ -1399,7 +1399,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return switch(sensor){
|
||||
case type -> block;
|
||||
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;
|
||||
default -> noSensed;
|
||||
};
|
||||
|
@ -56,7 +56,7 @@ abstract class FireComp implements Timedc, Posc, Syncc, Drawc{
|
||||
return;
|
||||
}
|
||||
|
||||
if(time >= lifetime || tile == null){
|
||||
if(time >= lifetime || tile == null || Float.isNaN(lifetime)){
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package mindustry.logic;
|
||||
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.logic.LExecutor.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@ -55,6 +57,10 @@ public class GlobalConstants{
|
||||
for(LAccess sensor : LAccess.all){
|
||||
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. */
|
||||
|
@ -922,6 +922,7 @@ public class LExecutor{
|
||||
v.objval instanceof Content ? "[content]" :
|
||||
v.objval instanceof Building build ? build.block.name :
|
||||
v.objval instanceof Unit unit ? unit.type.name :
|
||||
v.objval instanceof Enum<?> e ? e.name() :
|
||||
"[object]";
|
||||
|
||||
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(){
|
||||
if(saveConfig && lastConfig != null){
|
||||
return lastConfig;
|
||||
|
@ -119,11 +119,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
float result = 0f;
|
||||
|
||||
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){
|
||||
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;
|
||||
|
@ -20,6 +20,8 @@ import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class CommandCenter extends Block{
|
||||
public final int timerEffect = timers ++;
|
||||
|
||||
public TextureRegionDrawable[] commandRegions = new TextureRegionDrawable[UnitCommand.all.length];
|
||||
public Color topColor = null, bottomColor = Color.valueOf("5e5e5e");
|
||||
public Effect effect = Fx.commandSend;
|
||||
@ -33,11 +35,17 @@ public class CommandCenter extends Block{
|
||||
solid = true;
|
||||
configurable = true;
|
||||
drawDisabled = false;
|
||||
logicConfigurable = true;
|
||||
|
||||
config(UnitCommand.class, (CommandBuild build, UnitCommand command) -> {
|
||||
build.team.data().command = command;
|
||||
effect.at(build, effectSize);
|
||||
Events.fire(new CommandIssueEvent(build, command));
|
||||
if(build.team.data().command != command){
|
||||
build.team.data().command = 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{
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user