Successful desktop compilation
This commit is contained in:
@@ -26,7 +26,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(":core")
|
implementation project(":core")
|
||||||
implementation project(":kryonet")
|
implementation project(":net")
|
||||||
implementation 'com.android.support:support-v4:28.0.0'
|
implementation 'com.android.support:support-v4:28.0.0'
|
||||||
implementation 'org.sufficientlysecure:donations:2.5'
|
implementation 'org.sufficientlysecure:donations:2.5'
|
||||||
implementation 'com.google.android.gms:play-services-auth:16.0.1'
|
implementation 'com.google.android.gms:play-services-auth:16.0.1'
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class RemoteWriteGenerator{
|
|||||||
method.beginControlFlow("if(" + getCheckString(methodEntry.where) + ")");
|
method.beginControlFlow("if(" + getCheckString(methodEntry.where) + ")");
|
||||||
|
|
||||||
//add statement to create packet from pool
|
//add statement to create packet from pool
|
||||||
method.addStatement("$1N packet = $2N.obtain($1N.class, $1N::new)", "io.anuke.mindustry.net.Packets.InvokePacket", "io.anuke.arc.util.Pooling");
|
method.addStatement("$1N packet = $2N.obtain($1N.class, $1N::new)", "io.anuke.mindustry.net.Packets.InvokePacket", "io.anuke.arc.util.pooling.Pools");
|
||||||
//assign buffer
|
//assign buffer
|
||||||
method.addStatement("packet.writeBuffer = TEMP_BUFFER");
|
method.addStatement("packet.writeBuffer = TEMP_BUFFER");
|
||||||
//assign priority
|
//assign priority
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
TypeSpec.Builder serializer = TypeSpec.anonymousClassBuilder("")
|
TypeSpec.Builder serializer = TypeSpec.anonymousClassBuilder("")
|
||||||
.addSuperinterface(ParameterizedTypeName.get(
|
.addSuperinterface(ParameterizedTypeName.get(
|
||||||
ClassName.bestGuess("io.anuke.arc.io.TypeSerializer"), type));
|
ClassName.bestGuess("io.anuke.arc.Settings.TypeSerializer"), type));
|
||||||
|
|
||||||
MethodSpec.Builder writeMethod = MethodSpec.methodBuilder("write")
|
MethodSpec.Builder writeMethod = MethodSpec.methodBuilder("write")
|
||||||
.returns(void.class)
|
.returns(void.class)
|
||||||
@@ -84,8 +84,8 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
writeMethod.addStatement("stream.write" + capName + "(object." + name + ")");
|
writeMethod.addStatement("stream.write" + capName + "(object." + name + ")");
|
||||||
readMethod.addStatement("object." + name + "= stream.read" + capName + "()");
|
readMethod.addStatement("object." + name + "= stream.read" + capName + "()");
|
||||||
}else{
|
}else{
|
||||||
writeMethod.addStatement("io.anuke.arc.core.Core.settings.getSerializer(" + typeName+ ".class).write(stream, object." + name + ")");
|
writeMethod.addStatement("io.anuke.arc.Core.settings.getSerializer(" + typeName+ ".class).write(stream, object." + name + ")");
|
||||||
readMethod.addStatement("object." + name + " = (" +typeName+")io.anuke.arc.core.Core.settings.getSerializer(" + typeName+ ".class).read(stream)");
|
readMethod.addStatement("object." + name + " = (" +typeName+")io.anuke.arc.Core.settings.getSerializer(" + typeName+ ".class).read(stream)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
serializer.addMethod(writeMethod.build());
|
serializer.addMethod(writeMethod.build());
|
||||||
serializer.addMethod(readMethod.build());
|
serializer.addMethod(readMethod.build());
|
||||||
|
|
||||||
method.addStatement("io.anuke.arc.core.Core.settings.setSerializer($N, $L)", Utils.elementUtils.getBinaryName(elem).toString().replace('$', '.') + ".class", serializer.build());
|
method.addStatement("io.anuke.arc.Core.settings.setSerializer($N, $L)", Utils.elementUtils.getBinaryName(elem).toString().replace('$', '.') + ".class", serializer.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
classBuilder.addMethod(method.build());
|
classBuilder.addMethod(method.build());
|
||||||
|
|||||||
23
build.gradle
23
build.gradle
@@ -88,13 +88,13 @@ project(":desktop"){
|
|||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
compile project(":kryonet")
|
compile project(":net")
|
||||||
if(new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null) compile project(":debug")
|
if(new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null) compile project(":debug")
|
||||||
|
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||||
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
||||||
|
|
||||||
|
compile project(":Arc:backends:backend-lwjgl3")
|
||||||
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0'
|
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ project(":ios"){
|
|||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
implementation project(":kryonet")
|
implementation project(":net")
|
||||||
|
|
||||||
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
|
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
|
||||||
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
|
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
|
||||||
@@ -170,21 +170,12 @@ project(":core"){
|
|||||||
|
|
||||||
if(new File(projectDir.parent, '../Arc').exists() && comp){
|
if(new File(projectDir.parent, '../Arc').exists() && comp){
|
||||||
compile project(":Arc:arc-core")
|
compile project(":Arc:arc-core")
|
||||||
//compile project(":Arc:extensions:freetype")
|
compile project(":Arc:extensions:freetype")
|
||||||
}else{
|
}else{
|
||||||
//TODO compile arc from jitpack
|
//TODO compile arc from jitpack
|
||||||
//compile 'com.github.Anuken.Arc:arc:-SNAPSHOT'
|
//compile 'com.github.Anuken.Arc:arc:-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(new File(projectDir.parent, '../GDXGifRecorder').exists() && comp){
|
|
||||||
// compile project(":GDXGifRecorder")
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
//compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
|
||||||
//compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
|
|
||||||
//compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
|
||||||
|
|
||||||
compileOnly project(":annotations")
|
compileOnly project(":annotations")
|
||||||
annotationProcessor project(":annotations")
|
annotationProcessor project(":annotations")
|
||||||
}
|
}
|
||||||
@@ -196,7 +187,7 @@ project(":server"){
|
|||||||
dependencies{
|
dependencies{
|
||||||
|
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
compile project(":kryonet")
|
compile project(":net")
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||||
}
|
}
|
||||||
@@ -235,7 +226,7 @@ project(":annotations"){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project(":kryonet"){
|
project(":net"){
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
@@ -1,6 +1,6 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import io.anuke.arc.ApplicationListener;
|
import io.anuke.arc.ApplicationCore;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Events;
|
import io.anuke.arc.Events;
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.arc.util.Log;
|
||||||
@@ -11,10 +11,10 @@ import io.anuke.mindustry.io.BundleLoader;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Mindustry implements ApplicationListener{
|
public class Mindustry extends ApplicationCore{
|
||||||
private long lastFrameTime;
|
|
||||||
|
|
||||||
public Mindustry(){
|
@Override
|
||||||
|
public void setup(){
|
||||||
Time.setDeltaProvider(() -> {
|
Time.setDeltaProvider(() -> {
|
||||||
float result = Core.graphics.getDeltaTime() * 60f;
|
float result = Core.graphics.getDeltaTime() * 60f;
|
||||||
return Float.isNaN(result) || Float.isInfinite(result) ? 1f : Math.min(result, 60f / 10f);
|
return Float.isNaN(result) || Float.isInfinite(result) ? 1f : Math.min(result, 60f / 10f);
|
||||||
@@ -28,26 +28,28 @@ public class Mindustry implements ApplicationListener{
|
|||||||
BundleLoader.load();
|
BundleLoader.load();
|
||||||
content.load();
|
content.load();
|
||||||
|
|
||||||
Core.app.addListener(logic = new Logic());
|
add(logic = new Logic());
|
||||||
Core.app.addListener(world = new World());
|
add(world = new World());
|
||||||
Core.app.addListener(control = new Control());
|
add(control = new Control());
|
||||||
Core.app.addListener(renderer = new Renderer());
|
add(renderer = new Renderer());
|
||||||
Core.app.addListener(ui = new UI());
|
add(ui = new UI());
|
||||||
Core.app.addListener(netServer = new NetServer());
|
add(netServer = new NetServer());
|
||||||
Core.app.addListener(netClient = new NetClient());
|
add(netClient = new NetClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
|
super.init();
|
||||||
|
|
||||||
Log.info("Time to load [total]: {0}", Time.elapsed());
|
Log.info("Time to load [total]: {0}", Time.elapsed());
|
||||||
Events.fire(new GameLoadEvent());
|
Events.fire(new GameLoadEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
lastFrameTime = Time.millis();
|
long lastFrameTime = Time.millis();
|
||||||
|
|
||||||
//TODO ??render it all??
|
super.update();
|
||||||
|
|
||||||
int fpsCap = Core.settings.getInt("fpscap", 125);
|
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.Core;
|
||||||
import io.anuke.arc.entities.Effects;
|
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.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
@@ -202,14 +202,14 @@ public class Mechs implements ContentList{
|
|||||||
public void draw(Player player){
|
public void draw(Player player){
|
||||||
if(player.shootHeat <= 0.01f) return;
|
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.progress = player.shootHeat;
|
||||||
Shaders.build.region = armorRegion;
|
Shaders.build.region = armorRegion;
|
||||||
Shaders.build.time = Time.time() / 10f;
|
Shaders.build.time = Time.time() / 10f;
|
||||||
Shaders.build.color.set(Palette.accent).a = player.shootHeat;
|
Shaders.build.color.set(Palette.accent).a = player.shootHeat;
|
||||||
Draw.shader(Shaders.build);
|
Draw.shader(Shaders.build);
|
||||||
Draw.alpha(1f);
|
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.shader(Shaders.mix);
|
||||||
Draw.color(1f, 1f, 1f, alpha);
|
Draw.color(1f, 1f, 1f, alpha);
|
||||||
}
|
}
|
||||||
@@ -268,13 +268,11 @@ public class Mechs implements ContentList{
|
|||||||
public void draw(Player player){
|
public void draw(Player player){
|
||||||
float scl = scld(player);
|
float scl = scld(player);
|
||||||
if(scl < 0.01f) return;
|
if(scl < 0.01f) return;
|
||||||
float alpha = Core.batch.getColor().a;
|
float alpha = Core.graphics.batch().getColor().a;
|
||||||
Draw.shader();
|
Draw.shader();
|
||||||
Graphics.setAdditiveBlending();
|
|
||||||
Draw.color(Palette.lancerLaser);
|
Draw.color(Palette.lancerLaser);
|
||||||
Draw.alpha(scl/2f);
|
Draw.alpha(scl/2f);
|
||||||
Draw.rect(shield, player.snappedX() + Mathf.range(scl/2f), player.snappedY() + Mathf.range(scl/2f), player.rotation - 90);
|
Draw.rect(shield, player.snappedX() + Mathf.range(scl/2f), player.snappedY() + Mathf.range(scl/2f)).rot(player.rotation - 90).blend(Blending.additive);
|
||||||
Graphics.setNormalBlending();
|
|
||||||
Draw.shader(Shaders.mix);
|
Draw.shader(Shaders.mix);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
Draw.alpha(alpha);
|
Draw.alpha(alpha);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class TurretBlocks extends BlockList implements ContentList{
|
|||||||
ammoUseEffect = ShootFx.shellEjectSmall;
|
ammoUseEffect = ShootFx.shellEjectSmall;
|
||||||
health = 160;
|
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;
|
ammoUseEffect = ShootFx.shellEjectBig;
|
||||||
|
|
||||||
drawer = (tile, entity) -> {
|
drawer = (tile, entity) -> {
|
||||||
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90);
|
||||||
float offsetx = (int) (Mathf.abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 3f);
|
float offsetx = (int) (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);
|
float offsety = -(int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 2f);
|
||||||
|
|
||||||
for(int i : Mathf.signs){
|
for(int i : Mathf.signs){
|
||||||
float rot = entity.rotation + 90 * i;
|
float rot = entity.rotation + 90 * i;
|
||||||
Draw.rect(panels[i == -1 ? 0 : 1],
|
Draw.rect(panels[i == -1 ? 0 : 1],
|
||||||
tile.drawx() + tr2.x + Angles.trnsx(rot, offsetx, offsety),
|
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;
|
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"){{
|
ripple = new ArtilleryTurret("ripple"){{
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
package io.anuke.mindustry.content.bullets;
|
package io.anuke.mindustry.content.bullets;
|
||||||
|
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.graphics.Color;
|
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.Liquids;
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.content.fx.BlockFx;
|
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.entities.effect.Lightning;
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.mindustry.graphics.Shapes;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.BuildBlock;
|
import io.anuke.mindustry.world.blocks.BuildBlock;
|
||||||
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
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.content;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
@@ -342,10 +346,10 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float w = 11f, h = 13f;
|
float w = 11f, h = 13f;
|
||||||
|
|
||||||
Draw.color(Palette.bulletYellowBack);
|
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.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();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
@@ -379,7 +383,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float baseAngle = data.to.angleTo(data.from);
|
float baseAngle = data.to.angleTo(data.from);
|
||||||
|
|
||||||
//if angles are nearby, then yes, it did
|
//if angles are nearby, then yes, it did
|
||||||
if(Mathf.angNear(angleTo, baseAngle, 2f)){
|
if(Angles.near(angleTo, baseAngle, 2f)){
|
||||||
intersect = true;
|
intersect = true;
|
||||||
//snap bullet position back; this is used for low-FPS situations
|
//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));
|
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();
|
Draw.reset();
|
||||||
});
|
});
|
||||||
ripple = new GroundEffect(false, 30, e -> {
|
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.stroke(e.fout() + 0.4f);
|
||||||
Lines.circle(e.x, e.y, 2f + e.fin() * 4f);
|
Lines.circle(e.x, e.y, 2f + e.fin() * 4f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
bubble = new Effect(20, e -> {
|
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);
|
Lines.stroke(e.fout() + 0.2f);
|
||||||
Angles.randLenVectors(e.id, 2, 8f, (x, y) -> {
|
Angles.randLenVectors(e.id, 2, 8f, (x, y) -> {
|
||||||
Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f);
|
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.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Fill;
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
import io.anuke.mindustry.content.Liquids;
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package io.anuke.mindustry.content.fx;
|
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.entities.Effects.Effect;
|
||||||
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Fill;
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
import io.anuke.arc.graphics.g2d.Lines;
|
||||||
import io.anuke.arc.graphics.Shapes;
|
|
||||||
import io.anuke.arc.math.Angles;
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.math.Mathf;
|
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 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;
|
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",
|
Draw.rect("white",
|
||||||
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
|
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()),
|
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();
|
Draw.color();
|
||||||
});
|
});
|
||||||
@@ -125,7 +125,7 @@ public class ShootFx extends FxList implements ContentList{
|
|||||||
Draw.rect("casing",
|
Draw.rect("casing",
|
||||||
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
|
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()),
|
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());
|
Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin());
|
||||||
@@ -148,8 +148,8 @@ public class ShootFx extends FxList implements ContentList{
|
|||||||
Draw.rect("casing",
|
Draw.rect("casing",
|
||||||
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
|
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()),
|
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
|
||||||
2.5f, 4f,
|
2.5f, 4f)
|
||||||
rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin()));
|
.rot(rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.color(Color.LIGHT_GRAY);
|
Draw.color(Color.LIGHT_GRAY);
|
||||||
|
|||||||
@@ -57,11 +57,12 @@ public class Control implements ApplicationListener{
|
|||||||
unlocks = new Unlocks();
|
unlocks = new Unlocks();
|
||||||
|
|
||||||
Core.input.setCatch(KeyCode.BACK, true);
|
Core.input.setCatch(KeyCode.BACK, true);
|
||||||
|
Core.keybinds.setDefaults(Binding.values());
|
||||||
|
|
||||||
Effects.setShakeFalloff(10000f);
|
Effects.setShakeFalloff(10000f);
|
||||||
|
|
||||||
content.initialize(Content::init);
|
content.initialize(Content::init);
|
||||||
Core.atlas = new TextureAtlas("sprites.atlas");
|
Core.atlas = new TextureAtlas("sprites/sprites.atlas");
|
||||||
content.initialize(Content::load);
|
content.initialize(Content::load);
|
||||||
|
|
||||||
unlocks.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.entities.trait.Entity;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.Consumer;
|
||||||
import io.anuke.arc.function.Predicate;
|
import io.anuke.arc.function.Predicate;
|
||||||
|
import io.anuke.arc.graphics.Camera;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
import io.anuke.arc.graphics.g2d.Lines;
|
||||||
@@ -37,7 +38,6 @@ public class Renderer implements ApplicationListener{
|
|||||||
public final BlockRenderer blocks = new BlockRenderer();
|
public final BlockRenderer blocks = new BlockRenderer();
|
||||||
public final MinimapRenderer minimap = new MinimapRenderer();
|
public final MinimapRenderer minimap = new MinimapRenderer();
|
||||||
public final OverlayRenderer overlays = new OverlayRenderer();
|
public final OverlayRenderer overlays = new OverlayRenderer();
|
||||||
public final FogRenderer fog = new FogRenderer();
|
|
||||||
|
|
||||||
private Color clearColor;
|
private Color clearColor;
|
||||||
private int targetscale = baseCameraScale;
|
private int targetscale = baseCameraScale;
|
||||||
@@ -45,6 +45,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
private Vector2 avgPosition = new Vector2();
|
private Vector2 avgPosition = new Vector2();
|
||||||
|
|
||||||
public Renderer(){
|
public Renderer(){
|
||||||
|
camera = new Camera();
|
||||||
Lines.setCircleVertices(14);
|
Lines.setCircleVertices(14);
|
||||||
|
|
||||||
Shaders.init();
|
Shaders.init();
|
||||||
@@ -285,11 +286,6 @@ public class Renderer implements ApplicationListener{
|
|||||||
camera.resize(width, height);
|
camera.resize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose(){
|
|
||||||
fog.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2 averagePosition(){
|
public Vector2 averagePosition(){
|
||||||
avgPosition.setZero();
|
avgPosition.setZero();
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import io.anuke.arc.Core;
|
|||||||
import io.anuke.arc.Events;
|
import io.anuke.arc.Events;
|
||||||
import io.anuke.arc.Graphics.Cursor;
|
import io.anuke.arc.Graphics.Cursor;
|
||||||
import io.anuke.arc.Graphics.Cursor.SystemCursor;
|
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.function.Consumer;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.Colors;
|
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.Align;
|
||||||
import io.anuke.arc.util.Strings;
|
import io.anuke.arc.util.Strings;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.arc.freetype.*;
|
|
||||||
import io.anuke.mindustry.editor.MapEditorDialog;
|
import io.anuke.mindustry.editor.MapEditorDialog;
|
||||||
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
@@ -32,17 +33,18 @@ import io.anuke.mindustry.ui.dialogs.*;
|
|||||||
import io.anuke.mindustry.ui.fragments.*;
|
import io.anuke.mindustry.ui.fragments.*;
|
||||||
|
|
||||||
import static io.anuke.arc.scene.actions.Actions.*;
|
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{
|
public class UI implements ApplicationListener{
|
||||||
private FreeTypeFontGenerator generator;
|
private FreeTypeFontGenerator generator;
|
||||||
|
|
||||||
public final MenuFragment menufrag = new MenuFragment();
|
public MenuFragment menufrag;
|
||||||
public final HudFragment hudfrag = new HudFragment();
|
public HudFragment hudfrag;
|
||||||
public final ChatFragment chatfrag = new ChatFragment();
|
public ChatFragment chatfrag;
|
||||||
public final PlayerListFragment listfrag = new PlayerListFragment();
|
public PlayerListFragment listfrag;
|
||||||
public final BackgroundFragment backfrag = new BackgroundFragment();
|
public BackgroundFragment backfrag;
|
||||||
public final LoadingFragment loadfrag = new LoadingFragment();
|
public LoadingFragment loadfrag;
|
||||||
|
|
||||||
public AboutDialog about;
|
public AboutDialog about;
|
||||||
public RestartDialog restart;
|
public RestartDialog restart;
|
||||||
@@ -71,7 +73,7 @@ public class UI implements ApplicationListener{
|
|||||||
|
|
||||||
public UI(){
|
public UI(){
|
||||||
Skin skin = new Skin(Core.atlas);
|
Skin skin = new Skin(Core.atlas);
|
||||||
generateFonts();
|
generateFonts(skin);
|
||||||
skin.load(Core.files.internal("ui/uiskin.json"));
|
skin.load(Core.files.internal("ui/uiskin.json"));
|
||||||
|
|
||||||
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
||||||
@@ -120,7 +122,7 @@ public class UI implements ApplicationListener{
|
|||||||
Core.graphics.restoreCursor();
|
Core.graphics.restoreCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateFonts(){
|
void generateFonts(Skin skin){
|
||||||
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/pixel.ttf"));
|
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/pixel.ttf"));
|
||||||
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
||||||
param.size = (int)(14*2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
param.size = (int)(14*2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
||||||
@@ -145,6 +147,13 @@ public class UI implements ApplicationListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
|
menufrag = new MenuFragment();
|
||||||
|
hudfrag = new HudFragment();
|
||||||
|
chatfrag = new ChatFragment();
|
||||||
|
listfrag = new PlayerListFragment();
|
||||||
|
backfrag = new BackgroundFragment();
|
||||||
|
loadfrag = new LoadingFragment();
|
||||||
|
|
||||||
editor = new MapEditorDialog();
|
editor = new MapEditorDialog();
|
||||||
controls = new ControlsDialog();
|
controls = new ControlsDialog();
|
||||||
restart = new RestartDialog();
|
restart = new RestartDialog();
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
package io.anuke.mindustry.editor;
|
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.Color;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
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.math.geom.Point2;
|
||||||
import io.anuke.arc.util.Disposable;
|
import io.anuke.arc.util.Disposable;
|
||||||
import io.anuke.arc.util.IntSet;
|
import io.anuke.arc.util.Pack;
|
||||||
import io.anuke.arc.util.IntSet.IntSetIterator;
|
import io.anuke.arc.util.Structs;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
|
import io.anuke.mindustry.graphics.IndexedRenderer;
|
||||||
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
||||||
import io.anuke.mindustry.world.Block;
|
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.content;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
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){
|
public void draw(float tx, float ty, float tw, float th){
|
||||||
Graphics.end();
|
Draw.flush();
|
||||||
|
|
||||||
IntSetIterator it = updates.iterator();
|
IntSetIterator it = updates.iterator();
|
||||||
while(it.hasNext){
|
while(it.hasNext){
|
||||||
@@ -79,15 +78,12 @@ public class MapRenderer implements Disposable{
|
|||||||
mesh = chunks[x][y];
|
mesh = chunks[x][y];
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.getTransformMatrix().setToTranslation(tx, ty, 0).scl(tw / (width * tilesize),
|
mesh.getTransformMatrix().setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize));
|
||||||
th / (height * tilesize), 1f);
|
mesh.setProjectionMatrix(Core.graphics.batch().getProjection());
|
||||||
mesh.setProjectionMatrix(Core.batch.getProjectionMatrix());
|
|
||||||
|
|
||||||
mesh.render(Core.atlas.getTextures().first());
|
mesh.render(Core.atlas.getTextures().first());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePoint(int x, int y){
|
public void updatePoint(int x, int y){
|
||||||
|
|||||||
@@ -1,32 +1,27 @@
|
|||||||
package io.anuke.mindustry.editor;
|
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.Core;
|
||||||
import io.anuke.arc.Graphics;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.Inputs;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
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.Element;
|
||||||
import io.anuke.arc.scene.event.InputEvent;
|
import io.anuke.arc.scene.event.InputEvent;
|
||||||
import io.anuke.arc.scene.event.InputListener;
|
import io.anuke.arc.scene.event.InputListener;
|
||||||
import io.anuke.arc.scene.event.Touchable;
|
import io.anuke.arc.scene.event.Touchable;
|
||||||
import io.anuke.arc.scene.ui.TextField;
|
import io.anuke.arc.scene.ui.TextField;
|
||||||
import io.anuke.arc.scene.ui.layout.Unit;
|
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.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.mobile;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
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);
|
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);
|
touchable(Touchable.enabled);
|
||||||
|
|
||||||
addListener(new InputListener(){
|
addListener(new InputListener(){
|
||||||
@@ -74,16 +69,16 @@ public class MapView extends Element implements GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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){
|
if(pointer != 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mobile && button != Buttons.LEFT && button != Buttons.MIDDLE){
|
if(!mobile && button != KeyCode.MOUSE_LEFT && button != KeyCode.MOUSE_MIDDLE){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(button == Buttons.MIDDLE){
|
if(button == KeyCode.MOUSE_MIDDLE){
|
||||||
lastTool = tool;
|
lastTool = tool;
|
||||||
tool = EditorTool.zoom;
|
tool = EditorTool.zoom;
|
||||||
}
|
}
|
||||||
@@ -112,8 +107,8 @@ public class MapView extends Element implements GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button){
|
public void touchUp(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||||
if(!mobile && button != Buttons.LEFT && button != Buttons.MIDDLE){
|
if(!mobile && button != KeyCode.MOUSE_LEFT && button != KeyCode.MOUSE_MIDDLE){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,16 +209,16 @@ public class MapView extends Element implements GestureListener{
|
|||||||
super.act(delta);
|
super.act(delta);
|
||||||
|
|
||||||
if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) &&
|
if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) &&
|
||||||
!Core.input.keyDown(io.anuke.arc.input.Input.CONTROL_LEFT)){
|
!Core.input.keyDown(KeyCode.CONTROL_LEFT)){
|
||||||
float ax = Core.input.getAxis("move_x");
|
float ax = Core.input.axis(Binding.move_x);
|
||||||
float ay = Core.input.getAxis("move_y");
|
float ay = Core.input.axis(Binding.move_y);
|
||||||
offsetx -= ax * 15f / zoom;
|
offsetx -= ax * 15f / zoom;
|
||||||
offsety -= ay * 15f / zoom;
|
offsety -= ay * 15f / zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ui.editor.hasPane()) return;
|
if(ui.editor.hasPane()) return;
|
||||||
|
|
||||||
zoom += Core.input.scroll() / 10f * zoom;
|
zoom += Core.input.axis(KeyCode.SCROLL) / 10f * zoom;
|
||||||
clampZoom();
|
clampZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +253,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float alpha){
|
public void draw(){
|
||||||
float ratio = 1f / ((float) editor.getMap().width() / editor.getMap().height());
|
float ratio = 1f / ((float) editor.getMap().width() / editor.getMap().height());
|
||||||
float size = Math.min(width, height);
|
float size = Math.min(width, height);
|
||||||
float sclwidth = size * zoom;
|
float sclwidth = size * zoom;
|
||||||
@@ -268,7 +263,9 @@ public class MapView extends Element implements GestureListener{
|
|||||||
|
|
||||||
image.setImageSize(editor.getMap().width(), editor.getMap().height());
|
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);
|
Draw.color(Palette.remove);
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f);
|
||||||
@@ -279,7 +276,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
if(grid){
|
if(grid){
|
||||||
Draw.color(Color.GRAY);
|
Draw.color(Color.GRAY);
|
||||||
image.setBounds(centerx - sclwidth / 2, centery - sclheight / 2, sclwidth, sclheight);
|
image.setBounds(centerx - sclwidth / 2, centery - sclheight / 2, sclwidth, sclheight);
|
||||||
image.draw(batch, alpha);
|
image.draw();
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,8 +320,6 @@ public class MapView extends Element implements GestureListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics.endClip();
|
|
||||||
|
|
||||||
Draw.color(Palette.accent);
|
Draw.color(Palette.accent);
|
||||||
Lines.stroke(Unit.dp.scl(3f));
|
Lines.stroke(Unit.dp.scl(3f));
|
||||||
Lines.rect(x, y, width, height);
|
Lines.rect(x, y, width, height);
|
||||||
@@ -335,27 +330,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
return Core.scene.getKeyboardFocus() != null
|
return Core.scene.getKeyboardFocus() != null
|
||||||
&& Core.scene.getKeyboardFocus().isDescendantOf(ui.editor)
|
&& Core.scene.getKeyboardFocus().isDescendantOf(ui.editor)
|
||||||
&& ui.editor.isShown() && tool == EditorTool.zoom &&
|
&& ui.editor.isShown() && tool == EditorTool.zoom &&
|
||||||
Core.scene.hit(Graphics.mouse().x, Graphics.mouse().y, true) == this;
|
Core.scene.hit(Core.input.mouse().x, Core.input.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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -366,11 +341,6 @@ public class MapView extends Element implements GestureListener{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean panStop(float x, float y, int pointer, int button){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean zoom(float initialDistance, float distance){
|
public boolean zoom(float initialDistance, float distance){
|
||||||
if(!active()) return false;
|
if(!active()) return false;
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public class ArtilleryBulletType extends BasicBulletType{
|
|||||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
Draw.color(backColor);
|
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.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();
|
Draw.color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.anuke.arc.entities.EntityGroup;
|
|||||||
import io.anuke.arc.entities.impl.TimedEntity;
|
import io.anuke.arc.entities.impl.TimedEntity;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
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.Structs;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.arc.util.pooling.Pool.Poolable;
|
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.game.EventType.BuildSelectEvent;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.mindustry.graphics.Shapes;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
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);
|
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));
|
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){
|
if(unit instanceof Player && ((Player) unit).isLocal){
|
||||||
Lines.stroke(1f, Palette.accent);
|
Lines.stroke(1f, Palette.accent);
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
import io.anuke.arc.graphics.Color;
|
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.math.geom.Vector2;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.entities.Predict;
|
import io.anuke.mindustry.entities.Predict;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
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.type.Weapon;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.Floor;
|
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.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -155,7 +154,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
Draw.rect(type.legRegion,
|
Draw.rect(type.legRegion,
|
||||||
x + Angles.trnsx(baseRotation, ft * i),
|
x + Angles.trnsx(baseRotation, ft * i),
|
||||||
y + Angles.trnsy(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){
|
if(floor.isLiquid){
|
||||||
@@ -164,16 +163,16 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
Draw.tint(Color.WHITE);
|
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){
|
for(int i : Mathf.signs){
|
||||||
float tra = rotation - 90, trY = -weapon.getRecoil(this, i > 0) + type.weaponOffsetY;
|
float tra = rotation - 90, trY = -weapon.getRecoil(this, i > 0) + type.weaponOffsetY;
|
||||||
float w = i > 0 ? -12 : 12;
|
float w = i > 0 ? -12 : 12;
|
||||||
Draw.rect(weapon.equipRegion,
|
Draw.rect(weapon.equipRegion,
|
||||||
x + Angles.trnsx(tra, type.weaponOffsetX * i, trY),
|
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();
|
drawItems();
|
||||||
@@ -191,7 +190,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
if(dst(target) < getWeapon().getAmmo().getRange()){
|
if(dst(target) < getWeapon().getAmmo().getRange()){
|
||||||
rotate(angleTo(target));
|
rotate(angleTo(target));
|
||||||
|
|
||||||
if(Mathf.angNear(angleTo(target), rotation, 13f)){
|
if(Angles.near(angleTo(target), rotation, 13f)){
|
||||||
AmmoType ammo = getWeapon().getAmmo();
|
AmmoType ammo = getWeapon().getAmmo();
|
||||||
|
|
||||||
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.bullet.speed);
|
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.bullet.speed);
|
||||||
|
|||||||
@@ -163,7 +163,6 @@ public class Saves{
|
|||||||
|
|
||||||
public void save(){
|
public void save(){
|
||||||
long time = totalPlaytime;
|
long time = totalPlaytime;
|
||||||
renderer.fog.writeFog();
|
|
||||||
long prev = totalPlaytime;
|
long prev = totalPlaytime;
|
||||||
totalPlaytime = time;
|
totalPlaytime = time;
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,22 @@ package io.anuke.mindustry.graphics;
|
|||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Events;
|
import io.anuke.arc.Events;
|
||||||
import io.anuke.arc.Graphics;
|
|
||||||
import io.anuke.arc.collection.IntArray;
|
import io.anuke.arc.collection.IntArray;
|
||||||
import io.anuke.arc.collection.IntSet;
|
import io.anuke.arc.collection.IntSet;
|
||||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||||
import io.anuke.arc.collection.ObjectSet;
|
import io.anuke.arc.collection.ObjectSet;
|
||||||
|
import io.anuke.arc.graphics.Camera;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.GL20;
|
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.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Fill;
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
|
import io.anuke.arc.graphics.g2d.SpriteBatch;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.arc.util.Log;
|
||||||
import io.anuke.arc.util.Structs;
|
import io.anuke.arc.util.Structs;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||||
import io.anuke.mindustry.maps.Sector;
|
import io.anuke.mindustry.maps.Sector;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.Floor;
|
import io.anuke.mindustry.world.blocks.Floor;
|
||||||
@@ -33,7 +36,7 @@ public class FloorRenderer{
|
|||||||
private IntArray drawnLayers = new IntArray();
|
private IntArray drawnLayers = new IntArray();
|
||||||
|
|
||||||
public FloorRenderer(){
|
public FloorRenderer(){
|
||||||
Events.on(WorldLoadGraphicsEvent.class, event -> clearTiles());
|
Events.on(WorldLoadEvent.class, event -> clearTiles());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawFloor(){
|
public void drawFloor(){
|
||||||
@@ -41,13 +44,13 @@ public class FloorRenderer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OrthographicCamera camera = Core.camera;
|
Camera camera = Core.camera;
|
||||||
|
|
||||||
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
||||||
int crangey = (int) (camera.height / (chunksize * tilesize)) + 1;
|
int crangey = (int) (camera.height / (chunksize * tilesize)) + 1;
|
||||||
|
|
||||||
int camx = Mathf.scl(camera.position.x, chunksize * tilesize);
|
int camx = (int)(camera.position.x / (chunksize * tilesize));
|
||||||
int camy = Mathf.scl(camera.position.y, chunksize * tilesize);
|
int camy = (int)(camera.position.y / (chunksize * tilesize));
|
||||||
|
|
||||||
int layers = CacheLayer.values().length;
|
int layers = CacheLayer.values().length;
|
||||||
|
|
||||||
@@ -81,7 +84,7 @@ public class FloorRenderer{
|
|||||||
|
|
||||||
drawnLayers.sort();
|
drawnLayers.sort();
|
||||||
|
|
||||||
Graphics.end();
|
Draw.flush();
|
||||||
beginDraw();
|
beginDraw();
|
||||||
|
|
||||||
for(int i = 0; i < drawnLayers.size; i++){
|
for(int i = 0; i < drawnLayers.size; i++){
|
||||||
@@ -91,7 +94,6 @@ public class FloorRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
endDraw();
|
endDraw();
|
||||||
Graphics.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginDraw(){
|
public void beginDraw(){
|
||||||
@@ -99,7 +101,7 @@ public class FloorRenderer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cbatch.setProjectionMatrix(Core.camera.combined);
|
cbatch.setProjection(Core.camera.projection());
|
||||||
cbatch.beginDraw();
|
cbatch.beginDraw();
|
||||||
|
|
||||||
Core.gl.glEnable(GL20.GL_BLEND);
|
Core.gl.glEnable(GL20.GL_BLEND);
|
||||||
@@ -118,7 +120,7 @@ public class FloorRenderer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OrthographicCamera camera = Core.camera;
|
Camera camera = Core.camera;
|
||||||
|
|
||||||
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
||||||
int crangey = (int) (camera.height / (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 x = -crangex; x <= crangex; x++){
|
||||||
for(int y = -crangey; y <= crangey; y++){
|
for(int y = -crangey; y <= crangey; y++){
|
||||||
int worldx = Mathf.scl(camera.position.x, chunksize * tilesize) + x;
|
int worldx = (int)(camera.position.x / (chunksize * tilesize)) + x;
|
||||||
int worldy = Mathf.scl(camera.position.y, chunksize * tilesize) + y;
|
int worldy = (int)(camera.position.y / (chunksize * tilesize)) + y;
|
||||||
|
|
||||||
if(!Structs.inBounds(worldx, worldy, cache)){
|
if(!Structs.inBounds(worldx, worldy, cache)){
|
||||||
continue;
|
continue;
|
||||||
@@ -145,7 +147,7 @@ public class FloorRenderer{
|
|||||||
|
|
||||||
private void fillChunk(float x, float y){
|
private void fillChunk(float x, float y){
|
||||||
Draw.color(Color.BLACK);
|
Draw.color(Color.BLACK);
|
||||||
Fill.crect(x, y, chunksize * tilesize, chunksize * tilesize);
|
Fill.rect().set(x, y, chunksize * tilesize, chunksize * tilesize);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,11 +174,8 @@ public class FloorRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cacheChunkLayer(int cx, int cy, Chunk chunk, CacheLayer layer){
|
private void cacheChunkLayer(int cx, int cy, Chunk chunk, CacheLayer layer){
|
||||||
|
SpriteBatch current = Core.graphics.batch();
|
||||||
Graphics.useBatch(cbatch);
|
Core.graphics.useBatch(cbatch);
|
||||||
cbatch.begin();
|
|
||||||
|
|
||||||
Sector sector = world.getSector();
|
|
||||||
|
|
||||||
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
|
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
|
||||||
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
||||||
@@ -196,10 +195,8 @@ public class FloorRenderer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Core.graphics.useBatch(current);
|
||||||
cbatch.end();
|
chunk.caches[layer.ordinal()] = cbatch.flushCache();
|
||||||
Graphics.popBatch();
|
|
||||||
chunk.caches[layer.ordinal()] = cbatch.getLastCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearTiles(){
|
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();
|
build = new UnitBuild();
|
||||||
mix = new MixShader();
|
mix = new MixShader();
|
||||||
fog = new FogShader();
|
fog = new FogShader();
|
||||||
fullMix = new Shader("fullmix", "default");
|
fullMix = new LoadShader("fullmix", "default");
|
||||||
menu = new MenuShader();
|
menu = new MenuShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MenuShader extends Shader{
|
public static class MenuShader extends LoadShader{
|
||||||
float time = 0f;
|
float time = 0f;
|
||||||
|
|
||||||
public MenuShader(){
|
public MenuShader(){
|
||||||
@@ -60,13 +60,13 @@ public class Shaders{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FogShader extends Shader{
|
public static class FogShader extends LoadShader{
|
||||||
public FogShader(){
|
public FogShader(){
|
||||||
super("fog", "default");
|
super("fog", "default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MixShader extends Shader{
|
public static class MixShader extends LoadShader{
|
||||||
public Color color = new Color(Color.WHITE);
|
public Color color = new Color(Color.WHITE);
|
||||||
|
|
||||||
public MixShader(){
|
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 float progress, time;
|
||||||
public Color color = new Color();
|
public Color color = new Color();
|
||||||
public TextureRegion region;
|
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 Color color = new Color();
|
||||||
|
public TextureRegion region = new TextureRegion();
|
||||||
|
|
||||||
public Outline(){
|
public Outline(){
|
||||||
super("outline", "default");
|
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 Color color = new Color();
|
||||||
public float progress;
|
public float progress;
|
||||||
|
public TextureRegion region = new TextureRegion();
|
||||||
|
|
||||||
public BlockBuild(){
|
public BlockBuild(){
|
||||||
super("blockbuild", "default");
|
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 Color color = new Color();
|
||||||
|
public TextureRegion region = new TextureRegion();
|
||||||
|
|
||||||
public BlockPreview(){
|
public BlockPreview(){
|
||||||
super("blockpreview", "default");
|
super("blockpreview", "default");
|
||||||
@@ -162,7 +165,7 @@ public class Shaders{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Shield extends Shader{
|
public static class Shield extends LoadShader{
|
||||||
|
|
||||||
public Shield(){
|
public Shield(){
|
||||||
super("shield", "default");
|
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){
|
public SurfaceShader(String frag){
|
||||||
super(frag, "default");
|
super(frag, "default");
|
||||||
@@ -196,4 +199,10 @@ public class Shaders{
|
|||||||
setUniformf("time", Time.time());
|
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;
|
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{
|
public void readMap(DataInputStream stream) throws IOException{
|
||||||
@@ -175,18 +153,6 @@ public abstract class SaveFileVersion{
|
|||||||
tiles[x][y] = tile;
|
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);
|
content.setTemporaryMapper(null);
|
||||||
world.endMapLoad();
|
world.endMapLoad();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package io.anuke.mindustry.maps;
|
|||||||
|
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.collection.GridMap;
|
import io.anuke.arc.collection.GridMap;
|
||||||
import io.anuke.arc.util.Structs;
|
|
||||||
import io.anuke.mindustry.content.Items;
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
import io.anuke.mindustry.content.Liquids;
|
||||||
import io.anuke.mindustry.content.Mechs;
|
import io.anuke.mindustry.content.Mechs;
|
||||||
@@ -30,7 +29,7 @@ public class SectorPresets{
|
|||||||
|
|
||||||
//command center mission
|
//command center mission
|
||||||
add(new SectorPreset(0, 1,
|
add(new SectorPreset(0, 1,
|
||||||
Structs.array(
|
Array.ofRecursive(
|
||||||
Missions.blockRecipe(UnitBlocks.daggerFactory),
|
Missions.blockRecipe(UnitBlocks.daggerFactory),
|
||||||
new UnitMission(UnitTypes.dagger),
|
new UnitMission(UnitTypes.dagger),
|
||||||
Missions.blockRecipe(UnitBlocks.commandCenter),
|
Missions.blockRecipe(UnitBlocks.commandCenter),
|
||||||
@@ -42,7 +41,7 @@ public class SectorPresets{
|
|||||||
|
|
||||||
//pad mission
|
//pad mission
|
||||||
add(new SectorPreset(0, -2,
|
add(new SectorPreset(0, -2,
|
||||||
Structs.array(
|
Array.ofRecursive(
|
||||||
Missions.blockRecipe(mobile ? UpgradeBlocks.alphaPad : UpgradeBlocks.dartPad),
|
Missions.blockRecipe(mobile ? UpgradeBlocks.alphaPad : UpgradeBlocks.dartPad),
|
||||||
new MechMission(mobile ? Mechs.alpha : Mechs.dart),
|
new MechMission(mobile ? Mechs.alpha : Mechs.dart),
|
||||||
new WaveMission(15)
|
new WaveMission(15)
|
||||||
@@ -51,7 +50,7 @@ public class SectorPresets{
|
|||||||
|
|
||||||
//oil mission
|
//oil mission
|
||||||
add(new SectorPreset(-2, 0,
|
add(new SectorPreset(-2, 0,
|
||||||
Structs.array(
|
Array.ofRecursive(
|
||||||
Missions.blockRecipe(ProductionBlocks.cultivator),
|
Missions.blockRecipe(ProductionBlocks.cultivator),
|
||||||
Missions.blockRecipe(ProductionBlocks.waterExtractor),
|
Missions.blockRecipe(ProductionBlocks.waterExtractor),
|
||||||
new ContentMission(Items.biomatter),
|
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);
|
stream.write(Team.all.length);
|
||||||
|
|
||||||
//write team data
|
//write team data
|
||||||
@@ -247,18 +225,6 @@ public class NetworkIO{
|
|||||||
tiles[x][y] = tile;
|
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();
|
state.teams = new Teams();
|
||||||
|
|
||||||
byte teams = stream.readByte();
|
byte teams = stream.readByte();
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
package io.anuke.mindustry.ui;
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
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.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
|
||||||
import io.anuke.arc.scene.Element;
|
import io.anuke.arc.scene.Element;
|
||||||
import io.anuke.arc.scene.event.InputEvent;
|
import io.anuke.arc.scene.event.InputEvent;
|
||||||
import io.anuke.arc.scene.event.InputListener;
|
import io.anuke.arc.scene.event.InputListener;
|
||||||
import io.anuke.arc.scene.ui.layout.Container;
|
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 class Minimap extends Container<Element>{
|
||||||
|
|
||||||
public Minimap(){
|
public Minimap(){
|
||||||
super(new Element(){
|
super(new Element(){
|
||||||
TextureRegion r = new TextureRegion();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
@@ -27,30 +23,6 @@ public class Minimap extends Container<Element>{
|
|||||||
if(renderer.minimap.getTexture() != null){
|
if(renderer.minimap.getTexture() != null){
|
||||||
renderer.minimap.drawEntities(x, y, width, height);
|
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;
|
pad = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell<TextButton> cell = ((Table) pane.getParent()).getCell(button);
|
Cell cell = ((Table) pane.getParent()).getCell(button);
|
||||||
|
|
||||||
if(!Mathf.isEqual(cell.getMinWidth(), pw)){
|
if(!Mathf.isEqual(cell.getMinWidth(), pw)){
|
||||||
cell.width(pw);
|
cell.width(pw);
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ public class Tile implements Position, TargetTrait{
|
|||||||
private byte team;
|
private byte team;
|
||||||
/** Tile elevation. -1 means slope.*/
|
/** Tile elevation. -1 means slope.*/
|
||||||
private byte elevation;
|
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){
|
public Tile(int x, int y){
|
||||||
this.x = (short) x;
|
this.x = (short) x;
|
||||||
@@ -67,10 +65,6 @@ public class Tile implements Position, TargetTrait{
|
|||||||
this.team = team;
|
this.team = team;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean discovered(){
|
|
||||||
return visibility > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**Returns this tile's position as a {@link Pos}.*/
|
/**Returns this tile's position as a {@link Pos}.*/
|
||||||
public int pos(){
|
public int pos(){
|
||||||
return Pos.get(x, y);
|
return Pos.get(x, y);
|
||||||
@@ -171,14 +165,6 @@ public class Tile implements Position, TargetTrait{
|
|||||||
this.floor = type;
|
this.floor = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getVisibility(){
|
|
||||||
return visibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVisibility(byte visibility){
|
|
||||||
this.visibility = visibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getRotation(){
|
public byte getRotation(){
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,14 +99,11 @@ public class Reconstructor extends Block{
|
|||||||
ReconstructorEntity entity = tile.entity();
|
ReconstructorEntity entity = tile.entity();
|
||||||
ReconstructorEntity oe = other.entity();
|
ReconstructorEntity oe = other.entity();
|
||||||
|
|
||||||
//called in main thread to prevent issues
|
unlink(entity);
|
||||||
threads.run(() -> {
|
unlink(oe);
|
||||||
unlink(entity);
|
|
||||||
unlink(oe);
|
|
||||||
|
|
||||||
entity.link = other.pos();
|
entity.link = other.pos();
|
||||||
oe.link = tile.pos();
|
oe.link = tile.pos();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.server, forward = true)
|
@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.entities.Units;
|
||||||
import io.anuke.mindustry.graphics.Layer;
|
import io.anuke.mindustry.graphics.Layer;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.mindustry.graphics.Shapes;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
@@ -71,11 +72,10 @@ public class RepairPoint extends Block{
|
|||||||
float ang = entity.angleTo(entity.target);
|
float ang = entity.angleTo(entity.target);
|
||||||
float len = 5f;
|
float len = 5f;
|
||||||
|
|
||||||
//TODO new laser drawing system
|
|
||||||
Draw.color(Color.valueOf("e8ffd7"));
|
Draw.color(Color.valueOf("e8ffd7"));
|
||||||
//Shapes.laser("laser", "laser-end",
|
Shapes.laser("laser", "laser-end",
|
||||||
// tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len),
|
tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len),
|
||||||
// entity.target.x, entity.target.y, entity.strength);
|
entity.target.x, entity.target.y, entity.strength);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package io.anuke.mindustry.desktop;
|
package io.anuke.mindustry.desktop;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.JsonValue;
|
import io.anuke.arc.Core;
|
||||||
import com.badlogic.gdx.utils.JsonValue.ValueType;
|
import io.anuke.arc.util.Log;
|
||||||
import com.badlogic.gdx.utils.JsonWriter.OutputType;
|
import io.anuke.arc.util.OS;
|
||||||
|
import io.anuke.arc.util.serialization.JsonValue;
|
||||||
|
import io.anuke.arc.util.serialization.JsonValue.ValueType;
|
||||||
|
import io.anuke.arc.util.serialization.JsonWriter.OutputType;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.game.Version;
|
import io.anuke.mindustry.game.Version;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.arc.core.Settings;
|
|
||||||
import io.anuke.arc.util.Log;
|
|
||||||
import io.anuke.arc.util.OS;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.anuke.mindustry.desktop;
|
package io.anuke.mindustry.desktop;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationListener;
|
import io.anuke.arc.ApplicationListener;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
import io.anuke.arc.backends.lwjgl3.Lwjgl3Application;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
import io.anuke.arc.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||||
import io.anuke.kryonet.KryoClient;
|
import io.anuke.kryonet.KryoClient;
|
||||||
import io.anuke.kryonet.KryoServer;
|
import io.anuke.kryonet.KryoServer;
|
||||||
import io.anuke.mindustry.Mindustry;
|
import io.anuke.mindustry.Mindustry;
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ package io.anuke.mindustry.desktop;
|
|||||||
import club.minnced.discord.rpc.DiscordEventHandlers;
|
import club.minnced.discord.rpc.DiscordEventHandlers;
|
||||||
import club.minnced.discord.rpc.DiscordRPC;
|
import club.minnced.discord.rpc.DiscordRPC;
|
||||||
import club.minnced.discord.rpc.DiscordRichPresence;
|
import club.minnced.discord.rpc.DiscordRichPresence;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import io.anuke.arc.collection.Array;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import com.badlogic.gdx.utils.Base64Coder;
|
import io.anuke.arc.function.Consumer;
|
||||||
|
import io.anuke.arc.util.OS;
|
||||||
|
import io.anuke.arc.util.Strings;
|
||||||
|
import io.anuke.arc.util.serialization.Base64Coder;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
import io.anuke.mindustry.game.GameMode;
|
import io.anuke.mindustry.game.GameMode;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||||
import io.anuke.arc.function.Consumer;
|
|
||||||
import io.anuke.arc.util.OS;
|
|
||||||
import io.anuke.arc.util.Strings;
|
|
||||||
|
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|||||||
BIN
net/build/libs/kryonet-release.jar
Normal file
BIN
net/build/libs/kryonet-release.jar
Normal file
Binary file not shown.
BIN
net/build/libs/net-release.jar
Normal file
BIN
net/build/libs/net-release.jar
Normal file
Binary file not shown.
@@ -2,10 +2,10 @@ package io.anuke.kryonet;
|
|||||||
|
|
||||||
import com.esotericsoftware.kryonet.FrameworkMessage;
|
import com.esotericsoftware.kryonet.FrameworkMessage;
|
||||||
import com.esotericsoftware.kryonet.serialization.Serialization;
|
import com.esotericsoftware.kryonet.serialization.Serialization;
|
||||||
|
import io.anuke.arc.function.Supplier;
|
||||||
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.net.Packet;
|
import io.anuke.mindustry.net.Packet;
|
||||||
import io.anuke.mindustry.net.Registrator;
|
import io.anuke.mindustry.net.Registrator;
|
||||||
import io.anuke.arc.function.Supplier;
|
|
||||||
import io.anuke.arc.util.Pooling;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package io.anuke.kryonet;
|
package io.anuke.kryonet;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.esotericsoftware.kryonet.*;
|
import com.esotericsoftware.kryonet.*;
|
||||||
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.collection.Array;
|
||||||
|
import io.anuke.arc.function.Consumer;
|
||||||
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.net.Host;
|
import io.anuke.mindustry.net.Host;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Net.ClientProvider;
|
import io.anuke.mindustry.net.Net.ClientProvider;
|
||||||
@@ -10,8 +12,6 @@ import io.anuke.mindustry.net.Net.SendMode;
|
|||||||
import io.anuke.mindustry.net.NetworkIO;
|
import io.anuke.mindustry.net.NetworkIO;
|
||||||
import io.anuke.mindustry.net.Packets.Connect;
|
import io.anuke.mindustry.net.Packets.Connect;
|
||||||
import io.anuke.mindustry.net.Packets.Disconnect;
|
import io.anuke.mindustry.net.Packets.Disconnect;
|
||||||
import io.anuke.arc.function.Consumer;
|
|
||||||
import io.anuke.arc.util.Pooling;
|
|
||||||
import net.jpountz.lz4.LZ4Factory;
|
import net.jpountz.lz4.LZ4Factory;
|
||||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||||
|
|
||||||
@@ -23,7 +23,8 @@ import java.net.NetworkInterface;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.ClosedSelectorException;
|
import java.nio.channels.ClosedSelectorException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.netClient;
|
||||||
|
import static io.anuke.mindustry.Vars.port;
|
||||||
|
|
||||||
public class KryoClient implements ClientProvider{
|
public class KryoClient implements ClientProvider{
|
||||||
final Client client;
|
final Client client;
|
||||||
@@ -50,7 +51,7 @@ public class KryoClient implements ClientProvider{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Gdx.app.postRunnable(() -> lastCallback.accept(host));
|
Core.app.post(() -> lastCallback.accept(host));
|
||||||
foundAddresses.add(datagramPacket.getAddress());
|
foundAddresses.add(datagramPacket.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +195,9 @@ public class KryoClient implements ClientProvider{
|
|||||||
ByteBuffer buffer = ByteBuffer.wrap(packet.getData());
|
ByteBuffer buffer = ByteBuffer.wrap(packet.getData());
|
||||||
Host host = NetworkIO.readServerData(packet.getAddress().getHostAddress(), buffer);
|
Host host = NetworkIO.readServerData(packet.getAddress().getHostAddress(), buffer);
|
||||||
|
|
||||||
Gdx.app.postRunnable(() -> valid.accept(host));
|
Core.app.post(() -> valid.accept(host));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Gdx.app.postRunnable(() -> invalid.accept(e));
|
Core.app.post(() -> invalid.accept(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -209,7 +210,7 @@ public class KryoClient implements ClientProvider{
|
|||||||
foundAddresses.clear();
|
foundAddresses.clear();
|
||||||
lastCallback = callback;
|
lastCallback = callback;
|
||||||
client.discoverHosts(port, 3000);
|
client.discoverHosts(port, 3000);
|
||||||
Gdx.app.postRunnable(done);
|
Core.app.post(done);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -231,9 +232,9 @@ public class KryoClient implements ClientProvider{
|
|||||||
|
|
||||||
private void handleException(Exception e){
|
private void handleException(Exception e){
|
||||||
if(e instanceof KryoNetException){
|
if(e instanceof KryoNetException){
|
||||||
Gdx.app.postRunnable(() -> Net.showError(new IOException("mismatch")));
|
Core.app.post(() -> Net.showError(new IOException("mismatch")));
|
||||||
}else{
|
}else{
|
||||||
Gdx.app.postRunnable(() -> Net.showError(e));
|
Core.app.post(() -> Net.showError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.anuke.kryonet;
|
package io.anuke.kryonet;
|
||||||
|
|
||||||
import com.esotericsoftware.minlog.Log;
|
import com.esotericsoftware.kryonet.util.Log;
|
||||||
import com.esotericsoftware.minlog.Log.Logger;
|
import com.esotericsoftware.kryonet.util.Log.Logger;
|
||||||
import io.anuke.arc.util.ColorCodes;
|
import io.anuke.arc.util.ColorCodes;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.kryonet;
|
package io.anuke.kryonet;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.dosse.upnp.UPnP;
|
import com.dosse.upnp.UPnP;
|
||||||
import com.esotericsoftware.kryonet.Connection;
|
import com.esotericsoftware.kryonet.Connection;
|
||||||
import com.esotericsoftware.kryonet.FrameworkMessage;
|
import com.esotericsoftware.kryonet.FrameworkMessage;
|
||||||
@@ -8,6 +7,10 @@ import com.esotericsoftware.kryonet.Listener;
|
|||||||
import com.esotericsoftware.kryonet.Listener.LagListener;
|
import com.esotericsoftware.kryonet.Listener.LagListener;
|
||||||
import com.esotericsoftware.kryonet.Server;
|
import com.esotericsoftware.kryonet.Server;
|
||||||
import com.esotericsoftware.kryonet.util.InputStreamSender;
|
import com.esotericsoftware.kryonet.util.InputStreamSender;
|
||||||
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.collection.Array;
|
||||||
|
import io.anuke.arc.util.Log;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.net.*;
|
import io.anuke.mindustry.net.*;
|
||||||
import io.anuke.mindustry.net.Net.SendMode;
|
import io.anuke.mindustry.net.Net.SendMode;
|
||||||
@@ -16,8 +19,6 @@ import io.anuke.mindustry.net.Packets.Connect;
|
|||||||
import io.anuke.mindustry.net.Packets.Disconnect;
|
import io.anuke.mindustry.net.Packets.Disconnect;
|
||||||
import io.anuke.mindustry.net.Packets.StreamBegin;
|
import io.anuke.mindustry.net.Packets.StreamBegin;
|
||||||
import io.anuke.mindustry.net.Packets.StreamChunk;
|
import io.anuke.mindustry.net.Packets.StreamChunk;
|
||||||
import io.anuke.arc.core.Timers;
|
|
||||||
import io.anuke.arc.util.Log;
|
|
||||||
import net.jpountz.lz4.LZ4Compressor;
|
import net.jpountz.lz4.LZ4Compressor;
|
||||||
import net.jpountz.lz4.LZ4Factory;
|
import net.jpountz.lz4.LZ4Factory;
|
||||||
|
|
||||||
@@ -27,8 +28,6 @@ import java.nio.channels.ClosedSelectorException;
|
|||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.threads;
|
|
||||||
|
|
||||||
public class KryoServer implements ServerProvider{
|
public class KryoServer implements ServerProvider{
|
||||||
final Server server;
|
final Server server;
|
||||||
final CopyOnWriteArrayList<KryoConnection> connections = new CopyOnWriteArrayList<>();
|
final CopyOnWriteArrayList<KryoConnection> connections = new CopyOnWriteArrayList<>();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
include 'desktop', 'core', 'kryonet', 'server', 'ios', 'annotations', 'tools', 'tests'
|
include 'desktop', 'core', 'net', 'server', 'ios', 'annotations', 'tools', 'tests'
|
||||||
|
|
||||||
def use = { String name, String path ->
|
def use = { String name, String path ->
|
||||||
include(name)
|
include(name)
|
||||||
@@ -25,9 +25,8 @@ if(System.properties["release"] == null || System.properties["release"] == "fals
|
|||||||
use(':Arc:arc-core', '../Arc/arc-core')
|
use(':Arc:arc-core', '../Arc/arc-core')
|
||||||
use(':Arc:extensions', '../Arc/extensions')
|
use(':Arc:extensions', '../Arc/extensions')
|
||||||
use(':Arc:extensions:freetype', '../Arc/extensions/freetype')
|
use(':Arc:extensions:freetype', '../Arc/extensions/freetype')
|
||||||
}
|
use(':Arc:backends', '../Arc/backends')
|
||||||
if (new File(settingsDir, '../GDXGifRecorder').exists()) {
|
use(':Arc:backends:backend-lwjgl3', '../Arc/backends/backend-lwjgl3')
|
||||||
use(':GDXGifRecorder', '../GDXGifRecorder')
|
|
||||||
}
|
}
|
||||||
if (new File(settingsDir, '../debug').exists()) {
|
if (new File(settingsDir, '../debug').exists()) {
|
||||||
use(':debug', '../debug')
|
use(':debug', '../debug')
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import com.badlogic.gdx.utils.OrderedMap;
|
import io.anuke.arc.collection.OrderedMap;
|
||||||
import com.badlogic.gdx.utils.PropertiesUtils;
|
|
||||||
import io.anuke.arc.function.BiFunction;
|
import io.anuke.arc.function.BiFunction;
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.arc.util.Log;
|
||||||
|
import io.anuke.arc.util.io.PropertiesUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion;
|
||||||
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
|
|
||||||
public class GenRegion extends TextureRegion {
|
public class GenRegion extends AtlasRegion{
|
||||||
public String name;
|
public String name;
|
||||||
public boolean invalid;
|
public boolean invalid;
|
||||||
public ImageContext context;
|
public ImageContext context;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import io.anuke.arc.Core;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.mindustry.entities.units.UnitType;
|
import io.anuke.mindustry.entities.units.UnitType;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
@@ -10,9 +12,8 @@ import io.anuke.mindustry.type.Mech;
|
|||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.blocks.Floor;
|
import io.anuke.mindustry.world.blocks.Floor;
|
||||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.graphics.Hue;
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
public class Generators {
|
public class Generators {
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ public class Generators {
|
|||||||
for (int y = 0; y < base.height(); y++) {
|
for (int y = 0; y < base.height(); y++) {
|
||||||
Color result = top.getColor(x, y);
|
Color result = top.getColor(x, y);
|
||||||
if(result.a > 0.01f){
|
if(result.a > 0.01f){
|
||||||
Hue.mix(result, color, 0.45f, result);
|
result.lerp(color, 0.45f);
|
||||||
base.draw(x, y, result);
|
base.draw(x, y, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +145,7 @@ public class Generators {
|
|||||||
for(Block block : content.blocks()){
|
for(Block block : content.blocks()){
|
||||||
if(!(block instanceof Floor)) continue;
|
if(!(block instanceof Floor)) continue;
|
||||||
Floor floor = (Floor)block;
|
Floor floor = (Floor)block;
|
||||||
if(floor.getIcon().length > 0 && !Draw.hasRegion(floor.name + "-cliff-side")){
|
if(floor.getIcon().length > 0 && !Core.atlas.has(floor.name + "-cliff-side")){
|
||||||
Image floori = context.get(floor.getIcon()[0]);
|
Image floori = context.get(floor.getIcon()[0]);
|
||||||
Color color = floori.getColor(0, 0).mul(1.3f, 1.3f, 1.3f, 1f);
|
Color color = floori.getColor(0, 0).mul(1.3f, 1.3f, 1.3f, 1f);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.util.Structs;
|
import io.anuke.arc.util.Structs;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -110,10 +110,10 @@ public class Image {
|
|||||||
x, y,
|
x, y,
|
||||||
x + region.getWidth(),
|
x + region.getWidth(),
|
||||||
y + region.getHeight(),
|
y + region.getHeight(),
|
||||||
(flipx ? region.getRegionX() + region.getWidth() : region.getRegionX()) + ofx,
|
(flipx ? region.getX() + region.getWidth() : region.getX()) + ofx,
|
||||||
(flipy ? region.getRegionY() + region.getHeight() : region.getRegionY()) + ofy,
|
(flipy ? region.getY() + region.getHeight() : region.getY()) + ofy,
|
||||||
(flipx ? region.getRegionX() : region.getRegionX() + region.getWidth()) + ofx,
|
(flipx ? region.getX() : region.getX() + region.getWidth()) + ofx,
|
||||||
(flipy ? region.getRegionY() : region.getRegionY() + region.getHeight()) + ofy,
|
(flipy ? region.getY() : region.getY() + region.getHeight()) + ofy,
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import io.anuke.arc.Core;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData;
|
import io.anuke.arc.collection.ObjectMap;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion;
|
||||||
import io.anuke.mindustry.core.ContentLoader;
|
import io.anuke.arc.graphics.g2d.TextureAtlas.TextureAtlasData;
|
||||||
import io.anuke.arc.core.Core;
|
import io.anuke.arc.graphics.g2d.TextureAtlas.TextureAtlasData.Region;
|
||||||
import io.anuke.arc.core.Timers;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.util.Atlas;
|
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.arc.util.Log;
|
||||||
import io.anuke.arc.util.Log.LogHandler;
|
import io.anuke.arc.util.Log.LogHandler;
|
||||||
import io.anuke.arc.util.Log.NoopLogHandler;
|
import io.anuke.arc.util.Log.NoopLogHandler;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.mindustry.core.ContentLoader;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@@ -31,7 +32,7 @@ public class ImageContext {
|
|||||||
TextureAtlasData data = new TextureAtlasData(new FileHandle(spritesFolder + "/sprites.atlas"),
|
TextureAtlasData data = new TextureAtlasData(new FileHandle(spritesFolder + "/sprites.atlas"),
|
||||||
new FileHandle(spritesFolder), false);
|
new FileHandle(spritesFolder), false);
|
||||||
|
|
||||||
ObjectMap<String, TextureRegion> regionCache = new ObjectMap<>();
|
ObjectMap<String, AtlasRegion> regionCache = new ObjectMap<>();
|
||||||
|
|
||||||
for(Region region : data.getRegions()){
|
for(Region region : data.getRegions()){
|
||||||
int x = region.left, y = region.top, width = region.width, height = region.height;
|
int x = region.left, y = region.top, width = region.width, height = region.height;
|
||||||
@@ -43,30 +44,30 @@ public class ImageContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegionX(){
|
public int getX(){
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegionY(){
|
public int getY(){
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegionWidth(){
|
public int getWidth(){
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegionHeight(){
|
public int getHeight(){
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.atlas = new Atlas(){
|
Core.atlas = new TextureAtlas(){
|
||||||
@Override
|
@Override
|
||||||
public TextureRegion getRegion(String name){
|
public AtlasRegion find(String name){
|
||||||
if(!regionCache.containsKey(name)){
|
if(!regionCache.containsKey(name)){
|
||||||
GenRegion region = new GenRegion();
|
GenRegion region = new GenRegion();
|
||||||
region.name = name;
|
region.name = name;
|
||||||
@@ -78,13 +79,11 @@ public class ImageContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasRegion(String s) {
|
public boolean has(String s) {
|
||||||
return regionCache.containsKey(s);
|
return regionCache.containsKey(s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Core.atlas.setErrorRegion("error");
|
|
||||||
|
|
||||||
image = ImageIO.read(new File(spritesFolder + "/sprites.png"));
|
image = ImageIO.read(new File(spritesFolder + "/sprites.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ public class ImageContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Image get(String name){
|
public Image get(String name){
|
||||||
return get(Core.atlas.getRegion(name));
|
return get(Core.atlas.find(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image get(TextureRegion region){
|
public Image get(TextureRegion region){
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import io.anuke.arc.core.Timers;
|
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.arc.util.Log;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user