Skip to content

Commit 5d3dfd9

Browse files
authored
Placing Exp Turrets in sandbox/editor (#74)
1 parent 2335c1f commit 5d3dfd9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

main/src/unity/world/blocks/exp/ExpTurret.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void drawPlace(int x, int y, int rotation, boolean valid){
181181
if(rangeStart != rangeEnd) Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, rangeEnd, UnityPal.exp);
182182
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, rangeStart, Pal.placing);
183183

184-
if(!valid && pregrade != null) drawPlaceText(Core.bundle.format("exp.pregrade", pregradeLevel, pregrade.localizedName), x, y, false);
184+
if(!valid && checkPregrade()) drawPlaceText(Core.bundle.format("exp.pregrade", pregradeLevel, pregrade.localizedName), x, y, false);
185185
}
186186

187187
@Override
@@ -194,11 +194,14 @@ public boolean canPlaceOn(Tile tile, Team team, int rotation){
194194
if(tile == null) return false;
195195
if(pregrade == null) return super.canPlaceOn(tile, team, rotation);
196196

197+
//don't bother checking requirements in sandbox or editor
198+
if(!checkPregrade()) return true;
199+
197200
CoreBlock.CoreBuild core = team.core();
198201
//must have all requirements
199-
if(core == null || (!state.rules.infiniteResources && !core.items.has(requirements, state.rules.buildCostMultiplier))) return false;
202+
if(core == null || (!core.items.has(requirements, state.rules.buildCostMultiplier))) return false;
200203

201-
//check is there is ONLY a single pregrade block INSIDE all the tiles it will replace - by tracking SEQS. This protocol is also known as UWAGH standard.
204+
//check is there is ONLY a single pregrade block INSIDE all the tiles it will replace - by tracking SEGGS. This protocol is also known as UWAGH standard.
202205
seqs.clear();
203206
tile.getLinkedTilesAs(this, inside -> {
204207
if(inside.build == null || seqs.contains(inside.build) || seqs.size > 1) return; //no point of checking if there are already two in seqs
@@ -207,6 +210,10 @@ public boolean canPlaceOn(Tile tile, Team team, int rotation){
207210
return seqs.size == 1; //no more, no less; a healthy monogamous relationship.
208211
}
209212

213+
public boolean checkPregrade(){
214+
return pregrade != null && !state.rules.infiniteResources && !state.isEditor();
215+
}
216+
210217
@Override
211218
public void placeBegan(Tile tile, Block previous){
212219
//finish placement immediately when a block is replaced.

0 commit comments

Comments
 (0)