Read-only component fields / Removed get/set prefix
This commit is contained in:
@@ -176,7 +176,7 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
public void onProximityRemoved(Tile tile){
|
||||
if(tile.entity.getPower() != null){
|
||||
if(tile.entity.power() != null){
|
||||
tile.block().powerGraphRemoved(tile);
|
||||
}
|
||||
}
|
||||
@@ -189,41 +189,41 @@ public class Block extends BlockStorage{
|
||||
Tilec entity = tile.ent();
|
||||
|
||||
for(Tile other : getPowerConnections(tile, tempTiles)){
|
||||
if(other.entity.getPower() != null){
|
||||
other.entity.getPower().graph.add(entity.getPower().graph);
|
||||
if(other.entity.power() != null){
|
||||
other.entity.power().graph.add(entity.power().graph);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void powerGraphRemoved(Tile tile){
|
||||
if(tile.entity == null || tile.entity.getPower() == null){
|
||||
if(tile.entity == null || tile.entity.power() == null){
|
||||
return;
|
||||
}
|
||||
|
||||
tile.entity.getPower().graph.remove(tile);
|
||||
for(int i = 0; i < tile.entity.getPower().links.size; i++){
|
||||
Tile other = world.tile(tile.entity.getPower().links.get(i));
|
||||
if(other != null && other.entity != null && other.entity.getPower() != null){
|
||||
other.entity.getPower().links.removeValue(tile.pos());
|
||||
tile.entity.power().graph.remove(tile);
|
||||
for(int i = 0; i < tile.entity.power().links.size; i++){
|
||||
Tile other = world.tile(tile.entity.power().links.get(i));
|
||||
if(other != null && other.entity != null && other.entity.power() != null){
|
||||
other.entity.power().links.removeValue(tile.pos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Array<Tile> getPowerConnections(Tile tile, Array<Tile> out){
|
||||
out.clear();
|
||||
if(tile == null || tile.entity == null || tile.entity.getPower() == null) return out;
|
||||
if(tile == null || tile.entity == null || tile.entity.power() == null) return out;
|
||||
|
||||
for(Tile other : tile.entity.proximity()){
|
||||
if(other != null && other.entity != null && other.entity.getPower() != null
|
||||
if(other != null && other.entity != null && other.entity.power() != null
|
||||
&& !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower)
|
||||
&& !tile.entity.getPower().links.contains(other.pos())){
|
||||
&& !tile.entity.power().links.contains(other.pos())){
|
||||
out.add(other);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < tile.entity.getPower().links.size; i++){
|
||||
Tile link = world.tile(tile.entity.getPower().links.get(i));
|
||||
if(link != null && link.entity != null && link.entity.getPower() != null) out.add(link);
|
||||
for(int i = 0; i < tile.entity.power().links.size; i++){
|
||||
Tile link = world.tile(tile.entity.power().links.get(i));
|
||||
if(link != null && link.entity != null && link.entity.power() != null) out.add(link);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -300,8 +300,8 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
public void drawLight(Tile tile){
|
||||
if(tile.entity != null && hasLiquids && drawLiquidLight && tile.entity.getLiquids().current().lightColor.a > 0.001f){
|
||||
drawLiquidLight(tile, tile.entity.getLiquids().current(), tile.entity.getLiquids().smoothAmount());
|
||||
if(tile.entity != null && hasLiquids && drawLiquidLight && tile.entity.liquids().current().lightColor.a > 0.001f){
|
||||
drawLiquidLight(tile, tile.entity.liquids().current(), tile.entity.liquids().smoothAmount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,14 +339,14 @@ public class Block extends BlockStorage{
|
||||
Geometry.circle(tile.x, tile.y, range, (x, y) -> {
|
||||
Tile other = world.ltile(x, y);
|
||||
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, tile) && !PowerNode.insulated(other, tile) && !other.entity.proximity().contains(tile) &&
|
||||
!(outputsPower && tile.entity.proximity().contains(p -> p.entity != null && p.entity.getPower() != null && p.entity.getPower().graph == other.entity.getPower().graph))){
|
||||
!(outputsPower && tile.entity.proximity().contains(p -> p.entity != null && p.entity.power() != null && p.entity.power().graph == other.entity.power().graph))){
|
||||
tempTiles.add(other);
|
||||
}
|
||||
});
|
||||
tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile)));
|
||||
if(!tempTiles.isEmpty()){
|
||||
Tile toLink = tempTiles.first();
|
||||
if(!toLink.entity.getPower().links.contains(tile.pos())){
|
||||
if(!toLink.entity.power().links.contains(tile.pos())){
|
||||
toLink.configureAny(tile.pos());
|
||||
}
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public class Block extends BlockStorage{
|
||||
/** Call when some content is produced. This unlocks the content if it is applicable. */
|
||||
public void useContent(Tile tile, UnlockableContent content){
|
||||
//only unlocks content in zones
|
||||
if(!headless && tile.getTeam() == player.getTeam() && world.isZone()){
|
||||
if(!headless && tile.getTeam() == player.team() && world.isZone()){
|
||||
logic.handleContent(content);
|
||||
}
|
||||
}
|
||||
@@ -547,10 +547,10 @@ public class Block extends BlockStorage{
|
||||
Liquid liquid = consumes.<ConsumeLiquid>get(ConsumeType.liquid).liquid;
|
||||
current = entity -> liquid;
|
||||
}else{
|
||||
current = entity -> entity.getLiquids().current();
|
||||
current = entity -> entity.liquids().current();
|
||||
}
|
||||
bars.add("liquid", entity -> new Bar(() -> entity.getLiquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
|
||||
() -> current.get(entity).barColor(), () -> entity.getLiquids().get(current.get(entity)) / liquidCapacity));
|
||||
bars.add("liquid", entity -> new Bar(() -> entity.liquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
|
||||
() -> current.get(entity).barColor(), () -> entity.liquids().get(current.get(entity)) / liquidCapacity));
|
||||
}
|
||||
|
||||
if(hasPower && consumes.hasPower()){
|
||||
@@ -558,12 +558,12 @@ public class Block extends BlockStorage{
|
||||
boolean buffered = cons.buffered;
|
||||
float capacity = cons.capacity;
|
||||
|
||||
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.getPower().status * capacity) ? "<ERROR>" : (int)(entity.getPower().status * capacity)) :
|
||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.getPower().graph.getPowerProduced() + entity.getPower().graph.getBatteryStored() > 0f ? 1f : entity.getPower().status));
|
||||
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power().status * capacity) ? "<ERROR>" : (int)(entity.power().status * capacity)) :
|
||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power().graph.getPowerProduced() + entity.power().graph.getBatteryStored() > 0f ? 1f : entity.power().status));
|
||||
}
|
||||
|
||||
if(hasItems && configurable){
|
||||
bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.getItems().total()), () -> Pal.items, () -> (float)entity.getItems().total() / itemCapacity));
|
||||
bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items().total()), () -> Pal.items, () -> (float)entity.items().total() / itemCapacity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,24 +608,24 @@ public class Block extends BlockStorage{
|
||||
|
||||
if(hasItems){
|
||||
for(Item item : content.items()){
|
||||
int amount = tile.entity.getItems().get(item);
|
||||
int amount = tile.entity.items().get(item);
|
||||
explosiveness += item.explosiveness * amount;
|
||||
flammability += item.flammability * amount;
|
||||
}
|
||||
}
|
||||
|
||||
if(hasLiquids){
|
||||
flammability += tile.entity.getLiquids().sum((liquid, amount) -> liquid.explosiveness * amount / 2f);
|
||||
explosiveness += tile.entity.getLiquids().sum((liquid, amount) -> liquid.flammability * amount / 2f);
|
||||
flammability += tile.entity.liquids().sum((liquid, amount) -> liquid.explosiveness * amount / 2f);
|
||||
explosiveness += tile.entity.liquids().sum((liquid, amount) -> liquid.flammability * amount / 2f);
|
||||
}
|
||||
|
||||
if(consumes.hasPower() && consumes.getPower().buffered){
|
||||
power += tile.entity.getPower().status * consumes.getPower().capacity;
|
||||
power += tile.entity.power().status * consumes.getPower().capacity;
|
||||
}
|
||||
|
||||
if(hasLiquids){
|
||||
|
||||
tile.entity.getLiquids().each((liquid, amount) -> {
|
||||
tile.entity.liquids().each((liquid, amount) -> {
|
||||
float splash = Mathf.clamp(amount / 4f, 0f, 10f);
|
||||
|
||||
for(int i = 0; i < Mathf.clamp(amount / 5, 0, 30); i++){
|
||||
@@ -656,10 +656,10 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
return 0;
|
||||
}else{
|
||||
float result = tile.entity.getItems().sum((item, amount) -> item.flammability * amount);
|
||||
float result = tile.entity.items().sum((item, amount) -> item.flammability * amount);
|
||||
|
||||
if(hasLiquids){
|
||||
result += tile.entity.getLiquids().sum((liquid, amount) -> liquid.flammability * amount / 3f);
|
||||
result += tile.entity.liquids().sum((liquid, amount) -> liquid.flammability * amount / 3f);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -9,7 +9,6 @@ import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -49,8 +48,8 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
|
||||
/** Returns the amount of items this block can accept. */
|
||||
public int acceptStack(Item item, int amount, Tile tile, Teamc source){
|
||||
if(acceptItem(item, tile, tile) && hasItems && (source == null || source.getTeam() == tile.getTeam())){
|
||||
return Math.min(getMaximumAccepted(tile, item) - tile.entity.getItems().get(item), amount);
|
||||
if(acceptItem(item, tile, tile) && hasItems && (source == null || source.team() == tile.getTeam())){
|
||||
return Math.min(getMaximumAccepted(tile, item) - tile.entity.items().get(item), amount);
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
@@ -62,17 +61,17 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
|
||||
/** Remove a stack from this inventory, and return the amount removed. */
|
||||
public int removeStack(Tile tile, Item item, int amount){
|
||||
if(tile.entity == null || tile.entity.getItems() == null) return 0;
|
||||
amount = Math.min(amount, tile.entity.getItems().get(item));
|
||||
if(tile.entity == null || tile.entity.items() == null) return 0;
|
||||
amount = Math.min(amount, tile.entity.items().get(item));
|
||||
tile.entity.noSleep();
|
||||
tile.entity.getItems().remove(item, amount);
|
||||
tile.entity.items().remove(item, amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
/** Handle a stack input. */
|
||||
public void handleStack(Item item, int amount, Tile tile, Teamc source){
|
||||
tile.entity.noSleep();
|
||||
tile.entity.getItems().add(item, amount);
|
||||
tile.entity.items().add(item, amount);
|
||||
}
|
||||
|
||||
public boolean outputsItems(){
|
||||
@@ -89,19 +88,19 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
tile.entity.getItems().add(item, 1);
|
||||
tile.entity.items().add(item, 1);
|
||||
}
|
||||
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return consumes.itemFilters.get(item.id) && tile.entity.getItems().get(item) < getMaximumAccepted(tile, item);
|
||||
return consumes.itemFilters.get(item.id) && tile.entity.items().get(item) < getMaximumAccepted(tile, item);
|
||||
}
|
||||
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return hasLiquids && tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && consumes.liquidfilters.get(liquid.id);
|
||||
return hasLiquids && tile.entity.liquids().get(liquid) + amount < liquidCapacity && consumes.liquidfilters.get(liquid.id);
|
||||
}
|
||||
|
||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
tile.entity.getLiquids().add(liquid, amount);
|
||||
tile.entity.liquids().add(liquid, amount);
|
||||
}
|
||||
|
||||
public void tryDumpLiquid(Tile tile, Liquid liquid){
|
||||
@@ -115,9 +114,9 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
|
||||
other = other.block().getLiquidDestination(other, in, liquid);
|
||||
|
||||
if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.getLiquids() != null){
|
||||
float ofract = other.entity.getLiquids().get(liquid) / other.block().liquidCapacity;
|
||||
float fract = tile.entity.getLiquids().get(liquid) / liquidCapacity;
|
||||
if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids() != null){
|
||||
float ofract = other.entity.liquids().get(liquid) / other.block().liquidCapacity;
|
||||
float fract = tile.entity.liquids().get(liquid) / liquidCapacity;
|
||||
|
||||
if(ofract < fract) tryMoveLiquid(tile, in, other, (fract - ofract) * liquidCapacity / 2f, liquid);
|
||||
}
|
||||
@@ -130,11 +129,11 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
|
||||
public void tryMoveLiquid(Tile tile, Tile tileSource, Tile next, float amount, Liquid liquid){
|
||||
float flow = Math.min(next.block().liquidCapacity - next.entity.getLiquids().get(liquid) - 0.001f, amount);
|
||||
float flow = Math.min(next.block().liquidCapacity - next.entity.liquids().get(liquid) - 0.001f, amount);
|
||||
|
||||
if(next.block().acceptLiquid(next, tileSource, liquid, flow)){
|
||||
next.block().handleLiquid(next, tileSource, liquid, flow);
|
||||
tile.entity.getLiquids().remove(liquid, flow);
|
||||
tile.entity.liquids().remove(liquid, flow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,20 +147,20 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
next = next.link();
|
||||
next = next.block().getLiquidDestination(next, tile, liquid);
|
||||
|
||||
if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.getLiquids().get(liquid) > 0f){
|
||||
if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.liquids().get(liquid) > 0f){
|
||||
|
||||
if(next.block().acceptLiquid(next, tile, liquid, 0f)){
|
||||
float ofract = next.entity.getLiquids().get(liquid) / next.block().liquidCapacity;
|
||||
float fract = tile.entity.getLiquids().get(liquid) / liquidCapacity * liquidPressure;
|
||||
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (liquidCapacity), tile.entity.getLiquids().get(liquid));
|
||||
flow = Math.min(flow, next.block().liquidCapacity - next.entity.getLiquids().get(liquid) - 0.001f);
|
||||
float ofract = next.entity.liquids().get(liquid) / next.block().liquidCapacity;
|
||||
float fract = tile.entity.liquids().get(liquid) / liquidCapacity * liquidPressure;
|
||||
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (liquidCapacity), tile.entity.liquids().get(liquid));
|
||||
flow = Math.min(flow, next.block().liquidCapacity - next.entity.liquids().get(liquid) - 0.001f);
|
||||
|
||||
if(flow > 0f && ofract <= fract && next.block().acceptLiquid(next, tile, liquid, flow)){
|
||||
next.block().handleLiquid(next, tile, liquid, flow);
|
||||
tile.entity.getLiquids().remove(liquid, flow);
|
||||
tile.entity.liquids().remove(liquid, flow);
|
||||
return flow;
|
||||
}else if(ofract > 0.1f && fract > 0.1f){
|
||||
Liquid other = next.entity.getLiquids().current();
|
||||
Liquid other = next.entity.liquids().current();
|
||||
if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){
|
||||
tile.entity.damage(1 * Time.delta());
|
||||
next.entity.damage(1 * Time.delta());
|
||||
@@ -169,7 +168,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
Fx.fire.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
|
||||
}
|
||||
}else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){
|
||||
tile.entity.getLiquids().remove(liquid, Math.min(tile.entity.getLiquids().get(liquid), 0.7f * Time.delta()));
|
||||
tile.entity.liquids().remove(liquid, Math.min(tile.entity.liquids().get(liquid), 0.7f * Time.delta()));
|
||||
if(Mathf.chance(0.2f * Time.delta())){
|
||||
Fx.steam.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
|
||||
}
|
||||
@@ -177,9 +176,9 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
}else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
|
||||
float leakAmount = tile.entity.getLiquids().get(liquid) / leakResistance;
|
||||
float leakAmount = tile.entity.liquids().get(liquid) / leakResistance;
|
||||
Puddle.deposit(next, tile, liquid, leakAmount);
|
||||
tile.entity.getLiquids().remove(liquid, leakAmount);
|
||||
tile.entity.liquids().remove(liquid, leakAmount);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -220,7 +219,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
*/
|
||||
public boolean tryDump(Tile tile, Item todump){
|
||||
Tilec entity = tile.entity;
|
||||
if(entity == null || !hasItems || tile.entity.getItems().total() == 0 || (todump != null && !entity.getItems().has(todump)))
|
||||
if(entity == null || !hasItems || tile.entity.items().total() == 0 || (todump != null && !entity.items().has(todump)))
|
||||
return false;
|
||||
|
||||
Array<Tile> proximity = entity.proximity();
|
||||
@@ -237,9 +236,9 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
for(int ii = 0; ii < Vars.content.items().size; ii++){
|
||||
Item item = Vars.content.item(ii);
|
||||
|
||||
if(other.getTeam() == tile.getTeam() && entity.getItems().has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
||||
if(other.getTeam() == tile.getTeam() && entity.items().has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
||||
other.block().handleItem(item, other, in);
|
||||
tile.entity.getItems().remove(item, 1);
|
||||
tile.entity.items().remove(item, 1);
|
||||
incrementDump(tile, proximity.size);
|
||||
return true;
|
||||
}
|
||||
@@ -248,7 +247,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
|
||||
if(other.getTeam() == tile.getTeam() && other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){
|
||||
other.block().handleItem(todump, other, in);
|
||||
tile.entity.getItems().remove(todump, 1);
|
||||
tile.entity.items().remove(todump, 1);
|
||||
incrementDump(tile, proximity.size);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -455,12 +455,12 @@ public class Tile implements Position{
|
||||
if(block.hasEntity()){
|
||||
//TODO assign data and don't use new entity
|
||||
entity = block.newEntity().init(this, block.update);
|
||||
entity.setCons(new ConsumeModule(entity));
|
||||
if(block.hasItems) entity.setItems(new ItemModule());
|
||||
if(block.hasLiquids) entity.setLiquids(new LiquidModule());
|
||||
entity.cons(new ConsumeModule(entity));
|
||||
if(block.hasItems) entity.items(new ItemModule());
|
||||
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
||||
if(block.hasPower){
|
||||
entity.setPower(new PowerModule());
|
||||
entity.getPower().graph.add(this);
|
||||
entity.power(new PowerModule());
|
||||
entity.power().graph.add(this);
|
||||
}
|
||||
|
||||
if(!world.isGenerating()){
|
||||
@@ -511,7 +511,7 @@ public class Tile implements Position{
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void onTileDamage(Tile tile, float health){
|
||||
if(tile.entity != null){
|
||||
tile.entity.setHealth(health);
|
||||
tile.entity.health(health);
|
||||
|
||||
if(tile.entity.damaged()){
|
||||
indexer.notifyTileDamaged(tile.entity);
|
||||
|
||||
@@ -9,13 +9,11 @@ import arc.math.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -228,7 +226,7 @@ public class BuildBlock extends Block{
|
||||
setConstruct(previous, cblock);
|
||||
}
|
||||
|
||||
float maxProgress = core == null ? amount : checkRequired(core.getItems(), amount, false);
|
||||
float maxProgress = core == null ? amount : checkRequired(core.items(), amount, false);
|
||||
|
||||
for(int i = 0; i < cblock.requirements.length; i++){
|
||||
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
||||
@@ -236,13 +234,13 @@ public class BuildBlock extends Block{
|
||||
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
||||
}
|
||||
|
||||
maxProgress = core == null ? maxProgress : checkRequired(core.getItems(), maxProgress, true);
|
||||
maxProgress = core == null ? maxProgress : checkRequired(core.items(), maxProgress, true);
|
||||
|
||||
progress = Mathf.clamp(progress + maxProgress);
|
||||
builderID = builder.getId();
|
||||
|
||||
if(progress >= 1f || state.rules.infiniteResources){
|
||||
constructed(tile, cblock, builderID, tile.rotation(), builder.getTeam(), configured);
|
||||
constructed(tile, cblock, builderID, tile.rotation(), builder.team(), configured);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class LiquidBlock extends Block{
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
LiquidModule mod = tile.entity.getLiquids();
|
||||
LiquidModule mod = tile.entity.liquids();
|
||||
|
||||
int rotation = rotate ? tile.rotation() * 90 : 0;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SurgeWall extends Wall{
|
||||
public void handleBulletHit(Tilec entity, Bullet bullet){
|
||||
super.handleBulletHit(entity, bullet);
|
||||
if(Mathf.chance(lightningChance)){
|
||||
Lightning.create(entity.getTeam(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength);
|
||||
Lightning.create(entity.team(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -37,7 +36,7 @@ public class CooledTurret extends Turret{
|
||||
|
||||
@Override
|
||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
if(tile.entity.getLiquids().currentAmount() <= 0.001f){
|
||||
if(tile.entity.liquids().currentAmount() <= 0.001f){
|
||||
Events.fire(Trigger.turretCool);
|
||||
}
|
||||
|
||||
@@ -51,11 +50,11 @@ public class CooledTurret extends Turret{
|
||||
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
||||
|
||||
TurretEntity entity = tile.ent();
|
||||
Liquid liquid = entity.getLiquids().current();
|
||||
Liquid liquid = entity.liquids().current();
|
||||
|
||||
float used = Math.min(Math.min(entity.getLiquids().get(liquid), maxUsed * Time.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed(tile);
|
||||
float used = Math.min(Math.min(entity.liquids().get(liquid), maxUsed * Time.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed(tile);
|
||||
entity.reload += used * liquid.heatCapacity * coolantMultiplier;
|
||||
entity.getLiquids().remove(liquid, used);
|
||||
entity.liquids().remove(liquid, used);
|
||||
|
||||
if(Mathf.chance(0.06 * used)){
|
||||
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
|
||||
|
||||
@@ -2,9 +2,7 @@ package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
@@ -72,12 +70,12 @@ public class LaserTurret extends PowerTurret{
|
||||
|
||||
entity.reload = 0f;
|
||||
}else{
|
||||
Liquid liquid = entity.getLiquids().current();
|
||||
Liquid liquid = entity.liquids().current();
|
||||
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
||||
|
||||
float used = baseReloadSpeed(tile) * (tile.isEnemyCheat() ? maxUsed : Math.min(entity.getLiquids().get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier;
|
||||
float used = baseReloadSpeed(tile) * (tile.isEnemyCheat() ? maxUsed : Math.min(entity.liquids().get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier;
|
||||
entity.reload += used;
|
||||
entity.getLiquids().remove(liquid, used);
|
||||
entity.liquids().remove(liquid, used);
|
||||
|
||||
if(Mathf.chance(0.06 * used)){
|
||||
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
|
||||
|
||||
@@ -7,7 +7,6 @@ import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
@@ -38,8 +37,8 @@ public class LiquidTurret extends Turret{
|
||||
TurretEntity entity = tile.ent();
|
||||
|
||||
if(Core.atlas.isFound(reg(liquidRegion))){
|
||||
Draw.color(entity.getLiquids().current().color);
|
||||
Draw.alpha(entity.getLiquids().total() / liquidCapacity);
|
||||
Draw.color(entity.liquids().current().color);
|
||||
Draw.alpha(entity.liquids().total() / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
Draw.color();
|
||||
}
|
||||
@@ -72,7 +71,7 @@ public class LiquidTurret extends Turret{
|
||||
@Override
|
||||
protected boolean validateTarget(Tile tile){
|
||||
TurretEntity entity = tile.ent();
|
||||
if(entity.getLiquids().current().canExtinguish() && entity.target instanceof Tile){
|
||||
if(entity.liquids().current().canExtinguish() && entity.target instanceof Tile){
|
||||
return Fire.has(((Tile)entity.target).x, ((Tile)entity.target).y);
|
||||
}
|
||||
return super.validateTarget(tile);
|
||||
@@ -81,7 +80,7 @@ public class LiquidTurret extends Turret{
|
||||
@Override
|
||||
protected void findTarget(Tile tile){
|
||||
TurretEntity entity = tile.ent();
|
||||
if(entity.getLiquids().current().canExtinguish()){
|
||||
if(entity.liquids().current().canExtinguish()){
|
||||
int tr = (int)(range / tilesize);
|
||||
for(int x = -tr; x <= tr; x++){
|
||||
for(int y = -tr; y <= tr; y++){
|
||||
@@ -102,8 +101,8 @@ public class LiquidTurret extends Turret{
|
||||
|
||||
TurretEntity entity = tile.ent();
|
||||
|
||||
type.shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.getLiquids().current().color);
|
||||
type.smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.getLiquids().current().color);
|
||||
type.shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids().current().color);
|
||||
type.smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids().current().color);
|
||||
//shootSound.at(tile);
|
||||
|
||||
if(shootShake > 0){
|
||||
@@ -116,21 +115,21 @@ public class LiquidTurret extends Turret{
|
||||
@Override
|
||||
public BulletType useAmmo(Tile tile){
|
||||
TurretEntity entity = tile.ent();
|
||||
if(tile.isEnemyCheat()) return ammo.get(entity.getLiquids().current());
|
||||
BulletType type = ammo.get(entity.getLiquids().current());
|
||||
entity.getLiquids().remove(entity.getLiquids().current(), type.ammoMultiplier);
|
||||
if(tile.isEnemyCheat()) return ammo.get(entity.liquids().current());
|
||||
BulletType type = ammo.get(entity.liquids().current());
|
||||
entity.liquids().remove(entity.liquids().current(), type.ammoMultiplier);
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulletType peekAmmo(Tile tile){
|
||||
return ammo.get(tile.entity.getLiquids().current());
|
||||
return ammo.get(tile.entity.liquids().current());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAmmo(Tile tile){
|
||||
TurretEntity entity = tile.ent();
|
||||
return ammo.get(entity.getLiquids().current()) != null && entity.getLiquids().total() >= ammo.get(entity.getLiquids().current()).ammoMultiplier;
|
||||
return ammo.get(entity.liquids().current()) != null && entity.liquids().total() >= ammo.get(entity.liquids().current()).ammoMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,7 +140,7 @@ public class LiquidTurret extends Turret{
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return ammo.get(liquid) != null
|
||||
&& (tile.entity.getLiquids().current() == liquid || (ammo.containsKey(tile.entity.getLiquids().current()) && tile.entity.getLiquids().get(tile.entity.getLiquids().current()) <= ammo.get(tile.entity.getLiquids().current()).ammoMultiplier + 0.001f));
|
||||
&& (tile.entity.liquids().current() == liquid || (ammo.containsKey(tile.entity.liquids().current()) && tile.entity.liquids().get(tile.entity.liquids().current()) <= ammo.get(tile.entity.liquids().current()).ammoMultiplier + 0.001f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@ public class PowerTurret extends CooledTurret{
|
||||
|
||||
@Override
|
||||
protected float baseReloadSpeed(Tile tile){
|
||||
return tile.isEnemyCheat() ? 1f : tile.entity.getPower().status;
|
||||
return tile.isEnemyCheat() ? 1f : tile.entity.power().status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,8 @@ import arc.math.geom.Vec2;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.BulletType;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
@@ -193,9 +191,9 @@ public abstract class Turret extends Block{
|
||||
TurretEntity entity = tile.ent();
|
||||
|
||||
if(targetAir && !targetGround){
|
||||
entity.target = Units.closestEnemy(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.isDead() && e.isFlying());
|
||||
entity.target = Units.closestEnemy(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && e.isFlying());
|
||||
}else{
|
||||
entity.target = Units.closestTarget(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround));
|
||||
entity.target = Units.closestTarget(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -96,7 +95,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
if(tile.front() != null && tile.front().entity != null){
|
||||
entity.next = tile.front().entity;
|
||||
entity.nextc = entity.next instanceof ConveyorEntity && entity.next.getTeam() == tile.getTeam() ? (ConveyorEntity)entity.next : null;
|
||||
entity.nextc = entity.next instanceof ConveyorEntity && entity.next.team() == tile.getTeam() ? (ConveyorEntity)entity.next : null;
|
||||
entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile.rotation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,10 +266,10 @@ public class ItemBridge extends Block{
|
||||
|
||||
if(rel == rel2) return false;
|
||||
}else{
|
||||
return source.block() instanceof ItemBridge && source.<ItemBridgeEntity>ent().link == tile.pos() && tile.entity.getItems().total() < itemCapacity;
|
||||
return source.block() instanceof ItemBridge && source.<ItemBridgeEntity>ent().link == tile.pos() && tile.entity.items().total() < itemCapacity;
|
||||
}
|
||||
|
||||
return tile.entity.getItems().total() < itemCapacity;
|
||||
return tile.entity.items().total() < itemCapacity;
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ public class ItemBridge extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f);
|
||||
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -116,8 +116,8 @@ public class MassDriver extends Block{
|
||||
float targetRotation = tile.angleTo(link);
|
||||
|
||||
if(
|
||||
tile.entity.getItems().total() >= minDistribute && //must shoot minimum amount of items
|
||||
link.block().itemCapacity - link.entity.getItems().total() >= minDistribute //must have minimum amount of space
|
||||
tile.entity.items().total() >= minDistribute && //must shoot minimum amount of items
|
||||
link.block().itemCapacity - link.entity.items().total() >= minDistribute //must have minimum amount of space
|
||||
){
|
||||
MassDriverEntity other = link.ent();
|
||||
other.waitingShooters.add(tile);
|
||||
@@ -225,7 +225,7 @@ public class MassDriver extends Block{
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
//mass drivers that ouput only cannot accept items
|
||||
return tile.entity.getItems().total() < itemCapacity && linkValid(tile);
|
||||
return tile.entity.items().total() < itemCapacity && linkValid(tile);
|
||||
}
|
||||
|
||||
protected void fire(Tile tile, Tile target){
|
||||
|
||||
@@ -42,8 +42,8 @@ public class OverflowGate extends Block{
|
||||
public void update(Tile tile){
|
||||
OverflowGateEntity entity = tile.ent();
|
||||
|
||||
if(entity.lastItem == null && entity.getItems().total() > 0){
|
||||
entity.getItems().clear();
|
||||
if(entity.lastItem == null && entity.items().total() > 0){
|
||||
entity.items().clear();
|
||||
}
|
||||
|
||||
if(entity.lastItem != null){
|
||||
@@ -53,7 +53,7 @@ public class OverflowGate extends Block{
|
||||
if(target != null && (entity.time >= 1f)){
|
||||
getTileTarget(tile, entity.lastItem, entity.lastInput, true);
|
||||
target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target));
|
||||
entity.getItems().remove(entity.lastItem, 1);
|
||||
entity.items().remove(entity.lastItem, 1);
|
||||
entity.lastItem = null;
|
||||
}
|
||||
}
|
||||
@@ -63,13 +63,13 @@ public class OverflowGate extends Block{
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
OverflowGateEntity entity = tile.ent();
|
||||
|
||||
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.getItems().total() == 0;
|
||||
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.items().total() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
OverflowGateEntity entity = tile.ent();
|
||||
entity.getItems().add(item, 1);
|
||||
entity.items().add(item, 1);
|
||||
entity.lastItem = item;
|
||||
entity.time = 0f;
|
||||
entity.lastInput = source;
|
||||
|
||||
@@ -26,8 +26,8 @@ public class Router extends Block{
|
||||
public void update(Tile tile){
|
||||
RouterEntity entity = tile.ent();
|
||||
|
||||
if(entity.lastItem == null && entity.getItems().total() > 0){
|
||||
entity.getItems().clear();
|
||||
if(entity.lastItem == null && entity.items().total() > 0){
|
||||
entity.items().clear();
|
||||
}
|
||||
|
||||
if(entity.lastItem != null){
|
||||
@@ -37,7 +37,7 @@ public class Router extends Block{
|
||||
if(target != null && (entity.time >= 1f || !(target.block() instanceof Router))){
|
||||
getTileTarget(tile, entity.lastItem, entity.lastInput, true);
|
||||
target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target));
|
||||
entity.getItems().remove(entity.lastItem, 1);
|
||||
entity.items().remove(entity.lastItem, 1);
|
||||
entity.lastItem = null;
|
||||
}
|
||||
}
|
||||
@@ -47,13 +47,13 @@ public class Router extends Block{
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
RouterEntity entity = tile.ent();
|
||||
|
||||
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.getItems().total() == 0;
|
||||
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.items().total() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
RouterEntity entity = tile.ent();
|
||||
entity.getItems().add(item, 1);
|
||||
entity.items().add(item, 1);
|
||||
entity.lastItem = item;
|
||||
entity.time = 0f;
|
||||
entity.lastInput = source;
|
||||
|
||||
@@ -8,7 +8,6 @@ import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -96,7 +95,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
Draw.colorl(0.34f);
|
||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||
|
||||
Draw.color(tile.entity.getLiquids().current().color);
|
||||
Draw.color(tile.entity.liquids().current().color);
|
||||
Draw.alpha(entity.smoothLiquid);
|
||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||
Draw.color();
|
||||
@@ -109,8 +108,8 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
ConduitEntity entity = tile.ent();
|
||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.getLiquids().currentAmount() / liquidCapacity, 0.05f);
|
||||
|
||||
if(tile.entity.getLiquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){
|
||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.getLiquids().current());
|
||||
if(tile.entity.liquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){
|
||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids().current());
|
||||
entity.noSleep();
|
||||
}else{
|
||||
entity.sleep();
|
||||
@@ -125,7 +124,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
tile.entity.noSleep();
|
||||
return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f)
|
||||
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f)
|
||||
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ public class LiquidRouter extends LiquidBlock{
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
|
||||
if(tile.entity.getLiquids().total() > 0.01f){
|
||||
tryDumpLiquid(tile, tile.entity.getLiquids().current());
|
||||
if(tile.entity.liquids().total() > 0.01f){
|
||||
tryDumpLiquid(tile, tile.entity.liquids().current());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f);
|
||||
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ImpactReactor extends PowerGenerator{
|
||||
public void update(Tile tile){
|
||||
FusionReactorEntity entity = tile.ent();
|
||||
|
||||
if(entity.consValid() && entity.getPower().status >= 0.99f){
|
||||
if(entity.consValid() && entity.power().status >= 0.99f){
|
||||
boolean prevOut = getPowerProduction(tile) <= consumes.getPower().requestedPower(entity);
|
||||
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed);
|
||||
|
||||
@@ -7,7 +7,6 @@ import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
@@ -106,7 +105,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
|
||||
Liquid liquid = null;
|
||||
for(Liquid other : content.liquids()){
|
||||
if(hasLiquids && entity.getLiquids().get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){
|
||||
if(hasLiquids && entity.liquids().get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){
|
||||
liquid = other;
|
||||
break;
|
||||
}
|
||||
@@ -115,12 +114,12 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.generateTime >= 0.001f ? 1f : 0f, 0.05f);
|
||||
|
||||
//liquid takes priority over solids
|
||||
if(hasLiquids && liquid != null && entity.getLiquids().get(liquid) >= 0.001f){
|
||||
if(hasLiquids && liquid != null && entity.liquids().get(liquid) >= 0.001f){
|
||||
float baseLiquidEfficiency = getLiquidEfficiency(liquid);
|
||||
float maximumPossible = maxLiquidGenerate * calculationDelta;
|
||||
float used = Math.min(entity.getLiquids().get(liquid) * calculationDelta, maximumPossible);
|
||||
float used = Math.min(entity.liquids().get(liquid) * calculationDelta, maximumPossible);
|
||||
|
||||
entity.getLiquids().remove(liquid, used * entity.getPower().graph.getUsageFraction());
|
||||
entity.liquids().remove(liquid, used * entity.power().graph.getUsageFraction());
|
||||
entity.productionEfficiency = baseLiquidEfficiency * used / maximumPossible;
|
||||
|
||||
if(used > 0.001f && Mathf.chance(0.05 * entity.delta())){
|
||||
@@ -128,16 +127,16 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
}
|
||||
}else if(hasItems){
|
||||
// No liquids accepted or none supplied, try using items if accepted
|
||||
if(entity.generateTime <= 0f && entity.getItems().total() > 0){
|
||||
if(entity.generateTime <= 0f && entity.items().total() > 0){
|
||||
generateEffect.at(tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
||||
Item item = entity.getItems().take();
|
||||
Item item = entity.items().take();
|
||||
entity.productionEfficiency = getItemEfficiency(item);
|
||||
entity.explosiveness = item.explosiveness;
|
||||
entity.generateTime = 1f;
|
||||
}
|
||||
|
||||
if(entity.generateTime > 0f){
|
||||
entity.generateTime -= Math.min(1f / itemDuration * entity.delta() * entity.getPower().graph.getUsageFraction(), entity.generateTime);
|
||||
entity.generateTime -= Math.min(1f / itemDuration * entity.delta() * entity.power().graph.getUsageFraction(), entity.generateTime);
|
||||
|
||||
if(randomlyExplode && state.rules.reactorExplosions && Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.5f))){
|
||||
//this block is run last so that in the event of a block destruction, no code relies on the block type
|
||||
@@ -166,8 +165,8 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
}
|
||||
|
||||
if(hasLiquids){
|
||||
Draw.color(entity.getLiquids().current().color);
|
||||
Draw.alpha(entity.getLiquids().currentAmount() / liquidCapacity);
|
||||
Draw.color(entity.liquids().current().color);
|
||||
Draw.alpha(entity.liquids().currentAmount() / liquidCapacity);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
ConsumeLiquid cliquid = consumes.get(ConsumeType.liquid);
|
||||
Item item = consumes.<ConsumeItems>get(ConsumeType.item).items[0].item;
|
||||
|
||||
int fuel = entity.getItems().get(item);
|
||||
int fuel = entity.items().get(item);
|
||||
float fullness = (float)fuel / itemCapacity;
|
||||
entity.productionEfficiency = fullness;
|
||||
|
||||
@@ -94,9 +94,9 @@ public class NuclearReactor extends PowerGenerator{
|
||||
Liquid liquid = cliquid.liquid;
|
||||
|
||||
if(entity.heat > 0){
|
||||
float maxUsed = Math.min(entity.getLiquids().get(liquid), entity.heat / coolantPower);
|
||||
float maxUsed = Math.min(entity.liquids().get(liquid), entity.heat / coolantPower);
|
||||
entity.heat -= maxUsed * coolantPower;
|
||||
entity.getLiquids().remove(liquid, maxUsed);
|
||||
entity.liquids().remove(liquid, maxUsed);
|
||||
}
|
||||
|
||||
if(entity.heat > smokeThreshold){
|
||||
@@ -123,7 +123,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
|
||||
NuclearReactorEntity entity = tile.ent();
|
||||
|
||||
int fuel = entity.getItems().get(consumes.<ConsumeItems>get(ConsumeType.item).items[0].item);
|
||||
int fuel = entity.items().get(consumes.<ConsumeItems>get(ConsumeType.item).items[0].item);
|
||||
|
||||
if((fuel < 5 && entity.heat < 0.5f) || !state.rules.reactorExplosions) return;
|
||||
|
||||
@@ -166,8 +166,8 @@ public class NuclearReactor extends PowerGenerator{
|
||||
Draw.color(coolColor, hotColor, entity.heat);
|
||||
Fill.rect(tile.drawx(), tile.drawy(), size * tilesize, size * tilesize);
|
||||
|
||||
Draw.color(entity.getLiquids().current().color);
|
||||
Draw.alpha(entity.getLiquids().currentAmount() / liquidCapacity);
|
||||
Draw.color(entity.liquids().current().color);
|
||||
Draw.alpha(entity.liquids().currentAmount() / liquidCapacity);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
|
||||
if(entity.heat > flashThreshold){
|
||||
|
||||
@@ -29,8 +29,8 @@ public class PowerDiode extends Block{
|
||||
|
||||
if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower || tile.back().getTeam() != tile.front().getTeam()) return;
|
||||
|
||||
PowerGraph backGraph = tile.back().entity.getPower().graph;
|
||||
PowerGraph frontGraph = tile.front().entity.getPower().graph;
|
||||
PowerGraph backGraph = tile.back().entity.power().graph;
|
||||
PowerGraph frontGraph = tile.front().entity.power().graph;
|
||||
if(backGraph == frontGraph) return;
|
||||
|
||||
// 0f - 1f of battery capacity in use
|
||||
@@ -51,7 +51,7 @@ public class PowerDiode extends Block{
|
||||
|
||||
// battery % of the graph on either side, defaults to zero
|
||||
public float bar(Tile tile){
|
||||
return (tile != null && tile.block().hasPower) ? tile.entity.getPower().graph.getBatteryStored() / tile.entity.getPower().graph.getTotalBatteryCapacity() : 0f;
|
||||
return (tile != null && tile.block().hasPower) ? tile.entity.power().graph.getBatteryStored() / tile.entity.power().graph.getTotalBatteryCapacity() : 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PowerGraph{
|
||||
for(Tile battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
if(consumes.hasPower()){
|
||||
totalAccumulator += battery.entity.getPower().status * consumes.getPower().capacity;
|
||||
totalAccumulator += battery.entity.power().status * consumes.getPower().capacity;
|
||||
}
|
||||
}
|
||||
return totalAccumulator;
|
||||
@@ -99,7 +99,7 @@ public class PowerGraph{
|
||||
for(Tile battery : batteries){
|
||||
if(battery.block().consumes.hasPower()){
|
||||
ConsumePower power = battery.block().consumes.getPower();
|
||||
totalCapacity += (1f - battery.entity.getPower().status) * power.capacity;
|
||||
totalCapacity += (1f - battery.entity.power().status) * power.capacity;
|
||||
}
|
||||
}
|
||||
return totalCapacity;
|
||||
@@ -124,7 +124,7 @@ public class PowerGraph{
|
||||
for(Tile battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
if(consumes.hasPower()){
|
||||
battery.entity.getPower().status *= (1f-consumedPowerPercentage);
|
||||
battery.entity.power().status *= (1f-consumedPowerPercentage);
|
||||
}
|
||||
}
|
||||
return used;
|
||||
@@ -141,7 +141,7 @@ public class PowerGraph{
|
||||
if(consumes.hasPower()){
|
||||
ConsumePower consumePower = consumes.getPower();
|
||||
if(consumePower.capacity > 0f){
|
||||
battery.entity.getPower().status += (1f-battery.entity.getPower().status) * chargedPercent;
|
||||
battery.entity.power().status += (1f-battery.entity.power().status) * chargedPercent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,17 +159,17 @@ public class PowerGraph{
|
||||
if(!Mathf.zero(consumePower.capacity)){
|
||||
// Add an equal percentage of power to all buffers, based on the global power coverage in this graph
|
||||
float maximumRate = consumePower.requestedPower(consumer.entity) * coverage * consumer.entity.delta();
|
||||
consumer.entity.getPower().status = Mathf.clamp(consumer.entity.getPower().status + maximumRate / consumePower.capacity);
|
||||
consumer.entity.power().status = Mathf.clamp(consumer.entity.power().status + maximumRate / consumePower.capacity);
|
||||
}
|
||||
}else{
|
||||
//valid consumers get power as usual
|
||||
if(otherConsumersAreValid(consumer, consumePower)){
|
||||
consumer.entity.getPower().status = coverage;
|
||||
consumer.entity.power().status = coverage;
|
||||
}else{ //invalid consumers get an estimate, if they were to activate
|
||||
consumer.entity.getPower().status = Math.min(1, produced / (needed + consumePower.usage * consumer.entity.delta()));
|
||||
consumer.entity.power().status = Math.min(1, produced / (needed + consumePower.usage * consumer.entity.delta()));
|
||||
//just in case
|
||||
if(Float.isNaN(consumer.entity.getPower().status)){
|
||||
consumer.entity.getPower().status = 0f;
|
||||
if(Float.isNaN(consumer.entity.power().status)){
|
||||
consumer.entity.power().status = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class PowerGraph{
|
||||
}else if(!consumers.isEmpty() && consumers.first().isEnemyCheat()){
|
||||
//when cheating, just set status to 1
|
||||
for(Tile tile : consumers){
|
||||
tile.entity.getPower().status = 1f;
|
||||
tile.entity.power().status = 1f;
|
||||
}
|
||||
|
||||
lastPowerNeeded = lastPowerProduced = lastUsageFraction = 1f;
|
||||
@@ -230,8 +230,8 @@ public class PowerGraph{
|
||||
}
|
||||
|
||||
public void add(Tile tile){
|
||||
if(tile.entity == null || tile.entity.getPower() == null) return;
|
||||
tile.entity.getPower().graph = this;
|
||||
if(tile.entity == null || tile.entity.power() == null) return;
|
||||
tile.entity.power().graph = this;
|
||||
all.add(tile);
|
||||
|
||||
if(tile.block().outputsPower && tile.block().consumesPower && !tile.block().consumes.getPower().buffered){
|
||||
@@ -277,7 +277,7 @@ public class PowerGraph{
|
||||
//go through all the connections of this tile
|
||||
for(Tile other : tile.block().getPowerConnections(tile, outArray1)){
|
||||
//a graph has already been assigned to this tile from a previous call, skip it
|
||||
if(other.entity.getPower().graph != this) continue;
|
||||
if(other.entity.power().graph != this) continue;
|
||||
|
||||
//create graph for this branch
|
||||
PowerGraph graph = new PowerGraph();
|
||||
@@ -296,7 +296,7 @@ public class PowerGraph{
|
||||
for(Tile next : child.block().getPowerConnections(child, outArray2)){
|
||||
//make sure it hasn't looped back, and that the new graph being assigned hasn't already been assigned
|
||||
//also skip closed tiles
|
||||
if(next != tile && next.entity.getPower().graph != graph && !closedSet.contains(next.pos())){
|
||||
if(next != tile && next.entity.power().graph != graph && !closedSet.contains(next.pos())){
|
||||
queue.addLast(next);
|
||||
closedSet.add(next.pos());
|
||||
}
|
||||
|
||||
@@ -41,19 +41,19 @@ public class PowerNode extends PowerBlock{
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
Tilec entity = tile.entity;
|
||||
Tile other = world.tile(value);
|
||||
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.getPower() != null;
|
||||
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;
|
||||
|
||||
if(contains){
|
||||
//unlink
|
||||
entity.getPower().links.removeValue(value);
|
||||
if(valid) other.entity.getPower().links.removeValue(tile.pos());
|
||||
if(valid) other.entity.power().links.removeValue(tile.pos());
|
||||
|
||||
PowerGraph newgraph = new PowerGraph();
|
||||
|
||||
//reflow from this point, covering all tiles on this side
|
||||
newgraph.reflow(tile);
|
||||
|
||||
if(valid && other.entity.getPower().graph != newgraph){
|
||||
if(valid && other.entity.power().graph != newgraph){
|
||||
//create new graph for other end
|
||||
PowerGraph og = new PowerGraph();
|
||||
//reflow from other end
|
||||
@@ -67,12 +67,12 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
if(other.getTeamID() == tile.getTeamID()){
|
||||
|
||||
if(!other.entity.getPower().links.contains(tile.pos())){
|
||||
other.entity.getPower().links.add(tile.pos());
|
||||
if(!other.entity.power().links.contains(tile.pos())){
|
||||
other.entity.power().links.add(tile.pos());
|
||||
}
|
||||
}
|
||||
|
||||
entity.getPower().graph.add(other.entity.getPower().graph);
|
||||
entity.getPower().graph.add(other.entity.power().graph);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,15 +89,15 @@ public class PowerNode extends PowerBlock{
|
||||
super.setBars();
|
||||
bars.add("power", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.powerbalance",
|
||||
((entity.getPower().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.getPower().graph.getPowerBalance() * 60, 1))),
|
||||
((entity.power().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power().graph.getPowerBalance() * 60, 1))),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.getPower().graph.getLastPowerProduced() / entity.getPower().graph.getLastPowerNeeded())));
|
||||
() -> Mathf.clamp(entity.power().graph.getLastPowerProduced() / entity.power().graph.getLastPowerNeeded())));
|
||||
|
||||
bars.add("batteries", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.powerstored",
|
||||
(ui.formatAmount((int)entity.getPower().graph.getBatteryStored())), ui.formatAmount((int)entity.getPower().graph.getTotalBatteryCapacity())),
|
||||
(ui.formatAmount((int)entity.power().graph.getBatteryStored())), ui.formatAmount((int)entity.power().graph.getTotalBatteryCapacity())),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.getPower().graph.getBatteryStored() / entity.getPower().graph.getTotalBatteryCapacity())));
|
||||
() -> Mathf.clamp(entity.power().graph.getBatteryStored() / entity.power().graph.getTotalBatteryCapacity())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,7 +105,7 @@ public class PowerNode extends PowerBlock{
|
||||
if(net.client()) return;
|
||||
|
||||
Boolf<Tile> valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(tile, other)
|
||||
&& !other.entity.proximity().contains(tile) && other.entity.getPower().graph != tile.entity.getPower().graph;
|
||||
&& !other.entity.proximity().contains(tile) && other.entity.power().graph != tile.entity.power().graph;
|
||||
|
||||
tempTiles.clear();
|
||||
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
|
||||
@@ -123,7 +123,7 @@ public class PowerNode extends PowerBlock{
|
||||
return Float.compare(a.dst2(tile), b.dst2(tile));
|
||||
});
|
||||
tempTiles.each(valid, other -> {
|
||||
if(!tile.entity.getPower().links.contains(other.pos())){
|
||||
if(!tile.entity.power().links.contains(other.pos())){
|
||||
tile.configureAny(other.pos());
|
||||
}
|
||||
});
|
||||
@@ -132,10 +132,10 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
private void getPotentialLinks(Tile tile, Cons<Tile> others){
|
||||
Boolf<Tile> valid = other -> other != null && other != tile && other.entity != null && other.entity.getPower() != null &&
|
||||
Boolf<Tile> valid = other -> other != null && other != tile && other.entity != null && other.entity.power() != null &&
|
||||
((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) &&
|
||||
overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other, laserRange * tilesize) && other.getTeam() == player.getTeam()
|
||||
&& !other.entity.proximity().contains(tile) && !graphs.contains(other.entity.getPower().graph);
|
||||
overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other, laserRange * tilesize) && other.getTeam() == player.team()
|
||||
&& !other.entity.proximity().contains(tile) && !graphs.contains(other.entity.power().graph);
|
||||
|
||||
tempTiles.clear();
|
||||
graphs.clear();
|
||||
@@ -152,7 +152,7 @@ public class PowerNode extends PowerBlock{
|
||||
return Float.compare(a.dst2(tile), b.dst2(tile));
|
||||
});
|
||||
tempTiles.each(valid, t -> {
|
||||
graphs.add(t.entity.getPower().graph);
|
||||
graphs.add(t.entity.power().graph);
|
||||
others.get(t);
|
||||
});
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
tile.entity.getPower().graph.update();
|
||||
tile.entity.power().graph.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,7 +181,7 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
if(tile == other){
|
||||
if(other.entity.getPower().links.size == 0){
|
||||
if(other.entity.power().links.size == 0){
|
||||
int[] total = {0};
|
||||
getPotentialLinks(tile, link -> {
|
||||
if(!insulated(tile, link) && total[0]++ < maxNodes){
|
||||
@@ -281,7 +281,7 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
protected boolean linked(Tile tile, Tile other){
|
||||
return tile.entity.getPower().links.contains(other.pos());
|
||||
return tile.entity.power().links.contains(other.pos());
|
||||
}
|
||||
|
||||
public boolean linkValid(Tile tile, Tile link){
|
||||
@@ -293,7 +293,7 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.<PowerNode>cblock().laserRange * tilesize))){
|
||||
if(checkMaxNodes && link.block() instanceof PowerNode){
|
||||
return link.entity.getPower().links.size < link.<PowerNode>cblock().maxNodes || link.entity.getPower().links.contains(tile.pos());
|
||||
return link.entity.power().links.size < link.<PowerNode>cblock().maxNodes || link.entity.power().links.contains(tile.pos());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ public class PowerNode extends PowerBlock{
|
||||
x2 += t2.x;
|
||||
y2 += t2.y;
|
||||
|
||||
float fract = 1f - tile.entity.getPower().graph.getSatisfaction();
|
||||
float fract = 1f - tile.entity.power().graph.getSatisfaction();
|
||||
|
||||
Draw.color(Color.white, Pal.powerLight, fract * 0.86f + Mathf.absin(3f, 0.1f));
|
||||
Draw.alpha(opacity);
|
||||
|
||||
@@ -9,7 +9,6 @@ import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -76,7 +75,7 @@ public class Drill extends Block{
|
||||
bars.add("drillspeed", e -> {
|
||||
DrillEntity entity = (DrillEntity)e;
|
||||
|
||||
return new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(entity.lastDrillSpeed * 60 * entity.getTimeScale(), 2)), () -> Pal.ammo, () -> entity.warmup);
|
||||
return new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(entity.lastDrillSpeed * 60 * entity.timeScale(), 2)), () -> Pal.ammo, () -> entity.warmup);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -128,7 +127,7 @@ public class Drill extends Block{
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(Tile tile){
|
||||
return tile.entity.getItems().total() < itemCapacity;
|
||||
return tile.entity.items().total() < itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,11 +251,11 @@ public class Drill extends Block{
|
||||
|
||||
entity.drillTime += entity.warmup * entity.delta();
|
||||
|
||||
if(entity.getItems().total() < itemCapacity && entity.dominantItems > 0 && entity.consValid()){
|
||||
if(entity.items().total() < itemCapacity && entity.dominantItems > 0 && entity.consValid()){
|
||||
|
||||
float speed = 1f;
|
||||
|
||||
if(entity.getCons().optionalValid()){
|
||||
if(entity.cons().optionalValid()){
|
||||
speed = liquidBoostIntensity;
|
||||
}
|
||||
|
||||
@@ -275,7 +274,7 @@ public class Drill extends Block{
|
||||
return;
|
||||
}
|
||||
|
||||
if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness && tile.entity.getItems().total() < itemCapacity){
|
||||
if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness && tile.entity.items().total() < itemCapacity){
|
||||
|
||||
offloadNear(tile, entity.dominantItem);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Fracker extends SolidPump{
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(Tile tile){
|
||||
return tile.entity.getLiquids().get(result) < liquidCapacity - 0.01f;
|
||||
return tile.entity.liquids().get(result) < liquidCapacity - 0.01f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +55,7 @@ public class Fracker extends SolidPump{
|
||||
super.drawCracks(tile);
|
||||
|
||||
Draw.color(result.color);
|
||||
Draw.alpha(tile.entity.getLiquids().get(result) / liquidCapacity);
|
||||
Draw.alpha(tile.entity.liquids().get(result) / liquidCapacity);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
|
||||
@@ -87,7 +87,7 @@ public class Fracker extends SolidPump{
|
||||
|
||||
@Override
|
||||
public float typeLiquid(Tile tile){
|
||||
return tile.entity.getLiquids().get(result);
|
||||
return tile.entity.liquids().get(result);
|
||||
}
|
||||
|
||||
public static class FrackerEntity extends SolidPumpEntity{
|
||||
|
||||
@@ -7,7 +7,6 @@ import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
@@ -60,7 +59,7 @@ public class GenericCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public boolean shouldIdleSound(Tile tile){
|
||||
return tile.entity.getCons().valid();
|
||||
return tile.entity.cons().valid();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,10 +134,10 @@ public class GenericCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(Tile tile){
|
||||
if(outputItem != null && tile.entity.getItems().get(outputItem.item) >= itemCapacity){
|
||||
if(outputItem != null && tile.entity.items().get(outputItem.item) >= itemCapacity){
|
||||
return false;
|
||||
}
|
||||
return outputLiquid == null || !(tile.entity.getLiquids().get(outputLiquid.liquid) >= liquidCapacity);
|
||||
return outputLiquid == null || !(tile.entity.liquids().get(outputLiquid.liquid) >= liquidCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ public class LiquidConverter extends GenericCrafter{
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
if(hasLiquids && drawLiquidLight && outputLiquid.liquid.lightColor.a > 0.001f){
|
||||
drawLiquidLight(tile, outputLiquid.liquid, tile.entity.getLiquids().get(outputLiquid.liquid));
|
||||
drawLiquidLight(tile, outputLiquid.liquid, tile.entity.liquids().get(outputLiquid.liquid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ public class LiquidConverter extends GenericCrafter{
|
||||
GenericCrafterEntity entity = tile.ent();
|
||||
ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid);
|
||||
|
||||
if(tile.entity.getCons().valid()){
|
||||
float use = Math.min(cl.amount * entity.delta(), liquidCapacity - entity.getLiquids().get(outputLiquid.liquid)) * entity.efficiency();
|
||||
if(tile.entity.cons().valid()){
|
||||
float use = Math.min(cl.amount * entity.delta(), liquidCapacity - entity.liquids().get(outputLiquid.liquid)) * entity.efficiency();
|
||||
|
||||
useContent(tile, outputLiquid.liquid);
|
||||
entity.progress += use / cl.amount / craftTime;
|
||||
entity.getLiquids().add(outputLiquid.liquid, use);
|
||||
entity.liquids().add(outputLiquid.liquid, use);
|
||||
if(entity.progress >= 1f){
|
||||
entity.consume();
|
||||
entity.progress = 0f;
|
||||
|
||||
@@ -48,8 +48,8 @@ public class Pump extends LiquidBlock{
|
||||
public void draw(Tile tile){
|
||||
Draw.rect(name, tile.drawx(), tile.drawy());
|
||||
|
||||
Draw.color(tile.entity.getLiquids().current().color);
|
||||
Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity);
|
||||
Draw.color(tile.entity.liquids().current().color);
|
||||
Draw.alpha(tile.entity.liquids().total() / liquidCapacity);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
}
|
||||
@@ -118,16 +118,16 @@ public class Pump extends LiquidBlock{
|
||||
liquidDrop = tile.floor().liquidDrop;
|
||||
}
|
||||
|
||||
if(tile.entity.getCons().valid() && liquidDrop != null){
|
||||
float maxPump = Math.min(liquidCapacity - tile.entity.getLiquids().total(), tiles * pumpAmount * tile.entity.delta() / size / size) * tile.entity.efficiency();
|
||||
tile.entity.getLiquids().add(liquidDrop, maxPump);
|
||||
if(tile.entity.cons().valid() && liquidDrop != null){
|
||||
float maxPump = Math.min(liquidCapacity - tile.entity.liquids().total(), tiles * pumpAmount * tile.entity.delta() / size / size) * tile.entity.efficiency();
|
||||
tile.entity.liquids().add(liquidDrop, maxPump);
|
||||
}
|
||||
|
||||
if(tile.entity.getLiquids().currentAmount() > 0f && tile.entity.timer(timerContentCheck, 10)){
|
||||
useContent(tile, tile.entity.getLiquids().current());
|
||||
if(tile.entity.liquids().currentAmount() > 0f && tile.entity.timer(timerContentCheck, 10)){
|
||||
useContent(tile, tile.entity.liquids().current());
|
||||
}
|
||||
|
||||
tryDumpLiquid(tile, tile.entity.getLiquids().current());
|
||||
tryDumpLiquid(tile, tile.entity.liquids().current());
|
||||
}
|
||||
|
||||
protected boolean isValid(Tile tile){
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Separator extends Block{
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(Tile tile){
|
||||
return tile.entity.getItems().total() < itemCapacity;
|
||||
return tile.entity.items().total() < itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,8 +63,8 @@ public class Separator extends Block{
|
||||
|
||||
GenericCrafterEntity entity = tile.ent();
|
||||
|
||||
Draw.color(tile.entity.getLiquids().current().color);
|
||||
Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity);
|
||||
Draw.color(tile.entity.liquids().current().color);
|
||||
Draw.alpha(tile.entity.liquids().total() / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
|
||||
|
||||
Draw.reset();
|
||||
@@ -106,7 +106,7 @@ public class Separator extends Block{
|
||||
|
||||
entity.consume();
|
||||
|
||||
if(item != null && entity.getItems().get(item) < itemCapacity){
|
||||
if(item != null && entity.items().get(item) < itemCapacity){
|
||||
offloadNear(tile, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ public class SolidPump extends Pump{
|
||||
SolidPumpEntity entity = tile.ent();
|
||||
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.color(tile.entity.getLiquids().current().color);
|
||||
Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity);
|
||||
Draw.color(tile.entity.liquids().current().color);
|
||||
Draw.alpha(tile.entity.liquids().total() / liquidCapacity);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
Draw.rect(name + "-rotator", tile.drawx(), tile.drawy(), entity.pumpTime * rotateSpeed);
|
||||
@@ -105,9 +105,9 @@ public class SolidPump extends Pump{
|
||||
|
||||
fraction += entity.boost;
|
||||
|
||||
if(tile.entity.getCons().valid() && typeLiquid(tile) < liquidCapacity - 0.001f){
|
||||
if(tile.entity.cons().valid() && typeLiquid(tile) < liquidCapacity - 0.001f){
|
||||
float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction * entity.efficiency());
|
||||
tile.entity.getLiquids().add(result, maxPump);
|
||||
tile.entity.liquids().add(result, maxPump);
|
||||
entity.lastPump = maxPump;
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f);
|
||||
if(Mathf.chance(entity.delta() * updateEffectChance))
|
||||
@@ -152,7 +152,7 @@ public class SolidPump extends Pump{
|
||||
}
|
||||
|
||||
public float typeLiquid(Tile tile){
|
||||
return tile.entity.getLiquids().total();
|
||||
return tile.entity.liquids().total();
|
||||
}
|
||||
|
||||
public static class SolidPumpEntity extends Tilec{
|
||||
|
||||
@@ -11,7 +11,6 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
@@ -54,9 +53,9 @@ public class LiquidSource extends Block{
|
||||
LiquidSourceEntity entity = tile.ent();
|
||||
|
||||
if(entity.source == null){
|
||||
tile.entity.getLiquids().clear();
|
||||
tile.entity.liquids().clear();
|
||||
}else{
|
||||
tile.entity.getLiquids().add(entity.source, liquidCapacity);
|
||||
tile.entity.liquids().add(entity.source, liquidCapacity);
|
||||
tryDumpLiquid(tile, entity.source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -71,7 +70,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return tile.entity.getItems().get(item) < getMaximumAccepted(tile, item);
|
||||
return tile.entity.items().get(item) < getMaximumAccepted(tile, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,14 +85,14 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
for(Tilec other : state.teams.cores(tile.getTeam())){
|
||||
if(other.tile != tile){
|
||||
entity.getItems() = other.items;
|
||||
entity.items() = other.items;
|
||||
}
|
||||
}
|
||||
state.teams.registerCore(entity);
|
||||
|
||||
entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
entity.proximity().each(this::isContainer, t -> {
|
||||
t.entity.getItems() = entity.getItems();
|
||||
t.entity.items() = entity.items();
|
||||
t.<StorageBlockEntity>ent().linkedCore = tile;
|
||||
});
|
||||
|
||||
@@ -104,7 +103,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
if(!world.isGenerating()){
|
||||
for(Item item : content.items()){
|
||||
entity.getItems().set(item, Math.min(entity.getItems().get(item), entity.storageCapacity));
|
||||
entity.items().set(item, Math.min(entity.items().get(item), entity.storageCapacity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +122,10 @@ public class CoreBlock extends StorageBlock{
|
||||
Draw.rect("block-select", t.drawx() + offset * p.x, t.drawy() + offset * p.y, i * 90);
|
||||
}
|
||||
};
|
||||
if(tile.entity.proximity().contains(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems())){
|
||||
if(tile.entity.proximity().contains(e -> isContainer(e) && e.entity.items() == tile.entity.items())){
|
||||
outline.get(tile);
|
||||
}
|
||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems(), outline);
|
||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), outline);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public float handleDamage(Tile tile, float amount){
|
||||
if(player != null && tile.getTeam() == player.getTeam()){
|
||||
if(player != null && tile.getTeam() == player.team()){
|
||||
Events.fire(Trigger.teamCoreDamage);
|
||||
}
|
||||
return amount;
|
||||
@@ -151,15 +150,15 @@ public class CoreBlock extends StorageBlock{
|
||||
@Override
|
||||
public void removed(Tile tile){
|
||||
CoreEntity entity = tile.ent();
|
||||
int total = tile.entity.proximity().count(e -> e.entity != null && e.entity.getItems() != null && e.entity.getItems() == tile.entity.getItems());
|
||||
int total = tile.entity.proximity().count(e -> e.entity != null && e.entity.items() != null && e.entity.items() == tile.entity.items());
|
||||
float fract = 1f / total / state.teams.cores(tile.getTeam()).size;
|
||||
|
||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems(), t -> {
|
||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), t -> {
|
||||
StorageBlockEntity ent = (StorageBlockEntity)t.entity;
|
||||
ent.linkedCore = null;
|
||||
ent.items = new ItemModule();
|
||||
for(Item item : content.items()){
|
||||
ent.items.set(item, (int)(fract * tile.entity.getItems().get(item)));
|
||||
ent.items.set(item, (int)(fract * tile.entity.items().get(item)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -167,7 +166,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
int max = itemCapacity * state.teams.cores(tile.getTeam()).size;
|
||||
for(Item item : content.items()){
|
||||
tile.entity.getItems().set(item, Math.min(tile.entity.getItems().get(item), max));
|
||||
tile.entity.items().set(item, Math.min(tile.entity.items().get(item), max));
|
||||
}
|
||||
|
||||
for(CoreEntity other : state.teams.cores(tile.getTeam())){
|
||||
@@ -206,7 +205,7 @@ public class CoreBlock extends StorageBlock{
|
||||
CoreEntity entity = tile.ent();
|
||||
|
||||
if(entity.spawnPlayer != null){
|
||||
if(!entity.spawnPlayer.isDead() || !entity.spawnPlayer.isAdded()){
|
||||
if(!entity.spawnPlayer.dead() || !entity.spawnPlayer.isAdded()){
|
||||
entity.spawnPlayer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ public class LaunchPad extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return item.type == ItemType.material && tile.entity.getItems().total() < itemCapacity;
|
||||
return item.type == ItemType.material && tile.entity.items().total() < itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
float progress = Mathf.clamp(Mathf.clamp((tile.entity.getItems().total() / (float)itemCapacity)) * ((tile.entity.timerTime(timerLaunch) / (launchTime / tile.entity.timeScale))));
|
||||
float progress = Mathf.clamp(Mathf.clamp((tile.entity.items().total() / (float)itemCapacity)) * ((tile.entity.timerTime(timerLaunch) / (launchTime / tile.entity.timeScale))));
|
||||
float scale = size / 3f;
|
||||
|
||||
Lines.stroke(2f);
|
||||
@@ -56,7 +56,7 @@ public class LaunchPad extends StorageBlock{
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
|
||||
if(tile.entity.getCons().valid()){
|
||||
if(tile.entity.cons().valid()){
|
||||
for(int i = 0; i < 3; i++){
|
||||
float f = (Time.time() / 200f + i * 0.5f) % 1f;
|
||||
|
||||
@@ -72,13 +72,13 @@ public class LaunchPad extends StorageBlock{
|
||||
public void update(Tile tile){
|
||||
Tilec entity = tile.entity;
|
||||
|
||||
if(world.isZone() && entity.consValid() && entity.getItems().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale)){
|
||||
if(world.isZone() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale)){
|
||||
for(Item item : Vars.content.items()){
|
||||
Events.fire(Trigger.itemLaunch);
|
||||
Fx.padlaunch.at(tile);
|
||||
int used = Math.min(entity.getItems().get(item), itemCapacity);
|
||||
int used = Math.min(entity.items().get(item), itemCapacity);
|
||||
data.addItem(item, used);
|
||||
entity.getItems().remove(item, used);
|
||||
entity.items().remove(item, used);
|
||||
Events.fire(new LaunchItemEvent(item, used));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class StorageBlock extends Block{
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
StorageBlockEntity entity = tile.ent();
|
||||
return entity.linkedCore != null ? entity.linkedCore.block().acceptItem(item, entity.linkedCore, source) : tile.entity.getItems().get(item) < getMaximumAccepted(tile, item);
|
||||
return entity.linkedCore != null ? entity.linkedCore.block().acceptItem(item, entity.linkedCore, source) : tile.entity.items().get(item) < getMaximumAccepted(tile, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,10 +46,10 @@ public abstract class StorageBlock extends Block{
|
||||
Tilec entity = tile.entity;
|
||||
|
||||
if(item == null){
|
||||
return entity.getItems().take();
|
||||
return entity.items().take();
|
||||
}else{
|
||||
if(entity.getItems().has(item)){
|
||||
entity.getItems().remove(item, 1);
|
||||
if(entity.items().has(item)){
|
||||
entity.items().remove(item, 1);
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ public abstract class StorageBlock extends Block{
|
||||
public boolean hasItem(Tile tile, Item item){
|
||||
Tilec entity = tile.entity;
|
||||
if(item == null){
|
||||
return entity.getItems().total() > 0;
|
||||
return entity.items().total() > 0;
|
||||
}else{
|
||||
return entity.getItems().has(item);
|
||||
return entity.items().has(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Unloader extends Block{
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
tile.entity.getItems().clear();
|
||||
tile.entity.items().clear();
|
||||
tile.<UnloaderEntity>ent().sortItem = content.item(value);
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ public class Unloader extends Block{
|
||||
public void update(Tile tile){
|
||||
UnloaderEntity entity = tile.ent();
|
||||
|
||||
if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.getItems().total() == 0){
|
||||
if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.items().total() == 0){
|
||||
for(Tile other : tile.entity.proximity()){
|
||||
if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.getItems().total() == 0 &&
|
||||
((entity.sortItem == null && other.entity.getItems().total() > 0) || hasItem(other, entity.sortItem))){
|
||||
((entity.sortItem == null && other.entity.items().total() > 0) || hasItem(other, entity.sortItem))){
|
||||
offloadNear(tile, removeItem(other, entity.sortItem));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
@@ -80,7 +79,7 @@ public class MechPad extends Block{
|
||||
|
||||
protected static boolean checkValidTap(Tile tile, Player player){
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
return !player.isDead() && tile.interactable(player.getTeam()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
||||
return !player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
||||
Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null;
|
||||
}
|
||||
|
||||
@@ -100,7 +99,7 @@ public class MechPad extends Block{
|
||||
|
||||
if(checkValidTap(tile, player)){
|
||||
Call.onMechFactoryTap(player, tile);
|
||||
}else if(player.isLocal && mobile && !player.isDead() && entity.consValid() && entity.player == null){
|
||||
}else if(player.isLocal && mobile && !player.dead() && entity.consValid() && entity.player == null){
|
||||
//deselect on double taps
|
||||
player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class RepairPoint extends Block{
|
||||
RepairPointEntity entity = tile.ent();
|
||||
|
||||
boolean targetIsBeingRepaired = false;
|
||||
if(entity.target != null && (entity.target.isDead() || entity.target.dst(tile) > repairRadius || entity.target.health >= entity.target.maxHealth())){
|
||||
if(entity.target != null && (entity.target.dead() || entity.target.dst(tile) > repairRadius || entity.target.health >= entity.target.maxHealth())){
|
||||
entity.target = null;
|
||||
}else if(entity.target != null && entity.consValid()){
|
||||
entity.target.health += repairSpeed * Time.delta() * entity.strength * entity.efficiency();
|
||||
|
||||
@@ -4,7 +4,6 @@ import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
@@ -35,7 +34,7 @@ public class ConsumeItemFilter extends Consume{
|
||||
@Override
|
||||
public void build(Tile tile, Table table){
|
||||
MultiReqImage image = new MultiReqImage();
|
||||
content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.getItems() != null && tile.entity.getItems().has(item))));
|
||||
content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(item))));
|
||||
|
||||
table.add(image).size(8 * 4);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package mindustry.world.consumers;
|
||||
import arc.struct.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
@@ -38,7 +37,7 @@ public class ConsumeItems extends Consume{
|
||||
@Override
|
||||
public void build(Tile tile, Table table){
|
||||
for(ItemStack stack : items){
|
||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), () -> tile.entity != null && tile.entity.getItems() != null && tile.entity.getItems().has(stack.item, stack.amount))).size(8 * 4).padRight(5);
|
||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(stack.item, stack.amount))).size(8 * 4).padRight(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
||||
public void build(Tile tile, Table table){
|
||||
Array<Liquid> list = content.liquids().select(l -> !l.isHidden() && filter.get(l));
|
||||
MultiReqImage image = new MultiReqImage();
|
||||
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.getLiquids() != null && tile.entity.getLiquids().get(liquid) >= use(tile.entity))));
|
||||
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.liquids() != null && tile.entity.liquids().get(liquid) >= use(tile.entity))));
|
||||
|
||||
table.add(image).size(8 * 4);
|
||||
}
|
||||
@@ -44,12 +44,12 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
entity.getLiquids().remove(entity.getLiquids().current(), use(entity));
|
||||
entity.liquids().remove(entity.liquids().current(), use(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity != null && entity.getLiquids() != null && filter.get(entity.getLiquids().current()) && entity.getLiquids().currentAmount() >= use(entity);
|
||||
return entity != null && entity.liquids() != null && filter.get(entity.liquids().current()) && entity.liquids().currentAmount() >= use(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ConsumePower extends Consume{
|
||||
if(buffered){
|
||||
return true;
|
||||
}else{
|
||||
return entity.getPower().status > 0f;
|
||||
return entity.power().status > 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +69,12 @@ public class ConsumePower extends Consume{
|
||||
* @return The amount of power which is requested per tick.
|
||||
*/
|
||||
public float requestedPower(Tilec entity){
|
||||
if(entity.getTile().entity == null) return 0f;
|
||||
if(entity.tile().entity == null) return 0f;
|
||||
if(buffered){
|
||||
return (1f-entity.getPower().status)*capacity;
|
||||
return (1f-entity.power().status)*capacity;
|
||||
}else{
|
||||
try{
|
||||
return usage * Mathf.num(entity.getBlock().shouldConsume(entity.getTile()));
|
||||
return usage * Mathf.num(entity.block().shouldConsume(entity.tile()));
|
||||
}catch(Exception e){
|
||||
//HACK an error will only happen with a bar that is checking its requested power, and the entity is null/a different class
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user