mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-16 02:38:37 +07:00
.
This commit is contained in:
@ -335,6 +335,24 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
|
|
||||||
idBuilder.addStaticBlock(idStore.build());
|
idBuilder.addStaticBlock(idStore.build());
|
||||||
|
|
||||||
|
//create mock types of all components
|
||||||
|
for(Stype component : allComponents){
|
||||||
|
|
||||||
|
|
||||||
|
Array<Stype> dependencies = getDependencies(component);
|
||||||
|
Array<Stype> out = new Array<>();
|
||||||
|
out.add(component);
|
||||||
|
out.addAll(component.superclasses());
|
||||||
|
dependencies.each(dep -> {
|
||||||
|
out.add(dep);
|
||||||
|
out.addAll(dep.superclasses());
|
||||||
|
});
|
||||||
|
|
||||||
|
out.distinct();
|
||||||
|
|
||||||
|
Log.info("Dependencies of {0}:\n{1}\n\n", component, out.toString("\n", s -> "&lb> " + s));
|
||||||
|
}
|
||||||
|
|
||||||
write(idBuilder);
|
write(idBuilder);
|
||||||
}else{
|
}else{
|
||||||
//round 2: generate actual classes and implement interfaces
|
//round 2: generate actual classes and implement interfaces
|
||||||
|
@ -54,11 +54,11 @@ public class Selement<T extends Element>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode(){
|
public int hashCode(){
|
||||||
return e.hashCode();
|
return toString().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o){
|
public boolean equals(Object o){
|
||||||
return o != null && o.getClass() == getClass() && ((Selement)o).e.equals(e);
|
return o != null && toString().equals(o.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,7 @@ public class Stype extends Selement<TypeElement>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Array<Stype> superclasses(){
|
public Array<Stype> superclasses(){
|
||||||
Array<Stype> out = new Array<>();
|
return Array.with(BaseProcessor.typeu.directSupertypes(mirror())).map(Stype::of);
|
||||||
Stype sup = superclass();
|
|
||||||
while(!sup.name().equals("Object")){
|
|
||||||
out.add(sup);
|
|
||||||
sup = sup.superclass();
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stype superclass(){
|
public Stype superclass(){
|
||||||
|
@ -4,5 +4,6 @@ mindustry.entities.def.EntityDefs.DecalDef=1
|
|||||||
mindustry.entities.def.EntityDefs.EffectDef=2
|
mindustry.entities.def.EntityDefs.EffectDef=2
|
||||||
mindustry.entities.def.EntityDefs.TileDef=3
|
mindustry.entities.def.EntityDefs.TileDef=3
|
||||||
mindustry.entities.def.EntityDefs.GenericUnitDef=5
|
mindustry.entities.def.EntityDefs.GenericUnitDef=5
|
||||||
|
mindustry.entities.def.EntityDefs.GenericBuilderDef=6
|
||||||
mindustry.entities.def.EntityDefs.BulletDef=0
|
mindustry.entities.def.EntityDefs.BulletDef=0
|
||||||
mindustry.entities.def.EntityDefs.PlayerDef=4
|
mindustry.entities.def.EntityDefs.PlayerDef=4
|
@ -508,11 +508,11 @@ public class NetClient implements ApplicationListener{
|
|||||||
if(timer.get(0, playerSyncTime)){
|
if(timer.get(0, playerSyncTime)){
|
||||||
BuildRequest[] requests;
|
BuildRequest[] requests;
|
||||||
//limit to 10 to prevent buffer overflows
|
//limit to 10 to prevent buffer overflows
|
||||||
int usedRequests = Math.min(player.buildQueue().size, 10);
|
int usedRequests = Math.min(player.builder().requests().size, 10);
|
||||||
|
|
||||||
requests = new BuildRequest[usedRequests];
|
requests = new BuildRequest[usedRequests];
|
||||||
for(int i = 0; i < usedRequests; i++){
|
for(int i = 0; i < usedRequests; i++){
|
||||||
requests[i] = player.buildQueue().get(i);
|
requests[i] = player.builder().requests().get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Call.onClientShapshot(lastSent++, player.x, player.y,
|
Call.onClientShapshot(lastSent++, player.x, player.y,
|
||||||
|
@ -513,7 +513,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
player.isBoosting = boosting;
|
player.isBoosting = boosting;
|
||||||
player.isShooting = shooting;
|
player.isShooting = shooting;
|
||||||
player.isBuilding = building;
|
player.isBuilding = building;
|
||||||
player.buildQueue().clear();
|
player.builder().requests().clear();
|
||||||
|
|
||||||
for(BuildRequest req : requests){
|
for(BuildRequest req : requests){
|
||||||
if(req == null) continue;
|
if(req == null) continue;
|
||||||
@ -536,7 +536,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
connection.rejectedRequests.add(req);
|
connection.rejectedRequests.add(req);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
player.buildQueue().addLast(req);
|
player.builder().requests().addLast(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.rejectedRequests.clear();
|
connection.rejectedRequests.clear();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package mindustry.entities.def;
|
package mindustry.entities.def;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.func.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
@ -677,7 +678,17 @@ public class EntityComps{
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract static class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
abstract static class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||||
|
//TODO mock these properly
|
||||||
private static final Unitc noUnit = GenericUnitEntity.create();
|
private static final Unitc noUnit = GenericUnitEntity.create();
|
||||||
|
private static final Builderc noBuilder = GenericBuilderEntity.create().with(s -> s.requests(new Queue<BuildRequest>(){
|
||||||
|
@Override
|
||||||
|
public void addLast(BuildRequest object){
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFirst(BuildRequest object){
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
@NonNull @ReadOnly Unitc unit = noUnit;
|
@NonNull @ReadOnly Unitc unit = noUnit;
|
||||||
|
|
||||||
@ -691,6 +702,14 @@ public class EntityComps{
|
|||||||
@Nullable String lastText;
|
@Nullable String lastText;
|
||||||
float textFadeTime;
|
float textFadeTime;
|
||||||
|
|
||||||
|
public boolean isBuilder(){
|
||||||
|
return unit instanceof Builderc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMiner(){
|
||||||
|
return unit instanceof Minerc;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable Tilec closestCore(){
|
public @Nullable Tilec closestCore(){
|
||||||
return state.teams.closestCore(x(), y(), team);
|
return state.teams.closestCore(x(), y(), team);
|
||||||
}
|
}
|
||||||
@ -732,6 +751,13 @@ public class EntityComps{
|
|||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builderc builder(){
|
||||||
|
if(!(unit instanceof Builderc)){
|
||||||
|
return noBuilder;
|
||||||
|
}
|
||||||
|
return (Builderc)unit;
|
||||||
|
}
|
||||||
|
|
||||||
public void unit(Unitc unit){
|
public void unit(Unitc unit){
|
||||||
if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead.");
|
if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead.");
|
||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
@ -1287,7 +1313,7 @@ public class EntityComps{
|
|||||||
|
|
||||||
transient float x, y, rotation;
|
transient float x, y, rotation;
|
||||||
|
|
||||||
@ReadOnly Queue<BuildRequest> requests = new Queue<>();
|
Queue<BuildRequest> requests = new Queue<>();
|
||||||
float buildSpeed = 1f;
|
float buildSpeed = 1f;
|
||||||
//boolean building;
|
//boolean building;
|
||||||
|
|
||||||
@ -1782,6 +1808,11 @@ public class EntityComps{
|
|||||||
return (T)this;
|
return (T)this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<T> T with(Cons<T> cons){
|
||||||
|
cons.get((T)this);
|
||||||
|
return (T)this;
|
||||||
|
}
|
||||||
|
|
||||||
@InternalImpl
|
@InternalImpl
|
||||||
abstract int classId();
|
abstract int classId();
|
||||||
|
|
||||||
|
@ -22,4 +22,7 @@ class EntityDefs{
|
|||||||
|
|
||||||
@EntityDef({UnitComp.class})
|
@EntityDef({UnitComp.class})
|
||||||
class GenericUnitDef{}
|
class GenericUnitDef{}
|
||||||
|
|
||||||
|
@EntityDef({BuilderComp.class})
|
||||||
|
class GenericBuilderDef{}
|
||||||
}
|
}
|
||||||
|
@ -376,7 +376,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
deleting = true;
|
deleting = true;
|
||||||
}else if(selected != null){
|
}else if(selected != null){
|
||||||
//only begin shooting if there's no cursor event
|
//only begin shooting if there's no cursor event
|
||||||
if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.buildQueue().size == 0 || !player.isBuilding) && !droppingItem &&
|
if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().requests().size == 0 || !player.isBuilding) && !droppingItem &&
|
||||||
!tryBeginMine(selected) && player.getMineTile() == null && !Core.scene.hasKeyboard()){
|
!tryBeginMine(selected) && player.getMineTile() == null && !Core.scene.hasKeyboard()){
|
||||||
player.isShooting = true;
|
player.isShooting = true;
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
if(Core.input.keyDown(Binding.select) && mode == none && !isPlacing() && deleting){
|
if(Core.input.keyDown(Binding.select) && mode == none && !isPlacing() && deleting){
|
||||||
BuildRequest req = getRequest(cursorX, cursorY);
|
BuildRequest req = getRequest(cursorX, cursorY);
|
||||||
if(req != null && req.breaking){
|
if(req != null && req.breaking){
|
||||||
player.buildQueue().remove(req);
|
player.builder().requests().remove(req);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
deleting = false;
|
deleting = false;
|
||||||
@ -431,7 +431,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
if(sreq != null){
|
if(sreq != null){
|
||||||
if(getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null){
|
if(getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null){
|
||||||
player.buildQueue().remove(sreq, true);
|
player.builder().requests().remove(sreq, true);
|
||||||
}
|
}
|
||||||
sreq = null;
|
sreq = null;
|
||||||
}
|
}
|
||||||
|
@ -96,17 +96,17 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
@Remote(variants = Variant.one)
|
@Remote(variants = Variant.one)
|
||||||
public static void removeQueueBlock(int x, int y, boolean breaking){
|
public static void removeQueueBlock(int x, int y, boolean breaking){
|
||||||
player.removeRequest(x, y, breaking);
|
player.builder().removeBuild(x, y, breaking);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.client, called = Loc.server)
|
@Remote(targets = Loc.client, called = Loc.server)
|
||||||
public static void dropItem(Playerc player, float angle){
|
public static void dropItem(Playerc player, float angle){
|
||||||
if(net.server() && player.item().amount <= 0){
|
if(net.server() && player.unit().stack().amount <= 0){
|
||||||
throw new ValidateException(player, "Player cannot drop an item.");
|
throw new ValidateException(player, "Player cannot drop an item.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Fx.dropItem.at(player.x, player.y, angle, Color.white, player.item().item);
|
Fx.dropItem.at(player.x(), player.y(), angle, Color.white, player.unit().item());
|
||||||
player.clearItem();
|
player.unit().clearItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.server, forward = true, unreliable = true)
|
@Remote(targets = Loc.both, called = Loc.server, forward = true, unreliable = true)
|
||||||
@ -127,53 +127,34 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
@Remote(targets = Loc.both, forward = true, called = Loc.server)
|
@Remote(targets = Loc.both, forward = true, called = Loc.server)
|
||||||
public static void transferInventory(Playerc player, Tile tile){
|
public static void transferInventory(Playerc player, Tile tile){
|
||||||
if(player == null) return;
|
if(player == null) return;
|
||||||
if(net.server() && (player.item().amount <= 0 || player.isTransferring|| !Units.canInteract(player, tile) ||
|
if(net.server() && (player.unit().stack().amount <= 0 || !Units.canInteract(player, tile) ||
|
||||||
!netServer.admins.allowAction(player, ActionType.depositItem, tile, action -> {
|
!netServer.admins.allowAction(player, ActionType.depositItem, tile, action -> {
|
||||||
action.itemAmount = player.item().amount;
|
action.itemAmount = player.unit().stack().amount;
|
||||||
action.item = player.item().item;
|
action.item = player.unit().item();
|
||||||
}))){
|
}))){
|
||||||
throw new ValidateException(player, "Player cannot transfer an item.");
|
throw new ValidateException(player, "Player cannot transfer an item.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile.entity == null) return;
|
if(tile.entity == null) return;
|
||||||
|
|
||||||
player.isTransferring = true;
|
Item item = player.unit().item();
|
||||||
|
int amount = player.unit().stack().amount;
|
||||||
Item item = player.item().item;
|
int accepted = tile.block().acceptStack(item, amount, tile, player.unit());
|
||||||
int amount = player.item().amount;
|
player.unit().stack().amount -= accepted;
|
||||||
int accepted = tile.block().acceptStack(item, amount, tile, player);
|
|
||||||
player.item().amount -= accepted;
|
|
||||||
|
|
||||||
int sent = Mathf.clamp(accepted / 4, 1, 8);
|
int sent = Mathf.clamp(accepted / 4, 1, 8);
|
||||||
int removed = accepted / sent;
|
|
||||||
int[] remaining = {accepted, accepted};
|
|
||||||
Block block = tile.block();
|
Block block = tile.block();
|
||||||
|
|
||||||
Core.app.post(() -> Events.fire(new DepositEvent(tile, player, item, accepted)));
|
Core.app.post(() -> Events.fire(new DepositEvent(tile, player, item, accepted)));
|
||||||
|
|
||||||
for(int i = 0; i < sent; i++){
|
for(int i = 0; i < sent; i++){
|
||||||
boolean end = i == sent - 1;
|
|
||||||
Time.run(i * 3, () -> {
|
|
||||||
tile.block().getStackOffset(item, tile, stackTrns);
|
tile.block().getStackOffset(item, tile, stackTrns);
|
||||||
|
|
||||||
ItemTransfer.create(item,
|
createItemTransfer(item, player.x() + Angles.trnsx(player.unit().rotation() + 180f, backTrns), player.y() + Angles.trnsy(player.unit().rotation() + 180f, backTrns),
|
||||||
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
|
|
||||||
new Vec2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
new Vec2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||||
if(tile.block() != block || tile.entity == null || tile.entity.items() == null) return;
|
if(tile.block() != block || tile.entity == null || tile.entity.items() == null) return;
|
||||||
|
|
||||||
tile.block().handleStack(item, removed, tile, player);
|
tile.block().handleStack(item, accepted, tile, player.unit());
|
||||||
remaining[1] -= removed;
|
|
||||||
|
|
||||||
if(end && remaining[1] > 0){
|
|
||||||
tile.block().handleStack(item, remaining[1], tile, player);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
remaining[0] -= removed;
|
|
||||||
|
|
||||||
if(end){
|
|
||||||
player.isTransferring = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +180,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
public Eachable<BuildRequest> allRequests(){
|
public Eachable<BuildRequest> allRequests(){
|
||||||
return cons -> {
|
return cons -> {
|
||||||
for(BuildRequest request : player.buildQueue()) cons.get(request);
|
for(BuildRequest request : player.builder().requests()) cons.get(request);
|
||||||
for(BuildRequest request : selectRequests) cons.get(request);
|
for(BuildRequest request : selectRequests) cons.get(request);
|
||||||
for(BuildRequest request : lineRequests) cons.get(request);
|
for(BuildRequest request : lineRequests) cons.get(request);
|
||||||
};
|
};
|
||||||
@ -275,7 +256,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void useSchematic(Schematic schem){
|
public void useSchematic(Schematic schem){
|
||||||
selectRequests.addAll(schematics.toRequests(schem, world.toTile(player.x), world.toTile(player.y)));
|
selectRequests.addAll(schematics.toRequests(schem, player.tileX(), player.tileY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showSchematicSave(){
|
protected void showSchematicSave(){
|
||||||
@ -401,7 +382,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
return r2.overlaps(r1);
|
return r2.overlaps(r1);
|
||||||
};
|
};
|
||||||
|
|
||||||
for(BuildRequest req : player.buildQueue()){
|
for(BuildRequest req : player.builder().requests()){
|
||||||
if(test.get(req)) return req;
|
if(test.get(req)) return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +411,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
Draw.color(Pal.remove);
|
Draw.color(Pal.remove);
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
|
|
||||||
for(BuildRequest req : player.buildQueue()){
|
for(BuildRequest req : player.builder().requests()){
|
||||||
if(req.breaking) continue;
|
if(req.breaking) continue;
|
||||||
if(req.bounds(Tmp.r2).overlaps(Tmp.r1)){
|
if(req.bounds(Tmp.r2).overlaps(Tmp.r1)){
|
||||||
drawBreaking(req);
|
drawBreaking(req);
|
||||||
@ -491,7 +472,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
if(copy.hasConfig && copy.block.posConfig){
|
if(copy.hasConfig && copy.block.posConfig){
|
||||||
copy.config = Pos.get(Pos.x(copy.config) + copy.x - copy.originalX, Pos.y(copy.config) + copy.y - copy.originalY);
|
copy.config = Pos.get(Pos.x(copy.config) + copy.x - copy.originalX, Pos.y(copy.config) + copy.y - copy.originalY);
|
||||||
}
|
}
|
||||||
player.addBuildRequest(copy);
|
player.builder().addBuild(copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -535,7 +516,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
//remove build requests
|
//remove build requests
|
||||||
Tmp.r1.set(result.x * tilesize, result.y * tilesize, (result.x2 - result.x) * tilesize, (result.y2 - result.y) * tilesize);
|
Tmp.r1.set(result.x * tilesize, result.y * tilesize, (result.x2 - result.x) * tilesize, (result.y2 - result.y) * tilesize);
|
||||||
|
|
||||||
Iterator<BuildRequest> it = player.buildQueue().iterator();
|
Iterator<BuildRequest> it = player.builder().requests().iterator();
|
||||||
while(it.hasNext()){
|
while(it.hasNext()){
|
||||||
BuildRequest req = it.next();
|
BuildRequest req = it.next();
|
||||||
if(!req.breaking && req.bounds(Tmp.r2).overlaps(Tmp.r1)){
|
if(!req.breaking && req.bounds(Tmp.r2).overlaps(Tmp.r1)){
|
||||||
@ -646,7 +627,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean canTapPlayer(float x, float y){
|
boolean canTapPlayer(float x, float y){
|
||||||
return Mathf.dst(x, y, player.x, player.y) <= playerSelectRange && player.item().amount > 0;
|
return Mathf.dst(x, y, player.x, player.y) <= playerSelectRange && player.unit().stack().amount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tries to begin mining a tile, returns true if successful. */
|
/** Tries to begin mining a tile, returns true if successful. */
|
||||||
@ -663,7 +644,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
return !Core.scene.hasMouse()
|
return !Core.scene.hasMouse()
|
||||||
&& tile.drop() != null && tile.drop().hardness <= player.mech.drillPower
|
&& tile.drop() != null && tile.drop().hardness <= player.mech.drillPower
|
||||||
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
||||||
&& player.acceptsItem(tile.drop())
|
&& player.unit().acceptsItem(tile.drop())
|
||||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Playerc.mineDistance;
|
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Playerc.mineDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,10 +730,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
frag.add();
|
frag.add();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player != null){
|
|
||||||
player.isBuilding = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canShoot(){
|
public boolean canShoot(){
|
||||||
@ -768,16 +745,16 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void tryDropItems(Tile tile, float x, float y){
|
public void tryDropItems(Tile tile, float x, float y){
|
||||||
if(!droppingItem || player.item().amount <= 0 || canTapPlayer(x, y) || state.isPaused() ){
|
if(!droppingItem || player.unit().stack().amount <= 0 || canTapPlayer(x, y) || state.isPaused() ){
|
||||||
droppingItem = false;
|
droppingItem = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
droppingItem = false;
|
droppingItem = false;
|
||||||
|
|
||||||
ItemStack stack = player.item();
|
ItemStack stack = player.unit().stack();
|
||||||
|
|
||||||
if(tile.block().acceptStack(stack.item, stack.amount, tile, player) > 0 && tile.interactable(player.team()) && tile.block().hasItems && player.item().amount > 0 && !player.isTransferring && tile.interactable(player.team())){
|
if(tile.block().acceptStack(stack.item, stack.amount, tile, player.unit()) > 0 && tile.interactable(player.team()) && tile.block().hasItems && player.unit().stack().amount > 0 && tile.interactable(player.team())){
|
||||||
Call.transferInventory(player, tile);
|
Call.transferInventory(player, tile);
|
||||||
}else{
|
}else{
|
||||||
Call.dropItem(player.angleTo(x, y));
|
Call.dropItem(player.angleTo(x, y));
|
||||||
@ -801,7 +778,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean validPlace(int x, int y, Block type, int rotation, BuildRequest ignore){
|
public boolean validPlace(int x, int y, Block type, int rotation, BuildRequest ignore){
|
||||||
for(BuildRequest req : player.buildQueue()){
|
for(BuildRequest req : player.builder().requests()){
|
||||||
if(req != ignore
|
if(req != ignore
|
||||||
&& !req.breaking
|
&& !req.breaking
|
||||||
&& req.block.bounds(req.x, req.y, Tmp.r1).overlaps(type.bounds(x, y, Tmp.r2))
|
&& req.block.bounds(req.x, req.y, Tmp.r1).overlaps(type.bounds(x, y, Tmp.r2))
|
||||||
@ -819,14 +796,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
public void placeBlock(int x, int y, Block block, int rotation){
|
public void placeBlock(int x, int y, Block block, int rotation){
|
||||||
BuildRequest req = getRequest(x, y);
|
BuildRequest req = getRequest(x, y);
|
||||||
if(req != null){
|
if(req != null){
|
||||||
player.buildQueue().remove(req);
|
player.builder().requests().remove(req);
|
||||||
}
|
}
|
||||||
player.addBuildRequest(new BuildRequest(x, y, rotation, block));
|
player.builder().addBuild(new BuildRequest(x, y, rotation, block));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void breakBlock(int x, int y){
|
public void breakBlock(int x, int y){
|
||||||
Tile tile = world.ltile(x, y);
|
Tile tile = world.ltile(x, y);
|
||||||
player.addBuildRequest(new BuildRequest(tile.x, tile.y));
|
player.builder().addBuild(new BuildRequest(tile.x, tile.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawArrow(Block block, int x, int y, int rotation){
|
public void drawArrow(Block block, int x, int y, int rotation){
|
||||||
|
@ -109,7 +109,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(BuildRequest req : player.buildQueue()){
|
for(BuildRequest req : player.builder().requests()){
|
||||||
Tile other = world.tile(req.x, req.y);
|
Tile other = world.tile(req.x, req.y);
|
||||||
|
|
||||||
if(other == null || req.breaking) continue;
|
if(other == null || req.breaking) continue;
|
||||||
@ -224,10 +224,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(other == null){
|
if(other == null){
|
||||||
player.addBuildRequest(copy);
|
player.builder().addBuild(copy);
|
||||||
}else if(!other.breaking && other.x == request.x && other.y == request.y && other.block.size == request.block.size){
|
}else if(!other.breaking && other.x == request.x && other.y == request.y && other.block.size == request.block.size){
|
||||||
player.buildQueue().remove(other);
|
player.builder().requests().remove(other);
|
||||||
player.addBuildRequest(copy);
|
player.builder().addBuild(copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,11 +89,11 @@ public class PlacementFragment extends Fragment{
|
|||||||
boolean gridUpdate(InputHandler input){
|
boolean gridUpdate(InputHandler input){
|
||||||
scrollPositions.put(currentCategory, blockPane.getScrollY());
|
scrollPositions.put(currentCategory, blockPane.getScrollY());
|
||||||
|
|
||||||
if(Core.input.keyDown(Binding.pick)){ //mouse eyedropper select
|
if(Core.input.keyDown(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
|
||||||
Tile tile = world.ltileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
Tile tile = world.ltileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||||
Block tryRecipe = tile == null ? null : tile.block();
|
Block tryRecipe = tile == null ? null : tile.block();
|
||||||
|
|
||||||
for(BuildRequest req : player.buildQueue()){
|
for(BuildRequest req : player.builder().requests()){
|
||||||
if(!req.breaking && req.block.bounds(req.x, req.y, Tmp.r1).contains(Core.input.mouseWorld())){
|
if(!req.breaking && req.block.bounds(req.x, req.y, Tmp.r1).contains(Core.input.mouseWorld())){
|
||||||
tryRecipe = req.block;
|
tryRecipe = req.block;
|
||||||
break;
|
break;
|
||||||
|
@ -147,7 +147,7 @@ public class BuildBlock extends Block{
|
|||||||
player.isBuilding = true;
|
player.isBuilding = true;
|
||||||
}
|
}
|
||||||
//player.clearBuilding();
|
//player.clearBuilding();
|
||||||
player.addBuildRequest(new BuildRequest(tile.x, tile.y, tile.rotation(), entity.cblock), false);
|
player.builder().addBuild(new BuildRequest(tile.x, tile.y, tile.rotation(), entity.cblock), false);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=50973a6e5c025f6f9573206d5f49f03d3a4ee914
|
archash=e9bd792158afc4f72017d9bed995e448934e472e
|
||||||
|
Reference in New Issue
Block a user