Public block fields / Better scripting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
enum PlaceMode{
|
||||
public enum PlaceMode{
|
||||
none, breaking, placing, schematicSelect
|
||||
}
|
||||
|
||||
8
core/src/io/anuke/mindustry/mod/ClassAccess.java
Normal file
8
core/src/io/anuke/mindustry/mod/ClassAccess.java
Normal file
File diff suppressed because one or more lines are too long
@@ -30,7 +30,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Mods implements Loadable{
|
||||
private Json json = new Json();
|
||||
private Scripts scripts = new Scripts();
|
||||
private Scripts scripts;
|
||||
private ContentParser parser = new ContentParser();
|
||||
private ObjectMap<String, Array<FileHandle>> bundles = new ObjectMap<>();
|
||||
private ObjectSet<String> specialFolders = ObjectSet.with("bundles", "sprites");
|
||||
@@ -373,7 +373,10 @@ public class Mods implements Loadable{
|
||||
|
||||
for(FileHandle file : mod.scripts){
|
||||
try{
|
||||
scripts.run(file.readString());
|
||||
if(scripts == null){
|
||||
scripts = new Scripts();
|
||||
}
|
||||
scripts.run(mod, file);
|
||||
}catch(Throwable e){
|
||||
Core.app.post(() -> {
|
||||
Log.err("Error loading script {0} for mod {1}.", file.name(), mod.meta.name);
|
||||
|
||||
@@ -1,18 +1,40 @@
|
||||
package io.anuke.mindustry.mod;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.mod.Mods.*;
|
||||
import org.graalvm.polyglot.*;
|
||||
|
||||
public class Scripts{
|
||||
//TODO allowHostAccess(...) is obviously insecure
|
||||
private Context context = Context.newBuilder("js").allowHostClassLookup(s -> s.startsWith("io.anuke.mindustry"))
|
||||
.allowHostAccess(HostAccess.newBuilder().allowPublicAccess(true).denyAccess(FileHandle.class).build()).build();
|
||||
private final Context context;
|
||||
private final String wrapper;
|
||||
|
||||
public Scripts(){
|
||||
context.eval("js", "console.log(\"Initialized JS context.\")");
|
||||
Time.mark();
|
||||
Context.Builder builder = Context.newBuilder("js").allowHostClassLookup(ClassAccess.allowedClassNames::contains);
|
||||
|
||||
HostAccess.Builder hb = HostAccess.newBuilder();
|
||||
for(Class c : ClassAccess.allowedClasses){
|
||||
hb.allowImplementations(c);
|
||||
Structs.each(hb::allowAccess, c.getConstructors());
|
||||
Structs.each(hb::allowAccess, c.getFields());
|
||||
Structs.each(hb::allowAccess, c.getMethods());
|
||||
}
|
||||
builder.allowHostAccess(hb.build());
|
||||
|
||||
context = builder.build();
|
||||
wrapper = Core.files.internal("scripts/wrapper.js").readString();
|
||||
|
||||
run(Core.files.internal("scripts/global.js").readString());
|
||||
Log.info("Time to load script engine: {0}", Time.elapsed());
|
||||
}
|
||||
|
||||
public void run(String script){
|
||||
public void run(LoadedMod mod, FileHandle file){
|
||||
run(wrapper.replace("$SCRIPT_NAME$", mod.name + "_" +file.nameWithoutExtension().replace("-", "_").replace(" ", "_")).replace("$CODE$", file.readString()));
|
||||
}
|
||||
|
||||
private void run(String script){
|
||||
context.eval("js", script);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Door extends Wall{
|
||||
protected final Rectangle rect = new Rectangle();
|
||||
protected final static Rectangle rect = new Rectangle();
|
||||
|
||||
protected int timerToggle = timers++;
|
||||
protected Effect openfx = Fx.dooropen;
|
||||
protected Effect closefx = Fx.doorclose;
|
||||
public final int timerToggle = timers++;
|
||||
public Effect openfx = Fx.dooropen;
|
||||
public Effect closefx = Fx.doorclose;
|
||||
|
||||
protected TextureRegion openRegion;
|
||||
|
||||
|
||||
@@ -21,17 +21,17 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ForceProjector extends Block{
|
||||
protected int timerUse = timers++;
|
||||
protected float phaseUseTime = 350f;
|
||||
public final int timerUse = timers++;
|
||||
public float phaseUseTime = 350f;
|
||||
|
||||
protected float phaseRadiusBoost = 80f;
|
||||
protected float radius = 101.7f;
|
||||
protected float breakage = 550f;
|
||||
protected float cooldownNormal = 1.75f;
|
||||
protected float cooldownLiquid = 1.5f;
|
||||
protected float cooldownBrokenBase = 0.35f;
|
||||
protected float basePowerDraw = 0.2f;
|
||||
protected TextureRegion topRegion;
|
||||
public float phaseRadiusBoost = 80f;
|
||||
public float radius = 101.7f;
|
||||
public float breakage = 550f;
|
||||
public float cooldownNormal = 1.75f;
|
||||
public float cooldownLiquid = 1.5f;
|
||||
public float cooldownBrokenBase = 0.35f;
|
||||
public float basePowerDraw = 0.2f;
|
||||
public TextureRegion topRegion;
|
||||
|
||||
private static Tile paramTile;
|
||||
private static ForceProjector paramBlock;
|
||||
|
||||
@@ -18,19 +18,18 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MendProjector extends Block{
|
||||
private static Color color = Color.valueOf("84f491");
|
||||
private static Color phase = Color.valueOf("ffd59e");
|
||||
private static IntSet healed = new IntSet();
|
||||
private static final IntSet healed = new IntSet();
|
||||
|
||||
protected int timerUse = timers++;
|
||||
|
||||
protected TextureRegion topRegion;
|
||||
protected float reload = 250f;
|
||||
protected float range = 60f;
|
||||
protected float healPercent = 12f;
|
||||
protected float phaseBoost = 12f;
|
||||
protected float phaseRangeBoost = 50f;
|
||||
protected float useTime = 400f;
|
||||
public final int timerUse = timers++;
|
||||
public Color baseColor = Color.valueOf("84f491");
|
||||
public Color phaseColor = Color.valueOf("ffd59e");
|
||||
public TextureRegion topRegion;
|
||||
public float reload = 250f;
|
||||
public float range = 60f;
|
||||
public float healPercent = 12f;
|
||||
public float phaseBoost = 12f;
|
||||
public float phaseRangeBoost = 50f;
|
||||
public float useTime = 400f;
|
||||
|
||||
public MendProjector(String name){
|
||||
super(name);
|
||||
@@ -92,7 +91,7 @@ public class MendProjector extends Block{
|
||||
|
||||
if(other.getTeamID() == tile.getTeamID() && !healed.contains(other.pos()) && other.entity != null && other.entity.health < other.entity.maxHealth()){
|
||||
other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat * phaseBoost) / 100f * entity.efficiency());
|
||||
Effects.effect(Fx.healBlockFull, Tmp.c1.set(color).lerp(phase, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size);
|
||||
Effects.effect(Fx.healBlockFull, Tmp.c1.set(baseColor).lerp(phaseColor, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size);
|
||||
healed.add(other.pos());
|
||||
}
|
||||
}
|
||||
@@ -110,7 +109,7 @@ public class MendProjector extends Block{
|
||||
MendEntity entity = tile.entity();
|
||||
float realRange = range + entity.phaseHeat * phaseRangeBoost;
|
||||
|
||||
Drawf.dashCircle(tile.drawx(), tile.drawy(), realRange, color);
|
||||
Drawf.dashCircle(tile.drawx(), tile.drawy(), realRange, baseColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +119,7 @@ public class MendProjector extends Block{
|
||||
MendEntity entity = tile.entity();
|
||||
float f = 1f - (Time.time() / 100f) % 1f;
|
||||
|
||||
Draw.color(color, phase, entity.phaseHeat);
|
||||
Draw.color(baseColor, phaseColor, entity.phaseHeat);
|
||||
Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f);
|
||||
//Draw.blend(Blending.additive);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
@@ -135,7 +134,7 @@ public class MendProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.efficiency(), color, 0.7f * tile.entity.efficiency());
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.efficiency(), baseColor, 0.7f * tile.entity.efficiency());
|
||||
}
|
||||
|
||||
class MendEntity extends TileEntity{
|
||||
|
||||
@@ -16,19 +16,19 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class OverdriveProjector extends Block{
|
||||
private static Color color = Color.valueOf("feb380");
|
||||
private static Color phase = Color.valueOf("ffd59e");
|
||||
private static IntSet healed = new IntSet();
|
||||
private static final IntSet healed = new IntSet();
|
||||
|
||||
protected int timerUse = timers++;
|
||||
public final int timerUse = timers++;
|
||||
|
||||
protected TextureRegion topRegion;
|
||||
protected float reload = 60f;
|
||||
protected float range = 80f;
|
||||
protected float speedBoost = 1.5f;
|
||||
protected float speedBoostPhase = 0.75f;
|
||||
protected float useTime = 400f;
|
||||
protected float phaseRangeBoost = 20f;
|
||||
public TextureRegion topRegion;
|
||||
public float reload = 60f;
|
||||
public float range = 80f;
|
||||
public float speedBoost = 1.5f;
|
||||
public float speedBoostPhase = 0.75f;
|
||||
public float useTime = 400f;
|
||||
public float phaseRangeBoost = 20f;
|
||||
public Color baseColor = Color.valueOf("feb380");
|
||||
public Color phaseColor = Color.valueOf("ffd59e");
|
||||
|
||||
public OverdriveProjector(String name){
|
||||
super(name);
|
||||
@@ -69,7 +69,7 @@ public class OverdriveProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.efficiency(), color, 0.7f * tile.entity.efficiency());
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.efficiency(), baseColor, 0.7f * tile.entity.efficiency());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,7 +118,7 @@ public class OverdriveProjector extends Block{
|
||||
OverdriveEntity entity = tile.entity();
|
||||
float realRange = range + entity.phaseHeat * phaseRangeBoost;
|
||||
|
||||
Drawf.dashCircle(tile.drawx(), tile.drawy(), realRange, color);
|
||||
Drawf.dashCircle(tile.drawx(), tile.drawy(), realRange, baseColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,7 +128,7 @@ public class OverdriveProjector extends Block{
|
||||
OverdriveEntity entity = tile.entity();
|
||||
float f = 1f - (Time.time() / 100f) % 1f;
|
||||
|
||||
Draw.color(color, phase, entity.phaseHeat);
|
||||
Draw.color(baseColor, phaseColor, entity.phaseHeat);
|
||||
Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
Draw.alpha(1f);
|
||||
|
||||
@@ -11,13 +11,13 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class ShockMine extends Block{
|
||||
protected int timerDamage = timers++;
|
||||
public final int timerDamage = timers++;
|
||||
|
||||
protected float cooldown = 80f;
|
||||
protected float tileDamage = 5f;
|
||||
protected float damage = 13;
|
||||
protected int length = 10;
|
||||
protected int tendrils = 6;
|
||||
public float cooldown = 80f;
|
||||
public float tileDamage = 5f;
|
||||
public float damage = 13;
|
||||
public int length = 10;
|
||||
public int tendrils = 6;
|
||||
|
||||
public ShockMine(String name){
|
||||
super(name);
|
||||
|
||||
@@ -7,9 +7,9 @@ import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
|
||||
public class SurgeWall extends Wall{
|
||||
protected float lightningChance = 0.05f;
|
||||
protected float lightningDamage = 15f;
|
||||
protected int lightningLength = 17;
|
||||
public float lightningChance = 0.05f;
|
||||
public float lightningDamage = 15f;
|
||||
public int lightningLength = 17;
|
||||
|
||||
public SurgeWall(String name){
|
||||
super(name);
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
|
||||
public class Wall extends Block{
|
||||
protected int variants = 0;
|
||||
public int variants = 0;
|
||||
|
||||
public Wall(String name){
|
||||
super(name);
|
||||
|
||||
@@ -13,7 +13,7 @@ import static io.anuke.mindustry.Vars.tilesize;
|
||||
* Artillery turrets have special shooting calculations done to hit targets.
|
||||
*/
|
||||
public class ArtilleryTurret extends ItemTurret{
|
||||
protected float velocityInaccuracy = 0f;
|
||||
public float velocityInaccuracy = 0f;
|
||||
|
||||
public ArtilleryTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class BurstTurret extends ItemTurret{
|
||||
protected float burstSpacing = 5;
|
||||
public float burstSpacing = 5;
|
||||
|
||||
public BurstTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -12,11 +12,11 @@ import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class ChargeTurret extends PowerTurret{
|
||||
|
||||
protected float chargeTime = 30f;
|
||||
protected int chargeEffects = 5;
|
||||
protected float chargeMaxDelay = 10f;
|
||||
protected Effect chargeEffect = Fx.none;
|
||||
protected Effect chargeBeginEffect = Fx.none;
|
||||
public float chargeTime = 30f;
|
||||
public int chargeEffects = 5;
|
||||
public float chargeMaxDelay = 10f;
|
||||
public Effect chargeEffect = Fx.none;
|
||||
public Effect chargeBeginEffect = Fx.none;
|
||||
|
||||
public ChargeTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -17,8 +17,8 @@ import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class CooledTurret extends Turret{
|
||||
/** How much reload is lowered by for each unit of liquid of heat capacity. */
|
||||
protected float coolantMultiplier = 5f;
|
||||
protected Effect coolEffect = Fx.fuelburn;
|
||||
public float coolantMultiplier = 5f;
|
||||
public Effect coolEffect = Fx.fuelburn;
|
||||
|
||||
public CooledTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class DoubleTurret extends ItemTurret{
|
||||
protected float shotWidth = 2f;
|
||||
public float shotWidth = 2f;
|
||||
|
||||
public DoubleTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ItemTurret extends CooledTurret{
|
||||
protected int maxAmmo = 30;
|
||||
protected ObjectMap<Item, BulletType> ammo = new ObjectMap<>();
|
||||
public int maxAmmo = 30;
|
||||
public ObjectMap<Item, BulletType> ammo = new ObjectMap<>();
|
||||
|
||||
public ItemTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -14,8 +14,8 @@ import io.anuke.mindustry.world.meta.values.*;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class LaserTurret extends PowerTurret{
|
||||
protected float firingMoveFract = 0.25f;
|
||||
protected float shootDuration = 100f;
|
||||
public float firingMoveFract = 0.25f;
|
||||
public float shootDuration = 100f;
|
||||
|
||||
public LaserTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -15,7 +15,7 @@ import io.anuke.mindustry.world.meta.values.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class LiquidTurret extends Turret{
|
||||
protected ObjectMap<Liquid, BulletType> ammo = new ObjectMap<>();
|
||||
public ObjectMap<Liquid, BulletType> ammo = new ObjectMap<>();
|
||||
|
||||
public LiquidTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -7,8 +7,8 @@ import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
|
||||
public class PowerTurret extends CooledTurret{
|
||||
protected @NonNull BulletType shootType;
|
||||
protected float powerUse = 1f;
|
||||
public @NonNull BulletType shootType;
|
||||
public float powerUse = 1f;
|
||||
|
||||
public PowerTurret(String name){
|
||||
super(name);
|
||||
|
||||
@@ -28,40 +28,39 @@ import io.anuke.mindustry.world.meta.*;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public abstract class Turret extends Block{
|
||||
protected static final int targetInterval = 20;
|
||||
public final int timerTarget = timers++;
|
||||
public int targetInterval = 20;
|
||||
|
||||
protected final int timerTarget = timers++;
|
||||
public Color heatColor = Pal.turretHeat;
|
||||
public Effect shootEffect = Fx.none;
|
||||
public Effect smokeEffect = Fx.none;
|
||||
public Effect ammoUseEffect = Fx.none;
|
||||
public Sound shootSound = Sounds.shoot;
|
||||
|
||||
protected Color heatColor = Pal.turretHeat;
|
||||
protected Effect shootEffect = Fx.none;
|
||||
protected Effect smokeEffect = Fx.none;
|
||||
protected Effect ammoUseEffect = Fx.none;
|
||||
protected Sound shootSound = Sounds.shoot;
|
||||
|
||||
protected int ammoPerShot = 1;
|
||||
protected float ammoEjectBack = 1f;
|
||||
protected float range = 50f;
|
||||
protected float reload = 10f;
|
||||
protected float inaccuracy = 0f;
|
||||
protected int shots = 1;
|
||||
protected float spread = 4f;
|
||||
protected float recoil = 1f;
|
||||
protected float restitution = 0.02f;
|
||||
protected float cooldown = 0.02f;
|
||||
protected float rotatespeed = 5f; //in degrees per tick
|
||||
protected float shootCone = 8f;
|
||||
protected float shootShake = 0f;
|
||||
protected float xRand = 0f;
|
||||
protected boolean targetAir = true;
|
||||
protected boolean targetGround = true;
|
||||
public int ammoPerShot = 1;
|
||||
public float ammoEjectBack = 1f;
|
||||
public float range = 50f;
|
||||
public float reload = 10f;
|
||||
public float inaccuracy = 0f;
|
||||
public int shots = 1;
|
||||
public float spread = 4f;
|
||||
public float recoil = 1f;
|
||||
public float restitution = 0.02f;
|
||||
public float cooldown = 0.02f;
|
||||
public float rotatespeed = 5f; //in degrees per tick
|
||||
public float shootCone = 8f;
|
||||
public float shootShake = 0f;
|
||||
public float xRand = 0f;
|
||||
public boolean targetAir = true;
|
||||
public boolean targetGround = true;
|
||||
|
||||
protected Vector2 tr = new Vector2();
|
||||
protected Vector2 tr2 = new Vector2();
|
||||
|
||||
protected TextureRegion baseRegion, heatRegion;
|
||||
public TextureRegion baseRegion, heatRegion;
|
||||
|
||||
protected Cons2<Tile, TurretEntity> drawer = (tile, entity) -> Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
protected Cons2<Tile, TurretEntity> heatDrawer = (tile, entity) -> {
|
||||
public Cons2<Tile, TurretEntity> drawer = (tile, entity) -> Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
public Cons2<Tile, TurretEntity> heatDrawer = (tile, entity) -> {
|
||||
if(entity.heat <= 0.00001f) return;
|
||||
Draw.color(heatColor, entity.heat);
|
||||
Draw.blend(Blending.additive);
|
||||
|
||||
@@ -7,10 +7,10 @@ import io.anuke.mindustry.world.*;
|
||||
import java.io.*;
|
||||
|
||||
public class BufferedItemBridge extends ExtendingItemBridge{
|
||||
protected int timerAccept = timers++;
|
||||
public final int timerAccept = timers++;
|
||||
|
||||
protected float speed = 40f;
|
||||
protected int bufferCapacity = 50;
|
||||
public float speed = 40f;
|
||||
public int bufferCapacity = 50;
|
||||
|
||||
public BufferedItemBridge(String name){
|
||||
super(name);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
private final Vector2 tr2 = new Vector2();
|
||||
private TextureRegion[][] regions = new TextureRegion[7][4];
|
||||
|
||||
protected float speed = 0f;
|
||||
public float speed = 0f;
|
||||
|
||||
protected Conveyor(String name){
|
||||
super(name);
|
||||
|
||||
@@ -20,12 +20,12 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ItemBridge extends Block{
|
||||
protected int timerTransport = timers++;
|
||||
protected int range;
|
||||
protected float transportTime = 2f;
|
||||
protected TextureRegion endRegion, bridgeRegion, arrowRegion;
|
||||
protected BuildRequest otherReq;
|
||||
public final int timerTransport = timers++;
|
||||
public int range;
|
||||
public float transportTime = 2f;
|
||||
public TextureRegion endRegion, bridgeRegion, arrowRegion;
|
||||
|
||||
private static BuildRequest otherReq;
|
||||
private static int lastPlaced = Pos.invalid;
|
||||
|
||||
public ItemBridge(String name){
|
||||
|
||||
@@ -17,8 +17,8 @@ import java.io.IOException;
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class Junction extends Block{
|
||||
protected float speed = 26; //frames taken to go through this junction
|
||||
protected int capacity = 6;
|
||||
public float speed = 26; //frames taken to go through this junction
|
||||
public int capacity = 6;
|
||||
|
||||
public Junction(String name){
|
||||
super(name);
|
||||
|
||||
@@ -20,17 +20,17 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MassDriver extends Block{
|
||||
protected float range;
|
||||
protected float rotateSpeed = 0.04f;
|
||||
protected float translation = 7f;
|
||||
protected int minDistribute = 10;
|
||||
protected float knockback = 4f;
|
||||
protected float reloadTime = 100f;
|
||||
protected Effect shootEffect = Fx.shootBig2;
|
||||
protected Effect smokeEffect = Fx.shootBigSmoke2;
|
||||
protected Effect recieveEffect = Fx.mineBig;
|
||||
protected float shake = 3f;
|
||||
protected TextureRegion baseRegion;
|
||||
public float range;
|
||||
public float rotateSpeed = 0.04f;
|
||||
public float translation = 7f;
|
||||
public int minDistribute = 10;
|
||||
public float knockback = 4f;
|
||||
public float reloadTime = 100f;
|
||||
public Effect shootEffect = Fx.shootBig2;
|
||||
public Effect smokeEffect = Fx.shootBigSmoke2;
|
||||
public Effect recieveEffect = Fx.mineBig;
|
||||
public float shake = 3f;
|
||||
public TextureRegion baseRegion;
|
||||
|
||||
public MassDriver(String name){
|
||||
super(name);
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import java.io.*;
|
||||
|
||||
public class OverflowGate extends Block{
|
||||
protected float speed = 1f;
|
||||
public float speed = 1f;
|
||||
|
||||
public OverflowGate(String name){
|
||||
super(name);
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
|
||||
public class Router extends Block{
|
||||
protected float speed = 8f;
|
||||
public float speed = 8f;
|
||||
|
||||
public Router(String name){
|
||||
super(name);
|
||||
|
||||
@@ -18,7 +18,7 @@ import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class Sorter extends Block{
|
||||
private static Item lastItem;
|
||||
protected boolean invert;
|
||||
public boolean invert;
|
||||
|
||||
public Sorter(String name){
|
||||
super(name);
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class ArmoredConduit extends Conduit{
|
||||
protected TextureRegion capRegion;
|
||||
public TextureRegion capRegion;
|
||||
|
||||
public ArmoredConduit(String name){
|
||||
super(name);
|
||||
|
||||
@@ -16,12 +16,12 @@ import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.modules.*;
|
||||
|
||||
public class Conduit extends LiquidBlock implements Autotiler{
|
||||
protected final int timerFlow = timers++;
|
||||
public final int timerFlow = timers++;
|
||||
|
||||
protected TextureRegion[] topRegions = new TextureRegion[7];
|
||||
protected TextureRegion[] botRegions = new TextureRegion[7];
|
||||
public TextureRegion[] topRegions = new TextureRegion[7];
|
||||
public TextureRegion[] botRegions = new TextureRegion[7];
|
||||
|
||||
protected float leakResistance = 1.5f;
|
||||
public float leakResistance = 1.5f;
|
||||
|
||||
public Conduit(String name){
|
||||
super(name);
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
//TODO implement later
|
||||
public class LiquidOverflowGate extends LiquidBlock{
|
||||
int topRegion;
|
||||
public int topRegion;
|
||||
|
||||
public LiquidOverflowGate(String name){
|
||||
super(name);
|
||||
|
||||
@@ -19,17 +19,17 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ImpactReactor extends PowerGenerator{
|
||||
protected int timerUse = timers++;
|
||||
public final int timerUse = timers++;
|
||||
|
||||
protected int plasmas = 4;
|
||||
protected float warmupSpeed = 0.001f;
|
||||
protected float itemDuration = 60f;
|
||||
protected int explosionRadius = 50;
|
||||
protected int explosionDamage = 2000;
|
||||
public int plasmas = 4;
|
||||
public float warmupSpeed = 0.001f;
|
||||
public float itemDuration = 60f;
|
||||
public int explosionRadius = 50;
|
||||
public int explosionDamage = 2000;
|
||||
|
||||
protected Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
|
||||
protected int bottomRegion;
|
||||
protected int[] plasmaRegions;
|
||||
public Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
|
||||
public int bottomRegion;
|
||||
public int[] plasmaRegions;
|
||||
|
||||
public ImpactReactor(String name){
|
||||
super(name);
|
||||
|
||||
@@ -20,20 +20,20 @@ import static io.anuke.mindustry.Vars.*;
|
||||
* Liquids will take priority over items.
|
||||
*/
|
||||
public class ItemLiquidGenerator extends PowerGenerator{
|
||||
protected float minItemEfficiency = 0.2f;
|
||||
public float minItemEfficiency = 0.2f;
|
||||
/** The time in number of ticks during which a single item will produce power. */
|
||||
protected float itemDuration = 70f;
|
||||
public float itemDuration = 70f;
|
||||
|
||||
protected float minLiquidEfficiency = 0.2f;
|
||||
public float minLiquidEfficiency = 0.2f;
|
||||
/** Maximum liquid used per frame. */
|
||||
protected float maxLiquidGenerate = 0.4f;
|
||||
public float maxLiquidGenerate = 0.4f;
|
||||
|
||||
protected Effect generateEffect = Fx.generatespark;
|
||||
protected Effect explodeEffect = Fx.generatespark;
|
||||
protected Color heatColor = Color.valueOf("ff9b59");
|
||||
protected TextureRegion topRegion, liquidRegion;
|
||||
protected boolean randomlyExplode = true;
|
||||
protected boolean defaults = false;
|
||||
public Effect generateEffect = Fx.generatespark;
|
||||
public Effect explodeEffect = Fx.generatespark;
|
||||
public Color heatColor = Color.valueOf("ff9b59");
|
||||
public TextureRegion topRegion, liquidRegion;
|
||||
public boolean randomlyExplode = true;
|
||||
public boolean defaults = false;
|
||||
|
||||
public ItemLiquidGenerator(boolean hasItems, boolean hasLiquids, String name){
|
||||
this(name);
|
||||
|
||||
@@ -16,9 +16,9 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class LightBlock extends Block{
|
||||
private static int lastColor = 0;
|
||||
|
||||
protected float brightness = 0.9f;
|
||||
protected float radius = 200f;
|
||||
protected int topRegion;
|
||||
public float brightness = 0.9f;
|
||||
public float radius = 200f;
|
||||
public int topRegion;
|
||||
|
||||
public LightBlock(String name){
|
||||
super(name);
|
||||
|
||||
@@ -22,22 +22,22 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class NuclearReactor extends PowerGenerator{
|
||||
protected final int timerFuel = timers++;
|
||||
public final int timerFuel = timers++;
|
||||
|
||||
protected final Vector2 tr = new Vector2();
|
||||
public final Vector2 tr = new Vector2();
|
||||
|
||||
protected Color lightColor = Color.valueOf("7f19ea");
|
||||
protected Color coolColor = new Color(1, 1, 1, 0f);
|
||||
protected Color hotColor = Color.valueOf("ff9575a3");
|
||||
protected float itemDuration = 120; //time to consume 1 fuel
|
||||
protected float heating = 0.01f; //heating per frame * fullness
|
||||
protected float smokeThreshold = 0.3f; //threshold at which block starts smoking
|
||||
protected int explosionRadius = 40;
|
||||
protected int explosionDamage = 1350;
|
||||
protected float flashThreshold = 0.46f; //heat threshold at which the lights start flashing
|
||||
protected float coolantPower = 0.5f;
|
||||
public Color lightColor = Color.valueOf("7f19ea");
|
||||
public Color coolColor = new Color(1, 1, 1, 0f);
|
||||
public Color hotColor = Color.valueOf("ff9575a3");
|
||||
public float itemDuration = 120; //time to consume 1 fuel
|
||||
public float heating = 0.01f; //heating per frame * fullness
|
||||
public float smokeThreshold = 0.3f; //threshold at which block starts smoking
|
||||
public int explosionRadius = 40;
|
||||
public int explosionDamage = 1350;
|
||||
public float flashThreshold = 0.46f; //heat threshold at which the lights start flashing
|
||||
public float coolantPower = 0.5f;
|
||||
|
||||
protected TextureRegion topRegion, lightsRegion;
|
||||
public TextureRegion topRegion, lightsRegion;
|
||||
|
||||
public NuclearReactor(String name){
|
||||
super(name);
|
||||
|
||||
@@ -13,7 +13,7 @@ import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
||||
|
||||
public class PowerDiode extends Block{
|
||||
protected TextureRegion arrow;
|
||||
public TextureRegion arrow;
|
||||
|
||||
public PowerDiode(String name){
|
||||
super(name);
|
||||
@@ -50,7 +50,7 @@ public class PowerDiode extends Block{
|
||||
}
|
||||
|
||||
// battery % of the graph on either side, defaults to zero
|
||||
protected float bar(Tile tile){
|
||||
public float bar(Tile tile){
|
||||
return (tile != null && tile.block().hasPower) ? tile.entity.power.graph.getBatteryStored() / tile.entity.power.graph.getTotalBatteryCapacity() : 0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.io.*;
|
||||
|
||||
public class PowerGenerator extends PowerDistributor{
|
||||
/** The amount of power produced per tick in case of an efficiency of 1.0, which represents 100%. */
|
||||
protected float powerProduction;
|
||||
public float powerProduction;
|
||||
public BlockStat generationType = BlockStat.basePowerGeneration;
|
||||
|
||||
public PowerGenerator(String name){
|
||||
|
||||
@@ -21,12 +21,12 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class PowerNode extends PowerBlock{
|
||||
protected static boolean returnValue = false;
|
||||
|
||||
protected ObjectSet<PowerGraph> graphs = new ObjectSet<>();
|
||||
protected Vector2 t1 = new Vector2(), t2 = new Vector2();
|
||||
protected TextureRegion laser, laserEnd;
|
||||
protected final ObjectSet<PowerGraph> graphs = new ObjectSet<>();
|
||||
protected final Vector2 t1 = new Vector2(), t2 = new Vector2();
|
||||
|
||||
protected float laserRange = 6;
|
||||
protected int maxNodes = 3;
|
||||
public TextureRegion laser, laserEnd;
|
||||
public float laserRange = 6;
|
||||
public int maxNodes = 3;
|
||||
|
||||
public PowerNode(String name){
|
||||
super(name);
|
||||
|
||||
@@ -12,7 +12,7 @@ import io.anuke.mindustry.world.meta.*;
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class ThermalGenerator extends PowerGenerator{
|
||||
protected Effect generateEffect = Fx.none;
|
||||
public Effect generateEffect = Fx.none;
|
||||
|
||||
public ThermalGenerator(String name){
|
||||
super(name);
|
||||
|
||||
@@ -16,14 +16,14 @@ import io.anuke.mindustry.world.meta.Attribute;
|
||||
import java.io.*;
|
||||
|
||||
public class Cultivator extends GenericCrafter{
|
||||
protected static final Color plantColor = Color.valueOf("5541b1");
|
||||
protected static final Color plantColorLight = Color.valueOf("7457ce");
|
||||
protected static final Color bottomColor = Color.valueOf("474747");
|
||||
public Color plantColor = Color.valueOf("5541b1");
|
||||
public Color plantColorLight = Color.valueOf("7457ce");
|
||||
public Color bottomColor = Color.valueOf("474747");
|
||||
|
||||
protected TextureRegion middleRegion, topRegion;
|
||||
protected RandomXS128 random = new RandomXS128(0);
|
||||
protected float recurrence = 6f;
|
||||
protected Attribute attribute = Attribute.spores;
|
||||
public TextureRegion middleRegion, topRegion;
|
||||
public RandomXS128 random = new RandomXS128(0);
|
||||
public float recurrence = 6f;
|
||||
public Attribute attribute = Attribute.spores;
|
||||
|
||||
public Cultivator(String name){
|
||||
super(name);
|
||||
|
||||
@@ -21,41 +21,40 @@ import io.anuke.mindustry.world.meta.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Drill extends Block{
|
||||
protected final static float hardnessDrillMultiplier = 50f;
|
||||
public float hardnessDrillMultiplier = 50f;
|
||||
|
||||
protected final ObjectIntMap<Item> oreCount = new ObjectIntMap<>();
|
||||
protected final Array<Item> itemArray = new Array<>();
|
||||
|
||||
/** Maximum tier of blocks this drill can mine. */
|
||||
protected int tier;
|
||||
public int tier;
|
||||
/** Base time to drill one ore, in frames. */
|
||||
protected float drillTime = 300;
|
||||
public float drillTime = 300;
|
||||
/** How many times faster the drill will progress when boosted by liquid. */
|
||||
protected float liquidBoostIntensity = 1.6f;
|
||||
public float liquidBoostIntensity = 1.6f;
|
||||
/** Speed at which the drill speeds up. */
|
||||
protected float warmupSpeed = 0.02f;
|
||||
public float warmupSpeed = 0.02f;
|
||||
|
||||
//return variables for countOre
|
||||
protected Item returnItem;
|
||||
protected int returnCount;
|
||||
|
||||
/** Whether to draw the item this drill is mining. */
|
||||
protected boolean drawMineItem = false;
|
||||
public boolean drawMineItem = false;
|
||||
/** Effect played when an item is produced. This is colored. */
|
||||
protected Effect drillEffect = Fx.mine;
|
||||
public Effect drillEffect = Fx.mine;
|
||||
/** Speed the drill bit rotates at. */
|
||||
protected float rotateSpeed = 2f;
|
||||
public float rotateSpeed = 2f;
|
||||
/** Effect randomly played while drilling. */
|
||||
protected Effect updateEffect = Fx.pulverizeSmall;
|
||||
public Effect updateEffect = Fx.pulverizeSmall;
|
||||
/** Chance the update effect will appear. */
|
||||
protected float updateEffectChance = 0.02f;
|
||||
public float updateEffectChance = 0.02f;
|
||||
|
||||
protected boolean drawRim = false;
|
||||
|
||||
protected Color heatColor = Color.valueOf("ff5512");
|
||||
protected TextureRegion rimRegion;
|
||||
protected TextureRegion rotatorRegion;
|
||||
protected TextureRegion topRegion;
|
||||
public boolean drawRim = false;
|
||||
public Color heatColor = Color.valueOf("ff5512");
|
||||
public TextureRegion rimRegion;
|
||||
public TextureRegion rotatorRegion;
|
||||
public TextureRegion topRegion;
|
||||
|
||||
public Drill(String name){
|
||||
super(name);
|
||||
|
||||
@@ -6,11 +6,11 @@ import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
public class Fracker extends SolidPump{
|
||||
protected final float itemUseTime = 100f;
|
||||
public float itemUseTime = 100f;
|
||||
|
||||
protected TextureRegion liquidRegion;
|
||||
protected TextureRegion rotatorRegion;
|
||||
protected TextureRegion topRegion;
|
||||
public TextureRegion liquidRegion;
|
||||
public TextureRegion rotatorRegion;
|
||||
public TextureRegion topRegion;
|
||||
|
||||
public Fracker(String name){
|
||||
super(name);
|
||||
|
||||
@@ -17,16 +17,16 @@ import io.anuke.mindustry.world.meta.*;
|
||||
import java.io.*;
|
||||
|
||||
public class GenericCrafter extends Block{
|
||||
protected ItemStack outputItem;
|
||||
protected LiquidStack outputLiquid;
|
||||
public ItemStack outputItem;
|
||||
public LiquidStack outputLiquid;
|
||||
|
||||
protected float craftTime = 80;
|
||||
protected Effect craftEffect = Fx.none;
|
||||
protected Effect updateEffect = Fx.none;
|
||||
protected float updateEffectChance = 0.04f;
|
||||
public float craftTime = 80;
|
||||
public Effect craftEffect = Fx.none;
|
||||
public Effect updateEffect = Fx.none;
|
||||
public float updateEffectChance = 0.04f;
|
||||
|
||||
protected Cons<Tile> drawer = null;
|
||||
protected Prov<TextureRegion[]> drawIcons = null;
|
||||
public Cons<Tile> drawer = null;
|
||||
public Prov<TextureRegion[]> drawIcons = null;
|
||||
|
||||
public GenericCrafter(String name){
|
||||
super(name);
|
||||
|
||||
@@ -11,8 +11,8 @@ import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
/** A GenericCrafter with a new glowing region drawn on top. */
|
||||
public class GenericSmelter extends GenericCrafter{
|
||||
protected Color flameColor = Color.valueOf("ffc999");
|
||||
protected TextureRegion topRegion;
|
||||
public Color flameColor = Color.valueOf("ffc999");
|
||||
public TextureRegion topRegion;
|
||||
|
||||
public GenericSmelter(String name){
|
||||
super(name);
|
||||
|
||||
@@ -15,8 +15,8 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class Incinerator extends Block{
|
||||
protected Effect effect = Fx.fuelburn;
|
||||
protected Color flameColor = Color.valueOf("ffad9d");
|
||||
public Effect effect = Fx.fuelburn;
|
||||
public Color flameColor = Color.valueOf("ffad9d");
|
||||
|
||||
public Incinerator(String name){
|
||||
super(name);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Pump extends LiquidBlock{
|
||||
protected final Array<Tile> drawTiles = new Array<>();
|
||||
protected final Array<Tile> updateTiles = new Array<>();
|
||||
|
||||
protected final int timerContentCheck = timers++;
|
||||
public final int timerContentCheck = timers++;
|
||||
|
||||
/** Pump amount, total. */
|
||||
protected float pumpAmount = 1f;
|
||||
|
||||
@@ -20,12 +20,12 @@ import io.anuke.mindustry.world.meta.BlockStat;
|
||||
* Pump that makes liquid from solids and takes in power. Only works on solid floor blocks.
|
||||
*/
|
||||
public class SolidPump extends Pump{
|
||||
protected Liquid result = Liquids.water;
|
||||
protected Effect updateEffect = Fx.none;
|
||||
protected float updateEffectChance = 0.02f;
|
||||
protected float rotateSpeed = 1f;
|
||||
public Liquid result = Liquids.water;
|
||||
public Effect updateEffect = Fx.none;
|
||||
public float updateEffectChance = 0.02f;
|
||||
public float rotateSpeed = 1f;
|
||||
/** Attribute that is checked when calculating output. */
|
||||
protected Attribute attribute;
|
||||
public Attribute attribute;
|
||||
|
||||
public SolidPump(String name){
|
||||
super(name);
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class LiquidSource extends Block{
|
||||
private static Liquid lastLiquid;
|
||||
public static Liquid lastLiquid;
|
||||
|
||||
public LiquidSource(String name){
|
||||
super(name);
|
||||
|
||||
@@ -24,7 +24,7 @@ import io.anuke.mindustry.world.modules.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class CoreBlock extends StorageBlock{
|
||||
protected Mech mech = Mechs.starter;
|
||||
public Mech mech = Mechs.starter;
|
||||
|
||||
public CoreBlock(String name){
|
||||
super(name);
|
||||
|
||||
@@ -21,9 +21,9 @@ import static io.anuke.mindustry.Vars.data;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class LaunchPad extends StorageBlock{
|
||||
protected final int timerLaunch = timers++;
|
||||
public final int timerLaunch = timers++;
|
||||
/** Time inbetween launches. */
|
||||
protected float launchTime;
|
||||
public float launchTime;
|
||||
|
||||
public LaunchPad(String name){
|
||||
super(name);
|
||||
|
||||
@@ -15,8 +15,8 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class Unloader extends Block{
|
||||
protected float speed = 1f;
|
||||
protected final int timerUnload = timers++;
|
||||
public float speed = 1f;
|
||||
public final int timerUnload = timers++;
|
||||
|
||||
private static Item lastItem;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MechPad extends Block{
|
||||
public @NonNull Mech mech;
|
||||
protected float buildTime = 60 * 5;
|
||||
public float buildTime = 60 * 5;
|
||||
|
||||
public MechPad(String name){
|
||||
super(name);
|
||||
|
||||
@@ -19,13 +19,13 @@ import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
public class RepairPoint extends Block{
|
||||
private static Rectangle rect = new Rectangle();
|
||||
|
||||
protected int timerTarget = timers++;
|
||||
public int timerTarget = timers++;
|
||||
|
||||
protected float repairRadius = 50f;
|
||||
protected float repairSpeed = 0.3f;
|
||||
protected float powerUse;
|
||||
protected TextureRegion baseRegion;
|
||||
protected TextureRegion laser, laserEnd;
|
||||
public float repairRadius = 50f;
|
||||
public float repairSpeed = 0.3f;
|
||||
public float powerUse;
|
||||
public TextureRegion baseRegion;
|
||||
public TextureRegion laser, laserEnd;
|
||||
|
||||
public RepairPoint(String name){
|
||||
super(name);
|
||||
|
||||
@@ -27,12 +27,12 @@ import java.io.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class UnitFactory extends Block{
|
||||
protected UnitType unitType;
|
||||
protected float produceTime = 1000f;
|
||||
protected float launchVelocity = 0f;
|
||||
protected TextureRegion topRegion;
|
||||
protected int maxSpawn = 4;
|
||||
protected int[] capacities;
|
||||
public UnitType unitType;
|
||||
public float produceTime = 1000f;
|
||||
public float launchVelocity = 0f;
|
||||
public TextureRegion topRegion;
|
||||
public int maxSpawn = 4;
|
||||
public int[] capacities;
|
||||
|
||||
public UnitFactory(String name){
|
||||
super(name);
|
||||
|
||||
Reference in New Issue
Block a user