Build beginPlace+Break access tracking / Instant rotation
This commit is contained in:
@@ -81,12 +81,12 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
|
|||||||
boolean hasAll = infinite || !Structs.contains(current.block.requirements, i -> core != null && !core.items.has(i.item));
|
boolean hasAll = infinite || !Structs.contains(current.block.requirements, i -> core != null && !core.items.has(i.item));
|
||||||
|
|
||||||
if(hasAll){
|
if(hasAll){
|
||||||
Call.beginPlace(current.block, team, current.x, current.y, current.rotation);
|
Call.beginPlace(self(), current.block, team, current.x, current.y, current.rotation);
|
||||||
}else{
|
}else{
|
||||||
current.stuck = true;
|
current.stuck = true;
|
||||||
}
|
}
|
||||||
}else if(!current.initialized && current.breaking && Build.validBreak(team, current.x, current.y)){
|
}else if(!current.initialized && current.breaking && Build.validBreak(team, current.x, current.y)){
|
||||||
Call.beginBreak(team, current.x, current.y);
|
Call.beginBreak(self(), team, current.x, current.y);
|
||||||
}else{
|
}else{
|
||||||
plans.removeFirst();
|
plans.removeFirst();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Build{
|
|||||||
private static final IntSet tmp = new IntSet();
|
private static final IntSet tmp = new IntSet();
|
||||||
|
|
||||||
@Remote(called = Loc.server)
|
@Remote(called = Loc.server)
|
||||||
public static void beginBreak(Team team, int x, int y){
|
public static void beginBreak(@Nullable Unit unit, Team team, int x, int y){
|
||||||
if(!validBreak(team, x, y)){
|
if(!validBreak(team, x, y)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -40,14 +40,14 @@ public class Build{
|
|||||||
tile.setBlock(sub, team, rotation);
|
tile.setBlock(sub, team, rotation);
|
||||||
tile.<ConstructBuild>bc().setDeconstruct(previous);
|
tile.<ConstructBuild>bc().setDeconstruct(previous);
|
||||||
tile.build.health = tile.build.maxHealth * prevPercent;
|
tile.build.health = tile.build.maxHealth * prevPercent;
|
||||||
|
if(unit != null && unit.isPlayer()) tile.build.lastAccessed = unit.getPlayer().name;
|
||||||
|
|
||||||
Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, true)));
|
Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Places a ConstructBlock at this location. */
|
/** Places a ConstructBlock at this location. */
|
||||||
@Remote(called = Loc.server)
|
@Remote(called = Loc.server)
|
||||||
public static void beginPlace(Block result, Team team, int x, int y, int rotation){
|
public static void beginPlace(@Nullable Unit unit, Block result, Team team, int x, int y, int rotation){
|
||||||
if(!validPlace(result, team, x, y, rotation)){
|
if(!validPlace(result, team, x, y, rotation)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,15 @@ public class Build{
|
|||||||
//just in case
|
//just in case
|
||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
|
|
||||||
|
//auto-rotate the block to the correct orientation and bail out
|
||||||
|
if(tile.team() == team && tile.block == result && tile.build != null){
|
||||||
|
if(unit != null && unit.isPlayer()) tile.build.lastAccessed = unit.getPlayer().name;
|
||||||
|
tile.build.rotation = Mathf.mod(rotation, 4);
|
||||||
|
tile.build.updateProximity();
|
||||||
|
tile.build.noSleep();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Block previous = tile.block();
|
Block previous = tile.block();
|
||||||
Block sub = ConstructBlock.get(result.size);
|
Block sub = ConstructBlock.get(result.size);
|
||||||
Seq<Building> prevBuild = new Seq<>(9);
|
Seq<Building> prevBuild = new Seq<>(9);
|
||||||
@@ -76,6 +85,7 @@ public class Build{
|
|||||||
|
|
||||||
build.setConstruct(previous.size == sub.size ? previous : Blocks.air, result);
|
build.setConstruct(previous.size == sub.size ? previous : Blocks.air, result);
|
||||||
build.prevBuild = prevBuild;
|
build.prevBuild = prevBuild;
|
||||||
|
if(unit != null && unit.isPlayer()) build.lastAccessed = unit.getPlayer().name;
|
||||||
|
|
||||||
result.placeBegan(tile, previous);
|
result.placeBegan(tile, previous);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user