itemTransferRange proper usage

This commit is contained in:
Anuken 2022-03-11 00:35:34 -05:00
parent da1517879a
commit 846a697d2e
9 changed files with 14 additions and 13 deletions

View file

@ -984,6 +984,7 @@ keybind.move_y.name = Move Y
keybind.mouse_move.name = Follow Mouse
keybind.pan.name = Pan View
keybind.boost.name = Boost
keybind.command_mode.name = Command Mode
keybind.schematic_select.name = Select Region
keybind.schematic_menu.name = Schematic Menu
keybind.schematic_flip_x.name = Flip Schematic X

View file

@ -86,7 +86,7 @@ public class Vars implements Loadable{
public static final float itemSize = 5f;
/** units outside this bound will die instantly */
public static final float finalWorldBounds = 250;
/** range for building */
/** default range for building */
public static final float buildingRange = 220f;
/** range for moving items */
public static final float itemTransferRange = 220f;

View file

@ -100,7 +100,7 @@ public class BuilderAI extends AIController{
if(valid){
//move toward the plan
moveTo(req.tile(), buildingRange - 20f);
moveTo(req.tile(), unit.type.buildRange - 20f);
}else{
//discard invalid plan
unit.plans.removeFirst();
@ -120,7 +120,7 @@ public class BuilderAI extends AIController{
Building build = world.build(plan.x, plan.y);
if(build instanceof ConstructBuild cons){
float dist = Math.min(cons.dst(unit) - buildingRange, 0);
float dist = Math.min(cons.dst(unit) - unit.type.buildRange, 0);
//make sure you can reach the plan in time
if(dist / unit.speed() < cons.buildCost * 0.9f){

View file

@ -1467,7 +1467,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
/**
* Called when another tile is tapped while this block is selected.
* Called when another tile is tapped while this building is selected.
* @return whether this block should be deselected.
*/
public boolean onConfigureBuildTapped(Building other){
@ -1483,7 +1483,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
/**
* Called when a position is tapped when this building is selected.
* Called when a position is tapped while this building is selected.
*
* @return whether the tap event is consumed - if true, the player will not start shooting or interact with things under the cursor.
* */
@ -1492,7 +1492,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
/**
* Called when this block's config menu is closed
* Called when this block's config menu is closed.
*/
public void onConfigureClosed(){}

View file

@ -175,7 +175,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Replace
public float clipSize(){
if(isBuilding()){
return state.rules.infiniteResources ? Float.MAX_VALUE : Math.max(type.clipSize, type.region.width) + buildingRange + tilesize*4f;
return state.rules.infiniteResources ? Float.MAX_VALUE : Math.max(type.clipSize, type.region.width) + type.buildRange + tilesize*4f;
}
if(mining()){
return type.clipSize + type.miningRange;

View file

@ -12,7 +12,7 @@ public enum Binding implements KeyBind{
pan(KeyCode.mouseForward),
boost(KeyCode.shiftLeft),
commandMode(KeyCode.shiftLeft),
command_mode(KeyCode.shiftLeft),
control(KeyCode.controlLeft),
respawn(KeyCode.v),
select(KeyCode.mouseLeft),

View file

@ -296,8 +296,8 @@ public class DesktopInput extends InputHandler{
if(!locked && block == null && !scene.hasField() &&
//disable command mode when player unit can boost and command mode binding is the same
!(!player.dead() && player.unit().type.canBoost && keybinds.get(Binding.commandMode).key == keybinds.get(Binding.boost).key)){
commandMode = input.keyDown(Binding.commandMode);
!(!player.dead() && player.unit().type.canBoost && keybinds.get(Binding.command_mode).key == keybinds.get(Binding.boost).key)){
commandMode = input.keyDown(Binding.command_mode);
}else{
commandMode = false;
}

View file

@ -254,7 +254,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
@Remote(called = Loc.server, targets = Loc.both, forward = true)
public static void requestItem(Player player, Building build, Item item, int amount){
if(player == null || build == null || !build.interactable(player.team()) || !player.within(build, buildingRange) || player.dead()) return;
if(player == null || build == null || !build.interactable(player.team()) || !player.within(build, itemTransferRange) || player.dead()) return;
if(net.server() && (!Units.canInteract(player, build) ||
!netServer.admins.allowAction(player, ActionType.withdrawItem, build.tile(), action -> {
@ -270,7 +270,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
@Remote(targets = Loc.both, forward = true, called = Loc.server)
public static void transferInventory(Player player, Building build){
if(player == null || build == null || !player.within(build, buildingRange) || build.items == null || player.dead()) return;
if(player == null || build == null || !player.within(build, itemTransferRange) || build.items == null || player.dead()) return;
if(net.server() && (player.unit().stack.amount <= 0 || !Units.canInteract(player, build) ||
!netServer.admins.allowAction(player, ActionType.depositItem, build.tile, action -> {

View file

@ -483,7 +483,7 @@ public class LExecutor{
}
}
case getBlock -> {
float range = Math.max(unit.range(), buildingRange);
float range = Math.max(unit.range(), unit.type.buildRange);
if(!unit.within(x1, y1, range)){
exec.setobj(p3, null);
exec.setobj(p4, null);