mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-24 13:39:03 +07:00
Door chaining / p l a s t a n i u m b l e n d i n g
This commit is contained in:
parent
b8d1f66653
commit
b672d79dd7
@ -4,6 +4,7 @@ import arc.Graphics.*;
|
||||
import arc.Graphics.Cursor.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
@ -12,7 +13,7 @@ import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.pathfinder;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Door extends Wall{
|
||||
protected final static Rect rect = new Rect();
|
||||
@ -28,11 +29,14 @@ public class Door extends Wall{
|
||||
solidifes = true;
|
||||
consumesTap = true;
|
||||
|
||||
config(Boolean.class, (DoorEntity entity, Boolean open) -> {
|
||||
entity.open = open;
|
||||
pathfinder.updateTile(entity.tile());
|
||||
(open ? closefx : openfx).at(entity);
|
||||
Sounds.door.at(entity);
|
||||
config(Boolean.class, (DoorEntity base, Boolean open) -> {
|
||||
Sounds.door.at(base);
|
||||
|
||||
for(DoorEntity entity : base.chained){
|
||||
entity.open = open;
|
||||
pathfinder.updateTile(entity.tile());
|
||||
entity.effect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -43,6 +47,45 @@ public class Door extends Wall{
|
||||
|
||||
public class DoorEntity extends Building{
|
||||
public boolean open = false;
|
||||
public ObjectSet<DoorEntity> chained = new ObjectSet<>();
|
||||
|
||||
@Override
|
||||
public void onProximityAdded(){
|
||||
super.onProximityAdded();
|
||||
updateChained();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityRemoved(){
|
||||
super.onProximityRemoved();
|
||||
|
||||
for(Building b : proximity){
|
||||
if(b instanceof DoorEntity){
|
||||
((DoorEntity)b).updateChained();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void effect(){
|
||||
(open ? closefx : openfx).at(this);
|
||||
}
|
||||
|
||||
public void updateChained(){
|
||||
chained = new ObjectSet<>();
|
||||
flow(chained);
|
||||
}
|
||||
|
||||
public void flow(ObjectSet<DoorEntity> set){
|
||||
if(!set.add(this)) return;
|
||||
|
||||
this.chained = set;
|
||||
|
||||
for(Building b : proximity){
|
||||
if(b instanceof DoorEntity){
|
||||
((DoorEntity)b).flow(set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
|
@ -57,10 +57,12 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
if(state == stateLoad){ //standard conveyor mode
|
||||
return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock);
|
||||
}else if(state == stateUnload){ //router mode
|
||||
return (otherblock.acceptsItems) &&
|
||||
return otherblock.acceptsItems &&
|
||||
(notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) ||
|
||||
(otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) &&
|
||||
!(world.build(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.build(otherx, othery)).state == stateUnload);
|
||||
!(world.build(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.build(otherx, othery)).state == stateUnload) &&
|
||||
!(world.build(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.build(otherx, othery)).state == stateMove &&
|
||||
!facing(otherx, othery, otherrot, tile.x, tile.y));
|
||||
}
|
||||
}
|
||||
return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock) && otherblock instanceof StackConveyor;
|
||||
|
Loading…
Reference in New Issue
Block a user