the errors are back
This commit is contained in:
@@ -50,6 +50,7 @@ public class Annotations{
|
|||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface EntityDef{
|
public @interface EntityDef{
|
||||||
Class[] value();
|
Class[] value();
|
||||||
|
boolean isFinal() default true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Indicates an internal interface for entity components. */
|
/** Indicates an internal interface for entity components. */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package mindustry.annotations;
|
package mindustry.annotations;
|
||||||
|
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.struct.*;
|
import arc.struct.Array;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import com.squareup.javapoet.*;
|
import com.squareup.javapoet.*;
|
||||||
import com.sun.source.util.*;
|
import com.sun.source.util.*;
|
||||||
@@ -16,6 +16,7 @@ import javax.tools.Diagnostic.*;
|
|||||||
import javax.tools.*;
|
import javax.tools.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
import java.lang.reflect.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||||
@@ -47,6 +48,12 @@ public abstract class BaseProcessor extends AbstractProcessor{
|
|||||||
return str.contains(".") ? str.substring(str.lastIndexOf('.') + 1) : str;
|
return str.contains(".") ? str.substring(str.lastIndexOf('.') + 1) : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TypeName tname(String name) throws Exception{
|
||||||
|
Constructor<TypeName> cons = TypeName.class.getDeclaredConstructor(String.class);
|
||||||
|
cons.setAccessible(true);
|
||||||
|
return cons.newInstance(name);
|
||||||
|
}
|
||||||
|
|
||||||
public static TypeVariableName getTVN(TypeParameterElement element) {
|
public static TypeVariableName getTVN(TypeParameterElement element) {
|
||||||
String name = element.getSimpleName().toString();
|
String name = element.getSimpleName().toString();
|
||||||
List<? extends TypeMirror> boundsMirrors = element.getBounds();
|
List<? extends TypeMirror> boundsMirrors = element.getBounds();
|
||||||
|
|||||||
@@ -134,11 +134,13 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
|
|
||||||
//look at each definition
|
//look at each definition
|
||||||
for(Stype type : allDefs){
|
for(Stype type : allDefs){
|
||||||
|
boolean isFinal = type.annotation(EntityDef.class).isFinal();
|
||||||
if(!type.name().endsWith("Def")){
|
if(!type.name().endsWith("Def")){
|
||||||
err("All entity def names must end with 'Def'", type.e);
|
err("All entity def names must end with 'Def'", type.e);
|
||||||
}
|
}
|
||||||
String name = type.name().replace("Def", "_"); //TODO remove extra underscore
|
String name = type.name().replace("Def", "Entity"); //TODO remove extra underscore
|
||||||
TypeSpec.Builder builder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
|
TypeSpec.Builder builder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC);
|
||||||
|
if(isFinal) builder.addModifiers(Modifier.FINAL);
|
||||||
|
|
||||||
Array<Stype> components = allComponents(type);
|
Array<Stype> components = allComponents(type);
|
||||||
Array<GroupDefinition> groups = groupDefs.select(g -> !g.components.contains(s -> !components.contains(s)));
|
Array<GroupDefinition> groups = groupDefs.select(g -> !g.components.contains(s -> !components.contains(s)));
|
||||||
@@ -185,7 +187,8 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//build method using same params/returns
|
//build method using same params/returns
|
||||||
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC, Modifier.FINAL);
|
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC);
|
||||||
|
if(isFinal) mbuilder.addModifiers(Modifier.FINAL);
|
||||||
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
|
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
|
||||||
mbuilder.returns(first.retn());
|
mbuilder.returns(first.retn());
|
||||||
mbuilder.addExceptions(first.thrownt());
|
mbuilder.addExceptions(first.thrownt());
|
||||||
@@ -244,6 +247,14 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
builder.addMethod(mbuilder.build());
|
builder.addMethod(mbuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//make constructor private
|
||||||
|
builder.addMethod(MethodSpec.constructorBuilder().addModifiers(Modifier.PROTECTED).build());
|
||||||
|
|
||||||
|
//add create() method
|
||||||
|
builder.addMethod(MethodSpec.methodBuilder("create").addModifiers(Modifier.PUBLIC, Modifier.STATIC)
|
||||||
|
.returns(tname(packageName + "." + name))
|
||||||
|
.addStatement("return new $L()", name).build());
|
||||||
|
|
||||||
definitions.add(new EntityDefinition("mindustry.gen." + name, builder, type, components, groups));
|
definitions.add(new EntityDefinition("mindustry.gen." + name, builder, type, components, groups));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#Maps entity names to IDs. Autogenerated.
|
#Maps entity names to IDs. Autogenerated.
|
||||||
#Wed Feb 05 12:35:36 EST 2020
|
|
||||||
|
|
||||||
mindustry.entities.def.EntityDefs.DecalDef=1
|
mindustry.entities.def.EntityDefs.DecalDef=1
|
||||||
mindustry.entities.def.EntityDefs.EffectDef=2
|
mindustry.entities.def.EntityDefs.EffectDef=2
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ public class UnitTypes implements ContentList{
|
|||||||
public void update(Playerc player){
|
public void update(Playerc player){
|
||||||
if(player.timer.get(Playerc.timerAbility, healReload)){
|
if(player.timer.get(Playerc.timerAbility, healReload)){
|
||||||
if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> {
|
if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> {
|
||||||
other.entity.healBy(other.entity.maxHealth() * healPercent / 100f);
|
other.entity.heal(other.entity.maxHealth() * healPercent / 100f);
|
||||||
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal);
|
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal);
|
||||||
})){
|
})){
|
||||||
Fx.healWave.at(player);
|
Fx.healWave.at(player);
|
||||||
@@ -468,7 +468,7 @@ public class UnitTypes implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Playerc player){
|
public void update(Playerc player){
|
||||||
player.healBy(Time.delta() * 0.09f);
|
player.heal(Time.delta() * 0.09f);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -546,7 +546,7 @@ public class UnitTypes implements ContentList{
|
|||||||
Fx.heal.at(unit);
|
Fx.heal.at(unit);
|
||||||
wasHealed = true;
|
wasHealed = true;
|
||||||
}
|
}
|
||||||
unit.healBy(healAmount);
|
unit.heal(healAmount);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(wasHealed){
|
if(wasHealed){
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class EntityDefs{
|
|||||||
@EntityDef({BulletComp.class, VelComp.class, TimedComp.class})
|
@EntityDef({BulletComp.class, VelComp.class, TimedComp.class})
|
||||||
class BulletDef{}
|
class BulletDef{}
|
||||||
|
|
||||||
@EntityDef({TileComp.class})
|
@EntityDef(value = {TileComp.class}, isFinal = false)
|
||||||
class TileDef{}
|
class TileDef{}
|
||||||
|
|
||||||
@EntityDef({EffectComp.class})
|
@EntityDef({EffectComp.class})
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package mindustry.io.versions;
|
package mindustry.io.versions;
|
||||||
|
|
||||||
import arc.func.Prov;
|
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.entities.type.base.*;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Latest data: [build 81]
|
Latest data: [build 81]
|
||||||
|
|
||||||
@@ -75,7 +71,7 @@ public class LegacyTypeTable{
|
|||||||
11 = Wraith
|
11 = Wraith
|
||||||
12 = Ghoul
|
12 = Ghoul
|
||||||
13 = Revenant
|
13 = Revenant
|
||||||
*/
|
|
||||||
private static final Prov[] build81Table = {
|
private static final Prov[] build81Table = {
|
||||||
Playerc::new,
|
Playerc::new,
|
||||||
Fire::new,
|
Fire::new,
|
||||||
@@ -139,5 +135,5 @@ public class LegacyTypeTable{
|
|||||||
}else{
|
}else{
|
||||||
return build79Table;
|
return build79Table;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import arc.util.pooling.*;
|
|||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -143,7 +142,7 @@ public class Block extends BlockStorage{
|
|||||||
|
|
||||||
protected TextureRegion[] cacheRegions = {};
|
protected TextureRegion[] cacheRegions = {};
|
||||||
protected Array<String> cacheRegionStrings = new Array<>();
|
protected Array<String> cacheRegionStrings = new Array<>();
|
||||||
protected Prov<TileData> entityType = TileData::new;
|
protected Prov<Tilec> entityType = TileEntity::create;
|
||||||
|
|
||||||
protected Array<Tile> tempTiles = new Array<>();
|
protected Array<Tile> tempTiles = new Array<>();
|
||||||
protected TextureRegion[] generatedIcons;
|
protected TextureRegion[] generatedIcons;
|
||||||
@@ -631,7 +630,8 @@ public class Block extends BlockStorage{
|
|||||||
Time.run(i / 2f, () -> {
|
Time.run(i / 2f, () -> {
|
||||||
Tile other = world.tile(tile.x + Mathf.range(size / 2), tile.y + Mathf.range(size / 2));
|
Tile other = world.tile(tile.x + Mathf.range(size / 2), tile.y + Mathf.range(size / 2));
|
||||||
if(other != null){
|
if(other != null){
|
||||||
Puddle.deposit(other, liquid, splash);
|
//TODO puddle
|
||||||
|
//Puddle.deposit(other, liquid, splash);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -640,7 +640,8 @@ public class Block extends BlockStorage{
|
|||||||
|
|
||||||
Damage.dynamicExplosion(x, y, flammability, explosiveness * 3.5f, power, tilesize * size / 2f, Pal.darkFlame);
|
Damage.dynamicExplosion(x, y, flammability, explosiveness * 3.5f, power, tilesize * size / 2f, Pal.darkFlame);
|
||||||
if(!tile.floor().solid && !tile.floor().isLiquid){
|
if(!tile.floor().solid && !tile.floor().isLiquid){
|
||||||
RubbleDecal.create(tile.drawx(), tile.drawy(), size);
|
//TODO rubble decal
|
||||||
|
//RubbleDecal.create(tile.drawx(), tile.drawy(), size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,7 +856,7 @@ public class Block extends BlockStorage{
|
|||||||
return destructible || update;
|
return destructible || update;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final TileData newData(){
|
public final Tilec newEntity(){
|
||||||
return entityType.get();
|
return entityType.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,8 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
|
}else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
|
||||||
float leakAmount = tile.entity.liquids().get(liquid) / leakResistance;
|
float leakAmount = tile.entity.liquids().get(liquid) / leakResistance;
|
||||||
Puddle.deposit(next, tile, liquid, leakAmount);
|
//TODO deposit puddle
|
||||||
|
//Puddle.deposit(next, tile, liquid, leakAmount);
|
||||||
tile.entity.liquids().remove(liquid, leakAmount);
|
tile.entity.liquids().remove(liquid, leakAmount);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class Tile implements Position{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Tilec> T ent(){
|
public <T extends TileEntity> T ent(){
|
||||||
return (T)entity;
|
return (T)entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ public class Tile implements Position{
|
|||||||
|
|
||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
//TODO assign data and don't use new entity
|
//TODO assign data and don't use new entity
|
||||||
//entity = block.newEntity().init(this, block.update);
|
entity = block.newEntity().init(this, block.update);
|
||||||
entity.cons(new ConsumeModule(entity));
|
entity.cons(new ConsumeModule(entity));
|
||||||
if(block.hasItems) entity.items(new ItemModule());
|
if(block.hasItems) entity.items(new ItemModule());
|
||||||
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class BuildBlock extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BuildEntity extends Tilec{
|
public class BuildEntity extends TileEntity{
|
||||||
/**
|
/**
|
||||||
* The recipe of the block that is being constructed.
|
* The recipe of the block that is being constructed.
|
||||||
* If there is no recipe for this block, as is the case with rocks, 'previous' is used.
|
* If there is no recipe for this block, as is the case with rocks, 'previous' is used.
|
||||||
@@ -364,8 +364,8 @@ public class BuildBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
progress = stream.readFloat();
|
progress = stream.readFloat();
|
||||||
short pid = stream.readShort();
|
short pid = stream.readShort();
|
||||||
short rid = stream.readShort();
|
short rid = stream.readShort();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
@@ -40,17 +41,18 @@ public class DeflectorWall extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleBulletHit(Tilec entity, Bullet bullet){
|
public void handleBulletHit(Tilec entity, Bulletc bullet){
|
||||||
super.handleBulletHit(entity, bullet);
|
super.handleBulletHit(entity, bullet);
|
||||||
|
|
||||||
|
//TODO fix and test
|
||||||
//doesn't reflect powerful bullets
|
//doesn't reflect powerful bullets
|
||||||
if(bullet.damage() > maxDamageDeflect || bullet.isDeflected()) return;
|
if(bullet.damage() > maxDamageDeflect) return;
|
||||||
|
|
||||||
float penX = Math.abs(entity.getX() - bullet.x), penY = Math.abs(entity.getY() - bullet.y);
|
float penX = Math.abs(entity.getX() - bullet.x()), penY = Math.abs(entity.getY() - bullet.y());
|
||||||
|
|
||||||
bullet.hitbox(rect2);
|
bullet.hitbox(rect2);
|
||||||
|
|
||||||
Vec2 position = Geometry.raycastRect(bullet.x - bullet.vel().x*Time.delta(), bullet.y - bullet.vel().y*Time.delta(), bullet.x + bullet.vel().x*Time.delta(), bullet.y + bullet.vel().y*Time.delta(),
|
Vec2 position = Geometry.raycastRect(bullet.x() - bullet.vel().x*Time.delta(), bullet.y() - bullet.vel().y*Time.delta(), bullet.x() + bullet.vel().x*Time.delta(), bullet.y() + bullet.vel().y*Time.delta(),
|
||||||
rect.setSize(size * tilesize + rect2.width*2 + rect2.height*2).setCenter(entity.getX(), entity.getY()));
|
rect.setSize(size * tilesize + rect2.width*2 + rect2.height*2).setCenter(entity.getX(), entity.getY()));
|
||||||
|
|
||||||
if(position != null){
|
if(position != null){
|
||||||
@@ -64,14 +66,16 @@ public class DeflectorWall extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//bullet.updateVelocity();
|
//bullet.updateVelocity();
|
||||||
bullet.resetOwner(entity, entity.team());
|
bullet.owner(entity);
|
||||||
bullet.scaleTime(1f);
|
bullet.team(entity.team());
|
||||||
bullet.deflect();
|
bullet.time(bullet.time() + 1f);
|
||||||
|
//TODO deflect
|
||||||
|
//bullet.deflect();
|
||||||
|
|
||||||
((DeflectorEntity)entity).hit = 1f;
|
((DeflectorEntity)entity).hit = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DeflectorEntity extends Tilec{
|
public static class DeflectorEntity extends TileEntity{
|
||||||
public float hit;
|
public float hit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class Door extends Wall{
|
|||||||
Call.onDoorToggle(null, tile, !entity.open);
|
Call.onDoorToggle(null, tile, !entity.open);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DoorEntity extends Tilec{
|
public class DoorEntity extends TileEntity{
|
||||||
public boolean open = false;
|
public boolean open = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,8 +99,8 @@ public class Door extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
open = stream.readBoolean();
|
open = stream.readBoolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import arc.math.*;
|
|||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -90,8 +89,9 @@ public class ForceProjector extends Block{
|
|||||||
ForceEntity entity = tile.ent();
|
ForceEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.shield == null){
|
if(entity.shield == null){
|
||||||
entity.shield = new ShieldEntity(tile);
|
//TODO implement
|
||||||
entity.shield.add();
|
//entity.shield = new ShieldEntity(tile);
|
||||||
|
//entity.shield.add();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean phaseValid = consumes.get(ConsumeType.item).valid(tile.entity);
|
boolean phaseValid = consumes.get(ConsumeType.item).valid(tile.entity);
|
||||||
@@ -115,7 +115,7 @@ public class ForceProjector extends Block{
|
|||||||
ConsumeLiquidFilter cons = consumes.get(ConsumeType.liquid);
|
ConsumeLiquidFilter cons = consumes.get(ConsumeType.liquid);
|
||||||
if(cons.valid(entity)){
|
if(cons.valid(entity)){
|
||||||
cons.update(entity);
|
cons.update(entity);
|
||||||
scale *= (cooldownLiquid * (1f + (entity.getLiquids().current().heatCapacity - 0.4f) * 0.9f));
|
scale *= (cooldownLiquid * (1f + (entity.liquids().current().heatCapacity - 0.4f) * 0.9f));
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.buildup -= Time.delta() * scale;
|
entity.buildup -= Time.delta() * scale;
|
||||||
@@ -140,7 +140,8 @@ public class ForceProjector extends Block{
|
|||||||
paramTile = tile;
|
paramTile = tile;
|
||||||
paramEntity = entity;
|
paramEntity = entity;
|
||||||
paramBlock = this;
|
paramBlock = this;
|
||||||
bulletGroup.intersect(tile.drawx() - realRadius, tile.drawy() - realRadius, realRadius*2f, realRadius * 2f, shieldConsumer);
|
//TODO fix
|
||||||
|
//bulletGroup.intersect(tile.drawx() - realRadius, tile.drawy() - realRadius, realRadius*2f, realRadius * 2f, shieldConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
float realRadius(ForceEntity entity){
|
float realRadius(ForceEntity entity){
|
||||||
@@ -161,7 +162,7 @@ public class ForceProjector extends Block{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
class ForceEntity extends Tilec{
|
class ForceEntity extends TileEntity{
|
||||||
ShieldEntity shield;
|
ShieldEntity shield;
|
||||||
boolean broken = true;
|
boolean broken = true;
|
||||||
float buildup = 0f;
|
float buildup = 0f;
|
||||||
@@ -181,8 +182,8 @@ public class ForceProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
broken = stream.readBoolean();
|
broken = stream.readBoolean();
|
||||||
buildup = stream.readFloat();
|
buildup = stream.readFloat();
|
||||||
radscl = stream.readFloat();
|
radscl = stream.readFloat();
|
||||||
@@ -191,6 +192,14 @@ public class ForceProjector extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO fix
|
||||||
|
class ShieldEntity{
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//@EntityDef({Drawc.class})
|
||||||
|
//class ShieldDef{}
|
||||||
|
|
||||||
public class ShieldEntity extends BaseEntity implements DrawTrait{
|
public class ShieldEntity extends BaseEntity implements DrawTrait{
|
||||||
final ForceEntity entity;
|
final ForceEntity entity;
|
||||||
|
|
||||||
@@ -245,5 +254,5 @@ public class ForceProjector extends Block{
|
|||||||
public EntityGroup targetGroup(){
|
public EntityGroup targetGroup(){
|
||||||
return shieldGroup;
|
return shieldGroup;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ public class MendProjector extends Block{
|
|||||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() || tile.isEnemyCheat() ? 1f : 0f, 0.08f);
|
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() || tile.isEnemyCheat() ? 1f : 0f, 0.08f);
|
||||||
entity.charge += entity.heat * entity.delta();
|
entity.charge += entity.heat * entity.delta();
|
||||||
|
|
||||||
entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, Mathf.num(entity.cons.optionalValid()), 0.1f);
|
entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, Mathf.num(entity.cons().optionalValid()), 0.1f);
|
||||||
|
|
||||||
if(entity.cons.optionalValid() && entity.timer(timerUse, useTime) && entity.efficiency() > 0){
|
if(entity.cons().optionalValid() && entity.timer(timerUse, useTime) && entity.efficiency() > 0){
|
||||||
entity.consume();
|
entity.consume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public class MendProjector extends Block{
|
|||||||
entity.charge = 0f;
|
entity.charge = 0f;
|
||||||
|
|
||||||
indexer.eachBlock(entity, realRange, other -> other.entity.damaged(), other -> {
|
indexer.eachBlock(entity, realRange, other -> other.entity.damaged(), other -> {
|
||||||
other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat * phaseBoost) / 100f * entity.efficiency());
|
other.entity.heal(other.entity.maxHealth() * (healPercent + entity.phaseHeat * phaseBoost) / 100f * entity.efficiency());
|
||||||
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Tmp.c1.set(baseColor).lerp(phaseColor, entity.phaseHeat));
|
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Tmp.c1.set(baseColor).lerp(phaseColor, entity.phaseHeat));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class MendProjector extends Block{
|
|||||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.efficiency(), baseColor, 0.7f * tile.entity.efficiency());
|
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.efficiency(), baseColor, 0.7f * tile.entity.efficiency());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MendEntity extends Tilec{
|
class MendEntity extends TileEntity{
|
||||||
float heat;
|
float heat;
|
||||||
float charge = Mathf.random(reload);
|
float charge = Mathf.random(reload);
|
||||||
float phaseHeat;
|
float phaseHeat;
|
||||||
@@ -133,8 +133,8 @@ public class MendProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
phaseHeat = stream.readFloat();
|
phaseHeat = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class OverdriveProjector extends Block{
|
|||||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() ? 1f : 0f, 0.08f);
|
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() ? 1f : 0f, 0.08f);
|
||||||
entity.charge += entity.heat * Time.delta();
|
entity.charge += entity.heat * Time.delta();
|
||||||
|
|
||||||
entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, Mathf.num(entity.cons.optionalValid()), 0.1f);
|
entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, Mathf.num(entity.cons().optionalValid()), 0.1f);
|
||||||
|
|
||||||
if(entity.timer(timerUse, useTime) && entity.efficiency() > 0){
|
if(entity.timer(timerUse, useTime) && entity.efficiency() > 0){
|
||||||
entity.consume();
|
entity.consume();
|
||||||
@@ -118,7 +118,7 @@ public class OverdriveProjector extends Block{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
class OverdriveEntity extends Tilec{
|
class OverdriveEntity extends TileEntity{
|
||||||
float heat;
|
float heat;
|
||||||
float charge = Mathf.random(reload);
|
float charge = Mathf.random(reload);
|
||||||
float phaseHeat;
|
float phaseHeat;
|
||||||
@@ -131,8 +131,8 @@ public class OverdriveProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
phaseHeat = stream.readFloat();
|
phaseHeat = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package mindustry.world.blocks.defense;
|
package mindustry.world.blocks.defense;
|
||||||
|
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.*;
|
||||||
import arc.graphics.g2d.Fill;
|
import arc.math.*;
|
||||||
import arc.math.Mathf;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.effect.Lightning;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Layer;
|
import mindustry.graphics.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.world.*;
|
||||||
import mindustry.world.Block;
|
|
||||||
import mindustry.world.Tile;
|
|
||||||
|
|
||||||
public class ShockMine extends Block{
|
public class ShockMine extends Block{
|
||||||
public final int timerDamage = timers++;
|
public final int timerDamage = timers++;
|
||||||
|
|||||||
@@ -162,8 +162,8 @@ public class ItemTurret extends CooledTurret{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
byte amount = stream.readByte();
|
byte amount = stream.readByte();
|
||||||
for(int i = 0; i < amount; i++){
|
for(int i = 0; i < amount; i++){
|
||||||
Item item = Vars.content.item(stream.readByte());
|
Item item = Vars.content.item(stream.readByte());
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ public abstract class Turret extends Block{
|
|||||||
public abstract BulletType type();
|
public abstract BulletType type();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TurretEntity extends Tilec{
|
public static class TurretEntity extends TileEntity{
|
||||||
public Array<AmmoEntry> ammo = new Array<>();
|
public Array<AmmoEntry> ammo = new Array<>();
|
||||||
public int totalAmmo;
|
public int totalAmmo;
|
||||||
public float reload;
|
public float reload;
|
||||||
@@ -327,8 +327,8 @@ public abstract class Turret extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
if(revision == 1){
|
if(revision == 1){
|
||||||
reload = stream.readFloat();
|
reload = stream.readFloat();
|
||||||
rotation = stream.readFloat();
|
rotation = stream.readFloat();
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public class BufferedItemBridge extends ExtendingItemBridge{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
buffer.read(stream);
|
buffer.read(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float nextMax = e.nextc != null && tile.rotation() == e.nextc.tile.rotation() ? 1f - Math.max(itemSpace - e.nextc.minitem, 0) : 1f;
|
float nextMax = e.nextc != null && tile.rotation() == e.nextc.tile().rotation() ? 1f - Math.max(itemSpace - e.nextc.minitem, 0) : 1f;
|
||||||
|
|
||||||
for(int i = e.len - 1; i >= 0; i--){
|
for(int i = e.len - 1; i >= 0; i--){
|
||||||
float nextpos = (i == e.len - 1 ? 100f : e.ys[i + 1]) - itemSpace;
|
float nextpos = (i == e.len - 1 ? 100f : e.ys[i + 1]) - itemSpace;
|
||||||
@@ -197,7 +197,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
e.nextc.xs[e.nextc.lastInserted] = e.xs[i];
|
e.nextc.xs[e.nextc.lastInserted] = e.xs[i];
|
||||||
}
|
}
|
||||||
//remove last item
|
//remove last item
|
||||||
e.items.remove(e.ids[i], e.len - i);
|
e.items().remove(e.ids[i], e.len - i);
|
||||||
e.len = Math.min(i, e.len);
|
e.len = Math.min(i, e.len);
|
||||||
}else if(e.ys[i] < e.minitem){
|
}else if(e.ys[i] < e.minitem){
|
||||||
e.minitem = e.ys[i];
|
e.minitem = e.ys[i];
|
||||||
@@ -244,7 +244,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.items.remove(item, removed);
|
e.items().remove(item, removed);
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
@@ -255,13 +255,13 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int acceptStack(Item item, int amount, Tile tile, Unitc source){
|
public int acceptStack(Item item, int amount, Tile tile, Teamc source){
|
||||||
ConveyorEntity entity = tile.ent();
|
ConveyorEntity entity = tile.ent();
|
||||||
return Math.min((int)(entity.minitem / itemSpace), amount);
|
return Math.min((int)(entity.minitem / itemSpace), amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleStack(Item item, int amount, Tile tile, Unitc source){
|
public void handleStack(Item item, int amount, Tile tile, Teamc source){
|
||||||
ConveyorEntity e = tile.ent();
|
ConveyorEntity e = tile.ent();
|
||||||
|
|
||||||
for(int i = amount - 1; i >= 0; i--){
|
for(int i = amount - 1; i >= 0; i--){
|
||||||
@@ -269,7 +269,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
e.xs[0] = 0;
|
e.xs[0] = 0;
|
||||||
e.ys[0] = i * itemSpace;
|
e.ys[0] = i * itemSpace;
|
||||||
e.ids[0] = item;
|
e.ids[0] = item;
|
||||||
e.items.add(item, 1);
|
e.items().add(item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.noSleep();
|
e.noSleep();
|
||||||
@@ -293,7 +293,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
float x = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
float x = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
||||||
|
|
||||||
e.noSleep();
|
e.noSleep();
|
||||||
e.items.add(item, 1);
|
e.items().add(item, 1);
|
||||||
|
|
||||||
if(Math.abs(source.relativeTo(tile.x, tile.y) - r) == 0){ //idx = 0
|
if(Math.abs(source.relativeTo(tile.x, tile.y) - r) == 0){ //idx = 0
|
||||||
e.add(0);
|
e.add(0);
|
||||||
@@ -308,7 +308,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConveyorEntity extends Tilec{
|
public static class ConveyorEntity extends TileEntity{
|
||||||
//parallel array data
|
//parallel array data
|
||||||
Item[] ids = new Item[capacity];
|
Item[] ids = new Item[capacity];
|
||||||
float[] xs = new float[capacity];
|
float[] xs = new float[capacity];
|
||||||
@@ -360,8 +360,8 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
int amount = stream.readInt();
|
int amount = stream.readInt();
|
||||||
len = Math.min(amount, capacity);
|
len = Math.min(amount, capacity);
|
||||||
|
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ public class ItemBridge extends Block{
|
|||||||
return other.block() == this && (!checkDouble || other.<ItemBridgeEntity>ent().link != tile.pos());
|
return other.block() == this && (!checkDouble || other.<ItemBridgeEntity>ent().link != tile.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ItemBridgeEntity extends Tilec{
|
public static class ItemBridgeEntity extends TileEntity{
|
||||||
public int link = Pos.invalid;
|
public int link = Pos.invalid;
|
||||||
public IntSet incoming = new IntSet();
|
public IntSet incoming = new IntSet();
|
||||||
public float uptime;
|
public float uptime;
|
||||||
@@ -389,8 +389,8 @@ public class ItemBridge extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
link = stream.readInt();
|
link = stream.readInt();
|
||||||
uptime = stream.readFloat();
|
uptime = stream.readFloat();
|
||||||
byte links = stream.readByte();
|
byte links = stream.readByte();
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class Junction extends Block{
|
|||||||
return to != null && to.link().entity != null && to.team() == tile.team();
|
return to != null && to.link().entity != null && to.team() == tile.team();
|
||||||
}
|
}
|
||||||
|
|
||||||
class JunctionEntity extends Tilec{
|
class JunctionEntity extends TileEntity{
|
||||||
DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity, speed);
|
DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity, speed);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,8 +96,8 @@ public class Junction extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
buffer.read(stream);
|
buffer.read(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MassDriverEntity extends Tilec{
|
public class MassDriverEntity extends TileEntity{
|
||||||
int link = -1;
|
int link = -1;
|
||||||
float rotation = 90;
|
float rotation = 90;
|
||||||
float reload = 0f;
|
float reload = 0f;
|
||||||
@@ -340,8 +340,8 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
link = stream.readInt();
|
link = stream.readInt();
|
||||||
rotation = stream.readFloat();
|
rotation = stream.readFloat();
|
||||||
state = DriverState.values()[stream.readByte()];
|
state = DriverState.values()[stream.readByte()];
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class OverflowGate extends Block{
|
|||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OverflowGateEntity extends Tilec{
|
public class OverflowGateEntity extends TileEntity{
|
||||||
Item lastItem;
|
Item lastItem;
|
||||||
Tile lastInput;
|
Tile lastInput;
|
||||||
float time;
|
float time;
|
||||||
@@ -129,8 +129,8 @@ public class OverflowGate extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
if(revision == 1){
|
if(revision == 1){
|
||||||
new DirectionalItemBuffer(25, 50f).read(stream);
|
new DirectionalItemBuffer(25, 50f).read(stream);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class Router extends Block{
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RouterEntity extends Tilec{
|
public class RouterEntity extends TileEntity{
|
||||||
Item lastItem;
|
Item lastItem;
|
||||||
Tile lastInput;
|
Tile lastInput;
|
||||||
float time;
|
float time;
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class Sorter extends Block{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SorterEntity extends Tilec{
|
public class SorterEntity extends TileEntity{
|
||||||
@Nullable Item sortItem;
|
@Nullable Item sortItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -159,8 +159,8 @@ public class Sorter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
sortItem = content.item(stream.readShort());
|
sortItem = content.item(stream.readShort());
|
||||||
if(revision == 1){
|
if(revision == 1){
|
||||||
new DirectionalItemBuffer(20, 45f).read(stream);
|
new DirectionalItemBuffer(20, 45f).read(stream);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import arc.struct.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
@@ -128,7 +129,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConduitEntity extends Tilec{
|
public static class ConduitEntity extends TileEntity{
|
||||||
public float smoothLiquid;
|
public float smoothLiquid;
|
||||||
|
|
||||||
int blendbits;
|
int blendbits;
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class MessageBlock extends Block{
|
|||||||
table.setPosition(pos.x, pos.y, Align.bottom);
|
table.setPosition(pos.x, pos.y, Align.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MessageBlockEntity extends Tilec{
|
public class MessageBlockEntity extends TileEntity{
|
||||||
public String message = "";
|
public String message = "";
|
||||||
public String[] lines = {""};
|
public String[] lines = {""};
|
||||||
|
|
||||||
@@ -157,8 +157,8 @@ public class MessageBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
message = stream.readUTF();
|
message = stream.readUTF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,8 +171,8 @@ public class ImpactReactor extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
warmup = stream.readFloat();
|
warmup = stream.readFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class LightBlock extends Block{
|
|||||||
renderer.lights.add(tile.drawx(), tile.drawy(), radius, Tmp.c1.set(entity.color), brightness * tile.entity.efficiency());
|
renderer.lights.add(tile.drawx(), tile.drawy(), radius, Tmp.c1.set(entity.color), brightness * tile.entity.efficiency());
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LightEntity extends Tilec{
|
public class LightEntity extends TileEntity{
|
||||||
public int color = Pal.accent.rgba();
|
public int color = Pal.accent.rgba();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -87,8 +87,8 @@ public class LightBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
color = stream.readInt();
|
color = stream.readInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,8 +192,8 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class PowerGenerator extends PowerDistributor{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GeneratorEntity extends Tilec{
|
public static class GeneratorEntity extends TileEntity{
|
||||||
public float generateTime;
|
public float generateTime;
|
||||||
/** The efficiency of the producer. An efficiency of 1.0 means 100% */
|
/** The efficiency of the producer. An efficiency of 1.0 means 100% */
|
||||||
public float productionEfficiency = 0.0f;
|
public float productionEfficiency = 0.0f;
|
||||||
@@ -65,8 +65,8 @@ public class PowerGenerator extends PowerDistributor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
productionEfficiency = stream.readFloat();
|
productionEfficiency = stream.readFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ public class Cultivator extends GenericCrafter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
warmup = stream.readFloat();
|
warmup = stream.readFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ public class Drill extends Block{
|
|||||||
return drops != null && drops.hardness <= tier;
|
return drops != null && drops.hardness <= tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DrillEntity extends Tilec{
|
public static class DrillEntity extends TileEntity{
|
||||||
float progress;
|
float progress;
|
||||||
int index;
|
int index;
|
||||||
float warmup;
|
float warmup;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class GenericCrafter extends Block{
|
|||||||
return itemCapacity;
|
return itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GenericCrafterEntity extends Tilec{
|
public static class GenericCrafterEntity extends TileEntity{
|
||||||
public float progress;
|
public float progress;
|
||||||
public float totalProgress;
|
public float totalProgress;
|
||||||
public float warmup;
|
public float warmup;
|
||||||
@@ -158,8 +158,8 @@ public class GenericCrafter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
progress = stream.readFloat();
|
progress = stream.readFloat();
|
||||||
warmup = stream.readFloat();
|
warmup = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class Incinerator extends Block{
|
|||||||
return entity.heat > 0.5f;
|
return entity.heat > 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IncineratorEntity extends Tilec{
|
public static class IncineratorEntity extends TileEntity{
|
||||||
public float heat;
|
public float heat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class SolidPump extends Pump{
|
|||||||
return tile.entity.liquids().total();
|
return tile.entity.liquids().total();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SolidPumpEntity extends Tilec{
|
public static class SolidPumpEntity extends TileEntity{
|
||||||
public float warmup;
|
public float warmup;
|
||||||
public float pumpTime;
|
public float pumpTime;
|
||||||
public float boost;
|
public float boost;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class ItemSource extends Block{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ItemSourceEntity extends Tilec{
|
public class ItemSourceEntity extends TileEntity{
|
||||||
Item outputItem;
|
Item outputItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,8 +107,8 @@ public class ItemSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
outputItem = content.item(stream.readShort());
|
outputItem = content.item(stream.readShort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class LiquidSource extends Block{
|
|||||||
tile.<LiquidSourceEntity>ent().source = value == -1 ? null : content.liquid(value);
|
tile.<LiquidSourceEntity>ent().source = value == -1 ? null : content.liquid(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
class LiquidSourceEntity extends Tilec{
|
class LiquidSourceEntity extends TileEntity{
|
||||||
public @Nullable Liquid source = null;
|
public @Nullable Liquid source = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,8 +127,8 @@ public class LiquidSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
byte id = stream.readByte();
|
byte id = stream.readByte();
|
||||||
source = id == -1 ? null : content.liquid(id);
|
source = id == -1 ? null : content.liquid(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
return entity.spawnPlayer != null;
|
return entity.spawnPlayer != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CoreEntity extends Tilec{
|
public class CoreEntity extends TileEntity{
|
||||||
protected Playerc spawnPlayer;
|
protected Playerc spawnPlayer;
|
||||||
protected float progress;
|
protected float progress;
|
||||||
protected float time;
|
protected float time;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public abstract class StorageBlock extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StorageBlockEntity extends Tilec{
|
public class StorageBlockEntity extends TileEntity{
|
||||||
protected @Nullable
|
protected @Nullable
|
||||||
Tile linkedCore;
|
Tile linkedCore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class Unloader extends Block{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnloaderEntity extends Tilec{
|
public static class UnloaderEntity extends TileEntity{
|
||||||
public Item sortItem = null;
|
public Item sortItem = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,8 +144,8 @@ public class Unloader extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
byte id = stream.readByte();
|
byte id = stream.readByte();
|
||||||
sortItem = id == -1 ? null : content.items().get(id);
|
sortItem = id == -1 ? null : content.items().get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class CommandCenter extends Block{
|
|||||||
Events.fire(new CommandIssueEvent(tile, command));
|
Events.fire(new CommandIssueEvent(tile, command));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CommandCenterEntity extends Tilec{
|
public class CommandCenterEntity extends TileEntity{
|
||||||
public UnitCommand command = UnitCommand.attack;
|
public UnitCommand command = UnitCommand.attack;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -133,29 +133,13 @@ public class MechPad extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MechFactoryEntity extends Tilec implements SpawnerTrait{
|
public class MechFactoryEntity extends TileEntity{
|
||||||
Playerc player;
|
Playerc player;
|
||||||
boolean sameMech;
|
boolean sameMech;
|
||||||
float progress;
|
float progress;
|
||||||
float time;
|
float time;
|
||||||
float heat;
|
float heat;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasUnit(Unitc unit){
|
|
||||||
return unit == player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSpawning(Playerc unit){
|
|
||||||
if(player == null){
|
|
||||||
progress = 0f;
|
|
||||||
player = unit;
|
|
||||||
sameMech = true;
|
|
||||||
|
|
||||||
player.beginRespawning(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
super.write(stream);
|
super.write(stream);
|
||||||
@@ -165,8 +149,8 @@ public class MechPad extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
progress = stream.readFloat();
|
progress = stream.readFloat();
|
||||||
time = stream.readFloat();
|
time = stream.readFloat();
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class RepairPoint extends Block{
|
|||||||
return entity.target != null;
|
return entity.target != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RepairPointEntity extends Tilec{
|
public class RepairPointEntity extends TileEntity{
|
||||||
public Unitc target;
|
public Unitc target;
|
||||||
public float strength, rotation = 90;
|
public float strength, rotation = 90;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public class UnitFactory extends Block{
|
|||||||
return entity.spawned < maxSpawn;
|
return entity.spawned < maxSpawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnitFactoryEntity extends Tilec{
|
public static class UnitFactoryEntity extends TileEntity{
|
||||||
float buildTime;
|
float buildTime;
|
||||||
float time;
|
float time;
|
||||||
float speedScl;
|
float speedScl;
|
||||||
@@ -198,8 +198,8 @@ public class UnitFactory extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream);
|
||||||
buildTime = stream.readFloat();
|
buildTime = stream.readFloat();
|
||||||
spawned = stream.readInt();
|
spawned = stream.readInt();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||||||
assertTrue(generator.acceptLiquid(tile, null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
|
assertTrue(generator.acceptLiquid(tile, null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
|
||||||
|
|
||||||
entity.liquids().add(liquid, availableLiquidAmount);
|
entity.liquids().add(liquid, availableLiquidAmount);
|
||||||
entity.cons.update();
|
entity.cons().update();
|
||||||
|
|
||||||
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
|
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
|
||||||
generator.update(tile);
|
generator.update(tile);
|
||||||
@@ -132,7 +132,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||||||
if(amount > 0){
|
if(amount > 0){
|
||||||
entity.items().add(item, amount);
|
entity.items().add(item, amount);
|
||||||
}
|
}
|
||||||
entity.cons.update();
|
entity.cons().update();
|
||||||
|
|
||||||
// Perform an update on the generator once - This should use up one or zero items - dependent on if the item is accepted and available or not.
|
// Perform an update on the generator once - This should use up one or zero items - dependent on if the item is accepted and available or not.
|
||||||
try{
|
try{
|
||||||
@@ -163,7 +163,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||||||
|
|
||||||
// Burn a single coal and test for the duration
|
// Burn a single coal and test for the duration
|
||||||
entity.items().add(Items.coal, 1);
|
entity.items().add(Items.coal, 1);
|
||||||
entity.cons.update();
|
entity.cons().update();
|
||||||
generator.update(tile);
|
generator.update(tile);
|
||||||
|
|
||||||
float expectedEfficiency = entity.productionEfficiency;
|
float expectedEfficiency = entity.productionEfficiency;
|
||||||
|
|||||||
Reference in New Issue
Block a user