Initial reconstructor impl
BIN
core/assets-raw/sprites/blocks/units/basic-reconstructor.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
core/assets-raw/sprites/blocks/units/factory-in.png
Normal file
After Width: | Height: | Size: 675 B |
Before Width: | Height: | Size: 686 B After Width: | Height: | Size: 697 B |
Before Width: | Height: | Size: 735 KiB After Width: | Height: | Size: 718 KiB |
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 128 KiB |
@ -437,7 +437,7 @@ public class BlockIndexer{
|
||||
}
|
||||
}
|
||||
|
||||
private class TileIndex{
|
||||
private static class TileIndex{
|
||||
public final EnumSet<BlockFlag> flags;
|
||||
public final Team team;
|
||||
|
||||
|
@ -330,7 +330,7 @@ public class Pathfinder implements Runnable{
|
||||
}
|
||||
|
||||
/** Data for a specific flow field to some set of destinations. */
|
||||
class PathData{
|
||||
static class PathData{
|
||||
/** Team this path is for. */
|
||||
final Team team;
|
||||
/** Flag that is being targeted. */
|
||||
|
@ -50,7 +50,7 @@ public class LoopControl{
|
||||
});
|
||||
}
|
||||
|
||||
private class SoundData{
|
||||
private static class SoundData{
|
||||
float volume;
|
||||
float total;
|
||||
Vec2 sum = new Vec2();
|
||||
|
@ -25,7 +25,6 @@ import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.sandbox.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
import mindustry.world.blocks.storage.MessageBlock;
|
||||
import mindustry.world.blocks.units.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
@ -77,14 +76,12 @@ public class Blocks implements ContentList{
|
||||
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown,
|
||||
|
||||
//units
|
||||
groundFactory, airFactory, navalFactory, repairPoint,
|
||||
groundFactory, airFactory, navalFactory, basicReconstructor, repairPoint,
|
||||
|
||||
//misc experimental
|
||||
|
||||
blockForge, blockLauncher;
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
//region environment
|
||||
@ -592,7 +589,7 @@ public class Blocks implements ContentList{
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||
|
||||
drawer = entity -> {
|
||||
int rotation = rotate ? entity.rotation() * 90 : 0;
|
||||
float rotation = rotate ? entity.rotdeg() : 0;
|
||||
|
||||
Draw.rect(re(bottomRegion), entity.x(), entity.y(), rotation);
|
||||
|
||||
@ -1702,6 +1699,15 @@ public class Blocks implements ContentList{
|
||||
consumes.power(1.2f);
|
||||
}};
|
||||
|
||||
basicReconstructor = new Reconstructor("basic-reconstructor"){{
|
||||
requirements(Category.units, ItemStack.with(Items.copper, 50, Items.lead, 120, Items.silicon, 230));
|
||||
|
||||
size = 3;
|
||||
consumes.power(3f);
|
||||
consumes.items(ItemStack.with(Items.silicon, 30, Items.graphite, 30));
|
||||
itemCapacity = 30;
|
||||
}};
|
||||
|
||||
repairPoint = new RepairPoint("repair-point"){{
|
||||
requirements(Category.units, ItemStack.with(Items.lead, 15, Items.copper, 15, Items.silicon, 15));
|
||||
repairSpeed = 0.5f;
|
||||
|
@ -51,6 +51,9 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
|
||||
titan = new UnitType("titan"){{
|
||||
dagger.upgrade = this;
|
||||
tier = 2;
|
||||
|
||||
speed = 0.4f;
|
||||
mass = 3.5f;
|
||||
hitsize = 9f;
|
||||
@ -94,6 +97,9 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
|
||||
fortress = new UnitType("fortress"){{
|
||||
titan.upgrade = this;
|
||||
tier = 2;
|
||||
|
||||
speed = 0.38f;
|
||||
mass = 5f;
|
||||
hitsize = 13f;
|
||||
@ -114,6 +120,9 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
|
||||
eruptor = new UnitType("eruptor"){{
|
||||
crawler.upgrade = this;
|
||||
tier = 2;
|
||||
|
||||
speed = 0.4f;
|
||||
drag = 0.4f;
|
||||
mass = 5f;
|
||||
@ -156,6 +165,9 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
|
||||
ghoul = new UnitType("ghoul"){{
|
||||
wraith.upgrade = this;
|
||||
tier = 2;
|
||||
|
||||
health = 220;
|
||||
speed = 2f;
|
||||
mass = 3f;
|
||||
@ -298,6 +310,8 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
|
||||
oculon = new UnitType("oculon"){{
|
||||
tier = 2;
|
||||
|
||||
drillTier = -1;
|
||||
speed = 0.6f;
|
||||
hitsize = 9f;
|
||||
|
@ -8,7 +8,6 @@ import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.mod.Mods.*;
|
||||
import mindustry.type.*;
|
||||
|
@ -15,6 +15,8 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
public String localizedName;
|
||||
/** Localized description. May be null. */
|
||||
public @Nullable String description;
|
||||
/** Whether this content is always unlocked in the tech tree. */
|
||||
public boolean alwaysUnlocked = false;
|
||||
/** Icons by Cicon ID.*/
|
||||
protected TextureRegion[] cicons = new TextureRegion[mindustry.ui.Cicon.all.length];
|
||||
|
||||
@ -62,7 +64,7 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
|
||||
/** Override to make content always unlocked. */
|
||||
public boolean alwaysUnlocked(){
|
||||
return false;
|
||||
return alwaysUnlocked;
|
||||
}
|
||||
|
||||
public final boolean unlocked(){
|
||||
|
@ -25,7 +25,6 @@ import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
@ -548,7 +547,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
mid.table(Tex.underline, t -> {
|
||||
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
|
||||
slider.moved(f -> editor.brushSize = MapEditor.brushSizes[(int)(float)f]);
|
||||
slider.moved(f -> editor.brushSize = MapEditor.brushSizes[(int)f]);
|
||||
for(int j = 0; j < MapEditor.brushSizes.length; j++){
|
||||
if(MapEditor.brushSizes[j] == editor.brushSize){
|
||||
slider.setValue(j);
|
||||
|
@ -410,7 +410,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
this.floor = floor.id;
|
||||
this.block = wall.id;
|
||||
this.ore = ore.id;
|
||||
this.team = (byte) team.id;
|
||||
this.team = team.id;
|
||||
this.rotation = (byte)rotation;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class MapRenderer implements Disposable{
|
||||
if(wall.rotate){
|
||||
mesh.draw(idxWall, region,
|
||||
wx * tilesize + wall.offset(), wy * tilesize + wall.offset(),
|
||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.rotation() * 90 - 90);
|
||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.rotdeg() - 90);
|
||||
}else{
|
||||
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class Damage{
|
||||
float dst = tr.set(entity.getX() - x, entity.getY() - y).len();
|
||||
entity.vel().add(tr.setLength((1f - dst / radius) * 2f / entity.mass()));
|
||||
|
||||
if(complete && damage >= 9999999f && entity == player){
|
||||
if(complete && damage >= 9999999f && entity.isPlayer()){
|
||||
Events.fire(Trigger.exclusionDeath);
|
||||
}
|
||||
};
|
||||
@ -270,6 +270,7 @@ public class Damage{
|
||||
}
|
||||
|
||||
@Struct
|
||||
static
|
||||
class PropCellStruct{
|
||||
byte x;
|
||||
byte y;
|
||||
|
@ -13,8 +13,6 @@ import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static mindustry.Vars.content;
|
||||
|
||||
@Component
|
||||
|
@ -223,7 +223,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
||||
}
|
||||
|
||||
public float rotdeg(){
|
||||
return tile.rotation() * 90;
|
||||
return tile.rotdeg();
|
||||
}
|
||||
|
||||
public int rotation(){
|
||||
@ -704,7 +704,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
Draw.rect(block.region, x, y, block.rotate ? rotation() * 90 : 0);
|
||||
Draw.rect(block.region, x, y, block.rotate ? rotdeg() : 0);
|
||||
}
|
||||
|
||||
public void drawLight(){
|
||||
|
@ -20,7 +20,7 @@ public enum Gamemode{
|
||||
}),
|
||||
attack(rules -> {
|
||||
rules.attackMode = true;
|
||||
}, map -> map.teams.contains((int)state.rules.waveTeam.id)),
|
||||
}, map -> map.teams.contains(state.rules.waveTeam.id)),
|
||||
pvp(rules -> {
|
||||
rules.pvp = true;
|
||||
rules.enemyCoreBuildRadius = 600f;
|
||||
|
@ -184,7 +184,28 @@ public class Drawf{
|
||||
Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length / 2f, width, length, width / 2f, oy, rotation - 90);
|
||||
}
|
||||
|
||||
public static void drawRespawn(Tilec tile, float heat, float progress, float time, UnitType to, @Nullable Playerc player){
|
||||
public static void construct(Tilec t, UnitType unit, float rotation, float progress, float speed, float time){
|
||||
TextureRegion region = unit.icon(Cicon.full);
|
||||
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = progress;
|
||||
Shaders.build.color.set(Pal.accent);
|
||||
Shaders.build.color.a = speed;
|
||||
Shaders.build.time = -time / 20f;
|
||||
|
||||
Draw.shader(Shaders.build);
|
||||
Draw.rect(region, t.x(), t.y(), rotation);
|
||||
Draw.shader();
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(speed);
|
||||
|
||||
Lines.lineAngleCenter(t.x() + Mathf.sin(time, 20f, Vars.tilesize / 2f * t.block().size - 2f), t.y(), 90, t.block().size * Vars.tilesize - 4f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public static void respawn(Tilec tile, float heat, float progress, float time, UnitType to, @Nullable Playerc player){
|
||||
float x = tile.x(), y = tile.y();
|
||||
progress = Mathf.clamp(progress);
|
||||
|
||||
|
@ -252,7 +252,7 @@ public class FloorRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
private class Chunk{
|
||||
private static class Chunk{
|
||||
/** Maps cache layer ID to cache ID in the batch.
|
||||
* -1 means that this cache is unoccupied. */
|
||||
int[] caches = new int[CacheLayer.all.length];
|
||||
|
@ -960,7 +960,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
class PlaceLine{
|
||||
static class PlaceLine{
|
||||
public int x, y, rotation;
|
||||
public boolean last;
|
||||
}
|
||||
|
@ -139,17 +139,12 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
r1.setSize(req.block.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
||||
|
||||
if(r2.overlaps(r1)){
|
||||
return req;
|
||||
}
|
||||
}else{
|
||||
r1.setSize(other.block().size * tilesize);
|
||||
r1.setCenter(other.worldx() + other.block().offset(), other.worldy() + other.block().offset());
|
||||
|
||||
if(r2.overlaps(r1)){
|
||||
return req;
|
||||
}
|
||||
}
|
||||
|
||||
if(r2.overlaps(r1)) return req;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class Placement{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
closed.add(Point2.pack((int)next.x, (int)next.y));
|
||||
closed.add(Point2.pack(next.x, next.y));
|
||||
for(Point2 point : Geometry.d4){
|
||||
int newx = next.x + point.x, newy = next.y + point.y;
|
||||
Tile child = world.tile(newx, newy);
|
||||
|
@ -27,7 +27,7 @@ public class LogicExecutor{
|
||||
void exec();
|
||||
}
|
||||
|
||||
class RegisterI implements Instruction{
|
||||
static class RegisterI implements Instruction{
|
||||
/** operation to perform */
|
||||
Op op;
|
||||
/** destination memory */
|
||||
@ -43,7 +43,7 @@ public class LogicExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
class ReadI implements Instruction{
|
||||
static class ReadI implements Instruction{
|
||||
/** register to write result to */
|
||||
short dest;
|
||||
/** device to read from */
|
||||
@ -59,7 +59,7 @@ public class LogicExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
class WriteI implements Instruction{
|
||||
static class WriteI implements Instruction{
|
||||
|
||||
@Override
|
||||
public void exec(){
|
||||
|
@ -3,7 +3,6 @@ package mindustry.maps.filters;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.maps.filters.FilterOption.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.maps.filters.FilterOption.*;
|
||||
|
@ -2,8 +2,6 @@ package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.maps.filters.FilterOption.BlockOption;
|
||||
import mindustry.maps.filters.FilterOption.SliderOption;
|
||||
import mindustry.world.Block;
|
||||
|
||||
import static mindustry.maps.filters.FilterOption.*;
|
||||
|
@ -25,9 +25,7 @@ public class Interpolator{
|
||||
if(lasts.length != values.length){
|
||||
lasts = new float[values.length];
|
||||
}
|
||||
for(int i = 0; i < values.length; i++){
|
||||
lasts[i] = values[i];
|
||||
}
|
||||
System.arraycopy(values, 0, lasts, 0, values.length);
|
||||
last.set(cx, cy);
|
||||
target.set(x, y);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package mindustry.type;
|
||||
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
|
||||
/** Represents a blank type of content that has an error. Replaces anything that failed to parse. */
|
||||
public class ErrorContent extends Content{
|
||||
|
@ -4,7 +4,6 @@ import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
@ -28,8 +27,6 @@ public class Item extends UnlockableContent{
|
||||
* 1 cost = 1 tick added to build time
|
||||
*/
|
||||
public float cost = 1f;
|
||||
/** If true, item is always unlocked. */
|
||||
public boolean alwaysUnlocked = false;
|
||||
|
||||
public Item(String name, Color color){
|
||||
super(name);
|
||||
@ -40,11 +37,6 @@ public class Item extends UnlockableContent{
|
||||
this(name, new Color(Color.black));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysUnlocked(){
|
||||
return alwaysUnlocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayInfo(Table table){
|
||||
ContentDisplay.displayItem(table, this);
|
||||
|
@ -5,7 +5,6 @@ import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class Liquid extends UnlockableContent{
|
||||
|
@ -21,7 +21,6 @@ public class SectorPreset extends UnlockableContent{
|
||||
public Array<Objective> requirements = new Array<>();
|
||||
|
||||
public Cons<Rules> rules = rules -> {};
|
||||
public boolean alwaysUnlocked;
|
||||
public int conditionWave = Integer.MAX_VALUE;
|
||||
public int launchPeriod = 10;
|
||||
public Schematic loadout = Loadouts.basicShard;
|
||||
@ -155,11 +154,6 @@ public class SectorPreset extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysUnlocked(){
|
||||
return alwaysUnlocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(){
|
||||
return true;
|
||||
|
@ -30,6 +30,8 @@ public class UnitType extends UnlockableContent{
|
||||
public boolean flying;
|
||||
public @NonNull Prov<? extends Unitc> constructor;
|
||||
public @NonNull Prov<? extends UnitController> defaultController = () -> !flying ? new GroundAI() : new FlyingAI();
|
||||
public @Nullable UnitType upgrade;
|
||||
public int tier = 1;
|
||||
public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f;
|
||||
public float drag = 0.3f, mass = 1f, accel = 0.5f, landShake = 0f;
|
||||
public float health = 200f, range = -1, armor = 0f;
|
||||
|
@ -15,7 +15,6 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
@ -10,7 +10,6 @@ import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
@ -61,15 +61,12 @@ public class JoinDialog extends FloatingDialog{
|
||||
Server server = new Server();
|
||||
server.setIP(Core.settings.getString("ip"));
|
||||
servers.add(server);
|
||||
saveServers();
|
||||
setupRemote();
|
||||
refreshRemote();
|
||||
}else{
|
||||
renaming.setIP(Core.settings.getString("ip"));
|
||||
saveServers();
|
||||
setupRemote();
|
||||
refreshRemote();
|
||||
}
|
||||
saveServers();
|
||||
setupRemote();
|
||||
refreshRemote();
|
||||
add.hide();
|
||||
}).disabled(b -> Core.settings.getString("ip").isEmpty() || net.active());
|
||||
|
||||
|
@ -8,7 +8,6 @@ import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
|
@ -22,7 +22,6 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.ui.layout.*;
|
||||
import mindustry.ui.layout.TreeLayout.*;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package mindustry.ui.dialogs;
|
||||
import arc.Core;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.net.Administration.TraceInfo;
|
||||
|
||||
public class TraceDialog extends FloatingDialog{
|
||||
|
@ -580,16 +580,14 @@ public class HudFragment extends Fragment{
|
||||
ibuild.setLength(0);
|
||||
int m = i/60;
|
||||
int s = i % 60;
|
||||
if(m <= 0){
|
||||
ibuild.append(s);
|
||||
}else{
|
||||
if(m > 0){
|
||||
ibuild.append(m);
|
||||
ibuild.append(":");
|
||||
if(s < 10){
|
||||
ibuild.append("0");
|
||||
}
|
||||
ibuild.append(s);
|
||||
}
|
||||
ibuild.append(s);
|
||||
return ibuild.toString();
|
||||
});
|
||||
|
||||
|
@ -244,7 +244,7 @@ public class MenuFragment extends Fragment{
|
||||
}
|
||||
}
|
||||
|
||||
private class Buttoni{
|
||||
private static class Buttoni{
|
||||
final Drawable icon;
|
||||
final String text;
|
||||
final Runnable runnable;
|
||||
|
@ -165,7 +165,6 @@ public class Block extends UnlockableContent{
|
||||
public float buildCostMultiplier = 1f;
|
||||
/** Whether this block has instant transfer.*/
|
||||
public boolean instantTransfer = false;
|
||||
public boolean alwaysUnlocked = false;
|
||||
|
||||
protected Prov<Tilec> entityType = null; //initialized later
|
||||
//TODO move
|
||||
@ -352,16 +351,16 @@ public class Block extends UnlockableContent{
|
||||
Draw.reset();
|
||||
Draw.mixcol(!valid ? Pal.breakInvalid : Color.white, (!valid ? 0.4f : 0.24f) + Mathf.absin(Time.globalTime(), 6f, 0.28f));
|
||||
Draw.alpha(1f);
|
||||
float prevScale = Draw.scl;
|
||||
Draw.scl *= req.animScale;
|
||||
drawRequestRegion(req, list);
|
||||
Draw.scl = prevScale;
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
TextureRegion reg = getRequestRegion(req, list);
|
||||
Draw.rect(reg, req.drawx(), req.drawy(),
|
||||
reg.getWidth() * req.animScale * Draw.scl,
|
||||
reg.getHeight() * req.animScale * Draw.scl,
|
||||
!rotate ? 0 : req.rotation * 90);
|
||||
Draw.rect(reg, req.drawx(), req.drawy(), !rotate ? 0 : req.rotation * 90);
|
||||
|
||||
if(req.hasConfig){
|
||||
drawRequestConfig(req, list);
|
||||
@ -380,12 +379,8 @@ public class Block extends UnlockableContent{
|
||||
Color color = content instanceof Item ? ((Item)content).color : content instanceof Liquid ? ((Liquid)content).color : null;
|
||||
if(color == null) return;
|
||||
|
||||
float prev = Draw.scl;
|
||||
|
||||
Draw.color(color);
|
||||
Draw.scl *= req.animScale;
|
||||
Draw.rect(region, req.drawx(), req.drawy());
|
||||
Draw.scl = prev;
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@ -627,11 +622,6 @@ public class Block extends UnlockableContent{
|
||||
return !buildVisibility.visible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysUnlocked(){
|
||||
return alwaysUnlocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createIcons(MultiPacker packer){
|
||||
super.createIcons(packer);
|
||||
|
@ -20,7 +20,7 @@ public class ItemBuffer{
|
||||
|
||||
public void accept(Item item, short data){
|
||||
//if(!accepts()) return;
|
||||
buffer[index++] = Pack.longInt(Float.floatToIntBits(Time.time()), Pack.shortInt((short)item.id, data));
|
||||
buffer[index++] = Pack.longInt(Float.floatToIntBits(Time.time()), Pack.shortInt(item.id, data));
|
||||
}
|
||||
|
||||
public void accept(Item item){
|
||||
|
@ -283,6 +283,10 @@ public class Tile implements Position, QuadTreeObject{
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public int rotdeg(){
|
||||
return rotation * 90;
|
||||
}
|
||||
|
||||
public void rotation(int rotation){
|
||||
this.rotation = (byte)rotation;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class BuildBlock extends Block{
|
||||
@Override
|
||||
public void draw(){
|
||||
if(!(previous == null || cblock == null || previous == cblock) && Core.atlas.isFound(previous.icon(Cicon.full))){
|
||||
Draw.rect(previous.icon(Cicon.full), x, y, previous.rotate ? tile.rotation() * 90 : 0);
|
||||
Draw.rect(previous.icon(Cicon.full), x, y, previous.rotate ? tile.rotdeg() : 0);
|
||||
}
|
||||
|
||||
Draw.draw(Layer.blockBuilding, () -> {
|
||||
@ -183,7 +183,7 @@ public class BuildBlock extends Block{
|
||||
Shaders.blockbuild.region = region;
|
||||
Shaders.blockbuild.progress = progress;
|
||||
|
||||
Draw.rect(region, x, y, target.rotate ? tile.rotation() * 90 : 0);
|
||||
Draw.rect(region, x, y, target.rotate ? tile.rotdeg() : 0);
|
||||
Draw.flush();
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
if(bits == null) return;
|
||||
|
||||
TextureRegion region = regions[bits[0]][0];
|
||||
Draw.rect(region, req.drawx(), req.drawy(), region.getWidth() * bits[1] * Draw.scl * req.animScale, region.getHeight() * bits[2] * Draw.scl * req.animScale, req.rotation * 90);
|
||||
Draw.rect(region, req.drawx(), req.drawy(), region.getWidth() * bits[1] * Draw.scl, region.getHeight() * bits[2] * Draw.scl, req.rotation * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -249,7 +249,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void getStackOffset(Item item, Vec2 trns){
|
||||
trns.trns(tile.rotation() * 90 + 180f, tilesize / 2f);
|
||||
trns.trns(tile.rotdeg() + 180f, tilesize / 2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,6 +14,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@ -81,7 +82,7 @@ public class PayloadConveyor extends Block{
|
||||
//TODO DEBUG
|
||||
if(Core.input.keyTap(KeyCode.g) && world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y) == this){
|
||||
item = new UnitPayload((Mathf.chance(0.5) ? UnitTypes.wraith : UnitTypes.dagger).create(Team.sharded));
|
||||
itemRotation = rotation() * 90;
|
||||
itemRotation = rotdeg();
|
||||
animation = 0f;
|
||||
}
|
||||
|
||||
@ -106,7 +107,7 @@ public class PayloadConveyor extends Block{
|
||||
//dump item forward
|
||||
float trnext = size * tilesize / 2f, cx = Geometry.d4(rotation()).x, cy = Geometry.d4(rotation()).y;
|
||||
|
||||
if(item.dump(x + cx * trnext, y + cy * trnext, rotation() * 90)){
|
||||
if(item.dump(x + cx * trnext, y + cy * trnext, rotdeg())){
|
||||
item = null;
|
||||
}
|
||||
}
|
||||
@ -123,7 +124,7 @@ public class PayloadConveyor extends Block{
|
||||
float glow = Math.max((dst - (Math.abs(fract() - 0.5f) * 2)) / dst, 0);
|
||||
Draw.mixcol(Pal.accent, glow);
|
||||
|
||||
float trnext = fract() * size * tilesize, trprev = size * tilesize * (fract() - 1), rot = rotation() * 90;
|
||||
float trnext = fract() * size * tilesize, trprev = size * tilesize * (fract() - 1), rot = rotdeg();
|
||||
|
||||
TextureRegion clipped = clipRegion(tile.getHitbox(Tmp.r1), tile.getHitbox(Tmp.r2).move(trnext, 0), topRegion);
|
||||
float s = tilesize * size;
|
||||
@ -164,12 +165,12 @@ public class PayloadConveyor extends Block{
|
||||
animation = Math.max(animation, fract());
|
||||
|
||||
float fract = animation;
|
||||
rot = Mathf.slerp(itemRotation, rotation() * 90, fract);
|
||||
rot = Mathf.slerp(itemRotation, rotdeg(), fract);
|
||||
|
||||
if(fract < 0.5f){
|
||||
Tmp.v1.trns(itemRotation + 180, (0.5f - fract) * tilesize * size);
|
||||
}else{
|
||||
Tmp.v1.trns(rotation() * 90, (fract - 0.5f) * tilesize * size);
|
||||
Tmp.v1.trns(rotdeg(), (fract - 0.5f) * tilesize * size);
|
||||
}
|
||||
|
||||
float vx = Tmp.v1.x, vy = Tmp.v1.y;
|
||||
@ -196,10 +197,7 @@ public class PayloadConveyor extends Block{
|
||||
if(direction == rotation()){
|
||||
return !blocked || next != null;
|
||||
}else{
|
||||
Tilec accept = nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size);
|
||||
return accept != null && accept.block().size == size && accept.block().outputsPayload &&
|
||||
//block must either be facing this one, or not be rotating
|
||||
((accept.tileX() + Geometry.d4(accept.rotation()).x * size == tileX() && accept.tileY() + Geometry.d4(accept.rotation()).y * size == tileY()) || !accept.block().rotate);
|
||||
return PayloadAcceptor.blends(this, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class Sorter extends Block{
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildRequest req, Eachable<BuildRequest> list){
|
||||
drawRequestConfigCenter(req, (Item)req.config, "center");
|
||||
drawRequestConfigCenter(req, req.config, "center");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,11 +74,11 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
if(bits == null) return;
|
||||
|
||||
TextureRegion region = regions[0];
|
||||
Draw.rect(region, req.drawx(), req.drawy(), region.getWidth() * Draw.scl * req.animScale, region.getHeight() * Draw.scl * req.animScale, req.rotation * 90);
|
||||
Draw.rect(region, req.drawx(), req.drawy(), req.rotation * 90);
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if((bits[3] & (1 << i)) == 0){
|
||||
Draw.rect(edgeRegion, req.drawx(), req.drawy(), region.getWidth() * Draw.scl * req.animScale, region.getHeight() * Draw.scl * req.animScale, (req.rotation - i) * 90);
|
||||
Draw.rect(edgeRegion, req.drawx(), req.drawy(), (req.rotation - i) * 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,7 +101,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(regions[state], x, y, rotation() * 90);
|
||||
Draw.rect(regions[state], x, y, rotdeg());
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if((blendprox & (1 << i)) == 0){
|
||||
|
@ -26,7 +26,7 @@ public class BlockLauncher extends PayloadAcceptor{
|
||||
size = 3;
|
||||
}
|
||||
|
||||
public class BlockLauncherEntity extends PayloadAcceptorEntity{
|
||||
public class BlockLauncherEntity extends PayloadAcceptorEntity<BlockPayload>{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
@ -42,15 +42,14 @@ public class BlockLauncher extends PayloadAcceptor{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(updatePayload() && efficiency() >= 0.99f){
|
||||
if(moveInPayload() && efficiency() >= 0.99f){
|
||||
Effects.shake(4f, 4f, this);
|
||||
Fx.producesmoke.at(this);
|
||||
|
||||
positions.clear();
|
||||
BlockPayload pay = (BlockPayload)payload;
|
||||
|
||||
Geometry.circle(tileX(), tileY(), world.width(), world.height(), (int)(range / tilesize), (cx, cy) -> {
|
||||
if(Build.validPlace(team, cx, cy, pay.block, 0)){
|
||||
if(Build.validPlace(team, cx, cy, payload.block, 0)){
|
||||
positions.add(Point2.pack(cx, cy));
|
||||
}
|
||||
});
|
||||
@ -58,7 +57,7 @@ public class BlockLauncher extends PayloadAcceptor{
|
||||
if(positions.isEmpty()) return;
|
||||
|
||||
int pick = positions.random();
|
||||
LaunchedBlock launch = new LaunchedBlock(Point2.x(pick), Point2.y(pick), pay.block, team);
|
||||
LaunchedBlock launch = new LaunchedBlock(Point2.x(pick), Point2.y(pick), payload.block, team);
|
||||
Fx.blockTransfer.at(x, y, 0, launch);
|
||||
Time.run(Fx.blockTransfer.lifetime, () -> {
|
||||
float ex = launch.x * tilesize + launch.block.offset(), ey = launch.y * tilesize + launch.block.offset();
|
||||
@ -75,7 +74,7 @@ public class BlockLauncher extends PayloadAcceptor{
|
||||
}
|
||||
}
|
||||
|
||||
public class LaunchedBlock{
|
||||
public static class LaunchedBlock{
|
||||
public final int x, y;
|
||||
public final Block block;
|
||||
public final Team team;
|
||||
|
@ -28,7 +28,7 @@ public class ArmoredConduit extends Conduit{
|
||||
Tilec next = tile.front();
|
||||
if(next != null && next.team() == team && next.block().hasLiquids) return;
|
||||
|
||||
Draw.rect(capRegion, x, y, tile.rotation() * 90);
|
||||
Draw.rect(capRegion, x, y, tile.rotdeg());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,13 +42,11 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
|
||||
Draw.color(botColor);
|
||||
Draw.alpha(0.5f);
|
||||
Draw.rect(botRegions[bits[0]], req.drawx(), req.drawy(),
|
||||
botRegions[bits[0]].getWidth() * Draw.scl * req.animScale, botRegions[bits[0]].getHeight() * Draw.scl * req.animScale,
|
||||
req.rotation * 90);
|
||||
Draw.rect(botRegions[bits[0]], req.drawx(), req.drawy(), req.rotation * 90);
|
||||
Draw.color();
|
||||
|
||||
|
||||
Draw.rect(topRegions[bits[0]], req.drawx(), req.drawy(), topRegions[bits[0]].getWidth() * Draw.scl * req.animScale, topRegions[bits[0]].getHeight() * Draw.scl * req.animScale, req.rotation * 90);
|
||||
Draw.rect(topRegions[bits[0]], req.drawx(), req.drawy(), req.rotation * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,7 +80,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
int rotation = rotation() * 90;
|
||||
float rotation = rotdeg();
|
||||
|
||||
Draw.color(botColor);
|
||||
Draw.rect(botRegions[blendbits], x, y, rotation);
|
||||
|
@ -29,7 +29,7 @@ public class LiquidBlock extends Block{
|
||||
public class LiquidBlockEntity extends TileEntity{
|
||||
@Override
|
||||
public void draw(){
|
||||
int rotation = rotate ? rotation() * 90 : 0;
|
||||
float rotation = rotate ? rotdeg() : 0;
|
||||
Draw.rect(bottomRegion, x, y, rotation);
|
||||
|
||||
if(liquids.total() > 0.001f){
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mindustry.world.blocks.payloads;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
@ -14,6 +15,9 @@ public class UnitPayload implements Payload{
|
||||
|
||||
@Override
|
||||
public boolean dump(float x, float y, float rotation){
|
||||
//no client dumping
|
||||
if(Vars.net.client()) return true;
|
||||
|
||||
unit.set(x, y);
|
||||
unit.rotation(rotation);
|
||||
unit.add();
|
||||
@ -23,8 +27,8 @@ public class UnitPayload implements Payload{
|
||||
|
||||
@Override
|
||||
public void draw(float x, float y, float rotation){
|
||||
Drawf.shadow(x, y, 24);
|
||||
Draw.rect("pneumatic-drill", x, y, rotation);
|
||||
// Drawf.shadow(x, y, 24);
|
||||
//Draw.rect("pneumatic-drill", x, y, rotation);
|
||||
Drawf.shadow(x, y, 20);
|
||||
Draw.rect(unit.type().icon(Cicon.full), x, y, rotation - 90);
|
||||
}
|
||||
|
@ -32,16 +32,9 @@ public class PowerDiode extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list) {
|
||||
TextureRegion reg = icon(Cicon.full);
|
||||
Draw.rect(icon(Cicon.full), req.drawx(), req.drawy(),
|
||||
reg.getWidth() * req.animScale * Draw.scl,
|
||||
reg.getHeight() * req.animScale * Draw.scl,
|
||||
0);
|
||||
Draw.rect(arrow, req.drawx(), req.drawy(),
|
||||
arrow.getWidth() * req.animScale * Draw.scl,
|
||||
arrow.getHeight() * req.animScale * Draw.scl,
|
||||
!rotate ? 0 : req.rotation * 90);
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
Draw.rect(icon(Cicon.full), req.drawx(), req.drawy());
|
||||
Draw.rect(arrow, req.drawx(), req.drawy(), !rotate ? 0 : req.rotation * 90);
|
||||
}
|
||||
|
||||
// battery % of the graph on either side, defaults to zero
|
||||
@ -53,7 +46,7 @@ public class PowerDiode extends Block{
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y, 0);
|
||||
Draw.rect(arrow, x, y, rotate ? tile.rotation() * 90 : 0);
|
||||
Draw.rect(arrow, x, y, rotate ? tile.rotdeg() : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -266,7 +266,7 @@ public class PowerNode extends PowerBlock{
|
||||
public void placed(){
|
||||
if(net.client()) return;
|
||||
|
||||
Boolf<Tilec> valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) ||
|
||||
Boolf<Tilec> valid = other -> other != null && other != this && ((!other.block().outputsPower && other.block().consumesPower) ||
|
||||
(other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(this, other)
|
||||
&& !other.proximity().contains(this) && other.power().graph != power.graph;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package mindustry.world.blocks.production;
|
||||
import arc.func.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
|
@ -12,6 +12,7 @@ import mindustry.world.blocks.payloads.*;
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class PayloadAcceptor extends Block{
|
||||
public float payloadSpeed = 0.5f;
|
||||
|
||||
public PayloadAcceptor(String name){
|
||||
super(name);
|
||||
@ -19,10 +20,20 @@ public class PayloadAcceptor extends Block{
|
||||
update = true;
|
||||
}
|
||||
|
||||
public class PayloadAcceptorEntity extends TileEntity{
|
||||
public @Nullable Payload payload;
|
||||
public Vec2 inputVector = new Vec2();
|
||||
public float inputRotation;
|
||||
public static boolean blends(Tilec tile, int direction){
|
||||
int size = tile.block().size;
|
||||
Tilec accept = tile.nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size);
|
||||
return accept != null &&
|
||||
accept.block().size == size &&
|
||||
accept.block().outputsPayload &&
|
||||
//block must either be facing this one, or not be rotating
|
||||
((accept.tileX() + Geometry.d4(accept.rotation()).x * size == tile.tileX() && accept.tileY() + Geometry.d4(accept.rotation()).y * size == tile.tileY()) || !accept.block().rotate);
|
||||
}
|
||||
|
||||
public class PayloadAcceptorEntity<T extends Payload> extends TileEntity{
|
||||
public @Nullable T payload;
|
||||
public Vec2 payVector = new Vec2();
|
||||
public float payRotation;
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
@ -31,25 +42,29 @@ public class PayloadAcceptor extends Block{
|
||||
|
||||
@Override
|
||||
public void handlePayload(Tilec source, Payload payload){
|
||||
this.payload = payload;
|
||||
this.inputVector.set(source).sub(this).clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f);
|
||||
this.inputRotation = source.angleTo(this);
|
||||
this.payload = (T)payload;
|
||||
this.payVector.set(source).sub(this).clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f);
|
||||
this.payRotation = source.angleTo(this);
|
||||
}
|
||||
|
||||
/** @return true if the payload is in position. */
|
||||
public boolean updatePayload(){
|
||||
public boolean moveInPayload(){
|
||||
if(payload == null) return false;
|
||||
|
||||
inputRotation = Mathf.slerpDelta(inputRotation, 90f, 0.3f);
|
||||
inputVector.lerpDelta(Vec2.ZERO, 0.2f);
|
||||
payRotation = Mathf.slerpDelta(payRotation, rotate ? rotdeg() : 90f, 0.3f);
|
||||
payVector.approachDelta(Vec2.ZERO, payloadSpeed);
|
||||
|
||||
return inputVector.isZero(0.5f);
|
||||
return hasArrived();
|
||||
}
|
||||
|
||||
public boolean hasArrived(){
|
||||
return payVector.isZero(0.01f);
|
||||
}
|
||||
|
||||
public void drawPayload(){
|
||||
if(payload != null){
|
||||
Draw.z(Layer.blockOver);
|
||||
payload.draw(x + inputVector.x, y + inputVector.y, inputRotation);
|
||||
payload.draw(x + payVector.x, y + payVector.y, payRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,13 @@ import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.Vars.content;
|
||||
|
||||
public class LiquidSource extends Block{
|
||||
|
||||
@ -39,7 +38,7 @@ public class LiquidSource extends Block{
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildRequest req, Eachable<BuildRequest> list){
|
||||
drawRequestConfigCenter(req, (Content)req.config, "center");
|
||||
drawRequestConfigCenter(req, req.config, "center");
|
||||
}
|
||||
|
||||
public class LiquidSourceEntity extends TileEntity{
|
||||
|
@ -216,7 +216,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
if(heat > 0.001f){
|
||||
Draw.draw(Layer.blockOver, () -> {
|
||||
Drawf.drawRespawn(this, heat, progress, time, unitType, lastRequested);
|
||||
Drawf.respawn(this, heat, progress, time, unitType, lastRequested);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class Unloader extends Block{
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildRequest req, Eachable<BuildRequest> list){
|
||||
drawRequestConfigCenter(req, (Item)req.config, "unloader-center");
|
||||
drawRequestConfigCenter(req, req.config, "unloader-center");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,21 +1,122 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
||||
public class Reconstructor extends Block{
|
||||
import static mindustry.Vars.state;
|
||||
|
||||
public class Reconstructor extends UnitBlock{
|
||||
public @Load(value = "@-top", fallback = "factory-top") TextureRegion topRegion;
|
||||
public @Load(value = "@-out", fallback = "factory-out") TextureRegion outRegion;
|
||||
public @Load(value = "@-in", fallback = "factory-in") TextureRegion inRegion;
|
||||
public int tier = 1;
|
||||
public float constructTime = 60 * 2;
|
||||
|
||||
public Reconstructor(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
public class ReassemblerEntity extends TileEntity{
|
||||
public @Nullable Unitc unit;
|
||||
@Override
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
Draw.rect(region, req.drawx(), req.drawy());
|
||||
Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90);
|
||||
Draw.rect(topRegion, req.drawx(), req.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, ((ReconstructorEntity)entity)::fraction));
|
||||
}
|
||||
|
||||
public class ReconstructorEntity extends UnitBlockEntity{
|
||||
|
||||
public float fraction(){
|
||||
return progress / constructTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
return this.payload == null
|
||||
&& relativeTo(source) != rotation()
|
||||
&& payload instanceof UnitPayload
|
||||
&& ((UnitPayload)payload).unit.type().upgrade != null
|
||||
&& ((UnitPayload)payload).unit.type().tier == tier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y);
|
||||
|
||||
//draw input
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(blends(this, i) && i != rotation()){
|
||||
Draw.rect(inRegion, x, y, i * 90);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.rect(outRegion, x, y, rotdeg());
|
||||
|
||||
if(constructing() && hasArrived()){
|
||||
Draw.draw(Layer.blockOver, () -> {
|
||||
Draw.alpha(1f - progress/ constructTime);
|
||||
Draw.rect(payload.unit.type().icon(Cicon.full), x, y, rotdeg() - 90);
|
||||
Draw.reset();
|
||||
Drawf.construct(this, payload.unit.type().upgrade, rotdeg() - 90f, progress / constructTime, speedScl, time);
|
||||
});
|
||||
}else{
|
||||
Draw.z(Layer.blockOver);
|
||||
payRotation = rotdeg();
|
||||
|
||||
drawPayload();
|
||||
}
|
||||
|
||||
Draw.z(Layer.blockOver + 0.1f);
|
||||
Draw.rect(topRegion, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
boolean valid = false;
|
||||
|
||||
if(payload != null){
|
||||
//check if offloading
|
||||
if(payload.unit.type().upgrade == null || payload.unit.type().tier != tier){
|
||||
outputPayload();
|
||||
}else{ //update progress
|
||||
if(moveInPayload()){
|
||||
if(consValid()){
|
||||
valid = true;
|
||||
progress += edelta();
|
||||
}
|
||||
|
||||
//upgrade the unit
|
||||
if(progress >= constructTime){
|
||||
payload.unit = payload.unit.type().upgrade.create(payload.unit.team());
|
||||
progress = 0;
|
||||
Fx.unitSpawn.at(this);
|
||||
consume();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
speedScl = Mathf.lerpDelta(speedScl, Mathf.num(valid), 0.05f);
|
||||
time += edelta() * speedScl * state.rules.unitBuildSpeedMultiplier;
|
||||
}
|
||||
|
||||
public boolean constructing(){
|
||||
return payload != null && payload.unit.type().upgrade != null && payload.unit.type().tier == tier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
75
core/src/mindustry/world/blocks/units/UnitBlock.java
Normal file
@ -0,0 +1,75 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UnitBlock extends PayloadAcceptor{
|
||||
|
||||
public UnitBlock(String name){
|
||||
super(name);
|
||||
|
||||
outputsPayload = true;
|
||||
rotate = true;
|
||||
update = true;
|
||||
solid = true;
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onUnitBlockSpawn(Tile tile){
|
||||
if(!(tile.entity instanceof UnitBlockEntity)) return;
|
||||
tile.<UnitBlockEntity>ent().spawned();
|
||||
}
|
||||
|
||||
|
||||
public class UnitBlockEntity extends PayloadAcceptorEntity<UnitPayload>{
|
||||
public float progress, payloadPos, time, speedScl;
|
||||
|
||||
public void spawned(){
|
||||
progress = 0f;
|
||||
|
||||
if(!net.client() && payload != null){
|
||||
Unitc unit = payload.unit;
|
||||
unit.set(x, y);
|
||||
unit.rotation(rotdeg());
|
||||
unit.vel().trns(rotdeg(), payloadSpeed * 2f).add(Mathf.range(0.1f), Mathf.range(0.1f));
|
||||
unit.trns(Tmp.v1.trns(rotdeg(), size * tilesize/2f));
|
||||
unit.trns(unit.vel());
|
||||
unit.add();
|
||||
Events.fire(new UnitCreateEvent(unit));
|
||||
}
|
||||
|
||||
payload = null;
|
||||
}
|
||||
|
||||
public void outputPayload(){
|
||||
if(payload == null) return;
|
||||
|
||||
payloadPos += edelta() * payloadSpeed;
|
||||
payVector.trns(rotdeg(), payloadPos);
|
||||
payRotation = rotdeg();
|
||||
|
||||
if(payloadPos >= size * tilesize/2f){
|
||||
payloadPos = size * tilesize/2f;
|
||||
|
||||
Tile front = frontLarge();
|
||||
if(front != null && front.entity != null && front.block().outputsPayload){
|
||||
if(movePayload(payload)){
|
||||
payload = null;
|
||||
}
|
||||
}else if(front != null && !front.solid()){
|
||||
//create unit if there's space
|
||||
Call.onUnitBlockSpawn(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,28 +7,22 @@ import arc.math.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UnitFactory extends Block{
|
||||
public float payloadSpeed = 0.5f;
|
||||
public class UnitFactory extends UnitBlock{
|
||||
public @Load(value = "@-top", fallback = "factory-top") TextureRegion topRegion;
|
||||
public @Load(value = "@-out", fallback = "factory-out") TextureRegion outRegion;
|
||||
public int[] capacities;
|
||||
@ -63,12 +57,6 @@ public class UnitFactory extends Block{
|
||||
}));
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onUnitFactorySpawn(Tile tile){
|
||||
if(!(tile.entity instanceof UnitFactoryEntity)) return;
|
||||
tile.<UnitFactoryEntity>ent().spawned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
@ -106,9 +94,9 @@ public class UnitFactory extends Block{
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
Draw.rect(region, req.drawx(), req.drawy(), region.getWidth() * req.animScale * Draw.scl, region.getHeight() * req.animScale * Draw.scl);
|
||||
Draw.rect(outRegion, req.drawx(), req.drawy(), outRegion.getWidth() * req.animScale * Draw.scl, outRegion.getHeight() * req.animScale * Draw.scl, req.rotation * 90);
|
||||
Draw.rect(topRegion, req.drawx(), req.drawy(), outRegion.getWidth() * req.animScale * Draw.scl, outRegion.getHeight() * req.animScale * Draw.scl);
|
||||
Draw.rect(region, req.drawx(), req.drawy());
|
||||
Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90);
|
||||
Draw.rect(topRegion, req.drawx(), req.drawy());
|
||||
}
|
||||
|
||||
public static class UnitPlan{
|
||||
@ -125,10 +113,8 @@ public class UnitFactory extends Block{
|
||||
UnitPlan(){}
|
||||
}
|
||||
|
||||
public class UnitFactoryEntity extends TileEntity{
|
||||
public class UnitFactoryEntity extends UnitBlockEntity{
|
||||
public int currentPlan = -1;
|
||||
public float progress, time, speedScl, payloadPos;
|
||||
public @Nullable UnitPayload payload;
|
||||
|
||||
public float fraction(){
|
||||
return currentPlan == -1 ? 0 : progress / plans[currentPlan].time;
|
||||
@ -141,6 +127,11 @@ public class UnitFactory extends Block{
|
||||
ItemSelection.buildTable(table, units, () -> currentPlan == -1 ? null : plans[currentPlan].unit, unit -> configure(units.indexOf(unit)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
super.display(table);
|
||||
@ -166,96 +157,38 @@ public class UnitFactory extends Block{
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y);
|
||||
Draw.rect(outRegion, x, y, rotation() * 90);
|
||||
Draw.rect(outRegion, x, y, rotdeg());
|
||||
|
||||
if(currentPlan != -1){
|
||||
UnitPlan plan = plans[currentPlan];
|
||||
|
||||
Draw.draw(Layer.blockOver, () -> {
|
||||
TextureRegion region = plan.unit.icon(Cicon.full);
|
||||
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = progress / plan.time;
|
||||
Shaders.build.color.set(Pal.accent);
|
||||
Shaders.build.color.a = speedScl;
|
||||
Shaders.build.time = -time / 20f;
|
||||
|
||||
Draw.shader(Shaders.build);
|
||||
Draw.rect(region, x, y, rotation() * 90 - 90);
|
||||
Draw.shader();
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(speedScl);
|
||||
|
||||
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
Draw.draw(Layer.blockOver, () -> Drawf.construct(this, plan.unit, rotdeg() - 90f, progress / plan.time, speedScl, time));
|
||||
}
|
||||
|
||||
Draw.z(Layer.blockOver);
|
||||
|
||||
if(payload != null){
|
||||
payload.draw(
|
||||
x + Angles.trnsx(rotation() * 90, payloadPos),
|
||||
y + Angles.trnsy(rotation() * 90, payloadPos),
|
||||
rotation() * 90
|
||||
);
|
||||
}
|
||||
payRotation = rotdeg();
|
||||
drawPayload();
|
||||
|
||||
Draw.z(Layer.blockOver + 0.1f);
|
||||
|
||||
Draw.rect(topRegion, x, y);
|
||||
}
|
||||
|
||||
public void spawned(){
|
||||
progress = 0f;
|
||||
|
||||
if(!net.client() && payload != null){
|
||||
Unitc unit = payload.unit;
|
||||
unit.set(x, y);
|
||||
|
||||
unit.rotation(rotation() * 90);
|
||||
unit.vel().trns(rotation() * 90, payloadSpeed * 2f).add(Mathf.range(0.1f), Mathf.range(0.1f));
|
||||
unit.trns(Tmp.v1.trns(rotation() * 90, size * tilesize/2f));
|
||||
unit.trns(unit.vel());
|
||||
unit.add();
|
||||
Events.fire(new UnitCreateEvent(unit));
|
||||
}
|
||||
|
||||
payload = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(currentPlan < 0 || currentPlan >= plans.length){
|
||||
currentPlan = -1;
|
||||
}
|
||||
|
||||
if((consValid() || tile.isEnemyCheat()) && currentPlan != -1){
|
||||
time += delta() * efficiency() * speedScl * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
progress += delta() * efficiency() * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
if(consValid() && currentPlan != -1){
|
||||
time += edelta() * speedScl * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
progress += edelta() * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
speedScl = Mathf.lerpDelta(speedScl, 1f, 0.05f);
|
||||
}else{
|
||||
speedScl = Mathf.lerpDelta(speedScl, 0f, 0.05f);
|
||||
}
|
||||
|
||||
if(payload != null){
|
||||
payloadPos += edelta() * payloadSpeed;
|
||||
if(payloadPos >= size * tilesize/2f){
|
||||
payloadPos = size * tilesize/2f;
|
||||
|
||||
Tile front = frontLarge();
|
||||
if(front != null && front.entity != null && front.block().outputsPayload){
|
||||
if(movePayload(payload)){
|
||||
payload = null;
|
||||
}
|
||||
}else if(front != null && !front.solid()){
|
||||
//create unit
|
||||
Call.onUnitFactorySpawn(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
outputPayload();
|
||||
|
||||
if(currentPlan != -1 && payload == null){
|
||||
UnitPlan plan = plans[currentPlan];
|
||||
|
@ -7,7 +7,6 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.world.meta.values.*;
|
||||
|
||||
|
@ -6,7 +6,6 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.world.meta.values.*;
|
||||
|
||||
@ -19,7 +18,7 @@ public class ConsumeItems extends Consume{
|
||||
|
||||
/** Mods.*/
|
||||
protected ConsumeItems(){
|
||||
this(new ItemStack[]{});
|
||||
this(ItemStack.empty);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,6 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
|
@ -57,9 +57,7 @@ public class LiquidModule extends BlockModule{
|
||||
}
|
||||
|
||||
public void reset(Liquid liquid, float amount){
|
||||
for(int i = 0; i < liquids.length; i++){
|
||||
liquids[i] = 0f;
|
||||
}
|
||||
Arrays.fill(liquids, 0f);
|
||||
liquids[liquid.id] = amount;
|
||||
total = amount;
|
||||
current = liquid;
|
||||
|