mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 03:08:38 +07:00
Fixed cores being replaceable
This commit is contained in:
parent
b82dca89b3
commit
4690aae197
@ -1325,7 +1325,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
case powerNetStored -> power == null ? 0 : power.graph.getLastPowerStored();
|
||||
case powerNetCapacity -> power == null ? 0 : power.graph.getLastCapacity();
|
||||
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 size -> block.size;
|
||||
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 mineY -> mining() ? mineTile.y : -1;
|
||||
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 payloadCount -> self() instanceof Payloadc pay ? pay.payloads().size : 0;
|
||||
case size -> hitSize / tilesize;
|
||||
|
@ -9,6 +9,8 @@ import mindustry.world.*;
|
||||
|
||||
/** Stores global constants for logic processors. */
|
||||
public class GlobalConstants{
|
||||
public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlFormation = 3;
|
||||
|
||||
private ObjectIntMap<String> namesToIds = new ObjectIntMap<>();
|
||||
private Seq<Var> vars = new Seq<>(Var.class);
|
||||
|
||||
@ -21,9 +23,9 @@ public class GlobalConstants{
|
||||
|
||||
//special enums
|
||||
|
||||
put("@ctrlProcessor", 1);
|
||||
put("@ctrlPlayer", 2);
|
||||
put("@ctrlFormation", 3);
|
||||
put("@ctrlProcessor", ctrlProcessor);
|
||||
put("@ctrlPlayer", ctrlPlayer);
|
||||
put("@ctrlFormation", ctrlFormation);
|
||||
|
||||
//store base content
|
||||
|
||||
|
@ -123,6 +123,8 @@ public class Block extends UnlockableContent{
|
||||
public boolean fillsTile = true;
|
||||
/** whether this block can be replaced in all cases */
|
||||
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. */
|
||||
public BlockGroup group = BlockGroup.none;
|
||||
/** List of block flags. Used for AI indexing. */
|
||||
@ -410,7 +412,7 @@ public class Block extends UnlockableContent{
|
||||
|
||||
public boolean canReplace(Block other){
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ public class CoreBlock extends StorageBlock{
|
||||
loopSoundVolume = 1f;
|
||||
drawDisabled = false;
|
||||
canOverdrive = false;
|
||||
replaceable = false;
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=e270ac561e10cbc1dc1f13907d75d614e2d51be0
|
||||
archash=1b24d685ea94dd40244be869e70671080e950825
|
||||
|
Loading…
Reference in New Issue
Block a user