Fixed reconstructor commanding in multiplayer
This commit is contained in:
@@ -128,6 +128,9 @@ public class TypeIO{
|
|||||||
for(Object obj : objs){
|
for(Object obj : objs){
|
||||||
writeObject(write, obj);
|
writeObject(write, obj);
|
||||||
}
|
}
|
||||||
|
}else if(object instanceof UnitCommand command){
|
||||||
|
write.b(23);
|
||||||
|
write.s(command.id);
|
||||||
}else{
|
}else{
|
||||||
throw new IllegalArgumentException("Unknown object type: " + object.getClass());
|
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);
|
for(int i = 0; i < objlen; i++) objs[i] = readObjectBoxed(read, box);
|
||||||
yield objs;
|
yield objs;
|
||||||
}
|
}
|
||||||
|
case 23 -> UnitCommand.all.get(read.us());
|
||||||
default -> throw new IllegalArgumentException("Unknown object type: " + type);
|
default -> throw new IllegalArgumentException("Unknown object type: " + type);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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. */
|
/** Called right before building of this block begins. */
|
||||||
public void beforePlaceBegan(Tile tile, Block previous){
|
public void beforePlaceBegan(Tile tile, Block previous){
|
||||||
|
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ public class Build{
|
|||||||
build.prevBuild = prevBuild;
|
build.prevBuild = prevBuild;
|
||||||
if(unit != null && unit.getControllerName() != null) build.lastAccessed = unit.getControllerName();
|
if(unit != null && unit.getControllerName() != null) build.lastAccessed = unit.getControllerName();
|
||||||
|
|
||||||
result.placeBegan(tile, previous);
|
|
||||||
|
|
||||||
Events.fire(new BlockBuildBeginEvent(tile, team, unit, false));
|
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. */
|
/** Returns whether a tile can be placed at this location by this team. */
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.
|
//finish placement immediately when a block is replaced.
|
||||||
if(previous instanceof CoreBlock){
|
if(previous instanceof CoreBlock){
|
||||||
tile.setBlock(this, tile.team());
|
tile.setBlock(this, tile.team());
|
||||||
@@ -181,6 +181,8 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
nextItems = null;
|
nextItems = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Events.fire(new BlockBuildEndEvent(tile, builder, tile.team(), false, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user