Added mend projector
This commit is contained in:
@@ -24,6 +24,7 @@ import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.impl.BaseEntity;
|
||||
import io.anuke.ucore.entities.trait.HealthTrait;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Timer;
|
||||
|
||||
@@ -34,7 +35,7 @@ import java.io.IOException;
|
||||
import static io.anuke.mindustry.Vars.tileGroup;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class TileEntity extends BaseEntity implements TargetTrait{
|
||||
public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep
|
||||
private static final ObjectSet<Tile> tmpTiles = new ObjectSet<>();
|
||||
/**This value is only used for debugging.*/
|
||||
@@ -118,18 +119,6 @@ public class TileEntity extends BaseEntity implements TargetTrait{
|
||||
public void read(DataInputStream stream) throws IOException{
|
||||
}
|
||||
|
||||
private void onDeath(){
|
||||
if(!dead){
|
||||
dead = true;
|
||||
Block block = tile.block();
|
||||
|
||||
block.onDestroyed(tile);
|
||||
world.removeBlock(tile);
|
||||
block.afterDestroyed(tile, this);
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean collide(Bullet other){
|
||||
return true;
|
||||
}
|
||||
@@ -206,6 +195,39 @@ public class TileEntity extends BaseEntity implements TargetTrait{
|
||||
return proximity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void health(float health){
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float health(){
|
||||
return health;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float maxHealth(){
|
||||
return tile.block().health;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDead(boolean dead){
|
||||
this.dead = dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(){
|
||||
if(!dead){
|
||||
dead = true;
|
||||
Block block = tile.block();
|
||||
|
||||
block.onDestroyed(tile);
|
||||
world.removeBlock(tile);
|
||||
block.afterDestroyed(tile, this);
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Team getTeam(){
|
||||
return tile.getTeam();
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.defense.ShieldBlock;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.impl.BaseEntity;
|
||||
import io.anuke.ucore.entities.trait.DrawTrait;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
//todo re-implement
|
||||
public class Shield extends BaseEntity implements DrawTrait{
|
||||
private final Tile tile;
|
||||
public boolean active;
|
||||
public boolean hitPlayers = false;
|
||||
public float radius = 0f;
|
||||
private float uptime = 0f;
|
||||
|
||||
public Shield(Tile tile){
|
||||
this.tile = tile;
|
||||
this.x = tile.worldx();
|
||||
this.y = tile.worldy();
|
||||
}
|
||||
|
||||
public float drawSize(){
|
||||
return 150;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
float alpha = 0.1f;
|
||||
Interpolation interp = Interpolation.fade;
|
||||
|
||||
if(active){
|
||||
uptime = interp.apply(uptime, 1f, alpha * Timers.delta());
|
||||
}else{
|
||||
uptime = interp.apply(uptime, 0f, alpha * Timers.delta());
|
||||
if(uptime <= 0.05f)
|
||||
remove();
|
||||
}
|
||||
uptime = Mathf.clamp(uptime);
|
||||
|
||||
if(!(tile.block() instanceof ShieldBlock)){
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
ShieldBlock block = (ShieldBlock) tile.block();
|
||||
|
||||
/*
|
||||
Entities.getNearby(bulletGroup, x, y, block.shieldRadius * 2*uptime + 10, entity->{
|
||||
BulletEntity bullet = (BulletEntity)entity;
|
||||
if((bullet.owner instanceof BaseUnit || hitPlayers)){
|
||||
|
||||
float dst = entity.distanceTo(this);
|
||||
|
||||
if(dst < drawRadius()/2f){
|
||||
((ShieldBlock)tile.block()).handleBullet(tile, bullet);
|
||||
}
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if(!(tile.block() instanceof ShieldBlock) || radius <= 1f){
|
||||
return;
|
||||
}
|
||||
|
||||
Fill.circle(x, y, drawRadius());
|
||||
}
|
||||
|
||||
float drawRadius(){
|
||||
return (radius + Mathf.sin(Timers.time(), 25f, 1f));
|
||||
}
|
||||
|
||||
public void removeDelay(){
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void added(){
|
||||
active = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(){
|
||||
active = false;
|
||||
uptime = 0f;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user