mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 14:32:06 -08:00
Cleanup + Generic cross rendering
This commit is contained in:
parent
bceb7b5809
commit
136c8cfcd2
7 changed files with 23 additions and 17 deletions
|
|
@ -3,6 +3,7 @@ package mindustry.input;
|
|||
import arc.*;
|
||||
import arc.Graphics.*;
|
||||
import arc.Graphics.Cursor.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
|
|
@ -160,14 +161,17 @@ public class DesktopInput extends InputHandler{
|
|||
drawArrow(block, cursorX, cursorY, rotation);
|
||||
}
|
||||
Draw.color();
|
||||
boolean valid = validPlace(cursorX, cursorY, block, rotation);
|
||||
drawRequest(cursorX, cursorY, block, rotation);
|
||||
block.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, block, rotation));
|
||||
block.drawPlace(cursorX, cursorY, rotation, valid);
|
||||
|
||||
if(block.saveConfig && block.lastConfig != null){
|
||||
if(block.saveConfig){
|
||||
Draw.mixcol(!valid ? Pal.breakInvalid : Color.white, (!valid ? 0.4f : 0.24f) + Mathf.absin(Time.globalTime, 6f, 0.28f));
|
||||
brequest.set(cursorX, cursorY, rotation, block);
|
||||
brequest.config = block.lastConfig;
|
||||
block.drawRequestConfig(brequest, allRequests());
|
||||
brequest.config = null;
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class PlacementFragment extends Fragment{
|
|||
|
||||
if(Core.input.keyTap(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
|
||||
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
Block tryRecipe = tile == null ? null : tile.block instanceof ConstructBlock ? ((ConstructBuild)tile).cblock : tile.block;
|
||||
Block tryRecipe = tile == null ? null : tile instanceof ConstructBuild c ? c.cblock : tile.block;
|
||||
Object tryConfig = tile == null ? null : tile.config();
|
||||
|
||||
for(BuildPlan req : player.unit().plans()){
|
||||
|
|
|
|||
|
|
@ -426,9 +426,7 @@ public class Block extends UnlockableContent{
|
|||
TextureRegion reg = getRequestRegion(req, list);
|
||||
Draw.rect(reg, req.drawx(), req.drawy(), !rotate ? 0 : req.rotation * 90);
|
||||
|
||||
if(req.config != null){
|
||||
drawRequestConfig(req, list);
|
||||
}
|
||||
drawRequestConfig(req, list);
|
||||
}
|
||||
|
||||
public TextureRegion getRequestRegion(BuildPlan req, Eachable<BuildPlan> list){
|
||||
|
|
@ -439,8 +437,14 @@ public class Block extends UnlockableContent{
|
|||
|
||||
}
|
||||
|
||||
public void drawRequestConfigCenter(BuildPlan req, Object content, String region){
|
||||
Color color = content instanceof Item ? ((Item)content).color : content instanceof Liquid ? ((Liquid)content).color : null;
|
||||
public void drawRequestConfigCenter(BuildPlan req, Object content, String region, boolean cross){
|
||||
if(content == null){
|
||||
if(cross){
|
||||
Draw.rect("cross", req.drawx(), req.drawy());
|
||||
}
|
||||
return;
|
||||
}
|
||||
Color color = content instanceof Item i ? i.color : content instanceof Liquid l ? l.color : null;
|
||||
if(color == null) return;
|
||||
|
||||
Draw.color(color);
|
||||
|
|
@ -448,6 +452,10 @@ public class Block extends UnlockableContent{
|
|||
Draw.color();
|
||||
}
|
||||
|
||||
public void drawRequestConfigCenter(BuildPlan req, Object content, String region){
|
||||
drawRequestConfigCenter(req, content, region, false);
|
||||
}
|
||||
|
||||
public void drawRequestConfigTop(BuildPlan req, Eachable<BuildPlan> list){
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,8 +176,6 @@ public class ItemBridge extends Block{
|
|||
public void playerPlaced(Object config){
|
||||
super.playerPlaced(config);
|
||||
|
||||
if(config != null) return;
|
||||
|
||||
Tile link = findLink(tile.x, tile.y);
|
||||
if(linkValid(tile, link) && !proximity.contains(link.build)){
|
||||
link.build.configure(tile.pos());
|
||||
|
|
|
|||
|
|
@ -33,11 +33,7 @@ public class Sorter extends Block{
|
|||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan req, Eachable<BuildPlan> list){
|
||||
if(req.config == null){
|
||||
Draw.rect("cross", req.drawx(), req.drawy());
|
||||
}else{
|
||||
drawRequestConfigCenter(req, req.config, "center");
|
||||
}
|
||||
drawRequestConfigCenter(req, req.config, "center", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class ItemSource extends Block{
|
|||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan req, Eachable<BuildPlan> list){
|
||||
drawRequestConfigCenter(req, req.config, "center");
|
||||
drawRequestConfigCenter(req, req.config, "center", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class LiquidSource extends Block{
|
|||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan req, Eachable<BuildPlan> list){
|
||||
drawRequestConfigCenter(req, req.config, "center");
|
||||
drawRequestConfigCenter(req, req.config, "center", true);
|
||||
}
|
||||
|
||||
public class LiquidSourceBuild extends Building{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue