pain and suffering of various kinds
This commit is contained in:
@@ -27,7 +27,7 @@ allprojects {
|
|||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
uCoreVersion = '367f0b0bab5936ce47155f17a74150451a0cddea'
|
uCoreVersion = '33a2bc650be42394821acad06aceb6f9ba74e77a'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Mindustry extends ModuleCore{
|
|||||||
|
|
||||||
Log.setUseColors(false);
|
Log.setUseColors(false);
|
||||||
BundleLoader.load();
|
BundleLoader.load();
|
||||||
ContentLoader.load();
|
content.load();
|
||||||
|
|
||||||
module(logic = new Logic());
|
module(logic = new Logic());
|
||||||
module(world = new World());
|
module(world = new World());
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public class Vars{
|
|||||||
public static float baseControllerSpeed = 11f;
|
public static float baseControllerSpeed = 11f;
|
||||||
//only if smoothCamera
|
//only if smoothCamera
|
||||||
public static boolean snapCamera = true;
|
public static boolean snapCamera = true;
|
||||||
|
public static ContentLoader content;
|
||||||
public static GameState state;
|
public static GameState state;
|
||||||
public static ThreadHandler threads;
|
public static ThreadHandler threads;
|
||||||
|
|
||||||
@@ -153,6 +154,8 @@ public class Vars{
|
|||||||
|
|
||||||
Version.init();
|
Version.init();
|
||||||
|
|
||||||
|
content = new ContentLoader();
|
||||||
|
|
||||||
playerGroup = Entities.addGroup(Player.class).enableMapping();
|
playerGroup = Entities.addGroup(Player.class).enableMapping();
|
||||||
tileGroup = Entities.addGroup(TileEntity.class, false);
|
tileGroup = Entities.addGroup(TileEntity.class, false);
|
||||||
bulletGroup = Entities.addGroup(Bullet.class).enableMapping();
|
bulletGroup = Entities.addGroup(Bullet.class).enableMapping();
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package io.anuke.mindustry.content;
|
package io.anuke.mindustry.content;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.bullets.*;
|
import io.anuke.mindustry.content.bullets.*;
|
||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
import io.anuke.mindustry.content.fx.Fx;
|
import io.anuke.mindustry.content.fx.Fx;
|
||||||
import io.anuke.mindustry.content.fx.ShootFx;
|
import io.anuke.mindustry.content.fx.ShootFx;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.type.AmmoType;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
public class AmmoTypes implements ContentList{
|
public class AmmoTypes implements ContentList{
|
||||||
public static AmmoType bulletCopper, bulletDense, bulletThorium, bulletSilicon, bulletPyratite,
|
public static AmmoType bulletCopper, bulletDense, bulletThorium, bulletSilicon, bulletPyratite,
|
||||||
@@ -219,7 +218,7 @@ public class AmmoTypes implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return AmmoType.all();
|
return ContentType.ammo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package io.anuke.mindustry.content;
|
package io.anuke.mindustry.content;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.ItemType;
|
import io.anuke.mindustry.type.ItemType;
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ public class Items implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return Item.all();
|
return ContentType.item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package io.anuke.mindustry.content;
|
package io.anuke.mindustry.content;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.type.Liquid;
|
||||||
|
|
||||||
public class Liquids implements ContentList{
|
public class Liquids implements ContentList{
|
||||||
@@ -50,7 +49,7 @@ public class Liquids implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return Liquid.all();
|
return ContentType.liquid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.content;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
import io.anuke.mindustry.content.fx.UnitFx;
|
import io.anuke.mindustry.content.fx.UnitFx;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
@@ -13,11 +12,11 @@ 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.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
import io.anuke.mindustry.entities.units.types.AlphaDrone;
|
import io.anuke.mindustry.entities.units.types.AlphaDrone;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Mech;
|
import io.anuke.mindustry.type.Mech;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
@@ -349,7 +348,7 @@ public class Mechs implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return Mech.all();
|
return ContentType.mech;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package io.anuke.mindustry.content;
|
package io.anuke.mindustry.content;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.blocks.*;
|
import io.anuke.mindustry.content.blocks.*;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
|
|
||||||
@@ -181,7 +180,7 @@ public class Recipes implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return Recipe.all();
|
return ContentType.recipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package io.anuke.mindustry.content;
|
package io.anuke.mindustry.content;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||||
import io.anuke.mindustry.entities.StatusController.StatusEntry;
|
import io.anuke.mindustry.entities.StatusController.StatusEntry;
|
||||||
import io.anuke.mindustry.entities.Unit;
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.StatusEffect;
|
import io.anuke.mindustry.type.StatusEffect;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
@@ -149,7 +148,7 @@ public class StatusEffects implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return StatusEffect.all();
|
return ContentType.status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package io.anuke.mindustry.content;
|
package io.anuke.mindustry.content;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.badlogic.gdx.utils.ObjectSet;
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
import io.anuke.mindustry.entities.units.UnitType;
|
import io.anuke.mindustry.entities.units.UnitType;
|
||||||
import io.anuke.mindustry.entities.units.types.*;
|
import io.anuke.mindustry.entities.units.types.*;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
public class UnitTypes implements ContentList{
|
public class UnitTypes implements ContentList{
|
||||||
public static UnitType drone, alphaDrone, dagger, interceptor, monsoon, titan, fabricator;
|
public static UnitType drone, alphaDrone, dagger, interceptor, monsoon, titan, fabricator;
|
||||||
@@ -93,7 +92,7 @@ public class UnitTypes implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return UnitType.all();
|
return ContentType.unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package io.anuke.mindustry.content;
|
package io.anuke.mindustry.content;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.fx.Fx;
|
import io.anuke.mindustry.content.fx.Fx;
|
||||||
import io.anuke.mindustry.content.fx.ShootFx;
|
import io.anuke.mindustry.content.fx.ShootFx;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Weapon;
|
import io.anuke.mindustry.type.Weapon;
|
||||||
|
|
||||||
public class Weapons implements ContentList{
|
public class Weapons implements ContentList{
|
||||||
@@ -153,7 +152,7 @@ public class Weapons implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return Weapon.all();
|
return ContentType.weapon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
package io.anuke.mindustry.content.blocks;
|
package io.anuke.mindustry.content.blocks;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
public abstract class BlockList implements ContentList{
|
public abstract class BlockList implements ContentList{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return Block.all();
|
return ContentType.item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class DebugBlocks extends BlockList implements ContentList{
|
public class DebugBlocks extends BlockList implements ContentList{
|
||||||
public static Block powerVoid, powerInfinite, itemSource, liquidSource, itemVoid;
|
public static Block powerVoid, powerInfinite, itemSource, liquidSource, itemVoid;
|
||||||
@@ -105,7 +106,7 @@ public class DebugBlocks extends BlockList implements ContentList{
|
|||||||
public void buildTable(Tile tile, Table table){
|
public void buildTable(Tile tile, Table table){
|
||||||
LiquidSourceEntity entity = tile.entity();
|
LiquidSourceEntity entity = tile.entity();
|
||||||
|
|
||||||
Array<Liquid> items = Liquid.all();
|
Array<Liquid> items = content.liquids();
|
||||||
|
|
||||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
Table cont = new Table();
|
Table cont = new Table();
|
||||||
@@ -159,7 +160,7 @@ public class DebugBlocks extends BlockList implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInputStream stream) throws IOException{
|
public void read(DataInputStream stream) throws IOException{
|
||||||
source = Liquid.getByID(stream.readByte());
|
source = content.liquid(stream.readByte());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.type.Item;
|
|||||||
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 static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class OreBlocks extends BlockList{
|
public class OreBlocks extends BlockList{
|
||||||
private static final ObjectMap<Item, ObjectMap<Block, Block>> oreBlockMap = new ObjectMap<>();
|
private static final ObjectMap<Item, ObjectMap<Block, Block>> oreBlockMap = new ObjectMap<>();
|
||||||
@@ -25,7 +26,7 @@ public class OreBlocks extends BlockList{
|
|||||||
ObjectMap<Block, Block> map = new ObjectMap<>();
|
ObjectMap<Block, Block> map = new ObjectMap<>();
|
||||||
oreBlockMap.put(item, map);
|
oreBlockMap.put(item, map);
|
||||||
|
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.blocks()){
|
||||||
if(block instanceof Floor && ((Floor) block).hasOres){
|
if(block instanceof Floor && ((Floor) block).hasOres){
|
||||||
map.put(block, new OreBlock(item, (Floor) block));
|
map.put(block, new OreBlock(item, (Floor) block));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
package io.anuke.mindustry.content.bullets;
|
package io.anuke.mindustry.content.bullets;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
public abstract class BulletList implements ContentList{
|
public abstract class BulletList implements ContentList{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return BulletType.all();
|
return ContentType.bullet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ import io.anuke.mindustry.entities.bullet.LiquidBulletType;
|
|||||||
import io.anuke.mindustry.entities.effect.Fire;
|
import io.anuke.mindustry.entities.effect.Fire;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
import io.anuke.mindustry.entities.effect.ItemDrop;
|
||||||
import io.anuke.mindustry.entities.effect.Lightning;
|
import io.anuke.mindustry.entities.effect.Lightning;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
@@ -28,6 +27,7 @@ import io.anuke.ucore.graphics.Shapes;
|
|||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public class TurretBullets extends BulletList implements ContentList{
|
public class TurretBullets extends BulletList implements ContentList{
|
||||||
@@ -328,7 +328,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
if(amountDropped > 0){
|
if(amountDropped > 0){
|
||||||
float angle = b.angle() + Mathf.range(100f);
|
float angle = b.angle() + Mathf.range(100f);
|
||||||
float vs = Mathf.random(0f, 4f);
|
float vs = Mathf.random(0f, 4f);
|
||||||
ItemDrop.create(Item.getByID(i), amountDropped, b.x, b.y, Angles.trnsx(angle, vs), Angles.trnsy(angle, vs));
|
ItemDrop.create(content.item(i), amountDropped, b.x, b.y, Angles.trnsx(angle, vs), Angles.trnsy(angle, vs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package io.anuke.mindustry.content.fx;
|
package io.anuke.mindustry.content.fx;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
public abstract class FxList implements ContentList{
|
public abstract class FxList implements ContentList{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return Array.with();
|
return ContentType.effect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.*;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.content.blocks.*;
|
import io.anuke.mindustry.content.blocks.*;
|
||||||
import io.anuke.mindustry.content.bullets.*;
|
import io.anuke.mindustry.content.bullets.*;
|
||||||
@@ -17,10 +20,12 @@ import io.anuke.mindustry.entities.units.UnitType;
|
|||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
import io.anuke.mindustry.game.MappableContent;
|
import io.anuke.mindustry.game.MappableContent;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
import io.anuke.mindustry.type.Item;
|
||||||
|
import io.anuke.mindustry.type.Liquid;
|
||||||
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.ColorMapper;
|
import io.anuke.mindustry.world.ColorMapper;
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
import io.anuke.ucore.function.Consumer;
|
import io.anuke.ucore.function.Consumer;
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
|
|
||||||
@@ -28,13 +33,15 @@ import io.anuke.ucore.util.Log;
|
|||||||
* Loads all game content.
|
* Loads all game content.
|
||||||
* Call load() before doing anything with content.
|
* Call load() before doing anything with content.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public class ContentLoader{
|
public class ContentLoader{
|
||||||
private static boolean loaded = false;
|
private boolean loaded = false;
|
||||||
private static ObjectSet<Array<? extends Content>> contentSet = new OrderedSet<>();
|
|
||||||
private static OrderedMap<ContentType, Array<Content>> contentMap = new OrderedMap<>();
|
private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
|
||||||
private static ObjectMap<ContentType, ObjectMap<String, MappableContent>> contentNameMap = new ObjectMap<>();
|
private Array<Content>[] contentMap = new Array[ContentType.values().length];
|
||||||
private static ObjectSet<Consumer<Content>> initialization = new ObjectSet<>();
|
private IntMap<IntMap<MappableContent>> temporaryMapper;
|
||||||
private static ContentList[] content = {
|
private ObjectSet<Consumer<Content>> initialization = new ObjectSet<>();
|
||||||
|
private ContentList[] content = {
|
||||||
//effects
|
//effects
|
||||||
new BlockFx(),
|
new BlockFx(),
|
||||||
new BulletFx(),
|
new BulletFx(),
|
||||||
@@ -96,10 +103,8 @@ public class ContentLoader{
|
|||||||
new Recipes(),
|
new Recipes(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**Creates all content types.*/
|
||||||
* Creates all content types.
|
public void load(){
|
||||||
*/
|
|
||||||
public static void load(){
|
|
||||||
if(loaded){
|
if(loaded){
|
||||||
Log.info("Content already loaded, skipping.");
|
Log.info("Content already loaded, skipping.");
|
||||||
return;
|
return;
|
||||||
@@ -107,51 +112,63 @@ public class ContentLoader{
|
|||||||
|
|
||||||
registerTypes();
|
registerTypes();
|
||||||
|
|
||||||
for(io.anuke.mindustry.game.ContentList list : content){
|
for(ContentType type : ContentType.values()){
|
||||||
list.load();
|
contentMap[type.ordinal()] = new Array<>();
|
||||||
|
contentNameMap[type.ordinal()] = new ObjectMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ContentList list : content){
|
for(ContentList list : content){
|
||||||
if(list.getAll().size != 0){
|
list.load();
|
||||||
ContentType type = list.getAll().first().getContentType();
|
|
||||||
|
|
||||||
if(!contentMap.containsKey(type)){
|
|
||||||
contentMap.put(type, new Array<>());
|
|
||||||
contentNameMap.put(type, new ObjectMap<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
contentMap.get(type).addAll(list.getAll());
|
|
||||||
for(Content c : list.getAll()){
|
|
||||||
if(c instanceof MappableContent){
|
|
||||||
contentNameMap.get(type).put(((MappableContent) c).getContentName(), (MappableContent) c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
contentSet.add(list.getAll());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Block.all().size >= 256){
|
int total = 0;
|
||||||
throw new IllegalArgumentException("THE TIME HAS COME. More than 256 blocks have been created.");
|
|
||||||
|
for(ContentType type : ContentType.values()){
|
||||||
|
|
||||||
|
for(Content c : contentMap[type.ordinal()]){
|
||||||
|
if(c instanceof MappableContent){
|
||||||
|
String name = ((MappableContent) c).getContentName();
|
||||||
|
if(contentNameMap[type.ordinal()].containsKey(name)){
|
||||||
|
throw new IllegalArgumentException("Two content objects cannot have the same name! (issue: '" + name + "')");
|
||||||
|
}
|
||||||
|
contentNameMap[type.ordinal()].put(name, (MappableContent) c);
|
||||||
|
}
|
||||||
|
total ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//set up ID mapping
|
||||||
|
for(int k = 0; k < contentMap.length; k ++){
|
||||||
|
Array<Content> arr = contentMap[k];
|
||||||
|
for(int i = 0; i < arr.size; i++){
|
||||||
|
int id = arr.get(i).id;
|
||||||
|
if(id < 0) id += 256;
|
||||||
|
if(id != i){
|
||||||
|
throw new IllegalArgumentException("Out-of-order IDs for content '" + arr.get(i) + "' (expected " + i + " but got " + id + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blocks().size >= 256){
|
||||||
|
throw new ImpendingDoomException("THE TIME HAS COME. More than 256 blocks have been created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info("--- CONTENT INFO ---");
|
Log.info("--- CONTENT INFO ---");
|
||||||
Log.info("Blocks loaded: {0}\nItems loaded: {1}\nLiquids loaded: {2}\nUpgrades loaded: {3}\nUnits loaded: {4}\nAmmo types loaded: {5}\nBullet types loaded: {6}\nStatus effects loaded: {7}\nRecipes loaded: {8}\nEffects loaded: {9}\nTotal content classes: {10}",
|
for(int k = 0; k < contentMap.length; k ++){
|
||||||
Block.all().size, Item.all().size, Liquid.all().size, Mech.all().size, UnitType.all().size,
|
Log.info("[{0}]: loaded {1}", ContentType.values()[k].name(), contentMap[k].size);
|
||||||
AmmoType.all().size, BulletType.all().size, StatusEffect.all().size, Recipe.all().size, Effects.all().size, content.length);
|
}
|
||||||
|
Log.info("Total content loaded: {0}", total);
|
||||||
Log.info("-------------------");
|
Log.info("-------------------");
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**Initializes all content with the specified function.*/
|
||||||
* Initializes all content with the specified function.
|
public void initialize(Consumer<Content> callable){
|
||||||
*/
|
|
||||||
public static void initialize(Consumer<Content> callable){
|
|
||||||
if(initialization.contains(callable)) return;
|
if(initialization.contains(callable)) return;
|
||||||
|
|
||||||
for(Array<? extends Content> arr : contentSet){
|
for(ContentType type : ContentType.values()){
|
||||||
for(Content content : arr){
|
for(Content content : contentMap[type.ordinal()]){
|
||||||
callable.accept(content);
|
callable.accept(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,26 +176,102 @@ public class ContentLoader{
|
|||||||
initialization.add(callable);
|
initialization.add(callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dispose(){
|
public void dispose(){
|
||||||
//TODO clear all content.
|
//TODO clear all content.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OrderedMap<ContentType, Array<Content>> getContentMap(){
|
public void handleContent(Content content){
|
||||||
|
contentMap[content.getContentType().ordinal()].add(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemporaryMapper(IntMap<IntMap<MappableContent>> temporaryMapper){
|
||||||
|
this.temporaryMapper = temporaryMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<Content>[] getContentMap(){
|
||||||
return contentMap;
|
return contentMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MappableContent getByName(ContentType type, String name){
|
public <T extends MappableContent> T getByName(ContentType type, String name){
|
||||||
if(!contentNameMap.containsKey(type)){
|
if(contentNameMap[type.ordinal()] == null){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return contentNameMap.get(type).get(name);
|
return (T)contentNameMap[type.ordinal()].get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Content> T getByID(ContentType type, int id){
|
||||||
|
if(temporaryMapper != null && temporaryMapper.containsKey(type.ordinal()) && temporaryMapper.get(type.ordinal()).containsKey(id)){
|
||||||
|
return (T)temporaryMapper.get(type.ordinal()).get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(id < 0){ //offset negative values by 256, as they are probably a product of byte overflow
|
||||||
|
id += 256;
|
||||||
|
}
|
||||||
|
if(id >= contentMap[type.ordinal()].size || id < 0){
|
||||||
|
throw new RuntimeException("No " + type.name() + " with ID '" + id + "' found!");
|
||||||
|
}
|
||||||
|
return (T)contentMap[type.ordinal()].get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Content> Array<T> getBy(ContentType type){
|
||||||
|
return (Array<T>) contentMap[type.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
//utility methods, just makes things a bit shorter
|
||||||
|
|
||||||
|
public Array<Block> blocks(){
|
||||||
|
return getBy(ContentType.block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block block(int id){
|
||||||
|
return (Block) getByID(ContentType.block, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<Recipe> recipes(){
|
||||||
|
return getBy(ContentType.recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Recipe recipe(int id){
|
||||||
|
return (Recipe) getByID(ContentType.recipe, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<Item> items(){
|
||||||
|
return getBy(ContentType.block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item item(int id){
|
||||||
|
return (Item) getByID(ContentType.item, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<Liquid> liquids(){
|
||||||
|
return getBy(ContentType.liquid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Liquid liquid(int id){
|
||||||
|
return (Liquid) getByID(ContentType.liquid, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<BulletType> bullets(){
|
||||||
|
return getBy(ContentType.bullet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BulletType bullet(int id){
|
||||||
|
return (BulletType) getByID(ContentType.bullet, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<UnitType> units(){
|
||||||
|
return getBy(ContentType.unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitType unit(int id){
|
||||||
|
return (UnitType) getByID(ContentType.unit, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers sync IDs for all types of sync entities.
|
* Registers sync IDs for all types of sync entities.
|
||||||
* Do not register units here!
|
* Do not register units here!
|
||||||
*/
|
*/
|
||||||
private static void registerTypes(){
|
private void registerTypes(){
|
||||||
TypeTrait.registerType(Player.class, Player::new);
|
TypeTrait.registerType(Player.class, Player::new);
|
||||||
TypeTrait.registerType(ItemDrop.class, ItemDrop::new);
|
TypeTrait.registerType(ItemDrop.class, ItemDrop::new);
|
||||||
TypeTrait.registerType(Fire.class, Fire::new);
|
TypeTrait.registerType(Fire.class, Fire::new);
|
||||||
@@ -186,4 +279,8 @@ public class ContentLoader{
|
|||||||
TypeTrait.registerType(Bullet.class, Bullet::new);
|
TypeTrait.registerType(Bullet.class, Bullet::new);
|
||||||
TypeTrait.registerType(Lightning.class, Lightning::new);
|
TypeTrait.registerType(Lightning.class, Lightning::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ImpendingDoomException extends RuntimeException{
|
||||||
|
public ImpendingDoomException(String s){ super(s); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ public class Control extends Module{
|
|||||||
|
|
||||||
Effects.setShakeFalloff(10000f);
|
Effects.setShakeFalloff(10000f);
|
||||||
|
|
||||||
ContentLoader.initialize(Content::init);
|
content.initialize(Content::init);
|
||||||
Core.atlas = new Atlas("sprites.atlas");
|
Core.atlas = new Atlas("sprites.atlas");
|
||||||
Core.atlas.setErrorRegion("error");
|
Core.atlas.setErrorRegion("error");
|
||||||
ContentLoader.initialize(Content::load);
|
content.initialize(Content::load);
|
||||||
|
|
||||||
db.load();
|
db.load();
|
||||||
|
|
||||||
@@ -270,8 +270,8 @@ public class Control extends Module{
|
|||||||
control.database().unlockContent(players[0].inventory.getItem().item);
|
control.database().unlockContent(players[0].inventory.getItem().item);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < Recipe.all().size; i++){
|
for(int i = 0; i < content.recipes().size; i ++){
|
||||||
Recipe recipe = Recipe.all().get(i);
|
Recipe recipe = content.recipes().get(i);
|
||||||
if(!recipe.debugOnly && recipe.requirements != null && entity.items.has(recipe.requirements, 1.4f)){
|
if(!recipe.debugOnly && recipe.requirements != null && entity.items.has(recipe.requirements, 1.4f)){
|
||||||
if(control.database().unlockContent(recipe)){
|
if(control.database().unlockContent(recipe)){
|
||||||
ui.hudfrag.showUnlock(recipe);
|
ui.hudfrag.showUnlock(recipe);
|
||||||
@@ -283,7 +283,7 @@ public class Control extends Module{
|
|||||||
@Override
|
@Override
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
Platform.instance.onGameExit();
|
Platform.instance.onGameExit();
|
||||||
ContentLoader.dispose();
|
content.dispose();
|
||||||
Net.dispose();
|
Net.dispose();
|
||||||
ui.editor.dispose();
|
ui.editor.dispose();
|
||||||
inputs = new InputHandler[]{};
|
inputs = new InputHandler[]{};
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class Logic extends Module{
|
|||||||
|
|
||||||
for(Tile tile : state.teams.get(defaultTeam).cores){
|
for(Tile tile : state.teams.get(defaultTeam).cores){
|
||||||
if(debug){
|
if(debug){
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(item.type == ItemType.material){
|
if(item.type == ItemType.material){
|
||||||
tile.entity.items.set(item, 1000);
|
tile.entity.items.set(item, 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.world.blocks.Floor;
|
|||||||
import io.anuke.ucore.function.IntPositionConsumer;
|
import io.anuke.ucore.function.IntPositionConsumer;
|
||||||
import io.anuke.ucore.util.Bits;
|
import io.anuke.ucore.util.Bits;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Vars.ui;
|
||||||
|
|
||||||
public enum EditorTool{
|
public enum EditorTool{
|
||||||
@@ -26,7 +27,7 @@ public enum EditorTool{
|
|||||||
bw = editor.getMap().read(x, y, DataPosition.wall);
|
bw = editor.getMap().read(x, y, DataPosition.wall);
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = Block.getByID(bw == 0 ? bf : bw);
|
Block block = content.block(bw == 0 ? bf : bw);
|
||||||
editor.setDrawBlock(block);
|
editor.setDrawBlock(block);
|
||||||
ui.editor.updateSelectedBlock();
|
ui.editor.updateSelectedBlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import io.anuke.mindustry.world.Block;
|
|||||||
import io.anuke.mindustry.world.blocks.Floor;
|
import io.anuke.mindustry.world.blocks.Floor;
|
||||||
import io.anuke.ucore.util.Bits;
|
import io.anuke.ucore.util.Bits;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
public class MapEditor{
|
public class MapEditor{
|
||||||
public static final int minMapSize = 128, maxMapSize = 512;
|
public static final int minMapSize = 128, maxMapSize = 512;
|
||||||
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15};
|
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15};
|
||||||
@@ -137,7 +137,7 @@ public class MapEditor{
|
|||||||
|
|
||||||
if(link != 0){
|
if(link != 0){
|
||||||
removeLinked(worldx - (Bits.getLeftByte(link) - 8), worldy - (Bits.getRightByte(link) - 8));
|
removeLinked(worldx - (Bits.getLeftByte(link) - 8), worldy - (Bits.getRightByte(link) - 8));
|
||||||
}else if(Block.getByID(block).isMultiblock()){
|
}else if(content.block(block).isMultiblock()){
|
||||||
removeLinked(worldx, worldy);
|
removeLinked(worldx, worldy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ public class MapEditor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeLinked(int x, int y){
|
private void removeLinked(int x, int y){
|
||||||
Block block = Block.getByID(map.read(x, y, DataPosition.wall));
|
Block block = content.block(map.read(x, y, DataPosition.wall));
|
||||||
|
|
||||||
int offsetx = -(block.size - 1) / 2;
|
int offsetx = -(block.size - 1) / 2;
|
||||||
int offsety = -(block.size - 1) / 2;
|
int offsety = -(block.size - 1) / 2;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
@@ -362,7 +363,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
public void updateSelectedBlock(){
|
public void updateSelectedBlock(){
|
||||||
Block block = editor.getDrawBlock();
|
Block block = editor.getDrawBlock();
|
||||||
for(int j = 0; j < Block.all().size; j++){
|
for(int j = 0; j < content.blocks().size; j++){
|
||||||
if(block.id == j && j < blockgroup.getButtons().size){
|
if(block.id == j && j < blockgroup.getButtons().size){
|
||||||
blockgroup.getButtons().get(j).setChecked(true);
|
blockgroup.getButtons().get(j).setChecked(true);
|
||||||
break;
|
break;
|
||||||
@@ -564,7 +565,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for(Block block : Block.all()){
|
for(Block block : Vars.content.blocks()){
|
||||||
TextureRegion[] regions = block.getCompactIcon();
|
TextureRegion[] regions = block.getCompactIcon();
|
||||||
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.database().isUnlocked(Recipe.getByResult(block))))
|
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.database().isUnlocked(Recipe.getByResult(block))))
|
||||||
&& !debug && block != StorageBlocks.core){
|
&& !debug && block != StorageBlocks.core){
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import io.anuke.ucore.util.Bits;
|
|||||||
import io.anuke.ucore.util.Geometry;
|
import io.anuke.ucore.util.Geometry;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class MapRenderer implements Disposable{
|
public class MapRenderer implements Disposable{
|
||||||
@@ -108,8 +109,8 @@ public class MapRenderer implements Disposable{
|
|||||||
byte rotation = Bits.getLeftByte(btr);
|
byte rotation = Bits.getLeftByte(btr);
|
||||||
Team team = Team.all[Bits.getRightByte(btr)];
|
Team team = Team.all[Bits.getRightByte(btr)];
|
||||||
|
|
||||||
Block floor = Block.getByID(bf);
|
Block floor = content.block(bf);
|
||||||
Block wall = Block.getByID(bw);
|
Block wall = content.block(bw);
|
||||||
|
|
||||||
TextureRegion region;
|
TextureRegion region;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import io.anuke.mindustry.graphics.Palette;
|
|||||||
import io.anuke.mindustry.graphics.Trail;
|
import io.anuke.mindustry.graphics.Trail;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.NetConnection;
|
import io.anuke.mindustry.net.NetConnection;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.type.Mech;
|
import io.anuke.mindustry.type.Mech;
|
||||||
import io.anuke.mindustry.type.Weapon;
|
import io.anuke.mindustry.type.Weapon;
|
||||||
@@ -765,13 +766,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
byte mechid = stream.readByte();
|
byte mechid = stream.readByte();
|
||||||
int index = stream.readByte();
|
int index = stream.readByte();
|
||||||
players[index].readSaveSuper(stream);
|
players[index].readSaveSuper(stream);
|
||||||
players[index].mech = Mech.getByID(mechid);
|
players[index].mech = content.getByID(ContentType.mech, mechid);
|
||||||
players[index].dead = false;
|
players[index].dead = false;
|
||||||
}else if(local){
|
}else if(local){
|
||||||
byte mechid = stream.readByte();
|
byte mechid = stream.readByte();
|
||||||
stream.readByte();
|
stream.readByte();
|
||||||
readSaveSuper(stream);
|
readSaveSuper(stream);
|
||||||
mech = Mech.getByID(mechid);
|
mech = content.getByID(ContentType.mech, mechid);
|
||||||
dead = false;
|
dead = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -807,7 +808,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
boolean boosting = (bools & 4) != 0;
|
boolean boosting = (bools & 4) != 0;
|
||||||
boolean alt = (bools & 8) != 0;
|
boolean alt = (bools & 8) != 0;
|
||||||
color.set(buffer.readInt());
|
color.set(buffer.readInt());
|
||||||
mech = Mech.getByID(buffer.readByte());
|
mech = content.getByID(ContentType.mech, buffer.readByte());
|
||||||
int mine = buffer.readInt();
|
int mine = buffer.readInt();
|
||||||
spawner = buffer.readInt();
|
spawner = buffer.readInt();
|
||||||
float baseRotation = buffer.readShort() / 2f;
|
float baseRotation = buffer.readShort() / 2f;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry.entities;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.entities.traits.Saveable;
|
import io.anuke.mindustry.entities.traits.Saveable;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.StatusEffect;
|
import io.anuke.mindustry.type.StatusEffect;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.util.Pooling;
|
import io.anuke.ucore.util.Pooling;
|
||||||
@@ -11,7 +12,7 @@ import io.anuke.ucore.util.ThreadArray;
|
|||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
/**
|
/**
|
||||||
* Class for controlling status effects on an entity.
|
* Class for controlling status effects on an entity.
|
||||||
*/
|
*/
|
||||||
@@ -129,7 +130,7 @@ public class StatusController implements Saveable{
|
|||||||
byte id = stream.readByte();
|
byte id = stream.readByte();
|
||||||
float time = stream.readShort() / 2f;
|
float time = stream.readShort() / 2f;
|
||||||
StatusEntry entry = Pooling.obtain(StatusEntry.class);
|
StatusEntry entry = Pooling.obtain(StatusEntry.class);
|
||||||
entry.set(StatusEffect.getByID(id), time);
|
entry.set(content.getByID(ContentType.status, id), time);
|
||||||
statuses.add(entry);
|
statuses.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import java.io.DataInput;
|
|||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class UnitInventory implements Saveable{
|
public class UnitInventory implements Saveable{
|
||||||
private final Unit unit;
|
private final Unit unit;
|
||||||
private ItemStack item = new ItemStack(Items.stone, 0);
|
private ItemStack item = new ItemStack(Items.stone, 0);
|
||||||
@@ -32,7 +34,7 @@ public class UnitInventory implements Saveable{
|
|||||||
short iamount = stream.readShort();
|
short iamount = stream.readShort();
|
||||||
byte iid = stream.readByte();
|
byte iid = stream.readByte();
|
||||||
|
|
||||||
item.item = Item.getByID(iid);
|
item.item = content.item(iid);
|
||||||
item.amount = iamount;
|
item.amount = iamount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.io.DataOutput;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.bulletGroup;
|
import static io.anuke.mindustry.Vars.bulletGroup;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait{
|
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait{
|
||||||
@@ -149,7 +150,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
velocity.x = data.readFloat();
|
velocity.x = data.readFloat();
|
||||||
velocity.y = data.readFloat();
|
velocity.y = data.readFloat();
|
||||||
team = Team.all[data.readByte()];
|
team = Team.all[data.readByte()];
|
||||||
type = BulletType.getByID(data.readByte());
|
type = content.bullet(data.readByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.entities.bullet;
|
package io.anuke.mindustry.entities.bullet;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
@@ -8,13 +7,20 @@ import io.anuke.mindustry.type.ContentType;
|
|||||||
import io.anuke.mindustry.type.StatusEffect;
|
import io.anuke.mindustry.type.StatusEffect;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.entities.impl.BaseBulletType;
|
import io.anuke.ucore.entities.impl.BaseBulletType;
|
||||||
|
import io.anuke.ucore.util.Translator;
|
||||||
|
|
||||||
public abstract class BulletType extends BaseBulletType<Bullet> implements Content{
|
public abstract class BulletType extends Content implements BaseBulletType<Bullet>{
|
||||||
private static int lastid = 0;
|
public float lifetime = 100;
|
||||||
private static Array<BulletType> types = new Array<>();
|
public float speed = 1f;
|
||||||
|
public float damage = 1;
|
||||||
|
public float hitsize = 4;
|
||||||
|
public float drawSize = 20f;
|
||||||
|
public float drag = 0f;
|
||||||
|
public boolean pierce;
|
||||||
|
public Effect hiteffect = null, despawneffect = null;
|
||||||
|
|
||||||
public final int id;
|
|
||||||
/**Knockback in velocity.*/
|
/**Knockback in velocity.*/
|
||||||
public float knockback;
|
public float knockback;
|
||||||
/**Whether this bullet hits tiles.*/
|
/**Whether this bullet hits tiles.*/
|
||||||
@@ -36,29 +42,65 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
|
|||||||
/**Whether velocity is inherited from the shooter.*/
|
/**Whether velocity is inherited from the shooter.*/
|
||||||
public boolean keepVelocity = true;
|
public boolean keepVelocity = true;
|
||||||
|
|
||||||
|
protected Translator vector = new Translator();
|
||||||
|
|
||||||
public BulletType(float speed, float damage){
|
public BulletType(float speed, float damage){
|
||||||
this.id = lastid++;
|
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
lifetime = 40f;
|
lifetime = 40f;
|
||||||
hiteffect = BulletFx.hitBulletSmall;
|
hiteffect = BulletFx.hitBulletSmall;
|
||||||
despawneffect = BulletFx.hitBulletSmall;
|
despawneffect = BulletFx.hitBulletSmall;
|
||||||
|
|
||||||
types.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BulletType getByID(int id){
|
|
||||||
return types.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Array<BulletType> all(){
|
|
||||||
return types;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hitTile(Bullet b, Tile tile){
|
public void hitTile(Bullet b, Tile tile){
|
||||||
hit(b);
|
hit(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float drawSize(){
|
||||||
|
return 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float lifetime(){
|
||||||
|
return lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float speed(){
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float damage(){
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float hitSize(){
|
||||||
|
return hitSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float drag(){
|
||||||
|
return drag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pierce(){
|
||||||
|
return pierce;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Effect hitEffect(){
|
||||||
|
return hiteffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Effect despawnEffect(){
|
||||||
|
return despawneffect;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hit(Bullet b, float hitx, float hity){
|
public void hit(Bullet b, float hitx, float hity){
|
||||||
Effects.effect(hiteffect, hitx, hity, b.angle());
|
Effects.effect(hiteffect, hitx, hity, b.angle());
|
||||||
@@ -73,9 +115,4 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
|
|||||||
public ContentType getContentType(){
|
public ContentType getContentType(){
|
||||||
return ContentType.bullet;
|
return ContentType.bullet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
|
|||||||
public void readSave(DataInput data) throws IOException{
|
public void readSave(DataInput data) throws IOException{
|
||||||
x = data.readFloat();
|
x = data.readFloat();
|
||||||
y = data.readFloat();
|
y = data.readFloat();
|
||||||
item = Item.getByID(data.readByte());
|
item = content.item(data.readByte());
|
||||||
amount = data.readShort();
|
amount = data.readShort();
|
||||||
add();
|
add();
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
|
|||||||
@Override
|
@Override
|
||||||
public void read(DataInput data, long time) throws IOException{
|
public void read(DataInput data, long time) throws IOException{
|
||||||
interpolator.read(x, y, data.readFloat(), data.readFloat(), time);
|
interpolator.read(x, y, data.readFloat(), data.readFloat(), time);
|
||||||
item = Item.getByID(data.readByte());
|
item = content.item(data.readByte());
|
||||||
amount = data.readShort();
|
amount = data.readShort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import java.io.DataInput;
|
|||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.puddleGroup;
|
import static io.anuke.mindustry.Vars.puddleGroup;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
@@ -261,7 +262,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait
|
|||||||
this.loadedPosition = stream.readInt();
|
this.loadedPosition = stream.readInt();
|
||||||
this.x = stream.readFloat();
|
this.x = stream.readFloat();
|
||||||
this.y = stream.readFloat();
|
this.y = stream.readFloat();
|
||||||
this.liquid = Liquid.getByID(stream.readByte());
|
this.liquid = content.liquid(stream.readByte());
|
||||||
this.amount = stream.readFloat();
|
this.amount = stream.readFloat();
|
||||||
this.generation = stream.readByte();
|
this.generation = stream.readByte();
|
||||||
add();
|
add();
|
||||||
@@ -304,7 +305,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait
|
|||||||
public void read(DataInput data, long time) throws IOException{
|
public void read(DataInput data, long time) throws IOException{
|
||||||
x = data.readFloat();
|
x = data.readFloat();
|
||||||
y = data.readFloat();
|
y = data.readFloat();
|
||||||
liquid = Liquid.getByID(data.readByte());
|
liquid = content.liquid(data.readByte());
|
||||||
targetAmount = data.readShort() / 4f;
|
targetAmount = data.readShort() / 4f;
|
||||||
tile = world.tile(data.readInt());
|
tile = world.tile(data.readInt());
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ import java.io.DataOutput;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static io.anuke.mindustry.Vars.tmptr;
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for units that build, break or mine things.
|
* Interface for units that build, break or mine things.
|
||||||
@@ -101,7 +99,7 @@ public interface BuilderTrait extends Entity{
|
|||||||
}else{ //place
|
}else{ //place
|
||||||
byte recipe = input.readByte();
|
byte recipe = input.readByte();
|
||||||
byte rotation = input.readByte();
|
byte rotation = input.readByte();
|
||||||
request = new BuildRequest(position % world.width(), position / world.width(), rotation, Recipe.getByID(recipe));
|
request = new BuildRequest(position % world.width(), position / world.width(), rotation, content.recipe(recipe));
|
||||||
}
|
}
|
||||||
|
|
||||||
request.progress = progress;
|
request.progress = progress;
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
this.isWave = stream.readBoolean();
|
this.isWave = stream.readBoolean();
|
||||||
this.spawner = stream.readInt();
|
this.spawner = stream.readInt();
|
||||||
|
|
||||||
this.type = UnitType.getByID(type);
|
this.type = content.unit(type);
|
||||||
add();
|
add();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
public void read(DataInput data, long time) throws IOException{
|
public void read(DataInput data, long time) throws IOException{
|
||||||
float lastx = x, lasty = y, lastrot = rotation;
|
float lastx = x, lasty = y, lastrot = rotation;
|
||||||
super.readSave(data);
|
super.readSave(data);
|
||||||
this.type = UnitType.getByID(data.readByte());
|
this.type = content.unit(data.readByte());
|
||||||
this.spawner = data.readInt();
|
this.spawner = data.readInt();
|
||||||
|
|
||||||
interpolator.read(lastx, lasty, x, y, time, rotation);
|
interpolator.read(lastx, lasty, x, y, time, rotation);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.anuke.mindustry.entities.TileEntity;
|
|||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.type.AmmoType;
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
|
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;
|
||||||
@@ -21,6 +22,7 @@ import java.io.DataInput;
|
|||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public abstract class GroundUnit extends BaseUnit{
|
public abstract class GroundUnit extends BaseUnit{
|
||||||
@@ -210,7 +212,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
@Override
|
@Override
|
||||||
public void read(DataInput data, long time) throws IOException{
|
public void read(DataInput data, long time) throws IOException{
|
||||||
super.read(data, time);
|
super.read(data, time);
|
||||||
weapon = Weapon.getByID(data.readByte());
|
weapon = content.getByID(ContentType.weapon, data.readByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -221,7 +223,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSave(DataInput stream) throws IOException{
|
public void readSave(DataInput stream) throws IOException{
|
||||||
weapon = Weapon.getByID(stream.readByte());
|
weapon = content.getByID(ContentType.weapon, stream.readByte());
|
||||||
super.readSave(stream);
|
super.readSave(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package io.anuke.mindustry.entities.units;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.badlogic.gdx.utils.ObjectSet;
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
import io.anuke.mindustry.content.Items;
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.content.Weapons;
|
import io.anuke.mindustry.content.Weapons;
|
||||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
@@ -22,15 +20,11 @@ import io.anuke.ucore.util.Log;
|
|||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
//TODO merge unit type with mech
|
//TODO merge unit type with mech
|
||||||
public class UnitType implements UnlockableContent{
|
public class UnitType extends UnlockableContent{
|
||||||
private static byte lastid = 0;
|
|
||||||
private static Array<UnitType> types = new Array<>();
|
|
||||||
|
|
||||||
protected final Supplier<? extends BaseUnit> constructor;
|
protected final Supplier<? extends BaseUnit> constructor;
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String description;
|
public final String description;
|
||||||
public final byte id;
|
|
||||||
public float health = 60;
|
public float health = 60;
|
||||||
public float hitsize = 5f;
|
public float hitsize = 5f;
|
||||||
public float hitsizeTile = 4f;
|
public float hitsizeTile = 4f;
|
||||||
@@ -55,13 +49,10 @@ public class UnitType implements UnlockableContent{
|
|||||||
public TextureRegion iconRegion, legRegion, baseRegion, region;
|
public TextureRegion iconRegion, legRegion, baseRegion, region;
|
||||||
|
|
||||||
public <T extends BaseUnit> UnitType(String name, Class<T> type, Supplier<T> mainConstructor){
|
public <T extends BaseUnit> UnitType(String name, Class<T> type, Supplier<T> mainConstructor){
|
||||||
this.id = lastid++;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.constructor = mainConstructor;
|
this.constructor = mainConstructor;
|
||||||
this.description = Bundles.getOrNull("unit." + name + ".description");
|
this.description = Bundles.getOrNull("unit." + name + ".description");
|
||||||
|
|
||||||
types.add(this);
|
|
||||||
|
|
||||||
TypeTrait.registerType(type, mainConstructor);
|
TypeTrait.registerType(type, mainConstructor);
|
||||||
|
|
||||||
if(!Bundles.has("unit." + this.name + ".name")){
|
if(!Bundles.has("unit." + this.name + ".name")){
|
||||||
@@ -70,19 +61,6 @@ public class UnitType implements UnlockableContent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UnitType getByID(byte id){
|
|
||||||
return types.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Array<UnitType> all(){
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayInfo(Table table){
|
public void displayInfo(Table table){
|
||||||
ContentDisplay.displayUnit(table, this);
|
ContentDisplay.displayUnit(table, this);
|
||||||
@@ -119,11 +97,6 @@ public class UnitType implements UnlockableContent{
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseUnit create(Team team){
|
public BaseUnit create(Team team){
|
||||||
BaseUnit unit = constructor.get();
|
BaseUnit unit = constructor.get();
|
||||||
unit.init(this, team);
|
unit.init(this, team);
|
||||||
|
|||||||
@@ -1,34 +1,37 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
/**
|
|
||||||
* Base interface for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}.
|
/**Base class for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}.*/
|
||||||
*/
|
public abstract class Content{
|
||||||
public interface Content{
|
public final byte id;
|
||||||
|
|
||||||
|
public Content(){
|
||||||
|
this.id = (byte)Vars.content.getBy(getContentType()).size;
|
||||||
|
Vars.content.handleContent(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type name of this piece of content.
|
* Returns the type name of this piece of content.
|
||||||
* This should return the same value for all instances of this content type.
|
* This should return the same value for all instances of this content type.
|
||||||
*/
|
*/
|
||||||
ContentType getContentType();
|
public abstract ContentType getContentType();
|
||||||
|
|
||||||
/**
|
/**Called after all content is created. Do not use to load regions or texture data!*/
|
||||||
* Returns a list of all instances of this content.
|
public void init(){
|
||||||
*/
|
|
||||||
Array<? extends Content> getAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called after all content is created. Do not use to load regions or texture data!
|
|
||||||
*/
|
|
||||||
default void init(){
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after all content is created, only on non-headless versions.
|
* Called after all content is created, only on non-headless versions.
|
||||||
* Use for loading regions or other image data.
|
* Use for loading regions or other image data.
|
||||||
*/
|
*/
|
||||||
default void load(){
|
public void load(){
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return getContentType().name() + "#" + id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
/**Interface for a list of content to be loaded in {@link io.anuke.mindustry.core.ContentLoader}.*/
|
/**Interface for a list of content to be loaded in {@link io.anuke.mindustry.core.ContentLoader}.*/
|
||||||
public interface ContentList{
|
public interface ContentList{
|
||||||
/**This method should create all the content.*/
|
/**This method should create all the content.*/
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
/**This method should return the list of the content of this type, for further loading.*/
|
/**This method should return the type of content being loaded.*/
|
||||||
Array<? extends Content> getAll();
|
ContentType type();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
public interface MappableContent extends Content {
|
public abstract class MappableContent extends Content {
|
||||||
/**
|
/**
|
||||||
* Returns the unqiue name of this piece of content.
|
* Returns the unqiue name of this piece of content.
|
||||||
* The name only needs to be unique for all content of this type.
|
* The name only needs to be unique for all content of this type.
|
||||||
* Do not use IDs for names! Make sure this string stays constant with each update unless removed.
|
* Do not use IDs for names! Make sure this string stays constant with each update unless removed.
|
||||||
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).
|
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).
|
||||||
*/
|
*/
|
||||||
String getContentName();
|
public abstract String getContentName();
|
||||||
|
|
||||||
int getID();
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return getContentName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,31 +6,31 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
|
||||||
/**Base interface for an unlockable content type.*/
|
/**Base interface for an unlockable content type.*/
|
||||||
public interface UnlockableContent extends MappableContent{
|
public abstract class UnlockableContent extends MappableContent{
|
||||||
/**Returns the localized name of this content.*/
|
/**Returns the localized name of this content.*/
|
||||||
String localizedName();
|
public abstract String localizedName();
|
||||||
|
|
||||||
TextureRegion getContentIcon();
|
public abstract TextureRegion getContentIcon();
|
||||||
|
|
||||||
/**This should show all necessary info about this content in the specified table.*/
|
/**This should show all necessary info about this content in the specified table.*/
|
||||||
void displayInfo(Table table);
|
public abstract void displayInfo(Table table);
|
||||||
|
|
||||||
/**Called when this content is unlocked. Use this to unlock other related content.*/
|
/**Called when this content is unlocked. Use this to unlock other related content.*/
|
||||||
default void onUnlock(){
|
public void onUnlock(){
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Whether this content is always hidden in the content info dialog.*/
|
/**Whether this content is always hidden in the content info dialog.*/
|
||||||
default boolean isHidden(){
|
public boolean isHidden(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Lists the content that must be unlocked in order for this specific content to become unlocked. May return null.*/
|
/**Lists the content that must be unlocked in order for this specific content to become unlocked. May return null.*/
|
||||||
default UnlockableContent[] getDependencies(){
|
public UnlockableContent[] getDependencies(){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Returns whether dependencies are satisfied for unlocking this content.*/
|
/**Returns whether dependencies are satisfied for unlocking this content.*/
|
||||||
default boolean canBeUnlocked(){
|
public boolean canBeUnlocked(){
|
||||||
UnlockableContent[] depend = getDependencies();
|
UnlockableContent[] depend = getDependencies();
|
||||||
if(depend == null){
|
if(depend == null){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeDrawResult;
|
import io.anuke.mindustry.input.PlaceUtils.NormalizeDrawResult;
|
||||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
|
import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
|
||||||
import io.anuke.mindustry.maps.generation.StructureFormat;
|
|
||||||
import io.anuke.mindustry.maps.generation.StructureFormat.StructBlock;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -20,9 +18,7 @@ import io.anuke.ucore.core.KeyBinds;
|
|||||||
import io.anuke.ucore.core.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
import io.anuke.ucore.input.Input;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Log;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
@@ -66,23 +62,6 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printArea(NormalizeResult result){
|
|
||||||
StructBlock[][] blocks = new StructBlock[Math.abs(result.x2 - result.x) + 1][Math.abs(result.y2 - result.y) + 1];
|
|
||||||
|
|
||||||
for(int x = 0; x <= Math.abs(result.x2 - result.x); x++){
|
|
||||||
for(int y = 0; y <= Math.abs(result.y2 - result.y); y++){
|
|
||||||
int wx = result.x + x;
|
|
||||||
int wy = result.y + y;
|
|
||||||
|
|
||||||
Block block = world.tile(wx, wy).block();
|
|
||||||
|
|
||||||
blocks[x][y] = new StructBlock(block == Blocks.blockpart ? Blocks.air : block, world.tile(wx, wy).getRotation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.info(StructureFormat.writeBase64(blocks));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDrawing(){
|
public boolean isDrawing(){
|
||||||
return mode != none || recipe != null;
|
return mode != none || recipe != null;
|
||||||
@@ -269,17 +248,12 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
}else if(mode == breaking){ //touch up while breaking, break everything in selection
|
}else if(mode == breaking){ //touch up while breaking, break everything in selection
|
||||||
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, false, maxLength);
|
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, false, maxLength);
|
||||||
|
for(int x = 0; x <= Math.abs(result.x2 - result.x); x++){
|
||||||
|
for(int y = 0; y <= Math.abs(result.y2 - result.y); y++){
|
||||||
|
int wx = selectX + x * Mathf.sign(cursor.x - selectX);
|
||||||
|
int wy = selectY + y * Mathf.sign(cursor.y - selectY);
|
||||||
|
|
||||||
if(debug && Inputs.keyDown(Input.CONTROL_LEFT)){
|
tryBreakBlock(wx, wy);
|
||||||
printArea(result);
|
|
||||||
}else{
|
|
||||||
for(int x = 0; x <= Math.abs(result.x2 - result.x); x++){
|
|
||||||
for(int y = 0; y <= Math.abs(result.y2 - result.y); y++){
|
|
||||||
int wx = selectX + x * Mathf.sign(cursor.x - selectX);
|
|
||||||
int wy = selectY + y * Mathf.sign(cursor.y - selectY);
|
|
||||||
|
|
||||||
tryBreakBlock(wx, wy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import io.anuke.mindustry.maps.MapMeta;
|
|||||||
import io.anuke.mindustry.maps.MapTileData;
|
import io.anuke.mindustry.maps.MapTileData;
|
||||||
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
||||||
import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
|
import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.ColorMapper;
|
import io.anuke.mindustry.world.ColorMapper;
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and writes map files.
|
* Reads and writes map files.
|
||||||
@@ -29,7 +31,7 @@ public class MapIO{
|
|||||||
private static IntIntMap defaultBlockMap = new IntIntMap();
|
private static IntIntMap defaultBlockMap = new IntIntMap();
|
||||||
|
|
||||||
private static void loadDefaultBlocks(){
|
private static void loadDefaultBlocks(){
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.blocks()){
|
||||||
defaultBlockMap.put(block.id, block.id);
|
defaultBlockMap.put(block.id, block.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,8 +46,8 @@ public class MapIO{
|
|||||||
for(int y = 0; y < data.height(); y++){
|
for(int y = 0; y < data.height(); y++){
|
||||||
for(int x = 0; x < data.width(); x++){
|
for(int x = 0; x < data.width(); x++){
|
||||||
data.read(marker);
|
data.read(marker);
|
||||||
Block floor = Block.getByID(marker.floor);
|
Block floor = content.block(marker.floor);
|
||||||
Block wall = Block.getByID(marker.wall);
|
Block wall = content.block(marker.wall);
|
||||||
int wallc = ColorMapper.getBlockColor(wall);
|
int wallc = ColorMapper.getBlockColor(wall);
|
||||||
if(wallc == 0 && (wall.update || wall.solid || wall.breakable)) wallc = Team.all[marker.team].intColor;
|
if(wallc == 0 && (wall.update || wall.solid || wall.breakable)) wallc = Team.all[marker.team].intColor;
|
||||||
wallc = wallc == 0 ? ColorMapper.getBlockColor(floor) : wallc;
|
wallc = wallc == 0 ? ColorMapper.getBlockColor(floor) : wallc;
|
||||||
@@ -146,7 +148,7 @@ public class MapIO{
|
|||||||
for(int i = 0; i < blocks; i++){
|
for(int i = 0; i < blocks; i++){
|
||||||
short id = stream.readShort();
|
short id = stream.readShort();
|
||||||
String name = stream.readUTF();
|
String name = stream.readUTF();
|
||||||
Block block = Block.getByName(name);
|
Block block = content.getByName(ContentType.block, name);
|
||||||
if(block == null){
|
if(block == null){
|
||||||
//Log.info("Map load info: No block with name {0} found.", name);
|
//Log.info("Map load info: No block with name {0} found.", name);
|
||||||
block = Blocks.air;
|
block = Blocks.air;
|
||||||
@@ -169,8 +171,8 @@ public class MapIO{
|
|||||||
stream.writeUTF(entry.value);
|
stream.writeUTF(entry.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.writeShort(Block.all().size);
|
stream.writeShort(content.blocks().size);
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.blocks()){
|
||||||
stream.writeShort(block.id);
|
stream.writeShort(block.id);
|
||||||
stream.writeUTF(block.name);
|
stream.writeUTF(block.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ package io.anuke.mindustry.io;
|
|||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
|
||||||
import com.badlogic.gdx.utils.ObjectMap.Entry;
|
|
||||||
import io.anuke.mindustry.core.ContentLoader;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.game.Difficulty;
|
import io.anuke.mindustry.game.Difficulty;
|
||||||
import io.anuke.mindustry.game.MappableContent;
|
import io.anuke.mindustry.game.MappableContent;
|
||||||
@@ -14,6 +11,8 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public abstract class SaveFileVersion{
|
public abstract class SaveFileVersion{
|
||||||
public final int version;
|
public final int version;
|
||||||
|
|
||||||
@@ -33,19 +32,19 @@ public abstract class SaveFileVersion{
|
|||||||
return new SaveMeta(version, time, playtime, build, sector, mode, map, wave, Difficulty.values()[difficulty]);
|
return new SaveMeta(version, time, playtime, build, sector, mode, map, wave, Difficulty.values()[difficulty]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectMap<ContentType, IntMap<MappableContent>> readContentHeader(DataInputStream stream) throws IOException{
|
public IntMap<IntMap<MappableContent>> readContentHeader(DataInputStream stream) throws IOException{
|
||||||
ObjectMap<ContentType, IntMap<MappableContent>> map = new ObjectMap<>();
|
IntMap<IntMap<MappableContent>> map = new IntMap<>();
|
||||||
|
|
||||||
byte mapped = stream.readByte();
|
byte mapped = stream.readByte();
|
||||||
for (int i = 0; i < mapped; i++) {
|
for (int i = 0; i < mapped; i++) {
|
||||||
ContentType type = ContentType.values()[stream.readByte()];
|
ContentType type = ContentType.values()[stream.readByte()];
|
||||||
map.put(type, new IntMap<>());
|
map.put(type.ordinal(), new IntMap<>());
|
||||||
short total = stream.readShort();
|
short total = stream.readShort();
|
||||||
for (int j = 0; j < total; j++) {
|
for (int j = 0; j < total; j++) {
|
||||||
byte id = stream.readByte();
|
int id = stream.readUnsignedByte();
|
||||||
String name = stream.readUTF();
|
String name = stream.readUTF();
|
||||||
if(ContentLoader.getContentMap().get(type).size == 0) continue;
|
if(content.getContentMap()[type.ordinal()].size == 0) continue;
|
||||||
map.get(type).put(id, ContentLoader.getByName(type, name));
|
map.get(type.ordinal()).put(id, content.getByName(type, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,24 +52,26 @@ public abstract class SaveFileVersion{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeContentHeader(DataOutputStream stream) throws IOException{
|
public void writeContentHeader(DataOutputStream stream) throws IOException{
|
||||||
ObjectMap<ContentType, Array<Content>> map = ContentLoader.getContentMap();
|
Array<Content>[] map = content.getContentMap();
|
||||||
|
|
||||||
int mappable = 0;
|
int mappable = 0;
|
||||||
for(Entry<ContentType, Array<Content>> entry : map.entries()){
|
for(int i =0; i < map.length; i ++){
|
||||||
if(entry.value.size > 0 && entry.value.first() instanceof MappableContent){
|
Array<Content> arr = map[i];
|
||||||
|
if(arr.size > 0 && arr.first() instanceof MappableContent){
|
||||||
mappable ++;
|
mappable ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.writeByte(mappable);
|
stream.writeByte(mappable);
|
||||||
for(Entry<ContentType, Array<Content>> entry : map.entries()){
|
for(int i =0; i < map.length; i ++){
|
||||||
if(entry.value.size > 0 && entry.value.first() instanceof MappableContent){
|
Array<Content> arr = map[i];
|
||||||
stream.writeByte(entry.value.first().getContentType().ordinal());
|
if(arr.size > 0 && arr.first() instanceof MappableContent){
|
||||||
stream.writeShort(entry.value.size);
|
stream.writeByte(arr.first().getContentType().ordinal());
|
||||||
for(Content c : entry.value){
|
stream.writeShort(arr.size);
|
||||||
|
for(Content c : arr){
|
||||||
MappableContent m = (MappableContent)c;
|
MappableContent m = (MappableContent)c;
|
||||||
if(m.getID() >= 128) throw new RuntimeException("Content " + c + " has ID > 127!");
|
if(m.id > 255) throw new RuntimeException("Content " + c + " has ID > 255!");
|
||||||
stream.writeByte(m.getID());
|
stream.writeByte(m.id);
|
||||||
stream.writeUTF(m.getContentName());
|
stream.writeUTF(m.getContentName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
@ReadClass(Block.class)
|
@ReadClass(Block.class)
|
||||||
public static Block readBlock(ByteBuffer buffer){
|
public static Block readBlock(ByteBuffer buffer){
|
||||||
return Block.getByID(buffer.get());
|
return content.block(buffer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(KickReason.class)
|
@WriteClass(KickReason.class)
|
||||||
@@ -224,7 +224,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
@ReadClass(Weapon.class)
|
@ReadClass(Weapon.class)
|
||||||
public static Weapon readWeapon(ByteBuffer buffer){
|
public static Weapon readWeapon(ByteBuffer buffer){
|
||||||
return Weapon.getByID(buffer.get());
|
return content.getByID(ContentType.weapon, buffer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(Mech.class)
|
@WriteClass(Mech.class)
|
||||||
@@ -234,7 +234,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
@ReadClass(Mech.class)
|
@ReadClass(Mech.class)
|
||||||
public static Mech readMech(ByteBuffer buffer){
|
public static Mech readMech(ByteBuffer buffer){
|
||||||
return Mech.getByID(buffer.get());
|
return content.getByID(ContentType.mech, buffer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(Liquid.class)
|
@WriteClass(Liquid.class)
|
||||||
@@ -244,7 +244,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
@ReadClass(Liquid.class)
|
@ReadClass(Liquid.class)
|
||||||
public static Liquid readLiquid(ByteBuffer buffer){
|
public static Liquid readLiquid(ByteBuffer buffer){
|
||||||
return Liquid.getByID(buffer.get());
|
return content.liquid(buffer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(AmmoType.class)
|
@WriteClass(AmmoType.class)
|
||||||
@@ -254,7 +254,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
@ReadClass(AmmoType.class)
|
@ReadClass(AmmoType.class)
|
||||||
public static AmmoType readAmmo(ByteBuffer buffer){
|
public static AmmoType readAmmo(ByteBuffer buffer){
|
||||||
return AmmoType.getByID(buffer.get());
|
return content.getByID(ContentType.weapon, buffer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(BulletType.class)
|
@WriteClass(BulletType.class)
|
||||||
@@ -264,7 +264,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
@ReadClass(BulletType.class)
|
@ReadClass(BulletType.class)
|
||||||
public static BulletType readBulletType(ByteBuffer buffer){
|
public static BulletType readBulletType(ByteBuffer buffer){
|
||||||
return BulletType.getByID(buffer.get());
|
return content.getByID(ContentType.bullet, buffer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(Item.class)
|
@WriteClass(Item.class)
|
||||||
@@ -275,7 +275,7 @@ public class TypeIO{
|
|||||||
@ReadClass(Item.class)
|
@ReadClass(Item.class)
|
||||||
public static Item readItem(ByteBuffer buffer){
|
public static Item readItem(ByteBuffer buffer){
|
||||||
byte id = buffer.get();
|
byte id = buffer.get();
|
||||||
return id == -1 ? null : Item.getByID(id);
|
return id == -1 ? null : content.item(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(Recipe.class)
|
@WriteClass(Recipe.class)
|
||||||
@@ -285,7 +285,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
@ReadClass(Recipe.class)
|
@ReadClass(Recipe.class)
|
||||||
public static Recipe readRecipe(ByteBuffer buffer){
|
public static Recipe readRecipe(ByteBuffer buffer){
|
||||||
return Recipe.getByID(buffer.get());
|
return content.recipe(buffer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(String.class)
|
@WriteClass(String.class)
|
||||||
@@ -356,9 +356,9 @@ public class TypeIO{
|
|||||||
info.android = buffer.get() == 1;
|
info.android = buffer.get() == 1;
|
||||||
info.totalBlocksBroken = buffer.getInt();
|
info.totalBlocksBroken = buffer.getInt();
|
||||||
info.structureBlocksBroken = buffer.getInt();
|
info.structureBlocksBroken = buffer.getInt();
|
||||||
info.lastBlockBroken = Block.getByID(buffer.getInt());
|
info.lastBlockBroken = content.block(buffer.getInt());
|
||||||
info.totalBlocksPlaced = buffer.getInt();
|
info.totalBlocksPlaced = buffer.getInt();
|
||||||
info.lastBlockPlaced = Block.getByID(buffer.getInt());
|
info.lastBlockPlaced = content.block(buffer.getInt());
|
||||||
byte[] uuid = new byte[8];
|
byte[] uuid = new byte[8];
|
||||||
buffer.get(uuid);
|
buffer.get(uuid);
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package io.anuke.mindustry.io.versions;
|
package io.anuke.mindustry.io.versions;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||||
import io.anuke.mindustry.entities.traits.SaveTrait;
|
import io.anuke.mindustry.entities.traits.SaveTrait;
|
||||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.Difficulty;
|
||||||
|
import io.anuke.mindustry.game.GameMode;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
|
import io.anuke.mindustry.game.Version;
|
||||||
import io.anuke.mindustry.io.SaveFileVersion;
|
import io.anuke.mindustry.io.SaveFileVersion;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.Map;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
@@ -56,8 +56,7 @@ public class Save16 extends SaveFileVersion{
|
|||||||
state.wave = wave;
|
state.wave = wave;
|
||||||
state.wavetime = wavetime;
|
state.wavetime = wavetime;
|
||||||
|
|
||||||
ObjectMap<ContentType, IntMap<MappableContent>> contentMap = readContentHeader(stream);
|
content.setTemporaryMapper(readContentHeader(stream));
|
||||||
//TODO implement
|
|
||||||
|
|
||||||
state.spawner.read(stream);
|
state.spawner.read(stream);
|
||||||
|
|
||||||
@@ -151,6 +150,7 @@ public class Save16 extends SaveFileVersion{
|
|||||||
i += consecutives;
|
i += consecutives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content.setTemporaryMapper(null);
|
||||||
world.endMapLoad();
|
world.endMapLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import io.anuke.ucore.function.IntPositionConsumer;
|
|||||||
import io.anuke.ucore.function.TriFunction;
|
import io.anuke.ucore.function.TriFunction;
|
||||||
import io.anuke.ucore.util.Geometry;
|
import io.anuke.ucore.util.Geometry;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class FortressGenerator{
|
public class FortressGenerator{
|
||||||
private final static int coreDst = 120;
|
private final static int coreDst = 120;
|
||||||
@@ -246,7 +247,7 @@ public class FortressGenerator{
|
|||||||
|
|
||||||
Array<Block> find(Predicate<Block> pred){
|
Array<Block> find(Predicate<Block> pred){
|
||||||
Array<Block> out = new Array<>();
|
Array<Block> out = new Array<>();
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.blocks()){
|
||||||
if(pred.evaluate(block) && Recipe.getByResult(block) != null){
|
if(pred.evaluate(block) && Recipe.getByResult(block) != null){
|
||||||
out.add(block);
|
out.add(block);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
package io.anuke.mindustry.maps.generation;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Base64Coder;
|
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
|
||||||
import com.badlogic.gdx.utils.ObjectIntMap;
|
|
||||||
import com.badlogic.gdx.utils.ObjectIntMap.Entry;
|
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class StructureFormat{
|
|
||||||
|
|
||||||
public static byte[] write(StructBlock[][] blocks){
|
|
||||||
try{
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream stream = new DataOutputStream(out);
|
|
||||||
|
|
||||||
ObjectIntMap<Block> mapping = new ObjectIntMap<>();
|
|
||||||
int lastid = 1;
|
|
||||||
mapping.put(Blocks.air, 0);
|
|
||||||
|
|
||||||
for(int x = 0; x < blocks.length; x++){
|
|
||||||
for(int y = 0; y < blocks[0].length; y++){
|
|
||||||
Block block = blocks[x][y].block;
|
|
||||||
if(!mapping.containsKey(block)){
|
|
||||||
mapping.put(block, lastid++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stream.writeByte(mapping.size);
|
|
||||||
for(Entry<Block> entry : mapping){
|
|
||||||
stream.writeByte(entry.value);
|
|
||||||
stream.writeUTF(entry.key.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
stream.writeByte(blocks.length);
|
|
||||||
stream.writeByte(blocks[0].length);
|
|
||||||
|
|
||||||
for(int x = 0; x < blocks.length; x++){
|
|
||||||
for(int y = 0; y < blocks[0].length; y++){
|
|
||||||
StructBlock block = blocks[x][y];
|
|
||||||
stream.writeByte(mapping.get(block.block, 0));
|
|
||||||
stream.writeByte(block.rotation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return out.toByteArray();
|
|
||||||
|
|
||||||
}catch(IOException e){
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String writeBase64(StructBlock[][] blocks){
|
|
||||||
return new String(Base64Coder.encode(write(blocks)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StructBlock[][] read(byte[] bytes){
|
|
||||||
try{
|
|
||||||
|
|
||||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(bytes));
|
|
||||||
byte size = stream.readByte();
|
|
||||||
IntMap<Block> map = new IntMap<>();
|
|
||||||
for(int i = 0; i < size; i++){
|
|
||||||
map.put(stream.readByte(), Block.getByName(stream.readUTF()));
|
|
||||||
}
|
|
||||||
|
|
||||||
byte width = stream.readByte(), height = stream.readByte();
|
|
||||||
StructBlock[][] blocks = new StructBlock[width][height];
|
|
||||||
for(int x = 0; x < width; x++){
|
|
||||||
for(int y = 0; y < height; y++){
|
|
||||||
blocks[x][y] = new StructBlock(map.get(stream.readByte()), stream.readByte());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return blocks;
|
|
||||||
}catch(IOException e){
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StructBlock[][] read(String base64){
|
|
||||||
return read(Base64Coder.decode(base64));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class StructBlock{
|
|
||||||
public final Block block;
|
|
||||||
public final byte rotation;
|
|
||||||
|
|
||||||
public StructBlock(Block block, byte rotation){
|
|
||||||
this.block = block;
|
|
||||||
this.rotation = rotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.entities.Unit;
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||||
import io.anuke.mindustry.game.Version;
|
import io.anuke.mindustry.game.Version;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.io.IOUtils;
|
import io.anuke.ucore.io.IOUtils;
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
@@ -16,6 +15,7 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,7 +187,7 @@ public class Packets{
|
|||||||
buffer.put(request.remove ? (byte) 1 : 0);
|
buffer.put(request.remove ? (byte) 1 : 0);
|
||||||
buffer.putInt(world.toPacked(request.x, request.y));
|
buffer.putInt(world.toPacked(request.x, request.y));
|
||||||
if(!request.remove){
|
if(!request.remove){
|
||||||
buffer.put((byte) request.recipe.id);
|
buffer.put(request.recipe.id);
|
||||||
buffer.put((byte) request.rotation);
|
buffer.put((byte) request.rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ public class Packets{
|
|||||||
}else{ //place
|
}else{ //place
|
||||||
byte recipe = buffer.get();
|
byte recipe = buffer.get();
|
||||||
byte rotation = buffer.get();
|
byte rotation = buffer.get();
|
||||||
currentRequest = new BuildRequest(position % world.width(), position / world.width(), rotation, Recipe.getByID(recipe));
|
currentRequest = new BuildRequest(position % world.width(), position / world.width(), rotation, content.recipe(recipe));
|
||||||
}
|
}
|
||||||
|
|
||||||
requests.add(currentRequest);
|
requests.add(currentRequest);
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
package io.anuke.mindustry.type;
|
package io.anuke.mindustry.type;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.fx.Fx;
|
import io.anuke.mindustry.content.fx.Fx;
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
|
|
||||||
public class AmmoType implements Content {
|
public class AmmoType extends Content {
|
||||||
private static int lastID = 0;
|
|
||||||
private static Array<AmmoType> allTypes = new Array<>(32);
|
|
||||||
|
|
||||||
public final byte id;
|
|
||||||
/**The item used. Always null if liquid isn't.*/
|
/**The item used. Always null if liquid isn't.*/
|
||||||
public final Item item;
|
public final Item item;
|
||||||
/**The liquid used. Always null if item isn't.*/
|
/**The liquid used. Always null if item isn't.*/
|
||||||
@@ -33,11 +28,6 @@ public class AmmoType implements Content {
|
|||||||
/**Extra smoke effect created when shooting.*/
|
/**Extra smoke effect created when shooting.*/
|
||||||
public Effect smokeEffect = Fx.none;
|
public Effect smokeEffect = Fx.none;
|
||||||
|
|
||||||
{
|
|
||||||
this.id = (byte) (lastID++);
|
|
||||||
allTypes.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an AmmoType with no liquid or item. Used for power-based ammo.
|
* Creates an AmmoType with no liquid or item. Used for power-based ammo.
|
||||||
*/
|
*/
|
||||||
@@ -69,14 +59,6 @@ public class AmmoType implements Content {
|
|||||||
this.quantityMultiplier = multiplier;
|
this.quantityMultiplier = multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Array<AmmoType> all(){
|
|
||||||
return allTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AmmoType getByID(int id){
|
|
||||||
return allTypes.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns maximum distance the bullet this ammo type has can travel.
|
* Returns maximum distance the bullet this ammo type has can travel.
|
||||||
*/
|
*/
|
||||||
@@ -88,9 +70,4 @@ public class AmmoType implements Content {
|
|||||||
public ContentType getContentType(){
|
public ContentType getContentType(){
|
||||||
return ContentType.ammo;
|
return ContentType.ammo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return allTypes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,6 @@ public enum ContentType {
|
|||||||
status,
|
status,
|
||||||
unit,
|
unit,
|
||||||
ammo,
|
ammo,
|
||||||
weather
|
weather,
|
||||||
|
effect
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package io.anuke.mindustry.type;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.ui.ContentDisplay;
|
import io.anuke.mindustry.ui.ContentDisplay;
|
||||||
@@ -12,12 +10,8 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
import io.anuke.ucore.util.ThreadArray;
|
|
||||||
|
|
||||||
public class Item implements Comparable<Item>, UnlockableContent{
|
public class Item extends UnlockableContent implements Comparable<Item>{
|
||||||
private static final ThreadArray<Item> items = new ThreadArray<>();
|
|
||||||
|
|
||||||
public final int id;
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String description;
|
public final String description;
|
||||||
public final Color color;
|
public final Color color;
|
||||||
@@ -44,36 +38,20 @@ public class Item implements Comparable<Item>, UnlockableContent{
|
|||||||
public float cost = 3f;
|
public float cost = 3f;
|
||||||
|
|
||||||
public Item(String name, Color color){
|
public Item(String name, Color color){
|
||||||
this.id = items.size;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.description = Bundles.getOrNull("item." + this.name + ".description");
|
this.description = Bundles.getOrNull("item." + this.name + ".description");
|
||||||
|
|
||||||
items.add(this);
|
|
||||||
|
|
||||||
if(!Bundles.has("item." + this.name + ".name")){
|
if(!Bundles.has("item." + this.name + ".name")){
|
||||||
Log.err("Warning: item '" + name + "' is missing a localized name. Add the follow to bundle.properties:");
|
Log.err("Warning: item '" + name + "' is missing a localized name. Add the follow to bundle.properties:");
|
||||||
Log.err("item." + this.name + ".name=" + Strings.capitalize(name.replace('-', '_')));
|
Log.err("item." + this.name + ".name=" + Strings.capitalize(name.replace('-', '_')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Array<Item> all(){
|
|
||||||
return Item.items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Item getByID(int id){
|
|
||||||
return items.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load(){
|
public void load(){
|
||||||
this.region = Draw.region("item-" + name);
|
this.region = Draw.region("item-" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayInfo(Table table){
|
public void displayInfo(Table table){
|
||||||
ContentDisplay.displayItem(table, this);
|
ContentDisplay.displayItem(table, this);
|
||||||
@@ -108,9 +86,4 @@ public class Item implements Comparable<Item>, UnlockableContent{
|
|||||||
public ContentType getContentType(){
|
public ContentType getContentType(){
|
||||||
return ContentType.item;
|
return ContentType.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return all();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,88 +2,47 @@ package io.anuke.mindustry.type;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.ui.ContentDisplay;
|
import io.anuke.mindustry.ui.ContentDisplay;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.ThreadArray;
|
|
||||||
|
|
||||||
public class Liquid implements UnlockableContent{
|
|
||||||
private static final Array<Liquid> liquids = new ThreadArray<>();
|
|
||||||
|
|
||||||
|
public class Liquid extends UnlockableContent{
|
||||||
public final Color color;
|
public final Color color;
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String description;
|
public final String description;
|
||||||
public final int id;
|
|
||||||
|
|
||||||
/**
|
/**0-1, 0 is completely inflammable, anything above that may catch fire when exposed to heat, 0.5+ is very flammable.*/
|
||||||
* 0-1, 0 is completely inflammable, anything above that may catch fire when exposed to heat, 0.5+ is very flammable.
|
|
||||||
*/
|
|
||||||
public float flammability;
|
public float flammability;
|
||||||
/**
|
/**temperature: 0.5 is 'room' temperature, 0 is very cold, 1 is molten hot*/
|
||||||
* temperature: 0.5 is 'room' temperature, 0 is very cold, 1 is molten hot
|
|
||||||
*/
|
|
||||||
public float temperature = 0.5f;
|
public float temperature = 0.5f;
|
||||||
/**
|
/**how much heat this liquid can store. 0.75=water (high), anything lower is probably less dense and bad at cooling.*/
|
||||||
* how much heat this liquid can store. 0.75=water (high), anything lower is probably less dense and bad at cooling.
|
|
||||||
*/
|
|
||||||
public float heatCapacity = 0.5f;
|
public float heatCapacity = 0.5f;
|
||||||
/**
|
/**how thick this liquid is. 0.5=water (relatively viscous), 1 would be something like tar (very slow)*/
|
||||||
* how thick this liquid is. 0.5=water (relatively viscous), 1 would be something like tar (very slow)
|
|
||||||
*/
|
|
||||||
public float viscosity = 0.5f;
|
public float viscosity = 0.5f;
|
||||||
/**
|
/**how prone to exploding this liquid is, when heated. 0 = nothing, 1 = nuke*/
|
||||||
* how prone to exploding this liquid is, when heated. 0 = nothing, 1 = nuke
|
|
||||||
*/
|
|
||||||
public float explosiveness;
|
public float explosiveness;
|
||||||
/**
|
/**the burning color of this liquid*/
|
||||||
* the burning color of this liquid
|
|
||||||
*/
|
|
||||||
public Color flameColor = Color.valueOf("ffb763");
|
public Color flameColor = Color.valueOf("ffb763");
|
||||||
/**
|
/**The associated status effect.*/
|
||||||
* The associated status effect.
|
|
||||||
*/
|
|
||||||
public StatusEffect effect = StatusEffects.none;
|
public StatusEffect effect = StatusEffects.none;
|
||||||
/**
|
/**Pump tier. Controls which pumps can use this liquid.*/
|
||||||
* Pump tier. Controls which pumps can use this liquid.
|
|
||||||
*/
|
|
||||||
public int tier;
|
public int tier;
|
||||||
/**
|
/**Displayed icon.*/
|
||||||
* Displayed icon.
|
|
||||||
*/
|
|
||||||
public TextureRegion iconRegion;
|
public TextureRegion iconRegion;
|
||||||
|
|
||||||
public Liquid(String name, Color color){
|
public Liquid(String name, Color color){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.color = new Color(color);
|
this.color = new Color(color);
|
||||||
|
|
||||||
this.id = liquids.size;
|
|
||||||
this.description = Bundles.getOrNull("liquid." + name + ".description");
|
this.description = Bundles.getOrNull("liquid." + name + ".description");
|
||||||
|
|
||||||
Liquid.liquids.add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canExtinguish(){
|
public boolean canExtinguish(){
|
||||||
return flammability < 0.1f && temperature <= 0.5f;
|
return flammability < 0.1f && temperature <= 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Array<Liquid> all(){
|
|
||||||
return Liquid.liquids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Liquid getByID(int id){
|
|
||||||
return liquids.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
iconRegion = Draw.region("liquid-icon-" + name);
|
iconRegion = Draw.region("liquid-icon-" + name);
|
||||||
@@ -118,9 +77,4 @@ public class Liquid implements UnlockableContent{
|
|||||||
public ContentType getContentType(){
|
public ContentType getContentType(){
|
||||||
return ContentType.liquid;
|
return ContentType.liquid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return all();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ package io.anuke.mindustry.type;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.content.Weapons;
|
import io.anuke.mindustry.content.Weapons;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.ui.ContentDisplay;
|
import io.anuke.mindustry.ui.ContentDisplay;
|
||||||
@@ -16,11 +14,7 @@ import io.anuke.ucore.util.Bundles;
|
|||||||
import static io.anuke.mindustry.Vars.mobile;
|
import static io.anuke.mindustry.Vars.mobile;
|
||||||
|
|
||||||
//TODO merge unit type with mech
|
//TODO merge unit type with mech
|
||||||
public class Mech implements UnlockableContent{
|
public class Mech extends UnlockableContent{
|
||||||
private static Array<Mech> mechs = new Array<>();
|
|
||||||
private static byte lastid;
|
|
||||||
|
|
||||||
public final byte id;
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String description;
|
public final String description;
|
||||||
|
|
||||||
@@ -50,19 +44,8 @@ public class Mech implements UnlockableContent{
|
|||||||
|
|
||||||
public Mech(String name, boolean flying){
|
public Mech(String name, boolean flying){
|
||||||
this.flying = flying;
|
this.flying = flying;
|
||||||
this.id = lastid++;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = Bundles.get("mech." + name + ".description");
|
this.description = Bundles.get("mech." + name + ".description");
|
||||||
|
|
||||||
mechs.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Array<Mech> all() {
|
|
||||||
return mechs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mech getByID(int id){
|
|
||||||
return mechs.get(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String localizedName(){
|
public String localizedName(){
|
||||||
@@ -87,11 +70,6 @@ public class Mech implements UnlockableContent{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isHidden() {
|
public boolean isHidden() {
|
||||||
return !flying && mobile;
|
return !flying && mobile;
|
||||||
@@ -132,9 +110,4 @@ public class Mech implements UnlockableContent{
|
|||||||
public String toString(){
|
public String toString(){
|
||||||
return localizedName();
|
return localizedName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return all();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
import com.badlogic.gdx.utils.OrderedMap;
|
import com.badlogic.gdx.utils.OrderedMap;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.ui.ContentDisplay;
|
import io.anuke.mindustry.ui.ContentDisplay;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
@@ -21,12 +20,9 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Recipe implements UnlockableContent{
|
public class Recipe extends UnlockableContent{
|
||||||
private static int lastid;
|
|
||||||
private static Array<Recipe> allRecipes = new Array<>();
|
|
||||||
private static ObjectMap<Block, Recipe> recipeMap = new ObjectMap<>();
|
private static ObjectMap<Block, Recipe> recipeMap = new ObjectMap<>();
|
||||||
|
|
||||||
public final int id;
|
|
||||||
public final Block result;
|
public final Block result;
|
||||||
public final ItemStack[] requirements;
|
public final ItemStack[] requirements;
|
||||||
public final Category category;
|
public final Category category;
|
||||||
@@ -40,7 +36,6 @@ public class Recipe implements UnlockableContent{
|
|||||||
private Block[] blockDependencies;
|
private Block[] blockDependencies;
|
||||||
|
|
||||||
public Recipe(Category category, Block result, ItemStack... requirements){
|
public Recipe(Category category, Block result, ItemStack... requirements){
|
||||||
this.id = lastid++;
|
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.requirements = requirements;
|
this.requirements = requirements;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
@@ -54,7 +49,6 @@ public class Recipe implements UnlockableContent{
|
|||||||
|
|
||||||
this.cost = timeToPlace;
|
this.cost = timeToPlace;
|
||||||
|
|
||||||
allRecipes.add(this);
|
|
||||||
recipeMap.put(result, this);
|
recipeMap.put(result, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +62,7 @@ public class Recipe implements UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.clear();
|
r.clear();
|
||||||
for(Recipe recipe : allRecipes){
|
for(Recipe recipe : content.recipes()){
|
||||||
if(recipe.category == category && (Vars.control.database().isUnlocked(recipe) || (debug && recipe.debugOnly))){
|
if(recipe.category == category && (Vars.control.database().isUnlocked(recipe) || (debug && recipe.debugOnly))){
|
||||||
r.add(recipe);
|
r.add(recipe);
|
||||||
}
|
}
|
||||||
@@ -80,29 +74,17 @@ public class Recipe implements UnlockableContent{
|
|||||||
*/
|
*/
|
||||||
public static void getByCategory(Category category, Array<Recipe> r){
|
public static void getByCategory(Category category, Array<Recipe> r){
|
||||||
r.clear();
|
r.clear();
|
||||||
for(Recipe recipe : allRecipes){
|
for(Recipe recipe : content.recipes()){
|
||||||
if(recipe.category == category){
|
if(recipe.category == category){
|
||||||
r.add(recipe);
|
r.add(recipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Array<Recipe> all(){
|
|
||||||
return allRecipes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Recipe getByResult(Block block){
|
public static Recipe getByResult(Block block){
|
||||||
return recipeMap.get(block);
|
return recipeMap.get(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Recipe getByID(int id){
|
|
||||||
if(id < 0 || id >= allRecipes.size){
|
|
||||||
return null;
|
|
||||||
}else{
|
|
||||||
return allRecipes.get(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Recipe setPad(){
|
public Recipe setPad(){
|
||||||
this.isPad = true;
|
this.isPad = true;
|
||||||
return this;
|
return this;
|
||||||
@@ -118,11 +100,6 @@ public class Recipe implements UnlockableContent{
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isHidden(){
|
public boolean isHidden(){
|
||||||
return debugOnly || (desktopOnly && mobile);
|
return debugOnly || (desktopOnly && mobile);
|
||||||
@@ -199,9 +176,4 @@ public class Recipe implements UnlockableContent{
|
|||||||
this.blockDependencies = dependencies;
|
this.blockDependencies = dependencies;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return allRecipes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,28 @@
|
|||||||
package io.anuke.mindustry.type;
|
package io.anuke.mindustry.type;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.badlogic.gdx.utils.ObjectSet;
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
import io.anuke.mindustry.entities.StatusController.StatusEntry;
|
import io.anuke.mindustry.entities.StatusController.StatusEntry;
|
||||||
import io.anuke.mindustry.entities.Unit;
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
|
|
||||||
public class StatusEffect implements Content{
|
public class StatusEffect extends Content{
|
||||||
private static final Array<StatusEffect> array = new Array<>();
|
/**Duration of this status effect in ticks at maximum power.*/
|
||||||
private static int lastid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Duration of this status effect in ticks at maximum power.
|
|
||||||
*/
|
|
||||||
public final float baseDuration;
|
public final float baseDuration;
|
||||||
public final int id;
|
|
||||||
|
|
||||||
public float damageMultiplier = 1f; //damage dealt
|
public float damageMultiplier = 1f; //damage dealt
|
||||||
public float armorMultiplier = 1f; //armor points
|
public float armorMultiplier = 1f; //armor points
|
||||||
public float speedMultiplier = 1f; //speed
|
public float speedMultiplier = 1f; //speed
|
||||||
|
|
||||||
/**
|
/**Set of 'opposite' effects, which will decrease the duration of this effect when applied.*/
|
||||||
* Set of 'opposite' effects, which will decrease the duration of this effect when applied.
|
|
||||||
*/
|
|
||||||
protected ObjectSet<StatusEffect> opposites = new ObjectSet<>();
|
protected ObjectSet<StatusEffect> opposites = new ObjectSet<>();
|
||||||
/**
|
/**The strength of time decrease when met with an opposite effect, as a fraction of the other's duration.*/
|
||||||
* The strength of time decrease when met with an opposite effect, as a fraction of the other's duration.
|
|
||||||
*/
|
|
||||||
protected float oppositeScale = 0.5f;
|
protected float oppositeScale = 0.5f;
|
||||||
|
|
||||||
public StatusEffect(float baseDuration){
|
public StatusEffect(float baseDuration){
|
||||||
this.baseDuration = baseDuration;
|
this.baseDuration = baseDuration;
|
||||||
|
|
||||||
id = lastid++;
|
|
||||||
array.add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StatusEffect getByID(int id){
|
/**Runs every tick on the affected unit while time is greater than 0.*/
|
||||||
return array.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Array<StatusEffect> all(){
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs every tick on the affected unit while time is greater than 0.
|
|
||||||
*/
|
|
||||||
public void update(Unit unit, float time){
|
public void update(Unit unit, float time){
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,9 +64,4 @@ public class StatusEffect implements Content{
|
|||||||
public ContentType getContentType(){
|
public ContentType getContentType(){
|
||||||
return ContentType.status;
|
return ContentType.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.anuke.mindustry.type;
|
package io.anuke.mindustry.type;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
@@ -19,11 +18,7 @@ import io.anuke.ucore.util.Angles;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Translator;
|
import io.anuke.ucore.util.Translator;
|
||||||
|
|
||||||
public class Weapon implements Content{
|
public class Weapon extends Content{
|
||||||
private static Array<Weapon> weapons = new Array<>();
|
|
||||||
private static byte lastid;
|
|
||||||
|
|
||||||
public final byte id;
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
/**minimum cursor distance from player, fixes 'cross-eyed' shooting.*/
|
/**minimum cursor distance from player, fixes 'cross-eyed' shooting.*/
|
||||||
@@ -58,9 +53,7 @@ public class Weapon implements Content{
|
|||||||
public TextureRegion equipRegion, region;
|
public TextureRegion equipRegion, region;
|
||||||
|
|
||||||
protected Weapon(String name){
|
protected Weapon(String name){
|
||||||
this.id = lastid ++;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
weapons.add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.server, called = Loc.both, unreliable = true)
|
@Remote(targets = Loc.server, called = Loc.both, unreliable = true)
|
||||||
@@ -105,14 +98,6 @@ public class Weapon implements Content{
|
|||||||
shooter.getTimer().get(shooter.getShootTimer(left), weapon.reload);
|
shooter.getTimer().get(shooter.getShootTimer(left), weapon.reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Array<Weapon> all() {
|
|
||||||
return weapons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Weapon getByID(int id){
|
|
||||||
return weapons.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
equipRegion = Draw.region(name + "-equip");
|
equipRegion = Draw.region(name + "-equip");
|
||||||
@@ -124,11 +109,6 @@ public class Weapon implements Content{
|
|||||||
return ContentType.weapon;
|
return ContentType.weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll() {
|
|
||||||
return weapons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AmmoType getAmmo(){
|
public AmmoType getAmmo(){
|
||||||
return ammo;
|
return ammo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,17 @@
|
|||||||
package io.anuke.mindustry.type;
|
package io.anuke.mindustry.type;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
|
|
||||||
//TODO implement this class
|
//TODO implement-- should it even be content?
|
||||||
public class WeatherEvent implements Content{
|
public class WeatherEvent extends Content{
|
||||||
private static final Array<WeatherEvent> all = new Array<>();
|
|
||||||
private static int lastid;
|
|
||||||
|
|
||||||
public final int id;
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
public WeatherEvent(String name){
|
public WeatherEvent(String name){
|
||||||
this.id = lastid++;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
all.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Array<WeatherEvent> all(){
|
|
||||||
return all;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WeatherEvent getByID(int id){
|
|
||||||
return all.get(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContentType getContentType(){
|
public ContentType getContentType(){
|
||||||
return ContentType.weather;
|
return ContentType.weather;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return all();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.OrderedMap;
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.ContentLoader;
|
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
@@ -15,6 +13,7 @@ import io.anuke.ucore.scene.ui.Tooltip;
|
|||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.utils.UIUtils;
|
import io.anuke.ucore.scene.utils.UIUtils;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
|
||||||
public class UnlocksDialog extends FloatingDialog{
|
public class UnlocksDialog extends FloatingDialog{
|
||||||
@@ -35,13 +34,15 @@ public class UnlocksDialog extends FloatingDialog{
|
|||||||
table.margin(20);
|
table.margin(20);
|
||||||
ScrollPane pane = new ScrollPane(table, "clear-black");
|
ScrollPane pane = new ScrollPane(table, "clear-black");
|
||||||
|
|
||||||
OrderedMap<ContentType, Array<Content>> allContent = ContentLoader.getContentMap();
|
Array<Content>[] allContent = content.getContentMap();
|
||||||
|
|
||||||
for(ContentType key : allContent.orderedKeys()){
|
for(int j =0; j< allContent.length; j ++){
|
||||||
Array<Content> array = allContent.get(key);
|
ContentType type = ContentType.values()[j];
|
||||||
|
|
||||||
|
Array<Content> array = allContent[j];
|
||||||
if(array.size == 0 || !(array.first() instanceof UnlockableContent)) continue;
|
if(array.size == 0 || !(array.first() instanceof UnlockableContent)) continue;
|
||||||
|
|
||||||
table.add("$content." + key + ".name").growX().left().color(Palette.accent);
|
table.add("$content." + type.name() + ".name").growX().left().color(Palette.accent);
|
||||||
table.row();
|
table.row();
|
||||||
table.addImage("white").growX().pad(5).padLeft(0).padRight(0).height(3).color(Palette.accent);
|
table.addImage("white").growX().pad(5).padLeft(0).padRight(0).height(3).color(Palette.accent);
|
||||||
table.row();
|
table.row();
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
|
|
||||||
updateTablePosition();
|
updateTablePosition();
|
||||||
if(tile.block().hasItems){
|
if(tile.block().hasItems){
|
||||||
for(int i = 0; i < Item.all().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
boolean has = tile.entity.items.has(Item.getByID(i));
|
boolean has = tile.entity.items.has(content.item(i));
|
||||||
if(has != container.contains(i)){
|
if(has != container.contains(i)){
|
||||||
rebuild(false);
|
rebuild(false);
|
||||||
}
|
}
|
||||||
@@ -123,8 +123,8 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
|
|
||||||
if(tile.block().hasItems){
|
if(tile.block().hasItems){
|
||||||
|
|
||||||
for(int i = 0; i < Item.all().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
Item item = Item.getByID(i);
|
Item item = content.item(i);
|
||||||
if(!tile.entity.items.has(item)) continue;
|
if(!tile.entity.items.has(item)) continue;
|
||||||
|
|
||||||
container.add(i);
|
container.add(i);
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class DebugFragment extends Fragment{
|
|||||||
t.row();
|
t.row();
|
||||||
t.addButton("spawn", () -> {
|
t.addButton("spawn", () -> {
|
||||||
FloatingDialog dialog = new FloatingDialog("debug spawn");
|
FloatingDialog dialog = new FloatingDialog("debug spawn");
|
||||||
for(UnitType type : UnitType.all()){
|
for(UnitType type : content.units()){
|
||||||
dialog.content().addImageButton("white", 40, () -> {
|
dialog.content().addImageButton("white", 40, () -> {
|
||||||
BaseUnit unit = type.create(player.getTeam());
|
BaseUnit unit = type.create(player.getTeam());
|
||||||
unit.setWave();
|
unit.setWave();
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.Unit;
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.mindustry.entities.effect.Puddle;
|
import io.anuke.mindustry.entities.effect.Puddle;
|
||||||
|
import io.anuke.mindustry.game.MappableContent;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.type.Liquid;
|
||||||
import io.anuke.mindustry.world.consumers.ConsumeItem;
|
import io.anuke.mindustry.world.consumers.ConsumeItem;
|
||||||
@@ -16,7 +18,7 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Translator;
|
import io.anuke.ucore.util.Translator;
|
||||||
|
|
||||||
public abstract class BaseBlock{
|
public abstract class BaseBlock extends MappableContent{
|
||||||
public boolean hasItems;
|
public boolean hasItems;
|
||||||
public boolean hasLiquids;
|
public boolean hasLiquids;
|
||||||
public boolean hasPower;
|
public boolean hasPower;
|
||||||
@@ -234,8 +236,8 @@ public abstract class BaseBlock{
|
|||||||
|
|
||||||
if(todump == null){
|
if(todump == null){
|
||||||
|
|
||||||
for(int ii = 0; ii < Item.all().size; ii++){
|
for(int ii = 0; ii < Vars.content.items().size; ii++){
|
||||||
Item item = Item.getByID(ii);
|
Item item = Vars.content.item(ii);
|
||||||
|
|
||||||
if(other.getTeamID() == tile.getTeamID() && entity.items.has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
if(other.getTeamID() == tile.getTeamID() && entity.items.has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
||||||
other.block().handleItem(item, other, in);
|
other.block().handleItem(item, other, in);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.world;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
|
||||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||||
import io.anuke.mindustry.entities.Damage;
|
import io.anuke.mindustry.entities.Damage;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
@@ -13,7 +12,6 @@ import io.anuke.mindustry.entities.bullet.Bullet;
|
|||||||
import io.anuke.mindustry.entities.effect.Puddle;
|
import io.anuke.mindustry.entities.effect.Puddle;
|
||||||
import io.anuke.mindustry.entities.effect.RubbleDecal;
|
import io.anuke.mindustry.entities.effect.RubbleDecal;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.game.MappableContent;
|
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.graphics.CacheLayer;
|
import io.anuke.mindustry.graphics.CacheLayer;
|
||||||
import io.anuke.mindustry.graphics.Layer;
|
import io.anuke.mindustry.graphics.Layer;
|
||||||
@@ -34,15 +32,9 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Block extends BaseBlock implements MappableContent {
|
public class Block extends BaseBlock {
|
||||||
private static int lastid;
|
|
||||||
private static Array<Block> blocks = new Array<>(140);
|
|
||||||
private static ObjectMap<String, Block> map = new ObjectMap<>();
|
|
||||||
|
|
||||||
/** internal name */
|
/** internal name */
|
||||||
public final String name;
|
public final String name;
|
||||||
/** internal ID */
|
|
||||||
public final int id;
|
|
||||||
/** display name */
|
/** display name */
|
||||||
public String formalName;
|
public String formalName;
|
||||||
/** Detailed description of the block. Can be as long as necesary. */
|
/** Detailed description of the block. Can be as long as necesary. */
|
||||||
@@ -127,39 +119,13 @@ public class Block extends BaseBlock implements MappableContent {
|
|||||||
this.formalName = Bundles.get("block." + name + ".name", name);
|
this.formalName = Bundles.get("block." + name + ".name", name);
|
||||||
this.fullDescription = Bundles.getOrNull("block." + name + ".description");
|
this.fullDescription = Bundles.getOrNull("block." + name + ".description");
|
||||||
this.solid = false;
|
this.solid = false;
|
||||||
this.id = lastid++;
|
|
||||||
|
|
||||||
if(map.containsKey(name)){
|
|
||||||
throw new RuntimeException("Two blocks cannot have the same names! Problematic block: " + name);
|
|
||||||
}
|
|
||||||
|
|
||||||
map.put(name, this);
|
|
||||||
blocks.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Array<Block> all(){
|
|
||||||
return blocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block getByName(String name){
|
|
||||||
return map.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block getByID(int id){
|
|
||||||
if(id < 0){ //offset negative values by 256, as they are a product of byte overflow
|
|
||||||
id += 256;
|
|
||||||
}
|
|
||||||
if(id >= blocks.size || id < 0){
|
|
||||||
throw new RuntimeException("No block with ID '" + id + "' found!");
|
|
||||||
}
|
|
||||||
return blocks.get(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Populates the array with all blocks that produce this content.*/
|
/**Populates the array with all blocks that produce this content.*/
|
||||||
public static void getByProduction(Array<Block> arr, Content content){
|
public static void getByProduction(Array<Block> arr, Content result){
|
||||||
arr.clear();
|
arr.clear();
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.<Block>getBy(ContentType.block)){
|
||||||
if(block.produces.get() == content){
|
if(block.produces.get() == result){
|
||||||
arr.add(block);
|
arr.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,8 +178,8 @@ public class Block extends BaseBlock implements MappableContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getID() {
|
public ContentType getContentType(){
|
||||||
return id;
|
return ContentType.block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -350,7 +316,7 @@ public class Block extends BaseBlock implements MappableContent {
|
|||||||
tempColor.set(Palette.darkFlame);
|
tempColor.set(Palette.darkFlame);
|
||||||
|
|
||||||
if(hasItems){
|
if(hasItems){
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
int amount = tile.entity.items.get(item);
|
int amount = tile.entity.items.get(item);
|
||||||
explosiveness += item.explosiveness * amount;
|
explosiveness += item.explosiveness * amount;
|
||||||
flammability += item.flammability * amount;
|
flammability += item.flammability * amount;
|
||||||
@@ -505,19 +471,4 @@ public class Block extends BaseBlock implements MappableContent {
|
|||||||
"entity.items.total", hasItems ? tile.entity.items.total() : null
|
"entity.items.total", hasItems ? tile.entity.items.total() : null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContentType getContentType(){
|
|
||||||
return ContentType.block;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<? extends Content> getAll(){
|
|
||||||
return all();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString(){
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import io.anuke.mindustry.content.blocks.Blocks;
|
|||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
||||||
import io.anuke.ucore.core.Events;
|
import io.anuke.ucore.core.Events;
|
||||||
@@ -34,7 +35,7 @@ public class Build{
|
|||||||
|
|
||||||
Block previous = tile.block();
|
Block previous = tile.block();
|
||||||
|
|
||||||
Block sub = Block.getByName("build" + previous.size);
|
Block sub = content.getByName(ContentType.block, "build" + previous.size);
|
||||||
|
|
||||||
tile.setBlock(sub);
|
tile.setBlock(sub);
|
||||||
tile.<BuildEntity>entity().setDeconstruct(previous);
|
tile.<BuildEntity>entity().setDeconstruct(previous);
|
||||||
@@ -75,7 +76,7 @@ public class Build{
|
|||||||
Block result = recipe.result;
|
Block result = recipe.result;
|
||||||
Block previous = tile.block();
|
Block previous = tile.block();
|
||||||
|
|
||||||
Block sub = Block.getByName("build" + result.size);
|
Block sub = content.getByName(ContentType.block, "build" + result.size);
|
||||||
|
|
||||||
tile.setBlock(sub, rotation);
|
tile.setBlock(sub, rotation);
|
||||||
tile.<BuildEntity>entity().setConstruct(previous, recipe);
|
tile.<BuildEntity>entity().setConstruct(previous, recipe);
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
import com.badlogic.gdx.utils.ObjectIntMap;
|
import com.badlogic.gdx.utils.ObjectIntMap;
|
||||||
import io.anuke.mindustry.game.Content;
|
|
||||||
import io.anuke.mindustry.game.Team;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class ColorMapper implements ContentList{
|
public class ColorMapper implements ContentList{
|
||||||
private static IntMap<Block> blockMap = new IntMap<>();
|
private static IntMap<Block> blockMap = new IntMap<>();
|
||||||
private static ObjectIntMap<Block> colorMap = new ObjectIntMap<>();
|
private static ObjectIntMap<Block> colorMap = new ObjectIntMap<>();
|
||||||
@@ -45,7 +46,7 @@ public class ColorMapper implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.blocks()){
|
||||||
int color = Color.rgba8888(block.minimapColor);
|
int color = Color.rgba8888(block.minimapColor);
|
||||||
if(color == 0) continue; //skip blocks that are not mapped
|
if(color == 0) continue; //skip blocks that are not mapped
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public class ColorMapper implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<? extends Content> getAll(){
|
public ContentType type(){
|
||||||
return new Array<>();
|
return ContentType.mech;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.utils.NumberUtils;
|
|||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.util.Bits;
|
import io.anuke.ucore.util.Bits;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class ItemBuffer{
|
public class ItemBuffer{
|
||||||
private final float speed;
|
private final float speed;
|
||||||
@@ -35,7 +36,7 @@ public class ItemBuffer{
|
|||||||
float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
|
float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
|
||||||
|
|
||||||
if(Timers.time() >= time + speed || Timers.time() < time){
|
if(Timers.time() >= time + speed || Timers.time() < time){
|
||||||
return Item.getByID(Bits.getLeftShort(Bits.getRightInt(l)));
|
return content.item(Bits.getLeftShort(Bits.getRightInt(l)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -54,15 +54,15 @@ public class Tile implements PosTrait, TargetTrait{
|
|||||||
|
|
||||||
public Tile(int x, int y, byte floor, byte wall){
|
public Tile(int x, int y, byte floor, byte wall){
|
||||||
this(x, y);
|
this(x, y);
|
||||||
this.floor = (Floor) Block.getByID(floor);
|
this.floor = (Floor) content.block(floor);
|
||||||
this.wall = Block.getByID(wall);
|
this.wall = content.block(wall);
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile(int x, int y, byte floor, byte wall, byte rotation, byte team, byte elevation){
|
public Tile(int x, int y, byte floor, byte wall, byte rotation, byte team, byte elevation){
|
||||||
this(x, y);
|
this(x, y);
|
||||||
this.floor = (Floor) Block.getByID(floor);
|
this.floor = (Floor) content.block(floor);
|
||||||
this.wall = Block.getByID(wall);
|
this.wall = content.block(wall);
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
this.setElevation(elevation);
|
this.setElevation(elevation);
|
||||||
changed();
|
changed();
|
||||||
|
|||||||
@@ -337,8 +337,8 @@ public class BuildBlock extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pid != -1) previous = Block.getByID(pid);
|
if(pid != -1) previous = content.block(pid);
|
||||||
if(rid != -1) recipe = Recipe.getByResult(Block.getByID(rid));
|
if(rid != -1) recipe = Recipe.getByResult(content.block(rid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import io.anuke.ucore.scene.ui.ImageButton;
|
|||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public interface SelectionTrait{
|
public interface SelectionTrait{
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ public interface SelectionTrait{
|
|||||||
|
|
||||||
default void buildItemTable(Table table, boolean nullItem, Supplier<Item> holder, Consumer<Item> consumer){
|
default void buildItemTable(Table table, boolean nullItem, Supplier<Item> holder, Consumer<Item> consumer){
|
||||||
|
|
||||||
Array<Item> items = Item.all();
|
Array<Item> items = content.items();
|
||||||
|
|
||||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
Table cont = new Table();
|
Table cont = new Table();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import io.anuke.mindustry.graphics.Layer;
|
|||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.type.AmmoEntry;
|
import io.anuke.mindustry.type.AmmoEntry;
|
||||||
import io.anuke.mindustry.type.AmmoType;
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
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;
|
||||||
@@ -34,6 +35,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public abstract class Turret extends Block{
|
public abstract class Turret extends Block{
|
||||||
@@ -358,7 +360,7 @@ public abstract class Turret extends Block{
|
|||||||
public void read(DataInputStream stream) throws IOException{
|
public void read(DataInputStream stream) throws IOException{
|
||||||
byte amount = stream.readByte();
|
byte amount = stream.readByte();
|
||||||
for(int i = 0; i < amount; i++){
|
for(int i = 0; i < amount; i++){
|
||||||
AmmoType type = AmmoType.getByID(stream.readByte());
|
AmmoType type = content.getByID(ContentType.ammo, stream.readByte());
|
||||||
short ta = stream.readShort();
|
short ta = stream.readShort();
|
||||||
ammo.add(new AmmoEntry(type, ta));
|
ammo.add(new AmmoEntry(type, ta));
|
||||||
totalAmmo += ta;
|
totalAmmo += ta;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import java.io.IOException;
|
|||||||
import static io.anuke.mindustry.Vars.itemSize;
|
import static io.anuke.mindustry.Vars.itemSize;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Conveyor extends Block{
|
public class Conveyor extends Block{
|
||||||
private static final float itemSpace = 0.135f * 2.2f;
|
private static final float itemSpace = 0.135f * 2.2f;
|
||||||
private static final float offsetScl = 128f * 3f;
|
private static final float offsetScl = 128f * 3f;
|
||||||
@@ -473,10 +475,10 @@ public class Conveyor extends Block{
|
|||||||
ItemPos set(long lvalue, short[] values){
|
ItemPos set(long lvalue, short[] values){
|
||||||
Bits.getShorts(lvalue, values);
|
Bits.getShorts(lvalue, values);
|
||||||
|
|
||||||
if(values[0] >= Item.all().size || values[0] < 0)
|
if(values[0] >= content.items().size || values[0] < 0)
|
||||||
item = null;
|
item = null;
|
||||||
else
|
else
|
||||||
item = Item.all().get(values[0]);
|
item = content.items().get(values[0]);
|
||||||
|
|
||||||
x = values[1] / (float) Short.MAX_VALUE;
|
x = values[1] / (float) Short.MAX_VALUE;
|
||||||
y = ((float) values[2]) / Short.MAX_VALUE + 1f;
|
y = ((float) values[2]) / Short.MAX_VALUE + 1f;
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.function.Consumer;
|
import io.anuke.ucore.function.Consumer;
|
||||||
import io.anuke.ucore.util.Bits;
|
import io.anuke.ucore.util.Bits;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Junction extends Block{
|
public class Junction extends Block{
|
||||||
protected float speed = 26; //frames taken to go through this junction
|
protected float speed = 26; //frames taken to go through this junction
|
||||||
protected int capacity = 32;
|
protected int capacity = 32;
|
||||||
@@ -44,7 +46,7 @@ public class Junction extends Block{
|
|||||||
|
|
||||||
int val = Bits.getRightInt(l);
|
int val = Bits.getRightInt(l);
|
||||||
|
|
||||||
Item item = Item.getByID(Bits.getLeftShort(val));
|
Item item = content.item(Bits.getLeftShort(val));
|
||||||
int direction = Bits.getRightShort(val);
|
int direction = Bits.getRightShort(val);
|
||||||
Tile dest = tile.getNearby(direction);
|
Tile dest = tile.getNearby(direction);
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ public class Junction extends Block{
|
|||||||
long l = b.items[i];
|
long l = b.items[i];
|
||||||
float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
|
float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
|
||||||
int val = Bits.getRightInt(l);
|
int val = Bits.getRightInt(l);
|
||||||
Item item = Item.getByID(Bits.getLeftShort(val));
|
Item item = content.item(Bits.getLeftShort(val));
|
||||||
int direction = Bits.getRightShort(val);
|
int direction = Bits.getRightShort(val);
|
||||||
Tile dest = tile.getNearby(direction);
|
Tile dest = tile.getNearby(direction);
|
||||||
arr.add(" bufferx.item");
|
arr.add(" bufferx.item");
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ public class MassDriver extends Block{
|
|||||||
DriverBulletData data = Pooling.obtain(DriverBulletData.class);
|
DriverBulletData data = Pooling.obtain(DriverBulletData.class);
|
||||||
data.from = entity;
|
data.from = entity;
|
||||||
data.to = other;
|
data.to = other;
|
||||||
for(int i = 0; i < Item.all().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
data.items[i] = entity.items.get(Item.getByID(i));
|
data.items[i] = entity.items.get(content.item(i));
|
||||||
}
|
}
|
||||||
entity.items.clear();
|
entity.items.clear();
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ public class MassDriver extends Block{
|
|||||||
|
|
||||||
public static class DriverBulletData implements Poolable{
|
public static class DriverBulletData implements Poolable{
|
||||||
public MassDriverEntity from, to;
|
public MassDriverEntity from, to;
|
||||||
public int[] items = new int[Item.all().size];
|
public int[] items = new int[content.items().size];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(){
|
public void reset(){
|
||||||
@@ -274,7 +274,7 @@ public class MassDriver extends Block{
|
|||||||
//add all the items possible
|
//add all the items possible
|
||||||
for(int i = 0; i < data.items.length; i++){
|
for(int i = 0; i < data.items.length; i++){
|
||||||
int maxAdd = Math.min(data.items[i], itemCapacity - totalItems);
|
int maxAdd = Math.min(data.items[i], itemCapacity - totalItems);
|
||||||
items.add(Item.getByID(i), maxAdd);
|
items.add(content.item(i), maxAdd);
|
||||||
data.items[i] -= maxAdd;
|
data.items[i] -= maxAdd;
|
||||||
totalItems += maxAdd;
|
totalItems += maxAdd;
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ public class MassDriver extends Block{
|
|||||||
if(amountDropped > 0){
|
if(amountDropped > 0){
|
||||||
float angle = Mathf.range(180f);
|
float angle = Mathf.range(180f);
|
||||||
float vs = Mathf.random(0f, 4f);
|
float vs = Mathf.random(0f, 4f);
|
||||||
ItemDrop.create(Item.getByID(i), amountDropped, bullet.x, bullet.y, Angles.trnsx(angle, vs), Angles.trnsy(angle, vs));
|
ItemDrop.create(content.item(i), amountDropped, bullet.x, bullet.y, Angles.trnsx(angle, vs), Angles.trnsy(angle, vs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Sorter extends Block implements SelectionTrait{
|
public class Sorter extends Block implements SelectionTrait{
|
||||||
|
|
||||||
@@ -118,7 +119,7 @@ public class Sorter extends Block implements SelectionTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SorterEntity extends TileEntity{
|
public static class SorterEntity extends TileEntity{
|
||||||
public Item sortItem = Item.getByID(0);
|
public Item sortItem = content.item(0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutputStream stream) throws IOException{
|
public void write(DataOutputStream stream) throws IOException{
|
||||||
@@ -127,7 +128,7 @@ public class Sorter extends Block implements SelectionTrait{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInputStream stream) throws IOException{
|
public void read(DataInputStream stream) throws IOException{
|
||||||
sortItem = Item.all().get(stream.readByte());
|
sortItem = content.items().get(stream.readByte());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public abstract class ItemLiquidGenerator extends ItemGenerator{
|
public abstract class ItemLiquidGenerator extends ItemGenerator{
|
||||||
@@ -33,7 +34,7 @@ public abstract class ItemLiquidGenerator extends ItemGenerator{
|
|||||||
ItemGeneratorEntity entity = tile.entity();
|
ItemGeneratorEntity entity = tile.entity();
|
||||||
|
|
||||||
Liquid liquid = null;
|
Liquid liquid = null;
|
||||||
for(Liquid other : Liquid.all()){
|
for(Liquid other : content.liquids()){
|
||||||
if(entity.liquids.get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){
|
if(entity.liquids.get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){
|
||||||
liquid = other;
|
liquid = other;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import io.anuke.ucore.core.Graphics;
|
|||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
public class Drill extends Block{
|
public class Drill extends Block{
|
||||||
protected final static float hardnessDrillMultiplier = 50f;
|
protected final static float hardnessDrillMultiplier = 50f;
|
||||||
protected final int timerDump = timers++;
|
protected final int timerDump = timers++;
|
||||||
@@ -120,7 +120,7 @@ public class Drill extends Block{
|
|||||||
stats.add(BlockStat.drillTier, table -> {
|
stats.add(BlockStat.drillTier, table -> {
|
||||||
Array<Item> list = new Array<>();
|
Array<Item> list = new Array<>();
|
||||||
|
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(tier >= item.hardness && Draw.hasRegion(item.name + "1")){
|
if(tier >= item.hardness && Draw.hasRegion(item.name + "1")){
|
||||||
list.add(item);
|
list.add(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class PowerSmelter extends PowerBlock{
|
public class PowerSmelter extends PowerBlock{
|
||||||
protected final int timerDump = timers++;
|
protected final int timerDump = timers++;
|
||||||
protected final int timerCraft = timers++;
|
protected final int timerCraft = timers++;
|
||||||
@@ -113,7 +115,7 @@ public class PowerSmelter extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
float baseSmeltSpeed = 1f;
|
float baseSmeltSpeed = 1f;
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
|
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
|
||||||
baseSmeltSpeed = fluxSpeedMult;
|
baseSmeltSpeed = fluxSpeedMult;
|
||||||
break;
|
break;
|
||||||
@@ -130,7 +132,7 @@ public class PowerSmelter extends PowerBlock{
|
|||||||
|
|
||||||
if(useFlux){
|
if(useFlux){
|
||||||
//remove flux materials if present
|
//remove flux materials if present
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(item.fluxiness >= minFlux && tile.entity.items.get(item) >= fluxNeeded){
|
if(item.fluxiness >= minFlux && tile.entity.items.get(item) >= fluxNeeded){
|
||||||
tile.entity.items.remove(item, fluxNeeded);
|
tile.entity.items.remove(item, fluxNeeded);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import io.anuke.ucore.graphics.Draw;
|
|||||||
import io.anuke.ucore.graphics.Fill;
|
import io.anuke.ucore.graphics.Fill;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Smelter extends Block{
|
public class Smelter extends Block{
|
||||||
protected final int timerDump = timers++;
|
protected final int timerDump = timers++;
|
||||||
protected final int timerCraft = timers++;
|
protected final int timerCraft = timers++;
|
||||||
@@ -109,7 +111,7 @@ public class Smelter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
float baseSmeltSpeed = 1f;
|
float baseSmeltSpeed = 1f;
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
|
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
|
||||||
baseSmeltSpeed = fluxSpeedMult;
|
baseSmeltSpeed = fluxSpeedMult;
|
||||||
break;
|
break;
|
||||||
@@ -126,7 +128,7 @@ public class Smelter extends Block{
|
|||||||
|
|
||||||
if(useFlux){
|
if(useFlux){
|
||||||
//remove flux materials if present
|
//remove flux materials if present
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
|
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
|
||||||
tile.entity.items.remove(item, 1);
|
tile.entity.items.remove(item, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class SortedUnloader extends Unloader implements SelectionTrait{
|
public class SortedUnloader extends Unloader implements SelectionTrait{
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void read(DataInputStream stream) throws IOException{
|
public void read(DataInputStream stream) throws IOException{
|
||||||
byte id = stream.readByte();
|
byte id = stream.readByte();
|
||||||
sortItem = id == -1 ? null : Item.all().get(id);
|
sortItem = id == -1 ? null : content.items().get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.type.Item;
|
|||||||
import io.anuke.mindustry.world.Edges;
|
import io.anuke.mindustry.world.Edges;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Vault extends StorageBlock{
|
public class Vault extends StorageBlock{
|
||||||
|
|
||||||
@@ -56,8 +57,8 @@ public class Vault extends StorageBlock{
|
|||||||
|
|
||||||
if(!(other.block() instanceof Vault)){
|
if(!(other.block() instanceof Vault)){
|
||||||
|
|
||||||
for(int ii = 0; ii < Item.all().size; ii++){
|
for(int ii = 0; ii < content.items().size; ii++){
|
||||||
Item item = Item.getByID(ii);
|
Item item = content.item(ii);
|
||||||
|
|
||||||
if(entity.items.has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
if(entity.items.has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
||||||
other.block().handleItem(item, other, in);
|
other.block().handleItem(item, other, in);
|
||||||
@@ -67,7 +68,7 @@ public class Vault extends StorageBlock{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
todump = Item.getByID(0);
|
todump = content.item(0);
|
||||||
|
|
||||||
if(other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){
|
if(other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){
|
||||||
other.block().handleItem(removeItem(tile, null), other, in);
|
other.block().handleItem(removeItem(tile, null), other, in);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import io.anuke.mindustry.world.meta.BlockStats;
|
|||||||
import io.anuke.mindustry.world.meta.values.ItemFilterValue;
|
import io.anuke.mindustry.world.meta.values.ItemFilterValue;
|
||||||
import io.anuke.ucore.function.Predicate;
|
import io.anuke.ucore.function.Predicate;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class ConsumeItemFilter extends Consume{
|
public class ConsumeItemFilter extends Consume{
|
||||||
private final Predicate<Item> filter;
|
private final Predicate<Item> filter;
|
||||||
@@ -21,7 +22,7 @@ public class ConsumeItemFilter extends Consume{
|
|||||||
public void buildTooltip(Table table){
|
public void buildTooltip(Table table){
|
||||||
Array<Item> list = new Array<>();
|
Array<Item> list = new Array<>();
|
||||||
|
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(filter.test(item)) list.add(item);
|
if(filter.test(item)) list.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +47,8 @@ public class ConsumeItemFilter extends Consume{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean valid(Block block, TileEntity entity){
|
public boolean valid(Block block, TileEntity entity){
|
||||||
for(int i = 0; i < Item.all().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
Item item = Item.getByID(i);
|
Item item = content.item(i);
|
||||||
if(entity.items != null && entity.items.has(item) && this.filter.test(item)){
|
if(entity.items != null && entity.items.has(item) && this.filter.test(item)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import io.anuke.mindustry.world.meta.values.LiquidFilterValue;
|
|||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.function.Predicate;
|
import io.anuke.ucore.function.Predicate;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class ConsumeLiquidFilter extends Consume{
|
public class ConsumeLiquidFilter extends Consume{
|
||||||
private final Predicate<Liquid> filter;
|
private final Predicate<Liquid> filter;
|
||||||
@@ -31,7 +32,7 @@ public class ConsumeLiquidFilter extends Consume{
|
|||||||
public void buildTooltip(Table table){
|
public void buildTooltip(Table table){
|
||||||
Array<Liquid> list = new Array<>();
|
Array<Liquid> list = new Array<>();
|
||||||
|
|
||||||
for(Liquid item : Liquid.all()){
|
for(Liquid item : content.liquids()){
|
||||||
if(!item.isHidden() && filter.test(item)) list.add(item);
|
if(!item.isHidden() && filter.test(item)) list.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.anuke.mindustry.type.Item;
|
|||||||
import io.anuke.mindustry.world.meta.StatValue;
|
import io.anuke.mindustry.world.meta.StatValue;
|
||||||
import io.anuke.ucore.function.Predicate;
|
import io.anuke.ucore.function.Predicate;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class ItemFilterValue implements StatValue{
|
public class ItemFilterValue implements StatValue{
|
||||||
private final Predicate<Item> filter;
|
private final Predicate<Item> filter;
|
||||||
@@ -17,7 +18,7 @@ public class ItemFilterValue implements StatValue{
|
|||||||
public void display(Table table){
|
public void display(Table table){
|
||||||
Array<Item> list = new Array<>();
|
Array<Item> list = new Array<>();
|
||||||
|
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(filter.test(item)) list.add(item);
|
if(filter.test(item)) list.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.anuke.mindustry.type.Liquid;
|
|||||||
import io.anuke.mindustry.world.meta.StatValue;
|
import io.anuke.mindustry.world.meta.StatValue;
|
||||||
import io.anuke.ucore.function.Predicate;
|
import io.anuke.ucore.function.Predicate;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class LiquidFilterValue implements StatValue{
|
public class LiquidFilterValue implements StatValue{
|
||||||
private final Predicate<Liquid> filter;
|
private final Predicate<Liquid> filter;
|
||||||
@@ -17,7 +18,7 @@ public class LiquidFilterValue implements StatValue{
|
|||||||
public void display(Table table){
|
public void display(Table table){
|
||||||
Array<Liquid> list = new Array<>();
|
Array<Liquid> list = new Array<>();
|
||||||
|
|
||||||
for(Liquid item : Liquid.all()){
|
for(Liquid item : content.liquids()){
|
||||||
if(!item.isHidden() && filter.test(item)) list.add(item);
|
if(!item.isHidden() && filter.test(item)) list.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,16 @@ import java.io.DataInput;
|
|||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class InventoryModule extends BlockModule{
|
public class InventoryModule extends BlockModule{
|
||||||
private int[] items = new int[Item.all().size];
|
private int[] items = new int[content.items().size];
|
||||||
private int total;
|
private int total;
|
||||||
|
|
||||||
public void forEach(ItemConsumer cons){
|
public void forEach(ItemConsumer cons){
|
||||||
for(int i = 0; i < items.length; i++){
|
for(int i = 0; i < items.length; i++){
|
||||||
if(items[i] > 0){
|
if(items[i] > 0){
|
||||||
cons.accept(Item.getByID(i), items[i]);
|
cons.accept(content.item(i), items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +25,7 @@ public class InventoryModule extends BlockModule{
|
|||||||
float sum = 0f;
|
float sum = 0f;
|
||||||
for(int i = 0; i < items.length; i++){
|
for(int i = 0; i < items.length; i++){
|
||||||
if(items[i] > 0){
|
if(items[i] > 0){
|
||||||
sum += calc.get(Item.getByID(i), items[i]);
|
sum += calc.get(content.item(i), items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
@@ -71,7 +72,7 @@ public class InventoryModule extends BlockModule{
|
|||||||
if(items[i] > 0){
|
if(items[i] > 0){
|
||||||
items[i]--;
|
items[i]--;
|
||||||
total--;
|
total--;
|
||||||
return Item.getByID(i);
|
return content.item(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -132,7 +133,7 @@ public class InventoryModule extends BlockModule{
|
|||||||
for(int j = 0; j < count; j++){
|
for(int j = 0; j < count; j++){
|
||||||
int itemid = stream.readByte();
|
int itemid = stream.readByte();
|
||||||
int itemamount = stream.readInt();
|
int itemamount = stream.readInt();
|
||||||
items[itemid] = itemamount;
|
items[content.item(itemid).id] = itemamount;
|
||||||
total += itemamount;
|
total += itemamount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import io.anuke.mindustry.type.Liquid;
|
|||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class LiquidModule extends BlockModule{
|
public class LiquidModule extends BlockModule{
|
||||||
private float[] liquids = new float[Liquid.all().size];
|
private float[] liquids = new float[content.liquids().size];
|
||||||
private float total;
|
private float total;
|
||||||
private Liquid current = Liquid.getByID(0);
|
private Liquid current = content.liquid(0);
|
||||||
|
|
||||||
/**Returns total amount of liquids.*/
|
/**Returns total amount of liquids.*/
|
||||||
public float total(){
|
public float total(){
|
||||||
@@ -51,7 +52,7 @@ public class LiquidModule extends BlockModule{
|
|||||||
public void forEach(LiquidConsumer cons){
|
public void forEach(LiquidConsumer cons){
|
||||||
for(int i = 0; i < liquids.length; i++){
|
for(int i = 0; i < liquids.length; i++){
|
||||||
if(liquids[i] > 0){
|
if(liquids[i] > 0){
|
||||||
cons.accept(Liquid.getByID(i), liquids[i]);
|
cons.accept(content.liquid(i), liquids[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +61,7 @@ public class LiquidModule extends BlockModule{
|
|||||||
float sum = 0f;
|
float sum = 0f;
|
||||||
for(int i = 0; i < liquids.length; i++){
|
for(int i = 0; i < liquids.length; i++){
|
||||||
if(liquids[i] > 0){
|
if(liquids[i] > 0){
|
||||||
sum += calc.get(Liquid.getByID(i), liquids[i]);
|
sum += calc.get(content.liquid(i), liquids[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
@@ -92,7 +93,7 @@ public class LiquidModule extends BlockModule{
|
|||||||
float amount = stream.readFloat();
|
float amount = stream.readFloat();
|
||||||
liquids[liquidid] = amount;
|
liquids[liquidid] = amount;
|
||||||
if(amount > 0){
|
if(amount > 0){
|
||||||
current = Liquid.getByID(liquidid);
|
current = content.liquid(liquidid);
|
||||||
}
|
}
|
||||||
this.total += amount;
|
this.total += amount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class Generators {
|
|||||||
public static void generate(ImageContext context){
|
public static void generate(ImageContext context){
|
||||||
|
|
||||||
context.generate("block-icons", () -> {
|
context.generate("block-icons", () -> {
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.blocks()){
|
||||||
TextureRegion[] regions = block.getBlockIcon();
|
TextureRegion[] regions = block.getBlockIcon();
|
||||||
|
|
||||||
if(regions.length == 0){
|
if(regions.length == 0){
|
||||||
@@ -139,7 +139,7 @@ public class Generators {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context.generate("block-edges", () -> {
|
context.generate("block-edges", () -> {
|
||||||
for(Block block : Block.all()){
|
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 && !Draw.hasRegion(floor.name + "-cliff-side")){
|
||||||
@@ -166,7 +166,7 @@ public class Generators {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context.generate("ore-icons", () -> {
|
context.generate("ore-icons", () -> {
|
||||||
for(Block block : Block.all()){
|
for(Block block : content.blocks()){
|
||||||
if(!(block instanceof OreBlock)) continue;
|
if(!(block instanceof OreBlock)) continue;
|
||||||
|
|
||||||
OreBlock ore = (OreBlock)block;
|
OreBlock ore = (OreBlock)block;
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ public class ServerControl extends Module{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Item item : Item.all()){
|
for(Item item : content.items()){
|
||||||
if(item.type == ItemType.material){
|
if(item.type == ItemType.material){
|
||||||
state.teams.get(Team.blue).cores.first().entity.items.add(item, 2000);
|
state.teams.get(Team.blue).cores.first().entity.items.add(item, 2000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user