Fixed reconstructor commanding in multiplayer

This commit is contained in:
Anuken
2023-06-17 17:54:29 -04:00
parent 6ed336ad95
commit 70516752fc
4 changed files with 14 additions and 3 deletions

View File

@@ -128,6 +128,9 @@ public class TypeIO{
for(Object obj : objs){
writeObject(write, obj);
}
}else if(object instanceof UnitCommand command){
write.b(23);
write.s(command.id);
}else{
throw new IllegalArgumentException("Unknown object type: " + object.getClass());
}
@@ -200,6 +203,7 @@ public class TypeIO{
for(int i = 0; i < objlen; i++) objs[i] = readObjectBoxed(read, box);
yield objs;
}
case 23 -> UnitCommand.all.get(read.us());
default -> throw new IllegalArgumentException("Unknown object type: " + type);
};
}

View File

@@ -890,6 +890,11 @@ public class Block extends UnlockableContent implements Senseable{
}
/** Called when building of this block begins. */
public void placeBegan(Tile tile, Block previous, @Nullable Unit builder){
placeBegan(tile, previous);
}
/** Called right before building of this block begins. */
public void beforePlaceBegan(Tile tile, Block previous){

View File

@@ -115,9 +115,9 @@ public class Build{
build.prevBuild = prevBuild;
if(unit != null && unit.getControllerName() != null) build.lastAccessed = unit.getControllerName();
result.placeBegan(tile, previous);
Events.fire(new BlockBuildBeginEvent(tile, team, unit, false));
result.placeBegan(tile, previous, unit);
}
/** Returns whether a tile can be placed at this location by this team. */

View File

@@ -164,7 +164,7 @@ public class CoreBlock extends StorageBlock{
}
@Override
public void placeBegan(Tile tile, Block previous){
public void placeBegan(Tile tile, Block previous, Unit builder){
//finish placement immediately when a block is replaced.
if(previous instanceof CoreBlock){
tile.setBlock(this, tile.team());
@@ -181,6 +181,8 @@ public class CoreBlock extends StorageBlock{
nextItems = null;
}
Events.fire(new BlockBuildEndEvent(tile, builder, tile.team(), false, null));
}
}