ItemDrop class removed
This commit is contained in:
@@ -9,7 +9,6 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
import io.anuke.mindustry.entities.effect.Fire;
|
import io.anuke.mindustry.entities.effect.Fire;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
|
||||||
import io.anuke.mindustry.entities.effect.Puddle;
|
import io.anuke.mindustry.entities.effect.Puddle;
|
||||||
import io.anuke.mindustry.entities.traits.SyncTrait;
|
import io.anuke.mindustry.entities.traits.SyncTrait;
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
@@ -117,7 +116,6 @@ public class Vars{
|
|||||||
public static EntityGroup<Bullet> bulletGroup;
|
public static EntityGroup<Bullet> bulletGroup;
|
||||||
public static EntityGroup<EffectEntity> effectGroup;
|
public static EntityGroup<EffectEntity> effectGroup;
|
||||||
public static EntityGroup<DrawTrait> groundEffectGroup;
|
public static EntityGroup<DrawTrait> groundEffectGroup;
|
||||||
public static EntityGroup<ItemDrop> itemGroup;
|
|
||||||
public static EntityGroup<ShieldEntity> shieldGroup;
|
public static EntityGroup<ShieldEntity> shieldGroup;
|
||||||
public static EntityGroup<Puddle> puddleGroup;
|
public static EntityGroup<Puddle> puddleGroup;
|
||||||
public static EntityGroup<Fire> fireGroup;
|
public static EntityGroup<Fire> fireGroup;
|
||||||
@@ -152,7 +150,6 @@ public class Vars{
|
|||||||
effectGroup = Entities.addGroup(EffectEntity.class, false);
|
effectGroup = Entities.addGroup(EffectEntity.class, false);
|
||||||
groundEffectGroup = Entities.addGroup(DrawTrait.class, false);
|
groundEffectGroup = Entities.addGroup(DrawTrait.class, false);
|
||||||
puddleGroup = Entities.addGroup(Puddle.class).enableMapping();
|
puddleGroup = Entities.addGroup(Puddle.class).enableMapping();
|
||||||
itemGroup = Entities.addGroup(ItemDrop.class).enableMapping();
|
|
||||||
shieldGroup = Entities.addGroup(ShieldEntity.class, false);
|
shieldGroup = Entities.addGroup(ShieldEntity.class, false);
|
||||||
fireGroup = Entities.addGroup(Fire.class).enableMapping();
|
fireGroup = Entities.addGroup(Fire.class).enableMapping();
|
||||||
unitGroups = new EntityGroup[Team.all.length];
|
unitGroups = new EntityGroup[Team.all.length];
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import io.anuke.mindustry.entities.bullet.Bullet;
|
|||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||||
import io.anuke.mindustry.entities.bullet.LiquidBulletType;
|
import io.anuke.mindustry.entities.bullet.LiquidBulletType;
|
||||||
import io.anuke.mindustry.entities.effect.Fire;
|
import io.anuke.mindustry.entities.effect.Fire;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
|
||||||
import io.anuke.mindustry.entities.effect.Lightning;
|
import io.anuke.mindustry.entities.effect.Lightning;
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
@@ -392,8 +391,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
int amountDropped = Mathf.random(0, data.items[i]);
|
int amountDropped = Mathf.random(0, data.items[i]);
|
||||||
if(amountDropped > 0){
|
if(amountDropped > 0){
|
||||||
float angle = b.angle() + Mathf.range(100f);
|
float angle = b.angle() + Mathf.range(100f);
|
||||||
float vs = Mathf.random(0f, 4f);
|
Effects.effect(EnvironmentFx.dropItem, Color.WHITE, b.x, b.y, angle, content.item(i));
|
||||||
ItemDrop.create(content.item(i), amountDropped, b.x, b.y, Angles.trnsx(angle, vs), Angles.trnsy(angle, vs));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package io.anuke.mindustry.content.fx;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
import io.anuke.mindustry.content.Liquids;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
|
||||||
import io.anuke.mindustry.game.ContentList;
|
import io.anuke.mindustry.game.ContentList;
|
||||||
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Fill;
|
import io.anuke.ucore.graphics.Fill;
|
||||||
@@ -11,7 +12,7 @@ import io.anuke.ucore.util.Angles;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class EnvironmentFx extends FxList implements ContentList{
|
public class EnvironmentFx extends FxList implements ContentList{
|
||||||
public static Effect burning, fire, smoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily, overdriven;
|
public static Effect burning, fire, smoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily, overdriven, dropItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
@@ -125,5 +126,12 @@ public class EnvironmentFx extends FxList implements ContentList{
|
|||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dropItem = new Effect(20f, e -> {
|
||||||
|
float length = 20f * e.finpow();
|
||||||
|
float size = 7f * e.fout();
|
||||||
|
|
||||||
|
Draw.rect(((Item) e.data).region, e.x + Angles.trnsx(e.rotation, length), e.y + Angles.trnsy(e.rotation, length), size, size);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||||
import io.anuke.mindustry.entities.effect.Fire;
|
import io.anuke.mindustry.entities.effect.Fire;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
|
||||||
import io.anuke.mindustry.entities.effect.Lightning;
|
import io.anuke.mindustry.entities.effect.Lightning;
|
||||||
import io.anuke.mindustry.entities.effect.Puddle;
|
import io.anuke.mindustry.entities.effect.Puddle;
|
||||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||||
@@ -263,7 +262,6 @@ public class ContentLoader{
|
|||||||
*/
|
*/
|
||||||
private void registerTypes(){
|
private void registerTypes(){
|
||||||
TypeTrait.registerType(Player.class, Player::new);
|
TypeTrait.registerType(Player.class, Player::new);
|
||||||
TypeTrait.registerType(ItemDrop.class, ItemDrop::new);
|
|
||||||
TypeTrait.registerType(Fire.class, Fire::new);
|
TypeTrait.registerType(Fire.class, Fire::new);
|
||||||
TypeTrait.registerType(Puddle.class, Puddle::new);
|
TypeTrait.registerType(Puddle.class, Puddle::new);
|
||||||
TypeTrait.registerType(Bullet.class, Bullet::new);
|
TypeTrait.registerType(Bullet.class, Bullet::new);
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ public class Logic extends Module{
|
|||||||
Entities.update(bulletGroup);
|
Entities.update(bulletGroup);
|
||||||
Entities.update(fireGroup);
|
Entities.update(fireGroup);
|
||||||
Entities.update(playerGroup);
|
Entities.update(playerGroup);
|
||||||
Entities.update(itemGroup);
|
|
||||||
|
|
||||||
//effect group only contains item drops in the headless version, update it!
|
//effect group only contains item drops in the headless version, update it!
|
||||||
if(headless){
|
if(headless){
|
||||||
@@ -145,7 +144,6 @@ public class Logic extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
EntityPhysics.collideGroups(bulletGroup, playerGroup);
|
EntityPhysics.collideGroups(bulletGroup, playerGroup);
|
||||||
EntityPhysics.collideGroups(itemGroup, playerGroup);
|
|
||||||
|
|
||||||
world.pathfinder().update();
|
world.pathfinder().update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,17 +246,6 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
blocks.drawBlocks(Layer.overlay);
|
blocks.drawBlocks(Layer.overlay);
|
||||||
|
|
||||||
if(itemGroup.size() > 0){
|
|
||||||
Graphics.surface(effectSurface);
|
|
||||||
drawAndInterpolate(itemGroup);
|
|
||||||
Graphics.surface();
|
|
||||||
|
|
||||||
Draw.color(0, 0, 0, 0.2f);
|
|
||||||
Draw.rect(effectSurface, -1, -1);
|
|
||||||
Draw.color();
|
|
||||||
Draw.rect(effectSurface, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawAllTeams(false);
|
drawAllTeams(false);
|
||||||
|
|
||||||
blocks.skipLayer(Layer.turret);
|
blocks.skipLayer(Layer.turret);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import io.anuke.annotations.Annotations.Remote;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.Mechs;
|
import io.anuke.mindustry.content.Mechs;
|
||||||
import io.anuke.mindustry.content.fx.UnitFx;
|
import io.anuke.mindustry.content.fx.UnitFx;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
|
||||||
import io.anuke.mindustry.entities.effect.ScorchDecal;
|
import io.anuke.mindustry.entities.effect.ScorchDecal;
|
||||||
import io.anuke.mindustry.entities.traits.*;
|
import io.anuke.mindustry.entities.traits.*;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
@@ -222,11 +221,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean collides(SolidTrait other){
|
|
||||||
return super.collides(other) || other instanceof ItemDrop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(float x, float y){
|
public void set(float x, float y){
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
|||||||
@@ -1,250 +0,0 @@
|
|||||||
package io.anuke.mindustry.entities.effect;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.math.Vector2;
|
|
||||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
|
||||||
import io.anuke.mindustry.content.fx.UnitFx;
|
|
||||||
import io.anuke.mindustry.entities.Player;
|
|
||||||
import io.anuke.mindustry.entities.Unit;
|
|
||||||
import io.anuke.mindustry.entities.traits.SaveTrait;
|
|
||||||
import io.anuke.mindustry.entities.traits.SyncTrait;
|
|
||||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
|
||||||
import io.anuke.mindustry.game.Team;
|
|
||||||
import io.anuke.mindustry.gen.Call;
|
|
||||||
import io.anuke.mindustry.net.Interpolator;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
|
||||||
import io.anuke.mindustry.type.Item;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
|
||||||
import io.anuke.ucore.entities.EntityGroup;
|
|
||||||
import io.anuke.ucore.entities.impl.SolidEntity;
|
|
||||||
import io.anuke.ucore.entities.trait.DrawTrait;
|
|
||||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
|
||||||
import io.anuke.ucore.entities.trait.TimeTrait;
|
|
||||||
import io.anuke.ucore.entities.trait.VelocityTrait;
|
|
||||||
import io.anuke.ucore.graphics.Draw;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawTrait, VelocityTrait, TimeTrait, TargetTrait, Poolable{
|
|
||||||
private static final float sinkLifetime = 80f;
|
|
||||||
|
|
||||||
private Interpolator interpolator = new Interpolator();
|
|
||||||
private Item item;
|
|
||||||
private int amount;
|
|
||||||
|
|
||||||
private Vector2 velocity = new Vector2();
|
|
||||||
private float time;
|
|
||||||
private float sinktime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal use only!
|
|
||||||
*/
|
|
||||||
public ItemDrop(){
|
|
||||||
hitbox.setSize(5f);
|
|
||||||
hitboxTile.setSize(5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemDrop create(Item item, int amount, float x, float y, float angle){
|
|
||||||
ItemDrop drop = new ItemDrop();
|
|
||||||
drop.item = item;
|
|
||||||
drop.amount = amount;
|
|
||||||
drop.velocity.set(4f, 0f).rotate(angle);
|
|
||||||
drop.setNet(x, y);
|
|
||||||
drop.add();
|
|
||||||
|
|
||||||
return drop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void create(Item item, int amount, float x, float y, float velocityX, float velocityY){
|
|
||||||
create(item, amount, x, y, 0).getVelocity().set(velocityX, velocityY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Remote(called = Loc.server)
|
|
||||||
public static void onPickup(int itemid){
|
|
||||||
ItemDrop drop = itemGroup.getByID(itemid);
|
|
||||||
if(drop != null){
|
|
||||||
Effects.effect(UnitFx.pickup, drop);
|
|
||||||
}
|
|
||||||
itemGroup.removeByID(itemid);
|
|
||||||
if(Net.client()){
|
|
||||||
netClient.addRemovedEntity(itemid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Item getItem(){
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAmount(){
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDead(){
|
|
||||||
return !isAdded();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Team getTeam(){
|
|
||||||
return Team.none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float lifetime(){
|
|
||||||
return 60 * 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void time(float time){
|
|
||||||
this.time = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float time(){
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector2 getVelocity(){
|
|
||||||
return velocity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean collides(SolidTrait other){
|
|
||||||
return other instanceof Player && time > 20f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void collision(SolidTrait other, float x, float y){
|
|
||||||
Unit player = (Unit) other;
|
|
||||||
if(player.inventory.canAcceptItem(item, 1)){
|
|
||||||
int used = Math.min(amount, player.inventory.capacity() - player.inventory.getItem().amount);
|
|
||||||
player.inventory.addItem(item, used);
|
|
||||||
amount -= used;
|
|
||||||
|
|
||||||
if(amount <= 0){
|
|
||||||
Call.onPickup(getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(){
|
|
||||||
float size = itemSize * (1f - sinktime / sinkLifetime) * (1f - Mathf.curve(fin(), 0.98f));
|
|
||||||
|
|
||||||
Tile tile = world.tileWorld(x, y);
|
|
||||||
|
|
||||||
Draw.color(Color.WHITE, tile == null || !tile.floor().isLiquid ? Color.WHITE : tile.floor().liquidColor, sinktime / sinkLifetime);
|
|
||||||
Draw.rect(item.region, x, y, size, size);
|
|
||||||
|
|
||||||
int stored = Mathf.clamp(amount / 6, 1, 8);
|
|
||||||
|
|
||||||
for(int i = 0; i < stored; i++){
|
|
||||||
float px = stored == 1 ? 0 : (int)Mathf.randomSeedRange(i + 1, 4f);
|
|
||||||
float py = stored == 1 ? 0 : (int)Mathf.randomSeedRange(i + 2, 4f);
|
|
||||||
Draw.rect(item.region, x + px, y + py, size, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw.color();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(){
|
|
||||||
if(Net.client()){
|
|
||||||
interpolate();
|
|
||||||
}else{
|
|
||||||
updateVelocity(0.2f);
|
|
||||||
updateTime();
|
|
||||||
if(time >= lifetime()){
|
|
||||||
Call.onPickup(getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile tile = world.tileWorld(x, y);
|
|
||||||
|
|
||||||
if(tile != null && tile.solid()){
|
|
||||||
Call.onPickup(getID());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tile != null && tile.floor().isLiquid){
|
|
||||||
sinktime += Timers.delta();
|
|
||||||
|
|
||||||
if(Mathf.chance(0.04 * Timers.delta())){
|
|
||||||
Effects.effect(tile.floor().drownUpdateEffect, tile.floor().liquidColor, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sinktime >= sinkLifetime){
|
|
||||||
remove();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
sinktime = 0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset(){
|
|
||||||
time = 0f;
|
|
||||||
interpolator.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolator getInterpolator(){
|
|
||||||
return interpolator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float drawSize(){
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float fin() {
|
|
||||||
return time()/lifetime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityGroup targetGroup(){
|
|
||||||
return itemGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeSave(DataOutput data) throws IOException{
|
|
||||||
data.writeFloat(x);
|
|
||||||
data.writeFloat(y);
|
|
||||||
data.writeByte(item.id);
|
|
||||||
data.writeShort(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readSave(DataInput data) throws IOException{
|
|
||||||
x = data.readFloat();
|
|
||||||
y = data.readFloat();
|
|
||||||
item = content.item(data.readByte());
|
|
||||||
amount = data.readShort();
|
|
||||||
add();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(DataOutput data) throws IOException{
|
|
||||||
data.writeFloat(x);
|
|
||||||
data.writeFloat(y);
|
|
||||||
data.writeByte(item.id);
|
|
||||||
data.writeShort(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(DataInput data, long time) throws IOException{
|
|
||||||
interpolator.read(x, y, data.readFloat(), data.readFloat(), time);
|
|
||||||
item = content.item(data.readByte());
|
|
||||||
amount = data.readShort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ import io.anuke.mindustry.content.blocks.Blocks;
|
|||||||
import io.anuke.mindustry.content.fx.BlockFx;
|
import io.anuke.mindustry.content.fx.BlockFx;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
||||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
@@ -158,10 +157,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
retarget(() -> {
|
retarget(() -> {
|
||||||
if(findItemDrop()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getMineTile() == null){
|
if(getMineTile() == null){
|
||||||
findItem();
|
findItem();
|
||||||
}
|
}
|
||||||
@@ -189,33 +184,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
setMineTile(null);
|
setMineTile(null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pickup = new UnitState(){
|
|
||||||
public void entered(){
|
|
||||||
target = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(){
|
|
||||||
ItemDrop item = (ItemDrop) target;
|
|
||||||
|
|
||||||
if(item == null || inventory.isFull() || item.getItem().type != ItemType.material || !inventory.canAcceptItem(item.getItem(), 1)){
|
|
||||||
setState(drop);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(distanceTo(item) < 4){
|
|
||||||
item.collision(Drone.this, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
//item has been picked up
|
|
||||||
if(item.getAmount() == 0){
|
|
||||||
if(!findItemDrop()){
|
|
||||||
setState(drop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
moveTo(0f);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = new UnitState(){
|
drop = new UnitState(){
|
||||||
public void entered(){
|
public void entered(){
|
||||||
target = null;
|
target = null;
|
||||||
@@ -409,23 +377,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
targetItem = Mathf.findMin(type.toMine, (a, b) -> -Integer.compare(entity.items.get(a), entity.items.get(b)));
|
targetItem = Mathf.findMin(type.toMine, (a, b) -> -Integer.compare(entity.items.get(a), entity.items.get(b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean findItemDrop(){
|
|
||||||
TileEntity core = getClosestCore();
|
|
||||||
|
|
||||||
if(core == null) return false;
|
|
||||||
|
|
||||||
//find nearby dropped items to pick up if applicable
|
|
||||||
ItemDrop drop = EntityPhysics.getClosest(itemGroup, x, y, 60f,
|
|
||||||
item -> core.tile.block().acceptStack(item.getItem(), item.getAmount(), core.tile, Drone.this) == item.getAmount() &&
|
|
||||||
inventory.canAcceptItem(item.getItem(), 1));
|
|
||||||
if(drop != null){
|
|
||||||
setState(pickup);
|
|
||||||
target = drop;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCreateBlocks(){
|
public boolean canCreateBlocks(){
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package io.anuke.mindustry.input;
|
package io.anuke.mindustry.input;
|
||||||
|
|
||||||
import com.badlogic.gdx.InputAdapter;
|
import com.badlogic.gdx.InputAdapter;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
|
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
|
||||||
import io.anuke.mindustry.entities.effect.ItemTransfer;
|
import io.anuke.mindustry.entities.effect.ItemTransfer;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
@@ -19,10 +20,7 @@ import io.anuke.mindustry.ui.fragments.OverlayFragment;
|
|||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Build;
|
import io.anuke.mindustry.world.Build;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.core.Graphics;
|
|
||||||
import io.anuke.ucore.core.Inputs;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
@@ -61,7 +59,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
throw new ValidateException(player, "Player cannot drop an item.");
|
throw new ValidateException(player, "Player cannot drop an item.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemDrop.create(player.inventory.getItem().item, player.inventory.getItem().amount, player.x, player.y, angle);
|
Effects.effect(EnvironmentFx.dropItem, Color.WHITE, player.x, player.y, angle, player.inventory.getItem().item);
|
||||||
player.inventory.clearItem();
|
player.inventory.clearItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import io.anuke.mindustry.content.fx.ShootFx;
|
|||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Layer;
|
import io.anuke.mindustry.graphics.Layer;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
@@ -283,16 +282,6 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//drop all items remaining on the ground
|
|
||||||
for(int i = 0; i < data.items.length; i++){
|
|
||||||
int amountDropped = Mathf.random(0, data.items[i]);
|
|
||||||
if(amountDropped > 0){
|
|
||||||
float angle = Mathf.range(180f);
|
|
||||||
float vs = Mathf.random(0f, 4f);
|
|
||||||
ItemDrop.create(content.item(i), amountDropped, bullet.x, bullet.y, Angles.trnsx(angle, vs), Angles.trnsy(angle, vs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reload = 1f;
|
reload = 1f;
|
||||||
Effects.shake(shake, shake, this);
|
Effects.shake(shake, shake, this);
|
||||||
Effects.effect(recieveEffect, bullet);
|
Effects.effect(recieveEffect, bullet);
|
||||||
|
|||||||
Reference in New Issue
Block a user