Implementation of #4921

This commit is contained in:
Anuken
2021-08-06 19:40:27 -04:00
parent 9c995be22e
commit cab71958d0

View File

@@ -26,12 +26,13 @@ public class CommandCenter extends Block{
public Color topColor = null, bottomColor = Color.valueOf("5e5e5e"); public Color topColor = null, bottomColor = Color.valueOf("5e5e5e");
public Effect effect = Fx.commandSend; public Effect effect = Fx.commandSend;
public float effectSize = 150f; public float effectSize = 150f;
public float forceRadius = 31f, forceStrength = 0.2f;
public CommandCenter(String name){ public CommandCenter(String name){
super(name); super(name);
flags = EnumSet.of(BlockFlag.rally); flags = EnumSet.of(BlockFlag.rally);
destructible = true; update = true;
solid = true; solid = true;
configurable = true; configurable = true;
drawDisabled = false; drawDisabled = false;
@@ -72,6 +73,22 @@ public class CommandCenter extends Block{
return team.data().command; return team.data().command;
} }
@Override
public void updateTile(){
super.updateTile();
//push away allied units
team.data().tree().intersect(x - forceRadius/2f, y - forceRadius/2f, forceRadius, forceRadius, u -> {
if(!u.isPlayer()){
float dst = dst(u);
float rs = forceRadius + u.hitSize/2f;
if(dst < rs){
u.vel.add(Tmp.v1.set(u).sub(x, y).setLength(1f - dst / rs).scl(forceStrength));
}
}
});
}
@Override @Override
public void draw(){ public void draw(){
super.draw(); super.draw();