Sector lock state
This commit is contained in:
@@ -77,11 +77,15 @@ public class Planet extends UnlockableContent{
|
||||
//read data for sectors
|
||||
Fi data = Vars.tree.get("planets/" + name + ".dat");
|
||||
if(data.exists()){
|
||||
try(Reads read = data.reads()){
|
||||
short dsize = read.s();
|
||||
for(int i = 0; i < dsize; i++){
|
||||
sectors.get(i).data.read(read);
|
||||
try{
|
||||
try(Reads read = data.reads()){
|
||||
short dsize = read.s();
|
||||
for(int i = 0; i < dsize; i++){
|
||||
sectors.get(i).data.read(read);
|
||||
}
|
||||
}
|
||||
}catch(Throwable t){
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package mindustry.type;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
@@ -34,6 +34,10 @@ public class Sector{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean locked(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return light dot product in the range [0, 1]. */
|
||||
public float getLight(){
|
||||
Vec3 normal = Tmp.v31.set(tile.v).rotate(Vec3.Y, -planet.getRotation()).nor();
|
||||
@@ -87,6 +91,10 @@ public class Sector{
|
||||
return new SectorRect(radius, center, planeTop, planeRight, angle);
|
||||
}
|
||||
|
||||
public boolean hasAttribute(SectorAttribute attribute){
|
||||
return (data.attributes & (1 << attribute.ordinal())) != 0;
|
||||
}
|
||||
|
||||
public static class SectorRect{
|
||||
public final Vec3 center, top, right;
|
||||
public final Vec3 result = new Vec3();
|
||||
@@ -115,6 +123,7 @@ public class Sector{
|
||||
|
||||
public Block[] floors = {};
|
||||
public int[] floorCounts = {};
|
||||
public int attributes;
|
||||
|
||||
public void write(Writes write){
|
||||
write.s(resources.length);
|
||||
@@ -129,6 +138,8 @@ public class Sector{
|
||||
write.s(floors[i].id);
|
||||
write.i(floorCounts[i]);
|
||||
}
|
||||
|
||||
write.i(attributes);
|
||||
}
|
||||
|
||||
public void read(Reads read){
|
||||
@@ -144,6 +155,12 @@ public class Sector{
|
||||
floors[i] = Vars.content.block(read.s());
|
||||
floorCounts[i] = read.i();
|
||||
}
|
||||
attributes = read.i();
|
||||
}
|
||||
}
|
||||
|
||||
public enum SectorAttribute{
|
||||
/** Requires naval technology to land on, e.g. mostly water */
|
||||
naval
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.graphics.g3d.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.type.Sector.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@@ -30,7 +31,7 @@ public class PlanetDialog extends FloatingDialog{
|
||||
borderColor = Pal.accent.cpy().a(0.3f),
|
||||
shadowColor = new Color(0, 0, 0, 0.7f);
|
||||
private static final float camLength = 4f;
|
||||
float outlineRad = 1.15f;
|
||||
float outlineRad = 1.16f;
|
||||
|
||||
//the base planet that's being rendered
|
||||
private final Planet solarSystem = Planets.sun;
|
||||
@@ -59,7 +60,7 @@ public class PlanetDialog extends FloatingDialog{
|
||||
buttons.addImageTextButton("$techtree", Icon.tree, () -> ui.tech.show()).size(230f, 64f);
|
||||
|
||||
camRelative.set(0, 0f, camLength);
|
||||
projector.setScaling(1f / 300f);
|
||||
projector.setScaling(1f / 150f);
|
||||
|
||||
update(() -> {
|
||||
Vec3 v = Tmp.v33.set(Core.input.mouseX(), Core.input.mouseY(), 0);
|
||||
@@ -95,7 +96,7 @@ public class PlanetDialog extends FloatingDialog{
|
||||
addListener(new ElementGestureListener(){
|
||||
@Override
|
||||
public void tap(InputEvent event, float x, float y, int count, KeyCode button){
|
||||
selected = hovered;
|
||||
selected = hovered != null && hovered.locked() ? null : hovered;
|
||||
if(selected != null){
|
||||
updateSelected();
|
||||
}
|
||||
@@ -158,10 +159,15 @@ public class PlanetDialog extends FloatingDialog{
|
||||
if(hovered != null){
|
||||
Draw.batch(projector, () -> {
|
||||
setPlane(hovered);
|
||||
Draw.color(Color.white, Pal.accent, Mathf.absin(5f, 1f));
|
||||
|
||||
if(false){ //TODO locked check
|
||||
Draw.rect(Icon.lock.getRegion(), 0, 0);
|
||||
TextureRegion icon = hovered.locked() ? Icon.lock.getRegion() : hovered.hasAttribute(SectorAttribute.naval) ? Liquids.water.icon(Cicon.large) : null;
|
||||
|
||||
if(icon != null){
|
||||
Draw.rect(icon, 0, 0);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.world.blocks.logic;
|
||||
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class LogicExecutor{
|
||||
Instruction[] instructions;
|
||||
@@ -17,26 +18,69 @@ public class LogicExecutor{
|
||||
if(counter >= instructions.length) counter = 0;
|
||||
}
|
||||
|
||||
Tilec device(short id){
|
||||
return null; //TODO
|
||||
}
|
||||
|
||||
interface Instruction{
|
||||
void exec();
|
||||
}
|
||||
|
||||
class RegisterI{
|
||||
class RegisterI implements Instruction{
|
||||
/** operation to perform */
|
||||
Op op;
|
||||
short from, to;
|
||||
int immediate;
|
||||
/** destination register */
|
||||
short dest;
|
||||
/** registers to take data from. -1 for no register. */
|
||||
short left, right;
|
||||
/** left/right immediate values, only used if no registers are present. */
|
||||
int ileft, iright;
|
||||
|
||||
@Override
|
||||
public void exec(){
|
||||
registers[to] = op.function.get(registers[from], immediate);
|
||||
registers[dest] = op.function.get(left == -1 ? ileft : registers[left], right == -1 ? iright : registers[right]);
|
||||
}
|
||||
}
|
||||
|
||||
static class ReadI{
|
||||
class ReadI implements Instruction{
|
||||
/** register to write result to */
|
||||
short dest;
|
||||
/** device to read from */
|
||||
short device;
|
||||
/** the type of data to be read */
|
||||
ReadOp op;
|
||||
/** any additional read parameters */
|
||||
int parameter;
|
||||
|
||||
@Override
|
||||
public void exec(){
|
||||
registers[dest] = op.function.get(device(device), parameter);
|
||||
}
|
||||
}
|
||||
|
||||
static class WriteI{
|
||||
class WriteI implements Instruction{
|
||||
|
||||
@Override
|
||||
public void exec(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
enum ReadOp{
|
||||
item((tile, id) -> tile.items() == null ? 0 : tile.items().get(id)),
|
||||
itemTotal((tile, param) -> tile.items() == null ? 0 : tile.items().total());
|
||||
|
||||
final ReadOpLambda function;
|
||||
final String symbol;
|
||||
|
||||
ReadOp(ReadOpLambda function){
|
||||
this.symbol = name();
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
interface ReadOpLambda{
|
||||
int get(Tilec tile, int parameter);
|
||||
}
|
||||
}
|
||||
|
||||
enum Op{
|
||||
@@ -52,16 +96,18 @@ public class LogicExecutor{
|
||||
and("and", (a, b) -> a & b),
|
||||
xor("xor", (a, b) -> a ^ b);
|
||||
|
||||
final BinaryOp function;
|
||||
final OpLambda function;
|
||||
final String symbol;
|
||||
|
||||
Op(String symbol, BinaryOp function){
|
||||
Op(String symbol, OpLambda function){
|
||||
this.symbol = symbol;
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
interface OpLambda{
|
||||
int get(int a, int b);
|
||||
}
|
||||
}
|
||||
|
||||
interface BinaryOp{
|
||||
int get(int a, int b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ public class ItemModule extends BlockModule{
|
||||
return null;
|
||||
}
|
||||
|
||||
public int get(int id){
|
||||
return items[id];
|
||||
}
|
||||
|
||||
public int get(Item item){
|
||||
return items[item.id];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user