Refactoring
This commit is contained in:
@@ -358,11 +358,11 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
/** Called every frame a unit is on this tile. */
|
||||
public void unitOn(Tile tile, Unit unit){
|
||||
public void unitOn(Tile tile, Unitc unit){
|
||||
}
|
||||
|
||||
/** Called when a unit that spawned at this tile is removed. */
|
||||
public void unitRemoved(Tile tile, Unit unit){
|
||||
public void unitRemoved(Tile tile, Unitc unit){
|
||||
}
|
||||
|
||||
/** Returns whether ot not this block can be place on the specified tile. */
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package mindustry.world;
|
||||
|
||||
import arc.struct.Array;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.Vars;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.entities.effect.Puddle;
|
||||
import mindustry.entities.type.TileEntity;
|
||||
import mindustry.entities.type.Unit;
|
||||
import mindustry.ctype.UnlockableContent;
|
||||
import mindustry.type.Item;
|
||||
import mindustry.type.Liquid;
|
||||
import mindustry.world.consumers.Consumers;
|
||||
import mindustry.world.meta.BlockBars;
|
||||
import mindustry.world.meta.BlockStats;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public abstract class BlockStorage extends UnlockableContent{
|
||||
public boolean hasItems;
|
||||
@@ -51,7 +48,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
|
||||
/** Returns the amount of items this block can accept. */
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
public int acceptStack(Item item, int amount, Tile tile, Teamc source){
|
||||
if(acceptItem(item, tile, tile) && hasItems && (source == null || source.getTeam() == tile.getTeam())){
|
||||
return Math.min(getMaximumAccepted(tile, item) - tile.entity.items.get(item), amount);
|
||||
}else{
|
||||
@@ -73,7 +70,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
|
||||
/** Handle a stack input. */
|
||||
public void handleStack(Item item, int amount, Tile tile, Unit source){
|
||||
public void handleStack(Item item, int amount, Tile tile, Teamc source){
|
||||
tile.entity.noSleep();
|
||||
tile.entity.items.add(item, amount);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class BuildBlock extends Block{
|
||||
private float[] accumulator;
|
||||
private float[] totalAccumulator;
|
||||
|
||||
public boolean construct(Unit builder, @Nullable TileEntity core, float amount, boolean configured){
|
||||
public boolean construct(Unitc builder, @Nullable TileEntity core, float amount, boolean configured){
|
||||
if(cblock == null){
|
||||
kill();
|
||||
return false;
|
||||
@@ -238,10 +238,7 @@ public class BuildBlock extends Block{
|
||||
maxProgress = core == null ? maxProgress : checkRequired(core.items, maxProgress, true);
|
||||
|
||||
progress = Mathf.clamp(progress + maxProgress);
|
||||
|
||||
if(builder instanceof Player){
|
||||
builderID = builder.getID();
|
||||
}
|
||||
builderID = builder.getId();
|
||||
|
||||
if(progress >= 1f || state.rules.infiniteResources){
|
||||
constructed(tile, cblock, builderID, tile.rotation(), builder.getTeam(), configured);
|
||||
@@ -250,7 +247,7 @@ public class BuildBlock extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void deconstruct(Unit builder, @Nullable TileEntity core, float amount){
|
||||
public void deconstruct(Unitc builder, @Nullable TileEntity core, float amount){
|
||||
float deconstructMultiplier = 0.5f;
|
||||
|
||||
if(cblock != null){
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package mindustry.world.blocks;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.g2d.TextureAtlas.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.MultiPacker.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
@@ -9,9 +9,7 @@ import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.entities.type.BaseEntity;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
||||
@@ -4,7 +4,6 @@ import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Fill;
|
||||
import arc.math.Mathf;
|
||||
import mindustry.entities.effect.Lightning;
|
||||
import mindustry.entities.type.Unit;
|
||||
import mindustry.graphics.Layer;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.world.Block;
|
||||
@@ -49,7 +48,7 @@ public class ShockMine extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unitOn(Tile tile, Unit unit){
|
||||
public void unitOn(Tile tile, Unitc unit){
|
||||
if(unit.getTeam() != tile.getTeam() && tile.entity.timer.get(timerDamage, cooldown)){
|
||||
for(int i = 0; i < tendrils; i++){
|
||||
Lightning.create(tile.getTeam(), Pal.lancerLaser, damage, tile.drawx(), tile.drawy(), Mathf.random(360f), length);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ItemTurret extends CooledTurret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unitc source){
|
||||
TurretEntity entity = tile.ent();
|
||||
|
||||
BulletType type = ammo.get(item);
|
||||
@@ -97,7 +97,7 @@ public class ItemTurret extends CooledTurret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleStack(Item item, int amount, Tile tile, Unit source){
|
||||
public void handleStack(Item item, int amount, Tile tile, Unitc source){
|
||||
for(int i = 0; i < amount; i++){
|
||||
handleItem(item, tile, null);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unitOn(Tile tile, Unit unit){
|
||||
public void unitOn(Tile tile, Unitc unit){
|
||||
ConveyorEntity entity = tile.ent();
|
||||
|
||||
if(entity.clogHeat > 0.5f){
|
||||
@@ -256,13 +256,13 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unitc source){
|
||||
ConveyorEntity entity = tile.ent();
|
||||
return Math.min((int)(entity.minitem / itemSpace), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleStack(Item item, int amount, Tile tile, Unit source){
|
||||
public void handleStack(Item item, int amount, Tile tile, Unitc source){
|
||||
ConveyorEntity e = tile.ent();
|
||||
|
||||
for(int i = amount - 1; i >= 0; i--){
|
||||
|
||||
@@ -2,7 +2,6 @@ package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.util.Time;
|
||||
import mindustry.entities.type.TileEntity;
|
||||
import mindustry.entities.type.Unit;
|
||||
import mindustry.gen.BufferItem;
|
||||
import mindustry.type.Item;
|
||||
import mindustry.world.Block;
|
||||
@@ -31,7 +30,7 @@ public class Junction extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unitc source){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
@@ -239,7 +238,7 @@ public class CoreBlock extends StorageBlock{
|
||||
protected int storageCapacity;
|
||||
|
||||
@Override
|
||||
public boolean hasUnit(Unit unit){
|
||||
public boolean hasUnit(Unitc unit){
|
||||
return unit == spawnPlayer;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,11 @@ import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -143,7 +141,7 @@ public class MechPad extends Block{
|
||||
float heat;
|
||||
|
||||
@Override
|
||||
public boolean hasUnit(Unit unit){
|
||||
public boolean hasUnit(Unitc unit){
|
||||
return unit == player;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import arc.math.geom.Rect;
|
||||
import arc.util.Time;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.type.TileEntity;
|
||||
import mindustry.entities.type.Unit;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
@@ -141,7 +140,7 @@ public class RepairPoint extends Block{
|
||||
}
|
||||
|
||||
public class RepairPointEntity extends TileEntity{
|
||||
public Unit target;
|
||||
public Unitc target;
|
||||
public float strength, rotation = 90;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class UnitFactory extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unitRemoved(Tile tile, Unit unit){
|
||||
public void unitRemoved(Tile tile, Unitc unit){
|
||||
UnitFactoryEntity entity = tile.ent();
|
||||
entity.spawned--;
|
||||
entity.spawned = Math.max(entity.spawned, 0);
|
||||
|
||||
Reference in New Issue
Block a user