mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
Better unit selection visuals / Bigger unit physics collision circles
This commit is contained in:
parent
d65f226b3a
commit
ec0ba9f424
11 changed files with 79 additions and 38 deletions
|
|
@ -1070,23 +1070,36 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
}
|
||||
|
||||
public void drawCommand(Unit sel){
|
||||
Drawf.square(sel.x, sel.y, sel.hitSize / 1.4f + Mathf.absin(4f, 1f), selectedUnits.contains(sel) ? Pal.remove : Pal.accent);
|
||||
Drawf.poly(sel.x, sel.y, 6, sel.hitSize / 1.1f + Mathf.absin(4f, 1f), 0f, selectedUnits.contains(sel) ? Pal.remove : Pal.accent);
|
||||
}
|
||||
|
||||
public void drawCommanded(){
|
||||
Draw.draw(Layer.plans, () -> {
|
||||
drawCommanded(true);
|
||||
});
|
||||
|
||||
Draw.draw(Layer.groundUnit - 1, () -> {
|
||||
drawCommanded(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void drawCommanded(boolean flying){
|
||||
float lineLimit = 6.5f;
|
||||
|
||||
if(commandMode){
|
||||
//happens sometimes
|
||||
selectedUnits.removeAll(u -> !u.isCommandable());
|
||||
|
||||
//draw command overlay UI
|
||||
for(Unit unit : selectedUnits){
|
||||
if(unit.isFlying() != flying) continue;
|
||||
CommandAI ai = unit.command();
|
||||
Position lastPos = ai.attackTarget != null ? ai.attackTarget : ai.targetPos;
|
||||
|
||||
//draw target line
|
||||
if(ai.targetPos != null && ai.currentCommand().drawTarget){
|
||||
Position lineDest = ai.attackTarget != null ? ai.attackTarget : ai.targetPos;
|
||||
Drawf.limitLine(unit, lineDest, unit.hitSize / 2f, 3.5f);
|
||||
Drawf.limitLine(unit, lineDest, unit.hitSize / 1.1f + 1f, lineLimit);
|
||||
|
||||
if(ai.attackTarget == null){
|
||||
Drawf.square(lineDest.getX(), lineDest.getY(), 3.5f);
|
||||
|
|
@ -1100,7 +1113,23 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
}
|
||||
}
|
||||
|
||||
Drawf.square(unit.x, unit.y, unit.hitSize / 1.4f + 1f);
|
||||
float rad = unit.hitSize / 1.1f + 1f;
|
||||
int sides = 6;
|
||||
|
||||
Fill.lightInner(unit.x, unit.y, sides,
|
||||
Math.max(0f, unit.hitSize / 1.1f + 1f - 4f),
|
||||
rad,
|
||||
0f,
|
||||
Tmp.c3.set(Pal.accent).a(0f),
|
||||
Tmp.c2.set(Pal.accent).a(0.7f)
|
||||
);
|
||||
|
||||
Lines.stroke(1f);
|
||||
Draw.color(Pal.accent);
|
||||
Lines.poly(unit.x, unit.y, sides, rad + 0.5f);
|
||||
//Draw.color(Pal.gray);
|
||||
//Lines.poly(unit.x, unit.y, sides, rad + 1.5f);
|
||||
Draw.reset();
|
||||
|
||||
if(ai.attackTarget != null && ai.currentCommand().drawTarget){
|
||||
Drawf.target(ai.attackTarget.getX(), ai.attackTarget.getY(), 6f, Pal.remove);
|
||||
|
|
@ -1113,7 +1142,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
//draw command queue
|
||||
if(ai.currentCommand().drawTarget && ai.commandQueue.size > 0){
|
||||
for(var next : ai.commandQueue){
|
||||
Drawf.limitLine(lastPos, next, 3.5f, 3.5f);
|
||||
Drawf.limitLine(lastPos, next, lineLimit, lineLimit);
|
||||
lastPos = next;
|
||||
|
||||
if(next instanceof Vec2 vec){
|
||||
|
|
@ -1139,14 +1168,16 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
}
|
||||
}
|
||||
|
||||
for(var commandBuild : commandBuildings){
|
||||
if(commandBuild != null){
|
||||
Drawf.square(commandBuild.x, commandBuild.y, commandBuild.hitSize() / 1.4f + 1f);
|
||||
var cpos = commandBuild.getCommandPosition();
|
||||
if(flying){
|
||||
for(var commandBuild : commandBuildings){
|
||||
if(commandBuild != null){
|
||||
Drawf.square(commandBuild.x, commandBuild.y, commandBuild.hitSize() / 1.4f + 1f);
|
||||
var cpos = commandBuild.getCommandPosition();
|
||||
|
||||
if(cpos != null){
|
||||
Drawf.limitLine(commandBuild, cpos, commandBuild.hitSize() / 2f, 3.5f);
|
||||
Drawf.square(cpos.x, cpos.y, 3.5f);
|
||||
if(cpos != null){
|
||||
Drawf.limitLine(commandBuild, cpos, commandBuild.hitSize() / 2f, lineLimit);
|
||||
Drawf.square(cpos.x, cpos.y, 3.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1154,27 +1185,29 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
if(commandMode && !commandRect){
|
||||
Unit sel = selectedCommandUnit(input.mouseWorldX(), input.mouseWorldY());
|
||||
|
||||
if(sel != null && !(!multiUnitSelect() && selectedUnits.size == 1 && selectedUnits.contains(sel))){
|
||||
if(sel != null && sel.isFlying() == flying && !(!multiUnitSelect() && selectedUnits.size == 1 && selectedUnits.contains(sel))){
|
||||
drawCommand(sel);
|
||||
}
|
||||
}
|
||||
|
||||
if(commandRect){
|
||||
float x2 = input.mouseWorldX(), y2 = input.mouseWorldY();
|
||||
var units = selectedCommandUnits(commandRectX, commandRectY, x2 - commandRectX, y2 - commandRectY);
|
||||
for(var unit : units){
|
||||
drawCommand(unit);
|
||||
}
|
||||
|
||||
Draw.color(Pal.accent, 0.3f);
|
||||
Fill.crect(commandRectX, commandRectY, x2 - commandRectX, y2 - commandRectY);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
||||
}
|
||||
|
||||
public void drawUnitSelection(){
|
||||
if(commandRect && commandMode){
|
||||
float x2 = input.mouseWorldX(), y2 = input.mouseWorldY();
|
||||
var units = selectedCommandUnits(commandRectX, commandRectY, x2 - commandRectX, y2 - commandRectY);
|
||||
for(var unit : units){
|
||||
drawCommand(unit);
|
||||
}
|
||||
|
||||
Draw.color(Pal.accent, 0.3f);
|
||||
Fill.crect(commandRectX, commandRectY, x2 - commandRectX, y2 - commandRectY);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawBottom(){
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue