Cleanup
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.AmmoTypes.*;
|
||||
@@ -51,12 +53,18 @@ public class ResupplyPoint extends Block{
|
||||
|
||||
/** Tries to resupply nearby units.
|
||||
* @return whether resupplying was successful. If unit ammo is disabled, always returns false. */
|
||||
public static boolean resupply(Building tile, float range, int ammoAmount, Color ammoColor){
|
||||
public static boolean resupply(Building tile, float range, float ammoAmount, Color ammoColor){
|
||||
return resupply(tile.team, tile.x, tile.y, range, ammoAmount, ammoColor, u -> true);
|
||||
}
|
||||
|
||||
/** Tries to resupply nearby units.
|
||||
* @return whether resupplying was successful. If unit ammo is disabled, always returns false. */
|
||||
public static boolean resupply(Team team, float x, float y, float range, float ammoAmount, Color ammoColor, Boolf<Unit> valid){
|
||||
if(!state.rules.unitAmmo) return false;
|
||||
|
||||
Unit unit = Units.closest(tile.team, tile.x, tile.y, range, u -> u.type().ammoType instanceof ItemAmmoType && u.ammo <= u.type().ammoCapacity - ammoAmount);
|
||||
Unit unit = Units.closest(team, x, y, range, u -> u.type().ammoType instanceof ItemAmmoType && u.ammo <= u.type().ammoCapacity - ammoAmount && valid.get(u));
|
||||
if(unit != null){
|
||||
Fx.itemTransfer.at(tile.x, tile.y, ammoAmount / 2f, ammoColor, unit);
|
||||
Fx.itemTransfer.at(x, y, ammoAmount / 2f, ammoColor, unit);
|
||||
unit.ammo = Math.min(unit.ammo + ammoAmount, unit.type().ammoCapacity);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user