Bugfixes / Direct payload support

This commit is contained in:
Anuken
2020-05-29 10:44:08 -04:00
parent a89d2025e3
commit 402fe88cf6
8 changed files with 50 additions and 13 deletions

View File

@@ -52,6 +52,8 @@ public abstract class Turret extends Block{
public float shootCone = 8f;
public float shootShake = 0f;
public float xRand = 0f;
/** Currently used for artillery only. */
public float minRange = 0f;
public float burstSpacing = 0;
public boolean alternate = false;
public boolean targetAir = true;
@@ -289,16 +291,12 @@ public abstract class Turret extends Block{
return entry.type();
}
/**
* Get the ammo type that will be returned if useAmmo is called.
*/
/** @return the ammo type that will be returned if useAmmo is called. */
public BulletType peekAmmo(){
return ammo.peek().type();
}
/**
* Returns whether the turret has ammo.
*/
/** @return whether the turret has ammo. */
public boolean hasAmmo(){
return ammo.size > 0 && ammo.peek().amount >= ammoPerShot;
}
@@ -358,7 +356,7 @@ public abstract class Turret extends Block{
}
protected void bullet(BulletType type, float angle){
float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x, y, targetPos.x, targetPos.y) / type.range()) : 1f;
float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x, y, targetPos.x, targetPos.y) / type.range(), minRange / type.range(), range / type.range()) : 1f;
type.create(this, team, x + tr.x, y + tr.y, angle, 1f + Mathf.range(velocityInaccuracy), lifeScl);
}

View File

@@ -156,7 +156,8 @@ public class PayloadConveyor extends Block{
@Override
public boolean acceptPayload(Tilec source, Payload payload){
return this.item == null && progress <= 5f;
//accepting payloads from units isn't supported
return this.item == null && progress <= 5f && source != this;
}
@Override

View File

@@ -6,6 +6,7 @@ import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
@@ -15,6 +16,7 @@ import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.meta.*;
import mindustry.world.modules.*;
@@ -79,8 +81,21 @@ public class CoreBlock extends StorageBlock{
return false;
}
public class CoreEntity extends TileEntity{
protected int storageCapacity;
public class CoreEntity extends TileEntity implements ControlBlock{
public int storageCapacity;
//note that this unit is never actually used for control; the possession handler makes the player respawn when this unit is controlled
public @NonNull BlockUnitc unit = Nulls.blockUnit;
@Override
public void created(){
unit = (BlockUnitc)UnitTypes.block.create(team);
unit.tile(this);
}
@Override
public Unitc unit(){
return unit;
}
public void requestSpawn(Playerc player){
Call.onPlayerSpawn(tile, player);