mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 15:02:03 -08:00
Cleanup
This commit is contained in:
parent
3a7ee50db3
commit
46ec457819
42 changed files with 142 additions and 118 deletions
|
|
@ -100,8 +100,7 @@ committingchanges = Comitting Changes
|
|||
done = Done
|
||||
feature.unsupported = Your device does not support this feature.
|
||||
|
||||
mods.alphainfo = Keep in mind that mods are in alpha, and[scarlet] may be very buggy[].\nReport any issues you find to the Mindustry GitHub or Discord.
|
||||
mods.alpha = [accent](Alpha)
|
||||
mods.alphainfo = Keep in mind that mods are in alpha, and[scarlet] may be very buggy[].\nReport any issues you find to the Mindustry GitHub.
|
||||
mods = Mods
|
||||
mods.none = [lightgray]No mods found!
|
||||
mods.guide = Modding Guide
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class BaseAI{
|
|||
CoreBlock block = (CoreBlock)data.core().block;
|
||||
|
||||
//create AI core unit
|
||||
if(!state.isEditor() && !Groups.unit.contains(u -> u.team() == data.team && u.type() == block.unitType)){
|
||||
if(!state.isEditor() && !Groups.unit.contains(u -> u.team() == data.team && u.type == block.unitType)){
|
||||
Unit unit = block.unitType.create(data.team);
|
||||
unit.set(data.core());
|
||||
unit.add();
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ public class WaveSpawner{
|
|||
}
|
||||
|
||||
private void spawnEffect(Unit unit){
|
||||
Call.spawnEffect(unit.x, unit.y, unit.type());
|
||||
Call.spawnEffect(unit.x, unit.y, unit.type);
|
||||
Time.run(30f, unit::add);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class BuilderAI extends AIController{
|
|||
float dist = Math.min(cons.dst(unit) - buildingRange, 0);
|
||||
|
||||
//make sure you can reach the request in time
|
||||
if(dist / unit.type().speed < cons.buildCost * 0.9f){
|
||||
if(dist / unit.type.speed < cons.buildCost * 0.9f){
|
||||
following = b;
|
||||
found = true;
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ public class BuilderAI extends AIController{
|
|||
|
||||
@Override
|
||||
public AIController fallback(){
|
||||
return unit.type().flying ? new FlyingAI() : new GroundAI();
|
||||
return unit.type.flying ? new FlyingAI() : new GroundAI();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class FlyingAI extends AIController{
|
|||
@Override
|
||||
public void updateMovement(){
|
||||
if(target != null && unit.hasWeapons() && command() == UnitCommand.attack){
|
||||
if(unit.type().weapons.first().rotate){
|
||||
if(unit.type.weapons.first().rotate){
|
||||
moveTo(target, unit.range() * 0.8f);
|
||||
unit.lookAt(target);
|
||||
}else{
|
||||
|
|
@ -57,7 +57,7 @@ public class FlyingAI extends AIController{
|
|||
vec.setAngle(Mathf.slerpDelta(unit.vel().angle(), vec.angle(), 0.6f));
|
||||
}
|
||||
|
||||
vec.setLength(unit.type().speed);
|
||||
vec.setLength(unit.type.speed);
|
||||
|
||||
unit.moveAt(vec);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ public class FormationAI extends AIController implements FormationMember{
|
|||
|
||||
@Override
|
||||
public void updateUnit(){
|
||||
UnitType type = unit.type();
|
||||
UnitType type = unit.type;
|
||||
|
||||
if(leader.dead){
|
||||
unit.resetController();
|
||||
return;
|
||||
}
|
||||
|
||||
if(unit.type().canBoost && unit.canPassOn()){
|
||||
if(unit.type.canBoost && unit.canPassOn()){
|
||||
unit.elevation = Mathf.approachDelta(unit.elevation, 0f, 0.08f);
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ public class FormationAI extends AIController implements FormationMember{
|
|||
|
||||
unit.aim(leader.aimX(), leader.aimY());
|
||||
|
||||
if(unit.type().rotateShooting){
|
||||
if(unit.type.rotateShooting){
|
||||
unit.lookAt(leader.aimX(), leader.aimY());
|
||||
}else if(unit.moving()){
|
||||
unit.lookAt(unit.vel.angle());
|
||||
|
|
@ -65,7 +65,7 @@ public class FormationAI extends AIController implements FormationMember{
|
|||
|
||||
CoreBuild core = unit.team.core();
|
||||
|
||||
if(core != null && com.mineTile().drop() != null && unit.within(core, unit.type().range) && !unit.acceptsItem(com.mineTile().drop())){
|
||||
if(core != null && com.mineTile().drop() != null && unit.within(core, unit.type.range) && !unit.acceptsItem(com.mineTile().drop())){
|
||||
if(core.acceptStack(unit.stack.item, unit.stack.amount, unit) > 0){
|
||||
Call.transferItemTo(unit.stack.item, unit.stack.amount, unit.x, unit.y, core);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ public class GroundAI extends AIController{
|
|||
}
|
||||
}
|
||||
|
||||
if(unit.type().canBoost && !unit.onSolid()){
|
||||
if(unit.type.canBoost && !unit.onSolid()){
|
||||
unit.elevation = Mathf.approachDelta(unit.elevation, 0f, 0.08f);
|
||||
}
|
||||
|
||||
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.type().rotateShooting){
|
||||
if(unit.type().hasWeapons()){
|
||||
unit.lookAt(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
|
||||
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.type.rotateShooting){
|
||||
if(unit.type.hasWeapons()){
|
||||
unit.lookAt(Predict.intercept(unit, target, unit.type.weapons.first().bullet.speed));
|
||||
}
|
||||
}else if(unit.moving()){
|
||||
unit.lookAt(unit.vel().angle());
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class LogicAI extends AIController{
|
|||
}
|
||||
}
|
||||
|
||||
if(unit.type().canBoost && !unit.type().flying){
|
||||
if(unit.type.canBoost && !unit.type.flying){
|
||||
unit.elevation = Mathf.approachDelta(unit.elevation, Mathf.num(boost || unit.onSolid()), 0.08f);
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ public class LogicAI extends AIController{
|
|||
|
||||
@Override
|
||||
protected boolean shouldShoot(){
|
||||
return shoot && !(unit.type().canBoost && boost);
|
||||
return shoot && !(unit.type.canBoost && boost);
|
||||
}
|
||||
|
||||
//always aim for the main target
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class MinerAI extends AIController{
|
|||
|
||||
if(!(unit instanceof Minerc miner) || core == null) return;
|
||||
|
||||
if(miner.mineTile() != null && !miner.mineTile().within(unit, unit.type().range)){
|
||||
if(miner.mineTile() != null && !miner.mineTile().within(unit, unit.type.range)){
|
||||
miner.mineTile(null);
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ public class MinerAI extends AIController{
|
|||
}
|
||||
|
||||
//if inventory is full, drop it off.
|
||||
if(unit.stack.amount >= unit.type().itemCapacity || (targetItem != null && !unit.acceptsItem(targetItem))){
|
||||
if(unit.stack.amount >= unit.type.itemCapacity || (targetItem != null && !unit.acceptsItem(targetItem))){
|
||||
mining = false;
|
||||
}else{
|
||||
if(retarget() && targetItem != null){
|
||||
|
|
@ -44,9 +44,9 @@ public class MinerAI extends AIController{
|
|||
}
|
||||
|
||||
if(ore != null){
|
||||
moveTo(ore, unit.type().range / 2f);
|
||||
moveTo(ore, unit.type.range / 2f);
|
||||
|
||||
if(unit.within(ore, unit.type().range)){
|
||||
if(unit.within(ore, unit.type.range)){
|
||||
miner.mineTile(ore);
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ public class MinerAI extends AIController{
|
|||
return;
|
||||
}
|
||||
|
||||
if(unit.within(core, unit.type().range)){
|
||||
if(unit.within(core, unit.type.range)){
|
||||
if(core.acceptStack(unit.stack.item, unit.stack.amount, unit) > 0){
|
||||
Call.transferItemTo(unit.stack.item, unit.stack.amount, unit.x, unit.y, core);
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ public class MinerAI extends AIController{
|
|||
mining = true;
|
||||
}
|
||||
|
||||
circle(core, unit.type().range / 1.8f);
|
||||
circle(core, unit.type.range / 1.8f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class RepairAI extends AIController{
|
|||
if(target instanceof Building){
|
||||
boolean shoot = false;
|
||||
|
||||
if(target.within(unit, unit.type().range)){
|
||||
if(target.within(unit, unit.type.range)){
|
||||
unit.aim(target);
|
||||
shoot = true;
|
||||
}
|
||||
|
|
@ -23,8 +23,8 @@ public class RepairAI extends AIController{
|
|||
}
|
||||
|
||||
if(target != null){
|
||||
if(!target.within(unit, unit.type().range * 0.65f) && target instanceof Building){
|
||||
moveTo(target, unit.type().range * 0.65f);
|
||||
if(!target.within(unit, unit.type.range * 0.65f) && target instanceof Building){
|
||||
moveTo(target, unit.type.range * 0.65f);
|
||||
}
|
||||
|
||||
unit.lookAt(target);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class SuicideAI extends GroundAI{
|
|||
}
|
||||
|
||||
if(retarget()){
|
||||
target = target(unit.x, unit.y, unit.range(), unit.type().targetAir, unit.type().targetGround);
|
||||
target = target(unit.x, unit.y, unit.range(), unit.type.targetAir, unit.type.targetGround);
|
||||
}
|
||||
|
||||
Building core = unit.closestEnemyCore();
|
||||
|
|
@ -30,11 +30,11 @@ public class SuicideAI extends GroundAI{
|
|||
|
||||
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.hasWeapons()){
|
||||
rotate = true;
|
||||
shoot = unit.within(target, unit.type().weapons.first().bullet.range() +
|
||||
shoot = unit.within(target, unit.type.weapons.first().bullet.range() +
|
||||
(target instanceof Building ? ((Building)target).block.size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f));
|
||||
|
||||
if(unit.type().hasWeapons()){
|
||||
unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
|
||||
if(unit.type.hasWeapons()){
|
||||
unit.aimLook(Predict.intercept(unit, target, unit.type.weapons.first().bullet.speed));
|
||||
}
|
||||
|
||||
//do not move toward walls or transport blocks
|
||||
|
|
@ -65,7 +65,7 @@ public class SuicideAI extends GroundAI{
|
|||
if(!blocked){
|
||||
moveToTarget = true;
|
||||
//move towards target directly
|
||||
unit.moveAt(vec.set(target).sub(unit).limit(unit.type().speed));
|
||||
unit.moveAt(vec.set(target).sub(unit).limit(unit.type.speed));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class PhysicsProcess implements AsyncProcess{
|
|||
PhysicRef ref = entity.physref();
|
||||
|
||||
ref.body.layer =
|
||||
entity.type().allowLegStep ? layerLegs :
|
||||
entity.type.allowLegStep ? layerLegs :
|
||||
entity.isGrounded() ? layerGround : layerFlying;
|
||||
ref.x = entity.x();
|
||||
ref.y = entity.y();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class Fx{
|
|||
|
||||
mixcol(Pal.accent, 1f);
|
||||
alpha(e.fout());
|
||||
rect(block ? ((BlockUnitc)select).tile().block.icon(Cicon.full) : select.type().icon(Cicon.full), select.x, select.y, block ? 0f : select.rotation - 90f);
|
||||
rect(block ? ((BlockUnitc)select).tile().block.icon(Cicon.full) : select.type.icon(Cicon.full), select.x, select.y, block ? 0f : select.rotation - 90f);
|
||||
alpha(1f);
|
||||
Lines.stroke(e.fslope() * 1f);
|
||||
Lines.square(select.x, select.y, e.fout() * select.hitSize * 2f, 45);
|
||||
|
|
@ -66,7 +66,7 @@ public class Fx{
|
|||
}),
|
||||
|
||||
unitDespawn = new Effect(100f, e -> {
|
||||
if(!(e.data instanceof Unit) || e.<Unit>data().type() == null) return;
|
||||
if(!(e.data instanceof Unit) || e.<Unit>data().type == null) return;
|
||||
|
||||
Unit select = e.data();
|
||||
float scl = e.fout(Interp.pow2Out);
|
||||
|
|
@ -74,7 +74,7 @@ public class Fx{
|
|||
Draw.scl *= scl;
|
||||
|
||||
mixcol(Pal.accent, 1f);
|
||||
rect(select.type().icon(Cicon.full), select.x, select.y, select.rotation - 90f);
|
||||
rect(select.type.icon(Cicon.full), select.x, select.y, select.rotation - 90f);
|
||||
reset();
|
||||
|
||||
Draw.scl = p;
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ public class Logic implements ApplicationListener{
|
|||
|
||||
if(state.isGame()){
|
||||
if(!net.client()){
|
||||
state.enemies = Groups.unit.count(u -> u.team() == state.rules.waveTeam && u.type().isCounted);
|
||||
state.enemies = Groups.unit.count(u -> u.team() == state.rules.waveTeam && u.type.isCounted);
|
||||
}
|
||||
|
||||
if(!state.isPaused()){
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ public class NetServer implements ApplicationListener{
|
|||
shooting = false;
|
||||
}
|
||||
|
||||
if(!player.dead() && (player.unit().type().flying || !player.unit().type().canBoost)){
|
||||
if(!player.dead() && (player.unit().type.flying || !player.unit().type.canBoost)){
|
||||
boosting = false;
|
||||
}
|
||||
|
||||
|
|
@ -629,7 +629,7 @@ public class NetServer implements ApplicationListener{
|
|||
Unit unit = player.unit();
|
||||
|
||||
long elapsed = Time.timeSinceMillis(con.lastReceivedClientTime);
|
||||
float maxSpeed = ((player.unit().type().canBoost && player.unit().isFlying()) ? player.unit().type().boostMultiplier : 1f) * player.unit().type().speed;
|
||||
float maxSpeed = ((player.unit().type.canBoost && player.unit().isFlying()) ? player.unit().type.boostMultiplier : 1f) * player.unit().type.speed;
|
||||
if(unit.isGrounded()){
|
||||
maxSpeed *= unit.floorSpeedMultiplier();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class Units{
|
|||
|
||||
nearby(x, y, width, height, unit -> {
|
||||
if(boolResult) return;
|
||||
if((unit.isGrounded() && !unit.type().hovering) == ground){
|
||||
if((unit.isGrounded() && !unit.type.hovering) == ground){
|
||||
unit.hitbox(hitrect);
|
||||
|
||||
if(hitrect.overlaps(x, y, width, height)){
|
||||
|
|
|
|||
|
|
@ -1295,7 +1295,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||
case type -> block;
|
||||
case firstItem -> items == null ? null : items.first();
|
||||
case config -> block.configurations.containsKey(Item.class) || block.configurations.containsKey(Liquid.class) ? config() : null;
|
||||
case payloadType -> getPayload() instanceof UnitPayload p1 ? p1.unit.type() : getPayload() instanceof BuildPayload p2 ? p2.block() : null;
|
||||
case payloadType -> getPayload() instanceof UnitPayload p1 ? p1.unit.type : getPayload() instanceof BuildPayload p2 ? p2.block() : null;
|
||||
default -> noSensed;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ abstract class CommanderComp implements Entityc, Posc{
|
|||
units.clear();
|
||||
|
||||
Units.nearby(team, x, y, 150f, u -> {
|
||||
if(u.isAI() && include.get(u) && u != self() && u.type().flying == type.flying && u.hitSize <= hitSize * 1.1f){
|
||||
if(u.isAI() && include.get(u) && u != self() && u.type.flying == type.flying && u.hitSize <= hitSize * 1.1f){
|
||||
units.add(u);
|
||||
}
|
||||
});
|
||||
|
|
@ -82,7 +82,7 @@ abstract class CommanderComp implements Entityc, Posc{
|
|||
FormationAI ai;
|
||||
unit.controller(ai = new FormationAI(self(), formation));
|
||||
spacing = Math.max(spacing, ai.formationSize());
|
||||
minFormationSpeed = Math.min(minFormationSpeed, unit.type().speed);
|
||||
minFormationSpeed = Math.min(minFormationSpeed, unit.type.speed);
|
||||
}
|
||||
this.formation = formation;
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ abstract class CommanderComp implements Entityc, Posc{
|
|||
//reset controlled units
|
||||
for(Unit unit : controlling){
|
||||
if(unit.controller().isBeingControlled(self())){
|
||||
unit.controller(unit.type().createController());
|
||||
unit.controller(unit.type.createController());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||
admin = typing = false;
|
||||
textFadeTime = 0f;
|
||||
if(!dead()){
|
||||
unit.controller(unit.type().createController());
|
||||
unit.controller(unit.type.createController());
|
||||
unit = Nulls.unit;
|
||||
}
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||
|
||||
@Replace
|
||||
public float clipSize(){
|
||||
return unit.isNull() ? 20 : unit.type().hitSize * 2f;
|
||||
return unit.isNull() ? 20 : unit.type.hitSize * 2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -123,7 +123,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||
deathTimer = 0;
|
||||
|
||||
//update some basic state to sync things
|
||||
if(unit.type().canBoost){
|
||||
if(unit.type.canBoost){
|
||||
Tile tile = unit.tileOn();
|
||||
unit.elevation = Mathf.approachDelta(unit.elevation, (tile != null && tile.solid()) || boosting ? 1f : 0f, 0.08f);
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||
|
||||
if(this.unit != Nulls.unit){
|
||||
//un-control the old unit
|
||||
this.unit.controller(this.unit.type().createController());
|
||||
this.unit.controller(this.unit.type.createController());
|
||||
}
|
||||
this.unit = unit;
|
||||
if(unit != Nulls.unit){
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
|||
unit.apply(liquid.effect, 60 * 2);
|
||||
|
||||
if(unit.vel.len() > 0.1){
|
||||
Fx.ripple.at(unit.x, unit.y, unit.type().rippleScale, liquid.color);
|
||||
Fx.ripple.at(unit.x, unit.y, unit.type.rippleScale, liquid.color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||
@Import int id;
|
||||
|
||||
private UnitController controller;
|
||||
private UnitType type;
|
||||
UnitType type;
|
||||
boolean spawnedByCore;
|
||||
double flag;
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||
case firstItem -> stack().amount == 0 ? null : item();
|
||||
case payloadType -> self() instanceof Payloadc pay ?
|
||||
(pay.payloads().isEmpty() ? null :
|
||||
pay.payloads().peek() instanceof UnitPayload p1 ? p1.unit.type() :
|
||||
pay.payloads().peek() instanceof UnitPayload p1 ? p1.unit.type :
|
||||
pay.payloads().peek() instanceof BuildPayload p2 ? p2.block() : null) : null;
|
||||
default -> noSensed;
|
||||
};
|
||||
|
|
@ -163,22 +163,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||
|
||||
@Override
|
||||
public void set(UnitType def, UnitController controller){
|
||||
type(type);
|
||||
if(this.type != def){
|
||||
setType(def);
|
||||
}
|
||||
controller(controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void type(UnitType type){
|
||||
if(this.type == type) return;
|
||||
|
||||
setStats(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitType type(){
|
||||
return type;
|
||||
}
|
||||
|
||||
/** @return pathfinder path type for calculating costs */
|
||||
public int pathType(){
|
||||
return Pathfinder.costGround;
|
||||
|
|
@ -208,7 +198,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||
return Units.getCap(team);
|
||||
}
|
||||
|
||||
public void setStats(UnitType type){
|
||||
public void setType(UnitType type){
|
||||
this.type = type;
|
||||
this.maxHealth = type.health;
|
||||
this.drag = type.drag;
|
||||
|
|
@ -226,7 +216,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||
@Override
|
||||
public void afterSync(){
|
||||
//set up type info after reading
|
||||
setStats(this.type);
|
||||
setType(this.type);
|
||||
controller.unit(self());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class AIController implements UnitController{
|
|||
|
||||
if(tile == targetTile || (costType == Pathfinder.costWater && !targetTile.floor().isLiquid)) return;
|
||||
|
||||
unit.moveAt(vec.trns(unit.angleTo(targetTile), unit.type().speed));
|
||||
unit.moveAt(vec.trns(unit.angleTo(targetTile), unit.type.speed));
|
||||
}
|
||||
|
||||
protected void updateWeapons(){
|
||||
|
|
@ -105,7 +105,7 @@ public class AIController implements UnitController{
|
|||
boolean ret = retarget();
|
||||
|
||||
if(ret){
|
||||
target = findTarget(unit.x, unit.y, unit.range(), unit.type().targetAir, unit.type().targetGround);
|
||||
target = findTarget(unit.x, unit.y, unit.range(), unit.type.targetAir, unit.type.targetGround);
|
||||
}
|
||||
|
||||
if(invalid(target)){
|
||||
|
|
@ -119,7 +119,7 @@ public class AIController implements UnitController{
|
|||
float mountX = unit.x + Angles.trnsx(rotation, weapon.x, weapon.y),
|
||||
mountY = unit.y + Angles.trnsy(rotation, weapon.x, weapon.y);
|
||||
|
||||
if(unit.type().singleTarget){
|
||||
if(unit.type.singleTarget){
|
||||
targets[i] = target;
|
||||
}else{
|
||||
if(ret){
|
||||
|
|
@ -176,7 +176,7 @@ public class AIController implements UnitController{
|
|||
}
|
||||
|
||||
protected void circle(Position target, float circleLength){
|
||||
circle(target, circleLength, unit.type().speed);
|
||||
circle(target, circleLength, unit.type.speed);
|
||||
}
|
||||
|
||||
protected void circle(Position target, float circleLength, float speed){
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import mindustry.gen.*;
|
|||
import mindustry.io.legacy.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/**
|
||||
|
|
@ -138,4 +140,20 @@ public class SpawnGroup implements Serializable{
|
|||
", items=" + items +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
SpawnGroup group = (SpawnGroup)o;
|
||||
return end == group.end && begin == group.begin && spacing == group.spacing && max == group.max
|
||||
&& Float.compare(group.unitScaling, unitScaling) == 0 && Float.compare(group.shields, shields) == 0
|
||||
&& Float.compare(group.shieldScaling, shieldScaling) == 0 && unitAmount == group.unitAmount &&
|
||||
type == group.type && effect == group.effect && Structs.eq(items, group.items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return Arrays.hashCode(new Object[]{type, end, begin, spacing, max, unitScaling, shields, shieldScaling, unitAmount, effect, items});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ public class Teams{
|
|||
}
|
||||
|
||||
private void count(Unit unit){
|
||||
unit.team.data().updateCount(unit.type(), 1);
|
||||
unit.team.data().updateCount(unit.type, 1);
|
||||
|
||||
if(unit instanceof Payloadc){
|
||||
((Payloadc)unit).payloads().each(p -> {
|
||||
|
|
@ -178,15 +178,15 @@ public class Teams{
|
|||
data.units.add(unit);
|
||||
data.presentFlag = true;
|
||||
|
||||
if(data.unitsByType == null || data.unitsByType.length <= unit.type().id){
|
||||
if(data.unitsByType == null || data.unitsByType.length <= unit.type.id){
|
||||
data.unitsByType = new Seq[content.units().size];
|
||||
}
|
||||
|
||||
if(data.unitsByType[unit.type().id] == null){
|
||||
data.unitsByType[unit.type().id] = new Seq<>();
|
||||
if(data.unitsByType[unit.type.id] == null){
|
||||
data.unitsByType[unit.type.id] = new Seq<>();
|
||||
}
|
||||
|
||||
data.unitsByType[unit.type().id].add(unit);
|
||||
data.unitsByType[unit.type.id].add(unit);
|
||||
|
||||
count(unit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class MinimapRenderer implements Disposable{
|
|||
|
||||
Draw.mixcol(unit.team().color, 1f);
|
||||
float scale = Scl.scl(1f) / 2f * scaling * 32f;
|
||||
Draw.rect(unit.type().icon(Cicon.full), x + rx, y + ry, scale, scale, unit.rotation() - 90);
|
||||
Draw.rect(unit.type.icon(Cicon.full), x + rx, y + ry, scale, scale, unit.rotation() - 90);
|
||||
Draw.reset();
|
||||
|
||||
//only disable player names in multiplayer
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class OverlayRenderer{
|
|||
//special selection for block "units"
|
||||
Fill.square(select.x, select.y, ((BlockUnitc)select).tile().block.size * tilesize/2f);
|
||||
}else{
|
||||
Draw.rect(select.type().icon(Cicon.full), select.x(), select.y(), select.rotation() - 90);
|
||||
Draw.rect(select.type.icon(Cicon.full), select.x(), select.y(), select.rotation() - 90);
|
||||
}
|
||||
|
||||
Lines.stroke(unitFade);
|
||||
|
|
|
|||
|
|
@ -599,11 +599,11 @@ public class DesktopInput extends InputHandler{
|
|||
}
|
||||
|
||||
protected void updateMovement(Unit unit){
|
||||
boolean omni = unit.type().omniMovement;
|
||||
boolean omni = unit.type.omniMovement;
|
||||
boolean ground = unit.isGrounded();
|
||||
|
||||
float strafePenalty = ground ? 1f : Mathf.lerp(1f, unit.type().strafePenalty, Angles.angleDist(unit.vel().angle(), unit.rotation()) / 180f);
|
||||
float baseSpeed = unit.type().speed;
|
||||
float strafePenalty = ground ? 1f : Mathf.lerp(1f, unit.type.strafePenalty, Angles.angleDist(unit.vel().angle(), unit.rotation()) / 180f);
|
||||
float baseSpeed = unit.type.speed;
|
||||
|
||||
//limit speed to minimum formation speed to preserve formation
|
||||
if(unit.isCommanding()){
|
||||
|
|
@ -611,7 +611,7 @@ public class DesktopInput extends InputHandler{
|
|||
baseSpeed = unit.minFormationSpeed * 0.95f;
|
||||
}
|
||||
|
||||
float speed = baseSpeed * Mathf.lerp(1f, unit.isCommanding() ? 1f : unit.type().canBoost ? unit.type().boostMultiplier : 1f, unit.elevation) * strafePenalty;
|
||||
float speed = baseSpeed * Mathf.lerp(1f, unit.isCommanding() ? 1f : unit.type.canBoost ? unit.type.boostMultiplier : 1f, unit.elevation) * strafePenalty;
|
||||
float xa = Core.input.axis(Binding.move_x);
|
||||
float ya = Core.input.axis(Binding.move_y);
|
||||
boolean boosted = (unit instanceof Mechc && unit.isFlying());
|
||||
|
|
@ -622,7 +622,7 @@ public class DesktopInput extends InputHandler{
|
|||
}
|
||||
|
||||
float mouseAngle = Angles.mouseAngle(unit.x, unit.y);
|
||||
boolean aimCursor = omni && player.shooting && unit.type().hasWeapons() && unit.type().faceTarget && !boosted && unit.type().rotateShooting;
|
||||
boolean aimCursor = omni && player.shooting && unit.type.hasWeapons() && unit.type.faceTarget && !boosted && unit.type.rotateShooting;
|
||||
|
||||
if(aimCursor){
|
||||
unit.lookAt(mouseAngle);
|
||||
|
|
@ -637,11 +637,11 @@ public class DesktopInput extends InputHandler{
|
|||
}else{
|
||||
unit.moveAt(Tmp.v2.trns(unit.rotation, movement.len()));
|
||||
if(!movement.isZero() && ground){
|
||||
unit.vel.rotateTo(movement.angle(), unit.type().rotateSpeed);
|
||||
unit.vel.rotateTo(movement.angle(), unit.type.rotateSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
unit.aim(unit.type().faceTarget ? Core.input.mouseWorld() : Tmp.v1.trns(unit.rotation, Core.input.mouseWorld().dst(unit)).add(unit.x, unit.y));
|
||||
unit.aim(unit.type.faceTarget ? Core.input.mouseWorld() : Tmp.v1.trns(unit.rotation, Core.input.mouseWorld().dst(unit)).add(unit.x, unit.y));
|
||||
unit.controlWeapons(true, player.shooting && !boosted);
|
||||
|
||||
player.boosting = Core.input.keyDown(Binding.boost) && !movement.isZero();
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
Payloadc pay = (Payloadc)unit;
|
||||
|
||||
if(target.isAI() && target.isGrounded() && pay.canPickup(target)
|
||||
&& target.within(unit, unit.type().hitSize * 2f + target.type().hitSize * 2f)){
|
||||
&& target.within(unit, unit.type.hitSize * 2f + target.type.hitSize * 2f)){
|
||||
Call.pickedUnitPayload(unit, target);
|
||||
}
|
||||
}
|
||||
|
|
@ -365,7 +365,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
|
||||
if(commander.isCommanding()){
|
||||
commander.clearCommand();
|
||||
}else if(player.unit().type().commandLimit > 0){
|
||||
}else if(player.unit().type.commandLimit > 0){
|
||||
|
||||
//TODO try out some other formations
|
||||
commander.commandNearby(new CircleFormation());
|
||||
|
|
@ -398,17 +398,17 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
}
|
||||
|
||||
if(player.shooting && !wasShooting && player.unit().hasWeapons() && state.rules.unitAmmo && player.unit().ammo <= 0){
|
||||
player.unit().type().weapons.first().noAmmoSound.at(player.unit());
|
||||
player.unit().type.weapons.first().noAmmoSound.at(player.unit());
|
||||
}
|
||||
|
||||
wasShooting = player.shooting;
|
||||
|
||||
if(!player.dead()){
|
||||
controlledType = player.unit().type();
|
||||
controlledType = player.unit().type;
|
||||
}
|
||||
|
||||
if(controlledType != null && player.dead()){
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType && !u.dead);
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type == controlledType && !u.dead);
|
||||
|
||||
if(unit != null){
|
||||
Call.unitControl(player, unit);
|
||||
|
|
@ -418,7 +418,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
|
||||
public void checkUnit(){
|
||||
if(controlledType != null){
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType && !u.dead);
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type == controlledType && !u.dead);
|
||||
if(unit == null && controlledType == UnitTypes.block){
|
||||
unit = world.buildWorld(player.x, player.y) instanceof ControlBlock ? ((ControlBlock)world.buildWorld(player.x, player.y)).unit() : null;
|
||||
}
|
||||
|
|
@ -437,7 +437,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
Unit unit = player.unit();
|
||||
if(!(unit instanceof Payloadc pay)) return;
|
||||
|
||||
Unit target = Units.closest(player.team(), pay.x(), pay.y(), unit.type().hitSize * 2.5f, u -> u.isAI() && u.isGrounded() && pay.canPickup(u) && u.within(unit, u.hitSize + unit.hitSize * 1.2f));
|
||||
Unit target = Units.closest(player.team(), pay.x(), pay.y(), unit.type.hitSize * 2.5f, u -> u.isAI() && u.isGrounded() && pay.canPickup(u) && u.within(unit, u.hitSize + unit.hitSize * 1.2f));
|
||||
if(target != null){
|
||||
Call.requestUnitPayload(player, target);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||
if(tile != null && player.team().isEnemy(tile.team)){
|
||||
player.miner().mineTile(null);
|
||||
target = tile;
|
||||
}else if(tile != null && player.unit().type().canHeal && tile.team == player.team() && tile.damaged()){
|
||||
}else if(tile != null && player.unit().type.canHeal && tile.team == player.team() && tile.damaged()){
|
||||
player.miner().mineTile(null);
|
||||
target = tile;
|
||||
}
|
||||
|
|
@ -834,10 +834,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||
protected void updateMovement(Unit unit){
|
||||
Rect rect = Tmp.r3;
|
||||
|
||||
UnitType type = unit.type();
|
||||
UnitType type = unit.type;
|
||||
if(type == null) return;
|
||||
|
||||
boolean omni = unit.type().omniMovement;
|
||||
boolean omni = unit.type.omniMovement;
|
||||
boolean legs = unit.isGrounded();
|
||||
boolean allowHealing = type.canHeal;
|
||||
boolean validHealTarget = allowHealing && target instanceof Building && ((Building)target).isValid() && target.team() == unit.team &&
|
||||
|
|
@ -855,7 +855,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||
float attractDst = 15f;
|
||||
float strafePenalty = legs ? 1f : Mathf.lerp(1f, type.strafePenalty, Angles.angleDist(unit.vel.angle(), unit.rotation) / 180f);
|
||||
|
||||
float baseSpeed = unit.type().speed;
|
||||
float baseSpeed = unit.type.speed;
|
||||
|
||||
//limit speed to minimum formation speed to preserve formation
|
||||
if(unit.isCommanding()){
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ public class LExecutor{
|
|||
if(unit instanceof Payloadc pay){
|
||||
//units
|
||||
if(exec.bool(p1)){
|
||||
Unit result = Units.closest(unit.team, unit.x, unit.y, unit.type().hitSize * 2f, u -> u.isAI() && u.isGrounded() && pay.canPickup(u) && u.within(unit, u.hitSize + unit.hitSize * 1.2f));
|
||||
Unit result = Units.closest(unit.team, unit.x, unit.y, unit.type.hitSize * 2f, u -> u.isAI() && u.isGrounded() && pay.canPickup(u) && u.within(unit, u.hitSize + unit.hitSize * 1.2f));
|
||||
|
||||
if(result != null){
|
||||
Call.pickedUnitPayload(unit, result);
|
||||
|
|
|
|||
|
|
@ -257,12 +257,12 @@ public class SectorDamage{
|
|||
float healthMult = 1f + Mathf.clamp(unit.armor / 20f);
|
||||
|
||||
sumHealth += unit.health*healthMult + unit.shield;
|
||||
sumDps += unit.type().dpsEstimate;
|
||||
sumDps += unit.type.dpsEstimate;
|
||||
if(unit.abilities.find(a -> a instanceof HealFieldAbility) instanceof HealFieldAbility h){
|
||||
sumRps += h.amount / h.reload * 60f;
|
||||
}
|
||||
}else{
|
||||
curEnemyDps += unit.type().dpsEstimate;
|
||||
curEnemyDps += unit.type.dpsEstimate;
|
||||
curEnemyHealth += unit.health;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,8 +260,8 @@ public class ContentParser{
|
|||
//TODO test this!
|
||||
read(() -> {
|
||||
//add reconstructor type
|
||||
if(value.hasChild("requirements")){
|
||||
JsonValue rec = value.remove("requirements");
|
||||
if(value.has("requirements")){
|
||||
JsonValue rec = value.remove("requirements");
|
||||
|
||||
//intermediate class for parsing
|
||||
class UnitReq{
|
||||
|
|
@ -286,6 +286,16 @@ public class ContentParser{
|
|||
|
||||
}
|
||||
|
||||
//read extra default waves
|
||||
if(value.has("waves")){
|
||||
SpawnGroup[] groups = parser.readValue(SpawnGroup[].class, value.get("waves"));
|
||||
for(SpawnGroup group : groups){
|
||||
group.type = unit;
|
||||
}
|
||||
|
||||
Vars.defaultWaves.get().addAll(groups);
|
||||
}
|
||||
|
||||
readFields(unit, value, true);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ public class AmmoTypes implements ContentList{
|
|||
|
||||
if(build.block.consumes.hasPower() && build.block.consumes.getPower().buffered){
|
||||
float amount = closest.build.power.status * build.block.consumes.getPower().capacity;
|
||||
float powerPerAmmo = totalPower / unit.type().ammoCapacity;
|
||||
float ammoRequired = unit.type().ammoCapacity - unit.ammo;
|
||||
float powerPerAmmo = totalPower / unit.type.ammoCapacity;
|
||||
float ammoRequired = unit.type.ammoCapacity - unit.ammo;
|
||||
float powerRequired = ammoRequired * powerPerAmmo;
|
||||
float powerTaken = Math.min(amount, powerRequired);
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,13 @@ public class ItemStack implements Comparable<ItemStack>{
|
|||
return item.compareTo(itemStack.item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ItemStack stack)) return false;
|
||||
return amount == stack.amount && item == stack.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "ItemStack{" +
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class StatusEffect extends MappableContent{
|
|||
}
|
||||
|
||||
if(effect != Fx.none && Mathf.chanceDelta(effectChance)){
|
||||
Tmp.v1.rnd(unit.type().hitSize /2f);
|
||||
Tmp.v1.rnd(unit.type.hitSize /2f);
|
||||
effect.at(unit.x + Tmp.v1.x, unit.y + Tmp.v1.y);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class UnitType extends UnlockableContent{
|
|||
public Unit create(Team team){
|
||||
Unit unit = constructor.get();
|
||||
unit.team = team;
|
||||
unit.type(this);
|
||||
unit.setType(this);
|
||||
unit.ammo = ammoCapacity; //fill up on ammo upon creation
|
||||
unit.elevation = flying ? 1f : 0;
|
||||
unit.heal();
|
||||
|
|
|
|||
|
|
@ -712,7 +712,7 @@ public class HudFragment extends Fragment{
|
|||
t.add(new SideBar(() -> player.unit().healthf(), () -> true, true)).width(bw).growY().padRight(pad);
|
||||
t.image(() -> player.icon()).scaling(Scaling.bounded).grow().maxWidth(54f);
|
||||
t.add(new SideBar(() -> player.dead() ? 0f : player.displayAmmo() ? player.unit().ammof() : player.unit().healthf(), () -> !player.displayAmmo(), false)).width(bw).growY().padLeft(pad).update(b -> {
|
||||
b.color.set(player.displayAmmo() ? player.dead() || player.unit() instanceof BlockUnitc ? Pal.ammo : player.unit().type().ammoType.color : Pal.health);
|
||||
b.color.set(player.displayAmmo() ? player.dead() || player.unit() instanceof BlockUnitc ? Pal.ammo : player.unit().type.ammoType.color : Pal.health);
|
||||
});
|
||||
|
||||
t.getChildren().get(1).toFront();
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class TractorBeamTurret extends Block{
|
|||
}
|
||||
|
||||
//look at target
|
||||
if(target != null && target.within(this, range) && target.team() != team && target.type().flying && efficiency() > 0.01f){
|
||||
if(target != null && target.within(this, range) && target.team() != team && target.type.flying && efficiency() > 0.01f){
|
||||
any = true;
|
||||
float dest = angleTo(target);
|
||||
rotation = Angles.moveToward(rotation, dest, rotateSpeed * edelta());
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class UnitPayload implements Payload{
|
|||
|
||||
@Override
|
||||
public boolean dump(){
|
||||
if(!Units.canCreate(unit.team, unit.type())){
|
||||
if(!Units.canCreate(unit.team, unit.type)){
|
||||
deactiveTime = 1f;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ public class UnitPayload implements Payload{
|
|||
@Override
|
||||
public void draw(){
|
||||
Drawf.shadow(unit.x, unit.y, 20);
|
||||
Draw.rect(unit.type().icon(Cicon.full), unit.x, unit.y, unit.rotation - 90);
|
||||
Draw.rect(unit.type.icon(Cicon.full), unit.x, unit.y, unit.rotation - 90);
|
||||
|
||||
//draw warning
|
||||
if(deactiveTime > 0){
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class Reconstructor extends UnitBlock{
|
|||
return this.payload == null
|
||||
&& relativeTo(source) != rotation
|
||||
&& payload instanceof UnitPayload
|
||||
&& hasUpgrade(((UnitPayload)payload).unit.type());
|
||||
&& hasUpgrade(((UnitPayload)payload).unit.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -114,9 +114,9 @@ public class Reconstructor extends UnitBlock{
|
|||
if(constructing() && hasArrived()){
|
||||
Draw.draw(Layer.blockOver, () -> {
|
||||
Draw.alpha(1f - progress/ constructTime);
|
||||
Draw.rect(payload.unit.type().icon(Cicon.full), x, y, rotdeg() - 90);
|
||||
Draw.rect(payload.unit.type.icon(Cicon.full), x, y, rotdeg() - 90);
|
||||
Draw.reset();
|
||||
Drawf.construct(this, upgrade(payload.unit.type()), rotdeg() - 90f, progress / constructTime, speedScl, time);
|
||||
Drawf.construct(this, upgrade(payload.unit.type), rotdeg() - 90f, progress / constructTime, speedScl, time);
|
||||
});
|
||||
}else{
|
||||
Draw.z(Layer.blockOver);
|
||||
|
|
@ -135,7 +135,7 @@ public class Reconstructor extends UnitBlock{
|
|||
|
||||
if(payload != null){
|
||||
//check if offloading
|
||||
if(!hasUpgrade(payload.unit.type())){
|
||||
if(!hasUpgrade(payload.unit.type)){
|
||||
moveOutPayload();
|
||||
}else{ //update progress
|
||||
if(moveInPayload()){
|
||||
|
|
@ -146,7 +146,7 @@ public class Reconstructor extends UnitBlock{
|
|||
|
||||
//upgrade the unit
|
||||
if(progress >= constructTime){
|
||||
payload.unit = upgrade(payload.unit.type()).create(payload.unit.team());
|
||||
payload.unit = upgrade(payload.unit.type).create(payload.unit.team());
|
||||
progress = 0;
|
||||
Effect.shake(2f, 3f, this);
|
||||
Fx.producesmoke.at(this);
|
||||
|
|
@ -168,12 +168,12 @@ public class Reconstructor extends UnitBlock{
|
|||
public UnitType unit(){
|
||||
if(payload == null) return null;
|
||||
|
||||
UnitType t = upgrade(payload.unit.type());
|
||||
UnitType t = upgrade(payload.unit.type);
|
||||
return t != null && t.unlockedNow() ? t : null;
|
||||
}
|
||||
|
||||
public boolean constructing(){
|
||||
return payload != null && hasUpgrade(payload.unit.type());
|
||||
return payload != null && hasUpgrade(payload.unit.type);
|
||||
}
|
||||
|
||||
public boolean hasUpgrade(UnitType type){
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ public class ResupplyPoint extends Block{
|
|||
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(team, x, y, range, u -> u.type().ammoType instanceof ItemAmmoType && u.ammo <= u.type().ammoCapacity - ammoAmount && valid.get(u));
|
||||
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(x, y, ammoAmount / 2f, ammoColor, unit);
|
||||
unit.ammo = Math.min(unit.ammo + ammoAmount, unit.type().ammoCapacity);
|
||||
unit.ammo = Math.min(unit.ammo + ammoAmount, unit.type.ammoCapacity);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class SStats implements SteamUserStatsCallback{
|
|||
// active10Phantoms.complete();
|
||||
//}
|
||||
|
||||
if(Groups.unit.count(u -> u.type() == UnitTypes.crawler && u.team() == player.team()) >= 50){
|
||||
if(Groups.unit.count(u -> u.type == UnitTypes.crawler && u.team() == player.team()) >= 50){
|
||||
active50Crawlers.complete();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue