Implemented slopes

This commit is contained in:
Anuken 2018-06-12 11:36:55 -04:00
parent 4df0641d67
commit 9abbd8c158
8 changed files with 248 additions and 224 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

View File

@ -162,6 +162,7 @@ text.unknown=Unknown
text.custom=Custom
text.builtin=Built-In
text.map.delete.confirm=Are you sure you want to delete this map? This action cannot be undone!
text.editor.slope=\\
text.editor.openin=Open In Editor
text.editor.oregen=Ore Generation
text.editor.oregen.info=Ore Generation:

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

@ -496,15 +496,14 @@ public class MapEditorDialog extends Dialog implements Disposable{
get().table("button", t -> {
t.margin(0);
t.addImageButton("icon-arrow-left", 16*2f, () -> {
editor.setDrawElevation(editor.getDrawElevation() - 1);
}).disabled(b -> editor.getDrawElevation() <= 0).size(size);
t.addImageButton("icon-arrow-left", 16*2f, () -> editor.setDrawElevation(editor.getDrawElevation() - 1))
.disabled(b -> editor.getDrawElevation() <= -1).size(size);
t.label(() -> editor.getDrawElevation() + "").size(size).get().setAlignment(Align.center, Align.center);
t.label(() -> editor.getDrawElevation() == -1 ? "$text.editor.slope" : (editor.getDrawElevation() + ""))
.size(size).get().setAlignment(Align.center, Align.center);
t.addImageButton("icon-arrow-right", 16*2f, () -> {
editor.setDrawElevation(editor.getDrawElevation() + 1);
}).disabled(b -> editor.getDrawElevation() >= 127).size(size);
t.addImageButton("icon-arrow-right", 16*2f, () -> editor.setDrawElevation(editor.getDrawElevation() + 1))
.disabled(b -> editor.getDrawElevation() >= 127).size(size);
}).colspan(3).height(size).padTop(-5).width(size*3f);
}}.left().growY().end();

View File

@ -71,6 +71,7 @@ public class MapRenderer implements Disposable{
add("clear", packer);
add("block-border", packer);
add("block-elevation", packer);
add("block-slope", packer);
if(packer.getPages().size > 1){
throw new IllegalArgumentException("Pixmap packer may not have more than 1 page!");
@ -213,6 +214,8 @@ public class MapRenderer implements Disposable{
}else if(elev > 0 && check){
mesh.setColor(tmpColor.fromHsv((360f * elev/127f * 4f) % 360f, 0.5f + (elev / 4f) % 0.5f, 1f));
region = regions.get("block-elevation");
}else if(elev == -1){
region = regions.get("block-slope");
}else{
region = regions.get("clear");
}

View File

@ -189,6 +189,11 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
if(tile.block() != Blocks.air){
onLiquid = false;
}
//on slope
if(tile.elevation == -1){
velocity.scl(0.7f);
}
}
if(onLiquid && velocity.len() > 0.4f && Timers.get(this, "flooreffect", 14 - (velocity.len() * floor.speedMultiplier)*2f)){

View File

@ -5,18 +5,19 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.blocks.Floor;
import io.anuke.mindustry.world.blocks.modules.InventoryModule;
import io.anuke.mindustry.world.blocks.modules.LiquidModule;
import io.anuke.mindustry.world.blocks.modules.PowerModule;
import io.anuke.ucore.entities.trait.PosTrait;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.util.Bits;
import io.anuke.ucore.entities.trait.PosTrait;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
@ -325,21 +326,29 @@ public class Tile implements PosTrait, TargetTrait {
//check for bitmasking cliffs
for(int i = 0; i < 4; i ++){
GridPoint2 pc = Geometry.d4[i];
GridPoint2 pcprev = Geometry.d4[Mathf.mod(i - 1, 4)];
GridPoint2 pcnext = Geometry.d4[(i + 1) % 4];
GridPoint2 pe = Geometry.d8edge[i];
Tile tc = world.tile(x + pc.x, y + pc.y);
Tile tprev = world.tile(x + pcprev.x, y + pcprev.y);
Tile tnext = world.tile(x + pcnext.x, y + pcnext.y);
Tile te = world.tile(x + pe.x, y + pe.y);
Tile tex = world.tile(x, y + pe.y);
Tile tey = world.tile(x + pe.x, y);
//check for cardinal direction elevation changes and bitmask that
if(tc != null && tc.elevation < elevation){
if(tc != null && tprev != null && tnext != null && ((tc.elevation < elevation && tc.elevation != -1))){
cliffs |= (1 << (i*2));
}
//check for corner bitmasking
if(te != null && tex != null && tey != null && te.elevation < elevation && tex.elevation < elevation && tey.elevation < elevation){
cliffs |= (1 << (i*2 + 1));
//00S
//0X0
//010
//check for corner bitmasking: doesn't even get checked so it doesn't matter
if(te != null && tex != null && tey != null && te.elevation == -1 && elevation > 0){
cliffs |= (1 << (((i+1)%4)*2));
}
}
if(occluded){