Successful desktop compilation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package io.anuke.mindustry;
|
||||
|
||||
import io.anuke.arc.ApplicationListener;
|
||||
import io.anuke.arc.ApplicationCore;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.util.Log;
|
||||
@@ -11,10 +11,10 @@ import io.anuke.mindustry.io.BundleLoader;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Mindustry implements ApplicationListener{
|
||||
private long lastFrameTime;
|
||||
public class Mindustry extends ApplicationCore{
|
||||
|
||||
public Mindustry(){
|
||||
@Override
|
||||
public void setup(){
|
||||
Time.setDeltaProvider(() -> {
|
||||
float result = Core.graphics.getDeltaTime() * 60f;
|
||||
return Float.isNaN(result) || Float.isInfinite(result) ? 1f : Math.min(result, 60f / 10f);
|
||||
@@ -28,26 +28,28 @@ public class Mindustry implements ApplicationListener{
|
||||
BundleLoader.load();
|
||||
content.load();
|
||||
|
||||
Core.app.addListener(logic = new Logic());
|
||||
Core.app.addListener(world = new World());
|
||||
Core.app.addListener(control = new Control());
|
||||
Core.app.addListener(renderer = new Renderer());
|
||||
Core.app.addListener(ui = new UI());
|
||||
Core.app.addListener(netServer = new NetServer());
|
||||
Core.app.addListener(netClient = new NetClient());
|
||||
add(logic = new Logic());
|
||||
add(world = new World());
|
||||
add(control = new Control());
|
||||
add(renderer = new Renderer());
|
||||
add(ui = new UI());
|
||||
add(netServer = new NetServer());
|
||||
add(netClient = new NetClient());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
Log.info("Time to load [total]: {0}", Time.elapsed());
|
||||
Events.fire(new GameLoadEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
lastFrameTime = Time.millis();
|
||||
long lastFrameTime = Time.millis();
|
||||
|
||||
//TODO ??render it all??
|
||||
super.update();
|
||||
|
||||
int fpsCap = Core.settings.getInt("fpscap", 125);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.content;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.entities.Effects;
|
||||
import io.anuke.arc.Graphics;
|
||||
import io.anuke.arc.graphics.Blending;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
@@ -202,14 +202,14 @@ public class Mechs implements ContentList{
|
||||
public void draw(Player player){
|
||||
if(player.shootHeat <= 0.01f) return;
|
||||
|
||||
float alpha = Core.batch.getColor().a;
|
||||
float alpha = Core.graphics.batch().getColor().a;
|
||||
Shaders.build.progress = player.shootHeat;
|
||||
Shaders.build.region = armorRegion;
|
||||
Shaders.build.time = Time.time() / 10f;
|
||||
Shaders.build.color.set(Palette.accent).a = player.shootHeat;
|
||||
Draw.shader(Shaders.build);
|
||||
Draw.alpha(1f);
|
||||
Draw.rect(armorRegion, player.snappedX(), player.snappedY(), player.rotation);
|
||||
Draw.rect(armorRegion, player.snappedX(), player.snappedY()).rot(player.rotation);
|
||||
Draw.shader(Shaders.mix);
|
||||
Draw.color(1f, 1f, 1f, alpha);
|
||||
}
|
||||
@@ -268,13 +268,11 @@ public class Mechs implements ContentList{
|
||||
public void draw(Player player){
|
||||
float scl = scld(player);
|
||||
if(scl < 0.01f) return;
|
||||
float alpha = Core.batch.getColor().a;
|
||||
float alpha = Core.graphics.batch().getColor().a;
|
||||
Draw.shader();
|
||||
Graphics.setAdditiveBlending();
|
||||
Draw.color(Palette.lancerLaser);
|
||||
Draw.alpha(scl/2f);
|
||||
Draw.rect(shield, player.snappedX() + Mathf.range(scl/2f), player.snappedY() + Mathf.range(scl/2f), player.rotation - 90);
|
||||
Graphics.setNormalBlending();
|
||||
Draw.rect(shield, player.snappedX() + Mathf.range(scl/2f), player.snappedY() + Mathf.range(scl/2f)).rot(player.rotation - 90).blend(Blending.additive);
|
||||
Draw.shader(Shaders.mix);
|
||||
Draw.color();
|
||||
Draw.alpha(alpha);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
ammoUseEffect = ShootFx.shellEjectSmall;
|
||||
health = 160;
|
||||
|
||||
drawer = (tile, entity) -> Draw.rect(entity.target != null ? shootRegion : region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
drawer = (tile, entity) -> Draw.rect(entity.target != null ? shootRegion : region, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -157,20 +157,25 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
ammoUseEffect = ShootFx.shellEjectBig;
|
||||
|
||||
drawer = (tile, entity) -> {
|
||||
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
float offsetx = (int) (Mathf.abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 3f);
|
||||
float offsety = -(int) (Mathf.abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 2f);
|
||||
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90);
|
||||
float offsetx = (int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 3f);
|
||||
float offsety = -(int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 2f);
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
float rot = entity.rotation + 90 * i;
|
||||
Draw.rect(panels[i == -1 ? 0 : 1],
|
||||
tile.drawx() + tr2.x + Angles.trnsx(rot, offsetx, offsety),
|
||||
tile.drawy() + tr2.y + Angles.trnsy(rot, -offsetx, offsety), entity.rotation - 90);
|
||||
tile.drawy() + tr2.y + Angles.trnsy(rot, -offsetx, offsety)).rot(entity.rotation - 90);
|
||||
}
|
||||
};
|
||||
|
||||
health = 360;
|
||||
}
|
||||
|
||||
/** Converts a value range from 0-1 to a value range 0-1-0. */
|
||||
float abscurve(float f){
|
||||
return 1f - Math.abs(f - 0.5f) * 2f;
|
||||
}
|
||||
};
|
||||
|
||||
ripple = new ArtilleryTurret("ripple"){{
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
package io.anuke.mindustry.content.bullets;
|
||||
|
||||
import io.anuke.arc.entities.Effects;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.CapStyle;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.content.fx.BlockFx;
|
||||
@@ -15,14 +23,10 @@ import io.anuke.mindustry.entities.effect.Fire;
|
||||
import io.anuke.mindustry.entities.effect.Lightning;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shapes;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.BuildBlock;
|
||||
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
||||
import io.anuke.arc.entities.Effects;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
@@ -342,10 +346,10 @@ public class TurretBullets extends BulletList implements ContentList{
|
||||
float w = 11f, h = 13f;
|
||||
|
||||
Draw.color(Palette.bulletYellowBack);
|
||||
Draw.rect("shell-back", b.x, b.y, w, h, b.angle() + 90);
|
||||
Draw.rect("shell-back", b.x, b.y, w, h).rot(b.angle() + 90);
|
||||
|
||||
Draw.color(Palette.bulletYellow);
|
||||
Draw.rect("shell", b.x, b.y, w, h, b.angle() + 90);
|
||||
Draw.rect("shell", b.x, b.y, w, h).rot(b.angle() + 90);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
@@ -379,7 +383,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
||||
float baseAngle = data.to.angleTo(data.from);
|
||||
|
||||
//if angles are nearby, then yes, it did
|
||||
if(Mathf.angNear(angleTo, baseAngle, 2f)){
|
||||
if(Angles.near(angleTo, baseAngle, 2f)){
|
||||
intersect = true;
|
||||
//snap bullet position back; this is used for low-FPS situations
|
||||
b.set(data.to.x + Angles.trnsx(baseAngle, hitDst), data.to.y + Angles.trnsy(baseAngle, hitDst));
|
||||
|
||||
@@ -263,14 +263,14 @@ public class BlockFx extends FxList implements ContentList{
|
||||
Draw.reset();
|
||||
});
|
||||
ripple = new GroundEffect(false, 30, e -> {
|
||||
Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f));
|
||||
Draw.color(Tmp.c1.set(e.color).shiftValue(0.1f));
|
||||
Lines.stroke(e.fout() + 0.4f);
|
||||
Lines.circle(e.x, e.y, 2f + e.fin() * 4f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
bubble = new Effect(20, e -> {
|
||||
Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f));
|
||||
Draw.color(Tmp.c1.set(e.color).shiftValue(0.1f));
|
||||
Lines.stroke(e.fout() + 0.2f);
|
||||
Angles.randLenVectors(e.id, 2, 8f, (x, y) -> {
|
||||
Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f);
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.anuke.arc.entities.Effects.Effect;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package io.anuke.mindustry.content.fx;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.arc.entities.Effects.Effect;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.graphics.Shapes;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shapes;
|
||||
|
||||
public class ShootFx extends FxList implements ContentList{
|
||||
public static Effect shootSmall, shootHeal, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke, shootBigSmoke2, shootSmallFlame, shootLiquid, shellEjectSmall, shellEjectMedium, shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot;
|
||||
@@ -111,7 +111,7 @@ public class ShootFx extends FxList implements ContentList{
|
||||
Draw.rect("white",
|
||||
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
|
||||
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
|
||||
1f, 2f, rot + e.fin() * 50f * i);
|
||||
1f, 2f).rot(rot + e.fin() * 50f * i);
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
@@ -125,7 +125,7 @@ public class ShootFx extends FxList implements ContentList{
|
||||
Draw.rect("casing",
|
||||
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
|
||||
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
|
||||
2f, 3f, rot);
|
||||
2f, 3f).rot(rot);
|
||||
}
|
||||
|
||||
Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin());
|
||||
@@ -148,8 +148,8 @@ public class ShootFx extends FxList implements ContentList{
|
||||
Draw.rect("casing",
|
||||
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
|
||||
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
|
||||
2.5f, 4f,
|
||||
rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin()));
|
||||
2.5f, 4f)
|
||||
.rot(rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin()));
|
||||
}
|
||||
|
||||
Draw.color(Color.LIGHT_GRAY);
|
||||
|
||||
@@ -57,11 +57,12 @@ public class Control implements ApplicationListener{
|
||||
unlocks = new Unlocks();
|
||||
|
||||
Core.input.setCatch(KeyCode.BACK, true);
|
||||
Core.keybinds.setDefaults(Binding.values());
|
||||
|
||||
Effects.setShakeFalloff(10000f);
|
||||
|
||||
content.initialize(Content::init);
|
||||
Core.atlas = new TextureAtlas("sprites.atlas");
|
||||
Core.atlas = new TextureAtlas("sprites/sprites.atlas");
|
||||
content.initialize(Content::load);
|
||||
|
||||
unlocks.load();
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.anuke.arc.entities.trait.DrawTrait;
|
||||
import io.anuke.arc.entities.trait.Entity;
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.function.Predicate;
|
||||
import io.anuke.arc.graphics.Camera;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
@@ -37,7 +38,6 @@ public class Renderer implements ApplicationListener{
|
||||
public final BlockRenderer blocks = new BlockRenderer();
|
||||
public final MinimapRenderer minimap = new MinimapRenderer();
|
||||
public final OverlayRenderer overlays = new OverlayRenderer();
|
||||
public final FogRenderer fog = new FogRenderer();
|
||||
|
||||
private Color clearColor;
|
||||
private int targetscale = baseCameraScale;
|
||||
@@ -45,6 +45,7 @@ public class Renderer implements ApplicationListener{
|
||||
private Vector2 avgPosition = new Vector2();
|
||||
|
||||
public Renderer(){
|
||||
camera = new Camera();
|
||||
Lines.setCircleVertices(14);
|
||||
|
||||
Shaders.init();
|
||||
@@ -285,11 +286,6 @@ public class Renderer implements ApplicationListener{
|
||||
camera.resize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
fog.dispose();
|
||||
}
|
||||
|
||||
public Vector2 averagePosition(){
|
||||
avgPosition.setZero();
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.Graphics.Cursor;
|
||||
import io.anuke.arc.Graphics.Cursor.SystemCursor;
|
||||
import io.anuke.arc.freetype.FreeTypeFontGenerator;
|
||||
import io.anuke.arc.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.Colors;
|
||||
@@ -24,7 +26,6 @@ import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.freetype.*;
|
||||
import io.anuke.mindustry.editor.MapEditorDialog;
|
||||
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
@@ -32,17 +33,18 @@ import io.anuke.mindustry.ui.dialogs.*;
|
||||
import io.anuke.mindustry.ui.fragments.*;
|
||||
|
||||
import static io.anuke.arc.scene.actions.Actions.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.disableUI;
|
||||
|
||||
public class UI implements ApplicationListener{
|
||||
private FreeTypeFontGenerator generator;
|
||||
|
||||
public final MenuFragment menufrag = new MenuFragment();
|
||||
public final HudFragment hudfrag = new HudFragment();
|
||||
public final ChatFragment chatfrag = new ChatFragment();
|
||||
public final PlayerListFragment listfrag = new PlayerListFragment();
|
||||
public final BackgroundFragment backfrag = new BackgroundFragment();
|
||||
public final LoadingFragment loadfrag = new LoadingFragment();
|
||||
public MenuFragment menufrag;
|
||||
public HudFragment hudfrag;
|
||||
public ChatFragment chatfrag;
|
||||
public PlayerListFragment listfrag;
|
||||
public BackgroundFragment backfrag;
|
||||
public LoadingFragment loadfrag;
|
||||
|
||||
public AboutDialog about;
|
||||
public RestartDialog restart;
|
||||
@@ -71,7 +73,7 @@ public class UI implements ApplicationListener{
|
||||
|
||||
public UI(){
|
||||
Skin skin = new Skin(Core.atlas);
|
||||
generateFonts();
|
||||
generateFonts(skin);
|
||||
skin.load(Core.files.internal("ui/uiskin.json"));
|
||||
|
||||
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
||||
@@ -120,7 +122,7 @@ public class UI implements ApplicationListener{
|
||||
Core.graphics.restoreCursor();
|
||||
}
|
||||
|
||||
void generateFonts(){
|
||||
void generateFonts(Skin skin){
|
||||
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/pixel.ttf"));
|
||||
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
||||
param.size = (int)(14*2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
||||
@@ -145,6 +147,13 @@ public class UI implements ApplicationListener{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
menufrag = new MenuFragment();
|
||||
hudfrag = new HudFragment();
|
||||
chatfrag = new ChatFragment();
|
||||
listfrag = new PlayerListFragment();
|
||||
backfrag = new BackgroundFragment();
|
||||
loadfrag = new LoadingFragment();
|
||||
|
||||
editor = new MapEditorDialog();
|
||||
controls = new ControlsDialog();
|
||||
restart = new RestartDialog();
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
import io.anuke.arc.util.IntSet;
|
||||
import io.anuke.arc.util.IntSet.IntSetIterator;
|
||||
import io.anuke.arc.util.Pack;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.graphics.IndexedRenderer;
|
||||
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Graphics;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.IndexedRenderer;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.arc.util.Bits;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
@@ -56,7 +55,7 @@ public class MapRenderer implements Disposable{
|
||||
|
||||
|
||||
public void draw(float tx, float ty, float tw, float th){
|
||||
Graphics.end();
|
||||
Draw.flush();
|
||||
|
||||
IntSetIterator it = updates.iterator();
|
||||
while(it.hasNext){
|
||||
@@ -79,15 +78,12 @@ public class MapRenderer implements Disposable{
|
||||
mesh = chunks[x][y];
|
||||
}
|
||||
|
||||
mesh.getTransformMatrix().setToTranslation(tx, ty, 0).scl(tw / (width * tilesize),
|
||||
th / (height * tilesize), 1f);
|
||||
mesh.setProjectionMatrix(Core.batch.getProjectionMatrix());
|
||||
mesh.getTransformMatrix().setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize));
|
||||
mesh.setProjectionMatrix(Core.graphics.batch().getProjection());
|
||||
|
||||
mesh.render(Core.atlas.getTextures().first());
|
||||
}
|
||||
}
|
||||
|
||||
Graphics.begin();
|
||||
}
|
||||
|
||||
public void updatePoint(int x, int y){
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
|
||||
import io.anuke.arc.Input.Buttons;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Batch;
|
||||
import io.anuke.arc.input.GestureDetector;
|
||||
import io.anuke.arc.input.GestureDetector.GestureListener;
|
||||
import io.anuke.arc.math.Bresenham2;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.math.geom.Rectangle;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.mindustry.editor.DrawOperation.TileOperation;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.ui.GridImage;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Graphics;
|
||||
import io.anuke.arc.Inputs;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.graphics.g2d.ScissorStack;
|
||||
import io.anuke.arc.input.GestureDetector;
|
||||
import io.anuke.arc.input.GestureDetector.GestureListener;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.event.InputEvent;
|
||||
import io.anuke.arc.scene.event.InputListener;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.TextField;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.mindustry.editor.DrawOperation.TileOperation;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.ui.GridImage;
|
||||
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
@@ -60,7 +55,7 @@ public class MapView extends Element implements GestureListener{
|
||||
brushPolygons[i] = Geometry.pixelCircle(size, (index, x, y) -> Mathf.dst(x, y, index, index) <= index - 0.5f);
|
||||
}
|
||||
|
||||
Core.input.addProcessor(0, new GestureDetector(20, 0.5f, 2, 0.15f, this));
|
||||
Core.input.getInputProcessors().insert(0, new GestureDetector(20, 0.5f, 2, 0.15f, this));
|
||||
touchable(Touchable.enabled);
|
||||
|
||||
addListener(new InputListener(){
|
||||
@@ -74,16 +69,16 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button){
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
if(pointer != 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!mobile && button != Buttons.LEFT && button != Buttons.MIDDLE){
|
||||
if(!mobile && button != KeyCode.MOUSE_LEFT && button != KeyCode.MOUSE_MIDDLE){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(button == Buttons.MIDDLE){
|
||||
if(button == KeyCode.MOUSE_MIDDLE){
|
||||
lastTool = tool;
|
||||
tool = EditorTool.zoom;
|
||||
}
|
||||
@@ -112,8 +107,8 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button){
|
||||
if(!mobile && button != Buttons.LEFT && button != Buttons.MIDDLE){
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
if(!mobile && button != KeyCode.MOUSE_LEFT && button != KeyCode.MOUSE_MIDDLE){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -214,16 +209,16 @@ public class MapView extends Element implements GestureListener{
|
||||
super.act(delta);
|
||||
|
||||
if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) &&
|
||||
!Core.input.keyDown(io.anuke.arc.input.Input.CONTROL_LEFT)){
|
||||
float ax = Core.input.getAxis("move_x");
|
||||
float ay = Core.input.getAxis("move_y");
|
||||
!Core.input.keyDown(KeyCode.CONTROL_LEFT)){
|
||||
float ax = Core.input.axis(Binding.move_x);
|
||||
float ay = Core.input.axis(Binding.move_y);
|
||||
offsetx -= ax * 15f / zoom;
|
||||
offsety -= ay * 15f / zoom;
|
||||
}
|
||||
|
||||
if(ui.editor.hasPane()) return;
|
||||
|
||||
zoom += Core.input.scroll() / 10f * zoom;
|
||||
zoom += Core.input.axis(KeyCode.SCROLL) / 10f * zoom;
|
||||
clampZoom();
|
||||
}
|
||||
|
||||
@@ -258,7 +253,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float alpha){
|
||||
public void draw(){
|
||||
float ratio = 1f / ((float) editor.getMap().width() / editor.getMap().height());
|
||||
float size = Math.min(width, height);
|
||||
float sclwidth = size * zoom;
|
||||
@@ -268,7 +263,9 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
image.setImageSize(editor.getMap().width(), editor.getMap().height());
|
||||
|
||||
Graphics.beginClip(x, y, width, height);
|
||||
if(!ScissorStack.pushScissors(rect.set(x, y, width, height))){
|
||||
return;
|
||||
}
|
||||
|
||||
Draw.color(Palette.remove);
|
||||
Lines.stroke(2f);
|
||||
@@ -279,7 +276,7 @@ public class MapView extends Element implements GestureListener{
|
||||
if(grid){
|
||||
Draw.color(Color.GRAY);
|
||||
image.setBounds(centerx - sclwidth / 2, centery - sclheight / 2, sclwidth, sclheight);
|
||||
image.draw(batch, alpha);
|
||||
image.draw();
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@@ -323,8 +320,6 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
Graphics.endClip();
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
Lines.stroke(Unit.dp.scl(3f));
|
||||
Lines.rect(x, y, width, height);
|
||||
@@ -335,27 +330,7 @@ public class MapView extends Element implements GestureListener{
|
||||
return Core.scene.getKeyboardFocus() != null
|
||||
&& Core.scene.getKeyboardFocus().isDescendantOf(ui.editor)
|
||||
&& ui.editor.isShown() && tool == EditorTool.zoom &&
|
||||
Core.scene.hit(Graphics.mouse().x, Graphics.mouse().y, true) == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDown(float x, float y, int pointer, int button){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count, int button){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean longPress(float x, float y){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fling(float velocityX, float velocityY, int button){
|
||||
return false;
|
||||
Core.scene.hit(Core.input.mouse().x, Core.input.mouse().y, true) == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -366,11 +341,6 @@ public class MapView extends Element implements GestureListener{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean panStop(float x, float y, int pointer, int button){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean zoom(float initialDistance, float distance){
|
||||
if(!active()) return false;
|
||||
|
||||
@@ -34,9 +34,9 @@ public class ArtilleryBulletType extends BasicBulletType{
|
||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||
|
||||
Draw.color(backColor);
|
||||
Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
|
||||
Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale).rot(b.angle() - 90);
|
||||
Draw.color(frontColor);
|
||||
Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
|
||||
Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale).rot(b.angle() - 90);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.anuke.arc.entities.EntityGroup;
|
||||
import io.anuke.arc.entities.impl.TimedEntity;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Point2
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.pooling.Pool.Poolable;
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.game.EventType.BuildSelectEvent;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shapes;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
@@ -353,8 +354,8 @@ public interface BuilderTrait extends Entity{
|
||||
float ey = tile.worldy() + Mathf.sin(Time.time() + 48, swingScl + 2f, swingMag);
|
||||
|
||||
Draw.color(Color.LIGHT_GRAY, Color.WHITE, 1f - flashScl + Mathf.absin(Time.time(), 0.5f, flashScl));
|
||||
//TODO better laser drawing functions
|
||||
//Shapes.laser("minelaser", "minelaser-end", px, py, ex, ey);
|
||||
|
||||
Shapes.laser("minelaser", "minelaser-end", px, py, ex, ey);
|
||||
|
||||
if(unit instanceof Player && ((Player) unit).isLocal){
|
||||
Lines.stroke(1f, Palette.accent);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
@@ -12,11 +16,6 @@ import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -155,7 +154,7 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
Draw.rect(type.legRegion,
|
||||
x + Angles.trnsx(baseRotation, ft * i),
|
||||
y + Angles.trnsy(baseRotation, ft * i),
|
||||
12f * i, 12f - Mathf.clamp(ft * i, 0, 2), baseRotation - 90);
|
||||
12f * i, 12f - Mathf.clamp(ft * i, 0, 2)).rot(baseRotation - 90);
|
||||
}
|
||||
|
||||
if(floor.isLiquid){
|
||||
@@ -164,16 +163,16 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
Draw.tint(Color.WHITE);
|
||||
}
|
||||
|
||||
Draw.rect(type.baseRegion, x, y, baseRotation - 90);
|
||||
Draw.rect(type.baseRegion, x, y).rot(baseRotation - 90);
|
||||
|
||||
Draw.rect(type.region, x, y, rotation - 90);
|
||||
Draw.rect(type.region, x, y).rot(rotation - 90);
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
float tra = rotation - 90, trY = -weapon.getRecoil(this, i > 0) + type.weaponOffsetY;
|
||||
float w = i > 0 ? -12 : 12;
|
||||
Draw.rect(weapon.equipRegion,
|
||||
x + Angles.trnsx(tra, type.weaponOffsetX * i, trY),
|
||||
y + Angles.trnsy(tra, type.weaponOffsetX * i, trY), w, 12, rotation - 90);
|
||||
y + Angles.trnsy(tra, type.weaponOffsetX * i, trY), w, 12).rot(rotation - 90);
|
||||
}
|
||||
|
||||
drawItems();
|
||||
@@ -191,7 +190,7 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
if(dst(target) < getWeapon().getAmmo().getRange()){
|
||||
rotate(angleTo(target));
|
||||
|
||||
if(Mathf.angNear(angleTo(target), rotation, 13f)){
|
||||
if(Angles.near(angleTo(target), rotation, 13f)){
|
||||
AmmoType ammo = getWeapon().getAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.bullet.speed);
|
||||
|
||||
@@ -163,7 +163,6 @@ public class Saves{
|
||||
|
||||
public void save(){
|
||||
long time = totalPlaytime;
|
||||
renderer.fog.writeFog();
|
||||
long prev = totalPlaytime;
|
||||
totalPlaytime = time;
|
||||
|
||||
|
||||
@@ -2,19 +2,22 @@ package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.Graphics;
|
||||
import io.anuke.arc.collection.IntArray;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||
import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.arc.graphics.Camera;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.GL20;
|
||||
import io.anuke.arc.graphics.g2d.CacheBatch;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.graphics.g2d.SpriteBatch;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
@@ -33,7 +36,7 @@ public class FloorRenderer{
|
||||
private IntArray drawnLayers = new IntArray();
|
||||
|
||||
public FloorRenderer(){
|
||||
Events.on(WorldLoadGraphicsEvent.class, event -> clearTiles());
|
||||
Events.on(WorldLoadEvent.class, event -> clearTiles());
|
||||
}
|
||||
|
||||
public void drawFloor(){
|
||||
@@ -41,13 +44,13 @@ public class FloorRenderer{
|
||||
return;
|
||||
}
|
||||
|
||||
OrthographicCamera camera = Core.camera;
|
||||
Camera camera = Core.camera;
|
||||
|
||||
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
||||
int crangey = (int) (camera.height / (chunksize * tilesize)) + 1;
|
||||
|
||||
int camx = Mathf.scl(camera.position.x, chunksize * tilesize);
|
||||
int camy = Mathf.scl(camera.position.y, chunksize * tilesize);
|
||||
int camx = (int)(camera.position.x / (chunksize * tilesize));
|
||||
int camy = (int)(camera.position.y / (chunksize * tilesize));
|
||||
|
||||
int layers = CacheLayer.values().length;
|
||||
|
||||
@@ -81,7 +84,7 @@ public class FloorRenderer{
|
||||
|
||||
drawnLayers.sort();
|
||||
|
||||
Graphics.end();
|
||||
Draw.flush();
|
||||
beginDraw();
|
||||
|
||||
for(int i = 0; i < drawnLayers.size; i++){
|
||||
@@ -91,7 +94,6 @@ public class FloorRenderer{
|
||||
}
|
||||
|
||||
endDraw();
|
||||
Graphics.begin();
|
||||
}
|
||||
|
||||
public void beginDraw(){
|
||||
@@ -99,7 +101,7 @@ public class FloorRenderer{
|
||||
return;
|
||||
}
|
||||
|
||||
cbatch.setProjectionMatrix(Core.camera.combined);
|
||||
cbatch.setProjection(Core.camera.projection());
|
||||
cbatch.beginDraw();
|
||||
|
||||
Core.gl.glEnable(GL20.GL_BLEND);
|
||||
@@ -118,7 +120,7 @@ public class FloorRenderer{
|
||||
return;
|
||||
}
|
||||
|
||||
OrthographicCamera camera = Core.camera;
|
||||
Camera camera = Core.camera;
|
||||
|
||||
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
||||
int crangey = (int) (camera.height / (chunksize * tilesize)) + 1;
|
||||
@@ -127,8 +129,8 @@ public class FloorRenderer{
|
||||
|
||||
for(int x = -crangex; x <= crangex; x++){
|
||||
for(int y = -crangey; y <= crangey; y++){
|
||||
int worldx = Mathf.scl(camera.position.x, chunksize * tilesize) + x;
|
||||
int worldy = Mathf.scl(camera.position.y, chunksize * tilesize) + y;
|
||||
int worldx = (int)(camera.position.x / (chunksize * tilesize)) + x;
|
||||
int worldy = (int)(camera.position.y / (chunksize * tilesize)) + y;
|
||||
|
||||
if(!Structs.inBounds(worldx, worldy, cache)){
|
||||
continue;
|
||||
@@ -145,7 +147,7 @@ public class FloorRenderer{
|
||||
|
||||
private void fillChunk(float x, float y){
|
||||
Draw.color(Color.BLACK);
|
||||
Fill.crect(x, y, chunksize * tilesize, chunksize * tilesize);
|
||||
Fill.rect().set(x, y, chunksize * tilesize, chunksize * tilesize);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@@ -172,11 +174,8 @@ public class FloorRenderer{
|
||||
}
|
||||
|
||||
private void cacheChunkLayer(int cx, int cy, Chunk chunk, CacheLayer layer){
|
||||
|
||||
Graphics.useBatch(cbatch);
|
||||
cbatch.begin();
|
||||
|
||||
Sector sector = world.getSector();
|
||||
SpriteBatch current = Core.graphics.batch();
|
||||
Core.graphics.useBatch(cbatch);
|
||||
|
||||
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
|
||||
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
||||
@@ -196,10 +195,8 @@ public class FloorRenderer{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cbatch.end();
|
||||
Graphics.popBatch();
|
||||
chunk.caches[layer.ordinal()] = cbatch.getLastCache();
|
||||
Core.graphics.useBatch(current);
|
||||
chunk.caches[layer.ordinal()] = cbatch.flushCache();
|
||||
}
|
||||
|
||||
public void clearTiles(){
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.Graphics;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.entities.EntityDraw;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.GL20;
|
||||
import io.anuke.arc.graphics.Pixmap.Format;
|
||||
import io.anuke.arc.graphics.Texture;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
/**Used for rendering fog of war. A framebuffer is used for this.*/
|
||||
public class FogRenderer implements Disposable{
|
||||
private TextureRegion region = new TextureRegion();
|
||||
private FrameBuffer buffer;
|
||||
private ByteBuffer pixelBuffer;
|
||||
private Array<Tile> changeQueue = new Array<>();
|
||||
private int shadowPadding;
|
||||
private boolean dirty;
|
||||
|
||||
public FogRenderer(){
|
||||
Events.on(WorldLoadEvent.class, event -> {
|
||||
dispose();
|
||||
|
||||
shadowPadding = -1;
|
||||
|
||||
buffer = new FrameBuffer(Format.RGBA8888, world.width(), world.height(), false);
|
||||
changeQueue.clear();
|
||||
|
||||
//clear buffer to black
|
||||
buffer.begin();
|
||||
Core.graphics.clear(0, 0, 0, 1f);
|
||||
buffer.end();
|
||||
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile.getTeam() == players[0].getTeam() && tile.block().synthetic() && tile.block().viewRange > 0){
|
||||
changeQueue.add(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pixelBuffer = ByteBuffer.allocateDirect(world.width() * world.height() * 4);
|
||||
dirty = true;
|
||||
});
|
||||
|
||||
Events.on(TileChangeEvent.class, event -> {
|
||||
if(event.tile.getTeam() == players[0].getTeam() && event.tile.block().synthetic() && event.tile.block().viewRange > 0){
|
||||
changeQueue.add(event.tile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void writeFog(){
|
||||
if(buffer == null) return;
|
||||
|
||||
buffer.begin();
|
||||
pixelBuffer.position(0);
|
||||
Core.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1);
|
||||
Core.gl.glReadPixels(0, 0, world.width(), world.height(), GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
|
||||
pixelBuffer.position(0);
|
||||
for(int i = 0; i < world.width() * world.height(); i++){
|
||||
int x = i % world.width();
|
||||
int y = i / world.width();
|
||||
byte r = pixelBuffer.get();
|
||||
if(r != 0){
|
||||
world.tile(x, y).setVisibility((byte)1);
|
||||
}
|
||||
pixelBuffer.position(pixelBuffer.position() + 3);
|
||||
}
|
||||
buffer.end();
|
||||
}
|
||||
|
||||
public int getPadding(){
|
||||
return -shadowPadding;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
if(buffer == null) return;
|
||||
|
||||
float vw = Core.camera.width ;
|
||||
float vh = Core.camera.height ;
|
||||
|
||||
float px = Core.camera.position.x - vw / 2f;
|
||||
float py = Core.camera.position.y - vh / 2f;
|
||||
|
||||
float u = (px / tilesize) / buffer.getWidth();
|
||||
float v = (py / tilesize) / buffer.getHeight();
|
||||
|
||||
float u2 = ((px + vw) / tilesize) / buffer.getWidth();
|
||||
float v2 = ((py + vh) / tilesize) / buffer.getHeight();
|
||||
|
||||
Core.batch.getProjectionMatrix().setToOrtho2D(0, 0, buffer.getWidth() * tilesize, buffer.getHeight() * tilesize);
|
||||
|
||||
Draw.color(Color.WHITE);
|
||||
|
||||
buffer.begin();
|
||||
|
||||
Graphics.beginClip((-shadowPadding), (-shadowPadding), (world.width() + shadowPadding*2), (world.height() + shadowPadding*2));
|
||||
|
||||
Graphics.begin();
|
||||
EntityDraw.setClip(false);
|
||||
|
||||
renderer.drawAndInterpolate(playerGroup, player -> !player.isDead() && player.getTeam() == players[0].getTeam(), Unit::drawView);
|
||||
renderer.drawAndInterpolate(unitGroups[players[0].getTeam().ordinal()], unit -> !unit.isDead(), Unit::drawView);
|
||||
|
||||
for(Tile tile : changeQueue){
|
||||
float viewRange = tile.block().viewRange;
|
||||
if(viewRange < 0) continue;
|
||||
Fill.circle(tile.drawx(), tile.drawy(), tile.block().viewRange);
|
||||
}
|
||||
|
||||
changeQueue.clear();
|
||||
|
||||
if(dirty){
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile.discovered()){
|
||||
Fill.rect(tile.worldx(), tile.worldy(), tilesize, tilesize);
|
||||
}
|
||||
}
|
||||
}
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
EntityDraw.setClip(true);
|
||||
Graphics.end();
|
||||
buffer.end();
|
||||
|
||||
Graphics.endClip();
|
||||
|
||||
region.setTexture(buffer.getTexture());
|
||||
region.setRegion(u, v2, u2, v);
|
||||
|
||||
Core.batch.setProjectionMatrix(Core.camera.combined);
|
||||
Draw.shader(Shaders.fog);
|
||||
renderer.pixelSurface.getBuffer().begin();
|
||||
Graphics.begin();
|
||||
|
||||
Core.batch.draw(region, px, py, vw, vh);
|
||||
|
||||
Graphics.end();
|
||||
renderer.pixelSurface.getBuffer().end();
|
||||
Draw.shader();
|
||||
|
||||
Graphics.setScreen();
|
||||
Core.batch.draw(renderer.pixelSurface.texture(), 0, Core.graphics.getHeight(), Core.graphics.getWidth(), -Core.graphics.getHeight());
|
||||
Graphics.end();
|
||||
}
|
||||
|
||||
public Texture getTexture(){
|
||||
return buffer.getTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
if(buffer != null) buffer.dispose();
|
||||
}
|
||||
}
|
||||
248
core/src/io/anuke/mindustry/graphics/IndexedRenderer.java
Normal file
248
core/src/io/anuke/mindustry/graphics/IndexedRenderer.java
Normal file
@@ -0,0 +1,248 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.VertexAttributes.Usage;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.graphics.glutils.Shader;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.Matrix3;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
|
||||
//TODO this class is a trainwreck, remove it
|
||||
public class IndexedRenderer implements Disposable{
|
||||
private final static int vsize = 5;
|
||||
|
||||
private Shader program = createDefaultShader();
|
||||
private Mesh mesh;
|
||||
private float[] tmpVerts = new float[vsize * 6];
|
||||
private float[] vertices;
|
||||
|
||||
private Matrix3 projMatrix = new Matrix3();
|
||||
private Matrix3 transMatrix = new Matrix3();
|
||||
private Matrix3 combined = new Matrix3();
|
||||
private float color = Color.WHITE.toFloatBits();
|
||||
|
||||
public IndexedRenderer(int sprites){
|
||||
resize(sprites);
|
||||
}
|
||||
|
||||
static public Shader createDefaultShader(){
|
||||
String vertexShader = "attribute vec4 " + Shader.POSITION_ATTRIBUTE + ";\n" //
|
||||
+ "attribute vec2 " + Shader.TEXCOORD_ATTRIBUTE + "0;\n" //
|
||||
+ "uniform mat4 u_projTrans;\n" //
|
||||
+ "varying vec2 v_texCoords;\n" //
|
||||
+ "\n" //
|
||||
+ "void main()\n" //
|
||||
+ "{\n" //
|
||||
+ " v_texCoords = " + Shader.TEXCOORD_ATTRIBUTE + "0;\n" //
|
||||
+ " gl_Position = u_projTrans * " + Shader.POSITION_ATTRIBUTE + ";\n" //
|
||||
+ "}\n";
|
||||
String fragmentShader = "#ifdef GL_ES\n" //
|
||||
+ "#define LOWP lowp\n" //
|
||||
+ "precision mediump float;\n" //
|
||||
+ "#else\n" //
|
||||
+ "#define LOWP \n" //
|
||||
+ "#endif\n" //
|
||||
+ "varying vec2 v_texCoords;\n" //
|
||||
+ "uniform sampler2D u_texture;\n" //
|
||||
+ "void main()\n"//
|
||||
+ "{\n" //
|
||||
+ " gl_FragColor = texture2D(u_texture, v_texCoords);\n" //
|
||||
+ "}";
|
||||
|
||||
return new Shader(vertexShader, fragmentShader);
|
||||
}
|
||||
|
||||
public void render(Texture texture){
|
||||
Core.gl.glEnable(GL20.GL_BLEND);
|
||||
|
||||
updateMatrix();
|
||||
|
||||
program.begin();
|
||||
|
||||
texture.bind();
|
||||
|
||||
program.setUniformMatrix("u_projTrans", combined);
|
||||
program.setUniformi("u_texture", 0);
|
||||
|
||||
mesh.render(program, GL20.GL_TRIANGLES, 0, vertices.length / 5);
|
||||
|
||||
program.end();
|
||||
}
|
||||
|
||||
public void setColor(Color color){
|
||||
this.color = color.toFloatBits();
|
||||
}
|
||||
|
||||
public void draw(int index, TextureRegion region, float x, float y, float w, float h){
|
||||
final float fx2 = x + w;
|
||||
final float fy2 = y + h;
|
||||
final float u = region.getU();
|
||||
final float v = region.getV2();
|
||||
final float u2 = region.getU2();
|
||||
final float v2 = region.getV();
|
||||
|
||||
float[] vertices = tmpVerts;
|
||||
|
||||
int idx = 0;
|
||||
vertices[idx++] = x;
|
||||
vertices[idx++] = y;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = x;
|
||||
vertices[idx++] = fy2;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
vertices[idx++] = fx2;
|
||||
vertices[idx++] = fy2;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
//tri2
|
||||
vertices[idx++] = x;
|
||||
vertices[idx++] = y;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = fx2;
|
||||
vertices[idx++] = y;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = fx2;
|
||||
vertices[idx++] = fy2;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
mesh.updateVertices(index * vsize * 6, vertices);
|
||||
}
|
||||
|
||||
public void draw(int index, TextureRegion region, float x, float y, float w, float h, float rotation){
|
||||
final float u = region.getU();
|
||||
final float v = region.getV2();
|
||||
final float u2 = region.getU2();
|
||||
final float v2 = region.getV();
|
||||
|
||||
final float originX = w / 2, originY = h / 2;
|
||||
|
||||
final float cos = Mathf.cosDeg(rotation);
|
||||
final float sin = Mathf.sinDeg(rotation);
|
||||
|
||||
float fx = -originX;
|
||||
float fy = -originY;
|
||||
float fx2 = w - originX;
|
||||
float fy2 = h - originY;
|
||||
|
||||
final float worldOriginX = x + originX;
|
||||
final float worldOriginY = y + originY;
|
||||
|
||||
float x1 = cos * fx - sin * fy;
|
||||
float y1 = sin * fx + cos * fy;
|
||||
|
||||
float x2 = cos * fx - sin * fy2;
|
||||
float y2 = sin * fx + cos * fy2;
|
||||
|
||||
float x3 = cos * fx2 - sin * fy2;
|
||||
float y3 = sin * fx2 + cos * fy2;
|
||||
|
||||
float x4 = x1 + (x3 - x2);
|
||||
float y4 = y3 - (y2 - y1);
|
||||
|
||||
x1 += worldOriginX;
|
||||
y1 += worldOriginY;
|
||||
x2 += worldOriginX;
|
||||
y2 += worldOriginY;
|
||||
x3 += worldOriginX;
|
||||
y3 += worldOriginY;
|
||||
x4 += worldOriginX;
|
||||
y4 += worldOriginY;
|
||||
|
||||
float[] vertices = tmpVerts;
|
||||
|
||||
int idx = 0;
|
||||
vertices[idx++] = x1;
|
||||
vertices[idx++] = y1;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = x3;
|
||||
vertices[idx++] = y3;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
vertices[idx++] = x4;
|
||||
vertices[idx++] = y4;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
//tri2
|
||||
vertices[idx++] = x1;
|
||||
vertices[idx++] = y1;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = x2;
|
||||
vertices[idx++] = y2;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = x3;
|
||||
vertices[idx++] = y3;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
mesh.updateVertices(index * vsize * 6, vertices);
|
||||
}
|
||||
|
||||
public Matrix3 getTransformMatrix(){
|
||||
return transMatrix;
|
||||
}
|
||||
|
||||
public void setTransformMatrix(Matrix3 matrix){
|
||||
transMatrix = matrix;
|
||||
}
|
||||
|
||||
public Matrix3 getProjectionMatrix(){
|
||||
return projMatrix;
|
||||
}
|
||||
|
||||
public void setProjectionMatrix(Matrix3 matrix){
|
||||
projMatrix = matrix;
|
||||
}
|
||||
|
||||
public void resize(int sprites){
|
||||
if(mesh != null) mesh.dispose();
|
||||
|
||||
mesh = new Mesh(true, 6 * sprites, 0,
|
||||
new VertexAttribute(Usage.Position, 2, "a_position"),
|
||||
new VertexAttribute(Usage.ColorPacked, 4, "a_color"),
|
||||
new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0"));
|
||||
vertices = new float[6 * sprites * vsize];
|
||||
mesh.setVertices(vertices);
|
||||
}
|
||||
|
||||
private void updateMatrix(){
|
||||
combined.set(projMatrix).mul(transMatrix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
mesh.dispose();
|
||||
program.dispose();
|
||||
}
|
||||
}
|
||||
@@ -37,11 +37,11 @@ public class Shaders{
|
||||
build = new UnitBuild();
|
||||
mix = new MixShader();
|
||||
fog = new FogShader();
|
||||
fullMix = new Shader("fullmix", "default");
|
||||
fullMix = new LoadShader("fullmix", "default");
|
||||
menu = new MenuShader();
|
||||
}
|
||||
|
||||
public static class MenuShader extends Shader{
|
||||
public static class MenuShader extends LoadShader{
|
||||
float time = 0f;
|
||||
|
||||
public MenuShader(){
|
||||
@@ -60,13 +60,13 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class FogShader extends Shader{
|
||||
public static class FogShader extends LoadShader{
|
||||
public FogShader(){
|
||||
super("fog", "default");
|
||||
}
|
||||
}
|
||||
|
||||
public static class MixShader extends Shader{
|
||||
public static class MixShader extends LoadShader{
|
||||
public Color color = new Color(Color.WHITE);
|
||||
|
||||
public MixShader(){
|
||||
@@ -93,7 +93,7 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnitBuild extends Shader{
|
||||
public static class UnitBuild extends LoadShader{
|
||||
public float progress, time;
|
||||
public Color color = new Color();
|
||||
public TextureRegion region;
|
||||
@@ -113,8 +113,9 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class Outline extends Shader{
|
||||
public static class Outline extends LoadShader{
|
||||
public Color color = new Color();
|
||||
public TextureRegion region = new TextureRegion();
|
||||
|
||||
public Outline(){
|
||||
super("outline", "default");
|
||||
@@ -127,9 +128,10 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockBuild extends Shader{
|
||||
public static class BlockBuild extends LoadShader{
|
||||
public Color color = new Color();
|
||||
public float progress;
|
||||
public TextureRegion region = new TextureRegion();
|
||||
|
||||
public BlockBuild(){
|
||||
super("blockbuild", "default");
|
||||
@@ -146,8 +148,9 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockPreview extends Shader{
|
||||
public static class BlockPreview extends LoadShader{
|
||||
public Color color = new Color();
|
||||
public TextureRegion region = new TextureRegion();
|
||||
|
||||
public BlockPreview(){
|
||||
super("blockpreview", "default");
|
||||
@@ -162,7 +165,7 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class Shield extends Shader{
|
||||
public static class Shield extends LoadShader{
|
||||
|
||||
public Shield(){
|
||||
super("shield", "default");
|
||||
@@ -180,7 +183,7 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class SurfaceShader extends Shader{
|
||||
public static class SurfaceShader extends LoadShader{
|
||||
|
||||
public SurfaceShader(String frag){
|
||||
super(frag, "default");
|
||||
@@ -196,4 +199,10 @@ public class Shaders{
|
||||
setUniformf("time", Time.time());
|
||||
}
|
||||
}
|
||||
|
||||
public static class LoadShader extends Shader{
|
||||
public LoadShader(String frag, String vert){
|
||||
super(Core.files.internal("shaders/" + vert + ".vertex"), Core.files.internal("shaders/" + frag + ".fragment"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
39
core/src/io/anuke/mindustry/graphics/Shapes.java
Normal file
39
core/src/io/anuke/mindustry/graphics/Shapes.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.CapStyle;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
|
||||
//TODO remove
|
||||
public class Shapes{
|
||||
|
||||
public static void laser(String line, String edge, float x, float y, float x2, float y2, float scale){
|
||||
laser(line, edge, x, y, x2, y2, Mathf.atan2(x2 - x, y2 - y), scale);
|
||||
}
|
||||
|
||||
public static void laser(String line, String edge, float x, float y, float x2, float y2){
|
||||
laser(line, edge, x, y, x2, y2, Mathf.atan2(x2 - x, y2 - y), 1f);
|
||||
}
|
||||
|
||||
public static void laser(String line, String edge, float x, float y, float x2, float y2, float rotation, float scale){
|
||||
|
||||
Lines.stroke(12f * scale);
|
||||
Lines.line(Core.atlas.find(line), x, y, x2, y2, CapStyle.none, 0f);
|
||||
Lines.stroke(1f);
|
||||
|
||||
TextureRegion region = Core.atlas.find(edge);
|
||||
|
||||
Draw.rect(edge, x, y, region.getWidth() * Draw.scl, region.getHeight() * scale * Draw.scl).rot(rotation + 180);
|
||||
|
||||
Draw.rect(edge, x2, y2, region.getWidth() * Draw.scl, region.getHeight() * scale * Draw.scl).rot(rotation);
|
||||
}
|
||||
|
||||
public static void tri(float x, float y, float width, float length, float rotation){
|
||||
float oy = 17f / 63f * length;
|
||||
Core.graphics.batch().draw().tex(Core.atlas.find("shape-3")).pos(x - width / 2f, y - oy)
|
||||
.origin(width / 2f, oy).size(width, length).rot(rotation - 90);
|
||||
}
|
||||
}
|
||||
@@ -86,28 +86,6 @@ public abstract class SaveFileVersion{
|
||||
i += consecutives;
|
||||
}
|
||||
}
|
||||
|
||||
//write visibility, length-run encoded
|
||||
for(int i = 0; i < world.width() * world.height(); i++){
|
||||
Tile tile = world.tile(i % world.width(), i / world.width());
|
||||
boolean discovered = tile.discovered();
|
||||
|
||||
int consecutives = 0;
|
||||
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 32767*2-1; j++){
|
||||
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
||||
|
||||
if(nextTile.discovered() != discovered){
|
||||
break;
|
||||
}
|
||||
|
||||
consecutives++;
|
||||
}
|
||||
|
||||
stream.writeBoolean(discovered);
|
||||
stream.writeShort(consecutives);
|
||||
i += consecutives;
|
||||
}
|
||||
}
|
||||
|
||||
public void readMap(DataInputStream stream) throws IOException{
|
||||
@@ -175,18 +153,6 @@ public abstract class SaveFileVersion{
|
||||
tiles[x][y] = tile;
|
||||
}
|
||||
|
||||
for(int i = 0; i < width * height; i++){
|
||||
boolean discovered = stream.readBoolean();
|
||||
int consecutives = stream.readUnsignedShort();
|
||||
if(discovered){
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
tiles[newx][newy].setVisibility((byte) 1);
|
||||
}
|
||||
}
|
||||
i += consecutives;
|
||||
}
|
||||
|
||||
content.setTemporaryMapper(null);
|
||||
world.endMapLoad();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.anuke.mindustry.maps;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.GridMap;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
@@ -30,7 +29,7 @@ public class SectorPresets{
|
||||
|
||||
//command center mission
|
||||
add(new SectorPreset(0, 1,
|
||||
Structs.array(
|
||||
Array.ofRecursive(
|
||||
Missions.blockRecipe(UnitBlocks.daggerFactory),
|
||||
new UnitMission(UnitTypes.dagger),
|
||||
Missions.blockRecipe(UnitBlocks.commandCenter),
|
||||
@@ -42,7 +41,7 @@ public class SectorPresets{
|
||||
|
||||
//pad mission
|
||||
add(new SectorPreset(0, -2,
|
||||
Structs.array(
|
||||
Array.ofRecursive(
|
||||
Missions.blockRecipe(mobile ? UpgradeBlocks.alphaPad : UpgradeBlocks.dartPad),
|
||||
new MechMission(mobile ? Mechs.alpha : Mechs.dart),
|
||||
new WaveMission(15)
|
||||
@@ -51,7 +50,7 @@ public class SectorPresets{
|
||||
|
||||
//oil mission
|
||||
add(new SectorPreset(-2, 0,
|
||||
Structs.array(
|
||||
Array.ofRecursive(
|
||||
Missions.blockRecipe(ProductionBlocks.cultivator),
|
||||
Missions.blockRecipe(ProductionBlocks.waterExtractor),
|
||||
new ContentMission(Items.biomatter),
|
||||
|
||||
@@ -93,28 +93,6 @@ public class NetworkIO{
|
||||
}
|
||||
}
|
||||
|
||||
//write visibility, length-run encoded
|
||||
for(int i = 0; i < world.width() * world.height(); i++){
|
||||
Tile tile = world.tile(i % world.width(), i / world.width());;
|
||||
boolean discovered = tile.discovered();
|
||||
|
||||
int consecutives = 0;
|
||||
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 32767*2-1; j++){
|
||||
Tile nextTile = world.tile(j % world.width(), j / world.width());;
|
||||
|
||||
if(nextTile.discovered() != discovered){
|
||||
break;
|
||||
}
|
||||
|
||||
consecutives++;
|
||||
}
|
||||
|
||||
stream.writeBoolean(discovered);
|
||||
stream.writeShort(consecutives);
|
||||
i += consecutives;
|
||||
}
|
||||
|
||||
stream.write(Team.all.length);
|
||||
|
||||
//write team data
|
||||
@@ -247,18 +225,6 @@ public class NetworkIO{
|
||||
tiles[x][y] = tile;
|
||||
}
|
||||
|
||||
for(int i = 0; i < width * height; i++){
|
||||
boolean discovered = stream.readBoolean();
|
||||
int consecutives = stream.readUnsignedShort();
|
||||
if(discovered){
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
tiles[newx][newy].setVisibility((byte) 1);
|
||||
}
|
||||
}
|
||||
i += consecutives;
|
||||
}
|
||||
|
||||
state.teams = new Teams();
|
||||
|
||||
byte teams = stream.readByte();
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Texture.TextureFilter;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.event.InputEvent;
|
||||
import io.anuke.arc.scene.event.InputListener;
|
||||
import io.anuke.arc.scene.ui.layout.Container;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class Minimap extends Container<Element>{
|
||||
|
||||
public Minimap(){
|
||||
super(new Element(){
|
||||
TextureRegion r = new TextureRegion();
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
@@ -27,30 +23,6 @@ public class Minimap extends Container<Element>{
|
||||
if(renderer.minimap.getTexture() != null){
|
||||
renderer.minimap.drawEntities(x, y, width, height);
|
||||
}
|
||||
|
||||
if(showFog){
|
||||
renderer.fog.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
|
||||
|
||||
r.set(renderer.minimap.getRegion());
|
||||
float pad = renderer.fog.getPadding();
|
||||
|
||||
float px = r.getU() * world.width() + pad;
|
||||
float py = r.getV() * world.height() + pad;
|
||||
float px2 = r.getU2() * world.width() + pad;
|
||||
float py2 = r.getV2() * world.height() + pad;
|
||||
|
||||
r.setTexture(renderer.fog.getTexture());
|
||||
r.setU(px / (world.width() + pad*2f));
|
||||
r.setV(1f - py / (world.height() + pad*2f));
|
||||
r.setU2(px2 / (world.width() + pad*2f));
|
||||
r.setV2(1f - py2 / (world.height() + pad*2f));
|
||||
|
||||
Draw.shader(Shaders.fog);
|
||||
Draw.rect().tex(r).set(x, y, width, height);
|
||||
Draw.shader();
|
||||
|
||||
renderer.fog.getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
pad = 6;
|
||||
}
|
||||
|
||||
Cell<TextButton> cell = ((Table) pane.getParent()).getCell(button);
|
||||
Cell cell = ((Table) pane.getParent()).getCell(button);
|
||||
|
||||
if(!Mathf.isEqual(cell.getMinWidth(), pw)){
|
||||
cell.width(pw);
|
||||
|
||||
@@ -42,8 +42,6 @@ public class Tile implements Position, TargetTrait{
|
||||
private byte team;
|
||||
/** Tile elevation. -1 means slope.*/
|
||||
private byte elevation;
|
||||
/** Fog visibility status: 3 states, but saved as a single bit. 0 = unexplored, 1 = visited, 2 = currently visible (saved as 1)*/
|
||||
private byte visibility;
|
||||
|
||||
public Tile(int x, int y){
|
||||
this.x = (short) x;
|
||||
@@ -67,10 +65,6 @@ public class Tile implements Position, TargetTrait{
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
public boolean discovered(){
|
||||
return visibility > 0;
|
||||
}
|
||||
|
||||
/**Returns this tile's position as a {@link Pos}.*/
|
||||
public int pos(){
|
||||
return Pos.get(x, y);
|
||||
@@ -171,14 +165,6 @@ public class Tile implements Position, TargetTrait{
|
||||
this.floor = type;
|
||||
}
|
||||
|
||||
public byte getVisibility(){
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(byte visibility){
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public byte getRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@@ -99,14 +99,11 @@ public class Reconstructor extends Block{
|
||||
ReconstructorEntity entity = tile.entity();
|
||||
ReconstructorEntity oe = other.entity();
|
||||
|
||||
//called in main thread to prevent issues
|
||||
threads.run(() -> {
|
||||
unlink(entity);
|
||||
unlink(oe);
|
||||
unlink(entity);
|
||||
unlink(oe);
|
||||
|
||||
entity.link = other.pos();
|
||||
oe.link = tile.pos();
|
||||
});
|
||||
entity.link = other.pos();
|
||||
oe.link = tile.pos();
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.server, forward = true)
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shapes;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
@@ -71,11 +72,10 @@ public class RepairPoint extends Block{
|
||||
float ang = entity.angleTo(entity.target);
|
||||
float len = 5f;
|
||||
|
||||
//TODO new laser drawing system
|
||||
Draw.color(Color.valueOf("e8ffd7"));
|
||||
//Shapes.laser("laser", "laser-end",
|
||||
// tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len),
|
||||
// entity.target.x, entity.target.y, entity.strength);
|
||||
Shapes.laser("laser", "laser-end",
|
||||
tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len),
|
||||
entity.target.x, entity.target.y, entity.strength);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user