Merge branch 'master' of https://github.com/Anuken/Mindustry into v105
@@ -572,6 +572,8 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
//implement each definition
|
//implement each definition
|
||||||
for(EntityDefinition def : definitions){
|
for(EntityDefinition def : definitions){
|
||||||
|
|
||||||
|
ObjectSet<String> methodNames = def.components.flatMap(type -> type.methods().map(Smethod::simpleString)).<String>as().asSet();
|
||||||
|
|
||||||
//get interface for each component
|
//get interface for each component
|
||||||
for(Stype comp : def.components){
|
for(Stype comp : def.components){
|
||||||
|
|
||||||
@@ -588,8 +590,8 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
for(Smethod method : inter.methods()){
|
for(Smethod method : inter.methods()){
|
||||||
String var = method.name();
|
String var = method.name();
|
||||||
FieldSpec field = Array.with(def.builder.fieldSpecs).find(f -> f.name.equals(var));
|
FieldSpec field = Array.with(def.builder.fieldSpecs).find(f -> f.name.equals(var));
|
||||||
//make sure it's a real variable AND that the component doesn't already implement it with custom logic
|
//make sure it's a real variable AND that the component doesn't already implement it somewhere with custom logic
|
||||||
if(field == null || comp.methods().contains(m -> m.simpleString().equals(method.simpleString()))) continue;
|
if(field == null || methodNames.contains(method.simpleString())) continue;
|
||||||
|
|
||||||
//getter
|
//getter
|
||||||
if(!method.isVoid()){
|
if(!method.isVoid()){
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
alpha=0
|
alpha=0
|
||||||
block=1
|
block=1
|
||||||
|
cix=17
|
||||||
draug=2
|
draug=2
|
||||||
mindustry.entities.comp.BulletComp=3
|
mindustry.entities.comp.BulletComp=3
|
||||||
mindustry.entities.comp.DecalComp=4
|
mindustry.entities.comp.DecalComp=4
|
||||||
|
|||||||
BIN
core/assets-raw/sprites/blocks/distribution/block-loader.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
core/assets-raw/sprites/blocks/distribution/block-unloader.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 579 B |
|
Before Width: | Height: | Size: 564 B |
|
Before Width: | Height: | Size: 1007 B |
|
Before Width: | Height: | Size: 578 B |
|
Before Width: | Height: | Size: 965 B |
|
Before Width: | Height: | Size: 566 B |
|
Before Width: | Height: | Size: 581 B |
BIN
core/assets-raw/sprites/units/cix-leg.png
Normal file
|
After Width: | Height: | Size: 223 B |
BIN
core/assets-raw/sprites/units/cix.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
core/assets-raw/sprites/units/reaper.aseprite
Normal file
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
@@ -233,3 +233,5 @@
|
|||||||
63511=naval-factory|block-naval-factory-medium
|
63511=naval-factory|block-naval-factory-medium
|
||||||
63510=air-factory|block-air-factory-medium
|
63510=air-factory|block-air-factory-medium
|
||||||
63509=basic-reconstructor|block-basic-reconstructor-medium
|
63509=basic-reconstructor|block-basic-reconstructor-medium
|
||||||
|
63508=block-loader|block-block-loader-medium
|
||||||
|
63507=block-unloader|block-block-unloader-medium
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 724 B |
|
Before Width: | Height: | Size: 818 KiB After Width: | Height: | Size: 818 KiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 859 KiB After Width: | Height: | Size: 876 KiB |
@@ -24,6 +24,7 @@ import mindustry.maps.*;
|
|||||||
import mindustry.mod.*;
|
import mindustry.mod.*;
|
||||||
import mindustry.net.Net;
|
import mindustry.net.Net;
|
||||||
import mindustry.net.*;
|
import mindustry.net.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
@@ -84,6 +85,8 @@ public class Vars implements Loadable{
|
|||||||
public static final float turnDuration = 5 * Time.toMinutes;
|
public static final float turnDuration = 5 * Time.toMinutes;
|
||||||
/** min armor fraction damage; e.g. 0.05 = at least 5% damage */
|
/** min armor fraction damage; e.g. 0.05 = at least 5% damage */
|
||||||
public static final float minArmorDamage = 0.05f;
|
public static final float minArmorDamage = 0.05f;
|
||||||
|
/** tile used in certain situations, instead of null */
|
||||||
|
public static Tile emptyTile;
|
||||||
/** for map generator dialog */
|
/** for map generator dialog */
|
||||||
public static boolean updateEditorOnChange = false;
|
public static boolean updateEditorOnChange = false;
|
||||||
/** size of tiles in units */
|
/** size of tiles in units */
|
||||||
@@ -231,6 +234,7 @@ public class Vars implements Loadable{
|
|||||||
schematicDirectory = dataDirectory.child("schematics/");
|
schematicDirectory = dataDirectory.child("schematics/");
|
||||||
bebuildDirectory = dataDirectory.child("be_builds/");
|
bebuildDirectory = dataDirectory.child("be_builds/");
|
||||||
emptyMap = new Map(new StringMap());
|
emptyMap = new Map(new StringMap());
|
||||||
|
emptyTile = null;
|
||||||
|
|
||||||
if(tree == null) tree = new FileTree();
|
if(tree == null) tree = new FileTree();
|
||||||
if(mods == null) mods = new Mods();
|
if(mods == null) mods = new Mods();
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ public class GroundAI extends AIController{
|
|||||||
target = null;
|
target = null;
|
||||||
|
|
||||||
//TODO this is hacky, cleanup
|
//TODO this is hacky, cleanup
|
||||||
if(unit instanceof Legsc && unit.moving()){
|
if(unit instanceof Mechc && unit.moving()){
|
||||||
unit.lookAt(((Legsc)unit).baseRotation());
|
unit.lookAt(((Mechc)unit).baseRotation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
//misc experimental
|
//misc experimental
|
||||||
|
|
||||||
blockForge, blockLauncher;
|
blockForge, blockLauncher, blockLoader, blockUnloader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
@@ -1274,7 +1274,7 @@ public class Blocks implements ContentList{
|
|||||||
//region storage
|
//region storage
|
||||||
|
|
||||||
coreShard = new CoreBlock("core-shard"){{
|
coreShard = new CoreBlock("core-shard"){{
|
||||||
requirements(Category.effect, BuildVisibility.debugOnly, ItemStack.with());
|
requirements(Category.effect, BuildVisibility.hidden, ItemStack.with());
|
||||||
alwaysUnlocked = true;
|
alwaysUnlocked = true;
|
||||||
|
|
||||||
health = 1100;
|
health = 1100;
|
||||||
@@ -1283,7 +1283,7 @@ public class Blocks implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
coreFoundation = new CoreBlock("core-foundation"){{
|
coreFoundation = new CoreBlock("core-foundation"){{
|
||||||
requirements(Category.effect, BuildVisibility.debugOnly, ItemStack.with());
|
requirements(Category.effect, BuildVisibility.hidden, ItemStack.with());
|
||||||
|
|
||||||
health = 2000;
|
health = 2000;
|
||||||
itemCapacity = 9000;
|
itemCapacity = 9000;
|
||||||
@@ -1291,7 +1291,7 @@ public class Blocks implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
coreNucleus = new CoreBlock("core-nucleus"){{
|
coreNucleus = new CoreBlock("core-nucleus"){{
|
||||||
requirements(Category.effect, BuildVisibility.debugOnly, ItemStack.with());
|
requirements(Category.effect, BuildVisibility.hidden, ItemStack.with());
|
||||||
|
|
||||||
health = 4000;
|
health = 4000;
|
||||||
itemCapacity = 13000;
|
itemCapacity = 13000;
|
||||||
@@ -1789,6 +1789,20 @@ public class Blocks implements ContentList{
|
|||||||
consumes.power(2f);
|
consumes.power(2f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
blockLoader = new BlockLoader("block-loader"){{
|
||||||
|
requirements(Category.production, BuildVisibility.debugOnly, ItemStack.with(Items.thorium, 100));
|
||||||
|
hasPower = true;
|
||||||
|
consumes.power(2f);
|
||||||
|
size = 3;
|
||||||
|
}};
|
||||||
|
|
||||||
|
blockUnloader = new BlockUnloader("block-unloader"){{
|
||||||
|
requirements(Category.production, BuildVisibility.debugOnly, ItemStack.with(Items.thorium, 100));
|
||||||
|
hasPower = true;
|
||||||
|
consumes.power(2f);
|
||||||
|
size = 3;
|
||||||
|
}};
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ import mindustry.type.*;
|
|||||||
public class UnitTypes implements ContentList{
|
public class UnitTypes implements ContentList{
|
||||||
|
|
||||||
//ground
|
//ground
|
||||||
public static @EntityDef({Unitc.class, Legsc.class}) UnitType titan, dagger, crawler, fortress, eruptor, chaosArray, eradicator;
|
public static @EntityDef({Unitc.class, Mechc.class}) UnitType titan, dagger, crawler, fortress, eruptor, chaosArray, eradicator;
|
||||||
|
|
||||||
//ground + builder
|
//ground + builder
|
||||||
public static @EntityDef({Unitc.class, Legsc.class, Builderc.class}) UnitType oculon, tau;
|
public static @EntityDef({Unitc.class, Mechc.class, Builderc.class}) UnitType oculon, tau;
|
||||||
|
|
||||||
|
//legs
|
||||||
|
public static @EntityDef({Unitc.class, Legsc.class}) UnitType cix;
|
||||||
|
|
||||||
//air
|
//air
|
||||||
public static @EntityDef({Unitc.class}) UnitType wraith, reaper, ghoul, revenant, lich;
|
public static @EntityDef({Unitc.class}) UnitType wraith, reaper, ghoul, revenant, lich;
|
||||||
@@ -65,6 +68,15 @@ public class UnitTypes implements ContentList{
|
|||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
cix = new UnitType("cix"){{
|
||||||
|
drag = 0.1f;
|
||||||
|
speed = 0.8f;
|
||||||
|
hitsize = 8f;
|
||||||
|
health = 130;
|
||||||
|
|
||||||
|
legCount = 6;
|
||||||
|
}};
|
||||||
|
|
||||||
titan = new UnitType("titan"){{
|
titan = new UnitType("titan"){{
|
||||||
dagger.upgrade = this;
|
dagger.upgrade = this;
|
||||||
tier = 2;
|
tier = 2;
|
||||||
|
|||||||
@@ -569,7 +569,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
unit.x(), unit.y(),
|
unit.x(), unit.y(),
|
||||||
player.unit().aimX(), player.unit().aimY(),
|
player.unit().aimX(), player.unit().aimY(),
|
||||||
unit.rotation(),
|
unit.rotation(),
|
||||||
unit instanceof Legsc ? ((Legsc)unit).baseRotation() : 0,
|
unit instanceof Mechc ? ((Mechc)unit).baseRotation() : 0,
|
||||||
unit.vel().x, unit.vel().y,
|
unit.vel().x, unit.vel().y,
|
||||||
player.miner().mineTile(),
|
player.miner().mineTile(),
|
||||||
control.input.isBoosting, control.input.isShooting, ui.chatfrag.shown(),
|
control.input.isBoosting, control.input.isShooting, ui.chatfrag.shown(),
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
fbuffer.position(0);
|
fbuffer.position(0);
|
||||||
|
|
||||||
//now, put the new position, rotation and baserotation into the buffer so it can be read
|
//now, put the new position, rotation and baserotation into the buffer so it can be read
|
||||||
if(unit instanceof Legsc) fbuffer.put(baseRotation); //base rotation is optional
|
if(unit instanceof Mechc) fbuffer.put(baseRotation); //base rotation is optional
|
||||||
fbuffer.put(rotation); //rotation is always there
|
fbuffer.put(rotation); //rotation is always there
|
||||||
fbuffer.put(newx);
|
fbuffer.put(newx);
|
||||||
fbuffer.put(newy);
|
fbuffer.put(newy);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.editor;
|
package mindustry.editor;
|
||||||
|
|
||||||
|
import arc.func.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.editor.DrawOperation.*;
|
import mindustry.editor.DrawOperation.*;
|
||||||
@@ -108,9 +109,9 @@ public class EditorTile extends Tile{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void changeEntity(Team team){
|
protected void changeEntity(Team team, Prov<Tilec> entityprov){
|
||||||
if(state.isGame()){
|
if(state.isGame()){
|
||||||
super.changeEntity(team);
|
super.changeEntity(team, entityprov);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ public class EditorTile extends Tile{
|
|||||||
Block block = block();
|
Block block = block();
|
||||||
|
|
||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
entity = block.newEntity().init(this, team, false);
|
entity = entityprov.get().init(this, team, false);
|
||||||
entity.cons(new ConsumeModule(entity));
|
entity.cons(new ConsumeModule(entity));
|
||||||
if(block.hasItems) entity.items(new ItemModule());
|
if(block.hasItems) entity.items(new ItemModule());
|
||||||
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import mindustry.ui.dialogs.*;
|
|||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -683,7 +684,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
for(Block block : blocksOut){
|
for(Block block : blocksOut){
|
||||||
TextureRegion region = block.icon(Cicon.medium);
|
TextureRegion region = block.icon(Cicon.medium);
|
||||||
|
|
||||||
if(!Core.atlas.isFound(region) || !block.inEditor) continue;
|
if(!Core.atlas.isFound(region) || !block.inEditor || (block.buildVisibility == BuildVisibility.debugOnly)) continue;
|
||||||
|
|
||||||
ImageButton button = new ImageButton(Tex.whiteui, Styles.clearTogglei);
|
ImageButton button = new ImageButton(Tex.whiteui, Styles.clearTogglei);
|
||||||
button.getStyle().imageUp = new TextureRegionDrawable(region);
|
button.getStyle().imageUp = new TextureRegionDrawable(region);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
|||||||
private CachedTile ctile = new CachedTile(){
|
private CachedTile ctile = new CachedTile(){
|
||||||
//nothing.
|
//nothing.
|
||||||
@Override
|
@Override
|
||||||
protected void changeEntity(Team team){
|
protected void changeEntity(Team team, Prov<Tilec> entityprov){
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
8
core/src/mindustry/entities/Leg.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package mindustry.entities;
|
||||||
|
|
||||||
|
import arc.math.geom.*;
|
||||||
|
|
||||||
|
public class Leg{
|
||||||
|
public final Vec2 joint = new Vec2(), base = new Vec2(), target = new Vec2();
|
||||||
|
public boolean moving = false;
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
package mindustry.entities.comp;
|
package mindustry.entities.comp;
|
||||||
|
|
||||||
import arc.util.ArcAnnotate.*;
|
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class BlockUnitComp implements Unitc{
|
abstract class BlockUnitComp implements Unitc{
|
||||||
@ReadOnly @NonNull Tilec tile;
|
@Import Team team;
|
||||||
|
|
||||||
|
@ReadOnly Tilec tile;
|
||||||
|
|
||||||
public void tile(Tilec tile){
|
public void tile(Tilec tile){
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
@@ -29,4 +31,19 @@ abstract class BlockUnitComp implements Unitc{
|
|||||||
public void damage(float v, boolean b){
|
public void damage(float v, boolean b){
|
||||||
tile.damage(v, b);
|
tile.damage(v, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Replace
|
||||||
|
public boolean dead(){
|
||||||
|
return tile == null || tile.dead();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Replace
|
||||||
|
public void team(Team team){
|
||||||
|
if(tile != null && this.team != team){
|
||||||
|
this.team = team;
|
||||||
|
if(tile.team() != team){
|
||||||
|
tile.team(team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,72 @@ package mindustry.entities.comp;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class LegsComp implements Posc, Flyingc, Hitboxc, Unitc, Legsc, ElevationMovec{
|
abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc{
|
||||||
@SyncField(false) @SyncLocal float baseRotation;
|
@Import float x, y, rotation, elevation;
|
||||||
transient float walkTime;
|
|
||||||
|
transient Leg[] legs = {};
|
||||||
|
transient float totalLength;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
float len = vel().len();
|
//keep elevation halfway
|
||||||
baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed));
|
elevation = 0.5f;
|
||||||
walkTime += Time.delta()*len;
|
|
||||||
|
int count = type().legCount;
|
||||||
|
float legLength = type().legLength;
|
||||||
|
|
||||||
|
if(legs.length != type().legCount){
|
||||||
|
this.legs = new Leg[count];
|
||||||
|
|
||||||
|
float spacing = 360f / count;
|
||||||
|
|
||||||
|
for(int i = 0; i < legs.length; i++){
|
||||||
|
Leg l = new Leg();
|
||||||
|
|
||||||
|
l.joint.trns(i * spacing + rotation, legLength/2f).add(x, y);
|
||||||
|
l.base.trns(i * spacing + rotation, legLength).add(x, y);
|
||||||
|
|
||||||
|
legs[i] = l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float moveSpeed = 0.1f;
|
||||||
|
int div = Math.max(legs.length / 2, 2);
|
||||||
|
float moveSpace = legLength / 1.6f / (div / 2f);
|
||||||
|
|
||||||
|
totalLength += Mathf.dst(deltaX(), deltaY());
|
||||||
|
|
||||||
|
int stage = (int)(totalLength / moveSpace);
|
||||||
|
int odd = stage % div;
|
||||||
|
float movespace = 360f / legs.length / 4f;
|
||||||
|
float trns = vel().len() * 12.5f * div/1.5f;
|
||||||
|
|
||||||
|
Tmp.v4.trns(rotation, trns);
|
||||||
|
|
||||||
|
for(int i = 0; i < legs.length; i++){
|
||||||
|
float dstRot = rotation + 360f / legs.length * i + (360f / legs.length / 2f);
|
||||||
|
float rot2 = Angles.moveToward(dstRot, rotation + (Angles.angleDist(dstRot, rotation) < 90f ? 180f : 0), movespace);
|
||||||
|
|
||||||
|
Leg l = legs[i];
|
||||||
|
|
||||||
|
Tmp.v1.trns(dstRot, legLength).add(x, y).add(Tmp.v4);
|
||||||
|
Tmp.v2.trns(rot2, legLength / 2f).add(x, y).add(Tmp.v4);
|
||||||
|
|
||||||
|
if(i % div == odd){
|
||||||
|
l.base.lerpDelta(Tmp.v1, moveSpeed);
|
||||||
|
l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f);
|
||||||
|
}
|
||||||
|
|
||||||
|
l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(){
|
||||||
|
elevation = 0.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
core/src/mindustry/entities/comp/MechComp.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package mindustry.entities.comp;
|
||||||
|
|
||||||
|
import arc.math.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
abstract class MechComp implements Posc, Flyingc, Hitboxc, Unitc, Mechc, ElevationMovec{
|
||||||
|
@SyncField(false) @SyncLocal float baseRotation;
|
||||||
|
transient float walkTime;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(){
|
||||||
|
float len = vel().len();
|
||||||
|
baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed));
|
||||||
|
walkTime += Time.delta()*len;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import arc.util.*;
|
|||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.audio.SoundLoop;
|
import mindustry.audio.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
@@ -64,14 +64,32 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
|
|
||||||
private transient boolean sleeping;
|
private transient boolean sleeping;
|
||||||
private transient float sleepTime;
|
private transient float sleepTime;
|
||||||
|
private transient boolean initialized;
|
||||||
|
|
||||||
/** Sets this tile entity data to this and adds it if necessary. */
|
/** Sets this tile entity data to this and adds it if necessary. */
|
||||||
public Tilec init(Tile tile, Team team, boolean shouldAdd){
|
public Tilec init(Tile tile, Team team, boolean shouldAdd){
|
||||||
|
if(!initialized){
|
||||||
|
create(tile.block(), team);
|
||||||
|
}
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
this.block = tile.block();
|
|
||||||
this.team = team;
|
|
||||||
|
|
||||||
set(tile.drawx(), tile.drawy());
|
set(tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
|
if(shouldAdd){
|
||||||
|
add();
|
||||||
|
}
|
||||||
|
|
||||||
|
created();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets up all the necessary variables, but does not add this entity anywhere. */
|
||||||
|
public Tilec create(Block block, Team team){
|
||||||
|
this.tile = emptyTile;
|
||||||
|
this.block = block;
|
||||||
|
this.team = team;
|
||||||
|
|
||||||
if(block.activeSound != Sounds.none){
|
if(block.activeSound != Sounds.none){
|
||||||
sound = new SoundLoop(block.activeSound, block.activeSoundVolume);
|
sound = new SoundLoop(block.activeSound, block.activeSoundVolume);
|
||||||
}
|
}
|
||||||
@@ -80,11 +98,15 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
maxHealth(block.health);
|
maxHealth(block.health);
|
||||||
timer(new Interval(block.timers));
|
timer(new Interval(block.timers));
|
||||||
|
|
||||||
if(shouldAdd){
|
cons = new ConsumeModule(this);
|
||||||
add();
|
if(block.hasItems) items = new ItemModule();
|
||||||
|
if(block.hasLiquids) liquids = new LiquidModule();
|
||||||
|
if(block.hasPower){
|
||||||
|
power = new PowerModule();
|
||||||
|
power.graph.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
created();
|
initialized = true;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -382,7 +404,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
* @return whether the payload was moved successfully
|
* @return whether the payload was moved successfully
|
||||||
*/
|
*/
|
||||||
public boolean dumpPayload(@NonNull Payload todump){
|
public boolean dumpPayload(@NonNull Payload todump){
|
||||||
int dump = rotation();
|
int dump = tile.data;
|
||||||
|
|
||||||
if(proximity.size == 0) return false;
|
if(proximity.size == 0) return false;
|
||||||
|
|
||||||
@@ -418,7 +440,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dumpLiquid(Liquid liquid){
|
public void dumpLiquid(Liquid liquid){
|
||||||
int dump = rotation() / block.dumpIncrement;
|
int dump = tile.data;
|
||||||
|
|
||||||
for(int i = 0; i < proximity.size; i++){
|
for(int i = 0; i < proximity.size; i++){
|
||||||
incrementDump(proximity.size);
|
incrementDump(proximity.size);
|
||||||
@@ -513,7 +535,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
*/
|
*/
|
||||||
public void offload(Item item){
|
public void offload(Item item){
|
||||||
Array<Tilec> proximity = proximity();
|
Array<Tilec> proximity = proximity();
|
||||||
int dump = rotation() / block.dumpIncrement;
|
int dump = tile.data;
|
||||||
useContent(item);
|
useContent(item);
|
||||||
|
|
||||||
for(int i = 0; i < proximity.size; i++){
|
for(int i = 0; i < proximity.size; i++){
|
||||||
@@ -533,7 +555,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
*/
|
*/
|
||||||
public boolean put(Item item){
|
public boolean put(Item item){
|
||||||
Array<Tilec> proximity = proximity();
|
Array<Tilec> proximity = proximity();
|
||||||
int dump = rotation() / block.dumpIncrement;
|
int dump = tile.data;
|
||||||
useContent(item);
|
useContent(item);
|
||||||
|
|
||||||
for(int i = 0; i < proximity.size; i++){
|
for(int i = 0; i < proximity.size; i++){
|
||||||
@@ -561,7 +583,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
if(!block.hasItems || items.total() == 0 || (todump != null && !items.has(todump))) return false;
|
if(!block.hasItems || items.total() == 0 || (todump != null && !items.has(todump))) return false;
|
||||||
|
|
||||||
Array<Tilec> proximity = proximity();
|
Array<Tilec> proximity = proximity();
|
||||||
int dump = rotation() / block.dumpIncrement;
|
int dump = tile.data;
|
||||||
|
|
||||||
if(proximity.size == 0) return false;
|
if(proximity.size == 0) return false;
|
||||||
|
|
||||||
@@ -596,7 +618,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void incrementDump(int prox){
|
public void incrementDump(int prox){
|
||||||
rotation((byte)((rotation() + block.dumpIncrement) % (prox * block.dumpIncrement)));
|
tile.data = (byte)((tile.data + 1) % prox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used for dumping items. */
|
/** Used for dumping items. */
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ public class Layer{
|
|||||||
//blocks currently in progress *shaders used*
|
//blocks currently in progress *shaders used*
|
||||||
blockBuilding = 40,
|
blockBuilding = 40,
|
||||||
|
|
||||||
//ground units
|
|
||||||
groundUnit = 50,
|
|
||||||
|
|
||||||
//turrets
|
//turrets
|
||||||
turret = 60,
|
turret = 50,
|
||||||
|
|
||||||
|
//ground units
|
||||||
|
groundUnit = 60,
|
||||||
|
|
||||||
//power lines
|
//power lines
|
||||||
power = 70,
|
power = 70,
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class OverlayRenderer{
|
|||||||
|
|
||||||
input.drawTop();
|
input.drawTop();
|
||||||
|
|
||||||
buildFade = Mathf.lerpDelta(buildFade, input.isPlacing() ? 1f : 0f, 0.06f);
|
buildFade = Mathf.lerpDelta(buildFade, input.isPlacing() || input.isUsingSchematic() ? 1f : 0f, 0.06f);
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
Lines.stroke(buildFade * 2f);
|
Lines.stroke(buildFade * 2f);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class Pal{
|
|||||||
bulletYellowBack = Color.valueOf("f9c27a"),
|
bulletYellowBack = Color.valueOf("f9c27a"),
|
||||||
|
|
||||||
darkMetal = Color.valueOf("6e7080"),
|
darkMetal = Color.valueOf("6e7080"),
|
||||||
|
darkerMetal = Color.valueOf("565666"),
|
||||||
|
|
||||||
missileYellow = Color.valueOf("ffd2ae"),
|
missileYellow = Color.valueOf("ffd2ae"),
|
||||||
missileYellowBack = Color.valueOf("e58956"),
|
missileYellowBack = Color.valueOf("e58956"),
|
||||||
|
|||||||
@@ -202,6 +202,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUsingSchematic(){
|
||||||
|
return !selectRequests.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public OverlayFragment getFrag(){
|
public OverlayFragment getFrag(){
|
||||||
return frag;
|
return frag;
|
||||||
}
|
}
|
||||||
@@ -765,7 +769,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tilec tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
Tilec tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||||
if(tile instanceof ControlBlock){
|
if(tile instanceof ControlBlock && tile.team() == player.team()){
|
||||||
return ((ControlBlock)tile).unit();
|
return ((ControlBlock)tile).unit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import arc.util.ArcAnnotate.*;
|
|||||||
import mindustry.ai.types.*;
|
import mindustry.ai.types.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -38,6 +39,8 @@ public class UnitType extends UnlockableContent{
|
|||||||
public boolean targetAir = true, targetGround = true;
|
public boolean targetAir = true, targetGround = true;
|
||||||
public boolean faceTarget = true, isCounted = true, lowAltitude = false;
|
public boolean faceTarget = true, isCounted = true, lowAltitude = false;
|
||||||
public boolean canBoost = false;
|
public boolean canBoost = false;
|
||||||
|
public int legCount = 4;
|
||||||
|
public float legLength = 24f;
|
||||||
public float sway = 1f;
|
public float sway = 1f;
|
||||||
|
|
||||||
public int itemCapacity = 30;
|
public int itemCapacity = 30;
|
||||||
@@ -125,7 +128,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
//region drawing
|
//region drawing
|
||||||
|
|
||||||
public void draw(Unitc unit){
|
public void draw(Unitc unit){
|
||||||
Legsc legs = unit instanceof Legsc ? (Legsc)unit : null;
|
Mechc legs = unit instanceof Mechc ? (Mechc)unit : null;
|
||||||
float z = unit.elevation() > 0.5f ? (lowAltitude ? Layer.flyingUnitLow : Layer.flyingUnit) : Layer.groundUnit;
|
float z = unit.elevation() > 0.5f ? (lowAltitude ? Layer.flyingUnitLow : Layer.flyingUnit) : Layer.groundUnit;
|
||||||
|
|
||||||
if(unit.controller().isBeingControlled(player.unit())){
|
if(unit.controller().isBeingControlled(player.unit())){
|
||||||
@@ -140,13 +143,17 @@ public class UnitType extends UnlockableContent{
|
|||||||
Draw.z(z - 0.02f);
|
Draw.z(z - 0.02f);
|
||||||
|
|
||||||
if(legs != null){
|
if(legs != null){
|
||||||
drawLegs(legs);
|
drawMech(legs);
|
||||||
|
|
||||||
float ft = Mathf.sin(legs.walkTime(), 3f, 3f);
|
float ft = Mathf.sin(legs.walkTime(), 3f, 3f);
|
||||||
legOffset.trns(legs.baseRotation(), 0f, Mathf.lerp(ft * 0.18f * sway, 0f, unit.elevation()));
|
legOffset.trns(legs.baseRotation(), 0f, Mathf.lerp(ft * 0.18f * sway, 0f, unit.elevation()));
|
||||||
unit.trns(legOffset.x, legOffset.y);
|
unit.trns(legOffset.x, legOffset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(unit instanceof Legsc){
|
||||||
|
drawLegs((Legsc)unit);
|
||||||
|
}
|
||||||
|
|
||||||
Draw.z(Math.min(z - 0.01f, Layer.bullet - 1f));
|
Draw.z(Math.min(z - 0.01f, Layer.bullet - 1f));
|
||||||
drawOcclusion(unit);
|
drawOcclusion(unit);
|
||||||
|
|
||||||
@@ -310,6 +317,32 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawLegs(Legsc unit){
|
public void drawLegs(Legsc unit){
|
||||||
|
Leg[] legs = unit.legs();
|
||||||
|
|
||||||
|
Lines.stroke(4f, Color.gray);
|
||||||
|
float srad = 2.1f;
|
||||||
|
|
||||||
|
for(Leg leg : legs){
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
|
|
||||||
|
Lines.line(legRegion, unit.x(), unit.y(), leg.joint.x, leg.joint.y, CapStyle.none, 0);
|
||||||
|
Lines.line(legRegion, leg.joint.x, leg.joint.y, leg.base.x, leg.base.y, CapStyle.none, 0);
|
||||||
|
|
||||||
|
Draw.color(Pal.darkMetal);
|
||||||
|
Fill.circle(leg.joint.x, leg.joint.y, srad);
|
||||||
|
|
||||||
|
Draw.color(Pal.darkerMetal);
|
||||||
|
Fill.circle(leg.base.x, leg.base.y, srad);
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
|
//Lines.line(unit.x(), unit.y(), leg.base.x, leg.base.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawMech(Mechc unit){
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
Draw.mixcol(Color.white, unit.hitTime());
|
Draw.mixcol(Color.white, unit.hitTime());
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ public class Block extends UnlockableContent{
|
|||||||
public int itemCapacity = 10;
|
public int itemCapacity = 10;
|
||||||
public float liquidCapacity = 10f;
|
public float liquidCapacity = 10f;
|
||||||
public float liquidPressure = 1f;
|
public float liquidPressure = 1f;
|
||||||
public int dumpIncrement = 1;
|
|
||||||
|
|
||||||
public final BlockStats stats = new BlockStats();
|
public final BlockStats stats = new BlockStats();
|
||||||
public final BlockBars bars = new BlockBars();
|
public final BlockBars bars = new BlockBars();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.world;
|
package mindustry.world;
|
||||||
|
|
||||||
|
import arc.func.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.world.modules.*;
|
import mindustry.world.modules.*;
|
||||||
@@ -20,13 +21,13 @@ public class CachedTile extends Tile{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void changeEntity(Team team){
|
protected void changeEntity(Team team, Prov<Tilec> entityprov){
|
||||||
entity = null;
|
entity = null;
|
||||||
|
|
||||||
Block block = block();
|
Block block = block();
|
||||||
|
|
||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
Tilec n = block.newEntity();
|
Tilec n = entityprov.get();
|
||||||
n.cons(new ConsumeModule(entity));
|
n.cons(new ConsumeModule(entity));
|
||||||
n.tile(this);
|
n.tile(this);
|
||||||
n.block(block);
|
n.block(block);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import mindustry.game.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.modules.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -24,10 +23,12 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
/** Tile entity, usually null. */
|
/** Tile entity, usually null. */
|
||||||
public @Nullable Tilec entity;
|
public @Nullable Tilec entity;
|
||||||
public short x, y;
|
public short x, y;
|
||||||
|
/** Extra data. Used for dumping. */
|
||||||
|
public byte data;
|
||||||
protected @NonNull Block block;
|
protected @NonNull Block block;
|
||||||
protected @NonNull Floor floor;
|
protected @NonNull Floor floor;
|
||||||
protected @NonNull Floor overlay;
|
protected @NonNull Floor overlay;
|
||||||
/** Rotation, 0-3. Also used to store offload location, in which case it can be any number.*/
|
/** Rotation, 0-3. Not guaranteed to be in any specific range. */
|
||||||
protected byte rotation;
|
protected byte rotation;
|
||||||
protected boolean changing = false;
|
protected boolean changing = false;
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
this.block = wall;
|
this.block = wall;
|
||||||
|
|
||||||
//update entity and create it if needed
|
//update entity and create it if needed
|
||||||
changeEntity(Team.derelict);
|
changeEntity(Team.derelict, wall::newEntity);
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,12 +165,16 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(@NonNull Block type, Team team, int rotation){
|
public void setBlock(@NonNull Block type, Team team, int rotation){
|
||||||
|
setBlock(type, team, rotation, type::newEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(@NonNull Block type, Team team, int rotation, Prov<Tilec> entityprov){
|
||||||
changing = true;
|
changing = true;
|
||||||
|
|
||||||
this.block = type;
|
this.block = type;
|
||||||
this.rotation = rotation == 0 ? 0 : (byte)Mathf.mod(rotation, 4);
|
this.rotation = rotation == 0 ? 0 : (byte)Mathf.mod(rotation, 4);
|
||||||
preChanged();
|
preChanged();
|
||||||
changeEntity(team);
|
changeEntity(team, entityprov);
|
||||||
|
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
entity.team(team);
|
entity.team(team);
|
||||||
@@ -523,7 +528,7 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void changeEntity(Team team){
|
protected void changeEntity(Team team, Prov<Tilec> entityprov){
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
int size = entity.block().size;
|
int size = entity.block().size;
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@@ -546,14 +551,7 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
entity = block.newEntity().init(this, team, block.update);
|
entity = entityprov.get().init(this, team, block.update);
|
||||||
entity.cons(new ConsumeModule(entity));
|
|
||||||
if(block.hasItems) entity.items(new ItemModule());
|
|
||||||
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
|
||||||
if(block.hasPower){
|
|
||||||
entity.power(new PowerModule());
|
|
||||||
entity.power().graph.add(entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package mindustry.world.blocks.distribution;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.input.*;
|
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import arc.util.io.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
|
||||||
import mindustry.game.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -79,12 +77,7 @@ public class PayloadConveyor extends Block{
|
|||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
progress = Time.time() % moveTime;
|
progress = Time.time() % moveTime;
|
||||||
|
|
||||||
//TODO DEBUG
|
updatePayload();
|
||||||
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 = rotdeg();
|
|
||||||
animation = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO nondeterministic input priority
|
//TODO nondeterministic input priority
|
||||||
int curStep = curStep();
|
int curStep = curStep();
|
||||||
@@ -105,9 +98,7 @@ public class PayloadConveyor extends Block{
|
|||||||
}
|
}
|
||||||
}else if(!blocked){
|
}else if(!blocked){
|
||||||
//dump item forward
|
//dump item forward
|
||||||
float trnext = size * tilesize / 2f, cx = Geometry.d4(rotation()).x, cy = Geometry.d4(rotation()).y;
|
if(item.dump()){
|
||||||
|
|
||||||
if(item.dump(x + cx * trnext, y + cy * trnext, rotdeg())){
|
|
||||||
item = null;
|
item = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,25 +149,8 @@ public class PayloadConveyor extends Block{
|
|||||||
|
|
||||||
Draw.z(Layer.blockOver);
|
Draw.z(Layer.blockOver);
|
||||||
|
|
||||||
if(animation > fract()){
|
|
||||||
animation = Mathf.lerp(animation, 0.8f, 0.15f);
|
|
||||||
}
|
|
||||||
|
|
||||||
animation = Math.max(animation, fract());
|
|
||||||
|
|
||||||
float fract = animation;
|
|
||||||
rot = Mathf.slerp(itemRotation, rotdeg(), fract);
|
|
||||||
|
|
||||||
if(fract < 0.5f){
|
|
||||||
Tmp.v1.trns(itemRotation + 180, (0.5f - fract) * tilesize * size);
|
|
||||||
}else{
|
|
||||||
Tmp.v1.trns(rotdeg(), (fract - 0.5f) * tilesize * size);
|
|
||||||
}
|
|
||||||
|
|
||||||
float vx = Tmp.v1.x, vy = Tmp.v1.y;
|
|
||||||
|
|
||||||
if(item != null){
|
if(item != null){
|
||||||
item.draw(x + vx, y + vy, rot);
|
item.draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,6 +165,49 @@ public class PayloadConveyor extends Block{
|
|||||||
this.stepAccepted = curStep();
|
this.stepAccepted = curStep();
|
||||||
this.itemRotation = source.angleTo(this);
|
this.itemRotation = source.angleTo(this);
|
||||||
this.animation = 0;
|
this.animation = 0;
|
||||||
|
|
||||||
|
updatePayload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Writes write){
|
||||||
|
super.write(write);
|
||||||
|
|
||||||
|
write.f(progress);
|
||||||
|
write.f(itemRotation);
|
||||||
|
Payload.write(item, write);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Reads read, byte revision){
|
||||||
|
super.read(read, revision);
|
||||||
|
|
||||||
|
progress = read.f();
|
||||||
|
itemRotation = read.f();
|
||||||
|
item = Payload.read(read);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePayload(){
|
||||||
|
if(item != null){
|
||||||
|
if(animation > fract()){
|
||||||
|
animation = Mathf.lerp(animation, 0.8f, 0.15f);
|
||||||
|
}
|
||||||
|
|
||||||
|
animation = Math.max(animation, fract());
|
||||||
|
|
||||||
|
float fract = animation;
|
||||||
|
float rot = Mathf.slerp(itemRotation, rotdeg(), fract);
|
||||||
|
|
||||||
|
if(fract < 0.5f){
|
||||||
|
Tmp.v1.trns(itemRotation + 180, (0.5f - fract) * tilesize * size);
|
||||||
|
}else{
|
||||||
|
Tmp.v1.trns(rotdeg(), (fract - 0.5f) * tilesize * size);
|
||||||
|
}
|
||||||
|
|
||||||
|
float vx = Tmp.v1.x, vy = Tmp.v1.y;
|
||||||
|
|
||||||
|
item.set(x + vx, y + vy, rot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean blends(int direction){
|
boolean blends(int direction){
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public class StackConveyor extends Block implements Autotiler{
|
|||||||
idleSound = Sounds.conveyor;
|
idleSound = Sounds.conveyor;
|
||||||
idleSoundVolume = 0.004f;
|
idleSoundVolume = 0.004f;
|
||||||
unloadable = false;
|
unloadable = false;
|
||||||
dumpIncrement = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import arc.math.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -14,9 +17,12 @@ import mindustry.ui.*;
|
|||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.blocks.payloads.*;
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
import mindustry.world.blocks.production.*;
|
||||||
|
import mindustry.world.consumers.*;
|
||||||
|
|
||||||
public class BlockForge extends Block{
|
public class BlockForge extends PayloadAcceptor{
|
||||||
public float buildSpeed = 0.4f;
|
public float buildSpeed = 0.4f;
|
||||||
|
public @Load(value = "@-out", fallback = "factory-out") TextureRegion outRegion;
|
||||||
|
|
||||||
public BlockForge(String name){
|
public BlockForge(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -27,8 +33,19 @@ public class BlockForge extends Block{
|
|||||||
hasItems = true;
|
hasItems = true;
|
||||||
configurable = true;
|
configurable = true;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
|
rotate = true;
|
||||||
|
|
||||||
config(Block.class, (tile, block) -> ((BlockForgeEntity)tile).recipe = block);
|
config(Block.class, (tile, block) -> ((BlockForgeEntity)tile).recipe = block);
|
||||||
|
|
||||||
|
consumes.add(new ConsumeItemDynamic(e -> {
|
||||||
|
BlockForgeEntity entity = (BlockForgeEntity)e;
|
||||||
|
|
||||||
|
if(entity.recipe != null){
|
||||||
|
return entity.recipe.requirements;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ItemStack.empty;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,8 +55,13 @@ public class BlockForge extends Block{
|
|||||||
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, () -> ((BlockForgeEntity)entity).progress));
|
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, () -> ((BlockForgeEntity)entity).progress));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BlockForgeEntity extends TileEntity{
|
@Override
|
||||||
public @Nullable Payload payload;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BlockForgeEntity extends PayloadAcceptorEntity<BlockPayload>{
|
||||||
public @Nullable Block recipe;
|
public @Nullable Block recipe;
|
||||||
public float progress, time, heat;
|
public float progress, time, heat;
|
||||||
|
|
||||||
@@ -57,16 +79,21 @@ public class BlockForge extends Block{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptPayload(Tilec source, Payload payload){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
boolean produce = recipe != null && consValid() && payload == null && items.has(recipe.requirements);
|
boolean produce = recipe != null && consValid() && payload == null;
|
||||||
|
|
||||||
if(produce){
|
if(produce){
|
||||||
progress += buildSpeed * edelta();
|
progress += buildSpeed * edelta();
|
||||||
|
|
||||||
if(progress >= recipe.buildCost){
|
if(progress >= recipe.buildCost){
|
||||||
items.remove(recipe.requirements);
|
consume();
|
||||||
payload = new BlockPayload(recipe);
|
payload = new BlockPayload(recipe, team);
|
||||||
progress = 0f;
|
progress = 0f;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -76,14 +103,12 @@ public class BlockForge extends Block{
|
|||||||
heat = Mathf.lerpDelta(heat, Mathf.num(produce), 0.3f);
|
heat = Mathf.lerpDelta(heat, Mathf.num(produce), 0.3f);
|
||||||
time += heat * delta();
|
time += heat * delta();
|
||||||
|
|
||||||
if(payload != null && dumpPayload(payload)){
|
moveOutPayload();
|
||||||
payload = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
Array<Block> blocks = Vars.content.blocks().select(b -> b.isVisible() && b.size <= 2 && b.requirements.length <= 3);
|
Array<Block> blocks = Vars.content.blocks().select(b -> b.isVisible() && b.size <= 2);
|
||||||
|
|
||||||
ItemSelection.buildTable(table, blocks, () -> recipe, block -> recipe = block);
|
ItemSelection.buildTable(table, blocks, () -> recipe, block -> recipe = block);
|
||||||
}
|
}
|
||||||
@@ -95,11 +120,8 @@ public class BlockForge extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
super.draw();
|
Draw.rect(region, x, y);
|
||||||
|
Draw.rect(outRegion, x, y, rotdeg());
|
||||||
if(payload != null){
|
|
||||||
payload.draw(x, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(recipe != null){
|
if(recipe != null){
|
||||||
Draw.draw(Layer.blockOver, () -> {
|
Draw.draw(Layer.blockOver, () -> {
|
||||||
@@ -123,6 +145,8 @@ public class BlockForge extends Block{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class BlockLauncher extends PayloadAcceptor{
|
|||||||
positions.clear();
|
positions.clear();
|
||||||
|
|
||||||
Geometry.circle(tileX(), tileY(), world.width(), world.height(), (int)(range / tilesize), (cx, cy) -> {
|
Geometry.circle(tileX(), tileY(), world.width(), world.height(), (int)(range / tilesize), (cx, cy) -> {
|
||||||
if(Build.validPlace(team, cx, cy, payload.block, 0)){
|
if(Build.validPlace(team, cx, cy, payload.entity.block(), 0)){
|
||||||
positions.add(Point2.pack(cx, cy));
|
positions.add(Point2.pack(cx, cy));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -57,7 +57,7 @@ public class BlockLauncher extends PayloadAcceptor{
|
|||||||
if(positions.isEmpty()) return;
|
if(positions.isEmpty()) return;
|
||||||
|
|
||||||
int pick = positions.random();
|
int pick = positions.random();
|
||||||
LaunchedBlock launch = new LaunchedBlock(Point2.x(pick), Point2.y(pick), payload.block, team);
|
LaunchedBlock launch = new LaunchedBlock(Point2.x(pick), Point2.y(pick), payload.entity.block(), team);
|
||||||
Fx.blockTransfer.at(x, y, 0, launch);
|
Fx.blockTransfer.at(x, y, 0, launch);
|
||||||
Time.run(Fx.blockTransfer.lifetime, () -> {
|
Time.run(Fx.blockTransfer.lifetime, () -> {
|
||||||
float ex = launch.x * tilesize + launch.block.offset(), ey = launch.y * tilesize + launch.block.offset();
|
float ex = launch.x * tilesize + launch.block.offset(), ey = launch.y * tilesize + launch.block.offset();
|
||||||
|
|||||||
144
core/src/mindustry/world/blocks/experimental/BlockLoader.java
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
package mindustry.world.blocks.experimental;
|
||||||
|
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.entities.units.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
import mindustry.world.blocks.production.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
|
public class BlockLoader extends PayloadAcceptor{
|
||||||
|
public final int timerLoad = timers++;
|
||||||
|
|
||||||
|
public float loadTime = 2f;
|
||||||
|
public int itemsLoaded = 5;
|
||||||
|
public float liquidsLoaded = 5f;
|
||||||
|
|
||||||
|
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 BlockLoader(String name){
|
||||||
|
super(name);
|
||||||
|
|
||||||
|
hasItems = true;
|
||||||
|
itemCapacity = 25;
|
||||||
|
//liquidCapacity = 25;
|
||||||
|
update = true;
|
||||||
|
outputsPayload = true;
|
||||||
|
size = 3;
|
||||||
|
rotate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean outputsItems(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
|
||||||
|
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, ((BlockLoaderEntity)entity)::fraction));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BlockLoaderEntity extends PayloadAcceptorEntity<BlockPayload>{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptPayload(Tilec source, Payload payload){
|
||||||
|
return super.acceptPayload(source, payload) &&
|
||||||
|
(payload instanceof BlockPayload) &&
|
||||||
|
((((BlockPayload)payload).entity.block().hasItems && ((BlockPayload)payload).block().unloadable && ((BlockPayload)payload).block().itemCapacity >= 10)/* ||
|
||||||
|
((BlockPayload)payload).entity.block().hasLiquids && ((BlockPayload)payload).block().liquidCapacity >= 10f)*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptItem(Tilec source, Item item){
|
||||||
|
return items.total() < itemCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
|
||||||
|
Draw.z(Layer.blockOver);
|
||||||
|
payRotation = rotdeg();
|
||||||
|
drawPayload();
|
||||||
|
|
||||||
|
Draw.z(Layer.blockOver + 0.1f);
|
||||||
|
Draw.rect(topRegion, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
if(shouldExport()){
|
||||||
|
moveOutPayload();
|
||||||
|
}else if(moveInPayload()){
|
||||||
|
|
||||||
|
//load up items
|
||||||
|
if(payload.block().hasItems && items.any()){
|
||||||
|
if(timer(timerLoad, loadTime)){
|
||||||
|
//load up items a set amount of times
|
||||||
|
for(int j = 0; j < itemsLoaded && items.any(); j++){
|
||||||
|
|
||||||
|
for(int i = 0; i < items.length(); i++){
|
||||||
|
if(items.get(i) > 0){
|
||||||
|
Item item = content.item(i);
|
||||||
|
if(payload.entity.acceptItem(payload.entity, item)){
|
||||||
|
payload.entity.handleItem(payload.entity, item);
|
||||||
|
items.remove(item, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//load up liquids (disabled)
|
||||||
|
/*
|
||||||
|
if(payload.block().hasLiquids && liquids.total() >= 0.001f){
|
||||||
|
Liquid liq = liquids.current();
|
||||||
|
float total = liquids.currentAmount();
|
||||||
|
float flow = Math.min(Math.min(liquidsLoaded * delta(), payload.block().liquidCapacity - payload.entity.liquids().get(liq) - 0.0001f), total);
|
||||||
|
if(payload.entity.acceptLiquid(payload.entity, liq, flow)){
|
||||||
|
payload.entity.liquids().add(liq, flow);
|
||||||
|
liquids.remove(liq, flow);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float fraction(){
|
||||||
|
return payload == null ? 0f : payload.entity.items().total() / (float)payload.entity.block().itemCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldExport(){
|
||||||
|
return payload != null &&
|
||||||
|
((payload.block().hasLiquids && payload.entity.liquids().total() >= payload.block().liquidCapacity - 0.001f) ||
|
||||||
|
(payload.block().hasItems && payload.entity.items().total() >= payload.block().itemCapacity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package mindustry.world.blocks.experimental;
|
||||||
|
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
|
public class BlockUnloader extends BlockLoader{
|
||||||
|
|
||||||
|
public BlockUnloader(String name){
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean outputsItems(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BlockUnloaderEntity extends BlockLoaderEntity{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptItem(Tilec source, Item item){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
if(shouldExport()){
|
||||||
|
moveOutPayload();
|
||||||
|
}else if(moveInPayload()){
|
||||||
|
|
||||||
|
//load up items
|
||||||
|
if(payload.block().hasItems && !full()){
|
||||||
|
if(timer(timerLoad, loadTime)){
|
||||||
|
//load up items a set amount of times
|
||||||
|
for(int j = 0; j < itemsLoaded && !full(); j++){
|
||||||
|
for(int i = 0; i < items.length(); i++){
|
||||||
|
if(payload.entity.items().get(i) > 0){
|
||||||
|
Item item = content.item(i);
|
||||||
|
payload.entity.items().remove(item, 1);
|
||||||
|
items.add(item, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dump();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean full(){
|
||||||
|
return items.total() >= itemCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float fraction(){
|
||||||
|
return payload == null ? 0f : 1f - payload.entity.items().total() / (float)payload.entity.block().itemCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldExport(){
|
||||||
|
return payload != null && (payload.block().hasItems && payload.entity.items().empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
public Color botColor = Color.valueOf("565656");
|
public Color botColor = Color.valueOf("565656");
|
||||||
|
|
||||||
public @Load(value = "@-top-#", length = 7) TextureRegion[] topRegions;
|
public @Load(value = "@-top-#", length = 7) TextureRegion[] topRegions;
|
||||||
public @Load(value = "@-bottom-#", length = 7, fallback = "conduit") TextureRegion[] botRegions;
|
public @Load(value = "@-bottom-#", length = 7, fallback = "conduit-bottom-#") TextureRegion[] botRegions;
|
||||||
|
|
||||||
public float leakResistance = 1.5f;
|
public float leakResistance = 1.5f;
|
||||||
|
|
||||||
@@ -44,8 +44,6 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
Draw.alpha(0.5f);
|
Draw.alpha(0.5f);
|
||||||
Draw.rect(botRegions[bits[0]], req.drawx(), req.drawy(), req.rotation * 90);
|
Draw.rect(botRegions[bits[0]], req.drawx(), req.drawy(), req.rotation * 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|
||||||
|
|
||||||
Draw.rect(topRegions[bits[0]], req.drawx(), req.drawy(), req.rotation * 90);
|
Draw.rect(topRegions[bits[0]], req.drawx(), req.drawy(), req.rotation * 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package mindustry.world.blocks.payloads;
|
package mindustry.world.blocks.payloads;
|
||||||
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.util.io.*;
|
||||||
|
import mindustry.game.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -8,15 +11,40 @@ import mindustry.world.*;
|
|||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class BlockPayload implements Payload{
|
public class BlockPayload implements Payload{
|
||||||
public Block block;
|
public Tilec entity;
|
||||||
|
|
||||||
public BlockPayload(Block block){
|
public BlockPayload(Block block, Team team){
|
||||||
this.block = block;
|
this.entity = block.newEntity().create(block, team);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block block(){
|
||||||
|
return entity.block();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void place(Tile tile){
|
||||||
|
place(tile, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void place(Tile tile, int rotation){
|
||||||
|
tile.setBlock(entity.block(), entity.team(), rotation, () -> entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(float x, float y, float rotation){
|
public void write(Writes write){
|
||||||
Drawf.shadow(x, y, block.size * tilesize * 2f);
|
write.b(payloadBlock);
|
||||||
Draw.rect(block.icon(Cicon.full), x, y, 0);
|
write.s(entity.block().id);
|
||||||
|
write.b(entity.version());
|
||||||
|
entity.writeAll(write);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(float x, float y, float rotation){
|
||||||
|
entity.set(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
Drawf.shadow(entity.x(), entity.y(), entity.block().size * tilesize * 2f);
|
||||||
|
Draw.rect(entity.block().icon(Cicon.full), entity.x(), entity.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,58 @@
|
|||||||
package mindustry.world.blocks.payloads;
|
package mindustry.world.blocks.payloads;
|
||||||
|
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
|
import arc.util.io.*;
|
||||||
|
import mindustry.game.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
public interface Payload{
|
public interface Payload{
|
||||||
|
int payloadUnit = 0, payloadBlock = 1;
|
||||||
|
|
||||||
|
/** sets this payload's position on the map. */
|
||||||
|
void set(float x, float y, float rotation);
|
||||||
|
|
||||||
/** draws this payload at a position. */
|
/** draws this payload at a position. */
|
||||||
void draw(float x, float y, float rotation);
|
void draw();
|
||||||
|
|
||||||
/** @return whether this payload was dumped. */
|
/** @return whether this payload was dumped. */
|
||||||
default boolean dump(float x, float y, float rotation){
|
default boolean dump(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** writes the payload for saving. */
|
||||||
|
void write(Writes write);
|
||||||
|
|
||||||
|
static void write(@Nullable Payload payload, Writes write){
|
||||||
|
if(payload == null){
|
||||||
|
write.bool(false);
|
||||||
|
}else{
|
||||||
|
write.bool(true);
|
||||||
|
payload.write(write);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Nullable
|
||||||
|
static <T extends Payload> T read(Reads read){
|
||||||
|
boolean exists = read.bool();
|
||||||
|
if(!exists) return null;
|
||||||
|
|
||||||
|
byte type = read.b();
|
||||||
|
if(type == payloadBlock){
|
||||||
|
Block block = content.block(read.s());
|
||||||
|
BlockPayload payload = new BlockPayload(block, Team.derelict);
|
||||||
|
byte version = read.b();
|
||||||
|
payload.entity.readAll(read, version);
|
||||||
|
return (T)payload;
|
||||||
|
}else if(type == payloadUnit){
|
||||||
|
byte id = read.b();
|
||||||
|
Unitc unit = (Unitc)EntityMapping.map(id).get();
|
||||||
|
unit.read(read);
|
||||||
|
return (T)new UnitPayload(unit);
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown payload type: " + type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.world.blocks.payloads;
|
package mindustry.world.blocks.payloads;
|
||||||
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.util.io.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -14,22 +15,31 @@ public class UnitPayload implements Payload{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dump(float x, float y, float rotation){
|
public void write(Writes write){
|
||||||
|
write.b(payloadUnit);
|
||||||
|
write.b(unit.classId());
|
||||||
|
unit.write(write);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(float x, float y, float rotation){
|
||||||
|
unit.set(x, y);
|
||||||
|
unit.rotation(rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dump(){
|
||||||
//no client dumping
|
//no client dumping
|
||||||
if(Vars.net.client()) return true;
|
if(Vars.net.client()) return true;
|
||||||
|
|
||||||
unit.set(x, y);
|
|
||||||
unit.rotation(rotation);
|
|
||||||
unit.add();
|
unit.add();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(float x, float y, float rotation){
|
public void draw(){
|
||||||
// Drawf.shadow(x, y, 24);
|
Drawf.shadow(unit.x(), unit.y(), 20);
|
||||||
//Draw.rect("pneumatic-drill", x, y, rotation);
|
Draw.rect(unit.type().icon(Cicon.full), unit.x(), unit.y(), unit.rotation() - 90);
|
||||||
Drawf.shadow(x, y, 20);
|
|
||||||
Draw.rect(unit.type().icon(Cicon.full), x, y, rotation - 90);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public class Drill extends Block{
|
|||||||
});
|
});
|
||||||
|
|
||||||
stats.add(BlockStat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
|
stats.add(BlockStat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
|
||||||
if(liquidBoostIntensity > 0){
|
if(liquidBoostIntensity != 1){
|
||||||
stats.add(BlockStat.boostEffect, liquidBoostIntensity * liquidBoostIntensity, StatUnit.timesSpeed);
|
stats.add(BlockStat.boostEffect, liquidBoostIntensity * liquidBoostIntensity, StatUnit.timesSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
|
import arc.util.io.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -45,27 +46,86 @@ public class PayloadAcceptor extends Block{
|
|||||||
this.payload = (T)payload;
|
this.payload = (T)payload;
|
||||||
this.payVector.set(source).sub(this).clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f);
|
this.payVector.set(source).sub(this).clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f);
|
||||||
this.payRotation = source.angleTo(this);
|
this.payRotation = source.angleTo(this);
|
||||||
|
|
||||||
|
updatePayload();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePayload(){
|
||||||
|
if(payload != null){
|
||||||
|
payload.set(x + payVector.x, y + payVector.y, payRotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return true if the payload is in position. */
|
/** @return true if the payload is in position. */
|
||||||
public boolean moveInPayload(){
|
public boolean moveInPayload(){
|
||||||
if(payload == null) return false;
|
if(payload == null) return false;
|
||||||
|
|
||||||
|
updatePayload();
|
||||||
|
|
||||||
payRotation = Mathf.slerpDelta(payRotation, rotate ? rotdeg() : 90f, 0.3f);
|
payRotation = Mathf.slerpDelta(payRotation, rotate ? rotdeg() : 90f, 0.3f);
|
||||||
payVector.approachDelta(Vec2.ZERO, payloadSpeed);
|
payVector.approachDelta(Vec2.ZERO, payloadSpeed);
|
||||||
|
|
||||||
return hasArrived();
|
return hasArrived();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void moveOutPayload(){
|
||||||
|
if(payload == null) return;
|
||||||
|
|
||||||
|
updatePayload();
|
||||||
|
|
||||||
|
payVector.trns(rotdeg(), payVector.len() + edelta() * payloadSpeed);
|
||||||
|
payRotation = rotdeg();
|
||||||
|
|
||||||
|
if(payVector.len() >= size * tilesize/2f){
|
||||||
|
payVector.clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, 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()){
|
||||||
|
dumpPayload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dumpPayload(){
|
||||||
|
if(payload.dump()){
|
||||||
|
payload = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasArrived(){
|
public boolean hasArrived(){
|
||||||
return payVector.isZero(0.01f);
|
return payVector.isZero(0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawPayload(){
|
public void drawPayload(){
|
||||||
if(payload != null){
|
if(payload != null){
|
||||||
|
payload.set(x + payVector.x, y + payVector.y, payRotation);
|
||||||
|
|
||||||
Draw.z(Layer.blockOver);
|
Draw.z(Layer.blockOver);
|
||||||
payload.draw(x + payVector.x, y + payVector.y, payRotation);
|
payload.draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Writes write){
|
||||||
|
super.write(write);
|
||||||
|
|
||||||
|
write.f(payVector.x);
|
||||||
|
write.f(payVector.y);
|
||||||
|
write.f(payRotation);
|
||||||
|
Payload.write(payload, write);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Reads read, byte revision){
|
||||||
|
super.read(read, revision);
|
||||||
|
|
||||||
|
payVector.set(read.f(), read.f());
|
||||||
|
payRotation = read.f();
|
||||||
|
payload = Payload.read(read);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class Reconstructor extends UnitBlock{
|
|||||||
if(payload != null){
|
if(payload != null){
|
||||||
//check if offloading
|
//check if offloading
|
||||||
if(payload.unit.type().upgrade == null || payload.unit.type().tier != tier){
|
if(payload.unit.type().upgrade == null || payload.unit.type().tier != tier){
|
||||||
outputPayload();
|
moveOutPayload();
|
||||||
}else{ //update progress
|
}else{ //update progress
|
||||||
if(moveInPayload()){
|
if(moveInPayload()){
|
||||||
if(consValid()){
|
if(consValid()){
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class UnitBlock extends PayloadAcceptor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class UnitBlockEntity extends PayloadAcceptorEntity<UnitPayload>{
|
public class UnitBlockEntity extends PayloadAcceptorEntity<UnitPayload>{
|
||||||
public float progress, payloadPos, time, speedScl;
|
public float progress, time, speedScl;
|
||||||
|
|
||||||
public void spawned(){
|
public void spawned(){
|
||||||
progress = 0f;
|
progress = 0f;
|
||||||
@@ -51,29 +51,11 @@ public class UnitBlock extends PayloadAcceptor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
payload = null;
|
payload = null;
|
||||||
payloadPos = 0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void outputPayload(){
|
@Override
|
||||||
if(payload == null) return;
|
public void dumpPayload(){
|
||||||
|
Call.onUnitBlockSpawn(tile);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class UnitFactory extends UnitBlock{
|
|||||||
speedScl = Mathf.lerpDelta(speedScl, 0f, 0.05f);
|
speedScl = Mathf.lerpDelta(speedScl, 0f, 0.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
outputPayload();
|
moveOutPayload();
|
||||||
|
|
||||||
if(currentPlan != -1 && payload == null){
|
if(currentPlan != -1 && payload == null){
|
||||||
UnitPlan plan = plans[currentPlan];
|
UnitPlan plan = plans[currentPlan];
|
||||||
@@ -196,7 +196,6 @@ public class UnitFactory extends UnitBlock{
|
|||||||
if(progress >= plan.time && Units.canCreate(team)){
|
if(progress >= plan.time && Units.canCreate(team)){
|
||||||
progress = 0f;
|
progress = 0f;
|
||||||
|
|
||||||
payloadPos = 0f;
|
|
||||||
payload = new UnitPayload(plan.unit.create(team));
|
payload = new UnitPayload(plan.unit.create(team));
|
||||||
payVector.setZero();
|
payVector.setZero();
|
||||||
consume();
|
consume();
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ public class ItemModule extends BlockModule{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int length(){
|
||||||
|
return items.length;
|
||||||
|
}
|
||||||
|
|
||||||
/** @return a specific item's flow rate in items/s; any value < 0 means not ready.*/
|
/** @return a specific item's flow rate in items/s; any value < 0 means not ready.*/
|
||||||
public float getFlowRate(Item item){
|
public float getFlowRate(Item item){
|
||||||
if(flow == null) return -1f;
|
if(flow == null) return -1f;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=ca7245cbd7cd13b4343da2f2b105d4fc44058df2
|
archash=c8cdb44c30f50d0350c403547ad25532ad77c465
|
||||||
|
|||||||
@@ -88,11 +88,7 @@ public class PowerTestFixture{
|
|||||||
|
|
||||||
// Simulate the "changed" method. Calling it through reflections would require half the game to be initialized.
|
// Simulate the "changed" method. Calling it through reflections would require half the game to be initialized.
|
||||||
tile.entity = block.newEntity().init(tile, Team.sharded, false);
|
tile.entity = block.newEntity().init(tile, Team.sharded, false);
|
||||||
tile.entity.cons(new ConsumeModule(tile.entity));
|
|
||||||
if(block.hasItems) tile.entity.items(new ItemModule());
|
|
||||||
if(block.hasLiquids) tile.entity.liquids(new LiquidModule());
|
|
||||||
if(block.hasPower){
|
if(block.hasPower){
|
||||||
tile.entity.power(new PowerModule());
|
|
||||||
tile.entity.power().graph = new PowerGraph(){
|
tile.entity.power().graph = new PowerGraph(){
|
||||||
//assume there's always something consuming power
|
//assume there's always something consuming power
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -242,36 +242,40 @@ public class Generators{
|
|||||||
ImagePacker.generate("unit-icons", () -> {
|
ImagePacker.generate("unit-icons", () -> {
|
||||||
content.units().each(type -> {
|
content.units().each(type -> {
|
||||||
type.load();
|
type.load();
|
||||||
|
try{
|
||||||
|
|
||||||
Image image = ImagePacker.get(type.region);
|
Image image = ImagePacker.get(type.region);
|
||||||
|
|
||||||
if(type.constructor.get() instanceof Legsc){
|
if(type.constructor.get() instanceof Mechc){
|
||||||
image.drawCenter(type.baseRegion);
|
image.drawCenter(type.baseRegion);
|
||||||
image.drawCenter(type.legRegion);
|
image.drawCenter(type.legRegion);
|
||||||
image.drawCenter(type.legRegion, true, false);
|
image.drawCenter(type.legRegion, true, false);
|
||||||
}
|
|
||||||
image.draw(type.region);
|
|
||||||
|
|
||||||
Image baseCell = ImagePacker.get(type.cellRegion);
|
|
||||||
Image cell = new Image(type.cellRegion.getWidth(), type.cellRegion.getHeight());
|
|
||||||
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));
|
|
||||||
|
|
||||||
image.draw(cell, image.width/2 - cell.width/2, image.height/2 - cell.height/2);
|
|
||||||
|
|
||||||
for(Weapon weapon : type.weapons){
|
|
||||||
weapon.load();
|
|
||||||
|
|
||||||
for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){
|
|
||||||
i *= Mathf.sign(weapon.flipped);
|
|
||||||
|
|
||||||
image.draw(weapon.region,
|
|
||||||
(int)(i * weapon.x / Draw.scl + image.width / 2 - weapon.region.getWidth() / 2),
|
|
||||||
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f),
|
|
||||||
i > 0, false);
|
|
||||||
}
|
}
|
||||||
}
|
image.draw(type.region);
|
||||||
|
|
||||||
image.save("unit-" + type.name + "-full");
|
Image baseCell = ImagePacker.get(type.cellRegion);
|
||||||
|
Image cell = new Image(type.cellRegion.getWidth(), type.cellRegion.getHeight());
|
||||||
|
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));
|
||||||
|
|
||||||
|
image.draw(cell, image.width / 2 - cell.width / 2, image.height / 2 - cell.height / 2);
|
||||||
|
|
||||||
|
for(Weapon weapon : type.weapons){
|
||||||
|
weapon.load();
|
||||||
|
|
||||||
|
for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){
|
||||||
|
i *= Mathf.sign(weapon.flipped);
|
||||||
|
|
||||||
|
image.draw(weapon.region,
|
||||||
|
(int)(i * weapon.x / Draw.scl + image.width / 2 - weapon.region.getWidth() / 2),
|
||||||
|
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f),
|
||||||
|
i > 0, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image.save("unit-" + type.name + "-full");
|
||||||
|
}catch(IllegalArgumentException ignored){
|
||||||
|
//skip
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||