Placement config code cleanup
This commit is contained in:
@@ -110,11 +110,7 @@ abstract class BuilderComp implements Unitc{
|
||||
if(current.breaking){
|
||||
entity.deconstruct(base(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier);
|
||||
}else{
|
||||
if(entity.construct(base(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){
|
||||
if(current.hasConfig){
|
||||
Call.tileConfig(null, tile.build, current.config);
|
||||
}
|
||||
}
|
||||
entity.construct(base(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier, current.config);
|
||||
}
|
||||
|
||||
current.stuck = Mathf.equal(current.progress, entity.progress);
|
||||
|
||||
@@ -813,9 +813,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
/** Called after the block is placed by this client. */
|
||||
@CallSuper
|
||||
public void playerPlaced(){
|
||||
if(block.saveConfig && block.lastConfig != null){
|
||||
configure(block.lastConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Called after the block is placed by anyone. */
|
||||
@@ -856,7 +854,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
/** Called when arbitrary configuration is applied to a tile. */
|
||||
public void configured(@Nullable Player player, @Nullable Object value){
|
||||
public void configured(@Nullable Unit builder, @Nullable Object value){
|
||||
//null is of type void.class; anonymous classes use their superclass.
|
||||
Class<?> type = value == null ? void.class : value.getClass().isAnonymousClass() ? value.getClass().getSuperclass() : value.getClass();
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ public class BuildPlan{
|
||||
public @Nullable Block block;
|
||||
/** Whether this is a break request.*/
|
||||
public boolean breaking;
|
||||
/** Whether this request comes with a config int. If yes, any blocks placed with this request will not call playerPlaced.*/
|
||||
public boolean hasConfig;
|
||||
/** Config int. Not used unless hasConfig is true.*/
|
||||
public Object config;
|
||||
/** Original position, only used in schematics.*/
|
||||
@@ -40,6 +38,16 @@ public class BuildPlan{
|
||||
this.breaking = false;
|
||||
}
|
||||
|
||||
/** This creates a build request with a config. */
|
||||
public BuildPlan(int x, int y, int rotation, Block block, Object config){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.rotation = rotation;
|
||||
this.block = block;
|
||||
this.breaking = false;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/** This creates a remove request. */
|
||||
public BuildPlan(int x, int y){
|
||||
this.x = x;
|
||||
@@ -84,7 +92,6 @@ public class BuildPlan{
|
||||
copy.rotation = rotation;
|
||||
copy.block = block;
|
||||
copy.breaking = breaking;
|
||||
copy.hasConfig = hasConfig;
|
||||
copy.config = config;
|
||||
copy.originalX = originalX;
|
||||
copy.originalY = originalY;
|
||||
@@ -127,12 +134,6 @@ public class BuildPlan{
|
||||
return y*tilesize + block.offset;
|
||||
}
|
||||
|
||||
public BuildPlan configure(Object config){
|
||||
this.config = config;
|
||||
this.hasConfig = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable Tile tile(){
|
||||
return world.tile(x, y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user