Cleanup, main menu progress
|
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 504 B After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 468 B After Width: | Height: | Size: 4 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 589 B After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 71 B After Width: | Height: | Size: 71 B |
|
Before Width: | Height: | Size: 299 B |
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
duplicatePadding: true,
|
||||
combineSubdirectories: true,
|
||||
flattenPaths: true,
|
||||
maxWidth: 1024,
|
||||
maxHeight: 1024,
|
||||
fast: true
|
||||
}
|
||||
|
Before Width: | Height: | Size: 70 B |
|
|
@ -2,7 +2,7 @@
|
|||
duplicatePadding: true,
|
||||
combineSubdirectories: true,
|
||||
flattenPaths: true,
|
||||
maxWidth: 1024,
|
||||
maxHeight: 1024,
|
||||
maxWidth: 2048,
|
||||
maxHeight: 2048,
|
||||
fast: true
|
||||
}
|
||||
BIN
core/assets-raw/sprites/ui/whiteui.png
Normal file
|
After Width: | Height: | Size: 71 B |
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 711 B |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1 MiB |
|
Before Width: | Height: | Size: 254 KiB After Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 276 KiB |
BIN
core/assets/sprites/sprites4.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 161 KiB |
|
Before Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 293 KiB |
|
Before Width: | Height: | Size: 233 KiB |
|
|
@ -9,15 +9,15 @@
|
|||
},
|
||||
TintedDrawable: {
|
||||
dialogDim: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { r: 0, g: 0, b: 0, a: 0.9 }
|
||||
},
|
||||
guideDim: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { r: 0, g: 0, b: 0, a: 0.3 }
|
||||
},
|
||||
invis: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { r: 0, g: 0, b: 0, a: 0 }
|
||||
}
|
||||
loadDim: {
|
||||
|
|
@ -25,27 +25,27 @@
|
|||
color: { r: 0, g: 0, b: 0, a: 0.8 }
|
||||
},
|
||||
chatfield: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { r: 0, g: 0, b: 0, a: 0.2 }
|
||||
},
|
||||
dark: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { hex: "#000000ff" }
|
||||
},
|
||||
none: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { r: 0, g: 0, b: 0, a: 0 }
|
||||
},
|
||||
flat: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { r: 0.0, g: 0.0, b: 0.0, a: 0.6 }
|
||||
},
|
||||
flat-over: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { hex: "#ffffff82" }
|
||||
},
|
||||
flat-down: {
|
||||
name: white,
|
||||
name: whiteui,
|
||||
color: { hex: "#ffd37fff" }
|
||||
}
|
||||
},
|
||||
|
|
@ -111,7 +111,7 @@
|
|||
up: info-banner
|
||||
},
|
||||
clear-partial: {
|
||||
down: white,
|
||||
down: whiteui,
|
||||
up: button-select,
|
||||
over: flat-down,
|
||||
font: default-font,
|
||||
|
|
@ -209,7 +209,7 @@
|
|||
over: flat-over
|
||||
},
|
||||
clear-full: {
|
||||
down: white,
|
||||
down: whiteui,
|
||||
up: button-select,
|
||||
over: flat-down
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,12 +2,9 @@ package io.anuke.mindustry;
|
|||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.Texture;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.SpriteBatch;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.EventType.GameLoadEvent;
|
||||
import io.anuke.mindustry.io.BundleLoader;
|
||||
|
|
@ -16,6 +13,7 @@ import static io.anuke.arc.Core.batch;
|
|||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Mindustry extends ApplicationCore{
|
||||
private long lastTime;
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
|
|
@ -55,42 +53,42 @@ public class Mindustry extends ApplicationCore{
|
|||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
setup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
long lastFrameTime = Time.nanos();
|
||||
|
||||
super.update();
|
||||
|
||||
int fpsCap = Core.settings.getInt("fpscap", 125);
|
||||
int targetfps = Core.settings.getInt("fpscap", 120);
|
||||
|
||||
if(fpsCap <= 120){
|
||||
long target = (1000 * 1000000) / fpsCap; //target in nanos
|
||||
long elapsed = Time.timeSinceNanos(lastFrameTime);
|
||||
if(targetfps > 0 && targetfps <= 120){
|
||||
long target = (1000 * 1000000) / targetfps; //target in nanos
|
||||
long elapsed = Time.timeSinceNanos(lastTime);
|
||||
if(elapsed < target){
|
||||
try{
|
||||
Thread.sleep((target - elapsed) / 1000000, (int)((target - elapsed) % 1000000));
|
||||
}catch(InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}catch(InterruptedException ignored){
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastTime = Time.nanos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
setup();
|
||||
}
|
||||
|
||||
void drawLoading(){
|
||||
Core.graphics.clear(Color.BLACK);
|
||||
Draw.proj().setOrtho(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||
|
||||
Texture icon = new Texture("sprites/logotext.png");
|
||||
float width = Math.min(Core.graphics.getWidth() - 10f, icon.getWidth());
|
||||
Draw.rect(Draw.wrap(icon), Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f, width, (float)icon.getHeight() / icon.getWidth() * width);
|
||||
Draw.flush();
|
||||
//Texture icon = new Texture("sprites/logotext.png");
|
||||
//float width = Math.min(Core.graphics.getWidth() - 10f, icon.getWidth());
|
||||
//Draw.rect(Draw.wrap(icon), Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f, width, (float)icon.getHeight() / icon.getWidth() * width);
|
||||
//Draw.flush();
|
||||
|
||||
icon.dispose();
|
||||
//icon.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ import io.anuke.mindustry.entities.bullet.BulletType;
|
|||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.blocks.defense.*;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.*;
|
||||
|
|
@ -310,11 +309,11 @@ public class Blocks implements ContentList{
|
|||
saltRocks = new StaticWall("saltrocks"){{
|
||||
}};
|
||||
|
||||
sporePine = new StaticWall("spore-pine"){{
|
||||
sporePine = new StaticTree("spore-pine"){{
|
||||
variants = 0;
|
||||
}};
|
||||
|
||||
pine = new StaticWall("pine"){{
|
||||
pine = new StaticTree("pine"){{
|
||||
variants = 0;
|
||||
}};
|
||||
|
||||
|
|
|
|||
18
core/src/io/anuke/mindustry/content/TypeIDs.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package io.anuke.mindustry.content;
|
||||
|
||||
import io.anuke.mindustry.entities.effect.Fire;
|
||||
import io.anuke.mindustry.entities.effect.Puddle;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.game.TypeID;
|
||||
|
||||
public class TypeIDs implements ContentList{
|
||||
public static TypeID fire, puddle, player;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
fire = new TypeID("fire", Fire::new);
|
||||
puddle = new TypeID("puddle", Puddle::new);
|
||||
player = new TypeID("player", Player::new);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,10 +7,6 @@ import io.anuke.arc.graphics.Pixmap;
|
|||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.effect.Fire;
|
||||
import io.anuke.mindustry.entities.effect.Puddle;
|
||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
|
|
@ -43,6 +39,7 @@ public class ContentLoader{
|
|||
new Loadouts(),
|
||||
new TechTree(),
|
||||
new Zones(),
|
||||
new TypeIDs(),
|
||||
|
||||
//these are not really content classes, but this makes initialization easier
|
||||
new LegacyColorMapper(),
|
||||
|
|
@ -59,8 +56,6 @@ public class ContentLoader{
|
|||
return;
|
||||
}
|
||||
|
||||
registerTypes();
|
||||
|
||||
for(ContentType type : ContentType.values()){
|
||||
contentMap[type.ordinal()] = new Array<>();
|
||||
contentNameMap[type.ordinal()] = new ObjectMap<>();
|
||||
|
|
@ -232,14 +227,4 @@ public class ContentLoader{
|
|||
public Array<UnitType> units(){
|
||||
return getBy(ContentType.unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers sync IDs for all types of sync entities.
|
||||
* Do not register units here!
|
||||
*/
|
||||
private void registerTypes(){
|
||||
TypeTrait.registerType(Player.class, Player::new);
|
||||
TypeTrait.registerType(Fire.class, Fire::new);
|
||||
TypeTrait.registerType(Puddle.class, Puddle::new);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package io.anuke.mindustry.core;
|
|||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.GL20;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureAtlas;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
|
|
@ -23,7 +22,6 @@ import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
|||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import static io.anuke.arc.Core.scene;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
|
@ -43,10 +41,6 @@ public class Control implements ApplicationListener{
|
|||
private InputHandler input;
|
||||
|
||||
public Control(){
|
||||
IntBuffer buf = BufferUtils.newIntBuffer(1);
|
||||
Core.gl.glGetIntegerv(GL20.GL_MAX_TEXTURE_SIZE, buf);
|
||||
int maxSize = buf.get(0);
|
||||
|
||||
saves = new Saves();
|
||||
data = new GlobalData();
|
||||
|
||||
|
|
@ -55,7 +49,7 @@ public class Control implements ApplicationListener{
|
|||
Effects.setShakeFalloff(10000f);
|
||||
|
||||
content.initialize(Content::init);
|
||||
Core.atlas = new TextureAtlas(maxSize < 2048 ? "sprites/sprites_fallback.atlas" : "sprites/sprites.atlas");
|
||||
Core.atlas = new TextureAtlas("sprites/sprites.atlas");
|
||||
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
|
||||
content.initialize(Content::load, true);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ import io.anuke.mindustry.entities.Entities;
|
|||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||
import io.anuke.mindustry.entities.traits.SyncTrait;
|
||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.type.Unit;
|
||||
import io.anuke.mindustry.game.TypeID;
|
||||
import io.anuke.mindustry.game.Version;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.gen.RemoteReadClient;
|
||||
|
|
@ -25,6 +25,7 @@ import io.anuke.mindustry.net.Administration.TraceInfo;
|
|||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.net.Net.SendMode;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.modules.ItemModule;
|
||||
|
||||
|
|
@ -240,7 +241,7 @@ public class NetClient implements ApplicationListener{
|
|||
|
||||
//entity must not be added yet, so create it
|
||||
if(entity == null){
|
||||
entity = (SyncTrait)TypeTrait.getTypeByID(typeID).get(); //create entity from supplier
|
||||
entity = (SyncTrait)content.<TypeID>getByID(ContentType.typeid, typeID).constructor.get();
|
||||
entity.resetID(id);
|
||||
if(!netClient.isEntityUsed(entity.getID())){
|
||||
add = true;
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ public class NetServer implements ApplicationListener{
|
|||
|
||||
//write all entities now
|
||||
dataStream.writeInt(entity.getID()); //write id
|
||||
dataStream.writeByte(sync.getTypeID()); //write type ID
|
||||
dataStream.writeByte(sync.getTypeID().id); //write type ID
|
||||
sync.write(dataStream); //write entity
|
||||
|
||||
sent++;
|
||||
|
|
|
|||
|
|
@ -189,11 +189,12 @@ public class Renderer implements ApplicationListener{
|
|||
|
||||
drawAllTeams(false);
|
||||
|
||||
blocks.skipLayer(Layer.turret);
|
||||
blocks.drawBlocks(Layer.laser);
|
||||
blocks.drawBlocks(Layer.turret);
|
||||
|
||||
drawFlyerShadows();
|
||||
|
||||
blocks.drawBlocks(Layer.power);
|
||||
|
||||
drawAllTeams(true);
|
||||
|
||||
draw(bulletGroup);
|
||||
|
|
@ -280,7 +281,6 @@ public class Renderer implements ApplicationListener{
|
|||
|
||||
draw(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
||||
draw(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll);
|
||||
blocks.drawTeamBlocks(Layer.turret, team);
|
||||
|
||||
draw(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawOver);
|
||||
draw(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawOver);
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||
int i = 0;
|
||||
|
||||
for(Team team : Team.all){
|
||||
ImageButton button = new ImageButton("white", "clear-toggle-partial");
|
||||
ImageButton button = new ImageButton("whiteui", "clear-toggle-partial");
|
||||
button.margin(4f);
|
||||
button.getImageCell().grow();
|
||||
button.getStyle().imageUpColor = team.color;
|
||||
|
|
@ -636,7 +636,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||
|
||||
if(!Core.atlas.isFound(region)) continue;
|
||||
|
||||
ImageButton button = new ImageButton("white", "clear-toggle");
|
||||
ImageButton button = new ImageButton("whiteui", "clear-toggle");
|
||||
button.getStyle().imageUp = new TextureRegionDrawable(region);
|
||||
button.clicked(() -> editor.drawBlock = block);
|
||||
button.resizeImage(8 * 4f);
|
||||
|
|
|
|||
|
|
@ -5,13 +5,15 @@ import io.anuke.arc.collection.IntMap;
|
|||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.impl.TimedEntity;
|
||||
import io.anuke.mindustry.entities.traits.SaveTrait;
|
||||
import io.anuke.mindustry.entities.traits.SyncTrait;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.game.TypeID;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
|
@ -75,6 +77,11 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeID getTypeID(){
|
||||
return TypeIDs.fire;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte version(){
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import io.anuke.mindustry.content.*;
|
|||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.impl.SolidEntity;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.game.TypeID;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
|
|
@ -143,6 +144,11 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||
return liquid.flammability * amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeID getTypeID(){
|
||||
return TypeIDs.puddle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte version(){
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package io.anuke.mindustry.entities.traits;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
|
|
@ -89,7 +90,7 @@ public interface MinerTrait extends Entity{
|
|||
|
||||
Draw.color(Color.LIGHT_GRAY, Color.WHITE, 1f - flashScl + Mathf.absin(Time.time(), 0.5f, flashScl));
|
||||
|
||||
Shapes.laser("minelaser", "minelaser-end", px, py, ex, ey, 0.75f);
|
||||
Shapes.laser(Core.atlas.find("minelaser"), Core.atlas.find("minelaser-end"), px, py, ex, ey, 0.75f);
|
||||
|
||||
if(unit instanceof Player && ((Player)unit).isLocal){
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
package io.anuke.mindustry.entities.traits;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.ObjectIntMap;
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.mindustry.game.TypeID;
|
||||
|
||||
public interface TypeTrait{
|
||||
|
||||
TypeID getTypeID();
|
||||
/*
|
||||
int[] lastRegisteredID = {0};
|
||||
Array<Supplier<? extends TypeTrait>> registeredTypes = new Array<>();
|
||||
ObjectIntMap<Class<? extends TypeTrait>> typeToID = new ObjectIntMap<>();
|
||||
|
||||
/**
|
||||
* Register and return a type ID. The supplier should return a fresh instace of that type.
|
||||
*/
|
||||
|
||||
static <T extends TypeTrait> void registerType(Class<T> type, Supplier<T> supplier){
|
||||
if(typeToID.get(type, -1) != -1){
|
||||
return; //already registered
|
||||
|
|
@ -23,7 +24,7 @@ public interface TypeTrait{
|
|||
lastRegisteredID[0]++;
|
||||
}
|
||||
|
||||
/**Gets a syncable type by ID.*/
|
||||
/**Gets a syncable type by ID.
|
||||
static Supplier<? extends TypeTrait> getTypeByID(int id){
|
||||
if(id == -1){
|
||||
throw new IllegalArgumentException("Attempt to retrieve invalid entity type ID! Did you forget to set it in ContentLoader.registerTypes()?");
|
||||
|
|
@ -34,11 +35,11 @@ public interface TypeTrait{
|
|||
/**
|
||||
* Returns the type ID of this entity used for intstantiation. Should be < BYTE_MAX.
|
||||
* Do not override!
|
||||
*/
|
||||
|
||||
default int getTypeID(){
|
||||
int id = typeToID.get(getClass(), -1);
|
||||
if(id == -1)
|
||||
throw new RuntimeException("Class of type '" + getClass() + "' is not registered! Did you forget to register it in ContentLoader#registerTypes()?");
|
||||
return id;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import io.anuke.mindustry.entities.traits.ShooterTrait;
|
|||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.entities.units.*;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.TypeID;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
|
@ -80,6 +81,11 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
return type.drag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeID getTypeID(){
|
||||
return type.typeID;
|
||||
}
|
||||
|
||||
public Tile getSpawner(){
|
||||
return world.tile(spawner);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||
if(target == null){
|
||||
setState(patrol);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if(target != null){
|
||||
attack(type.attackLength);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ import io.anuke.arc.math.geom.*;
|
|||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.TypeID;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
|
|
@ -115,6 +115,11 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||
heal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeID getTypeID(){
|
||||
return TypeIDs.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(float x, float y){
|
||||
if(!mech.flying){
|
||||
|
|
|
|||
19
core/src/io/anuke/mindustry/game/TypeID.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
|
||||
public class TypeID extends MappableContent{
|
||||
public final Supplier<? extends TypeTrait> constructor;
|
||||
|
||||
public TypeID(String name, Supplier<? extends TypeTrait> constructor){
|
||||
super(name);
|
||||
this.constructor = constructor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentType getContentType(){
|
||||
return ContentType.typeid;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +1,16 @@
|
|||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.Sort;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.Texture.TextureFilter;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.arc.Core.camera;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,5 @@ public enum Layer{
|
|||
/** "High" blocks, like turrets. */
|
||||
turret,
|
||||
/** Power lasers. */
|
||||
power,
|
||||
/** Extra lasers, like healing turrets. */
|
||||
laser
|
||||
power
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,36 @@
|
|||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.function.PositionConsumer;
|
||||
import io.anuke.arc.graphics.Camera;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||
import io.anuke.arc.math.Matrix3;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.noise.RidgedPerlin;
|
||||
import io.anuke.arc.util.noise.Simplex;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MenuRenderer implements Disposable{
|
||||
private static final int width = 100, height = 50;
|
||||
private static final float darkness = 0.1f;
|
||||
private static final float darkness = 0.3f;
|
||||
|
||||
private int cacheFloor, cacheWall;
|
||||
private Camera camera = new Camera();
|
||||
private Matrix3 mat = new Matrix3();
|
||||
private FrameBuffer shadows;
|
||||
private CacheBatch batch;
|
||||
private float time = 0f;
|
||||
private float flyerRot = 45f;
|
||||
private int flyers = Mathf.chance(0.2) ? Mathf.random(30) : Mathf.random(12);
|
||||
|
||||
public MenuRenderer(){
|
||||
Time.mark();
|
||||
|
|
@ -32,34 +41,109 @@ public class MenuRenderer implements Disposable{
|
|||
|
||||
private void generate(){
|
||||
Tile[][] tiles = world.createTiles(width, height);
|
||||
Array<Block> ores = content.blocks().select(b -> b instanceof OreBlock);
|
||||
shadows = new FrameBuffer(width, height);
|
||||
Simplex s1 = new Simplex(0);
|
||||
Simplex s2 = new Simplex(1);
|
||||
Simplex s3 = new Simplex(2);
|
||||
int offset = Mathf.random(100000);
|
||||
Simplex s1 = new Simplex(offset);
|
||||
Simplex s2 = new Simplex(offset + 1);
|
||||
Simplex s3 = new Simplex(offset + 2);
|
||||
RidgedPerlin rid = new RidgedPerlin(1 + offset, 1);
|
||||
Block[] selected = Structs.select(
|
||||
new Block[]{Blocks.moss, Blocks.sporePine},
|
||||
new Block[]{Blocks.sand, Blocks.sandRocks},
|
||||
new Block[]{Blocks.shale, Blocks.shaleRocks},
|
||||
new Block[]{Blocks.ice, Blocks.icerocks}
|
||||
);
|
||||
Block[] selected2 = Structs.select(
|
||||
new Block[]{Blocks.moss, Blocks.sporerocks},
|
||||
new Block[]{Blocks.ignarock, Blocks.duneRocks},
|
||||
new Block[]{Blocks.stone, Blocks.rocks},
|
||||
new Block[]{Blocks.stone, Blocks.rocks},
|
||||
new Block[]{Blocks.salt, Blocks.saltRocks}
|
||||
);
|
||||
|
||||
Block ore1 = ores.random();
|
||||
ores.remove(ore1);
|
||||
Block ore2 = ores.random();
|
||||
|
||||
double tr1 = Mathf.random(0.65f, 0.85f);
|
||||
double tr2 = Mathf.random(0.65f, 0.85f);
|
||||
boolean doheat = Mathf.chance(0.25);
|
||||
boolean tendrils = Mathf.chance(0.25);
|
||||
boolean tech = Mathf.chance(0.25);
|
||||
int secSize = 10;
|
||||
|
||||
Block floord = selected[0], walld = selected[1];
|
||||
Block floord2 = selected2[0], walld2 = selected2[1];
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Block floor = Blocks.shale;
|
||||
Block floor = floord;
|
||||
Block ore = Blocks.air;
|
||||
Block wall = Blocks.air;
|
||||
|
||||
if(s1.octaveNoise2D(3, 0.5, 1/20.0, x, y) > 0.5){
|
||||
wall = Blocks.shaleRocks;
|
||||
wall = walld;
|
||||
}
|
||||
|
||||
if(s3.octaveNoise2D(3, 0.5, 1/20.0, x, y) > 0.5){
|
||||
floor = Blocks.stone;
|
||||
floor = floord2;
|
||||
if(wall != Blocks.air){
|
||||
wall = Blocks.rocks;
|
||||
wall = walld2;
|
||||
}
|
||||
}
|
||||
|
||||
if(s2.octaveNoise2D(3, 0.3, 1/30.0, x, y) > 0.5){
|
||||
ore = Blocks.oreCopper;
|
||||
if(s2.octaveNoise2D(3, 0.3, 1/30.0, x, y) > tr1){
|
||||
ore = ore1;
|
||||
}
|
||||
|
||||
if(s2.octaveNoise2D(2, 0.2, 1/15.0, x, y+99999) > 0.7){
|
||||
ore = Blocks.oreLead;
|
||||
if(s2.octaveNoise2D(2, 0.2, 1/15.0, x, y+99999) > tr2){
|
||||
ore = ore2;
|
||||
}
|
||||
|
||||
if(doheat){
|
||||
double heat = s3.octaveNoise2D(4, 0.6, 1 / 50.0, x, y + 9999);
|
||||
double base = 0.65;
|
||||
|
||||
if(heat > base){
|
||||
ore = Blocks.air;
|
||||
wall = Blocks.air;
|
||||
floor = Blocks.ignarock;
|
||||
|
||||
if(heat > base + 0.1){
|
||||
floor = Blocks.hotrock;
|
||||
|
||||
if(heat > base + 0.15){
|
||||
floor = Blocks.magmarock;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tech){
|
||||
int mx = x % secSize, my = y % secSize;
|
||||
int sclx = x / secSize, scly = y / secSize;
|
||||
if(s1.octaveNoise2D(2, 1f / 10f, 0.5f, sclx, scly) > 0.4f && (mx == 0 || my == 0 || mx == secSize - 1 || my == secSize - 1)){
|
||||
floor = Blocks.darkPanel3;
|
||||
if(Mathf.dst(mx, my, secSize/2, secSize/2) > secSize/2f + 1){
|
||||
floor = Blocks.darkPanel4;
|
||||
}
|
||||
|
||||
|
||||
if(wall != Blocks.air && Mathf.chance(0.7)){
|
||||
wall = Blocks.darkMetal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tendrils){
|
||||
if(rid.getValue(x, y, 1f / 17f) > 0f){
|
||||
floor = Mathf.chance(0.2) ? Blocks.sporeMoss : Blocks.moss;
|
||||
|
||||
if(wall != Blocks.air){
|
||||
wall = Blocks.sporerocks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tile tile;
|
||||
|
|
@ -130,7 +214,8 @@ public class MenuRenderer implements Disposable{
|
|||
}
|
||||
|
||||
public void render(){
|
||||
float scaling = 4f;
|
||||
time += Time.delta();
|
||||
float scaling = Math.max(Unit.dp.scl(4f), Math.max(Core.graphics.getWidth() / ((width - 1f) * tilesize), Core.graphics.getHeight() / ((height - 1f) * tilesize)));
|
||||
camera.position.set(width * tilesize / 2f, height * tilesize / 2f);
|
||||
camera.resize(Core.graphics.getWidth() / scaling,
|
||||
Core.graphics.getHeight() / scaling);
|
||||
|
|
@ -150,12 +235,56 @@ public class MenuRenderer implements Disposable{
|
|||
batch.drawCache(cacheWall);
|
||||
batch.endDraw();
|
||||
|
||||
drawFlyers();
|
||||
|
||||
Draw.proj(mat);
|
||||
Draw.color(0f, 0f, 0f, darkness);
|
||||
Fill.crect(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
private void drawFlyers(){
|
||||
Draw.color(0f, 0f, 0f, 0.4f);
|
||||
|
||||
flyers((x, y) -> {
|
||||
Draw.rect("wraith", x - 12f, y - 13f, flyerRot - 90);
|
||||
});
|
||||
|
||||
flyers((x, y) -> {
|
||||
Draw.rect("circle-shadow", x, y, 18f, 18f);
|
||||
});
|
||||
Draw.color();
|
||||
|
||||
flyers((x, y) -> {
|
||||
float engineOffset = 5.5f, engineSize = 2f, rotation = flyerRot;
|
||||
|
||||
Draw.color(Pal.engine);
|
||||
Fill.circle(x + Angles.trnsx(rotation + 180, engineOffset), y + Angles.trnsy(rotation + 180, engineOffset),
|
||||
engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f));
|
||||
|
||||
Draw.color(Color.WHITE);
|
||||
Fill.circle(x + Angles.trnsx(rotation + 180, engineOffset - 1f), y + Angles.trnsy(rotation + 180, engineOffset - 1f),
|
||||
(engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f)) / 2f);
|
||||
Draw.color();
|
||||
|
||||
Draw.rect("wraith", x, y, flyerRot - 90);
|
||||
});
|
||||
}
|
||||
|
||||
private void flyers(PositionConsumer cons){
|
||||
float tw = width * tilesize * 2;
|
||||
float th = height * tilesize * 2;
|
||||
float range = 500f;
|
||||
float offset = -300f;
|
||||
|
||||
for(int i = 0; i < flyers; i++){
|
||||
Tmp.v1.trns(flyerRot, time * 3f);
|
||||
|
||||
cons.accept((Mathf.randomSeedRange(i, range) + Tmp.v1.x + Mathf.absin(time + Mathf.randomSeedRange(i + 2, 500), 10f, 3f) + offset) % tw,
|
||||
(Mathf.randomSeedRange(i + 1, range) + Tmp.v1.y + Mathf.absin(time + Mathf.randomSeedRange(i + 3, 500), 10f, 3f) + offset) % th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
batch.dispose();
|
||||
|
|
|
|||
|
|
@ -7,24 +7,22 @@ import io.anuke.arc.util.Tmp;
|
|||
|
||||
public class Shapes{
|
||||
|
||||
public static void laser(String line, String edge, float x, float y, float x2, float y2, float scale){
|
||||
public static void laser(TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float scale){
|
||||
laser(line, edge, x, y, x2, y2, Mathf.angle(x2 - x, y2 - y), scale);
|
||||
}
|
||||
|
||||
public static void laser(String line, String edge, float x, float y, float x2, float y2){
|
||||
public static void laser(TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2){
|
||||
laser(line, edge, x, y, x2, y2, Mathf.angle(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){
|
||||
TextureRegion region = Core.atlas.find(edge);
|
||||
|
||||
public static void laser(TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float rotation, float scale){
|
||||
Tmp.v1.trns(rotation, 8f * scale * Draw.scl);
|
||||
|
||||
Draw.rect(Core.atlas.find(edge), x, y, region.getWidth() * scale * Draw.scl, region.getHeight() * scale * Draw.scl, rotation + 180);
|
||||
Draw.rect(Core.atlas.find(edge), x2, y2, region.getWidth() * scale * Draw.scl, region.getHeight() * scale * Draw.scl, rotation);
|
||||
Draw.rect(edge, x, y, edge.getWidth() * scale * Draw.scl, edge.getHeight() * scale * Draw.scl, rotation + 180);
|
||||
Draw.rect(edge, x2, y2, edge.getWidth() * scale * Draw.scl, edge.getHeight() * scale * Draw.scl, rotation);
|
||||
|
||||
Lines.stroke(12f * scale);
|
||||
Lines.line(Core.atlas.find(line), x + Tmp.v1.x, y + Tmp.v1.y, x2 - Tmp.v1.x, y2 - Tmp.v1.y, CapStyle.none, 0f);
|
||||
Lines.line(line, x + Tmp.v1.x, y + Tmp.v1.y, x2 - Tmp.v1.x, y2 - Tmp.v1.y, CapStyle.none, 0f);
|
||||
Lines.stroke(1f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import io.anuke.arc.util.io.CounterInputStream;
|
|||
import io.anuke.arc.util.io.FastDeflaterOutputStream;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.versions.Save1;
|
||||
import io.anuke.mindustry.io.versions.Save2;
|
||||
import io.anuke.mindustry.world.WorldContext;
|
||||
|
||||
import java.io.*;
|
||||
|
|
@ -18,7 +19,7 @@ public class SaveIO{
|
|||
/** Format header. This is the string 'MSAV' in ASCII. */
|
||||
public static final byte[] header = {77, 83, 65, 86};
|
||||
public static final IntMap<SaveVersion> versions = new IntMap<>();
|
||||
public static final Array<SaveVersion> versionArray = Array.with(new Save1());
|
||||
public static final Array<SaveVersion> versionArray = Array.with(new Save1(), new Save2());
|
||||
|
||||
static{
|
||||
for(SaveVersion version : versionArray){
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import io.anuke.arc.util.Time;
|
|||
import io.anuke.arc.util.io.CounterInputStream;
|
||||
import io.anuke.mindustry.entities.Entities;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.traits.Entity;
|
||||
import io.anuke.mindustry.entities.traits.SaveTrait;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.BrokenBlock;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
|
|
@ -20,6 +21,9 @@ import static io.anuke.mindustry.Vars.*;
|
|||
public abstract class SaveVersion extends SaveFileReader{
|
||||
public final int version;
|
||||
|
||||
//HACK stores the last read build of the save file, valid after read meta call
|
||||
protected int lastReadBuild;
|
||||
|
||||
public SaveVersion(int version){
|
||||
this.version = version;
|
||||
}
|
||||
|
|
@ -78,6 +82,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||
state.stats = JsonIO.read(Stats.class, map.get("stats", "{}"));
|
||||
state.rules = JsonIO.read(Rules.class, map.get("rules", "{}"));
|
||||
if(state.rules.spawns.isEmpty()) state.rules.spawns = defaultWaves.get();
|
||||
lastReadBuild = map.getInt("build", -1);
|
||||
|
||||
Map worldmap = world.maps.byName(map.get("mapname", "\\\\\\"));
|
||||
world.setMap(worldmap == null ? new Map(StringMap.of(
|
||||
|
|
@ -222,7 +227,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||
SaveTrait save = (SaveTrait)entity;
|
||||
//each entity is a separate chunk.
|
||||
writeChunk(stream, true, out -> {
|
||||
out.writeByte(save.getTypeID());
|
||||
out.writeByte(save.getTypeID().id);
|
||||
out.writeByte(save.version());
|
||||
save.writeSave(out);
|
||||
});
|
||||
|
|
@ -241,9 +246,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||
readChunk(stream, true, in -> {
|
||||
byte typeid = in.readByte();
|
||||
byte version = in.readByte();
|
||||
|
||||
Log.info(typeid);
|
||||
SaveTrait trait = (SaveTrait)TypeTrait.getTypeByID(typeid).get();
|
||||
SaveTrait trait = (SaveTrait)content.<TypeID>getByID(ContentType.typeid, typeid).constructor.get();
|
||||
trait.readSave(in, version);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
129
core/src/io/anuke/mindustry/io/versions/LegacyTypeTable.java
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
package io.anuke.mindustry.io.versions;
|
||||
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.type.base.*;
|
||||
|
||||
/*
|
||||
Latest data: [build 81]
|
||||
|
||||
0 = Player
|
||||
1 = Fire
|
||||
2 = Puddle
|
||||
3 = Draug
|
||||
4 = Spirit
|
||||
5 = Phantom
|
||||
6 = Dagger
|
||||
7 = Crawler
|
||||
8 = Titan
|
||||
9 = Fortress
|
||||
10 = Eruptor
|
||||
11 = Wraith
|
||||
12 = Ghoul
|
||||
13 = Revenant
|
||||
|
||||
Before removal of lightining/bullet: [build 80]
|
||||
|
||||
0 = Player
|
||||
1 = Fire
|
||||
2 = Puddle
|
||||
3 = Bullet
|
||||
4 = Lightning
|
||||
5 = Draug
|
||||
6 = Spirit
|
||||
7 = Phantom
|
||||
8 = Dagger
|
||||
9 = Crawler
|
||||
10 = Titan
|
||||
11 = Fortress
|
||||
12 = Eruptor
|
||||
13 = Wraith
|
||||
14 = Ghoul
|
||||
15 = Revenant
|
||||
|
||||
Before addition of new units: [build 79 and below]
|
||||
|
||||
0 = Player
|
||||
1 = Fire
|
||||
2 = Puddle
|
||||
3 = Bullet
|
||||
4 = Lightning
|
||||
5 = Spirit
|
||||
6 = Dagger
|
||||
7 = Crawler
|
||||
8 = Titan
|
||||
9 = Fortress
|
||||
10 = Eruptor
|
||||
11 = Wraith
|
||||
12 = Ghoul
|
||||
13 = Phantom
|
||||
14 = Revenant
|
||||
*/
|
||||
public class LegacyTypeTable{
|
||||
private static final Supplier[] build81Table = {
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Draug::new,
|
||||
Spirit::new,
|
||||
Phantom::new,
|
||||
Dagger::new,
|
||||
Crawler::new,
|
||||
Titan::new,
|
||||
Fortress::new,
|
||||
Eruptor::new,
|
||||
Wraith::new,
|
||||
Ghoul::new,
|
||||
Revenant::new
|
||||
};
|
||||
|
||||
private static final Supplier[] build80Table = {
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Bullet::new, //TODO reading these may crash
|
||||
Lightning::new,
|
||||
Draug::new,
|
||||
Spirit::new,
|
||||
Phantom::new,
|
||||
Dagger::new,
|
||||
Crawler::new,
|
||||
Titan::new,
|
||||
Fortress::new,
|
||||
Eruptor::new,
|
||||
Wraith::new,
|
||||
Ghoul::new,
|
||||
Revenant::new
|
||||
};
|
||||
|
||||
private static final Supplier[] build79Table = {
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Bullet::new, //TODO reading these may crash
|
||||
Lightning::new,
|
||||
Spirit::new,
|
||||
Dagger::new,
|
||||
Crawler::new,
|
||||
Titan::new,
|
||||
Fortress::new,
|
||||
Eruptor::new,
|
||||
Wraith::new,
|
||||
Ghoul::new,
|
||||
Phantom::new,
|
||||
Revenant::new
|
||||
};
|
||||
|
||||
public static Supplier[] getTable(int build){
|
||||
if(build == -1 || build == 81){
|
||||
//return most recent one since that's probably is; not guaranteed
|
||||
return build81Table;
|
||||
}else if(build == 80){
|
||||
return build80Table;
|
||||
}else{
|
||||
return build79Table;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,34 @@
|
|||
package io.anuke.mindustry.io.versions;
|
||||
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.mindustry.entities.traits.SaveTrait;
|
||||
import io.anuke.mindustry.io.SaveVersion;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Save1 extends SaveVersion{
|
||||
|
||||
public Save1(){
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntities(DataInput stream) throws IOException{
|
||||
Supplier[] table = LegacyTypeTable.getTable(lastReadBuild);
|
||||
|
||||
byte groups = stream.readByte();
|
||||
|
||||
for(int i = 0; i < groups; i++){
|
||||
int amount = stream.readInt();
|
||||
for(int j = 0; j < amount; j++){
|
||||
readChunk(stream, true, in -> {
|
||||
byte typeid = in.readByte();
|
||||
byte version = in.readByte();
|
||||
SaveTrait trait = (SaveTrait)table[typeid].get();
|
||||
trait.readSave(in, version);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
core/src/io/anuke/mindustry/io/versions/Save2.java
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package io.anuke.mindustry.io.versions;
|
||||
|
||||
import io.anuke.mindustry.io.SaveVersion;
|
||||
|
||||
public class Save2 extends SaveVersion{
|
||||
public Save2(){
|
||||
super(2);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,5 +12,6 @@ public enum ContentType{
|
|||
weather,
|
||||
effect,
|
||||
zone,
|
||||
loadout
|
||||
loadout,
|
||||
typeid
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ import io.anuke.arc.function.Supplier;
|
|||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.ui.ContentDisplay;
|
||||
|
||||
public class UnitType extends UnlockableContent{
|
||||
protected final Supplier<? extends BaseUnit> constructor;
|
||||
public final TypeID typeID;
|
||||
public final Supplier<? extends BaseUnit> constructor;
|
||||
|
||||
public float health = 60;
|
||||
public float hitsize = 7f;
|
||||
public float hitsizeTile = 4f;
|
||||
|
|
@ -42,8 +42,7 @@ public class UnitType extends UnlockableContent{
|
|||
super(name);
|
||||
this.constructor = mainConstructor;
|
||||
this.description = Core.bundle.getOrNull("unit." + name + ".description");
|
||||
|
||||
TypeTrait.registerType(type, mainConstructor);
|
||||
this.typeID = new TypeID(name, mainConstructor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ContentDisplay{
|
|||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public class ContentDisplay{
|
|||
table.add(block.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ public class ContentDisplay{
|
|||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ public class ContentDisplay{
|
|||
table.add(item.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ public class ContentDisplay{
|
|||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ public class ContentDisplay{
|
|||
table.add(liquid.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ public class ContentDisplay{
|
|||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ public class ContentDisplay{
|
|||
table.add(mech.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ public class ContentDisplay{
|
|||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ public class ContentDisplay{
|
|||
table.add(unit.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ public class AboutDialog extends FloatingDialog{
|
|||
Table table = new Table("underline");
|
||||
table.margin(0);
|
||||
table.table(img -> {
|
||||
img.addImage("white").height(h - 5).width(40f).color(link.color);
|
||||
img.addImage("whiteui").height(h - 5).width(40f).color(link.color);
|
||||
img.row();
|
||||
img.addImage("white").height(5).width(40f).color(link.color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
|
||||
img.addImage("whiteui").height(5).width(40f).color(link.color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
|
||||
}).expandY();
|
||||
|
||||
table.table(i -> {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ColorPickDialog extends Dialog{
|
|||
for(int i = 0; i < playerColors.length; i++){
|
||||
Color color = playerColors[i];
|
||||
|
||||
ImageButton button = table.addImageButton("white", "clear-toggle", 34, () -> {
|
||||
ImageButton button = table.addImageButton("whiteui", "clear-toggle", 34, () -> {
|
||||
cons.accept(color);
|
||||
hide();
|
||||
}).size(48).get();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class ControlsDialog extends KeybindDialog{
|
|||
setFillParent(true);
|
||||
title.setAlignment(Align.center);
|
||||
titleTable.row();
|
||||
titleTable.add(new Image("white"))
|
||||
titleTable.add(new Image("whiteui"))
|
||||
.growX().height(3f).pad(4f).get().setColor(Pal.accent);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class DatabaseDialog extends FloatingDialog{
|
|||
|
||||
table.add("$content." + type.name() + ".name").growX().left().color(Pal.accent);
|
||||
table.row();
|
||||
table.addImage("white").growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
|
||||
table.addImage("whiteui").growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
|
||||
table.row();
|
||||
table.table(list -> {
|
||||
list.left();
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ public class DiscordDialog extends Dialog{
|
|||
t.background("button").margin(0);
|
||||
|
||||
t.table(img -> {
|
||||
img.addImage("white").height(h - 5).width(40f).color(color);
|
||||
img.addImage("whiteui").height(h - 5).width(40f).color(color);
|
||||
img.row();
|
||||
img.addImage("white").height(5).width(40f).color(color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
|
||||
img.addImage("whiteui").height(5).width(40f).color(color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
|
||||
}).expandY();
|
||||
|
||||
t.table(i -> {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class FloatingDialog extends Dialog{
|
|||
setFillParent(true);
|
||||
this.title.setAlignment(Align.center);
|
||||
titleTable.row();
|
||||
titleTable.addImage("white", Pal.accent)
|
||||
titleTable.addImage("whiteui", Pal.accent)
|
||||
.growX().height(3f).pad(4f);
|
||||
|
||||
hidden(() -> {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class HostDialog extends FloatingDialog{
|
|||
ui.listfrag.rebuild();
|
||||
}).grow().pad(8).get().setMaxLength(40);
|
||||
|
||||
ImageButton button = t.addImageButton("white", "clear-full", 40, () -> {
|
||||
ImageButton button = t.addImageButton("whiteui", "clear-full", 40, () -> {
|
||||
new ColorPickDialog().show(color -> {
|
||||
player.color.set(color);
|
||||
Core.settings.put("color-0", Color.rgba8888(color));
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ public class JoinDialog extends FloatingDialog{
|
|||
Core.settings.save();
|
||||
}).grow().pad(8).get().setMaxLength(maxNameLength);
|
||||
|
||||
ImageButton button = t.addImageButton("white", "clear-full", 40, () -> {
|
||||
ImageButton button = t.addImageButton("whiteui", "clear-full", 40, () -> {
|
||||
new ColorPickDialog().show(color -> {
|
||||
player.color.set(color);
|
||||
Core.settings.put("color-0", Color.rgba8888(color));
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class MapsDialog extends FloatingDialog{
|
|||
button.margin(9);
|
||||
button.add(map.name()).width(mapsize - 18f).center().get().setEllipsis(true);
|
||||
button.row();
|
||||
button.addImage("white").growX().pad(4).color(Color.GRAY);
|
||||
button.addImage("whiteui").growX().pad(4).color(Color.GRAY);
|
||||
button.row();
|
||||
button.stack(new Image(map.texture).setScaling(Scaling.fit), new BorderImage(map.texture).setScaling(Scaling.fit)).size(mapsize - 20f);
|
||||
button.row();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
|||
setFillParent(true);
|
||||
title.setAlignment(Align.center);
|
||||
titleTable.row();
|
||||
titleTable.add(new Image("white")).growX().height(3f).pad(4f).get().setColor(Pal.accent);
|
||||
titleTable.add(new Image("whiteui")).growX().height(3f).pad(4f).get().setColor(Pal.accent);
|
||||
|
||||
cont.clearChildren();
|
||||
cont.remove();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class ZoneInfoDialog extends FloatingDialog{
|
|||
}else{
|
||||
cont.add(zone.localizedName()).color(Pal.accent).growX().center();
|
||||
cont.row();
|
||||
cont.addImage("white").color(Pal.accent).height(3).pad(6).growX();
|
||||
cont.addImage("whiteui").color(Pal.accent).height(3).pad(6).growX();
|
||||
cont.row();
|
||||
cont.addButton(zone.canConfigure() ? "$configure" : Core.bundle.format("configure.locked", zone.configureWave), () -> loadout.show(zone, rebuildItems)).fillX().pad(3).disabled(b -> !zone.canConfigure());
|
||||
cont.row();
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ public class HudFragment extends Fragment{
|
|||
}
|
||||
|
||||
public void showLaunch(){
|
||||
Image image = new Image("white");
|
||||
Image image = new Image("whiteui");
|
||||
image.getColor().a = 0f;
|
||||
image.setFillParent(true);
|
||||
image.actions(Actions.fadeIn(40f / 60f));
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ public class LoadingFragment extends Fragment{
|
|||
t.touchable(Touchable.enabled);
|
||||
t.add().height(70f).row();
|
||||
|
||||
t.addImage("white").growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
|
||||
t.addImage("whiteui").growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
|
||||
t.row();
|
||||
t.add("$loading").name("namelabel").pad(10f);
|
||||
t.row();
|
||||
t.addImage("white").growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
|
||||
t.addImage("whiteui").growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
|
||||
t.row();
|
||||
|
||||
button = t.addButton("$cancel", () -> {
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ public class MenuFragment extends Fragment{
|
|||
|
||||
parent.fill((x, y, w, h) -> {
|
||||
float logoscl = (int)Unit.dp.scl(1);
|
||||
float logow = Math.min(Math.min(logo.getWidth() * logoscl, 768), Core.graphics.getWidth() - 10);
|
||||
float logow = Math.min(logo.getWidth() * logoscl, Core.graphics.getWidth() - Unit.dp.scl(20));
|
||||
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(Draw.wrap(logo), (int)(Core.graphics.getWidth() / 2), (int)(Core.graphics.getHeight() - 10 - logoh) + logoh / 2, logow, logoh);
|
||||
Draw.rect(Draw.wrap(logo), (int)(Core.graphics.getWidth() / 2), (int)(Core.graphics.getHeight() - 10 - logoh) + logoh / 2 - (Core.graphics.isPortrait() ? Unit.dp.scl(30f) : 0f), logow, logoh);
|
||||
}).touchable(Touchable.disabled);
|
||||
}
|
||||
|
||||
|
|
|
|||
44
core/src/io/anuke/mindustry/world/StaticTree.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package io.anuke.mindustry.world;
|
||||
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.mindustry.world.blocks.StaticWall;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class StaticTree extends StaticWall{
|
||||
|
||||
public StaticTree(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
TextureRegion r = Tmp.tr1;
|
||||
r.set(region);
|
||||
int crop = (region.getWidth() - tilesize*4) / 2;
|
||||
float ox = 0;
|
||||
float oy = 0;
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(tile.getNearby(i) != null && tile.getNearby(i).block() instanceof StaticWall){
|
||||
|
||||
if(i == 0){
|
||||
r.setWidth(r.getWidth() - crop);
|
||||
ox -= crop /2f;
|
||||
}else if(i == 1){
|
||||
r.setY(r.getY() + crop);
|
||||
oy -= crop /2f;
|
||||
}else if(i == 2){
|
||||
r.setX(r.getX() + crop);
|
||||
ox += crop /2f;
|
||||
}else{
|
||||
r.setHeight(r.getHeight() - crop);
|
||||
oy += crop /2f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Draw.rect(r, tile.drawx() + ox * Draw.scl, tile.drawy() + oy * Draw.scl);
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ public class ItemSelection{
|
|||
for(Item item : items){
|
||||
if(!data.isUnlocked(item) && world.isZone()) continue;
|
||||
|
||||
ImageButton button = cont.addImageButton("white", "clear-toggle", 24, () -> control.input().frag.config.hideConfig()).group(group).get();
|
||||
ImageButton button = cont.addImageButton("whiteui", "clear-toggle", 24, () -> control.input().frag.config.hideConfig()).group(group).get();
|
||||
button.changed(() -> consumer.accept(button.isChecked() ? item : null));
|
||||
button.getStyle().imageUp = new TextureRegionDrawable(item.icon(Icon.medium));
|
||||
button.update(() -> button.setChecked(holder.get() == item));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package io.anuke.mindustry.world.blocks.defense;
|
|||
|
||||
import io.anuke.arc.graphics.Blending;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.Time;
|
||||
|
|
@ -35,7 +35,7 @@ public class DeflectorWall extends Wall{
|
|||
Draw.color(Color.WHITE);
|
||||
Draw.alpha(entity.hit * 0.5f);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect("blank", tile.drawx(), tile.drawy(), tilesize * size, tilesize * size);
|
||||
Fill.rect(tile.drawx(), tile.drawy(), tilesize * size, tilesize * size);
|
||||
Draw.blend();
|
||||
Draw.reset();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,25 +2,20 @@ package io.anuke.mindustry.world.blocks.defense;
|
|||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.graphics.Blending;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MendProjector extends Block{
|
||||
private static Color color = Color.valueOf("84f491");
|
||||
|
|
@ -130,13 +125,13 @@ public class MendProjector extends Block{
|
|||
|
||||
Draw.color(color, phase, entity.phaseHeat);
|
||||
Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f);
|
||||
Draw.blend(Blending.additive);
|
||||
//Draw.blend(Blending.additive);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
Draw.blend();
|
||||
//Draw.blend();
|
||||
|
||||
Draw.alpha(1f);
|
||||
Lines.stroke((2f * f + 0.2f) * entity.heat);
|
||||
Lines.circle(tile.drawx(), tile.drawy(), ((1f - f) * 8f) * size / 2f);
|
||||
Lines.square(tile.drawx(), tile.drawy(), ((1f - f) * 8f) * size / 2f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,22 +2,18 @@ package io.anuke.mindustry.world.blocks.defense;
|
|||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.graphics.Blending;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class OverdriveProjector extends Block{
|
||||
private static Color color = Color.valueOf("feb380");
|
||||
|
|
@ -130,12 +126,12 @@ public class OverdriveProjector extends Block{
|
|||
|
||||
Draw.color(color, phase, entity.phaseHeat);
|
||||
Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f);
|
||||
Draw.blend(Blending.additive);
|
||||
//Draw.blend(Blending.additive);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
Draw.blend();
|
||||
//Draw.blend();
|
||||
Draw.alpha(1f);
|
||||
Lines.stroke((2f * f + 0.2f) * entity.heat);
|
||||
Lines.circle(tile.drawx(), tile.drawy(), (1f - f) * 9f);
|
||||
Lines.square(tile.drawx(), tile.drawy(), (1f - f) * 8f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package io.anuke.mindustry.world.blocks.distribution;
|
|||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
|
|
@ -54,7 +54,7 @@ public class Sorter extends Block{
|
|||
if(entity.sortItem == null) return;
|
||||
|
||||
Draw.color(entity.sortItem.color);
|
||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f);
|
||||
Draw.rect("center", tile.worldx(), tile.worldy());
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||
protected Effects.Effect generateEffect = Fx.generatespark;
|
||||
protected Effects.Effect explodeEffect = Fx.generatespark;
|
||||
protected Color heatColor = Color.valueOf("ff9b59");
|
||||
protected TextureRegion topRegion;
|
||||
protected TextureRegion topRegion, liquidRegion;
|
||||
protected boolean randomlyExplode = false;
|
||||
|
||||
public ItemLiquidGenerator(boolean hasItems, boolean hasLiquids, String name){
|
||||
|
|
@ -59,6 +59,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||
if(hasItems){
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -151,15 +152,11 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||
if(hasLiquids){
|
||||
Draw.color(entity.liquids.current().color);
|
||||
Draw.alpha(entity.liquids.currentAmount() / liquidCapacity);
|
||||
drawLiquidCenter(tile);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawLiquidCenter(Tile tile){
|
||||
Draw.rect("blank", tile.drawx(), tile.drawy(), 2, 2);
|
||||
}
|
||||
|
||||
protected float getItemEfficiency(Item item){
|
||||
return 0.0f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ package io.anuke.mindustry.world.blocks.power;
|
|||
|
||||
import io.anuke.arc.Core;
|
||||
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.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Time;
|
||||
|
|
@ -155,7 +154,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||
NuclearReactorEntity entity = tile.entity();
|
||||
|
||||
Draw.color(coolColor, hotColor, entity.heat);
|
||||
Draw.rect("white", tile.drawx(), tile.drawy(), size * tilesize, size * tilesize);
|
||||
Fill.rect(tile.drawx(), tile.drawy(), size * tilesize, size * tilesize);
|
||||
|
||||
Draw.color(entity.liquids.current().color);
|
||||
Draw.alpha(entity.liquids.currentAmount() / liquidCapacity);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import io.anuke.annotations.Annotations.Loc;
|
|||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Intersector;
|
||||
|
|
@ -29,7 +28,7 @@ public class PowerNode extends PowerBlock{
|
|||
private static int lastPlaced = -1;
|
||||
|
||||
protected Vector2 t1 = new Vector2();
|
||||
protected Vector2 t2 = new Vector2();
|
||||
protected TextureRegion laser, laserEnd;
|
||||
|
||||
protected float laserRange = 6;
|
||||
protected int maxNodes = 3;
|
||||
|
|
@ -86,6 +85,14 @@ public class PowerNode extends PowerBlock{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
laser = Core.atlas.find("laser");
|
||||
laserEnd = Core.atlas.find("laser-end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
|
@ -204,7 +211,7 @@ public class PowerNode extends PowerBlock{
|
|||
|
||||
for(int i = 0; i < entity.power.links.size; i++){
|
||||
Tile link = world.tile(entity.power.links.get(i));
|
||||
if(linkValid(tile, link)){
|
||||
if(link != null && (link.pos() < tile.pos() || !(link.block() instanceof PowerNode) || !Core.camera.bounds(Tmp.r1).contains(link.drawx(), link.drawy()))){
|
||||
drawLaser(tile, link);
|
||||
}
|
||||
}
|
||||
|
|
@ -237,26 +244,21 @@ public class PowerNode extends PowerBlock{
|
|||
}
|
||||
|
||||
protected void drawLaser(Tile tile, Tile target){
|
||||
|
||||
float x1 = tile.drawx(), y1 = tile.drawy(),
|
||||
x2 = target.drawx(), y2 = target.drawy();
|
||||
|
||||
float angle1 = Angles.angle(x1, y1, x2, y2);
|
||||
float angle2 = angle1 + 180f;
|
||||
|
||||
t1.trns(angle1, tile.block().size * tilesize / 2f - 1.5f);
|
||||
t2.trns(angle2, target.block().size * tilesize / 2f - 1.5f);
|
||||
|
||||
x1 += t1.x;
|
||||
y1 += t1.y;
|
||||
x2 += t2.x;
|
||||
y2 += t2.y;
|
||||
x2 -= t1.x;
|
||||
y2 -= t1.y;
|
||||
|
||||
Draw.color(Pal.powerLight, Color.WHITE, Mathf.absin(Time.time(), 8f, 0.3f) + 0.2f);
|
||||
//Lines.stroke(2f);
|
||||
//Lines.line(x1, y1, x2, y2);
|
||||
|
||||
Shapes.laser("laser", "laser-end", x1, y1, x2, y2, 0.6f);
|
||||
Shapes.laser(laser, laserEnd, x1, y1, x2, y2, 0.6f);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ import io.anuke.arc.collection.Array;
|
|||
import io.anuke.arc.collection.ObjectIntMap;
|
||||
import io.anuke.arc.graphics.Blending;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.arc.util.Time;
|
||||
|
|
@ -116,7 +115,7 @@ public class Drill extends Block{
|
|||
|
||||
if(entity.dominantItem != null && drawMineItem){
|
||||
Draw.color(entity.dominantItem.color);
|
||||
Draw.rect("blank", tile.drawx(), tile.drawy(), 2f, 2f);
|
||||
Fill.square(tile.drawx(), tile.drawy(), 1f);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
package io.anuke.mindustry.world.blocks.storage;
|
||||
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.ItemSelection;
|
||||
|
||||
import java.io.*;
|
||||
|
|
@ -81,7 +78,7 @@ public class Unloader extends Block{
|
|||
SortedUnloaderEntity entity = tile.entity();
|
||||
|
||||
Draw.color(entity.sortItem == null ? Color.CLEAR : entity.sortItem.color);
|
||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 2f, 2f);
|
||||
Fill.square(tile.worldx(), tile.worldy(), 1f);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class RepairPoint extends Block{
|
|||
protected float repairSpeed = 0.3f;
|
||||
protected float powerUse;
|
||||
protected TextureRegion baseRegion;
|
||||
protected TextureRegion laser, laserEnd;
|
||||
|
||||
public RepairPoint(String name){
|
||||
super(name);
|
||||
|
|
@ -32,7 +33,7 @@ public class RepairPoint extends Block{
|
|||
solid = true;
|
||||
flags = EnumSet.of(BlockFlag.repair);
|
||||
layer = Layer.turret;
|
||||
layer2 = Layer.laser;
|
||||
layer2 = Layer.power;
|
||||
hasPower = true;
|
||||
outlineIcon = true;
|
||||
}
|
||||
|
|
@ -42,6 +43,8 @@ public class RepairPoint extends Block{
|
|||
super.load();
|
||||
|
||||
baseRegion = Core.atlas.find(name + "-base");
|
||||
laser = Core.atlas.find("laser");
|
||||
laserEnd = Core.atlas.find("laser-end");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -79,9 +82,9 @@ public class RepairPoint extends Block{
|
|||
float len = 5f;
|
||||
|
||||
Draw.color(Color.valueOf("e8ffd7"));
|
||||
Shapes.laser("laser", "laser-end",
|
||||
tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len),
|
||||
entity.target.x, entity.target.y, entity.strength);
|
||||
Shapes.laser(laser, laserEnd,
|
||||
tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len),
|
||||
entity.target.x, entity.target.y, entity.strength);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -300,32 +300,24 @@ task pack(dependsOn: classes){
|
|||
workingDir = "../core/assets-raw/sprites_out/ui/icons"
|
||||
}
|
||||
|
||||
//antialias everything except UI elements (...for some reason)
|
||||
copy{
|
||||
from "../core/assets-raw/sprites_out/ui/icons"
|
||||
into "../core/assets-raw/sprites_out/ui/"
|
||||
}
|
||||
|
||||
delete{
|
||||
delete "../core/assets-raw/sprites_out/ui/icons"
|
||||
}
|
||||
|
||||
//antialias everything except UI elements
|
||||
fileTree(dir: '../core/assets-raw/sprites_out/', include: "**/*.png").visit{ file ->
|
||||
if(file.isDirectory() || (file.toString().replace("\\", "/").contains("/ui/") && !file.toString().replace("\\", "/").contains("/icons/"))) return
|
||||
if(file.isDirectory() || (file.toString().replace("\\", "/").contains("/ui/"))) return
|
||||
|
||||
antialias(file.file)
|
||||
}
|
||||
|
||||
//pack normal sprites
|
||||
TexturePacker.process("core/assets-raw/sprites_out/", "core/assets/sprites/", "sprites.atlas")
|
||||
|
||||
//delete old pack defintions
|
||||
delete{
|
||||
delete fileTree(dir: '../core/assets-raw/sprites_out/', include: '**/pack.json')
|
||||
}
|
||||
|
||||
if(false){
|
||||
//rename pack definitions, generate fallback 1024x sprites
|
||||
copy{
|
||||
from '../core/assets-raw/sprites_out/'
|
||||
into '../core/assets-raw/sprites_out/'
|
||||
include "**/*.json"
|
||||
rename 'pack_fallback.json', "pack.json"
|
||||
}
|
||||
|
||||
TexturePacker.process("core/assets-raw/sprites_out/", "core/assets/sprites/", "sprites_fallback.atlas")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||