Sprite reorganization, new power and tier-based pumps

This commit is contained in:
Anuken 2018-06-15 15:53:43 -04:00
parent 604f315a83
commit ffbb6bb40b
95 changed files with 862 additions and 817 deletions

View File

@ -30,7 +30,7 @@ public class IOFinder {
//make sure there's only one read method
if(readers.stream().filter(elem -> getValue(elem.getAnnotation(ReadClass.class)).equals(typeName)).count() > 1){
Utils.messager.printMessage(Kind.ERROR, "Multiple writer methods for type: ", writer);
Utils.messager.printMessage(Kind.ERROR, "Multiple writer methods for type '" + typeName + "'", writer);
}
//make sure there's only one write method

View File

@ -90,7 +90,7 @@ public class RemoteReadGenerator {
ClassSerializer ser = serializers.get(typeName);
if (ser == null) { //make sure a serializer exists!
Utils.messager.printMessage(Kind.ERROR, "No @ReadClass method to read class type: ", var);
Utils.messager.printMessage(Kind.ERROR, "No @ReadClass method to read class type: '" + typeName + "'", var);
return;
}

View File

@ -174,7 +174,7 @@ public class RemoteWriteGenerator {
ClassSerializer ser = serializers.get(typeName);
if(ser == null){ //make sure a serializer exists!
Utils.messager.printMessage(Kind.ERROR, "No @WriteClass method to write class type: ", var);
Utils.messager.printMessage(Kind.ERROR, "No @WriteClass method to write class type: '" + typeName + "'", var);
return;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

View File

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 261 B

After

Width:  |  Height:  |  Size: 261 B

View File

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

View File

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View File

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

View File

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 298 B

View File

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 289 B

View File

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View File

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 239 B

View File

Before

Width:  |  Height:  |  Size: 341 B

After

Width:  |  Height:  |  Size: 341 B

View File

Before

Width:  |  Height:  |  Size: 379 B

After

Width:  |  Height:  |  Size: 379 B

View File

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 473 B

View File

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

View File

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 354 B

View File

Before

Width:  |  Height:  |  Size: 296 B

After

Width:  |  Height:  |  Size: 296 B

View File

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 678 B

View File

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 192 B

View File

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 196 B

View File

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 228 B

View File

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

View File

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 196 B

View File

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 233 B

View File

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

View File

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 196 B

View File

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 260 B

View File

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 192 B

View File

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

View File

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 338 B

View File

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 298 B

View File

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

View File

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 181 B

View File

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 185 B

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

View File

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 177 B

View File

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View File

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 227 B

View File

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 199 B

View File

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

View File

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 161 B

View File

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View File

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

View File

Before

Width:  |  Height:  |  Size: 235 B

After

Width:  |  Height:  |  Size: 235 B

View File

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 225 B

View File

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

View File

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

View File

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

View File

Before

Width:  |  Height:  |  Size: 613 B

After

Width:  |  Height:  |  Size: 613 B

View File

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 196 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 285 B

View File

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

View File

Before

Width:  |  Height:  |  Size: 267 B

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 196 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View File

@ -80,7 +80,7 @@ public class Pathfinder {
}
private boolean passable(Tile tile, Team team){
return (tile.getWallID() == 0 && !(tile.floor().liquid && (tile.floor().damageTaken > 0 || tile.floor().drownTime > 0)))
return (tile.getWallID() == 0 && !(tile.floor().isLiquid && (tile.floor().damageTaken > 0 || tile.floor().drownTime > 0)))
|| (tile.breakable() && (tile.getTeam() != team)) || !tile.solid();
}

View File

@ -17,6 +17,7 @@ public class Liquids implements ContentList {
water = new Liquid("water", Color.valueOf("486acd")) {
{
heatCapacity = 0.4f;
tier = 0;
effect = StatusEffects.wet;
}
};
@ -25,6 +26,7 @@ public class Liquids implements ContentList {
{
temperature = 0.8f;
viscosity = 0.8f;
tier = 2;
effect = StatusEffects.melting;
}
};
@ -34,6 +36,7 @@ public class Liquids implements ContentList {
viscosity = 0.7f;
flammability = 0.6f;
explosiveness = 0.6f;
tier = 1;
effect = StatusEffects.oiled;
}
};
@ -42,6 +45,7 @@ public class Liquids implements ContentList {
{
heatCapacity = 0.75f;
temperature = 0.5f;
tier = 1;
effect = StatusEffects.freezing;
}
};

View File

@ -108,8 +108,9 @@ public class Recipes implements ContentList{
new Recipe(liquid, LiquidBlocks.bridgeconduit, new ItemStack(Items.titanium, 2), new ItemStack(Items.steel, 2));
new Recipe(liquid, LiquidBlocks.laserconduit, new ItemStack(Items.titanium, 2), new ItemStack(Items.steel, 2));
new Recipe(liquid, LiquidBlocks.pump, new ItemStack(Items.steel, 10));
new Recipe(liquid, LiquidBlocks.fluxpump, new ItemStack(Items.steel, 10), new ItemStack(Items.surgealloy, 5));
new Recipe(liquid, LiquidBlocks.mechanicalPump, new ItemStack(Items.steel, 10));
new Recipe(liquid, LiquidBlocks.rotaryPump, new ItemStack(Items.steel, 10), new ItemStack(Items.surgealloy, 5));
new Recipe(liquid, LiquidBlocks.thermalPump, new ItemStack(Items.steel, 10), new ItemStack(Items.surgealloy, 5));
new Recipe(units, UnitBlocks.repairPoint, new ItemStack(Items.steel, 10));
new Recipe(units, UnitBlocks.dropPoint, new ItemStack(Items.steel, 10));

View File

@ -51,7 +51,7 @@ public class Blocks extends BlockList implements ContentList{
speedMultiplier = 0.2f;
variants = 0;
liquidDrop = Liquids.water;
liquid = true;
isLiquid = true;
status = StatusEffects.wet;
statusIntensity = 1f;
drownTime = 140f;
@ -66,7 +66,7 @@ public class Blocks extends BlockList implements ContentList{
status = StatusEffects.wet;
statusIntensity = 0.9f;
liquidDrop = Liquids.water;
liquid = true;
isLiquid = true;
cacheLayer = CacheLayer.water;
}};
@ -79,7 +79,7 @@ public class Blocks extends BlockList implements ContentList{
statusIntensity = 0.8f;
variants = 0;
liquidDrop = Liquids.lava;
liquid = true;
isLiquid = true;
cacheLayer = CacheLayer.lava;
}};
@ -91,7 +91,7 @@ public class Blocks extends BlockList implements ContentList{
speedMultiplier = 0.2f;
variants = 0;
liquidDrop = Liquids.oil;
liquid = true;
isLiquid = true;
cacheLayer = CacheLayer.oil;
}};

View File

@ -194,7 +194,7 @@ public class CraftingBlocks extends BlockList implements ContentList {
hasLiquids = hasItems = true;
}};
weaponFactory = new WeaponFactory("weaponfactory") {{
weaponFactory = new MechFactory("weaponfactory") {{
size = 2;
health = 250;
}};

View File

@ -6,17 +6,30 @@ import io.anuke.mindustry.world.blocks.distribution.*;
import io.anuke.mindustry.world.blocks.production.Pump;
public class LiquidBlocks extends BlockList implements ContentList{
public static Block pump, fluxpump, conduit, pulseconduit, liquidrouter, liquidtank, liquidjunction, bridgeconduit, laserconduit;
public static Block mechanicalPump, rotaryPump, thermalPump, conduit, pulseconduit, liquidrouter, liquidtank, liquidjunction, bridgeconduit, laserconduit;
@Override
public void load() {
pump = new Pump("pump") {{
mechanicalPump = new Pump("mechanical-pump") {{
pumpAmount = 0.1f;
tier = 0;
}};
fluxpump = new Pump("fluxpump") {{
rotaryPump = new Pump("rotary-pump") {{
pumpAmount = 0.2f;
powerUse = 0.015f;
liquidCapacity = 30f;
size = 2;
tier = 1;
}};
thermalPump = new Pump("thermal-pump") {{
pumpAmount = 0.3f;
powerUse = 0.02f;
liquidCapacity = 40f;
size = 2;
tier = 2;
}};
conduit = new Conduit("conduit") {{

View File

@ -62,12 +62,12 @@ public class ContentLoader {
//ammotypes
new AmmoTypes(),
//mechs
new Mechs(),
//weapons
new Weapons(),
//mechs
new Mechs(),
//units
new UnitTypes(),

View File

@ -306,7 +306,7 @@ public class NetServer extends Module{
return;
}
if(!player.timer.get(Player.timeSync, serverSyncTime)) continue;
if(!player.timer.get(Player.timerSync, serverSyncTime)) continue;
//if the player hasn't acknowledged that it has recieved the packet, send the same thing again
if(connection.lastSentSnapshotID > connection.lastSnapshotID){

View File

@ -3,23 +3,27 @@ package io.anuke.mindustry.entities;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pools;
import com.badlogic.gdx.utils.Queue;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.content.Weapons;
import io.anuke.mindustry.entities.effect.ItemDrop;
import io.anuke.mindustry.entities.traits.*;
import io.anuke.mindustry.entities.traits.BuilderTrait;
import io.anuke.mindustry.entities.traits.CarriableTrait;
import io.anuke.mindustry.entities.traits.CarryTrait;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.CallEntity;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Trail;
import io.anuke.mindustry.net.In;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.Floor;
@ -29,7 +33,10 @@ import io.anuke.ucore.entities.EntityGroup;
import io.anuke.ucore.entities.trait.SolidTrait;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.*;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.ThreadQueue;
import io.anuke.ucore.util.Timer;
import java.io.DataInput;
import java.io.DataOutput;
@ -38,14 +45,13 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
public class Player extends Unit implements BuilderTrait, CarryTrait {
private static final float debugSpeed = 1.8f;
private static final Vector2 movement = new Vector2();
public static int typeID = -1;
public static final int timerShootLeft = 0;
public static final int timerShootRight = 1;
public static final int timeSync = 2;
public static final int timerSync = 2;
//region instance variables, constructor
@ -56,9 +62,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
public String uuid, usid;
public boolean isAdmin, isTransferring, isShooting;
public Color color = new Color();
public Array<Upgrade> upgrades = new Array<>();
public Weapon weapon = Weapons.blaster;
public Mech mech = Mechs.standard;
public int clientid = -1;
@ -78,8 +81,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
public Player(){
hitbox.setSize(5);
hitboxTile.setSize(4f);
heal();
}
//endregion
@ -146,12 +147,12 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
@Override
public boolean acceptsAmmo(Item item) {
return weapon.getAmmoType(item) != null && inventory.canAcceptAmmo(weapon.getAmmoType(item));
return mech.weapon.getAmmoType(item) != null && inventory.canAcceptAmmo(mech.weapon.getAmmoType(item));
}
@Override
public void addAmmo(Item item) {
inventory.addAmmo(weapon.getAmmoType(item));
inventory.addAmmo(mech.weapon.getAmmoType(item));
}
@Override
@ -258,7 +259,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
Draw.alpha(hitTime / hitDuration);
if(!mech.flying) {
if(floor.liquid){
if(floor.isLiquid){
Draw.tint(Color.WHITE, floor.liquidColor, 0.5f);
}
@ -272,7 +273,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
Draw.rect(mech.baseRegion, x, y, baseRotation- 90);
}
if(floor.liquid) {
if(floor.isLiquid) {
Draw.tint(Color.WHITE, floor.liquidColor, drownTime * 0.4f);
}else {
Draw.tint(Color.WHITE);
@ -282,9 +283,9 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
for (int i : Mathf.signs) {
float tra = rotation - 90,
trX = 4*i, trY = 3 - weapon.getRecoil(this, i > 0)*1.5f;
trX = 4*i, trY = 3 - mech.weapon.getRecoil(this, i > 0)*1.5f;
float w = i > 0 ? -8 : 8;
Draw.rect(weapon.equipRegion,
Draw.rect(mech.weapon.equipRegion,
x + Angles.trnsx(tra, trX, trY),
y + Angles.trnsy(tra, trX, trY), w, 8, rotation - 90);
}
@ -481,8 +482,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
protected void updateShooting(){
if(isShooting()){
weapon.update(this, true, pointerX, pointerY);
weapon.update(this, false, pointerX, pointerY);
mech.weapon.update(this, true, pointerX, pointerY);
mech.weapon.update(this, false, pointerX, pointerY);
}
}
@ -577,10 +578,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
/**Resets all values of the player.*/
public void reset(){
weapon = Weapons.blaster;
team = Team.blue;
inventory.clear();
upgrades.clear();
placeQueue.clear();
dead = true;
respawning = false;
@ -617,13 +616,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
stream.writeBoolean(isLocal);
if(isLocal){
stream.writeInt(playerIndex);
stream.writeByte(playerIndex);
super.writeSave(stream, false);
stream.writeByte(upgrades.size);
for(Upgrade u : upgrades){
stream.writeByte(u.id);
}
}
}
@ -632,17 +626,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
boolean local = stream.readBoolean();
if(local){
int index = stream.readInt();
int index = stream.readByte();
players[index].readSaveSuper(stream);
}
}
private void readSaveSuper(DataInput stream) throws IOException {
super.readSave(stream);
byte uamount = stream.readByte();
for (int i = 0; i < uamount; i++) {
upgrades.add(Upgrade.getByID(stream.readByte()));
}
add();
}
@ -654,7 +644,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
buffer.writeBoolean(isAdmin);
buffer.writeInt(Color.rgba8888(color));
buffer.writeBoolean(dead);
buffer.writeByte(weapon.id);
buffer.writeByte(mech.id);
}
@ -666,7 +655,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
isAdmin = buffer.readBoolean();
color.set(buffer.readInt());
dead = buffer.readBoolean();
weapon = Upgrade.getByID(buffer.readByte());
mech = Upgrade.getByID(buffer.readByte());
interpolator.read(lastx, lasty, x, y, time, rotation);
rotation = lastrot;

View File

@ -186,7 +186,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
x += velocity.x / getMass() * Timers.delta();
y += velocity.y / getMass() * Timers.delta();
}else{
boolean onLiquid = floor.liquid;
boolean onLiquid = floor.isLiquid;
if(tile != null){
tile.block().unitOn(tile, this);

View File

@ -26,7 +26,7 @@ public class GroundEffectEntity extends EffectEntity {
once = true;
time = 0f;
Tile tile = Vars.world.tileWorld(x, y);
if(tile != null && tile.floor().liquid){
if(tile != null && tile.floor().isLiquid){
remove();
}
} else if (once && time >= effect.staticLife) {

View File

@ -111,7 +111,7 @@ public class ItemDrop extends SolidEntity implements SyncTrait, DrawTrait, Veloc
Tile tile = world.tileWorld(x, y);
Draw.color(Color.WHITE, tile == null || !tile.floor().liquid ? Color.WHITE : tile.floor().liquidColor, sinktime/sinkLifetime);
Draw.color(Color.WHITE, tile == null || !tile.floor().isLiquid ? Color.WHITE : tile.floor().liquidColor, sinktime/sinkLifetime);
Draw.rect(item.region, x, y, size, size);
int stored = Mathf.clamp(amount / 6, 1, 8);
@ -136,7 +136,7 @@ public class ItemDrop extends SolidEntity implements SyncTrait, DrawTrait, Veloc
Tile tile = world.tileWorld(x, y);
if(tile.floor().liquid){
if(tile.floor().isLiquid){
sinktime += Timers.delta();
if(Mathf.chance(0.04 * Timers.delta())){

View File

@ -76,7 +76,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait
}
private static void deposit(Tile tile, Tile source, Liquid liquid, float amount, int generation){
if(tile.floor().liquid && !canStayOn(liquid, tile.floor().liquidDrop)){
if(tile.floor().isLiquid && !canStayOn(liquid, tile.floor().liquidDrop)){
reactPuddle(tile.floor().liquidDrop, liquid, amount, tile,
(tile.worldx() + source.worldx())/2f, (tile.worldy() + source.worldy())/2f);
@ -204,7 +204,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait
@Override
public void draw() {
seeds = id;
boolean onLiquid = tile.floor().liquid;
boolean onLiquid = tile.floor().isLiquid;
float f = Mathf.clamp(amount/(maxLiquid/1.5f));
float smag = onLiquid ? 0.8f : 0f;
float sscl = 20f;

View File

@ -68,7 +68,7 @@ public abstract class GroundUnit extends BaseUnit {
Floor floor = getFloorOn();
if(floor.liquid){
if(floor.isLiquid){
Draw.tint(Color.WHITE, floor.liquidColor, 0.5f);
}
@ -79,7 +79,7 @@ public abstract class GroundUnit extends BaseUnit {
12f * i, 12f - Mathf.clamp(ft * i, 0, 2), baseRotation - 90);
}
if(floor.liquid) {
if(floor.isLiquid) {
Draw.tint(Color.WHITE, floor.liquidColor, drownTime * 0.4f);
}else {
Draw.tint(Color.WHITE);

View File

@ -0,0 +1,9 @@
package io.anuke.mindustry.graphics;
/**Used for generating extra textures before packing.*/
public class TextureGenerator {
public static void main(String[] args){
}
}

View File

@ -173,6 +173,16 @@ public class TypeIO {
return Upgrade.getByID(buffer.get());
}
@WriteClass(Mech.class)
public static void writeMech(ByteBuffer buffer, Mech mech){
buffer.put(mech.id);
}
@ReadClass(Mech.class)
public static Mech readMech(ByteBuffer buffer){
return Upgrade.getByID(buffer.get());
}
@WriteClass(Liquid.class)
public static void writeLiquid(ByteBuffer buffer, Liquid liquid){
buffer.put((byte)liquid.id);

View File

@ -28,6 +28,8 @@ public class Liquid implements UnlockableContent{
public Color flameColor = Color.valueOf("ffb763");
/**The associated status effect.*/
public StatusEffect effect = StatusEffects.none;
/**Pump tier. Controls which pumps can use this liquid.*/
public int tier;
public Liquid(String name, Color color) {
this.name = name;

View File

@ -1,6 +1,7 @@
package io.anuke.mindustry.type;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.Weapons;
import io.anuke.ucore.graphics.Draw;
public class Mech extends Upgrade {
@ -10,6 +11,7 @@ public class Mech extends Upgrade {
public float mass = 1f;
public int drillPower = -1;
public float carryWeight = 1f;
public Weapon weapon = Weapons.blaster;
public TextureRegion baseRegion, legRegion, region;

View File

@ -117,7 +117,7 @@ public class PlayerListFragment implements Fragment{
public void draw(){
float s = getWidth() / 12f;
for(int i : Mathf.signs){
Draw.rect((player.weapon.name)
Draw.rect((player.mech.weapon.name)
+ "-equip", x + s * 6 + i * 3*s, y + s*6 + 2*s, -8*s*i, 8*s);
}
}

View File

@ -69,8 +69,6 @@ public class Block extends BaseBlock implements UnlockableContent{
public boolean rotate;
/**whether you can break this with rightclick*/
public boolean breakable;
/**whether this block can be drowned in*/
public boolean liquid;
/**whether this floor can be placed on.*/
public boolean placeableOn = true;
/**tile entity health*/
@ -308,7 +306,7 @@ public class Block extends BaseBlock implements UnlockableContent{
}
Damage.dynamicExplosion(x, y, flammability, explosiveness, power, tilesize * size/2f, tempColor);
if(!tile.floor().solid && !tile.floor().liquid){
if(!tile.floor().solid && !tile.floor().isLiquid){
Rubble.create(tile.drawx(), tile.drawy(), size);
}
}
@ -317,7 +315,7 @@ public class Block extends BaseBlock implements UnlockableContent{
* Takes flammability of floor liquid into account.*/
public float getFlammability(Tile tile){
if(!hasItems || tile.entity == null){
if(tile.floor().liquid && !solid){
if(tile.floor().isLiquid && !solid){
return tile.floor().liquidDrop.flammability;
}
return 0;

View File

@ -59,7 +59,7 @@ public class BreakBlock extends Block {
public void onDestroyed(Tile tile){
Effects.effect(ExplosionFx.blockExplosionSmoke, tile);
if(!tile.floor().solid && !tile.floor().liquid){
if(!tile.floor().solid && !tile.floor().isLiquid){
Rubble.create(tile.drawx(), tile.drawy(), size);
}
}

View File

@ -58,7 +58,7 @@ public class BuildBlock extends Block {
public void onDestroyed(Tile tile){
Effects.effect(ExplosionFx.blockExplosionSmoke, tile);
if(!tile.floor().solid && !tile.floor().liquid){
if(!tile.floor().solid && !tile.floor().isLiquid){
Rubble.create(tile.drawx(), tile.drawy(), size);
}
}

View File

@ -59,6 +59,8 @@ public class Floor extends Block{
public Liquid liquidDrop = null;
/**Whether ores generate on this block.*/
public boolean hasOres = true;
/**whether this block can be drowned in*/
public boolean isLiquid;
public Floor(String name) {
super(name);
@ -113,7 +115,7 @@ public class Floor extends Block{
public void init(){
super.init();
if(liquid && liquidColor == null){
if(isLiquid && liquidColor == null){
throw new RuntimeException("All liquids must define a liquidColor! Problematic block: " + name);
}
}

View File

@ -12,8 +12,8 @@ import io.anuke.mindustry.gen.CallBlocks;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.net.In;
import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
@ -31,9 +31,9 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WeaponFactory extends Block{
public class MechFactory extends Block{
public WeaponFactory(String name){
public MechFactory(String name){
super(name);
solid = true;
destructible = true;
@ -43,12 +43,12 @@ public class WeaponFactory extends Block{
@Override
public void draw(Tile tile) {
WeaponFactoryEntity entity = tile.entity();
MechFactoryEntity entity = tile.entity();
Draw.rect(name, tile.drawx(), tile.drawy());
if(entity.current != null) {
TextureRegion region = entity.current.equipRegion;
TextureRegion region = entity.current.region;
Shaders.build.region = region;
Shaders.build.progress = entity.progress;
@ -74,7 +74,7 @@ public class WeaponFactory extends Block{
@Override
public void update(Tile tile) {
WeaponFactoryEntity entity = tile.entity();
MechFactoryEntity entity = tile.entity();
if(entity.current != null){
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
@ -82,7 +82,7 @@ public class WeaponFactory extends Block{
entity.progress += 1f / Vars.respawnduration;
if(entity.progress >= 1f){
CallBlocks.onWeaponFactoryDone(tile, entity.current);
CallBlocks.onMechFactoryDone(tile, entity.current);
}
}else{
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
@ -91,7 +91,7 @@ public class WeaponFactory extends Block{
@Override
public void buildTable(Tile tile, Table table) {
WeaponFactoryEntity entity = tile.entity();
MechFactoryEntity entity = tile.entity();
Table cont = new Table();
@ -108,7 +108,7 @@ public class WeaponFactory extends Block{
}
protected void showSelect(Tile tile, Table cont){
WeaponFactoryEntity entity = tile.entity();
MechFactoryEntity entity = tile.entity();
Array<Upgrade> items = Upgrade.all();
@ -118,13 +118,13 @@ public class WeaponFactory extends Block{
int i = 0;
for (Upgrade upgrade : items) {
if (!(upgrade instanceof Weapon)) continue;
Weapon weapon = (Weapon) upgrade;
if (!(upgrade instanceof Mech)) continue;
Mech mech = (Mech) upgrade;
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> CallBlocks.setWeaponFactoryWeapon(null, tile, weapon))
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> CallBlocks.setMechFactory(null, tile, mech))
.size(38, 42).padBottom(-5.1f).group(group).get();
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(weapon.region));
button.setChecked(entity.current == weapon);
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(mech.region));
button.setChecked(entity.current == mech);
if (i++ % 4 == 3) {
cont.row();
@ -142,14 +142,14 @@ public class WeaponFactory extends Block{
}
protected void showResult(Tile tile, Table cont){
WeaponFactoryEntity entity = tile.entity();
MechFactoryEntity entity = tile.entity();
Weapon weapon = entity.result;
Mech mech = entity.result;
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> CallBlocks.setWeaponFactoryWeapon(null, tile, weapon))
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> CallBlocks.pickupMechFactory(null, tile))
.size(38, 42).padBottom(-5.1f).get();
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(weapon.region));
button.setChecked(entity.current == weapon);
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(mech.region));
button.setChecked(entity.current == mech);
cont.update(() -> {
//show selection menu when result disappears
@ -163,15 +163,15 @@ public class WeaponFactory extends Block{
@Override
public TileEntity getEntity() {
return new WeaponFactoryEntity();
return new MechFactoryEntity();
}
@Remote(targets = Loc.both, called = Loc.server, in = In.blocks, forward = true)
public static void pickupWeaponFactoryWeapon(Player player, Tile tile){
WeaponFactoryEntity entity = tile.entity();
public static void pickupMechFactory(Player player, Tile tile){
MechFactoryEntity entity = tile.entity();
if(entity.current != null){
player.upgrades.add(entity.current);
player.mech = entity.current;
entity.current = null;
entity.progress = 0;
entity.result = null;
@ -179,28 +179,28 @@ public class WeaponFactory extends Block{
}
@Remote(targets = Loc.both, called = Loc.server, in = In.blocks, forward = true)
public static void setWeaponFactoryWeapon(Player player, Tile tile, Weapon weapon){
WeaponFactoryEntity entity = tile.entity();
public static void setMechFactory(Player player, Tile tile, Mech weapon){
MechFactoryEntity entity = tile.entity();
entity.current = weapon;
entity.progress = 0f;
entity.heat = 0f;
}
@Remote(called = Loc.server, in = In.blocks)
public static void onWeaponFactoryDone(Tile tile, Weapon result){
WeaponFactoryEntity entity = tile.entity();
public static void onMechFactoryDone(Tile tile, Mech result){
MechFactoryEntity entity = tile.entity();
Effects.effect(Fx.spawn, entity);
entity.current = null;
entity.progress = 0;
entity.result = result;
}
public class WeaponFactoryEntity extends TileEntity{
public Weapon current;
public class MechFactoryEntity extends TileEntity{
public Mech current;
public Mech result;
public float progress;
public float time;
public float heat;
public Weapon result;
@Override
public void write(DataOutputStream stream) throws IOException {

View File

@ -9,12 +9,19 @@ import io.anuke.mindustry.world.blocks.LiquidBlock;
import io.anuke.mindustry.world.meta.BlockGroup;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
public class Pump extends LiquidBlock{
protected final Array<Tile> drawTiles = new Array<>();
protected final Array<Tile> updateTiles = new Array<>();
/**Pump amount per tile this block is on.*/
protected float pumpAmount = 1f;
/**Power used per frame per tile this block is on.*/
protected float powerUse = 0f;
/**Maximum liquid tier this pump can use.*/
protected int tier = 0;
public Pump(String name) {
super(name);
@ -53,12 +60,18 @@ public class Pump extends LiquidBlock{
@Override
public boolean canPlaceOn(Tile tile) {
if(isMultiblock()){
Liquid last = null;
for(Tile other : tile.getLinkedTiles(drawTiles)){
//can't place pump on block with multiple liquids
if(last != null && other.floor().liquidDrop != last){
return false;
}
if(isValid(other)){
return true;
last = other.floor().liquidDrop;
}
}
return false;
return last != null;
}else{
return isValid(tile);
}
@ -66,10 +79,34 @@ public class Pump extends LiquidBlock{
@Override
public void update(Tile tile){
if(tile.floor().liquidDrop != null){
float maxPump = Math.min(liquidCapacity - tile.entity.liquids.amount, pumpAmount * Timers.delta());
tile.entity.liquids.liquid = tile.floor().liquidDrop;
float tiles = 0f;
Liquid liquidDrop = null;
if(isMultiblock()){
for(Tile other : tile.getLinkedTiles(updateTiles)){
if(isValid(other)){
liquidDrop = other.floor().liquidDrop;
tiles ++;
}
}
}else{
tiles = 1f;
liquidDrop = tile.floor().liquidDrop;
}
if(hasPower){
float used = Math.min(powerCapacity, tiles * powerUse * Timers.delta());
//multiply liquid obtained by the fraction of power this pump has to pump it
//e.g. only has 50% power required = only pumps 50% of liquid that it can
tiles *= Mathf.clamp(tile.entity.power.amount / used);
tile.entity.power.amount -= Math.min(tile.entity.power.amount, used);
}
if(liquidDrop != null){
float maxPump = Math.min(liquidCapacity - tile.entity.liquids.amount, tiles * pumpAmount * Timers.delta());
tile.entity.liquids.liquid = liquidDrop;
tile.entity.liquids.amount += maxPump;
}
@ -77,7 +114,7 @@ public class Pump extends LiquidBlock{
}
protected boolean isValid(Tile tile){
return tile.floor().liquidDrop != null;
return tile.floor().liquidDrop != null && tier >= tile.floor().liquidDrop.tier;
}
}

View File

@ -98,7 +98,7 @@ public class SolidPump extends Pump {
}
protected boolean isValid(Tile tile){
return !tile.floor().liquid;
return !tile.floor().isLiquid;
}
@Override