Map editor tweaks & fixes / New map

This commit is contained in:
Anuken 2020-10-22 15:27:30 -04:00
parent c2ff5a69ef
commit a2e75df096
22 changed files with 108 additions and 76 deletions

View file

@ -446,6 +446,7 @@ filter.option.amount = Amount
filter.option.block = Block
filter.option.floor = Floor
filter.option.flooronto = Target Floor
filter.option.target = Target
filter.option.wall = Wall
filter.option.ore = Ore
filter.option.floor2 = Secondary Floor

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 827 B

After

Width:  |  Height:  |  Size: 826 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Before After
Before After

View file

@ -39,8 +39,8 @@ public class Blocks implements ContentList{
//environment
air, spawn, cliff, deepwater, water, taintedWater, tar, slag, stone, craters, charr, sand, darksand, dirt, mud, ice, snow, darksandTaintedWater, space,
dacite, stoneWall, dirtWall, sporeWall, iceWall, daciteWall, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
iceSnow, sandWater, darksandWater, duneWall, sandWall, moss, sporeMoss, shale, shaleWall, shaleBoulder, sandBoulder, daciteBoulder, grass, salt,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, basalt, magmarock, hotrock, snowWall, boulder, snowBoulder, saltWall,
iceSnow, sandWater, darksandWater, duneWall, sandWall, moss, sporeMoss, shale, shaleWall, shaleBoulder, sandBoulder, daciteBoulder, boulder, snowBoulder, grass, salt,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, basalt, magmarock, hotrock, snowWall, saltWall,
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal,
pebbles, tendrils,
@ -102,6 +102,7 @@ public class Blocks implements ContentList{
{
alwaysReplace = true;
hasShadow = false;
useColor = false;
}
@Override public void drawBase(Tile tile){}
@ -318,6 +319,11 @@ public class Blocks implements ContentList{
attributes.set(Attribute.water, 0.3f);
}};
shale = new Floor("shale"){{
variants = 3;
attributes.set(Attribute.oil, 1f);
}};
stoneWall = new StaticWall("stone-wall"){{
variants = 2;
}};
@ -326,15 +332,6 @@ public class Blocks implements ContentList{
variants = 2;
}};
boulder = new Boulder("boulder"){{
variants = 2;
}};
snowBoulder = new Boulder("snow-boulder"){{
variants = 2;
snow.asFloor().decoration = ice.asFloor().decoration = iceSnow.asFloor().decoration = salt.asFloor().decoration = this;
}};
dirtWall = new StaticWall("dirt-wall"){{
variants = 2;
}};
@ -364,6 +361,12 @@ public class Blocks implements ContentList{
saltWall = new StaticWall("salt-wall");
shrubs = new StaticWall("shrubs");
shaleWall = new StaticWall("shale-wall"){{
variants = 2;
}};
sporePine = new StaticTree("spore-pine"){{
variants = 0;
}};
@ -376,8 +379,6 @@ public class Blocks implements ContentList{
variants = 0;
}};
shrubs = new StaticWall("shrubs");
whiteTreeDead = new TreeBlock("white-tree-dead");
whiteTree = new TreeBlock("white-tree");
@ -386,13 +387,13 @@ public class Blocks implements ContentList{
variants = 3;
}};
shale = new Floor("shale"){{
variants = 3;
attributes.set(Attribute.oil, 1f);
boulder = new Boulder("boulder"){{
variants = 2;
}};
shaleWall = new StaticWall("shale-wall"){{
snowBoulder = new Boulder("snow-boulder"){{
variants = 2;
snow.asFloor().decoration = ice.asFloor().decoration = iceSnow.asFloor().decoration = salt.asFloor().decoration = this;
}};
shaleBoulder = new Boulder("shale-boulder"){{

View file

@ -258,6 +258,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
Groups.unit.clear();
Groups.build.clear();
logic.play();
if(player.team().core() == null){
player.set(world.width() * tilesize/2f, world.height() * tilesize/2f);
player.unit(UnitTypes.alpha.spawn(player.team(), player.x, player.y));
}
});
}

View file

@ -66,7 +66,7 @@ public class MapGenerateDialog extends BaseDialog{
shown(this::setup);
addCloseButton();
if(applied){
buttons.button("@editor.apply", () -> {
buttons.button("@editor.apply", Icon.ok, () -> {
ui.loadAnd(() -> {
apply();
hide();
@ -79,14 +79,14 @@ public class MapGenerateDialog extends BaseDialog{
update();
}).size(160f, 64f);
}
buttons.button("@editor.randomize", () -> {
buttons.button("@editor.randomize", Icon.refresh, () -> {
for(GenerateFilter filter : filters){
filter.randomize();
}
update();
}).size(160f, 64f);
buttons.button("@add", Icon.add, this::showAdd).height(64f).width(140f);
buttons.button("@add", Icon.add, this::showAdd).height(64f).width(150f);
if(!applied){
hidden(this::apply);

View file

@ -159,7 +159,7 @@ public class WaveInfoDialog extends BaseDialog{
t.margin(0).defaults().pad(3).padLeft(5f).growX().left();
t.button(b -> {
b.left();
b.image(group.type.icon(mindustry.ui.Cicon.medium)).size(32f).padRight(3);
b.image(group.type.icon(Cicon.medium)).size(32f).padRight(3).scaling(Scaling.fit);
b.add(group.type.localizedName).color(Pal.accent);
b.add().growX();
@ -262,7 +262,7 @@ public class WaveInfoDialog extends BaseDialog{
if(type.isHidden()) continue;
p.button(t -> {
t.left();
t.image(type.icon(Cicon.medium)).size(40f).padRight(2f);
t.image(type.icon(Cicon.medium)).size(8 * 4).scaling(Scaling.fit).padRight(2f);
t.add(type.localizedName);
}, () -> {
lastType = type;

View file

@ -1,6 +1,7 @@
package mindustry.entities.comp;
import arc.*;
import arc.func.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
@ -71,6 +72,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
return Mathf.lerp(1f, type.canBoost ? type.boostMultiplier : 1f, elevation) * type.speed;
}
/** Iterates through this unit and everything it is controlling. */
public void eachGroup(Cons<Unit> cons){
cons.get(self());
controlling().each(cons);
}
@Override
public float range(){
return type.range;

View file

@ -126,24 +126,62 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
@Remote(called = Loc.server, targets = Loc.both, forward = true)
public static void requestItem(Player player, Building tile, Item item, int amount){
if(player == null || tile == null || !tile.interactable(player.team()) || !player.within(tile, buildingRange) || player.dead()) return;
amount = Math.min(player.unit().maxAccepted(item), amount);
int fa = amount;
if(amount == 0) return;
if(net.server() && (!Units.canInteract(player, tile) ||
!netServer.admins.allowAction(player, ActionType.withdrawItem, tile.tile(), action -> {
action.item = item;
action.itemAmount = fa;
action.itemAmount = amount;
}))) throw new ValidateException(player, "Player cannot request items.");
int removed = tile.removeStack(item, amount);
//remove item for every controlling unit
player.unit().eachGroup(unit -> {
int removed = Math.min(unit.maxAccepted(item), tile.removeStack(item, amount));
player.unit().addItem(item, removed);
Events.fire(new WithdrawEvent(tile, player, item, amount));
for(int j = 0; j < Mathf.clamp(removed / 3, 1, 8); j++){
Time.run(j * 3f, () -> Call.transferItemEffect(item, tile.x, tile.y, player.unit()));
unit.addItem(item, removed);
for(int j = 0; j < Mathf.clamp(removed / 3, 1, 8); j++){
Time.run(j * 3f, () -> Call.transferItemEffect(item, tile.x, tile.y, unit));
}
if(unit == player.unit()){
Events.fire(new WithdrawEvent(tile, player, item, amount));
}
});
}
@Remote(targets = Loc.both, forward = true, called = Loc.server)
public static void transferInventory(Player player, Building tile){
if(player == null || tile == null || !player.within(tile, buildingRange) || tile.items == null || player.dead()) return;
if(net.server() && (player.unit().stack.amount <= 0 || !Units.canInteract(player, tile) ||
!netServer.admins.allowAction(player, ActionType.depositItem, tile.tile, action -> {
action.itemAmount = player.unit().stack.amount;
action.item = player.unit().item();
}))){
throw new ValidateException(player, "Player cannot transfer an item.");
}
//deposit for every controlling unit
player.unit().eachGroup(unit -> {
Item item = unit.item();
int accepted = tile.acceptStack(item, unit.stack.amount, unit);
unit.stack.amount -= accepted;
tile.getStackOffset(item, stackTrns);
tile.handleStack(item, accepted, unit);
createItemTransfer(
item,
accepted,
unit.x + Angles.trnsx(unit.rotation + 180f, backTrns), unit.y + Angles.trnsy(unit.rotation + 180f, backTrns),
new Vec2(tile.x + stackTrns.x, tile.y + stackTrns.y),
() -> {}
);
if(unit == player.unit()){
Events.fire(new DepositEvent(tile, player, item, accepted));
}
});
}
@Remote(variants = Variant.one)
@ -276,37 +314,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
tile.noSleep();
}
@Remote(targets = Loc.both, forward = true, called = Loc.server)
public static void transferInventory(Player player, Building tile){
if(player == null || tile == null || !player.within(tile, buildingRange) || tile.items == null || player.dead()) return;
if(net.server() && (player.unit().stack.amount <= 0 || !Units.canInteract(player, tile) ||
!netServer.admins.allowAction(player, ActionType.depositItem, tile.tile, action -> {
action.itemAmount = player.unit().stack.amount;
action.item = player.unit().item();
}))){
throw new ValidateException(player, "Player cannot transfer an item.");
}
Item item = player.unit().item();
int amount = player.unit().stack.amount;
int accepted = tile.acceptStack(item, amount, player.unit());
player.unit().stack.amount -= accepted;
Core.app.post(() -> Events.fire(new DepositEvent(tile, player, item, accepted)));
tile.getStackOffset(item, stackTrns);
tile.handleStack(item, accepted, player.unit());
createItemTransfer(
item,
amount,
player.x + Angles.trnsx(player.unit().rotation + 180f, backTrns), player.y + Angles.trnsy(player.unit().rotation + 180f, backTrns),
new Vec2(tile.x + stackTrns.x, tile.y + stackTrns.y),
() -> {}
);
}
@Remote(targets = Loc.both, called = Loc.both, forward = true)
public static void tileConfig(@Nullable Player player, Building tile, @Nullable Object value){
if(tile == null) return;

View file

@ -151,7 +151,7 @@ public class MapIO{
if(wall.synthetic()){
return team.color.rgba();
}
return (wall.solid ? wall.mapColor : ore == Blocks.air ? floor.mapColor : ore.mapColor).rgba();
return (wall.solid ? wall.mapColor : !ore.useColor ? floor.mapColor : ore.mapColor).rgba();
}
public static Pixmap writeImage(Tiles tiles){

View file

@ -29,7 +29,7 @@ import static mindustry.Vars.*;
public class Maps{
/** List of all built-in maps. Filenames only. */
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "mudFlats", "moltenLake", "veins", "glacier"};
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "mudFlats", "moltenLake", "archipelago", "veins", "glacier"};
/** Maps tagged as PvP */
static final String[] pvpMaps = {"veins", "glacier"};
/** All maps stored in an ordered array. */

View file

@ -11,7 +11,7 @@ public class ClearFilter extends GenerateFilter{
@Override
public FilterOption[] options(){
return Structs.arr(new BlockOption("block", () -> block, b -> block = b, wallsOnly));
return Structs.arr(new BlockOption("block", () -> block, b -> block = b, b -> oresOnly.get(b) || wallsOnly.get(b)));
}
@Override
@ -20,5 +20,9 @@ public class ClearFilter extends GenerateFilter{
if(in.block == block){
in.block = Blocks.air;
}
if(in.overlay == block){
in.overlay = Blocks.air;
}
}
}

View file

@ -20,9 +20,10 @@ public abstract class FilterOption{
public static final Boolf<Block> floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && !headless && Core.atlas.isFound(b.icon(Cicon.full));
public static final Boolf<Block> wallsOnly = b -> (!b.synthetic() && !(b instanceof Floor)) && !headless && Core.atlas.isFound(b.icon(Cicon.full)) && b.inEditor;
public static final Boolf<Block> floorsOptional = b -> b == Blocks.air || ((b instanceof Floor && !(b instanceof OverlayFloor)) && !headless && Core.atlas.isFound(b.icon(Cicon.full)));
public static final Boolf<Block> wallsOptional = b -> b == Blocks.air || ((!b.synthetic() && !(b instanceof Floor)) && !headless && Core.atlas.isFound(b.icon(Cicon.full)));
public static final Boolf<Block> wallsOptional = b -> (b == Blocks.air || ((!b.synthetic() && !(b instanceof Floor)) && !headless && Core.atlas.isFound(b.icon(Cicon.full)))) && b.inEditor;
public static final Boolf<Block> wallsOresOptional = b -> b == Blocks.air || (((!b.synthetic() && !(b instanceof Floor)) || (b instanceof OverlayFloor)) && !headless && Core.atlas.isFound(b.icon(Cicon.full))) && b.inEditor;
public static final Boolf<Block> oresOnly = b -> b instanceof OverlayFloor && !headless && Core.atlas.isFound(b.icon(mindustry.ui.Cicon.full));
public static final Boolf<Block> oresOnly = b -> b instanceof OverlayFloor && !headless && Core.atlas.isFound(b.icon(Cicon.full));
public static final Boolf<Block> oresFloorsOptional = b -> (b instanceof Floor) && !headless && Core.atlas.isFound(b.icon(Cicon.full));
public static final Boolf<Block> anyOptional = b -> (floorsOnly.get(b) || wallsOnly.get(b) || oresOnly.get(b) || b == Blocks.air) && b.inEditor;
public abstract void build(Table table);

View file

@ -9,7 +9,7 @@ import static mindustry.maps.filters.FilterOption.*;
public class NoiseFilter extends GenerateFilter{
float scl = 40, threshold = 0.5f, octaves = 3f, falloff = 0.5f;
Block floor = Blocks.stone, block = Blocks.stoneWall;
Block floor = Blocks.stone, block = Blocks.stoneWall, target = Blocks.air;
@Override
public FilterOption[] options(){
@ -18,6 +18,7 @@ public class NoiseFilter extends GenerateFilter{
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
new BlockOption("target", () -> target, b -> target = b, anyOptional),
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
new BlockOption("wall", () -> block, b -> block = b, wallsOptional)
);
@ -27,9 +28,9 @@ public class NoiseFilter extends GenerateFilter{
public void apply(){
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
if(noise > threshold){
if(noise > threshold && (target == Blocks.air || in.floor == target || in.block == target)){
in.floor = floor;
if(in.block != Blocks.air) in.block = block;
if(block != Blocks.air) in.block = block;
}
}
}

View file

@ -9,7 +9,7 @@ import static mindustry.maps.filters.FilterOption.*;
public class OreFilter extends GenerateFilter{
public float scl = 23, threshold = 0.81f, octaves = 2f, falloff = 0.3f;
public Block ore = Blocks.oreCopper;
public Block ore = Blocks.oreCopper, target = Blocks.air;
@Override
public FilterOption[] options(){
@ -18,7 +18,8 @@ public class OreFilter extends GenerateFilter{
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly)
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly),
new BlockOption("target", () -> target, b -> target = b, oresFloorsOptional)
);
}
@ -26,7 +27,7 @@ public class OreFilter extends GenerateFilter{
public void apply(){
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
if(noise > threshold && in.overlay != Blocks.spawn){
if(noise > threshold && in.overlay != Blocks.spawn && (target == Blocks.air || in.floor == target || in.overlay == target)){
in.overlay = ore;
}
}

View file

@ -39,7 +39,7 @@ public class SpawnPathFilter extends GenerateFilter{
if(core != null && spawns.any()){
for(var spawn : spawns){
var path = Astar.pathfind(core.x, core.y, spawn.x, spawn.y, t -> t.solid() ? 20 : 1, Astar.manhattan, tile -> !tile.floor().isDeep());
var path = Astar.pathfind(core.x, core.y, spawn.x, spawn.y, t -> t.solid() ? 100 : 1, Astar.manhattan, tile -> !tile.floor().isDeep());
for(var tile : path){
for(int x = -radius; x <= radius; x++){
for(int y = -radius; y <= radius; y++){

View file

@ -100,6 +100,8 @@ public class Block extends UnlockableContent{
public boolean autoResetEnabled = true;
/** if true, the block stops updating when disabled */
public boolean noUpdateDisabled = false;
/** Whether to use this block's color in the minimap. Only used for overlays. */
public boolean useColor = true;
/** tile entity health */
public int health = -1;
/** base block explosiveness */

View file

@ -183,7 +183,7 @@ public class Conveyor extends Block implements Autotiler{
@Override
public void unitOn(Unit unit){
if(clogHeat > 0.5f) return;
if(clogHeat > 0.5f || !enabled) return;
noSleep();

View file

@ -20,6 +20,7 @@ public class OreBlock extends OverlayFloor{
this.itemDrop = ore;
this.variants = 3;
this.mapColor.set(ore.color);
this.useColor = true;
}
/** For mod use only!*/

View file

@ -9,6 +9,7 @@ public class OverlayFloor extends Floor{
public OverlayFloor(String name){
super(name);
useColor = false;
}
@Override