mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-27 16:09:57 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
53310ed80a
@ -22,7 +22,7 @@ bool id(vec2 coords, vec4 base){
|
||||
}
|
||||
|
||||
bool cont(vec2 T, vec2 v){
|
||||
float step = 1.0;
|
||||
const float step = 3.0;
|
||||
vec4 base = texture2D(u_texture, T);
|
||||
return base.a > 0.1 &&
|
||||
(id(T + vec2(0, step) * v, base) || id(T + vec2(0, -step) * v, base) ||
|
||||
@ -41,13 +41,8 @@ void main() {
|
||||
|
||||
vec2 center = ((u_uv + u_uv2)/2.0 - u_uv) /v;
|
||||
float dst = (abs(center.x - coords.x) + abs(center.y - coords.y))/2.0;
|
||||
float chance = 1.0;
|
||||
|
||||
if(u_progress > 0.8){
|
||||
chance = 1.0-(u_progress-0.8)*5.0;
|
||||
}
|
||||
|
||||
if((mod(u_time / 1.5 + value, 20.0) < 5.0 && cont(t, v))){
|
||||
if((mod(u_time / 1.5 + value, 20.0) < 15.0 && cont(t, v))){
|
||||
gl_FragColor = u_color;
|
||||
}else if(dst > (1.0-u_progress) * (center.x)){
|
||||
gl_FragColor = color;
|
||||
|
@ -673,9 +673,10 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
junction = new Junction("junction"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 2));
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 3));
|
||||
speed = 26;
|
||||
capacity = 32;
|
||||
health = 25;
|
||||
}};
|
||||
|
||||
itemBridge = new BufferedItemBridge("bridge-conveyor"){{
|
||||
|
@ -33,6 +33,8 @@ public class PlacementFragment extends Fragment{
|
||||
final int rowWidth = 4;
|
||||
|
||||
Array<Block> returnArray = new Array<>();
|
||||
Array<Category> returnCatArray = new Array<>();
|
||||
boolean[] categoryEmpty = new boolean[Category.values().length];
|
||||
Category currentCategory = Category.distribution;
|
||||
Block hovered, lastDisplay;
|
||||
Tile lastHover;
|
||||
@ -56,13 +58,18 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
public PlacementFragment(){
|
||||
Events.on(WorldLoadEvent.class, event -> {
|
||||
currentCategory = Category.turret;
|
||||
Group group = toggler.getParent();
|
||||
toggler.remove();
|
||||
build(group);
|
||||
control.input(0).block = null;
|
||||
rebuild();
|
||||
});
|
||||
}
|
||||
|
||||
void rebuild(){
|
||||
currentCategory = Category.turret;
|
||||
Group group = toggler.getParent();
|
||||
toggler.remove();
|
||||
build(group);
|
||||
}
|
||||
|
||||
boolean gridUpdate(InputHandler input){
|
||||
if(Core.input.keyDown(Binding.pick)){ //mouse eyedropper select
|
||||
Tile tile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
@ -121,12 +128,14 @@ public class PlacementFragment extends Fragment{
|
||||
group.setMinCheckCount(0);
|
||||
|
||||
for(Block block : getByCategory(currentCategory)){
|
||||
|
||||
if(index++ % rowWidth == 0){
|
||||
blockTable.row();
|
||||
}
|
||||
|
||||
boolean[] unlocked = {false};
|
||||
if(!data.isUnlocked(block)){
|
||||
blockTable.add().size(46);
|
||||
continue;
|
||||
}
|
||||
|
||||
ImageButton button = blockTable.addImageButton("icon-locked", "select", 8 * 4, () -> {
|
||||
if(data.isUnlocked(block)){
|
||||
@ -134,21 +143,14 @@ public class PlacementFragment extends Fragment{
|
||||
}
|
||||
}).size(46f).group(group).get();
|
||||
|
||||
button.replaceImage(new Image(block.icon(Icon.medium)));
|
||||
|
||||
button.update(() -> { //color unplacable things gray
|
||||
boolean ulock = data.isUnlocked(block);
|
||||
TileEntity core = players[0].getClosestCore();
|
||||
Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : ulock ? Color.GRAY : Color.WHITE;
|
||||
button.forEach(elem -> elem.setColor(color));
|
||||
button.setChecked(input.block == block);
|
||||
|
||||
if(ulock == unlocked[0]) return;
|
||||
unlocked[0] = ulock;
|
||||
|
||||
if(!ulock){
|
||||
button.replaceImage(new Image("icon-locked"));
|
||||
}else{
|
||||
button.replaceImage(new Image(block.icon(Icon.medium)));
|
||||
}
|
||||
});
|
||||
|
||||
button.hovered(() -> hovered = block);
|
||||
@ -246,15 +248,25 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
//update category empty values
|
||||
for(Category cat : Category.values()){
|
||||
if(getByCategory(cat).isEmpty()) continue;
|
||||
Array<Block> blocks = getByCategory(cat);
|
||||
categoryEmpty[cat.ordinal()] = blocks.isEmpty() || !blocks.first().unlocked();
|
||||
}
|
||||
|
||||
int f = 0;
|
||||
for(Category cat : getCategories()){
|
||||
if(f++ % 2 == 0) categories.row();
|
||||
|
||||
if(categoryEmpty[cat.ordinal()]){
|
||||
categories.addImage("flat");
|
||||
continue;
|
||||
}
|
||||
|
||||
categories.addImageButton("icon-" + cat.name(), "clear-toggle", 16 * 2, () -> {
|
||||
currentCategory = cat;
|
||||
rebuildCategory.run();
|
||||
}).group(group).update(i -> i.setChecked(currentCategory == cat));
|
||||
|
||||
if(cat.ordinal() % 2 == 1) categories.row();
|
||||
}
|
||||
}).touchable(Touchable.enabled);
|
||||
|
||||
@ -265,6 +277,13 @@ public class PlacementFragment extends Fragment{
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Array<Category> getCategories(){
|
||||
returnCatArray.clear();
|
||||
returnCatArray.addAll(Category.values());
|
||||
returnCatArray.sort((c1, c2) -> Boolean.compare(categoryEmpty[c1.ordinal()], categoryEmpty[c2.ordinal()]));
|
||||
return returnCatArray;
|
||||
}
|
||||
|
||||
Array<Block> getByCategory(Category cat){
|
||||
returnArray.clear();
|
||||
@ -273,6 +292,7 @@ public class PlacementFragment extends Fragment{
|
||||
returnArray.add(block);
|
||||
}
|
||||
}
|
||||
returnArray.sort((b1, b2) -> -Boolean.compare(b1.unlocked(), b2.unlocked()));
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
|
@ -244,10 +244,15 @@ public class ServerControl implements ApplicationListener{
|
||||
});
|
||||
|
||||
handler.register("maps", "Display all available maps.", arg -> {
|
||||
info("Maps:");
|
||||
for(Map map : world.maps.all()){
|
||||
info(" &ly{0}: &lb&fi{1} / {2}x{3}", map.name, map.custom ? "Custom" : "Default", map.meta.width, map.meta.height);
|
||||
if(!world.maps.all().isEmpty()){
|
||||
info("Maps:");
|
||||
for(Map map : world.maps.all()){
|
||||
info(" &ly{0}: &lb&fi{1} / {2}x{3}", map.name, map.custom ? "Custom" : "Default", map.meta.width, map.meta.height);
|
||||
}
|
||||
}else{
|
||||
info("No maps found.");
|
||||
}
|
||||
info("&lyMap directory: &lb&fi{0}", customMapDirectory.file().getAbsoluteFile().toString());
|
||||
});
|
||||
|
||||
handler.register("status", "Display server status.", arg -> {
|
||||
|
Loading…
Reference in New Issue
Block a user