Prevent locked block replacement

This commit is contained in:
Anuken
2019-11-01 19:23:01 -04:00
parent ad23cbc03c
commit 59401ab5f5
3 changed files with 13 additions and 3 deletions

View File

@@ -67,6 +67,11 @@ public abstract class UnlockableContent extends MappableContent{
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(){
return !unlocked();
}

View File

@@ -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. */
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))
.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.*/

View File

@@ -13,8 +13,8 @@ import io.anuke.arc.math.geom.*;
import io.anuke.arc.scene.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.ArcAnnotate.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.effect.*;
@@ -527,7 +527,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
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){