All hail the cuteness of this crater roomba critter
This commit is contained in:
@@ -57,7 +57,7 @@ public class Blocks implements ContentList{
|
||||
scrapWall, scrapWallLarge, scrapWallHuge, scrapWallGigantic, thruster, //ok, these names are getting ridiculous, but at least I don't have humongous walls yet
|
||||
|
||||
//transport
|
||||
conveyor, titaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, overflowGate, massDriver,
|
||||
conveyor, titaniumConveyor, armoredConveyor, compressedConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, overflowGate, massDriver,
|
||||
|
||||
//liquids
|
||||
mechanicalPump, rotaryPump, thermalPump, conduit, pulseConduit, platedConduit, liquidRouter, liquidTank, liquidJunction, bridgeConduit, phaseConduit,
|
||||
@@ -897,6 +897,12 @@ public class Blocks implements ContentList{
|
||||
speed = 0.08f;
|
||||
}};
|
||||
|
||||
compressedConveyor = new CompressedConveyor("compressed-conveyor"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.plastanium, 1, Items.surgealloy, 1, Items.phasefabric, 1));
|
||||
health = 150;
|
||||
speed = 0f;
|
||||
}};
|
||||
|
||||
junction = new Junction("junction"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 1), true);
|
||||
speed = 26;
|
||||
|
||||
@@ -11,12 +11,30 @@ import mindustry.type.*;
|
||||
|
||||
public class UnitTypes implements ContentList{
|
||||
public static UnitType
|
||||
draug, spirit, phantom,
|
||||
crater, draug, spirit, phantom,
|
||||
wraith, ghoul, revenant, lich, reaper,
|
||||
dagger, crawler, titan, fortress, eruptor, chaosArray, eradicator;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
crater = new UnitType("crater", CraterUnit::new){{
|
||||
maxVelocity = 0.75f;
|
||||
speed = 0.1f;
|
||||
drag = 0.25f;
|
||||
hitsize = 4f;
|
||||
mass = 0.5f;
|
||||
health = 50;
|
||||
rotatespeed = 0.1f;
|
||||
itemCapacity = 10;
|
||||
weapon = new Weapon(){{
|
||||
length = 1.5f;
|
||||
reload = 28f;
|
||||
alternate = true;
|
||||
ejectEffect = Fx.shellEjectSmall;
|
||||
bullet = Bullets.standardCopper;
|
||||
}};
|
||||
}};
|
||||
|
||||
draug = new UnitType("draug", MinerDrone::new){{
|
||||
flying = true;
|
||||
drag = 0.01f;
|
||||
|
||||
122
core/src/mindustry/entities/type/base/CraterUnit.java
Normal file
122
core/src/mindustry/entities/type/base/CraterUnit.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package mindustry.entities.type.base;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class CraterUnit extends GroundUnit{
|
||||
|
||||
public final Effect io = Fx.plasticburn;
|
||||
public int inactivity = 0;
|
||||
|
||||
public final UnitState
|
||||
|
||||
load = new UnitState(){
|
||||
public void update(){
|
||||
if(item().amount >= getItemCapacity() || !velocity.isZero(1f) || inactivity++ > 120) state.set(move);
|
||||
}
|
||||
},
|
||||
move = new UnitState(){
|
||||
public void update(){
|
||||
velocity.add(vec.trnsExact(angleTo(on().front()), type.speed * Time.delta()));
|
||||
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
|
||||
|
||||
if(dst(on()) < 2.5f && on().block() instanceof CompressedConveyor && ((CompressedConveyor) on().block()).end(on())){
|
||||
state.set(unload);
|
||||
}
|
||||
}
|
||||
},
|
||||
unload = new UnitState(){
|
||||
public void update(){
|
||||
|
||||
if(on().block() instanceof CompressedConveyor && !((CompressedConveyor)on().block()).end(on())){
|
||||
state.set(move);
|
||||
return;
|
||||
}
|
||||
|
||||
if(item().amount-- > 0){
|
||||
int rot = on().rotation();
|
||||
on().block().offloadNear(on(), item().item);
|
||||
on().rotation(rot);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public UnitState getStartState(){
|
||||
return load;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawStats(){
|
||||
if(item.amount > 0) drawBackItems();
|
||||
drawLight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
super.update();
|
||||
|
||||
if(on() == null || !on().block().compressable || item.amount == 0){
|
||||
Effects.effect(io, x, y);
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void added(){
|
||||
super.added();
|
||||
Effects.effect(io, x, y);
|
||||
baseRotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(){
|
||||
Events.fire(new UnitDestroyEvent(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommanded(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public Tile on(){
|
||||
return world.ltileWorld(x, y);
|
||||
}
|
||||
|
||||
private void drawBackItems(){
|
||||
float itemtime = 0.5f;
|
||||
float backTrns = 0f;
|
||||
|
||||
float size = itemSize / 1.5f;
|
||||
|
||||
Draw.rect(item.item.icon(Cicon.medium),
|
||||
x + Angles.trnsx(rotation + 180f, backTrns),
|
||||
y + Angles.trnsy(rotation + 180f, backTrns),
|
||||
size, size, rotation);
|
||||
|
||||
Fonts.outline.draw(item.amount + "",
|
||||
x + Angles.trnsx(rotation + 180f, backTrns),
|
||||
y + Angles.trnsy(rotation + 180f, backTrns) - 1,
|
||||
Pal.accent, 0.25f * itemtime / Scl.scl(1f), false, Align.center);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public boolean loading(){
|
||||
return state.is(load);
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,8 @@ public class Block extends BlockStorage{
|
||||
public boolean sync;
|
||||
/** Whether this block uses conveyor-type placement mode.*/
|
||||
public boolean conveyorPlacement;
|
||||
/** Whether this block uses is compatible with compressed.*/
|
||||
public boolean compressable;
|
||||
/**
|
||||
* The color of this block when displayed on the minimap or map preview.
|
||||
* Do not set manually! This is overriden when loading for most blocks.
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.entities.type.base.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class CompressedConveyor extends ArmoredConveyor{
|
||||
protected TextureRegion start;
|
||||
public TextureRegion end;
|
||||
|
||||
protected static int cooldown = 10;
|
||||
|
||||
public CompressedConveyor(String name){
|
||||
super(name);
|
||||
compressable = true;
|
||||
entityType = CompressedConveyorEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
int i;
|
||||
for(i = 0; i < regions.length; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
regions[i][j] = Core.atlas.find(name + "-" + i + "-" + 0);
|
||||
}
|
||||
}
|
||||
|
||||
start = Core.atlas.find(name + "-5-0");
|
||||
end = Core.atlas.find(name + "-6-0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
if(start(tile) && end(tile)) return;
|
||||
if(start(tile)) Draw.rect(start, tile.drawx(), tile.drawy(), tile.rotation() * 90);
|
||||
if( end(tile)) Draw.rect( end, tile.drawx(), tile.drawy(), tile.rotation() * 90);
|
||||
}
|
||||
|
||||
protected boolean start(Tile tile){
|
||||
Tile[] inputs = new Tile[]{tile.back(), tile.left(), tile.right()};
|
||||
for(Tile input : inputs){
|
||||
if(input != null && input.getTeam() == tile.getTeam() && input.block().compressable && input.front() == tile) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean end(Tile tile){
|
||||
Tile next = tile.front();
|
||||
if(next == null) return true;
|
||||
if(next.getTeam() != tile.getTeam()) return true;
|
||||
return !next.block().compressable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unitOn(Tile tile, Unit unit){
|
||||
CompressedConveyorEntity entity = tile.ent();
|
||||
entity.reload = cooldown;
|
||||
if(unit instanceof CraterUnit) entity.crater = (CraterUnit)unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
CompressedConveyorEntity entity = tile.ent();
|
||||
if(entity.reload > 0) entity.reload--;
|
||||
}
|
||||
|
||||
class CompressedConveyorEntity extends ConveyorEntity{
|
||||
public int reload = 0;
|
||||
public CraterUnit crater = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
CompressedConveyorEntity entity = tile.ent();
|
||||
|
||||
if(!start(tile)) return false;
|
||||
if(entity.crater == null || entity.crater.dead || !entity.crater.loading() || entity.crater.on() != tile){
|
||||
if(entity.reload > 0) return false;
|
||||
entity.reload = cooldown;
|
||||
entity.crater = (CraterUnit)UnitTypes.crater.create(tile.getTeam());
|
||||
entity.crater.set(tile.drawx(), tile.drawy());
|
||||
entity.crater.rotation = tile.rotation() * 90;
|
||||
entity.crater.add();
|
||||
Events.fire(new UnitCreateEvent(entity.crater));
|
||||
}
|
||||
|
||||
if(entity.crater.item().amount > 0 && entity.crater.item().item != item) return false;
|
||||
if(entity.crater.item().amount >= entity.crater.getItemCapacity()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
CompressedConveyorEntity entity = tile.ent();
|
||||
|
||||
entity.crater.item().item = item;
|
||||
entity.crater.item().amount++;
|
||||
entity.crater.inactivity = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleStack(Item item, int amount, Tile tile, Unit source){
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
private static ItemPos pos2 = new ItemPos();
|
||||
private final Vec2 tr1 = new Vec2();
|
||||
private final Vec2 tr2 = new Vec2();
|
||||
private TextureRegion[][] regions = new TextureRegion[7][4];
|
||||
protected TextureRegion[][] regions = new TextureRegion[7][4];
|
||||
|
||||
public float speed = 0f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user