mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-11 07:39:39 +07:00
Better builder detection for ConstructBlock
This commit is contained in:
parent
f1ec26f82b
commit
2f6f205dc7
@ -153,7 +153,6 @@ public class OverlayRenderer{
|
||||
input.drawOverSelect();
|
||||
|
||||
if(ui.hudfrag.blockfrag.hover() instanceof Unit unit && unit.controller() instanceof LogicAI ai && ai.controller instanceof Building build){
|
||||
Draw.z(Layer.overlayUI);
|
||||
Drawf.square(build.x, build.y, build.block.size * tilesize/2f + 2f);
|
||||
if(!unit.within(build, unit.hitSize * 2f)){
|
||||
Drawf.arrow(unit.x, unit.y, build.x, build.y, unit.hitSize *2f, 4f);
|
||||
|
@ -146,6 +146,9 @@ public class ConstructBlock extends Block{
|
||||
public Block previous;
|
||||
public Object lastConfig;
|
||||
|
||||
@Nullable
|
||||
public Unit lastBuilder;
|
||||
|
||||
private float[] accumulator;
|
||||
private float[] totalAccumulator;
|
||||
|
||||
@ -218,6 +221,10 @@ public class ConstructBlock extends Block{
|
||||
return;
|
||||
}
|
||||
|
||||
if(builder.isPlayer()){
|
||||
lastBuilder = builder;
|
||||
}
|
||||
|
||||
lastConfig = config;
|
||||
|
||||
if(cblock.requirements.length != accumulator.length || totalAccumulator.length != cblock.requirements.length){
|
||||
@ -237,13 +244,18 @@ public class ConstructBlock extends Block{
|
||||
progress = Mathf.clamp(progress + maxProgress);
|
||||
|
||||
if(progress >= 1f || state.rules.infiniteResources){
|
||||
constructed(tile, cblock, builder, (byte)rotation, builder.team, config);
|
||||
if(lastBuilder == null) lastBuilder = builder;
|
||||
constructed(tile, cblock, lastBuilder, (byte)rotation, builder.team, config);
|
||||
}
|
||||
}
|
||||
|
||||
public void deconstruct(Unit builder, @Nullable Building core, float amount){
|
||||
float deconstructMultiplier = state.rules.deconstructRefundMultiplier;
|
||||
|
||||
if(builder.isPlayer()){
|
||||
lastBuilder = builder;
|
||||
}
|
||||
|
||||
if(cblock != null){
|
||||
ItemStack[] requirements = cblock.requirements;
|
||||
if(requirements.length != accumulator.length || totalAccumulator.length != requirements.length){
|
||||
@ -275,7 +287,8 @@ public class ConstructBlock extends Block{
|
||||
progress = Mathf.clamp(progress - amount);
|
||||
|
||||
if(progress <= 0 || state.rules.infiniteResources){
|
||||
Call.deconstructFinish(tile, this.cblock == null ? previous : this.cblock, builder);
|
||||
if(lastBuilder == null) lastBuilder = builder;
|
||||
Call.deconstructFinish(tile, this.cblock == null ? previous : this.cblock, lastBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user