TextField fixes

This commit is contained in:
Anuken
2020-06-15 19:26:03 -04:00
parent 89aec3ac51
commit b789394efc
4 changed files with 13 additions and 3 deletions

View File

@@ -514,7 +514,6 @@ public class UnitTypes implements ContentList{
shootEffect = Fx.shootSmall;
smokeEffect = Fx.shootSmallSmoke;
tileDamageMultiplier = 0.15f;
ammoMultiplier = 2;
}};
}});
}};

View File

@@ -10,11 +10,13 @@ import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.type.*;
import static mindustry.Vars.*;
@Component
abstract class WeaponsComp implements Teamc, Posc, Rotc{
@Import float x, y, rotation;
/** minimum cursor distance from player, fixes 'cross-eyed' shooting */
/** minimum cursor distance from unit, fixes 'cross-eyed' shooting */
static final float minAimDst = 20f;
/** temporary weapon sequence number */
static int sequenceNum = 0;
@@ -24,6 +26,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
@ReadOnly transient float range, aimX, aimY;
@ReadOnly transient boolean isRotate;
boolean isShooting;
int ammo;
void setWeaponRotation(float rotation){
for(WeaponMount mount : mounts){
@@ -94,7 +97,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
mount.targetRotation = angleTo(mount.aimX, mount.aimY);
}
if(mount.shoot){
if(mount.shoot && (ammo > 0 || !state.rules.unitAmmo)){
float rotation = this.rotation - 90;
//shoot if applicable
@@ -116,11 +119,15 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
if(mount.weapon.mirror) mount.side = !mount.side;
mount.reload = weapon.reload;
}
ammo --;
if(ammo < 0) ammo = 0;
}
}
}
private void shoot(Weapon weapon, float x, float y, float aimX, float aimY, float rotation, int side){
float baseX = this.x, baseY = this.y;
weapon.shootSound.at(x, y, Mathf.random(0.8f, 1.0f));

View File

@@ -38,6 +38,8 @@ public class Rules{
public boolean canGameOver = true;
/** Whether reactors can explode and damage other blocks. */
public boolean reactorExplosions = true;
/** Whether units use and require ammo. */
public boolean unitAmmo = false;
/** How fast unit pads build units. */
public float unitBuildSpeedMultiplier = 1f;
/** How much health units start with. */

View File

@@ -51,6 +51,7 @@ public class UnitType extends UnlockableContent{
public boolean flipBackLegs = true;
public int itemCapacity = 30;
public int ammoCapacity = 100;
public int drillTier = -1;
public float buildSpeed = 1f, mineSpeed = 1f;
@@ -86,6 +87,7 @@ public class UnitType extends UnlockableContent{
Unitc unit = constructor.get();
unit.team(team);
unit.type(this);
unit.ammo(ammoCapacity); //fill up on ammo upon creation
return unit;
}