Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions main/src/unity/world/blocks/exp/ExpTurret.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void drawPlace(int x, int y, int rotation, boolean valid){
if(rangeStart != rangeEnd) Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, rangeEnd, UnityPal.exp);
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, rangeStart, Pal.placing);

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

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

//don't bother checking requirements in sandbox or editor
if(!checkPregrade()) return true;

CoreBlock.CoreBuild core = team.core();
//must have all requirements
if(core == null || (!state.rules.infiniteResources && !core.items.has(requirements, state.rules.buildCostMultiplier))) return false;
if(core == null || (!core.items.has(requirements, state.rules.buildCostMultiplier))) return false;

//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.
//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.
seqs.clear();
tile.getLinkedTilesAs(this, inside -> {
if(inside.build == null || seqs.contains(inside.build) || seqs.size > 1) return; //no point of checking if there are already two in seqs
Expand All @@ -207,6 +210,10 @@ public boolean canPlaceOn(Tile tile, Team team, int rotation){
return seqs.size == 1; //no more, no less; a healthy monogamous relationship.
}

public boolean checkPregrade(){
return pregrade != null && !state.rules.infiniteResources && !state.isEditor();
}

@Override
public void placeBegan(Tile tile, Block previous){
//finish placement immediately when a block is replaced.
Expand Down