This commit is contained in:
Anuken
2020-01-19 11:10:14 -05:00
parent f7c4ea3e58
commit c0844304a6
259 changed files with 7166 additions and 7198 deletions
+9 -11
View File
@@ -1,17 +1,15 @@
package mindustry.world;
import mindustry.annotations.Annotations.Loc;
import mindustry.annotations.Annotations.Remote;
import arc.Core;
import arc.Events;
import arc.math.Mathf;
import arc.*;
import arc.math.*;
import arc.math.geom.*;
import mindustry.content.Blocks;
import mindustry.entities.Units;
import mindustry.game.EventType.BlockBuildBeginEvent;
import mindustry.game.Team;
import mindustry.world.blocks.BuildBlock;
import mindustry.world.blocks.BuildBlock.BuildEntity;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.BuildBlock.*;
import static mindustry.Vars.*;
+24 -1
View File
@@ -1,10 +1,11 @@
package mindustry.world;
import arc.struct.*;
import arc.func.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.traits.*;
import mindustry.entities.type.*;
@@ -215,6 +216,16 @@ public class Tile implements Position, TargetTrait{
}
}
/** remove()-s this tile, except it's synced across the network */
public void removeNet(){
Call.removeTile(this);
}
/** set()-s this tile, except it's synced across the network */
public void setNet(Block block, Team team, int rotation){
Call.setTile(this, block, team, rotation);
}
public byte rotation(){
return rotation;
}
@@ -506,4 +517,16 @@ public class Tile implements Position, TargetTrait{
public String toString(){
return floor.name + ":" + block.name + ":" + overlay + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : (entity.getClass())) + ":" + getTeam();
}
//remote utility methods
@Remote(called = Loc.server)
public static void removeTile(Tile tile){
tile.remove();
}
@Remote(called = Loc.server)
public static void setTile(Tile tile, Block block, Team team, int rotation){
tile.set(block, team, rotation);
}
}
@@ -33,6 +33,7 @@ public class Conveyor extends Block implements Autotiler{
private TextureRegion[][] regions = new TextureRegion[7][4];
public float speed = 0f;
public float displayedSpeed = 0f;
protected Conveyor(String name){
super(name);
@@ -59,7 +60,8 @@ public class Conveyor extends Block implements Autotiler{
@Override
public void setStats(){
super.setStats();
stats.add(BlockStat.itemsMoved, speed * 60 / itemSpace, StatUnit.itemsSecond);
//have to add a custom calculated speed, since the actual movement speed is apparently not linear
stats.add(BlockStat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
}
@Override
@@ -3,8 +3,8 @@ package mindustry.world.blocks.distribution;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.type.*;
@@ -85,7 +85,8 @@ public class Sorter extends Block{
}
boolean isSame(Tile tile, Tile other){
return other != null && other.block() instanceof Sorter;
//uncomment comment below to prevent sorter/gate chaining (hacky)
return other != null && (other.block() instanceof Sorter/* || other.block() instanceof OverflowGate */);
}
Tile getTileTarget(Item item, Tile dest, Tile source, boolean flip){
@@ -1,11 +1,11 @@
package mindustry.world.blocks.liquid;
import arc.*;
import arc.struct.*;
import arc.func.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.traits.BuilderTrait.*;
@@ -13,7 +13,6 @@ import mindustry.entities.type.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.modules.*;
public class Conduit extends LiquidBlock implements Autotiler{
public final int timerFlow = timers++;
@@ -92,13 +91,12 @@ public class Conduit extends LiquidBlock implements Autotiler{
@Override
public void draw(Tile tile){
ConduitEntity entity = tile.ent();
LiquidModule mod = tile.entity.liquids;
int rotation = tile.rotation() * 90;
Draw.colorl(0.34f);
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
Draw.color(mod.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,7 +107,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
@Override
public void update(Tile tile){
ConduitEntity entity = tile.ent();
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids.total() / liquidCapacity, 0.05f);
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids.currentAmount() / liquidCapacity, 0.05f);
if(tile.entity.liquids.total() > 0.001f && tile.entity.timer.get(timerFlow, 1)){
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids.current());
@@ -98,7 +98,7 @@ public class MessageBlock extends Block{
public void buildConfiguration(Tile tile, Table table){
MessageBlockEntity entity = tile.ent();
table.addImageButton(Icon.pencilSmall, () -> {
table.addImageButton(Icon.pencil, () -> {
if(mobile){
Core.input.getTextInput(new TextInput(){{
text = entity.message;
@@ -52,7 +52,7 @@ public class LightBlock extends Block{
public void buildConfiguration(Tile tile, Table table){
LightEntity entity = tile.ent();
table.addImageButton(Icon.pencilSmall, () -> {
table.addImageButton(Icon.pencil, () -> {
ui.picker.show(Tmp.c1.set(entity.color).a(0.5f), false, res -> {
entity.color = res.rgba();
lastColor = entity.color;
@@ -4,7 +4,7 @@ import arc.Core;
import arc.graphics.Color;
import arc.graphics.g2d.*;
import arc.math.Mathf;
import arc.math.RandomXS128;
import arc.math.Rand;
import arc.util.Time;
import mindustry.content.Fx;
import mindustry.entities.type.TileEntity;
@@ -21,7 +21,7 @@ public class Cultivator extends GenericCrafter{
public Color bottomColor = Color.valueOf("474747");
public TextureRegion middleRegion, topRegion;
public RandomXS128 random = new RandomXS128(0);
public Rand random = new Rand(0);
public float recurrence = 6f;
public Attribute attribute = Attribute.spores;
@@ -1,6 +1,6 @@
package mindustry.world.blocks.production;
import arc.graphics.*;
import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.ArcAnnotate.*;
@@ -15,15 +15,11 @@ import mindustry.world.meta.values.*;
* Extracts a random list of items from an input item and an input liquid.
*/
public class Separator extends Block{
protected @NonNull ItemStack[] results;
protected float craftTime;
protected float spinnerRadius = 2.5f;
protected float spinnerLength = 1f;
protected float spinnerThickness = 1f;
protected float spinnerSpeed = 2f;
public @NonNull ItemStack[] results;
public float craftTime;
protected Color color = Color.valueOf("858585");
protected int liquidRegion;
public int liquidRegion, spinnerRegion;
public float spinnerSpeed = 3f;
public Separator(String name){
super(name);
@@ -33,6 +29,7 @@ public class Separator extends Block{
hasLiquids = true;
liquidRegion = reg("-liquid");
spinnerRegion = reg("-spinner");
entityType = GenericCrafterEntity::new;
}
@@ -70,10 +67,10 @@ public class Separator extends Block{
Draw.alpha(tile.entity.liquids.total() / liquidCapacity);
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
Draw.color(color);
Lines.stroke(spinnerThickness);
Lines.spikes(tile.drawx(), tile.drawy(), spinnerRadius, spinnerLength, 3, entity.totalProgress * spinnerSpeed);
Draw.reset();
if(Core.atlas.isFound(reg(spinnerRegion))){
Draw.rect(reg(spinnerRegion), tile.drawx(), tile.drawy(), entity.totalProgress * spinnerSpeed);
}
}
@Override
@@ -66,7 +66,7 @@ public class CommandCenter extends Block{
super.load();
for(UnitCommand cmd : UnitCommand.all){
commandRegions[cmd.ordinal()] = Core.atlas.find("icon-command-" + cmd.name() + "-small");
commandRegions[cmd.ordinal()] = Core.atlas.find("Icon.command-" + cmd.name() + "-");
}
}
@@ -91,7 +91,7 @@ public class CommandCenter extends Block{
Table buttons = new Table();
for(UnitCommand cmd : UnitCommand.all){
buttons.addImageButton(Core.atlas.drawable("icon-command-" + cmd.name() + "-small"), Styles.clearToggleTransi, () -> tile.configure(cmd.ordinal()))
buttons.addImageButton(Core.atlas.drawable("Icon.command-" + cmd.name() + "-"), Styles.clearToggleTransi, () -> tile.configure(cmd.ordinal()))
.size(44).group(group).update(b -> b.setChecked(entity.command == cmd));
}
table.add(buttons);