Build beginPlace+Break access tracking / Instant rotation

This commit is contained in:
Anuken
2020-11-29 10:12:24 -05:00
parent 9a3b21d77a
commit 8f186a16b3
2 changed files with 15 additions and 5 deletions
+13 -3
View File
@@ -20,7 +20,7 @@ public class Build{
private static final IntSet tmp = new IntSet();
@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)){
return;
}
@@ -40,14 +40,14 @@ public class Build{
tile.setBlock(sub, team, rotation);
tile.<ConstructBuild>bc().setDeconstruct(previous);
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)));
}
/** Places a ConstructBlock at this location. */
@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)){
return;
}
@@ -57,6 +57,15 @@ public class Build{
//just in case
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 sub = ConstructBlock.get(result.size);
Seq<Building> prevBuild = new Seq<>(9);
@@ -76,6 +85,7 @@ public class Build{
build.setConstruct(previous.size == sub.size ? previous : Blocks.air, result);
build.prevBuild = prevBuild;
if(unit != null && unit.isPlayer()) build.lastAccessed = unit.getPlayer().name;
result.placeBegan(tile, previous);