Skip to content

Commit

Permalink
Tin Sorter, Distributor and Flow Gate
Browse files Browse the repository at this point in the history
  • Loading branch information
Slotterleet committed Apr 26, 2024
1 parent f5e5c55 commit 2047cf7
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 6 deletions.
6 changes: 6 additions & 0 deletions res/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ block.fos-item-catapult.name = Item Catapult
block.fos-item-catapult.description = Slowly launches items to another catapult through space. Intended for transportation between asteroids.
block.fos-tin-router.name = Tin Router
block.fos-tin-router.description = Distributes input items to 3 output directions equally.
block.fos-tin-distributor.name = Tin Distributor
block.fos-tin-distributor.description = Distributes input items to 7 output directions equally.
block.fos-tin-junction.name = Tin Junction
block.fos-tin-junction.description = Acts as a bridge for two crossing conveyor belts.
block.fos-tin-sorter.name = Tin Sorter
block.fos-tin-sorter.description = If an input item matches the selection, it moves forward. Otherwise, the item is inputted to the sides.
block.fos-flow-gate.name = Flow Gate
block.fos-flow-gate.description = Has 2 toggleable modes.\nNormal Mode: Outputs items to the sides only if the front path is blocked.\nInverse Mode: Outputs items to the front only if the side paths are blocked.
block.fos-tin-bridge.name = Tin Bridge Conveyor
block.fos-tin-bridge.description = Transports items over terrain or buildings.
block.fos-tin-belt.name = Tin Belt
Expand Down
6 changes: 6 additions & 0 deletions res/bundles/bundle_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ block.fos-item-catapult.name = Предметная катапульта
block.fos-item-catapult.description = Медленно запускает предметы в другую катапульту через космос. Предназначена для перевозки между астероидами.
block.fos-tin-router.name = Оловянный маршрутизатор
block.fos-tin-router.description = Равномерно распределяет входящие предметы по 3 выходящим направлениям.
block.fos-tin-distributor.name = Оловянный распределитель
block.fos-tin-distributor.description = Равномерно распределяет входящие предметы по 7 выходящим направлениям.
block.fos-tin-junction.name = Оловянный перекресток
block.fos-tin-junction.description = Действует как мост для двух пересекающихся конвейерных лент.
block.fos-tin-sorter.name = Оловянный сортировщик
block.fos-tin-sorter.description = Если входящий предмет совпадает с выбором, то он проходит вперед. Если нет, то предмет выводится в стороны.
block.fos-flow-gate.name = Избыточный вентиль
block.fos-flow-gate.description = Имеет 2 переключаемых режима работы.\nОбычный режим: Выводит предметы по бокам, только если передний путь заблокирован.\nОбратный режим: Выводит предметы вперед, только если боковые пути заблокированы.
block.fos-tin-bridge.name = Оловянный мостовой конвейер
block.fos-tin-bridge.description = Перемещает предметы над местностью или зданиями.
block.fos-tin-belt.name = Оловянная лента
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/sprites/blocks/distribution/flow-gate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/sprites/blocks/distribution/tin-distributor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/sprites/blocks/distribution/tin-junction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/sprites/blocks/distribution/tin-router.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/sprites/blocks/distribution/tin-sorter-cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/sprites/blocks/distribution/tin-sorter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion src/fos/content/FOSBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class FOSBlocks {
oreDetectorSmall, oreDetector, oreDetectorReinforced, oreDetectorOverclocked,

// DISTRIBUTION
spaceDuct, spaceRouter, spaceBridge, itemCatapult, tinRouter, tinJunction, tinBridge, tinBelt, liquidConveyor,
spaceDuct, spaceRouter, spaceBridge, itemCatapult, tinRouter, tinDistributor, tinJunction, tinBridge, tinBelt, tinSorter, flowGate, liquidConveyor,

// FLUIDS
fluidPipe, pumpjack,
Expand Down Expand Up @@ -1199,6 +1199,19 @@ diamond, new MissileBulletType(5f, 5){{
researchCost = with(tin, 90);
requirements(Category.distribution, with(tin, 3));
}};
tinDistributor = new Router("tin-distributor"){{
size = 2;
researchCost = with(tin, 120);
requirements(Category.distribution, with(tin, 4));
}};
tinSorter = new Sorter("tin-sorter"){{
researchCost = with(tin, 60, silver, 60);
requirements(Category.distribution, with(tin, 2, silver, 2));
}};
flowGate = new FlowGate("flow-gate"){{
researchCost = with(tin, 60, silver, 60);
requirements(Category.distribution, with(tin, 2, silver, 2));
}};
tinBridge = new BufferedItemBridge("tin-bridge"){{
fadeIn = moveArrows = false;
range = 4;
Expand Down
14 changes: 9 additions & 5 deletions src/fos/content/LumoniTechTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ public static void load() {
);

// TRANSPORT. TODO
node(tinBelt, () -> {
node(tinJunction, () -> {
node(tinBelt, () ->
node(tinJunction, () ->
node(tinRouter, () -> {
node(tinDistributor);
node(tinSorter, () ->
node(flowGate)
);
node(tinBridge);
});
});
});
})
)
);

// POWER. TODO
node(windTurbine, () -> {
Expand Down
94 changes: 94 additions & 0 deletions src/fos/type/blocks/distribution/FlowGate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package fos.type.blocks.distribution;

import arc.Core;
import arc.audio.Sound;
import arc.graphics.g2d.*;
import arc.math.Mathf;
import arc.util.Nullable;
import arc.util.io.*;
import mindustry.gen.*;
import mindustry.type.Item;
import mindustry.world.blocks.distribution.OverflowGate;

public class FlowGate extends OverflowGate {
public TextureRegion inverseRegion;
public Sound clickSound = Sounds.click;

public FlowGate(String name) {
super(name);
configurable = true;
update = true;

config(Boolean.class, (FlowGateBuild entity, Boolean b) -> entity.inverse = b);
}

@Override
public void load() {
super.load();
inverseRegion = Core.atlas.find(name + "-inverse");
}

@Override
public void setBars() {
super.setBars();
removeBar("items");
}

public class FlowGateBuild extends OverflowGateBuild {
public boolean inverse = false;

@Override
public void draw() {
Draw.rect(inverse ? inverseRegion : region, x, y);
}

@Override
public boolean configTapped() {
configure(!inverse);
clickSound.at(this);
return false;
}

public @Nullable Building getTileTarget(Item item, Building src, boolean flip){
int from = relativeToEdge(src.tile);
if(from == -1) return null;
Building to = nearby((from + 2) % 4);
boolean
fromInst = src.block.instantTransfer,
canForward = to != null && to.team == team && !(fromInst && to.block.instantTransfer) && to.acceptItem(this, item),
inv = inverse;

if(!canForward || inv){
Building a = nearby(Mathf.mod(from - 1, 4));
Building b = nearby(Mathf.mod(from + 1, 4));
boolean ac = a != null && !(fromInst && a.block.instantTransfer) && a.team == team && a.acceptItem(this, item);
boolean bc = b != null && !(fromInst && b.block.instantTransfer) && b.team == team && b.acceptItem(this, item);

if(!ac && !bc){
return inv && canForward ? to : null;
}

if(ac && !bc){
to = a;
}else if(bc && !ac){
to = b;
}else{
to = (rotation & (1 << from)) == 0 ? a : b;
if(flip) rotation ^= (1 << from);
}
}

return to;
}

@Override
public void write(Writes write) {
write.bool(inverse);
}

@Override
public void read(Reads read, byte revision) {
inverse = read.bool();
}
}
}

0 comments on commit 2047cf7

Please sign in to comment.