Merge branch 'remove-ammo' of https://github.com/Anuken/Mindustry
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 308 B |
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 374 B |
Before Width: | Height: | Size: 298 B After Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 423 B After Width: | Height: | Size: 423 B |
BIN
core/assets-raw/sprites/units/power-cell.png
Normal file
After Width: | Height: | Size: 388 B |
Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 327 B |
@ -139,7 +139,6 @@ public class Recipes implements ContentList{
|
||||
new Recipe(units, UnitBlocks.monsoonPad, new ItemStack(Items.plastanium, 80), new ItemStack(Items.titanium, 100), new ItemStack(Items.lead, 130), new ItemStack(Items.silicon, 220)).setMode(GameMode.noWaves);
|
||||
|
||||
new Recipe(units, UnitBlocks.repairPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
|
||||
new Recipe(units, UnitBlocks.resupplyPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
|
||||
new Recipe(units, UnitBlocks.commandCenter, new ItemStack(Items.lead, 100), new ItemStack(Items.carbide, 100), new ItemStack(Items.silicon, 200)).setMode(GameMode.noWaves);
|
||||
|
||||
//LIQUIDS
|
||||
|
@ -19,7 +19,7 @@ public class Weapons implements ContentList{
|
||||
reload = 15f;
|
||||
roundrobin = true;
|
||||
ejectEffect = ShootFx.shellEjectSmall;
|
||||
setAmmo(AmmoTypes.bulletLead);
|
||||
ammo = AmmoTypes.bulletLead;
|
||||
}};
|
||||
|
||||
missiles = new Weapon("missiles"){{
|
||||
@ -30,7 +30,7 @@ public class Weapons implements ContentList{
|
||||
roundrobin = false;
|
||||
roundrobin = true;
|
||||
ejectEffect = Fx.none;
|
||||
setAmmo(AmmoTypes.weaponMissile);
|
||||
ammo = AmmoTypes.weaponMissile;
|
||||
}};
|
||||
|
||||
chainBlaster = new Weapon("chain-blaster"){{
|
||||
@ -38,7 +38,7 @@ public class Weapons implements ContentList{
|
||||
reload = 28f;
|
||||
roundrobin = true;
|
||||
ejectEffect = ShootFx.shellEjectSmall;
|
||||
setAmmo(AmmoTypes.bulletLead, AmmoTypes.bulletCarbide, AmmoTypes.bulletTungsten, AmmoTypes.bulletSilicon, AmmoTypes.bulletThorium);
|
||||
ammo = AmmoTypes.bulletLead;
|
||||
}};
|
||||
|
||||
shockgun = new Weapon("shockgun"){{
|
||||
@ -50,7 +50,7 @@ public class Weapons implements ContentList{
|
||||
recoil = 2f;
|
||||
velocityRnd = 0.7f;
|
||||
ejectEffect = ShootFx.shellEjectSmall;
|
||||
setAmmo(AmmoTypes.shotgunTungsten);
|
||||
ammo = AmmoTypes.shotgunTungsten;
|
||||
}};
|
||||
|
||||
flakgun = new Weapon("flakgun"){{
|
||||
@ -62,7 +62,7 @@ public class Weapons implements ContentList{
|
||||
recoil = 3f;
|
||||
velocityRnd = 0.1f;
|
||||
ejectEffect = ShootFx.shellEjectMedium;
|
||||
setAmmo(AmmoTypes.shellCarbide);
|
||||
ammo = AmmoTypes.shellCarbide;
|
||||
}};
|
||||
|
||||
flamethrower = new Weapon("flamethrower"){{
|
||||
@ -71,7 +71,7 @@ public class Weapons implements ContentList{
|
||||
roundrobin = true;
|
||||
recoil = 1f;
|
||||
ejectEffect = Fx.none;
|
||||
setAmmo(AmmoTypes.flamerThermite);
|
||||
ammo = AmmoTypes.flamerThermite;
|
||||
}};
|
||||
|
||||
sapper = new Weapon("sapper"){{
|
||||
@ -79,7 +79,7 @@ public class Weapons implements ContentList{
|
||||
reload = 12f;
|
||||
roundrobin = true;
|
||||
ejectEffect = ShootFx.shellEjectSmall;
|
||||
setAmmo(AmmoTypes.bulletCarbide);
|
||||
ammo = AmmoTypes.bulletCarbide;
|
||||
}};
|
||||
|
||||
swarmer = new Weapon("swarmer"){{
|
||||
@ -87,7 +87,7 @@ public class Weapons implements ContentList{
|
||||
reload = 10f;
|
||||
roundrobin = true;
|
||||
ejectEffect = ShootFx.shellEjectSmall;
|
||||
setAmmo(AmmoTypes.bulletPyratite);
|
||||
ammo = AmmoTypes.bulletPyratite;
|
||||
}};
|
||||
|
||||
bomber = new Weapon("bomber"){{
|
||||
@ -98,7 +98,7 @@ public class Weapons implements ContentList{
|
||||
ejectEffect = Fx.none;
|
||||
velocityRnd = 1f;
|
||||
inaccuracy = 40f;
|
||||
setAmmo(AmmoTypes.bombExplosive, AmmoTypes.bombIncendiary, AmmoTypes.bombOil);
|
||||
ammo = AmmoTypes.bombExplosive;
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.units.*;
|
||||
|
||||
public class UnitBlocks extends BlockList implements ContentList{
|
||||
public static Block resupplyPoint, repairPoint, dronePad,
|
||||
public static Block repairPoint, dronePad,
|
||||
fabricatorPad, interceptorPad, monsoonPad, daggerPad, titanPad,
|
||||
dropPoint, reconstructor, overdriveProjector, shieldProjector, commandCenter;
|
||||
|
||||
@ -64,11 +64,6 @@ public class UnitBlocks extends BlockList implements ContentList{
|
||||
consumes.items(new ItemStack[]{new ItemStack(Items.silicon, 20), new ItemStack(Items.thorium, 30)});
|
||||
}};
|
||||
|
||||
resupplyPoint = new ResupplyPoint("resupply-point"){{
|
||||
shadow = "shadow-round-1";
|
||||
itemCapacity = 30;
|
||||
}};
|
||||
|
||||
dropPoint = new DropPoint("drop-point"){{
|
||||
shadow = "shadow-round-1";
|
||||
itemCapacity = 40;
|
||||
|
@ -331,8 +331,8 @@ public class Renderer extends RendererModule{
|
||||
|
||||
Graphics.beginShaders(Shaders.outline);
|
||||
Graphics.shader(Shaders.mix, true);
|
||||
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead());
|
||||
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team);
|
||||
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
||||
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll);
|
||||
Graphics.shader();
|
||||
blocks.drawTeamBlocks(Layer.turret, team);
|
||||
Graphics.endShaders();
|
||||
|
@ -129,11 +129,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
return mech.itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmmoCapacity(){
|
||||
return mech.ammoCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interpolate(){
|
||||
super.interpolate();
|
||||
@ -187,21 +182,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
return mech.armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsAmmo(Item item){
|
||||
return mech.weapon.getAmmoType(item) != null && inventory.canAcceptAmmo(mech.weapon.getAmmoType(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void added(){
|
||||
baseRotation = 90f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAmmo(Item item){
|
||||
inventory.addAmmo(mech.weapon.getAmmoType(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMass(){
|
||||
return mech.mass;
|
||||
@ -273,6 +258,23 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
Draw.rect(mech.iconRegion, x , y, rotation - 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAll(){
|
||||
boolean snap = snapCamera && isLocal;
|
||||
|
||||
float px = x, py = y;
|
||||
|
||||
if(snap){
|
||||
x = (int) (x + 0.0001f);
|
||||
y = (int) (y + 0.0001f);
|
||||
}
|
||||
|
||||
super.drawAll();
|
||||
|
||||
x = px;
|
||||
y = py;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if((debug && (!showPlayer || !showUI)) || dead) return;
|
||||
@ -284,15 +286,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
|
||||
boostHeat = Mathf.lerpDelta(boostHeat, isBoosting && ((!movement.isZero() && moved) || !isLocal) ? 1f : 0f, 0.08f);
|
||||
|
||||
boolean snap = snapCamera && isLocal;
|
||||
|
||||
float px = x, py = y;
|
||||
|
||||
if(snap){
|
||||
x = (int) (x + 0.0001f);
|
||||
y = (int) (y + 0.0001f);
|
||||
}
|
||||
|
||||
float ft = Mathf.sin(walktime, 6f, 2f) * (1f - boostHeat);
|
||||
|
||||
Floor floor = getFloorOn();
|
||||
@ -351,9 +344,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
Draw.alpha(1f);
|
||||
|
||||
x = px;
|
||||
y = py;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -620,20 +610,20 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
y += Mathf.cos(Timers.time() + id * 999, 25f, 0.08f);
|
||||
|
||||
//update shooting if not building, not mining and there's ammo left
|
||||
if(!isBuilding() && inventory.hasAmmo() && getMineTile() == null){
|
||||
if(!isBuilding() && getMineTile() == null){
|
||||
|
||||
//autofire: mobile only!
|
||||
if(mobile){
|
||||
|
||||
if(target == null){
|
||||
isShooting = false;
|
||||
target = Units.getClosestTarget(team, x, y, inventory.getAmmoRange());
|
||||
target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().getRange());
|
||||
}else if(target.isValid()){
|
||||
//rotate toward and shoot the target
|
||||
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f);
|
||||
|
||||
Vector2 intercept =
|
||||
Predict.intercept(x, y, target.getX(), target.getY(), target.getVelocity().x - velocity.x, target.getVelocity().y - velocity.y, inventory.getAmmo().bullet.speed);
|
||||
Predict.intercept(x, y, target.getX(), target.getY(), target.getVelocity().x - velocity.x, target.getVelocity().y - velocity.y, getWeapon().getAmmo().bullet.speed);
|
||||
|
||||
pointerX = intercept.x;
|
||||
pointerY = intercept.y;
|
||||
@ -677,7 +667,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
public boolean isShooting(){
|
||||
return isShooting && inventory.hasAmmo() && (!isBoosting || mech.flying);
|
||||
return isShooting && (!isBoosting || mech.flying);
|
||||
}
|
||||
|
||||
public void updateRespawning(){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
@ -8,8 +9,8 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.net.Interpolator;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
@ -294,16 +295,30 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
}
|
||||
|
||||
public float getAmmoFraction(){
|
||||
return inventory.totalAmmo() / (float) inventory.ammoCapacity();
|
||||
}
|
||||
|
||||
public void drawUnder(){
|
||||
}
|
||||
|
||||
public void drawOver(){
|
||||
}
|
||||
|
||||
public void drawStats(){
|
||||
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Timers.time(), 1f+healthf()*5f, 1f - healthf()));
|
||||
Draw.alpha(hitTime);
|
||||
Draw.rect(getPowerCellRegion(), x, y, rotation - 90);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public TextureRegion getPowerCellRegion(){
|
||||
return Draw.region("power-cell");
|
||||
}
|
||||
|
||||
public void drawAll(){
|
||||
if(!isDead()){
|
||||
draw();
|
||||
drawStats();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawShadow(){
|
||||
Draw.rect(getIconRegion(), x , y, rotation - 90);
|
||||
}
|
||||
@ -312,26 +327,18 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
Fill.circle(x, y, getViewDistance());
|
||||
}
|
||||
|
||||
public boolean isInfiniteAmmo(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getViewDistance(){
|
||||
return 135f;
|
||||
}
|
||||
|
||||
public abstract TextureRegion getIconRegion();
|
||||
|
||||
public abstract Weapon getWeapon();
|
||||
|
||||
public abstract int getItemCapacity();
|
||||
|
||||
public abstract int getAmmoCapacity();
|
||||
|
||||
public abstract float getArmor();
|
||||
|
||||
public abstract boolean acceptsAmmo(Item item);
|
||||
|
||||
public abstract void addAmmo(Item item);
|
||||
|
||||
public abstract float getMass();
|
||||
|
||||
public abstract boolean isFlying();
|
||||
|
@ -1,10 +1,7 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.entities.traits.Saveable;
|
||||
import io.anuke.mindustry.type.AmmoEntry;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
|
||||
@ -14,8 +11,6 @@ import java.io.IOException;
|
||||
|
||||
public class UnitInventory implements Saveable{
|
||||
private final Unit unit;
|
||||
private Array<AmmoEntry> ammos = new Array<>();
|
||||
private int totalAmmo;
|
||||
private ItemStack item = new ItemStack(Items.stone, 0);
|
||||
|
||||
public UnitInventory(Unit unit){
|
||||
@ -30,90 +25,19 @@ public class UnitInventory implements Saveable{
|
||||
public void writeSave(DataOutput stream) throws IOException{
|
||||
stream.writeShort(item.amount);
|
||||
stream.writeByte(item.item.id);
|
||||
stream.writeShort(totalAmmo);
|
||||
stream.writeByte(ammos.size);
|
||||
for(int i = 0; i < ammos.size; i++){
|
||||
stream.writeByte(ammos.get(i).type.id);
|
||||
stream.writeShort(ammos.get(i).amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSave(DataInput stream) throws IOException{
|
||||
short iamount = stream.readShort();
|
||||
byte iid = stream.readByte();
|
||||
this.totalAmmo = stream.readShort();
|
||||
byte ammoa = stream.readByte();
|
||||
for(int i = 0; i < ammoa; i++){
|
||||
byte aid = stream.readByte();
|
||||
int am = stream.readShort();
|
||||
ammos.add(new AmmoEntry(AmmoType.getByID(aid), am));
|
||||
}
|
||||
|
||||
item.item = Item.getByID(iid);
|
||||
item.amount = iamount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns ammo range, or MAX_VALUE if this inventory has no ammo.
|
||||
*/
|
||||
public float getAmmoRange(){
|
||||
return hasAmmo() ? getAmmo().getRange() : Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
public AmmoType getAmmo(){
|
||||
return ammos.size == 0 ? null : ammos.peek().type;
|
||||
}
|
||||
|
||||
public boolean hasAmmo(){
|
||||
return totalAmmo > 0;
|
||||
}
|
||||
|
||||
public void useAmmo(){
|
||||
if(unit.isInfiniteAmmo()) return;
|
||||
AmmoEntry entry = ammos.peek();
|
||||
entry.amount--;
|
||||
if(entry.amount == 0) ammos.pop();
|
||||
totalAmmo--;
|
||||
}
|
||||
|
||||
public int totalAmmo(){
|
||||
return totalAmmo;
|
||||
}
|
||||
|
||||
public int ammoCapacity(){
|
||||
return unit.getAmmoCapacity();
|
||||
}
|
||||
|
||||
public boolean canAcceptAmmo(AmmoType type){
|
||||
return totalAmmo + type.quantityMultiplier <= unit.getAmmoCapacity();
|
||||
}
|
||||
|
||||
public void addAmmo(AmmoType type){
|
||||
if(type == null) return;
|
||||
totalAmmo += type.quantityMultiplier;
|
||||
|
||||
//find ammo entry by type
|
||||
for(int i = ammos.size - 1; i >= 0; i--){
|
||||
AmmoEntry entry = ammos.get(i);
|
||||
|
||||
//if found, put it to the right
|
||||
if(entry.type == type){
|
||||
entry.amount += type.quantityMultiplier;
|
||||
ammos.swap(i, ammos.size - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//must not be found
|
||||
AmmoEntry entry = new AmmoEntry(type, (int) type.quantityMultiplier);
|
||||
ammos.add(entry);
|
||||
}
|
||||
|
||||
public void fillAmmo(AmmoType type){
|
||||
totalAmmo = ammoCapacity();
|
||||
ammos.clear();
|
||||
ammos.add(new AmmoEntry(type, ammoCapacity()));
|
||||
public void clear(){
|
||||
item.amount = 0;
|
||||
}
|
||||
|
||||
public int capacity(){
|
||||
@ -140,12 +64,6 @@ public class UnitInventory implements Saveable{
|
||||
return (!hasItem() && amount <= unit.getItemCapacity()) || (item.item == type && item.amount + amount <= unit.getItemCapacity());
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
item.amount = 0;
|
||||
ammos.clear();
|
||||
totalAmmo = 0;
|
||||
}
|
||||
|
||||
public void clearItem(){
|
||||
item.amount = 0;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class Units{
|
||||
* See {@link #invalidateTarget(TargetTrait, Team, float, float, float)}
|
||||
*/
|
||||
public static boolean invalidateTarget(TargetTrait target, Unit targeter){
|
||||
return invalidateTarget(target, targeter.team, targeter.x, targeter.y, targeter.inventory.getAmmoRange());
|
||||
return invalidateTarget(target, targeter.team, targeter.x, targeter.y, targeter.getWeapon().getAmmo().getRange());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,14 +34,6 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
public ItemTransfer(){
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void transferAmmo(Item item, float x, float y, Unit to){
|
||||
if(to == null) return;
|
||||
to.addAmmo(item);
|
||||
create(item, x, y, to, () -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void transferItemEffect(Item item, float x, float y, Unit to){
|
||||
if(to == null) return;
|
||||
|
@ -19,7 +19,6 @@ import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@ -185,7 +184,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
public void targetClosest(){
|
||||
target = Units.getClosestTarget(team, x, y, inventory.getAmmoRange());
|
||||
target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().getRange());
|
||||
}
|
||||
|
||||
public TileEntity getClosestEnemyCore(){
|
||||
@ -253,16 +252,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
return type.itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmmoCapacity(){
|
||||
return type.ammoCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfiniteAmmo(){
|
||||
return isWave;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interpolate(){
|
||||
super.interpolate();
|
||||
@ -282,16 +271,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
return type.armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsAmmo(Item item){
|
||||
return getWeapon().getAmmoType(item) != null && inventory.canAcceptAmmo(getWeapon().getAmmoType(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAmmo(Item item){
|
||||
inventory.addAmmo(getWeapon().getAmmoType(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSize(){
|
||||
return 8;
|
||||
|
@ -28,22 +28,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
protected CarriableTrait carrying;
|
||||
protected final UnitState
|
||||
|
||||
resupply = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(inventory.totalAmmo() + 10 >= inventory.ammoCapacity()){
|
||||
state.set(attack);
|
||||
}else if(!targetHasFlag(BlockFlag.resupplyPoint)){
|
||||
retarget(() -> targetClosestAllyFlag(BlockFlag.resupplyPoint));
|
||||
}else{
|
||||
circle(20f);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
idle = new UnitState(){
|
||||
public void update(){
|
||||
if(!isCommanded()){
|
||||
@ -75,9 +59,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
target = null;
|
||||
}
|
||||
|
||||
if(!inventory.hasAmmo()){
|
||||
state.set(resupply);
|
||||
}else if(target == null){
|
||||
if(target == null){
|
||||
retarget(() -> {
|
||||
targetClosest();
|
||||
if(target == null) targetClosestEnemyFlag(BlockFlag.target);
|
||||
@ -91,10 +73,9 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
}else{
|
||||
attack(150f);
|
||||
|
||||
if((Mathf.angNear(angleTo(target), rotation, 15f) || !inventory.getAmmo().bullet.keepVelocity) //bombers don't care about rotation
|
||||
&& distanceTo(target) < inventory.getAmmo().getRange()){
|
||||
AmmoType ammo = inventory.getAmmo();
|
||||
inventory.useAmmo();
|
||||
if((Mathf.angNear(angleTo(target), rotation, 15f) || !getWeapon().getAmmo().bullet.keepVelocity) //bombers don't care about rotation
|
||||
&& distanceTo(target) < getWeapon().getAmmo().getRange()){
|
||||
AmmoType ammo = getWeapon().getAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.bullet.speed);
|
||||
|
||||
|
@ -12,11 +12,9 @@ import io.anuke.mindustry.type.Upgrade;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
@ -35,24 +33,6 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
|
||||
public final UnitState
|
||||
|
||||
resupply = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
Tile tile = Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.resupplyPoint));
|
||||
|
||||
if(tile != null && distanceTo(tile) > 40){
|
||||
moveAwayFromCore();
|
||||
}
|
||||
|
||||
//TODO move toward resupply point
|
||||
if(isWave || inventory.totalAmmo() + 10 >= inventory.ammoCapacity()){
|
||||
state.set(attack);
|
||||
}
|
||||
}
|
||||
},
|
||||
attack = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
@ -62,17 +42,15 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
TileEntity core = getClosestEnemyCore();
|
||||
float dst = core == null ? 0 : distanceTo(core);
|
||||
|
||||
if(core != null && inventory.hasAmmo() && dst < inventory.getAmmo().getRange() / 1.1f){
|
||||
if(core != null && dst < getWeapon().getAmmo().getRange() / 1.1f){
|
||||
target = core;
|
||||
}else{
|
||||
retarget(() -> targetClosest());
|
||||
}
|
||||
|
||||
if(!inventory.hasAmmo()){
|
||||
state.set(resupply);
|
||||
}else if(target != null){
|
||||
if(target != null){
|
||||
if(core != null){
|
||||
if(dst > inventory.getAmmo().getRange() * 0.5f){
|
||||
if(dst > getWeapon().getAmmo().getRange() * 0.5f){
|
||||
moveToCore();
|
||||
}
|
||||
|
||||
@ -80,11 +58,11 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
moveToCore();
|
||||
}
|
||||
|
||||
if(distanceTo(target) < inventory.getAmmo().getRange()){
|
||||
if(distanceTo(target) < getWeapon().getAmmo().getRange()){
|
||||
rotate(angleTo(target));
|
||||
|
||||
if(Mathf.angNear(angleTo(target), rotation, 13f)){
|
||||
AmmoType ammo = inventory.getAmmo();
|
||||
AmmoType ammo = getWeapon().getAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.bullet.speed);
|
||||
|
||||
@ -143,14 +121,14 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
|
||||
@Override
|
||||
public UnitState getStartState(){
|
||||
return resupply;
|
||||
return attack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
super.update();
|
||||
|
||||
if(!velocity.isZero(0.0001f) && (target == null || !inventory.hasAmmo() || (inventory.hasAmmo() && distanceTo(target) > inventory.getAmmoRange()))){
|
||||
if(!velocity.isZero(0.0001f) && (target == null || (distanceTo(target) > getWeapon().getAmmo().getRange()))){
|
||||
rotation = Mathf.slerpDelta(rotation, velocity.angle(), 0.2f);
|
||||
}
|
||||
}
|
||||
|
@ -395,11 +395,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
return isBuilding() ? placeDistance * 2f : 30f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAmmoFraction(){
|
||||
return inventory.getItem().amount / (float) type.itemCapacity;
|
||||
}
|
||||
|
||||
protected void findItem(){
|
||||
TileEntity entity = getClosestCore();
|
||||
if(entity == null){
|
||||
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.game;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.GroundUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
@ -62,10 +61,6 @@ public class SpawnGroup{
|
||||
* Items this unit spawns with. Null to disable.
|
||||
*/
|
||||
protected ItemStack items;
|
||||
/**
|
||||
* Ammo type this unit spawns with. Null to use the first available ammo.
|
||||
*/
|
||||
protected Item ammoItem;
|
||||
|
||||
public SpawnGroup(UnitType type){
|
||||
this.type = type;
|
||||
@ -114,12 +109,6 @@ public class SpawnGroup{
|
||||
unit.inventory.addItem(items.item, items.amount);
|
||||
}
|
||||
|
||||
if(ammoItem != null){
|
||||
unit.inventory.addAmmo(unit.getWeapon().getAmmoType(ammoItem));
|
||||
}else{
|
||||
unit.inventory.addAmmo(unit.getWeapon().getAmmoType(unit.getWeapon().getAcceptedItems().iterator().next()));
|
||||
}
|
||||
|
||||
return unit;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ public class Waves{
|
||||
unitScaling = 2;
|
||||
unitAmount = 1;
|
||||
spacing = 2;
|
||||
ammoItem = Items.tungsten;
|
||||
end = 30;
|
||||
}},
|
||||
|
||||
@ -86,7 +85,6 @@ public class Waves{
|
||||
groupAmount = 2;
|
||||
unitScaling = 3;
|
||||
effect = StatusEffects.overdrive;
|
||||
ammoItem = Items.silicon;
|
||||
}},
|
||||
|
||||
new SpawnGroup(UnitTypes.dagger){{
|
||||
@ -95,7 +93,6 @@ public class Waves{
|
||||
unitAmount = 1;
|
||||
unitScaling = 3;
|
||||
effect = StatusEffects.shielded;
|
||||
ammoItem = Items.thorium;
|
||||
max = 10;
|
||||
}},
|
||||
|
||||
@ -121,7 +118,6 @@ public class Waves{
|
||||
|
||||
new SpawnGroup(UnitTypes.monsoon){{
|
||||
begin = 40;
|
||||
ammoItem = Items.blastCompound;
|
||||
unitAmount = 2;
|
||||
spacing = 2;
|
||||
unitScaling = 3;
|
||||
@ -140,7 +136,6 @@ public class Waves{
|
||||
|
||||
new SpawnGroup(UnitTypes.monsoon){{
|
||||
begin = 53;
|
||||
ammoItem = Items.pyratite;
|
||||
unitAmount = 2;
|
||||
unitScaling = 3;
|
||||
spacing = 4;
|
||||
@ -150,7 +145,6 @@ public class Waves{
|
||||
|
||||
new SpawnGroup(UnitTypes.monsoon){{
|
||||
begin = 53;
|
||||
ammoItem = Items.coal;
|
||||
unitAmount = 2;
|
||||
unitScaling = 3;
|
||||
spacing = 4;
|
||||
@ -176,10 +170,6 @@ public class Waves{
|
||||
System.out.print(":" + spawn.weapon.name);
|
||||
}
|
||||
|
||||
if(spawn.ammoItem != null){
|
||||
System.out.print(":" + spawn.ammoItem.name);
|
||||
}
|
||||
|
||||
System.out.print(" ");
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,11 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockBar;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
@ -176,32 +173,7 @@ public class OverlayRenderer{
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if((!debug || showUI) && Settings.getBool("healthbars")){
|
||||
for(TeamData ally : (debug ? state.teams.getTeams() : state.teams.getTeams(true))){
|
||||
renderer.drawAndInterpolate(unitGroups[ally.team.ordinal()], u -> !u.isDead(), this::drawStats);
|
||||
}
|
||||
|
||||
renderer.drawAndInterpolate(playerGroup, u -> !u.isDead(), this::drawStats);
|
||||
}
|
||||
}
|
||||
|
||||
void drawStats(Unit unit){
|
||||
if(unit.isDead()) return;
|
||||
|
||||
float x = unit.x;
|
||||
float y = unit.y;
|
||||
|
||||
if(unit == players[0] && players.length == 1 && snapCamera){
|
||||
x = (int) (x + 0.0001f);
|
||||
y = (int) (y + 0.0001f);
|
||||
}
|
||||
|
||||
drawEncloser(x, y - 9f, 2f);
|
||||
drawBar(Palette.healthstats, x, y - 8f, unit.healthf());
|
||||
drawBar(Palette.ammo, x, y - 9f, unit.getAmmoFraction());
|
||||
}
|
||||
|
||||
void drawBar(Color color, float x, float y, float finion){
|
||||
|
@ -3,70 +3,72 @@ package io.anuke.mindustry.graphics;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
public class Palette{
|
||||
public static final Color command = Color.valueOf("eab678");
|
||||
public static final Color
|
||||
|
||||
public static final Color bulletYellow = Color.valueOf("ffeec9");
|
||||
public static final Color bulletYellowBack = Color.valueOf("f9c87a");
|
||||
command = Color.valueOf("eab678"),
|
||||
|
||||
public static final Color missileYellow = Color.valueOf("ffd2ae");
|
||||
public static final Color missileYellowBack = Color.valueOf("e58956");
|
||||
bulletYellow = Color.valueOf("ffeec9"),
|
||||
bulletYellowBack = Color.valueOf("f9c87a"),
|
||||
|
||||
public static final Color plastaniumBack = Color.valueOf("d8d97f");
|
||||
public static final Color plastaniumFront = Color.valueOf("fffac6");
|
||||
missileYellow = Color.valueOf("ffd2ae"),
|
||||
missileYellowBack = Color.valueOf("e58956"),
|
||||
|
||||
public static final Color lightFlame = Color.valueOf("ffdd55");
|
||||
public static final Color darkFlame = Color.valueOf("db401c");
|
||||
plastaniumBack = Color.valueOf("d8d97f"),
|
||||
plastaniumFront = Color.valueOf("fffac6"),
|
||||
|
||||
public static final Color turretHeat = Color.valueOf("ab3400");
|
||||
lightFlame = Color.valueOf("ffdd55"),
|
||||
darkFlame = Color.valueOf("db401c"),
|
||||
|
||||
public static final Color lightOrange = Color.valueOf("f68021");
|
||||
public static final Color lightishOrange = Color.valueOf("f8ad42");
|
||||
public static final Color lighterOrange = Color.valueOf("f6e096");
|
||||
turretHeat = Color.valueOf("ab3400"),
|
||||
|
||||
public static final Color lightishGray = Color.valueOf("a2a2a2");
|
||||
public static final Color darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f);
|
||||
lightOrange = Color.valueOf("f68021"),
|
||||
lightishOrange = Color.valueOf("f8ad42"),
|
||||
lighterOrange = Color.valueOf("f6e096"),
|
||||
|
||||
public static final Color lancerLaser = Color.valueOf("a9d8ff");
|
||||
lightishGray = Color.valueOf("a2a2a2"),
|
||||
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
|
||||
|
||||
public static final Color stoneGray = Color.valueOf("8f8f8f");
|
||||
lancerLaser = Color.valueOf("a9d8ff"),
|
||||
|
||||
public static final Color portalLight = Color.valueOf("9054ea");
|
||||
public static final Color portal = Color.valueOf("6344d7");
|
||||
public static final Color portalDark = Color.valueOf("3f3dac");
|
||||
stoneGray = Color.valueOf("8f8f8f"),
|
||||
|
||||
public static final Color powerLaserFrom = Color.valueOf("e3e3e3");
|
||||
public static final Color powerLaserTo = Color.valueOf("ffe7a8");
|
||||
portalLight = Color.valueOf("9054ea"),
|
||||
portal = Color.valueOf("6344d7"),
|
||||
portalDark = Color.valueOf("3f3dac"),
|
||||
|
||||
public static final Color description = Color.WHITE;
|
||||
public static final Color turretinfo = Color.ORANGE;
|
||||
public static final Color iteminfo = Color.LIGHT_GRAY;
|
||||
public static final Color powerinfo = Color.YELLOW;
|
||||
public static final Color liquidinfo = Color.ROYAL;
|
||||
public static final Color craftinfo = Color.LIGHT_GRAY;
|
||||
powerLaserFrom = Color.valueOf("e3e3e3"),
|
||||
powerLaserTo = Color.valueOf("ffe7a8"),
|
||||
|
||||
public static final Color missingitems = Color.SCARLET;
|
||||
public static final Color health = Color.YELLOW;
|
||||
public static final Color ammo = Color.valueOf("32cf6d");
|
||||
public static final Color healthstats = Color.SCARLET;
|
||||
public static final Color bar = Color.SLATE;
|
||||
public static final Color interact = Color.ORANGE;
|
||||
public static final Color accent = Color.valueOf("f4ba6e");
|
||||
public static final Color place = Color.valueOf("6335f8");
|
||||
public static final Color remove = Color.valueOf("e55454");
|
||||
public static final Color placeRotate = accent;
|
||||
public static final Color breakInvalid = Color.valueOf("d44b3d");
|
||||
public static final Color range = Color.valueOf("f4ba6e");
|
||||
public static final Color power = Color.valueOf("fbd367");
|
||||
public static final Color placing = Color.valueOf("616161");
|
||||
description = Color.WHITE,
|
||||
turretinfo = Color.ORANGE,
|
||||
iteminfo = Color.LIGHT_GRAY,
|
||||
powerinfo = Color.YELLOW,
|
||||
liquidinfo = Color.ROYAL,
|
||||
craftinfo = Color.LIGHT_GRAY,
|
||||
|
||||
public static final Color lightTrail = Color.valueOf("ffe2a9");
|
||||
missingitems = Color.SCARLET,
|
||||
health = Color.YELLOW,
|
||||
ammo = Color.valueOf("32cf6d"),
|
||||
healthstats = Color.SCARLET,
|
||||
bar = Color.SLATE,
|
||||
interact = Color.ORANGE,
|
||||
accent = Color.valueOf("f4ba6e"),
|
||||
place = Color.valueOf("6335f8"),
|
||||
remove = Color.valueOf("e55454"),
|
||||
placeRotate = accent,
|
||||
breakInvalid = Color.valueOf("d44b3d"),
|
||||
range = Color.valueOf("f4ba6e"),
|
||||
power = Color.valueOf("fbd367"),
|
||||
placing = Color.valueOf("616161"),
|
||||
|
||||
public static final Color redSpark = Color.valueOf("fbb97f");
|
||||
public static final Color orangeSpark = Color.valueOf("d2b29c");
|
||||
lightTrail = Color.valueOf("ffe2a9"),
|
||||
|
||||
public static final Color redDust = Color.valueOf("ffa480");
|
||||
public static final Color redderDust = Color.valueOf("ff7b69");
|
||||
redSpark = Color.valueOf("fbb97f"),
|
||||
orangeSpark = Color.valueOf("d2b29c"),
|
||||
|
||||
public static final Color plasticSmoke = Color.valueOf("f1e479");
|
||||
public static final Color plasticBurn = Color.valueOf("e9ead3");
|
||||
redDust = Color.valueOf("ffa480"),
|
||||
redderDust = Color.valueOf("ff7b69"),
|
||||
|
||||
plasticSmoke = Color.valueOf("f1e479"),
|
||||
plasticBurn = Color.valueOf("e9ead3");
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.ItemTurret;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.PowerTurret;
|
||||
import io.anuke.mindustry.world.blocks.units.ResupplyPoint;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
@ -186,7 +185,6 @@ public class FortressGenerator{
|
||||
}
|
||||
|
||||
Block fixBlock(Block result){
|
||||
if(result == UnitBlocks.resupplyPoint) result = DefenseBlocks.tungstenWall;
|
||||
if(result == UnitBlocks.dronePad) result = DefenseBlocks.tungstenWallLarge;
|
||||
if(result == UnitBlocks.fabricatorPad) result = DefenseBlocks.tungstenWallLarge;
|
||||
return result;
|
||||
@ -201,8 +199,6 @@ public class FortressGenerator{
|
||||
ItemTurret turret = (ItemTurret)block;
|
||||
AmmoType[] type = turret.getAmmoTypes();
|
||||
block.handleStack(type[0].item, block.acceptStack(type[0].item, 1000, tile, null), tile, null);
|
||||
}else if(block instanceof ResupplyPoint){
|
||||
tile.entity.items.add(Items.lead, tile.block().itemCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.type;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@ -19,64 +18,37 @@ import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
public class Weapon extends Upgrade{
|
||||
/**
|
||||
* minimum cursor distance from player, fixes 'cross-eyed' shooting.
|
||||
*/
|
||||
/**minimum cursor distance from player, fixes 'cross-eyed' shooting.*/
|
||||
protected static float minPlayerDist = 20f;
|
||||
public TextureRegion equipRegion, region;
|
||||
/**
|
||||
* ammo type map. set with setAmmo()
|
||||
*/
|
||||
protected OrderedMap<Item, AmmoType> ammoMap = new OrderedMap<>();
|
||||
/**
|
||||
* shell ejection effect
|
||||
*/
|
||||
/**ammo type map. set with setAmmo()*/
|
||||
protected AmmoType ammo;
|
||||
/**shell ejection effect*/
|
||||
protected Effect ejectEffect = Fx.none;
|
||||
/**
|
||||
* weapon reload in frames
|
||||
*/
|
||||
/**weapon reload in frames*/
|
||||
protected float reload;
|
||||
/**
|
||||
* amount of shots per fire
|
||||
*/
|
||||
/**amount of shots per fire*/
|
||||
protected int shots = 1;
|
||||
/**
|
||||
* spacing in degrees between multiple shots, if applicable
|
||||
*/
|
||||
/**spacing in degrees between multiple shots, if applicable*/
|
||||
protected float spacing = 12f;
|
||||
/**
|
||||
* inaccuracy of degrees of each shot
|
||||
*/
|
||||
/**inaccuracy of degrees of each shot*/
|
||||
protected float inaccuracy = 0f;
|
||||
/**
|
||||
* intensity and duration of each shot's screen shake
|
||||
*/
|
||||
/**intensity and duration of each shot's screen shake*/
|
||||
protected float shake = 0f;
|
||||
/**
|
||||
* visual weapon knockback.
|
||||
*/
|
||||
/**visual weapon knockback.*/
|
||||
protected float recoil = 1.5f;
|
||||
/**
|
||||
* shoot barrel y offset
|
||||
*/
|
||||
/**shoot barrel y offset*/
|
||||
protected float length = 3f;
|
||||
/**
|
||||
* shoot barrel x offset.
|
||||
*/
|
||||
/**shoot barrel x offset.*/
|
||||
protected float width = 4f;
|
||||
/**
|
||||
* fraction of velocity that is random
|
||||
*/
|
||||
/**fraction of velocity that is random*/
|
||||
protected float velocityRnd = 0f;
|
||||
/**
|
||||
* whether to shoot the weapons in different arms one after another, rather than all at once
|
||||
*/
|
||||
/**whether to shoot the weapons in different arms one after another, rather than all at once*/
|
||||
protected boolean roundrobin = false;
|
||||
/**
|
||||
* translator for vector calulations
|
||||
*/
|
||||
/**translator for vector calulations*/
|
||||
protected Translator tr = new Translator();
|
||||
|
||||
public TextureRegion equipRegion, region;
|
||||
|
||||
protected Weapon(String name){
|
||||
super(name);
|
||||
}
|
||||
@ -103,12 +75,9 @@ public class Weapon extends Upgrade{
|
||||
Weapon weapon = shooter.getWeapon();
|
||||
|
||||
Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> weapon.bullet(shooter, x, y, f + Mathf.range(weapon.inaccuracy)));
|
||||
AmmoType ammo = weapon.ammo;
|
||||
|
||||
AmmoType type = shooter.getInventory().getAmmo();
|
||||
|
||||
if(type == null) return;
|
||||
|
||||
weapon.tr.trns(rotation + 180f, type.recoil);
|
||||
weapon.tr.trns(rotation + 180f, ammo.recoil);
|
||||
|
||||
shooter.getVelocity().add(weapon.tr);
|
||||
|
||||
@ -116,8 +85,8 @@ public class Weapon extends Upgrade{
|
||||
|
||||
Effects.shake(weapon.shake, weapon.shake, x, y);
|
||||
Effects.effect(weapon.ejectEffect, x, y, rotation * -Mathf.sign(left));
|
||||
Effects.effect(type.shootEffect, x + weapon.tr.x, y + weapon.tr.y, rotation, shooter);
|
||||
Effects.effect(type.smokeEffect, x + weapon.tr.x, y + weapon.tr.y, rotation, shooter);
|
||||
Effects.effect(ammo.shootEffect, x + weapon.tr.x, y + weapon.tr.y, rotation, shooter);
|
||||
Effects.effect(ammo.smokeEffect, x + weapon.tr.x, y + weapon.tr.y, rotation, shooter);
|
||||
|
||||
//reset timer for remote players
|
||||
shooter.getTimer().get(shooter.getShootTimer(left), weapon.reload);
|
||||
@ -134,13 +103,17 @@ public class Weapon extends Upgrade{
|
||||
return "weapon";
|
||||
}
|
||||
|
||||
public AmmoType getAmmo(){
|
||||
return ammo;
|
||||
}
|
||||
|
||||
public void update(ShooterTrait shooter, float pointerX, float pointerY){
|
||||
update(shooter, true, pointerX, pointerY);
|
||||
update(shooter, false, pointerX, pointerY);
|
||||
}
|
||||
|
||||
private void update(ShooterTrait shooter, boolean left, float pointerX, float pointerY){
|
||||
if(shooter.getInventory().hasAmmo() && shooter.getTimer().get(shooter.getShootTimer(left), reload)){
|
||||
if(shooter.getTimer().get(shooter.getShootTimer(left), reload)){
|
||||
if(roundrobin){
|
||||
shooter.getTimer().reset(shooter.getShootTimer(!left), reload / 2f);
|
||||
}
|
||||
@ -180,29 +153,13 @@ public class Weapon extends Upgrade{
|
||||
Call.onGenericShootWeapon(p, x, y, angle, left);
|
||||
}
|
||||
}
|
||||
|
||||
p.getInventory().useAmmo();
|
||||
}
|
||||
|
||||
public Iterable<Item> getAcceptedItems(){
|
||||
return ammoMap.orderedKeys();
|
||||
}
|
||||
|
||||
public AmmoType getAmmoType(Item item){
|
||||
return ammoMap.get(item);
|
||||
}
|
||||
|
||||
protected void setAmmo(AmmoType... types){
|
||||
for(AmmoType type : types){
|
||||
ammoMap.put(type.item, type);
|
||||
}
|
||||
}
|
||||
|
||||
void bullet(ShooterTrait owner, float x, float y, float angle){
|
||||
if(owner == null || !owner.getInventory().hasAmmo()) return;
|
||||
if(owner == null) return;
|
||||
|
||||
tr.trns(angle, 3f);
|
||||
Bullet.create(owner.getInventory().getAmmo().bullet,
|
||||
Bullet.create(ammo.bullet,
|
||||
owner, owner.getTeam(), x + tr.x, y + tr.y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd));
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,6 @@ public class DebugFragment extends Fragment{
|
||||
for(UnitType type : UnitType.all()){
|
||||
dialog.content().addImageButton("white", 40, () -> {
|
||||
BaseUnit unit = type.create(player.getTeam());
|
||||
unit.inventory.addAmmo(type.weapon.getAmmoType(type.weapon.getAcceptedItems().iterator().next()));
|
||||
unit.setWave();
|
||||
unit.set(player.x, player.y);
|
||||
unit.add();
|
||||
|
@ -235,25 +235,6 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
|
||||
}
|
||||
|
||||
if(entity.solid && tile.entity.timer.get(timerSupply, supplyInterval)){
|
||||
rect.setSize(supplyRadius * 2).setCenter(tile.drawx(), tile.drawy());
|
||||
|
||||
Units.getNearby(tile.getTeam(), rect, unit -> {
|
||||
if(unit.isDead() || unit.distanceTo(tile.drawx(), tile.drawy()) > supplyRadius || unit.getGroup() == null)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < Item.all().size; i++){
|
||||
Item item = Item.getByID(i);
|
||||
if(tile.entity.items.get(item) > 0 && unit.acceptsAmmo(item)){
|
||||
tile.entity.items.remove(item, 1);
|
||||
unit.addAmmo(item);
|
||||
Call.transferAmmo(item, tile.drawx(), tile.drawy(), unit);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -261,19 +242,6 @@ public class CoreBlock extends StorageBlock{
|
||||
return new CoreEntity();
|
||||
}
|
||||
|
||||
/*
|
||||
@Remote(called = Loc.server)
|
||||
public static void onCoreUnitSet(Tile tile, Unit player){
|
||||
CoreEntity entity = tile.entity();
|
||||
entity.currentUnit = player;
|
||||
entity.progress = 0f;
|
||||
player.set(tile.drawx(), tile.drawy());
|
||||
|
||||
if(player instanceof Player){
|
||||
((Player) player).setRespawning(true);
|
||||
}
|
||||
}
|
||||
*/
|
||||
public class CoreEntity extends TileEntity implements SpawnerTrait{
|
||||
public Unit currentUnit;
|
||||
int droneID = -1;
|
||||
|
@ -1,144 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.units;
|
||||
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.graphics.Shapes;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.EnumSet;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class ResupplyPoint extends Block{
|
||||
private static Rectangle rect = new Rectangle();
|
||||
|
||||
protected int timerSupply = timers++;
|
||||
protected int timerTarget = timers++;
|
||||
|
||||
protected float supplyRadius = 50f;
|
||||
protected float supplyInterval = 10f;
|
||||
|
||||
public ResupplyPoint(String name){
|
||||
super(name);
|
||||
update = true;
|
||||
solid = true;
|
||||
flags = EnumSet.of(BlockFlag.resupplyPoint);
|
||||
layer = Layer.laser;
|
||||
hasItems = true;
|
||||
hasPower = true;
|
||||
powerCapacity = 20f;
|
||||
|
||||
consumes.power(0.02f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
Draw.color(Palette.accent);
|
||||
Lines.dashCircle(tile.drawx(), tile.drawy(), supplyRadius);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Tile tile){
|
||||
ResupplyPointEntity entity = tile.entity();
|
||||
|
||||
if(entity.strength > 0f){
|
||||
float ang = entity.angleTo(entity.lastx, entity.lasty);
|
||||
float len = 5f;
|
||||
float x1 = tile.drawx() + Angles.trnsx(ang, len), y1 = tile.drawy() + Angles.trnsy(ang, len);
|
||||
float dstTo = Vector2.dst(x1, y1, entity.lastx, entity.lasty);
|
||||
float space = 4f;
|
||||
|
||||
float xf = entity.lastx - x1, yf = entity.lasty - y1;
|
||||
|
||||
Shapes.laser("transfer", "transfer-end",
|
||||
x1, y1, entity.lastx, entity.lasty, entity.strength);
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
for(int i = 0; i < dstTo / space - 1; i++){
|
||||
float fract = (i * space) / dstTo + ((Timers.time() / 90f) % (space / dstTo));
|
||||
Draw.alpha(Mathf.clamp(fract * 1.5f));
|
||||
Draw.rect("transfer-arrow", x1 + fract * xf, y1 + fract * yf,
|
||||
8, 8 * entity.strength, ang);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
ResupplyPointEntity entity = tile.entity();
|
||||
|
||||
if(!validTarget(entity, entity.target) || entity.target.distanceTo(tile) > supplyRadius){
|
||||
entity.target = null;
|
||||
}else if(entity.target != null && entity.strength > 0.5f){
|
||||
|
||||
if(entity.timer.get(timerSupply, supplyInterval)){
|
||||
for(int i = 0; i < Item.all().size; i++){
|
||||
Item item = Item.getByID(i);
|
||||
if(tile.entity.items.has(item) && entity.target.acceptsAmmo(item)){
|
||||
tile.entity.items.remove(item, 1);
|
||||
entity.target.addAmmo(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entity.rotation = Mathf.slerpDelta(entity.rotation, entity.angleTo(entity.target), 0.5f);
|
||||
}
|
||||
|
||||
if(entity.target != null && entity.cons.valid()){
|
||||
entity.lastx = entity.target.x;
|
||||
entity.lasty = entity.target.y;
|
||||
entity.strength = Mathf.lerpDelta(entity.strength, 1f, 0.08f * Timers.delta());
|
||||
}else{
|
||||
entity.strength = Mathf.lerpDelta(entity.strength, 0f, 0.08f * Timers.delta());
|
||||
}
|
||||
|
||||
if(entity.timer.get(timerTarget, 20)){
|
||||
rect.setSize(supplyRadius * 2).setCenter(tile.drawx(), tile.drawy());
|
||||
|
||||
entity.target = Units.getClosest(tile.getTeam(), tile.drawx(), tile.drawy(), supplyRadius, unit -> validTarget(entity, unit));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return tile.entity.items.total() < itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
return new ResupplyPointEntity();
|
||||
}
|
||||
|
||||
boolean validTarget(ResupplyPointEntity entity, Unit unit){
|
||||
if(unit == null || unit.inventory.totalAmmo() >= unit.inventory.ammoCapacity()
|
||||
|| unit.isDead()) return false;
|
||||
|
||||
for(int i = 0; i < Item.all().size; i++){
|
||||
Item item = Item.getByID(i);
|
||||
if(entity.items.has(item) && unit.acceptsAmmo(item)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public class ResupplyPointEntity extends TileEntity{
|
||||
public Unit target;
|
||||
public float strength, rotation = 90, lastx, lasty;
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.BarType;
|
||||
@ -74,10 +73,6 @@ public class UnitPad extends Block{
|
||||
unit.set(tile.drawx(), tile.drawy());
|
||||
unit.add();
|
||||
unit.getVelocity().y = factory.launchVelocity;
|
||||
|
||||
//fill inventory with 1st ammo
|
||||
AmmoType type = unit.getWeapon().getAmmoType(unit.getWeapon().getAcceptedItems().iterator().next());
|
||||
unit.inventory.fillAmmo(type);
|
||||
}
|
||||
}
|
||||
|
||||
|