Prevent locked block replacement
This commit is contained in:
@@ -67,6 +67,11 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
return Vars.data.isUnlocked(this);
|
return Vars.data.isUnlocked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return whether this content is unlocked, or the player is in a custom game. */
|
||||||
|
public final boolean unlockedCur(){
|
||||||
|
return Vars.data.isUnlocked(this) || !Vars.world.isZone();
|
||||||
|
}
|
||||||
|
|
||||||
public final boolean locked(){
|
public final boolean locked(){
|
||||||
return !unlocked();
|
return !unlocked();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ public class Schematics implements Loadable{
|
|||||||
/** Creates an array of build requests from a schematic's data, centered on the provided x+y coordinates. */
|
/** Creates an array of build requests from a schematic's data, centered on the provided x+y coordinates. */
|
||||||
public Array<BuildRequest> toRequests(Schematic schem, int x, int y){
|
public Array<BuildRequest> toRequests(Schematic schem, int x, int y){
|
||||||
return schem.tiles.map(t -> new BuildRequest(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block).original(t.x, t.y, schem.width, schem.height).configure(t.config))
|
return schem.tiles.map(t -> new BuildRequest(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block).original(t.x, t.y, schem.width, schem.height).configure(t.config))
|
||||||
.removeAll(s -> !s.block.isVisible() || (!s.block.unlocked() && world.isZone()));
|
.removeAll(s -> !s.block.isVisible() || !s.block.unlockedCur());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds a schematic to the list, also copying it into the files.*/
|
/** Adds a schematic to the list, also copying it into the files.*/
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import io.anuke.arc.math.geom.*;
|
|||||||
import io.anuke.arc.scene.*;
|
import io.anuke.arc.scene.*;
|
||||||
import io.anuke.arc.scene.event.*;
|
import io.anuke.arc.scene.event.*;
|
||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.util.*;
|
|
||||||
import io.anuke.arc.util.ArcAnnotate.*;
|
import io.anuke.arc.util.ArcAnnotate.*;
|
||||||
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.entities.*;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.entities.effect.*;
|
import io.anuke.mindustry.entities.effect.*;
|
||||||
@@ -527,7 +527,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
lineRequests.add(req);
|
lineRequests.add(req);
|
||||||
});
|
});
|
||||||
|
|
||||||
lineRequests.each(req -> req.block = req.block.getReplacement(req, lineRequests));
|
lineRequests.each(req -> {
|
||||||
|
Block replace = req.block.getReplacement(req, lineRequests);
|
||||||
|
if(replace.unlockedCur()){
|
||||||
|
req.block = replace;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateLine(int x1, int y1){
|
protected void updateLine(int x1, int y1){
|
||||||
|
|||||||
Reference in New Issue
Block a user