Fixed #1959 / Indication of selected units

This commit is contained in:
Anuken
2020-05-02 10:53:48 -04:00
parent 5f27261cb1
commit 342523a7de
6 changed files with 39 additions and 2 deletions

View File

@@ -28,4 +28,9 @@ public class MimicAI extends AIController{
}
}
}
@Override
public boolean isFollowing(Playerc player){
return control == player.unit();
}
}

View File

@@ -27,7 +27,6 @@ public class UnitTypes implements ContentList{
public void load(){
dagger = new UnitType("dagger"){{
speed = 0.5f;
drag = 0.3f;
hitsize = 8f;
@@ -168,6 +167,7 @@ public class UnitTypes implements ContentList{
health = 400;
buildSpeed = 0.4f;
engineOffset = 6.5f;
hitsize = 7f;
}};
/*

View File

@@ -14,4 +14,8 @@ public interface UnitController{
default void update(){
}
default boolean isFollowing(Playerc player){
return false;
}
}

View File

@@ -115,6 +115,10 @@ public class UnitType extends UnlockableContent{
//region drawing
public void draw(Unitc unit){
if(unit.controller().isFollowing(player)){
drawControl(unit);
}
if(unit.isFlying()){
Draw.z(Layer.darkness);
drawShadow(unit);
@@ -139,6 +143,15 @@ public class UnitType extends UnlockableContent{
drawLight(unit);
}
public void drawControl(Unitc unit){
Draw.z(Layer.groundUnit - 2);
Draw.color(Pal.accent, Color.white, Mathf.absin(4f, 0.3f));
Lines.poly(unit.x(), unit.y(), 4, unit.hitSize() + 1.5f);
Draw.reset();
}
public void drawShadow(Unitc unit){
Draw.color(shadowColor);
Draw.rect(region, unit.x() + shadowTX * unit.elevation(), unit.y() + shadowTY * unit.elevation(), unit.rotation() - 90);

View File

@@ -147,6 +147,8 @@ public class StackConveyor extends Block implements Autotiler{
public void onProximityUpdate(){
super.onProximityUpdate();
int lastState = state;
state = stateMove;
int[] bits = buildBlending(tile, tile.rotation(), null, true);
@@ -160,6 +162,15 @@ public class StackConveyor extends Block implements Autotiler{
blendprox |= (1 << i);
}
}
//update other conveyor state when this conveyor's state changes
if(state != lastState){
for(Tilec near : proximity){
if(near instanceof StackConveyorEntity){
near.onProximityUpdate();
}
}
}
}
@Override

View File

@@ -43,7 +43,11 @@ public class UnitFactory extends Block{
flags = EnumSet.of(BlockFlag.producer);
configurable = true;
config(Integer.class, (tile, i) -> ((UnitFactoryEntity)tile).currentPlan = i < 0 || i >= plans.length ? -1 : i);
config(Integer.class, (tile, i) -> {
((UnitFactoryEntity)tile).currentPlan = i < 0 || i >= plans.length ? -1 : i;
((UnitFactoryEntity)tile).progress = 0;
});
consumes.add(new ConsumeItemDynamic(e -> {
UnitFactoryEntity entity = (UnitFactoryEntity)e;