Merge branch '6.0' into crater
# Conflicts: # core/assets/sprites/block_colors.png # core/assets/sprites/sprites.atlas # core/assets/sprites/sprites.png # core/assets/sprites/sprites2.png # core/assets/sprites/sprites4.png # core/assets/sprites/sprites6.png # core/src/mindustry/ui/fragments/PlayerListFragment.java
This commit is contained in:
@@ -75,7 +75,7 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
if(!current.initialized && !current.breaking && Build.validPlace(team(), current.x, current.y, current.block, current.rotation)){
|
||||
boolean hasAll = !Structs.contains(current.block.requirements, i -> !core.items().has(i.item));
|
||||
|
||||
if(hasAll){
|
||||
if(hasAll || state.rules.infiniteResources){
|
||||
Build.beginPlace(team(), current.x, current.y, current.block, current.rotation);
|
||||
}else{
|
||||
current.stuck = true;
|
||||
|
||||
@@ -26,6 +26,7 @@ import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -319,6 +320,40 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
||||
noSleep();
|
||||
}
|
||||
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handlePayload(Tilec source, Payload payload){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries dumping a payload.
|
||||
* @param todump payload to dump.
|
||||
* @return whether the payload was moved successfully
|
||||
*/
|
||||
public boolean dumpPayload(@NonNull Payload todump){
|
||||
Array<Tilec> proximity = proximity();
|
||||
int dump = rotation();
|
||||
|
||||
if(proximity.size == 0) return false;
|
||||
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Tilec other = proximity.get((i + dump) % proximity.size);
|
||||
|
||||
if(other.team() == team() && other.acceptPayload(this, todump)){
|
||||
other.handlePayload(this, todump);
|
||||
incrementDump(proximity.size);
|
||||
return true;
|
||||
}
|
||||
|
||||
incrementDump(proximity.size);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleItem(Tilec source, Item item){
|
||||
items.add(item, 1);
|
||||
}
|
||||
|
||||
@@ -4,17 +4,31 @@ import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.renderer;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Drawf{
|
||||
|
||||
public static void selected(int x, int y, Block block, Color color){
|
||||
Draw.color(color);
|
||||
for(int i = 0; i < 4; i++){
|
||||
Point2 p = Geometry.d8edge[i];
|
||||
float offset = -Math.max(block.size - 1, 0) / 2f * tilesize;
|
||||
Draw.rect("block-select",
|
||||
x*tilesize + block.offset() + offset * p.x,
|
||||
y*tilesize + block.offset() + offset * p.y, i * 90);
|
||||
}
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public static void shadow(float x, float y, float rad){
|
||||
Draw.color(0, 0, 0, 0.4f);
|
||||
Draw.rect("circle-shadow", x, y, rad, rad);
|
||||
|
||||
@@ -229,15 +229,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
public void drawSelected(int x, int y, Block block, Color color){
|
||||
Draw.color(color);
|
||||
for(int i = 0; i < 4; i++){
|
||||
Point2 p = Geometry.d8edge[i];
|
||||
float offset = -Math.max(block.size - 1, 0) / 2f * tilesize;
|
||||
Draw.rect("block-select",
|
||||
x*tilesize + block.offset() + offset * p.x,
|
||||
y*tilesize + block.offset() + offset * p.y, i * 90);
|
||||
}
|
||||
Draw.reset();
|
||||
Drawf.selected(x, y, block, color);
|
||||
}
|
||||
|
||||
public void drawBreaking(BuildRequest request){
|
||||
|
||||
@@ -116,9 +116,9 @@ public class PlayerListFragment extends Fragment{
|
||||
t.defaults().size(bs);
|
||||
|
||||
t.addImageButton(Icon.hammer, Styles.clearPartiali,
|
||||
() -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(user, AdminAction.ban)));
|
||||
() -> ui.showConfirm("$confirm", Core.bundle.format("confirmban", user.name()), () -> Call.onAdminRequest(user, AdminAction.ban)));
|
||||
t.addImageButton(Icon.cancel, Styles.clearPartiali,
|
||||
() -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(user, AdminAction.kick)));
|
||||
() -> ui.showConfirm("$confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.onAdminRequest(user, AdminAction.kick)));
|
||||
|
||||
t.row();
|
||||
|
||||
@@ -128,9 +128,9 @@ public class PlayerListFragment extends Fragment{
|
||||
String id = user.uuid();
|
||||
|
||||
if(netServer.admins.isAdmin(id, connection.address)){
|
||||
ui.showConfirm("$confirm", "$confirmunadmin", () -> netServer.admins.unAdminPlayer(id));
|
||||
ui.showConfirm("$confirm", Core.bundle.format("confirmunadmin", user.name()), () -> netServer.admins.unAdminPlayer(id));
|
||||
}else{
|
||||
ui.showConfirm("$confirm", "$confirmadmin", () -> netServer.admins.adminPlayer(id, user.usid()));
|
||||
ui.showConfirm("$confirm", Core.bundle.format("confirmadmin", user.name()), () -> netServer.admins.adminPlayer(id, user.usid()));
|
||||
}
|
||||
}).update(b -> b.setChecked(user.admin()))
|
||||
.disabled(b -> net.client())
|
||||
@@ -144,7 +144,7 @@ public class PlayerListFragment extends Fragment{
|
||||
button.add().growY();
|
||||
|
||||
button.addImageButton(Icon.hammer, Styles.clearPartiali,
|
||||
() -> ui.showConfirm("$confirm", "$confirmvotekick", () -> Call.sendChatMessage("/votekick " + user.name()))).size(h);
|
||||
() -> ui.showConfirm("$confirm", Core.bundle.format("confirmvotekick", user.name()), () -> Call.sendChatMessage("/votekick " + user.name()))).size(h);
|
||||
}
|
||||
|
||||
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14);
|
||||
|
||||
@@ -43,6 +43,7 @@ public class Block extends UnlockableContent{
|
||||
public boolean outputsLiquid = false;
|
||||
public boolean consumesPower = true;
|
||||
public boolean outputsPower = false;
|
||||
public boolean outputsPayload = false;
|
||||
|
||||
public int itemCapacity = 10;
|
||||
public float liquidCapacity = 10f;
|
||||
|
||||
@@ -11,8 +11,8 @@ import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -29,6 +29,7 @@ public class MassConveyor extends Block{
|
||||
size = 3;
|
||||
rotate = true;
|
||||
update = true;
|
||||
outputsPayload = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,10 +40,27 @@ public class MassConveyor extends Block{
|
||||
edgeRegion = Core.atlas.find(name + "-edge");
|
||||
}
|
||||
|
||||
public class MassConveyorEntity extends TileEntity implements MassAcceptor{
|
||||
@Override
|
||||
protected TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-icon")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
super.drawPlace(x, y, rotation, valid);
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tilec other = world.ent(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size);
|
||||
if(other != null && other.block().outputsPayload && other.block().size == size){
|
||||
Drawf.selected(other.tileX(), other.tileY(), other.block(), Pal.accent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MassConveyorEntity extends TileEntity{
|
||||
public @Nullable Payload item;
|
||||
public float progress, itemRotation, animation;
|
||||
public @Nullable MassAcceptor next;
|
||||
public @Nullable Tilec next;
|
||||
public boolean blocked;
|
||||
public int step = -1, stepAccepted = -1;
|
||||
|
||||
@@ -52,9 +70,9 @@ public class MassConveyor extends Block{
|
||||
|
||||
Tilec accept = nearby(Geometry.d4[rotation()].x * size, Geometry.d4[rotation()].y * size);
|
||||
//next block must be aligned and of the same size
|
||||
if(accept instanceof MassAcceptor && accept.block().size == size &&
|
||||
if(accept != null && accept.block().size == size &&
|
||||
tileX() + Geometry.d4[rotation()].x * size == accept.tileX() && tileY() + Geometry.d4[rotation()].y * size == accept.tileY()){
|
||||
next = (MassAcceptor)accept;
|
||||
next = accept;
|
||||
}
|
||||
|
||||
int ntrns = 1 + size/2;
|
||||
@@ -73,6 +91,7 @@ public class MassConveyor extends Block{
|
||||
animation = 0f;
|
||||
}
|
||||
|
||||
//TODO nondeterministic input priority
|
||||
int curStep = curStep();
|
||||
if(curStep > step){
|
||||
boolean valid = step != -1;
|
||||
@@ -83,21 +102,21 @@ public class MassConveyor extends Block{
|
||||
//trigger update forward
|
||||
next.updateTile();
|
||||
|
||||
if(next.acceptMass(item, this)){
|
||||
if(next.acceptPayload(this, item)){
|
||||
//move forward.
|
||||
next.handleMass(item, this);
|
||||
next.handlePayload(this, item);
|
||||
item = null;
|
||||
}
|
||||
}else if(!blocked){
|
||||
//dump item forward
|
||||
float trnext = size * tilesize / 2f, cx = Geometry.d4[rotation()].x, cy = Geometry.d4[rotation()].y, rot = rotation() * 90;
|
||||
|
||||
item.dump(x + cx * trnext, y + cy * trnext, rotation() * 90);
|
||||
item = null;
|
||||
if(item.dump(x + cx * trnext, y + cy * trnext, rotation() * 90)){
|
||||
item = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,13 +191,13 @@ public class MassConveyor extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptMass(Payload item, Tilec source){
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
return this.item == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMass(Payload item, Tilec source){
|
||||
this.item = item;
|
||||
public void handlePayload(Tilec source, Payload payload){
|
||||
this.item = payload;
|
||||
this.stepAccepted = curStep();
|
||||
this.itemRotation = source.rotation() * 90;
|
||||
this.animation = 0;
|
||||
@@ -189,8 +208,9 @@ public class MassConveyor extends Block{
|
||||
return !blocked || next != null;
|
||||
}else{
|
||||
Tilec accept = nearby(Geometry.d4[direction].x * size, Geometry.d4[direction].y * size);
|
||||
return accept instanceof MassAcceptor && accept.block().size == size &&
|
||||
accept.tileX() + Geometry.d4[accept.rotation()].x * size == tileX() && accept.tileY() + Geometry.d4[accept.rotation()].y * size == tileY();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +239,7 @@ public class MassConveyor extends Block{
|
||||
}
|
||||
|
||||
int curStep(){
|
||||
return (int)(Time.time() / moveTime);
|
||||
return (int)((Time.time()) / moveTime);
|
||||
}
|
||||
|
||||
float fract(){
|
||||
@@ -227,36 +247,4 @@ public class MassConveyor extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public interface MassAcceptor extends Tilec{
|
||||
boolean acceptMass(Payload item, Tilec source);
|
||||
void handleMass(Payload item, Tilec source);
|
||||
}
|
||||
|
||||
public interface Payload{
|
||||
void draw(float x, float y, float rotation);
|
||||
void dump(float x, float y, float rotation);
|
||||
}
|
||||
|
||||
public static class UnitPayload implements Payload{
|
||||
public Unitc unit;
|
||||
|
||||
public UnitPayload(Unitc unit){
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(float x, float y, float rotation){
|
||||
unit.set(x, y);
|
||||
unit.rotation(rotation);
|
||||
unit.add();
|
||||
}
|
||||
|
||||
@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, 20);
|
||||
Draw.rect(unit.type().icon(Cicon.full), x, y, rotation - 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
core/src/mindustry/world/blocks/payloads/Payload.java
Normal file
12
core/src/mindustry/world/blocks/payloads/Payload.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package mindustry.world.blocks.payloads;
|
||||
|
||||
public interface Payload{
|
||||
|
||||
/** draws this payload at a position. */
|
||||
void draw(float x, float y, float rotation);
|
||||
|
||||
/** @return whether this payload was dumped. */
|
||||
default boolean dump(float x, float y, float rotation){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
31
core/src/mindustry/world/blocks/payloads/UnitPayload.java
Normal file
31
core/src/mindustry/world/blocks/payloads/UnitPayload.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package mindustry.world.blocks.payloads;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class UnitPayload implements Payload{
|
||||
public Unitc unit;
|
||||
|
||||
public UnitPayload(Unitc unit){
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dump(float x, float y, float rotation){
|
||||
unit.set(x, y);
|
||||
unit.rotation(rotation);
|
||||
unit.add();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@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, 20);
|
||||
Draw.rect(unit.type().icon(Cicon.full), x, y, rotation - 90);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user