Fixed cores being replaceable
This commit is contained in:
@@ -1325,7 +1325,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
case powerNetStored -> power == null ? 0 : power.graph.getLastPowerStored();
|
case powerNetStored -> power == null ? 0 : power.graph.getLastPowerStored();
|
||||||
case powerNetCapacity -> power == null ? 0 : power.graph.getLastCapacity();
|
case powerNetCapacity -> power == null ? 0 : power.graph.getLastCapacity();
|
||||||
case enabled -> enabled ? 1 : 0;
|
case enabled -> enabled ? 1 : 0;
|
||||||
case controlled -> this instanceof ControlBlock c && c.isControlled() ? 2 : 0;
|
case controlled -> this instanceof ControlBlock c && c.isControlled() ? GlobalConstants.ctrlPlayer : 0;
|
||||||
case payloadCount -> getPayload() != null ? 1 : 0;
|
case payloadCount -> getPayload() != null ? 1 : 0;
|
||||||
case size -> block.size;
|
case size -> block.size;
|
||||||
default -> Float.NaN; //gets converted to null in logic
|
default -> Float.NaN; //gets converted to null in logic
|
||||||
|
|||||||
@@ -139,7 +139,11 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
case mineX -> mining() ? mineTile.x : -1;
|
case mineX -> mining() ? mineTile.x : -1;
|
||||||
case mineY -> mining() ? mineTile.y : -1;
|
case mineY -> mining() ? mineTile.y : -1;
|
||||||
case flag -> flag;
|
case flag -> flag;
|
||||||
case controlled -> !isValid() ? 0 : controller instanceof LogicAI ? 1 : controller instanceof Player ? 2 : controller instanceof FormationAI ? 3 : 0;
|
case controlled -> !isValid() ? 0 :
|
||||||
|
controller instanceof LogicAI ? GlobalConstants.ctrlProcessor :
|
||||||
|
controller instanceof Player ? GlobalConstants.ctrlPlayer :
|
||||||
|
controller instanceof FormationAI ? GlobalConstants.ctrlFormation :
|
||||||
|
0;
|
||||||
case commanded -> controller instanceof FormationAI && isValid() ? 1 : 0;
|
case commanded -> controller instanceof FormationAI && isValid() ? 1 : 0;
|
||||||
case payloadCount -> self() instanceof Payloadc pay ? pay.payloads().size : 0;
|
case payloadCount -> self() instanceof Payloadc pay ? pay.payloads().size : 0;
|
||||||
case size -> hitSize / tilesize;
|
case size -> hitSize / tilesize;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import mindustry.world.*;
|
|||||||
|
|
||||||
/** Stores global constants for logic processors. */
|
/** Stores global constants for logic processors. */
|
||||||
public class GlobalConstants{
|
public class GlobalConstants{
|
||||||
|
public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlFormation = 3;
|
||||||
|
|
||||||
private ObjectIntMap<String> namesToIds = new ObjectIntMap<>();
|
private ObjectIntMap<String> namesToIds = new ObjectIntMap<>();
|
||||||
private Seq<Var> vars = new Seq<>(Var.class);
|
private Seq<Var> vars = new Seq<>(Var.class);
|
||||||
|
|
||||||
@@ -21,9 +23,9 @@ public class GlobalConstants{
|
|||||||
|
|
||||||
//special enums
|
//special enums
|
||||||
|
|
||||||
put("@ctrlProcessor", 1);
|
put("@ctrlProcessor", ctrlProcessor);
|
||||||
put("@ctrlPlayer", 2);
|
put("@ctrlPlayer", ctrlPlayer);
|
||||||
put("@ctrlFormation", 3);
|
put("@ctrlFormation", ctrlFormation);
|
||||||
|
|
||||||
//store base content
|
//store base content
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ public class Block extends UnlockableContent{
|
|||||||
public boolean fillsTile = true;
|
public boolean fillsTile = true;
|
||||||
/** whether this block can be replaced in all cases */
|
/** whether this block can be replaced in all cases */
|
||||||
public boolean alwaysReplace = false;
|
public boolean alwaysReplace = false;
|
||||||
|
/** if false, this block can never be replaced. */
|
||||||
|
public boolean replaceable = true;
|
||||||
/** The block group. Unless {@link #canReplace} is overriden, blocks in the same group can replace each other. */
|
/** The block group. Unless {@link #canReplace} is overriden, blocks in the same group can replace each other. */
|
||||||
public BlockGroup group = BlockGroup.none;
|
public BlockGroup group = BlockGroup.none;
|
||||||
/** List of block flags. Used for AI indexing. */
|
/** List of block flags. Used for AI indexing. */
|
||||||
@@ -410,7 +412,7 @@ public class Block extends UnlockableContent{
|
|||||||
|
|
||||||
public boolean canReplace(Block other){
|
public boolean canReplace(Block other){
|
||||||
if(other.alwaysReplace) return true;
|
if(other.alwaysReplace) return true;
|
||||||
return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group &&
|
return other.replaceable && (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group &&
|
||||||
(size == other.size || (size >= other.size && ((subclass != null && subclass == other.subclass) || group.anyReplace)));
|
(size == other.size || (size >= other.size && ((subclass != null && subclass == other.subclass) || group.anyReplace)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
loopSoundVolume = 1f;
|
loopSoundVolume = 1f;
|
||||||
drawDisabled = false;
|
drawDisabled = false;
|
||||||
canOverdrive = false;
|
canOverdrive = false;
|
||||||
|
replaceable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(called = Loc.server)
|
@Remote(called = Loc.server)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=e270ac561e10cbc1dc1f13907d75d614e2d51be0
|
archash=1b24d685ea94dd40244be869e70671080e950825
|
||||||
|
|||||||
Reference in New Issue
Block a user