Memory optimizations, multithreading fixes, uCore updated

This commit is contained in:
Anuken 2018-06-05 14:03:08 -04:00
parent c5ed0afb4e
commit 917e2e40fb
87 changed files with 1018 additions and 752 deletions

View File

@ -27,7 +27,7 @@ allprojects {
gdxVersion = '1.9.8'
roboVMVersion = '2.3.0'
aiVersion = '1.8.1'
uCoreVersion = '8a2faf0'
uCoreVersion = '32c8405'
getVersionString = {
String buildVersion = getBuildVersion()

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

View File

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

@ -2,6 +2,7 @@ package io.anuke.mindustry;
import io.anuke.mindustry.core.*;
import io.anuke.mindustry.io.BundleLoader;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.modules.ModuleCore;
import io.anuke.ucore.util.Log;
@ -15,10 +16,14 @@ public class Mindustry extends ModuleCore {
debug = Platform.instance.isDebug();
Timers.mark();
Log.setUseColors(false);
BundleLoader.load();
ContentLoader.load();
Log.info("Time to load content: {0}", Timers.elapsed());
module(logic = new Logic());
module(world = new World());
module(control = new Control());

View File

@ -25,7 +25,7 @@ import io.anuke.ucore.util.OS;
import java.util.Locale;
public class Vars{
public static final boolean testMobile = true;
public static final boolean testMobile = false;
//shorthand for whether or not this is running on android or ios
public static boolean mobile;
public static boolean ios;

View File

@ -1,7 +1,9 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.bullets.*;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.ContentList;
@ -160,4 +162,9 @@ public class AmmoTypes implements ContentList {
cryofluid = new AmmoType(Liquids.cryofluid, TurretBullets.cryoShot, 0.3f);
}
@Override
public Array<? extends Content> getAll() {
return AmmoType.all();
}
}

View File

@ -1,6 +1,8 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemType;
@ -80,4 +82,9 @@ public class Items implements ContentList{
explosiveness = 0.2f;
}};
}
@Override
public Array<? extends Content> getAll() {
return Item.all();
}
}

View File

@ -1,6 +1,8 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.Liquid;
@ -43,6 +45,10 @@ public class Liquids implements ContentList {
effect = StatusEffects.freezing;
}
};
}
@Override
public Array<? extends Content> getAll() {
return Liquid.all();
}
}

View File

@ -1,7 +1,10 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.type.Upgrade;
public class Mechs implements ContentList {
public static Mech standard, standardShip;
@ -17,4 +20,9 @@ public class Mechs implements ContentList {
drillPower = 1;
}};
}
@Override
public Array<? extends Content> getAll() {
return Upgrade.all();
}
}

View File

@ -1,6 +1,8 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.blocks.*;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Recipe;
@ -127,4 +129,9 @@ public class Recipes implements ContentList{
new Recipe(units, DebugBlocks.powerVoid, new ItemStack(Items.steel, 10)).setDebug();
new Recipe(units, DebugBlocks.powerInfinite, new ItemStack(Items.steel, 10), new ItemStack(Items.surgealloy, 5)).setDebug();
}
@Override
public Array<? extends Content> getAll() {
return Recipe.all();
}
}

View File

@ -1,7 +1,9 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.fx.EnvironmentFx;
import io.anuke.mindustry.entities.StatusController.TransitionResult;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.StatusEffect;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.type.ContentList;
@ -124,4 +126,9 @@ public class StatusEffects implements ContentList {
freezing.setOpposites(burning, melting);
burning.setOpposites(wet, freezing);
}
@Override
public Array<? extends Content> getAll() {
return StatusEffect.all();
}
}

View File

@ -1,10 +1,13 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.entities.units.types.Drone;
import io.anuke.mindustry.entities.units.types.Scout;
import io.anuke.mindustry.entities.units.types.Vtol;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.StatusEffect;
public class UnitTypes implements ContentList {
public static UnitType drone, scout, vtol;
@ -36,4 +39,9 @@ public class UnitTypes implements ContentList {
setAmmo(AmmoTypes.bulletIron);
}};
}
@Override
public Array<? extends Content> getAll() {
return StatusEffect.all();
}
}

View File

@ -1,7 +1,10 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.type.Weapon;
public class Weapons implements ContentList {
@ -18,4 +21,9 @@ public class Weapons implements ContentList {
setAmmo(AmmoTypes.bulletIron);
}};
}
@Override
public Array<? extends Content> getAll() {
return Upgrade.all();
}
}

View File

@ -0,0 +1,14 @@
package io.anuke.mindustry.content.blocks;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.world.Block;
public abstract class BlockList implements ContentList {
@Override
public Array<? extends Content> getAll() {
return Block.all();
}
}

View File

@ -11,7 +11,7 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.*;
public class Blocks implements ContentList{
public class Blocks extends BlockList implements ContentList{
public static Block air, spawn, blockpart, build1, build2, build3, build4, build5, build6, defaultFloor, space, metalfloor, deepwater, water, lava, oil, stone, blackstone, iron, lead, coal, titanium, thorium, dirt, sand, ice, snow, grass, sandblock, snowblock, stoneblock, blackstoneblock, grassblock, mossblock, shrub, rock, icerock, blackrock, dirtblock;
@Override

View File

@ -10,7 +10,7 @@ import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.types.production.*;
public class CraftingBlocks implements ContentList {
public class CraftingBlocks extends BlockList implements ContentList {
public static Block smelter, alloysmelter, siliconsmelter, poweralloysmelter, powersmelter, cryofluidmixer, melter, separator, centrifuge, plasticFormer, biomatterCompressor, pulverizer, oilRefinery, stoneFormer, weaponFactory, incinerator;
@Override

View File

@ -20,7 +20,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class DebugBlocks implements ContentList{
public class DebugBlocks extends BlockList implements ContentList{
public static Block powerVoid, powerInfinite, itemSource, liquidSource, itemVoid;
@Override

View File

@ -7,7 +7,7 @@ import io.anuke.mindustry.world.blocks.types.Wall;
import io.anuke.mindustry.world.blocks.types.defense.Door;
import io.anuke.mindustry.world.blocks.types.defense.ShieldedWallBlock;
public class DefenseBlocks implements ContentList {
public class DefenseBlocks extends BlockList implements ContentList {
public static Block stonewall, ironwall, steelwall, titaniumwall, diriumwall, compositewall, steelwalllarge, titaniumwalllarge, diriumwalllarge, titaniumshieldwall, door, largedoor;
@Override

View File

@ -4,7 +4,7 @@ import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.types.distribution.*;
public class DistributionBlocks implements ContentList{
public class DistributionBlocks extends BlockList implements ContentList{
public static Block conveyor, steelconveyor, pulseconveyor, router, multiplexer, junction, bridgeconveyor, laserconveyor, sorter, splitter, overflowgate;
@Override

View File

@ -5,7 +5,7 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.types.distribution.*;
import io.anuke.mindustry.world.blocks.types.production.Pump;
public class LiquidBlocks implements ContentList{
public class LiquidBlocks extends BlockList implements ContentList{
public static Block pump, fluxpump, conduit, pulseconduit, liquidrouter, liquidtank, liquidjunction, bridgeconduit, laserconduit;
@Override

View File

@ -8,7 +8,7 @@ import io.anuke.mindustry.world.blocks.types.defense.ShieldBlock;
import io.anuke.mindustry.world.blocks.types.distribution.Teleporter;
import io.anuke.mindustry.world.blocks.types.power.*;
public class PowerBlocks implements ContentList {
public class PowerBlocks extends BlockList implements ContentList {
public static Block combustiongenerator, thermalgenerator, liquidcombustiongenerator, rtgenerator, solarpanel, largesolarpanel, nuclearReactor, fusionReactor, repairturret, megarepairturret, shieldgenerator, battery, batteryLarge, powernode, powernodelarge, teleporter;
@Override
@ -95,7 +95,7 @@ public class PowerBlocks implements ContentList {
powerSpeed = 1f;
maxNodes = 5;
laserRange = 7.5f;
shadow = "powernodelarge-shadow";
shadow = "shadow-round-2";
}};
teleporter = new Teleporter("teleporter");

View File

@ -11,7 +11,7 @@ import io.anuke.mindustry.world.blocks.types.production.Drill;
import io.anuke.mindustry.world.blocks.types.production.Fracker;
import io.anuke.mindustry.world.blocks.types.production.SolidPump;
public class ProductionBlocks implements ContentList {
public class ProductionBlocks extends BlockList implements ContentList {
public static Block ironDrill, reinforcedDrill, steelDrill, titaniumDrill, laserdrill, nucleardrill, plasmadrill, waterextractor, oilextractor, cultivator;
@Override

View File

@ -7,7 +7,7 @@ import io.anuke.mindustry.world.blocks.types.storage.SortedUnloader;
import io.anuke.mindustry.world.blocks.types.storage.Unloader;
import io.anuke.mindustry.world.blocks.types.storage.Vault;
public class StorageBlocks implements ContentList {
public class StorageBlocks extends BlockList implements ContentList {
public static Block core, vault, unloader, sortedunloader;
@Override

View File

@ -10,7 +10,7 @@ import io.anuke.mindustry.world.blocks.types.units.RepairPoint;
import io.anuke.mindustry.world.blocks.types.units.ResupplyPoint;
import io.anuke.mindustry.world.blocks.types.units.UnitFactory;
public class UnitBlocks implements ContentList {
public class UnitBlocks extends BlockList implements ContentList {
public static Block resupplyPoint, repairPoint, droneFactory, dropPoint;
@Override

View File

@ -12,7 +12,7 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
public class WeaponBlocks implements ContentList {
public class WeaponBlocks extends BlockList implements ContentList {
public static Block duo, scatter, scorch, hail, wave, crux, lancer, arc, swarmer, ripple, cyclone, fuse, spectre, eraser, meltdown;
@Override

View File

@ -5,80 +5,74 @@ import io.anuke.mindustry.entities.bullet.BasicBulletType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.ContentList;
public class ArtilleryBullets implements ContentList{
public class ArtilleryBullets extends BulletList implements ContentList{
public static BulletType lead, thorium, plastic, homing, incindiary, surge;
@Override
public void load() {
lead = new BasicBulletType(3f, 0) {
lead = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 90f;
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
thorium = new BasicBulletType(3f, 0) {
thorium = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 90f;
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
plastic = new BasicBulletType(3f, 0) {
plastic = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 90f;
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
homing = new BasicBulletType(3f, 0) {
homing = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 90f;
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
incindiary = new BasicBulletType(3f, 0) {
incindiary = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 90f;
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
surge = new BasicBulletType(3f, 0) {
surge = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 90f;
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};

View File

@ -0,0 +1,14 @@
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.type.ContentList;
public abstract class BulletList implements ContentList {
@Override
public Array<? extends Content> getAll() {
return BulletType.all();
}
}

View File

@ -4,34 +4,34 @@ import io.anuke.mindustry.entities.bullet.BasicBulletType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.ContentList;
public class FlakBullets implements ContentList {
public class FlakBullets extends BulletList implements ContentList {
public static BulletType lead, plastic, explosive, surge;
@Override
public void load() {
lead = new BasicBulletType(3f, 5) {
lead = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
plastic = new BasicBulletType(3f, 5) {
plastic = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
explosive = new BasicBulletType(3f, 5) {
explosive = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
surge = new BasicBulletType(3f, 5) {
surge = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;

View File

@ -4,27 +4,27 @@ import io.anuke.mindustry.entities.bullet.BasicBulletType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.ContentList;
public class MissileBullets implements ContentList {
public class MissileBullets extends BulletList implements ContentList {
public static BulletType explosive, incindiary, surge;
@Override
public void load() {
explosive = new BasicBulletType(3f, 5) {
explosive = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
incindiary = new BasicBulletType(3f, 5) {
incindiary = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
surge = new BasicBulletType(3f, 5) {
surge = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;

View File

@ -6,13 +6,13 @@ import io.anuke.mindustry.entities.bullet.BasicBulletType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.ContentList;
public class ShellBullets implements ContentList {
public class ShellBullets extends BulletList implements ContentList {
public static BulletType lead, leadShard, thorium, thoriumShard, plastic, plasticShard, explosive, explosiveShard, incindiary;
@Override
public void load() {
lead = new BasicBulletType(3f, 0) {
lead = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
@ -20,12 +20,11 @@ public class ShellBullets implements ContentList {
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
fragBullet = leadShard;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
leadShard = new BasicBulletType(3f, 0) {
leadShard = new BasicBulletType(3f, 0, "shell") {
{
drag = 0.1f;
hiteffect = Fx.none;
@ -38,7 +37,7 @@ public class ShellBullets implements ContentList {
}
};
thorium = new BasicBulletType(3f, 0) {
thorium = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
@ -46,12 +45,11 @@ public class ShellBullets implements ContentList {
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
fragBullet = leadShard;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
thoriumShard = new BasicBulletType(3f, 0) {
thoriumShard = new BasicBulletType(3f, 0, "shell") {
{
drag = 0.1f;
hiteffect = Fx.none;
@ -64,7 +62,7 @@ public class ShellBullets implements ContentList {
}
};
plastic = new BasicBulletType(3f, 0) {
plastic = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
@ -72,12 +70,11 @@ public class ShellBullets implements ContentList {
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
fragBullet = leadShard;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
plasticShard = new BasicBulletType(3f, 0) {
plasticShard = new BasicBulletType(3f, 0, "shell") {
{
drag = 0.1f;
hiteffect = Fx.none;
@ -90,7 +87,7 @@ public class ShellBullets implements ContentList {
}
};
explosive = new BasicBulletType(3f, 0) {
explosive = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
@ -98,12 +95,11 @@ public class ShellBullets implements ContentList {
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
fragBullet = leadShard;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};
explosiveShard = new BasicBulletType(3f, 0) {
explosiveShard = new BasicBulletType(3f, 0, "shell") {
{
drag = 0.1f;
hiteffect = Fx.none;
@ -116,7 +112,7 @@ public class ShellBullets implements ContentList {
}
};
incindiary = new BasicBulletType(3f, 0) {
incindiary = new BasicBulletType(3f, 0, "shell") {
{
hiteffect = BulletFx.flakExplosion;
knockback = 0.8f;
@ -124,7 +120,6 @@ public class ShellBullets implements ContentList {
drag = 0.01f;
bulletWidth = bulletHeight = 9f;
fragBullet = leadShard;
bulletSprite = "frag";
bulletShrink = 0.1f;
}
};

View File

@ -4,48 +4,48 @@ import io.anuke.mindustry.entities.bullet.BasicBulletType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.ContentList;
public class StandardBullets implements ContentList {
public class StandardBullets extends BulletList implements ContentList {
public static BulletType iron, lead, steel, thorium, homing, tracer;
@Override
public void load() {
iron = new BasicBulletType(3f, 5) {
iron = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
lead = new BasicBulletType(3f, 5) {
lead = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
steel = new BasicBulletType(3f, 5) {
steel = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
thorium = new BasicBulletType(3f, 5) {
thorium = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
homing = new BasicBulletType(3f, 5) {
homing = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
tracer = new BasicBulletType(3f, 5) {
tracer = new BasicBulletType(3f, 5, "bullet") {
{
bulletWidth = 7f;
bulletHeight = 9f;

View File

@ -24,7 +24,7 @@ import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.world;
public class TurretBullets implements ContentList {
public class TurretBullets extends BulletList implements ContentList {
public static BulletType fireball, basicFlame, lancerLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning;
@Override

View File

@ -15,7 +15,7 @@ import io.anuke.ucore.util.Tmp;
import static io.anuke.mindustry.Vars.tilesize;
public class BlockFx implements ContentList{
public class BlockFx extends FxList implements ContentList{
public static Effect reactorsmoke, nuclearsmoke, nuclearcloud, redgeneratespark, generatespark, fuelburn, plasticburn, pulverize, pulverizeRed, pulverizeRedder, pulverizeSmall, pulverizeMedium, producesmoke, smeltsmoke, formsmoke, blastsmoke, lava, dooropen, doorclose, dooropenlarge, doorcloselarge, purify, purifyoil, purifystone, generate, mine, mineBig, mineHuge, smelt, teleportActivate, teleport, teleportOut, ripple, bubble;
@Override
@ -48,7 +48,7 @@ public class BlockFx implements ContentList{
redgeneratespark = new Effect(18, e -> {
Angles.randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> {
float len = e.fout() * 4f;
Draw.color(Color.valueOf("fbb97f"), Color.GRAY, e.fin());
Draw.color(Palette.redSpark, Color.GRAY, e.fin());
//Draw.alpha(e.fout());
Draw.rect("circle", e.x + x, e.y + y, len, len);
Draw.reset();
@ -57,7 +57,7 @@ public class BlockFx implements ContentList{
generatespark = new Effect(18, e -> {
Angles.randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> {
float len = e.fout() * 4f;
Draw.color(Color.valueOf("d2b29c"), Color.GRAY, e.fin());
Draw.color(Palette.orangeSpark, Color.GRAY, e.fin());
Draw.rect("circle", e.x + x, e.y + y, len, len);
Draw.reset();
});
@ -86,14 +86,14 @@ public class BlockFx implements ContentList{
});
pulverizeRed = new Effect(40, e -> {
Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> {
Draw.color(Color.valueOf("ffa480"), Palette.stoneGray, e.fin());
Draw.color(Palette.redDust, Palette.stoneGray, e.fin());
Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45);
Draw.reset();
});
});
pulverizeRedder = new Effect(40, e -> {
Angles.randLenVectors(e.id, 5, 3f + e.fin() * 9f, (x, y) -> {
Draw.color(Color.valueOf("ff7b69"), Palette.stoneGray, e.fin());
Draw.color(Palette.redderDust, Palette.stoneGray, e.fin());
Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2.5f + 0.5f, 45);
Draw.reset();
});
@ -128,7 +128,7 @@ public class BlockFx implements ContentList{
});
formsmoke = new Effect(40, e -> {
Angles.randLenVectors(e.id, 6, 5f + e.fin() * 8f, (x, y) -> {
Draw.color(Color.valueOf("f1e479"), Color.LIGHT_GRAY, e.fin());
Draw.color(Palette.plasticSmoke, Color.LIGHT_GRAY, e.fin());
Fill.poly(e.x + x, e.y + y, 4, 0.2f + e.fout() * 2f, 45);
Draw.reset();
});

View File

@ -10,7 +10,7 @@ import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class BulletFx implements ContentList {
public class BulletFx extends FxList implements ContentList {
public static Effect hitBulletSmall, hitBulletBig, hitFlameSmall, hitLiquid, hitLancer, despawn, flakExplosion;
@Override

View File

@ -10,7 +10,7 @@ import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class EnvironmentFx implements ContentList {
public class EnvironmentFx extends FxList implements ContentList {
public static Effect burning, fire, smoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily;
@Override

View File

@ -10,7 +10,7 @@ import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class ExplosionFx implements ContentList {
public class ExplosionFx extends FxList implements ContentList {
public static Effect shockwave, bigShockwave, nuclearShockwave, explosion, blockExplosion, blockExplosionSmoke;
@Override

View File

@ -11,7 +11,7 @@ import io.anuke.ucore.util.Angles;
import static io.anuke.mindustry.Vars.tilesize;
public class Fx implements ContentList {
public class Fx extends FxList implements ContentList {
public static Effect none, placeBlock, breakBlock, smoke, spawn, tapBlock, select;
@Override
@ -53,7 +53,7 @@ public class Fx implements ContentList {
});
smoke = new Effect(100, e -> {
Draw.color(Color.GRAY, new Color(0.3f, 0.3f, 0.3f, 1f), e.fin());
Draw.color(Color.GRAY, Palette.darkishGray, e.fin());
float size = 7f - e.fin() * 7f;
Draw.rect("circle", e.x, e.y, size, size);
Draw.reset();

View File

@ -0,0 +1,13 @@
package io.anuke.mindustry.content.fx;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
public abstract class FxList implements ContentList{
@Override
public Array<? extends Content> getAll() {
return Array.with();
}
}

View File

@ -12,7 +12,7 @@ import io.anuke.ucore.graphics.Shapes;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class ShootFx implements ContentList {
public class ShootFx extends FxList implements ContentList {
public static Effect shootSmall, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke, shootBigSmoke2, shootSmallFlame, shootLiquid, shellEjectSmall, shellEjectMedium, shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot;
@Override

View File

@ -10,7 +10,7 @@ import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class UnitFx implements ContentList {
public class UnitFx extends FxList implements ContentList {
public static Effect vtolHover, unitDrop, unitPickup;
@Override

View File

@ -1,22 +1,28 @@
package io.anuke.mindustry.core;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectSet;
import com.badlogic.gdx.utils.OrderedSet;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.content.blocks.*;
import io.anuke.mindustry.content.bullets.*;
import io.anuke.mindustry.content.fx.*;
import io.anuke.mindustry.type.StatusEffect;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.type.StatusEffect;
import io.anuke.mindustry.world.Block;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.util.Log;
/**Loads all game content.
* Call load() before doing anything with content.*/
public class ContentLoader {
private static boolean loaded = false;
private static ObjectSet<Array<? extends Content>> contentSet = new OrderedSet<>();
private static ContentList[] content = {
//effects
new BlockFx(),
@ -73,7 +79,7 @@ public class ContentLoader {
new Recipes(),
};
/**Creates all content types.*/
public static void load(){
if(loaded){
Log.info("Content already loaded, skipping.");
@ -84,20 +90,30 @@ public class ContentLoader {
list.load();
}
for(Block block : Block.getAllBlocks()){
block.init();
for (ContentList list : content){
contentSet.add(list.getAll());
}
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}",
Block.getAllBlocks().size, io.anuke.mindustry.type.Item.all().size, Liquid.all().size,
io.anuke.mindustry.type.Mech.all().size, UnitType.getAllTypes().size, io.anuke.mindustry.type.AmmoType.all().size, BulletType.all().size, StatusEffect.getAllEffects().size, io.anuke.mindustry.type.Recipe.all().size, Effects.all().size, content.length);
Block.all().size, io.anuke.mindustry.type.Item.all().size, Liquid.all().size,
io.anuke.mindustry.type.Mech.all().size, UnitType.getAllTypes().size, io.anuke.mindustry.type.AmmoType.all().size, BulletType.all().size, StatusEffect.all().size, io.anuke.mindustry.type.Recipe.all().size, Effects.all().size, content.length);
Log.info("-------------------");
loaded = true;
}
/**Initializes all content with the specified function.*/
public static void initialize(Consumer<Content> callable){
for(Array<? extends Content> arr : contentSet){
for(Content content : arr){
callable.accept(content);
}
}
}
public static void dispose(){
//TODO clear all content.
}

View File

@ -10,6 +10,7 @@ import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.ContentDatabase;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.input.AndroidInput;
@ -19,7 +20,6 @@ import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.io.Map;
import io.anuke.mindustry.io.Saves;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Recipe;
import io.anuke.ucore.core.*;
import io.anuke.ucore.entities.Entities;
@ -59,11 +59,11 @@ public class Control extends Module{
Effects.setShakeFalloff(10000f);
ContentLoader.initialize(Content::init);
Core.atlas = new Atlas("sprites.atlas");
for(Item item : Item.all()){
item.load();
}
ContentLoader.initialize(Content::load);
db.load();
@ -91,7 +91,7 @@ public class Control extends Module{
}
};
Gdx.input = proxy;
//Gdx.input = proxy;
Sounds.load("shoot.mp3", "place.mp3", "explosion.mp3", "enemyshoot.mp3",
"corexplode.mp3", "break.mp3", "spawn.mp3", "flame.mp3", "die.mp3",
@ -255,7 +255,7 @@ public class Control extends Module{
}
public void triggerUpdateInput(){
Gdx.input = proxy;
//Gdx.input = proxy;
}
public void playMap(Map map){

View File

@ -82,7 +82,7 @@ public class Logic extends Module {
public void runWave(){
//TODO spawn enemies
for(int i = 0; i < 10; i ++){
for(int i = 0; i < 100; i ++){
BaseUnit unit = UnitTypes.vtol.create(Team.red);
Vector2 offset = new Vector2().setToRandomDirection().scl(world.width()/2f*tilesize).add(world.width()/2f*tilesize, world.height()/2f*tilesize);
unit.inventory.addAmmo(AmmoTypes.bulletIron);

View File

@ -14,13 +14,12 @@ import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.traits.BelowLiquidTrait;
import io.anuke.mindustry.entities.effect.GroundEffectEntity;
import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect;
import io.anuke.mindustry.entities.traits.BelowLiquidTrait;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.BlockFlag;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Core;
@ -29,8 +28,8 @@ import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.entities.EntityDraw;
import io.anuke.ucore.entities.EntityGroup;
import io.anuke.ucore.entities.impl.EffectEntity;
import io.anuke.ucore.entities.impl.BaseEntity;
import io.anuke.ucore.entities.impl.EffectEntity;
import io.anuke.ucore.function.Callable;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Hue;
@ -113,10 +112,6 @@ public class Renderer extends RendererModule{
clearColor.a = 1f;
background.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
for(Block block : Block.getAllBlocks()){
block.load();
}
}
@Override

View File

@ -190,7 +190,7 @@ public class UI extends SceneModule{
}
@Override
public synchronized boolean hasMouse() {
public boolean hasMouse() {
return super.hasMouse();
}

View File

@ -18,6 +18,7 @@ import io.anuke.ucore.core.Events;
import io.anuke.ucore.entities.EntityPhysics;
import io.anuke.ucore.modules.Module;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.ThreadArray;
import io.anuke.ucore.util.Tmp;
import static io.anuke.mindustry.Vars.threads;
@ -32,7 +33,7 @@ public class World extends Module{
private BlockIndexer indexer = new BlockIndexer();
private Maps maps = new Maps();
private Array<Tile> tempTiles = new Array<>();
private Array<Tile> tempTiles = new ThreadArray<>();
private boolean generating;
public World(){

View File

@ -1,5 +1,6 @@
package io.anuke.mindustry.editor;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
@ -33,13 +34,17 @@ import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.scene.utils.UIUtils;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Log;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import static io.anuke.mindustry.Vars.*;
@ -377,7 +382,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
}
public void build(){
float size = 60;
float size = mobile ? (int)(Gdx.graphics.getHeight() / 9.5f / Unit.dp.scl(1f)) : 60;
new table(){{
aleft();
@ -537,7 +542,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
int i = 0;
for(Block block : Block.getAllBlocks()){
for(Block block : Block.all()){
TextureRegion[] regions = block.getCompactIcon();
if(regions.length == 0) continue;

View File

@ -50,7 +50,7 @@ public class MapRenderer implements Disposable{
PixmapPacker packer = new PixmapPacker(512, 512, Format.RGBA8888, 2, true);
Pixmap pixmap = Core.atlas.getPixmapOf("blank");
for(Block block : Block.getAllBlocks()){
for(Block block : Block.all()){
TextureRegion[] regions = block.getBlockIcon();
if(regions.length > 0){
Pixmap result = new Pixmap(regions[0].getRegionWidth(), regions[0].getRegionHeight(), Format.RGBA8888);

View File

@ -28,10 +28,7 @@ import io.anuke.ucore.entities.trait.SolidTrait;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Timer;
import io.anuke.ucore.util.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -69,7 +66,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
private boolean respawning;
private float walktime;
private Queue<BuildRequest> placeQueue = new Queue<>();
private Queue<BuildRequest> placeQueue = new ThreadQueue<>();
private Tile mining;
private CarriableTrait carrying;
private Trail trail = new Trail(16);
@ -239,13 +236,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
}
for (int i : Mathf.signs) {
Draw.rect(mname + "-leg",
Draw.rect(mech.legRegion,
x + Angles.trnsx(baseRotation, ft * i),
y + Angles.trnsy(baseRotation, ft * i),
12f * i, 12f - Mathf.clamp(ft * i, 0, 2), baseRotation - 90);
}
Draw.rect(mname + "-base", x, y,baseRotation- 90);
Draw.rect(mech.baseRegion, x, y, baseRotation- 90);
}
if(floor.liquid) {
@ -254,13 +251,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
Draw.tint(Color.WHITE);
}
Draw.rect(mname, x, y, rotation -90);
Draw.rect(mech.region, x, y, rotation -90);
for (int i : Mathf.signs) {
float tra = rotation - 90,
trX = 4*i, trY = 3 - weapon.getRecoil(this, i > 0)*1.5f;
float w = i > 0 ? -8 : 8;
Draw.rect(weapon.name + "-equip",
Draw.rect(weapon.equipRegion,
x + Angles.trnsx(tra, trX, trY),
y + Angles.trnsy(tra, trX, trY), w, 8, rotation - 90);
}
@ -413,11 +410,15 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
if(ui.chatfrag.chatOpen()) return;
float speed = Inputs.keyDown("dash") ? (debug ? Player.dashSpeed * 5f : Player.dashSpeed) : Player.walkSpeed;
float carrySlowdown = 0.3f;
speed *= ((1f-carrySlowdown) + (inventory.hasItem() ? (float)inventory.getItem().amount/inventory.capacity(): 1f) * carrySlowdown);
//drop from carrier on key press
if(Inputs.keyTap("drop_unit") && getCarrier() != null){
getCarrier().dropCarry();
}
movement.set(0, 0);
String section = "player_" + (playerIndex + 1);
@ -549,6 +550,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
placeQueue.clear();
dead = true;
respawning = false;
trail.clear();
add();
heal();

View File

@ -1,6 +1,7 @@
package io.anuke.mindustry.entities.bullet;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Angles;
@ -9,16 +10,26 @@ import io.anuke.ucore.util.Mathf;
/**A BulletType for most ammo-based bullets shot from turrets and units.*/
public class BasicBulletType extends BulletType {
public Color backColor = Palette.bulletYellowBack, frontColor = Palette.bulletYellow;
public String bulletSprite = "bullet";
public float bulletWidth = 5f, bulletHeight = 7f;
public float bulletShrink = 0.5f;
public String bulletSprite;
public int fragBullets = 9;
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
public BulletType fragBullet = null;
public BasicBulletType(float speed, float damage) {
public TextureRegion backRegion;
public TextureRegion frontRegion;
public BasicBulletType(float speed, float damage, String bulletSprite) {
super(speed, damage);
this.bulletSprite = bulletSprite;
}
@Override
public void load() {
backRegion = Draw.region(bulletSprite + "-back");
frontRegion = Draw.region(bulletSprite);
}
@Override
@ -26,9 +37,9 @@ public class BasicBulletType extends BulletType {
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
Draw.color(backColor);
Draw.rect(bulletSprite + "-back", b.x, b.y, bulletWidth, height, b.angle() - 90);
Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
Draw.color(frontColor);
Draw.rect(bulletSprite, b.x, b.y, bulletWidth, height, b.angle() - 90);
Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
Draw.color();
}

View File

@ -3,11 +3,12 @@ package io.anuke.mindustry.entities.bullet;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.StatusEffects;
import io.anuke.mindustry.content.fx.BulletFx;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.StatusEffect;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.entities.impl.BaseBulletType;
public abstract class BulletType extends BaseBulletType<Bullet>{
public abstract class BulletType extends BaseBulletType<Bullet> implements Content{
private static int lastid = 0;
private static Array<BulletType> types = new Array<>();
@ -46,6 +47,16 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Effects.effect(despawneffect, b.x, b.y, b.angle());
}
@Override
public String getContentTypeName() {
return "bullettype";
}
@Override
public Array<? extends Content> getAll() {
return types;
}
public static BulletType getByID(int id){
return types.get(id);
}

View File

@ -25,7 +25,7 @@ public class Rubble extends TimedEntity implements BelowLiquidTrait, DrawTrait {
@Override
public float lifetime() {
return 7000f;
return 8200f;
}
@Override

View File

@ -113,7 +113,7 @@ public interface BuilderTrait {
}else if(current.remove){
if(Build.validBreak(unit.getTeam(), current.x, current.y) && current.recipe == Recipe.getByResult(tile.block())){ //if it's valid, break it
float progress = 1f / tile.getBreakTime();
float progress = 1f / tile.getBreakTime() * Timers.delta() * getBuildPower(tile);
TileEntity core = unit.getClosestCore();
//update accumulation of resources to add
@ -164,7 +164,7 @@ public interface BuilderTrait {
//otherwise, update it.
BuildEntity entity = tile.entity();
entity.addProgress(core.items, 1f / entity.recipe.cost);
entity.addProgress(core.items, 1f / entity.recipe.cost * Timers.delta() * getBuildPower(tile));
unit.rotation = Mathf.slerpDelta(unit.rotation, unit.angleTo(entity), 0.4f);
getCurrentRequest().progress = entity.progress();
}

View File

@ -76,7 +76,6 @@ public class FlyingUnit extends BaseUnit implements CarryTrait{
}
}
@Override
public UnitState getStartState(){
return attack;

View File

@ -10,7 +10,6 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.Floor;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.util.*;
import static io.anuke.mindustry.Vars.world;
@ -67,7 +66,7 @@ public abstract class GroundUnit extends BaseUnit {
Floor floor = getFloorOn();
if(floor.liquid){
Draw.tint(Hue.mix(Color.WHITE, floor.liquidColor, 0.5f));
Draw.tint(Color.WHITE, floor.liquidColor, 0.5f);
}
for (int i : Mathf.signs) {

View File

@ -3,9 +3,9 @@ package io.anuke.mindustry.entities.units.types;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Queue;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.entities.traits.BuilderTrait;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.traits.BuilderTrait;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.FlyingUnit;
import io.anuke.mindustry.entities.units.UnitState;
@ -25,6 +25,7 @@ import io.anuke.ucore.graphics.Shapes;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.ThreadQueue;
import static io.anuke.mindustry.Vars.unitGroups;
import static io.anuke.mindustry.Vars.world;
@ -35,7 +36,7 @@ public class Drone extends FlyingUnit implements BuilderTrait {
protected static boolean initialized;
protected Tile mineTile;
protected Queue<BuildRequest> placeQueue = new Queue<>();
protected Queue<BuildRequest> placeQueue = new ThreadQueue<>();
/**Initialize placement event notifier system.
* Static initialization is to be avoided, thus, this is done lazily.*/

View File

@ -1,43 +1,31 @@
package io.anuke.mindustry.entities.units.types;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.entities.units.FlyingUnit;
import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class Vtol extends FlyingUnit {
static TextureRegion
booster1 = Draw.region("vtol-booster-1"),
booster2 = Draw.region("vtol-booster-2"),
region = Draw.region("vtol");
public Vtol(UnitType type, Team team) {
super(type, team);
}
@Override
public void drawUnder() {
float rotation = this.rotation - 90;
float scl = 0.6f + Mathf.absin(Timers.time(), 1f, 0.3f);
float dy = -6f*scl;
Draw.color(Palette.lighterOrange, Palette.lightFlame, Mathf.absin(Timers.time(), 3f, 0.7f));
Draw.rect("vtol-flame",
x + Angles.trnsx(rotation, 0, dy),
y + Angles.trnsy(rotation, 0, dy), Mathf.atan2(0, dy) + rotation);
Draw.color();
}
@Override
public void draw() {
Draw.alpha(hitTime / hitDuration);
Draw.rect(type.name, x, y, rotation - 90);
Draw.rect(region, x, y, rotation - 90);
for(int i : Mathf.signs){
Draw.rect(type.name + "-booster-1", x, y, 12*i, 12, rotation - 90);
Draw.rect(type.name + "-booster-2", x, y, 12*i, 12, rotation - 90);
Draw.rect(booster1, x, y, 12*i, 12, rotation - 90);
Draw.rect(booster2, x, y, 12*i, 12, rotation - 90);
}
Draw.alpha(1f);

View File

@ -1,14 +1,22 @@
package io.anuke.mindustry.game;
import com.badlogic.gdx.utils.Array;
/**Base interface for an unlockable content type.*/
public interface Content {
/**Returns the unqiue name of this piece of content.
* 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.
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).*/
String getContentName();
/**Returns the type name of this piece of content.
* This should return the same value for all instances of this content type.*/
String getContentTypeName();
/**Returns a list of all instances of this content.*/
Array<? extends Content> getAll();
/**Called after all content is created. Use for loading texture regions and other data.
* Do not use to load regions!*/
default void init(){}
/**Called after all content is created, only on non-headless versions.
* Use for loading regions or other image data.*/
default void load(){}
}

View File

@ -15,7 +15,7 @@ public class ContentDatabase {
private boolean dirty;
/**Returns whether or not this piece of content is unlocked yet.*/
public boolean isUnlocked(Content content){
public boolean isUnlocked(UnlockableContent content){
if(!unlocked.containsKey(content.getContentTypeName())){
unlocked.put(content.getContentTypeName(), new ObjectSet<>());
}
@ -29,7 +29,7 @@ public class ContentDatabase {
* If this piece of content is already unlocked, nothing changes.
* Results are not saved until you call {@link #save()}.
* @return whether or not this content was newly unlocked.*/
public boolean unlockContent(Content content){
public boolean unlockContent(UnlockableContent content){
if(!unlocked.containsKey(content.getContentTypeName())){
unlocked.put(content.getContentTypeName(), new ObjectSet<>());
}

View File

@ -1,19 +1,20 @@
package io.anuke.mindustry.game;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.util.ThreadArray;
import io.anuke.ucore.util.ThreadSet;
/**Class for various team-based utilities.*/
public class TeamInfo {
private ObjectMap<Team, TeamData> map = new ObjectMap<>();
private ObjectSet<Team> allies = new ObjectSet<>(),
enemies = new ObjectSet<>();
private ObjectSet<TeamData> allyData = new ObjectSet<>(),
enemyData = new ObjectSet<>();
private ObjectSet<TeamData> allTeamData = new ObjectSet<>();
private ObjectSet<Team> allTeams = new ObjectSet<>();
private ThreadSet<Team> allies = new ThreadSet<>(),
enemies = new ThreadSet<>();
private ThreadSet<TeamData> allyData = new ThreadSet<>(),
enemyData = new ThreadSet<>();
private ThreadSet<TeamData> allTeamData = new ThreadSet<>();
private ThreadSet<Team> allTeams = new ThreadSet<>();
/**Returns all teams on a side.*/
public ObjectSet<TeamData> getTeams(boolean ally) {
@ -93,7 +94,7 @@ public class TeamInfo {
}
public class TeamData {
public final Array<Tile> cores = new Array<>();
public final ThreadArray<Tile> cores = new ThreadArray<>();
public final Team team;
public final boolean ally;

View File

@ -0,0 +1,11 @@
package io.anuke.mindustry.game;
/**Base interface for an unlockable content type.*/
public interface UnlockableContent extends Content{
/**Returns the unqiue name of this piece of content.
* 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.
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).*/
String getContentName();
}

View File

@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectSet.ObjectSetIterator;
import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.Unit;
@ -163,9 +162,8 @@ public class OverlayRenderer {
}
if((!debug || showUI) && Settings.getBool("healthbars")){
ObjectSetIterator<TeamData> iterator = new ObjectSetIterator<>((debug ? state.teams.getTeams() : state.teams.getTeams(true)));
for(TeamData ally : iterator){
for(TeamData ally : (debug ? state.teams.getTeams() : state.teams.getTeams(true))){
for(Unit e : unitGroups[ally.team.ordinal()].all()){
drawStats(e);
}
@ -189,8 +187,8 @@ public class OverlayRenderer {
}
drawEncloser(x, y - 8f, 2f);
drawBar(Color.SCARLET, x, y - 8f, unit.healthf());
drawBar(Color.valueOf("32cf6d"), x, y - 9f, unit.inventory.totalAmmo() / (float) unit.inventory.ammoCapacity());
drawBar(Palette.healthstats, x, y - 8f, unit.healthf());
drawBar(Palette.ammo, x, y - 9f, unit.inventory.totalAmmo() / (float) unit.inventory.ammoCapacity());
}
void drawBar(Color color, float x, float y, float finion){
@ -220,7 +218,7 @@ public class OverlayRenderer {
float len = 3;
Lines.stroke(2f + height);
Draw.color(Color.SLATE);
Draw.color(Palette.bar);
Lines.line(x - len - 0.5f, y, x + len + 1.5f, y, CapStyle.none);
Draw.reset();

View File

@ -16,6 +16,7 @@ public class Palette {
public static final Color lighterOrange = Color.valueOf("f6e096");
public static final Color lightishGray = Color.valueOf("a2a2a2");
public static final Color darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f);
public static final Color lancerLaser = Color.valueOf("a9d8ff");
@ -37,7 +38,9 @@ public class Palette {
public static final Color missingitems = Color.SCARLET;
public static final Color health = Color.YELLOW;
public static final Color ammo = Color.valueOf("32cf6d");
public static final Color healthstats = Color.SCARLET;
public static final Color bar = Color.SLATE;
public static final Color interact = Color.ORANGE;
public static final Color accent = Color.valueOf("f4ba6e");
public static final Color place = Color.valueOf("6335f8");
@ -46,4 +49,13 @@ public class Palette {
public static final Color breakInvalid = Color.valueOf("d44b3d");
public static final Color range = Color.valueOf("f4ba6e");
public static final Color power = Color.valueOf("fbd367");
public static final Color redSpark = Color.valueOf("fbb97f");
public static final Color orangeSpark = Color.valueOf("d2b29c");
public static final Color redDust = Color.valueOf("ffa480");
public static final Color redderDust = Color.valueOf("ff7b69");
public static final Color plasticSmoke = Color.valueOf("f1e479");
public static final Color plasticBurn = Color.valueOf("e9ead3");
}

View File

@ -10,14 +10,13 @@ import io.anuke.ucore.util.Mathf;
/**Class that renders a trail.*/
public class Trail {
private final int length;
private FloatArray points = new FloatArray();
private final FloatArray points = new FloatArray();
public Trail(int length){
this.length = length;
}
public void update(float curx, float cury){
public synchronized void update(float curx, float cury){
points.add(curx, cury);
if(points.size > length*2) {
@ -27,7 +26,11 @@ public class Trail {
}
}
public void draw(Color start, Color end, float stroke){
public synchronized void clear(){
points.clear();
}
public synchronized void draw(Color start, Color end, float stroke){
for(int i = 0; i < points.size - 2; i += 2){
float x = points.get(i);

View File

@ -25,6 +25,7 @@ import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.*;
import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.scene.Group;
@ -80,16 +81,18 @@ public class AndroidInput extends InputHandler implements GestureListener{
/**Check and assign targets for a specific position.*/
void checkTargets(float x, float y){
Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> true);
synchronized (Entities.entityLock) {
Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> true);
if(unit != null){
player.target = unit;
}else{
Tile tile = world.tileWorld(x, y);
if(tile != null) tile = tile.target();
if (unit != null) {
player.target = unit;
} else {
Tile tile = world.tileWorld(x, y);
if (tile != null) tile = tile.target();
if(tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())){
player.target = tile.entity;
if (tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())) {
player.target = tile.entity;
}
}
}
}

View File

@ -16,7 +16,7 @@ public class DefaultKeybinds {
for(String section : sections) {
KeyBinds.defaultSection(section, DeviceType.keyboard,
new Category("General"),
new Category("General"),
"move_x", new Axis(Input.A, Input.D),
"move_y", new Axis(Input.S, Input.W),
"select", Input.MOUSE_LEFT,
@ -25,6 +25,7 @@ public class DefaultKeybinds {
"rotate_alt", new Axis(Input.R, Input.E),
"rotate", new Axis(Input.SCROLL),
"dash", Input.SHIFT_LEFT,
"drop_unit", Input.SHIFT_LEFT,
new Category("View"),
"zoom_hold", Input.CONTROL_LEFT,
"zoom", new Axis(Input.SCROLL),
@ -45,7 +46,7 @@ public class DefaultKeybinds {
);
KeyBinds.defaultSection(section, DeviceType.controller,
new Category("General"),
new Category("General"),
"move_x", new Axis(Input.CONTROLLER_L_STICK_HORIZONTAL_AXIS),
"move_y", new Axis(Input.CONTROLLER_L_STICK_VERTICAL_AXIS),
"cursor_x", new Axis(Input.CONTROLLER_R_STICK_HORIZONTAL_AXIS),

View File

@ -25,7 +25,7 @@ public class MapIO {
private static IntIntMap defaultBlockMap = new IntIntMap();
private static void loadDefaultBlocks(){
for(Block block : Block.getAllBlocks()){
for(Block block : Block.all()){
defaultBlockMap.put(block.id, block.id);
}
}
@ -151,8 +151,8 @@ public class MapIO {
stream.writeUTF(entry.value);
}
stream.writeShort(Block.getAllBlocks().size);
for(Block block : Block.getAllBlocks()){
stream.writeShort(Block.all().size);
for(Block block : Block.all()){
stream.writeShort(block.id);
stream.writeUTF(block.name);
}

View File

@ -3,10 +3,14 @@ package io.anuke.mindustry.io;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.*;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Base64Coder;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.function.Supplier;
import io.anuke.ucore.util.Log;
import io.anuke.ucore.util.ThreadArray;
import java.io.*;
@ -21,9 +25,9 @@ public class Maps implements Disposable{
/**Maps map names to the real maps.*/
private ObjectMap<String, Map> maps = new ObjectMap<>();
/**All maps stored in an ordered array.*/
private Array<Map> allMaps = new Array<>();
private Array<Map> allMaps = new ThreadArray<>();
/**Temporary array used for returning things.*/
private Array<Map> returnArray = new Array<>();
private Array<Map> returnArray = new ThreadArray<>();
/**Used for storing a list of custom map names for GWT.*/
private Array<String> customMapNames;

View File

@ -9,6 +9,7 @@ import io.anuke.mindustry.game.Difficulty;
import io.anuke.mindustry.game.GameMode;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.ThreadArray;
import java.io.IOException;
@ -16,7 +17,7 @@ import static io.anuke.mindustry.Vars.*;
public class Saves {
private int nextSlot;
private Array<SaveSlot> saves = new Array<>();
private Array<SaveSlot> saves = new ThreadArray<>();
private SaveSlot current;
private boolean saving;
private float time;

View File

@ -148,10 +148,10 @@ public class Save16 extends SaveFileVersion {
//--BLOCK HEADER--
stream.writeInt(Block.getAllBlocks().size);
stream.writeInt(Block.all().size);
for(int i = 0; i < Block.getAllBlocks().size; i ++){
Block block = Block.getAllBlocks().get(i);
for(int i = 0; i < Block.all().size; i ++){
Block block = Block.all().get(i);
stream.writeUTF(block.name);
stream.writeShort(block.id);
}

View File

@ -64,17 +64,16 @@ public class AmmoType implements Content{
return bullet.speed * bullet.lifetime;
}
//TODO implement content name?
@Override
public String getContentName() {
return "???";
}
@Override
public String getContentTypeName() {
return "ammotype";
}
@Override
public Array<? extends Content> getAll() {
return allTypes;
}
public static Array<AmmoType> all() {
return allTypes;
}

View File

@ -1,5 +1,13 @@
package io.anuke.mindustry.type;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
/**Interface for a list of content to be loaded in {@link io.anuke.mindustry.core.ContentLoader}.*/
public interface ContentList {
/**This method should create all the content.*/
void load();
/**This method should return the list of the content of this type, for further loading.*/
Array<? extends Content> getAll();
}

View File

@ -4,11 +4,12 @@ import com.badlogic.gdx.graphics.Color;
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.graphics.Palette;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Bundles;
public class Item implements Comparable<Item>, Content{
public class Item implements Comparable<Item>, UnlockableContent{
private static final Array<Item> items = new Array<>();
public final int id;
@ -70,6 +71,11 @@ public class Item implements Comparable<Item>, Content{
return "item";
}
@Override
public Array<? extends Content> getAll() {
return all();
}
public static Array<Item> all() {
return Item.items;
}

View File

@ -4,9 +4,10 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.StatusEffects;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.ucore.util.Bundles;
public class Liquid implements Content{
public class Liquid implements UnlockableContent{
private static final Array<Liquid> liquids = new Array<>();
public final Color color;
@ -56,6 +57,11 @@ public class Liquid implements Content{
return "liquid";
}
@Override
public Array<? extends Content> getAll() {
return all();
}
public static Array<Liquid> all() {
return Liquid.liquids;
}

View File

@ -1,13 +1,28 @@
package io.anuke.mindustry.type;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.ucore.graphics.Draw;
public class Mech extends Upgrade {
public boolean flying;
public float mass = 1f;
public int drillPower = -1;
public float carryWeight = 1f;
public TextureRegion baseRegion, legRegion, region;
public Mech(String name, boolean flying){
super(name);
this.flying = flying;
}
@Override
public void load() {
if (!flying){
legRegion = Draw.region(name + "-leg");
baseRegion = Draw.region(name + "-base");
}
region = Draw.region(name);
}
}

View File

@ -4,11 +4,12 @@ import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.world.Block;
import static io.anuke.mindustry.Vars.headless;
public class Recipe implements Content{
public class Recipe implements UnlockableContent{
private static int lastid;
private static Array<Recipe> allRecipes = new Array<>();
private static ObjectMap<Block, Recipe> recipeMap = new ObjectMap<>();
@ -58,6 +59,11 @@ public class Recipe implements Content{
return "recipe";
}
@Override
public Array<? extends Content> getAll() {
return allRecipes;
}
/**Returns unlocked recipes in a category.
* Do not call on the server backend, as unlocking does not exist!*/
public static void getUnlockedByCategory(Category category, Array<Recipe> r){

View File

@ -4,8 +4,9 @@ import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.entities.StatusController.TransitionResult;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.game.Content;
public class StatusEffect{
public class StatusEffect implements Content{
private static final Array<StatusEffect> array = new Array<>();
private static int lastid;
@ -52,11 +53,21 @@ public class StatusEffect{
}
}
@Override
public String getContentTypeName() {
return "statuseffect";
}
@Override
public Array<? extends Content> getAll() {
return null;
}
public static StatusEffect getByID(int id){
return array.get(id);
}
public static Array<StatusEffect> getAllEffects(){
public static Array<StatusEffect> all(){
return array;
}
}

View File

@ -2,9 +2,10 @@ package io.anuke.mindustry.type;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.ucore.util.Bundles;
public abstract class Upgrade implements Content{
public abstract class Upgrade implements UnlockableContent{
private static Array<Upgrade> upgrades = new Array<>();
private static byte lastid;
@ -39,6 +40,11 @@ public abstract class Upgrade implements Content{
return "upgrade";
}
@Override
public Array<? extends Content> getAll() {
return all();
}
public static Array<Upgrade> all() {
return upgrades;
}

View File

@ -1,5 +1,6 @@
package io.anuke.mindustry.type;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.Player;
@ -7,6 +8,7 @@ import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.bullet.Bullet;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Translator;
@ -35,10 +37,18 @@ public class Weapon extends Upgrade {
/**translator for vector calulations*/
protected Translator tr = new Translator();
public TextureRegion equipRegion, region;
protected Weapon(String name){
super(name);
}
@Override
public void load() {
equipRegion = Draw.region(name + "-equip");
region = Draw.region(name);
}
public void update(Player p, boolean left, float pointerX, float pointerY){
int t = left ? 1 : 2;
int t2 = !left ? 1 : 2;
@ -78,7 +88,7 @@ public class Weapon extends Upgrade {
}
protected void setAmmo(AmmoType... types){
for(io.anuke.mindustry.type.AmmoType type : types){
for(AmmoType type : types){
ammoMap.put(type.item, type);
}
}

View File

@ -2,9 +2,10 @@ package io.anuke.mindustry.type;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.UnlockableContent;
//TODO implement this class
public class WeatherEvent implements Content{
public class WeatherEvent implements UnlockableContent{
private static final Array<WeatherEvent> all = new Array<>();
private static int lastid;
@ -28,6 +29,11 @@ public class WeatherEvent implements Content{
return "weatherevent";
}
@Override
public Array<? extends Content> getAll() {
return all();
}
public static Array<WeatherEvent> all(){
return all;
}

View File

@ -6,13 +6,14 @@ import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Damage;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Damage;
import io.anuke.mindustry.entities.effect.Puddle;
import io.anuke.mindustry.entities.effect.Rubble;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.graphics.CacheLayer;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
@ -30,7 +31,7 @@ import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.*;
public class Block extends BaseBlock implements Content{
public class Block extends BaseBlock implements UnlockableContent{
private static int lastid;
private static Array<Block> blocks = new Array<>();
private static ObjectMap<String, Block> map = new ObjectMap<>();
@ -70,8 +71,6 @@ public class Block extends BaseBlock implements Content{
public int health = 40;
/**base block explosiveness*/
public float baseExplosiveness = 0f;
/**the shadow drawn under the block. use 'null' to indicate the default shadow for this block.*/
public String shadow = null;
/**whether to display a different shadow per variant*/
public boolean varyShadow = false;
/**edge fallback, used mainly for ores*/
@ -108,6 +107,12 @@ public class Block extends BaseBlock implements Content{
public EnumSet<BlockFlag> flags;
/**Whether to automatically set the entity to 'sleeping' when created.*/
public boolean autoSleep;
/**Name of shadow region to load. Null to indicate normal shadow.*/
public String shadow = null;
/**Region used for drawing shadows.*/
public TextureRegion shadowRegion;
/**Texture region array for drawing multiple shadows.*/
public TextureRegion[] shadowRegions;
public Block(String name) {
this.name = name;
@ -145,13 +150,23 @@ public class Block extends BaseBlock implements Content{
public boolean canPlaceOn(Tile tile){ return true; }
/**Called after all blocks are created.*/
@Override
public void init(){
setStats();
setBars();
}
/**Called after texture atlas is loaded.*/
public void load(){}
@Override
public void load() {
shadowRegion = Draw.region(shadow == null ? "shadow-" + size : shadow);
if(varyShadow && variants > 0) {
shadowRegions = new TextureRegion[variants];
for(int i = 0; i < variants; i ++){
shadowRegions[i] = Draw.region(name + "shadow" + (i + 1));
}
}
}
/**Called when the block is tapped.*/
public boolean tapped(Tile tile, Player player){
@ -394,12 +409,10 @@ public class Block extends BaseBlock implements Content{
public void drawShadow(Tile tile){
if(varyShadow && variants > 0 && shadow != null) {
Draw.rect(shadow + (Mathf.randomSeed(tile.id(), 1, variants)), tile.worldx(), tile.worldy());
}else if(shadow != null){
Draw.rect(shadow, tile.drawx(), tile.drawy());
if(shadowRegions != null) {
Draw.rect(shadowRegions[(Mathf.randomSeed(tile.id(), 0, variants - 1))], tile.worldx(), tile.worldy());
}else{
Draw.rect("shadow-" + size, tile.drawx(), tile.drawy());
Draw.rect(shadowRegion, tile.drawx(), tile.drawy());
}
}
@ -411,24 +424,6 @@ public class Block extends BaseBlock implements Content{
public boolean isMultiblock(){
return size > 1;
}
public static Array<Block> getAllBlocks(){
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);
}
public Array<Object> getDebugInfo(Tile tile){
return Array.with(
@ -454,8 +449,31 @@ public class Block extends BaseBlock implements Content{
return "block";
}
@Override
public Array<? extends Content> getAll() {
return all();
}
@Override
public String toString(){
return name;
}
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);
}
}

View File

@ -6,7 +6,7 @@ public class Rock extends Block {
public Rock(String name) {
super(name);
shadow = name+"shadow";
varyShadow = true;
breakable = true;
alwaysReplace = true;
}

View File

@ -4,7 +4,10 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.Predict;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
@ -20,10 +23,7 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.function.BiConsumer;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
import io.anuke.ucore.util.Translator;
import io.anuke.ucore.util.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -267,7 +267,7 @@ public abstract class Turret extends Block{
public static class TurretEntity extends TileEntity{
public TileEntity blockTarget;
public Array<AmmoEntry> ammo = new Array<>();
public Array<AmmoEntry> ammo = new ThreadArray<>();
public int totalAmmo;
public float reload;
public float rotation = 90;

View File

@ -20,6 +20,9 @@ public class FusionReactor extends PowerGenerator {
protected Liquid inputLiquid = Liquids.water;
protected float warmupSpeed = 0.001f;
protected Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
protected Color ind1 = Color.valueOf("858585"), ind2 = Color.valueOf("fea080");
public FusionReactor(String name) {
super(name);
hasPower = true;
@ -62,7 +65,7 @@ public class FusionReactor extends PowerGenerator {
for(int i = 0; i < plasmas; i ++){
float r = 29f + Mathf.absin(Timers.time(), 2f + i*1f, 5f - i*0.5f);
Draw.color(Color.valueOf("ffd06b"), Color.valueOf("ff361b"), (float)i/plasmas);
Draw.color(plasma1, plasma2, (float)i/plasmas);
Draw.alpha((0.3f + Mathf.absin(Timers.time(), 2f+i*2f, 0.3f+i*0.05f)) * entity.warmup);
Draw.rect(name + "-plasma-" + i, tile.drawx(), tile.drawy(), r, r, Timers.time()*(12+i*6f) * entity.warmup);
}
@ -75,7 +78,7 @@ public class FusionReactor extends PowerGenerator {
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
Draw.color(Color.valueOf("858585"), Color.valueOf("fea080"), entity.warmup + Mathf.absin(entity.totalProgress, 3f, entity.warmup*0.5f));
Draw.color(ind1, ind2, entity.warmup + Mathf.absin(entity.totalProgress, 3f, entity.warmup*0.5f));
Draw.rect(name + "-light", tile.drawx(), tile.drawy());
Draw.color();

View File

@ -2,6 +2,7 @@ package io.anuke.mindustry.server;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.*;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.io.BundleLoader;
import io.anuke.ucore.modules.ModuleCore;
@ -22,6 +23,7 @@ public class MindustryServer extends ModuleCore {
BundleLoader.load();
ContentLoader.load();
ContentLoader.initialize(Content::init);
module(logic = new Logic());
module(world = new World());