pain and suffering of various kinds
This commit is contained in:
@@ -20,6 +20,7 @@ import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Trail;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetConnection;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
@@ -765,13 +766,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
byte mechid = stream.readByte();
|
||||
int index = stream.readByte();
|
||||
players[index].readSaveSuper(stream);
|
||||
players[index].mech = Mech.getByID(mechid);
|
||||
players[index].mech = content.getByID(ContentType.mech, mechid);
|
||||
players[index].dead = false;
|
||||
}else if(local){
|
||||
byte mechid = stream.readByte();
|
||||
stream.readByte();
|
||||
readSaveSuper(stream);
|
||||
mech = Mech.getByID(mechid);
|
||||
mech = content.getByID(ContentType.mech, mechid);
|
||||
dead = false;
|
||||
}
|
||||
}
|
||||
@@ -807,7 +808,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
boolean boosting = (bools & 4) != 0;
|
||||
boolean alt = (bools & 8) != 0;
|
||||
color.set(buffer.readInt());
|
||||
mech = Mech.getByID(buffer.readByte());
|
||||
mech = content.getByID(ContentType.mech, buffer.readByte());
|
||||
int mine = buffer.readInt();
|
||||
spawner = buffer.readInt();
|
||||
float baseRotation = buffer.readShort() / 2f;
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry.entities;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.entities.traits.Saveable;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Pooling;
|
||||
@@ -11,7 +12,7 @@ import io.anuke.ucore.util.ThreadArray;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
/**
|
||||
* Class for controlling status effects on an entity.
|
||||
*/
|
||||
@@ -129,7 +130,7 @@ public class StatusController implements Saveable{
|
||||
byte id = stream.readByte();
|
||||
float time = stream.readShort() / 2f;
|
||||
StatusEntry entry = Pooling.obtain(StatusEntry.class);
|
||||
entry.set(StatusEffect.getByID(id), time);
|
||||
entry.set(content.getByID(ContentType.status, id), time);
|
||||
statuses.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class UnitInventory implements Saveable{
|
||||
private final Unit unit;
|
||||
private ItemStack item = new ItemStack(Items.stone, 0);
|
||||
@@ -32,7 +34,7 @@ public class UnitInventory implements Saveable{
|
||||
short iamount = stream.readShort();
|
||||
byte iid = stream.readByte();
|
||||
|
||||
item.item = Item.getByID(iid);
|
||||
item.item = content.item(iid);
|
||||
item.amount = iamount;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.bulletGroup;
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait{
|
||||
@@ -149,7 +150,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
velocity.x = data.readFloat();
|
||||
velocity.y = data.readFloat();
|
||||
team = Team.all[data.readByte()];
|
||||
type = BulletType.getByID(data.readByte());
|
||||
type = content.bullet(data.readByte());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
@@ -8,13 +7,20 @@ import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.entities.impl.BaseBulletType;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
public abstract class BulletType extends BaseBulletType<Bullet> implements Content{
|
||||
private static int lastid = 0;
|
||||
private static Array<BulletType> types = new Array<>();
|
||||
public abstract class BulletType extends Content implements BaseBulletType<Bullet>{
|
||||
public float lifetime = 100;
|
||||
public float speed = 1f;
|
||||
public float damage = 1;
|
||||
public float hitsize = 4;
|
||||
public float drawSize = 20f;
|
||||
public float drag = 0f;
|
||||
public boolean pierce;
|
||||
public Effect hiteffect = null, despawneffect = null;
|
||||
|
||||
public final int id;
|
||||
/**Knockback in velocity.*/
|
||||
public float knockback;
|
||||
/**Whether this bullet hits tiles.*/
|
||||
@@ -36,29 +42,65 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
|
||||
/**Whether velocity is inherited from the shooter.*/
|
||||
public boolean keepVelocity = true;
|
||||
|
||||
protected Translator vector = new Translator();
|
||||
|
||||
public BulletType(float speed, float damage){
|
||||
this.id = lastid++;
|
||||
this.speed = speed;
|
||||
this.damage = damage;
|
||||
lifetime = 40f;
|
||||
hiteffect = BulletFx.hitBulletSmall;
|
||||
despawneffect = BulletFx.hitBulletSmall;
|
||||
|
||||
types.add(this);
|
||||
}
|
||||
|
||||
public static BulletType getByID(int id){
|
||||
return types.get(id);
|
||||
}
|
||||
|
||||
public static Array<BulletType> all(){
|
||||
return types;
|
||||
}
|
||||
|
||||
public void hitTile(Bullet b, Tile tile){
|
||||
hit(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float drawSize(){
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float lifetime(){
|
||||
return lifetime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float speed(){
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float damage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float hitSize(){
|
||||
return hitSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float drag(){
|
||||
return drag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pierce(){
|
||||
return pierce;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Effect hitEffect(){
|
||||
return hiteffect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Effect despawnEffect(){
|
||||
return despawneffect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hit(Bullet b, float hitx, float hity){
|
||||
Effects.effect(hiteffect, hitx, hity, b.angle());
|
||||
@@ -73,9 +115,4 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
|
||||
public ContentType getContentType(){
|
||||
return ContentType.bullet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<? extends Content> getAll(){
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
|
||||
public void readSave(DataInput data) throws IOException{
|
||||
x = data.readFloat();
|
||||
y = data.readFloat();
|
||||
item = Item.getByID(data.readByte());
|
||||
item = content.item(data.readByte());
|
||||
amount = data.readShort();
|
||||
add();
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
|
||||
@Override
|
||||
public void read(DataInput data, long time) throws IOException{
|
||||
interpolator.read(x, y, data.readFloat(), data.readFloat(), time);
|
||||
item = Item.getByID(data.readByte());
|
||||
item = content.item(data.readByte());
|
||||
amount = data.readShort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.puddleGroup;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
@@ -261,7 +262,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait
|
||||
this.loadedPosition = stream.readInt();
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.liquid = Liquid.getByID(stream.readByte());
|
||||
this.liquid = content.liquid(stream.readByte());
|
||||
this.amount = stream.readFloat();
|
||||
this.generation = stream.readByte();
|
||||
add();
|
||||
@@ -304,7 +305,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait
|
||||
public void read(DataInput data, long time) throws IOException{
|
||||
x = data.readFloat();
|
||||
y = data.readFloat();
|
||||
liquid = Liquid.getByID(data.readByte());
|
||||
liquid = content.liquid(data.readByte());
|
||||
targetAmount = data.readShort() / 4f;
|
||||
tile = world.tile(data.readInt());
|
||||
|
||||
|
||||
@@ -34,9 +34,7 @@ import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.tmptr;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
/**
|
||||
* Interface for units that build, break or mine things.
|
||||
@@ -101,7 +99,7 @@ public interface BuilderTrait extends Entity{
|
||||
}else{ //place
|
||||
byte recipe = input.readByte();
|
||||
byte rotation = input.readByte();
|
||||
request = new BuildRequest(position % world.width(), position / world.width(), rotation, Recipe.getByID(recipe));
|
||||
request = new BuildRequest(position % world.width(), position / world.width(), rotation, content.recipe(recipe));
|
||||
}
|
||||
|
||||
request.progress = progress;
|
||||
|
||||
@@ -385,7 +385,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
this.isWave = stream.readBoolean();
|
||||
this.spawner = stream.readInt();
|
||||
|
||||
this.type = UnitType.getByID(type);
|
||||
this.type = content.unit(type);
|
||||
add();
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
public void read(DataInput data, long time) throws IOException{
|
||||
float lastx = x, lasty = y, lastrot = rotation;
|
||||
super.readSave(data);
|
||||
this.type = UnitType.getByID(data.readByte());
|
||||
this.type = content.unit(data.readByte());
|
||||
this.spawner = data.readInt();
|
||||
|
||||
interpolator.read(lastx, lasty, x, y, time, rotation);
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
@@ -21,6 +22,7 @@ import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public abstract class GroundUnit extends BaseUnit{
|
||||
@@ -210,7 +212,7 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
@Override
|
||||
public void read(DataInput data, long time) throws IOException{
|
||||
super.read(data, time);
|
||||
weapon = Weapon.getByID(data.readByte());
|
||||
weapon = content.getByID(ContentType.weapon, data.readByte());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,7 +223,7 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
|
||||
@Override
|
||||
public void readSave(DataInput stream) throws IOException{
|
||||
weapon = Weapon.getByID(stream.readByte());
|
||||
weapon = content.getByID(ContentType.weapon, stream.readByte());
|
||||
super.readSave(stream);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@ package io.anuke.mindustry.entities.units;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Weapons;
|
||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
@@ -22,15 +20,11 @@ import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
//TODO merge unit type with mech
|
||||
public class UnitType implements UnlockableContent{
|
||||
private static byte lastid = 0;
|
||||
private static Array<UnitType> types = new Array<>();
|
||||
|
||||
public class UnitType extends UnlockableContent{
|
||||
protected final Supplier<? extends BaseUnit> constructor;
|
||||
|
||||
public final String name;
|
||||
public final String description;
|
||||
public final byte id;
|
||||
public float health = 60;
|
||||
public float hitsize = 5f;
|
||||
public float hitsizeTile = 4f;
|
||||
@@ -55,13 +49,10 @@ public class UnitType implements UnlockableContent{
|
||||
public TextureRegion iconRegion, legRegion, baseRegion, region;
|
||||
|
||||
public <T extends BaseUnit> UnitType(String name, Class<T> type, Supplier<T> mainConstructor){
|
||||
this.id = lastid++;
|
||||
this.name = name;
|
||||
this.constructor = mainConstructor;
|
||||
this.description = Bundles.getOrNull("unit." + name + ".description");
|
||||
|
||||
types.add(this);
|
||||
|
||||
TypeTrait.registerType(type, mainConstructor);
|
||||
|
||||
if(!Bundles.has("unit." + this.name + ".name")){
|
||||
@@ -70,19 +61,6 @@ public class UnitType implements UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
public static UnitType getByID(byte id){
|
||||
return types.get(id);
|
||||
}
|
||||
|
||||
public static Array<UnitType> all(){
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayInfo(Table table){
|
||||
ContentDisplay.displayUnit(table, this);
|
||||
@@ -119,11 +97,6 @@ public class UnitType implements UnlockableContent{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<? extends Content> getAll(){
|
||||
return types;
|
||||
}
|
||||
|
||||
public BaseUnit create(Team team){
|
||||
BaseUnit unit = constructor.get();
|
||||
unit.init(this, team);
|
||||
|
||||
Reference in New Issue
Block a user