mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-25 15:18:24 +07:00
Bugfixes
This commit is contained in:
@ -39,7 +39,7 @@ public class Weathers implements ContentList{
|
|||||||
minAlpha = 0f;
|
minAlpha = 0f;
|
||||||
maxAlpha = 0.2f;
|
maxAlpha = 0.2f;
|
||||||
density = 1500f;
|
density = 1500f;
|
||||||
baseSpeed = 6.1f;
|
baseSpeed = 5.4f;
|
||||||
attrs.set(Attribute.light, -0.1f);
|
attrs.set(Attribute.light, -0.1f);
|
||||||
attrs.set(Attribute.water, -0.1f);
|
attrs.set(Attribute.water, -0.1f);
|
||||||
opacityMultiplier = 0.8f;
|
opacityMultiplier = 0.8f;
|
||||||
|
@ -1319,7 +1319,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void control(LAccess type, Object p1, double p2, double p3, double p4){
|
public void control(LAccess type, Object p1, double p2, double p3, double p4){
|
||||||
|
if(type == LAccess.configure && block.logicConfigurable){
|
||||||
|
//change config only if it's new
|
||||||
|
Object prev = senseObject(LAccess.config);
|
||||||
|
if(prev != p1){
|
||||||
|
configureAny(p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,12 +38,15 @@ public enum LAccess{
|
|||||||
//values with parameters are considered controllable
|
//values with parameters are considered controllable
|
||||||
enabled("to"), //"to" is standard for single parameter access
|
enabled("to"), //"to" is standard for single parameter access
|
||||||
shoot("x", "y", "shoot"),
|
shoot("x", "y", "shoot"),
|
||||||
shootp(true, "unit", "shoot")
|
shootp(true, "unit", "shoot"),
|
||||||
|
configure(true, 30, "to")
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
public final String[] params;
|
public final String[] params;
|
||||||
public final boolean isObj;
|
public final boolean isObj;
|
||||||
|
/** Tick cooldown between invocations. */
|
||||||
|
public float cooldown = -1;
|
||||||
|
|
||||||
public static final LAccess[]
|
public static final LAccess[]
|
||||||
all = values(),
|
all = values(),
|
||||||
@ -59,4 +62,10 @@ public enum LAccess{
|
|||||||
this.params = params;
|
this.params = params;
|
||||||
isObj = obj;
|
isObj = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LAccess(boolean obj, float cooldown, String... params){
|
||||||
|
this.params = params;
|
||||||
|
this.cooldown = cooldown;
|
||||||
|
isObj = obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,14 +292,15 @@ public class LExecutor{
|
|||||||
/** Controls the unit based on some parameters. */
|
/** Controls the unit based on some parameters. */
|
||||||
public static class UnitControlI implements LInstruction{
|
public static class UnitControlI implements LInstruction{
|
||||||
public LUnitControl type = LUnitControl.move;
|
public LUnitControl type = LUnitControl.move;
|
||||||
public int p1, p2, p3, p4;
|
public int p1, p2, p3, p4, p5;
|
||||||
|
|
||||||
public UnitControlI(LUnitControl type, int p1, int p2, int p3, int p4){
|
public UnitControlI(LUnitControl type, int p1, int p2, int p3, int p4, int p5){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.p1 = p1;
|
this.p1 = p1;
|
||||||
this.p2 = p2;
|
this.p2 = p2;
|
||||||
this.p3 = p3;
|
this.p3 = p3;
|
||||||
this.p4 = p4;
|
this.p4 = p4;
|
||||||
|
this.p5 = p5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitControlI(){
|
public UnitControlI(){
|
||||||
@ -437,7 +438,7 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ai.plan.set(x, y, rot, block);
|
ai.plan.set(x, y, rot, block);
|
||||||
ai.plan.config = null;
|
ai.plan.config = exec.obj(p5) instanceof Content c ? c : null;
|
||||||
|
|
||||||
builder.clearBuilding();
|
builder.clearBuilding();
|
||||||
|
|
||||||
@ -500,6 +501,7 @@ public class LExecutor{
|
|||||||
public int target;
|
public int target;
|
||||||
public LAccess type = LAccess.enabled;
|
public LAccess type = LAccess.enabled;
|
||||||
public int p1, p2, p3, p4;
|
public int p1, p2, p3, p4;
|
||||||
|
public Interval timer = new Interval(1);
|
||||||
|
|
||||||
public ControlI(LAccess type, int target, int p1, int p2, int p3, int p4){
|
public ControlI(LAccess type, int target, int p1, int p2, int p3, int p4){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -515,7 +517,7 @@ public class LExecutor{
|
|||||||
@Override
|
@Override
|
||||||
public void run(LExecutor exec){
|
public void run(LExecutor exec){
|
||||||
Object obj = exec.obj(target);
|
Object obj = exec.obj(target);
|
||||||
if(obj instanceof Building b && b.team == exec.team && exec.linkIds.contains(b.id)){
|
if(obj instanceof Building b && b.team == exec.team && exec.linkIds.contains(b.id) && (type.cooldown <= 0 || timer.get(type.cooldown))){
|
||||||
if(type.isObj){
|
if(type.isObj){
|
||||||
b.control(type, exec.obj(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
b.control(type, exec.obj(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||||
}else{
|
}else{
|
||||||
|
@ -748,7 +748,7 @@ public class LStatements{
|
|||||||
@RegisterStatement("ucontrol")
|
@RegisterStatement("ucontrol")
|
||||||
public static class UnitControlStatement extends LStatement{
|
public static class UnitControlStatement extends LStatement{
|
||||||
public LUnitControl type = LUnitControl.move;
|
public LUnitControl type = LUnitControl.move;
|
||||||
public String p1 = "0", p2 = "0", p3 = "0", p4 = "0";
|
public String p1 = "0", p2 = "0", p3 = "0", p4 = "0", p5 = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table){
|
public void build(Table table){
|
||||||
@ -777,7 +777,7 @@ public class LStatements{
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
for(int i = 0; i < type.params.length; i++){
|
for(int i = 0; i < type.params.length; i++){
|
||||||
|
|
||||||
fields(table, type.params[i], i == 0 ? p1 : i == 1 ? p2 : i == 2 ? p3 : p4, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : i == 2 ? v -> p3 = v : v -> p4 = v).width(110f);
|
fields(table, type.params[i], i == 0 ? p1 : i == 1 ? p2 : i == 2 ? p3 : p4, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : i == 2 ? v -> p3 = v : i == 3 ? v -> p4 = v : v -> p5 = v).width(110f);
|
||||||
|
|
||||||
if(++c % 2 == 0) row(table);
|
if(++c % 2 == 0) row(table);
|
||||||
}
|
}
|
||||||
@ -790,7 +790,7 @@ public class LStatements{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LInstruction build(LAssembler builder){
|
public LInstruction build(LAssembler builder){
|
||||||
return new UnitControlI(type, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4));
|
return new UnitControlI(type, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4), builder.var(p5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,7 +861,7 @@ public class LStatements{
|
|||||||
table.table(ts -> {
|
table.table(ts -> {
|
||||||
ts.color.set(table.color);
|
ts.color.set(table.color);
|
||||||
|
|
||||||
field(ts, ore, str -> ore = str);
|
fields(ts, ore, str -> ore = str);
|
||||||
|
|
||||||
ts.button(b -> {
|
ts.button(b -> {
|
||||||
b.image(Icon.pencilSmall);
|
b.image(Icon.pencilSmall);
|
||||||
@ -905,8 +905,10 @@ public class LStatements{
|
|||||||
table.add(" found ").left();
|
table.add(" found ").left();
|
||||||
fields(table, outFound, str -> outFound = str);
|
fields(table, outFound, str -> outFound = str);
|
||||||
|
|
||||||
table.add(" building ").left();
|
if(locate != LLocate.ore){
|
||||||
fields(table, outBuild, str -> outBuild = str);
|
table.add(" building ").left();
|
||||||
|
fields(table, outBuild, str -> outBuild = str);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public enum LUnitControl{
|
|||||||
payTake("takeUnits"),
|
payTake("takeUnits"),
|
||||||
mine("x", "y"),
|
mine("x", "y"),
|
||||||
flag("value"),
|
flag("value"),
|
||||||
build("x", "y", "block", "rotation"),
|
build("x", "y", "block", "rotation", "config"),
|
||||||
getBlock("x", "y", "type", "building"),
|
getBlock("x", "y", "type", "building"),
|
||||||
within("x", "y", "radius", "result");
|
within("x", "y", "radius", "result");
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public abstract class GenerateFilter{
|
|||||||
apply();
|
apply();
|
||||||
|
|
||||||
tile.setFloor(in.floor.asFloor());
|
tile.setFloor(in.floor.asFloor());
|
||||||
tile.setOverlay(!in.floor.asFloor().hasSurface() ? Blocks.air : in.overlay);
|
tile.setOverlay(!in.floor.asFloor().hasSurface() && in.overlay.asFloor().needsSurface ? Blocks.air : in.overlay);
|
||||||
|
|
||||||
if(!tile.block().synthetic() && !in.block.synthetic()){
|
if(!tile.block().synthetic() && !in.block.synthetic()){
|
||||||
tile.setBlock(in.block);
|
tile.setBlock(in.block);
|
||||||
@ -49,7 +49,7 @@ public abstract class GenerateFilter{
|
|||||||
apply();
|
apply();
|
||||||
|
|
||||||
tile.setFloor(in.floor.asFloor());
|
tile.setFloor(in.floor.asFloor());
|
||||||
tile.setOverlay(!in.floor.asFloor().hasSurface() ? Blocks.air : in.overlay);
|
tile.setOverlay(!in.floor.asFloor().hasSurface() && in.overlay.asFloor().needsSurface ? Blocks.air : in.overlay);
|
||||||
|
|
||||||
if(!tile.block().synthetic() && !in.block.synthetic()){
|
if(!tile.block().synthetic() && !in.block.synthetic()){
|
||||||
tile.setBlock(in.block);
|
tile.setBlock(in.block);
|
||||||
|
@ -74,7 +74,7 @@ public class ParticleWeather extends Weather{
|
|||||||
float sspeed = 1f, sscl = 1f, salpha = 1f, offset = 0f;
|
float sspeed = 1f, sscl = 1f, salpha = 1f, offset = 0f;
|
||||||
Color col = Tmp.c1.set(noiseColor);
|
Color col = Tmp.c1.set(noiseColor);
|
||||||
for(int i = 0; i < noiseLayers; i++){
|
for(int i = 0; i < noiseLayers; i++){
|
||||||
drawNoise(noise, noiseColor, noiseScale * sscl, state.opacity * salpha * opacityMultiplier, baseSpeed * sspeed, state.intensity, windx, windy, offset);
|
drawNoise(noise, noiseColor, noiseScale * sscl, state.opacity * salpha * opacityMultiplier, sspeed * (useWindVector ? 1f : baseSpeed), state.intensity, windx, windy, offset);
|
||||||
sspeed *= noiseLayerSpeedM;
|
sspeed *= noiseLayerSpeedM;
|
||||||
salpha *= noiseLayerAlphaM;
|
salpha *= noiseLayerAlphaM;
|
||||||
sscl *= noiseLayerSclM;
|
sscl *= noiseLayerSclM;
|
||||||
|
@ -133,6 +133,8 @@ public class Block extends UnlockableContent{
|
|||||||
public int unitCapModifier = 0;
|
public int unitCapModifier = 0;
|
||||||
/** Whether the block can be tapped and selected to configure. */
|
/** Whether the block can be tapped and selected to configure. */
|
||||||
public boolean configurable;
|
public boolean configurable;
|
||||||
|
/** If true, this block can be configured by logic. */
|
||||||
|
public boolean logicConfigurable = false;
|
||||||
/** Whether this block consumes touchDown events when tapped. */
|
/** Whether this block consumes touchDown events when tapped. */
|
||||||
public boolean consumesTap;
|
public boolean consumesTap;
|
||||||
/** Whether to draw the glow of the liquid for this block, if it has one. */
|
/** Whether to draw the glow of the liquid for this block, if it has one. */
|
||||||
@ -674,6 +676,14 @@ public class Block extends UnlockableContent{
|
|||||||
|
|
||||||
consumes.init();
|
consumes.init();
|
||||||
|
|
||||||
|
if(!logicConfigurable){
|
||||||
|
configurations.each((key, val) -> {
|
||||||
|
if(UnlockableContent.class.isAssignableFrom(key)){
|
||||||
|
logicConfigurable = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(!outputsPower && consumes.hasPower() && consumes.getPower().buffered){
|
if(!outputsPower && consumes.hasPower() && consumes.getPower().buffered){
|
||||||
throw new IllegalArgumentException("Consumer using buffered power: " + name);
|
throw new IllegalArgumentException("Consumer using buffered power: " + name);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,6 @@ public class UnitFactory extends UnitBlock{
|
|||||||
hasPower = true;
|
hasPower = true;
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
//flags = EnumSet.of(BlockFlag.producer, BlockFlag.unitModifier);
|
|
||||||
//unitCapModifier = 2;
|
|
||||||
configurable = true;
|
configurable = true;
|
||||||
outputsPayload = true;
|
outputsPayload = true;
|
||||||
rotate = true;
|
rotate = true;
|
||||||
@ -44,6 +42,11 @@ public class UnitFactory extends UnitBlock{
|
|||||||
tile.progress = 0;
|
tile.progress = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
config(UnitType.class, (UnitFactoryBuild tile, UnitType val) -> {
|
||||||
|
tile.currentPlan = plans.indexOf(p -> p.unit == val);
|
||||||
|
tile.progress = 0;
|
||||||
|
});
|
||||||
|
|
||||||
consumes.add(new ConsumeItemDynamic((UnitFactoryBuild e) -> e.currentPlan != -1 ? plans.get(e.currentPlan).requirements : ItemStack.empty));
|
consumes.add(new ConsumeItemDynamic((UnitFactoryBuild e) -> e.currentPlan != -1 ? plans.get(e.currentPlan).requirements : ItemStack.empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user