mirror of
https://github.com/demodude4u/Factorio-FBSR.git
synced 2025-01-26 18:58:00 +02:00
commit
048ab592e6
@ -57,6 +57,8 @@ import com.demod.fbsr.entity.InserterRendering;
|
||||
import com.demod.fbsr.entity.LabRendering;
|
||||
import com.demod.fbsr.entity.LampRendering;
|
||||
import com.demod.fbsr.entity.LandMineRendering;
|
||||
import com.demod.fbsr.entity.LinkedBeltRendering;
|
||||
import com.demod.fbsr.entity.LinkedContainerRendering;
|
||||
import com.demod.fbsr.entity.LoaderRendering;
|
||||
import com.demod.fbsr.entity.LogisticContainerRendering;
|
||||
import com.demod.fbsr.entity.MiningDrillRendering;
|
||||
@ -187,6 +189,8 @@ public class EntityRendererFactory {
|
||||
byType.put("loader-1x1", new LoaderRendering());
|
||||
byType.put("locomotive", new RollingStockRendering());
|
||||
byType.put("logistic-container", new LogisticContainerRendering());
|
||||
byType.put("linked-belt", new LinkedBeltRendering());
|
||||
byType.put("linked-container", new LinkedContainerRendering());
|
||||
byType.put("mining-drill", new MiningDrillRendering());
|
||||
byType.put("offshore-pump", new OffshorePumpRendering());
|
||||
byType.put("pipe", new PipeRendering());
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.demod.fbsr.entity;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.demod.factorio.DataTable;
|
||||
import com.demod.factorio.prototype.EntityPrototype;
|
||||
import com.demod.fbsr.BlueprintEntity;
|
||||
import com.demod.fbsr.Direction;
|
||||
import com.demod.fbsr.EntityRendererFactory;
|
||||
import com.demod.fbsr.RenderUtils;
|
||||
import com.demod.fbsr.Renderer;
|
||||
import com.demod.fbsr.Renderer.Layer;
|
||||
import com.demod.fbsr.Sprite;
|
||||
import com.demod.fbsr.WorldMap;
|
||||
import com.demod.fbsr.WorldMap.BeltBend;
|
||||
|
||||
public class LinkedBeltRendering extends EntityRendererFactory {
|
||||
@Override
|
||||
public void createRenderers(Consumer<Renderer> register, WorldMap map, DataTable dataTable, BlueprintEntity entity,
|
||||
EntityPrototype prototype) {
|
||||
boolean input = entity.json().getString("type").equals("input");
|
||||
Direction structDir = input ? entity.getDirection() : entity.getDirection().back();
|
||||
|
||||
Sprite beltSprite = TransportBeltRendering.getBeltSprite(prototype, entity.getDirection(), BeltBend.NONE);
|
||||
|
||||
Sprite sprite = RenderUtils.getSpriteFromAnimation(
|
||||
prototype.lua().get("structure").get(input ? "direction_in" : "direction_out").get("sheet"));
|
||||
sprite.source.x += sprite.source.width * (structDir.cardinal());
|
||||
|
||||
register.accept(RenderUtils.spriteRenderer(Layer.ENTITY, beltSprite, entity, prototype));
|
||||
register.accept(RenderUtils.spriteRenderer(Layer.ENTITY2, sprite, entity, prototype));
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.demod.fbsr.entity;
|
||||
|
||||
import com.demod.fbsr.EntityRendererFactory;
|
||||
|
||||
public class LinkedContainerRendering extends EntityRendererFactory {
|
||||
}
|
@ -106,30 +106,52 @@ public class LoaderRendering extends EntityRendererFactory {
|
||||
Point2D.Double inPos = new Point2D.Double(pos.x + beltShift.x, pos.y + beltShift.y);
|
||||
Point2D.Double outPos = new Point2D.Double(pos.x + containerShift.x, pos.y + containerShift.y);
|
||||
|
||||
setLogisticMove(map, inPos, dir.frontLeft(), dir);
|
||||
setLogisticMove(map, inPos, dir.frontRight(), dir);
|
||||
setLogisticMove(map, inPos, dir.backLeft(), dir);
|
||||
setLogisticMove(map, inPos, dir.backRight(), dir);
|
||||
setLogisticMoveAndAcceptFilter(map, inPos, dir.frontLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, inPos, dir.frontRight(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, inPos, dir.backLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, inPos, dir.backRight(), dir, dir);
|
||||
|
||||
addLogisticWarp(map, inPos, dir.back().backLeft(), outPos, dir);
|
||||
addLogisticWarp(map, inPos, dir.back().backRight(), outPos, dir);
|
||||
map.getOrCreateLogisticGridCell(dir.back().backLeft().offset(inPos, 0.25)).setBlockWarpFromIfMove(true);
|
||||
map.getOrCreateLogisticGridCell(dir.back().backRight().offset(inPos, 0.25)).setBlockWarpFromIfMove(true);
|
||||
if (beltShift.x != 0 || beltShift.y != 0) { // don't do this for 1x1 loaders
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.frontLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.frontRight(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.backLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.backRight(), dir, dir);
|
||||
}
|
||||
|
||||
// don't sideload on the output(chest) end of the loader either
|
||||
setLogisticAcceptFilter(map, outPos, dir.back().frontLeft(), dir);
|
||||
setLogisticAcceptFilter(map, outPos, dir.back().frontRight(), dir);
|
||||
|
||||
addLogisticWarp(map, outPos, dir.back().frontLeft(), outPos, dir);
|
||||
addLogisticWarp(map, outPos, dir.back().frontRight(), outPos, dir);
|
||||
map.getOrCreateLogisticGridCell(dir.back().frontLeft().offset(outPos, 0.25)).setBlockWarpFromIfMove(true);
|
||||
map.getOrCreateLogisticGridCell(dir.back().frontRight().offset(outPos, 0.25)).setBlockWarpFromIfMove(true);
|
||||
|
||||
} else {
|
||||
Point2D.Double inPos = new Point2D.Double(pos.x + containerShift.x, pos.y + containerShift.y);
|
||||
Point2D.Double outPos = new Point2D.Double(pos.x + beltShift.x, pos.y + beltShift.y);
|
||||
|
||||
setLogisticMove(map, outPos, dir.frontLeft(), dir);
|
||||
setLogisticMove(map, outPos, dir.frontRight(), dir);
|
||||
setLogisticMove(map, outPos, dir.backLeft(), dir);
|
||||
setLogisticMove(map, outPos, dir.backRight(), dir);
|
||||
setLogisticMoveAndAcceptFilter(map, outPos, dir.frontLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, outPos, dir.frontRight(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, outPos, dir.backLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, outPos, dir.backRight(), dir, dir);
|
||||
|
||||
addLogisticWarp(map, inPos, dir.back(), outPos, dir.backLeft());
|
||||
addLogisticWarp(map, inPos, dir.back(), outPos, dir.backRight());
|
||||
if (beltShift.x != 0 || beltShift.y != 0) { // don't do this for 1x1 loaders
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.frontLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.frontRight(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.backLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, pos, dir.backRight(), dir, dir);
|
||||
|
||||
map.getOrCreateLogisticGridCell(dir.backLeft().offset(outPos, 0.25)).setBlockWarpToIfMove(true);
|
||||
map.getOrCreateLogisticGridCell(dir.backRight().offset(outPos, 0.25)).setBlockWarpToIfMove(true);
|
||||
// XXX really should be a filter that accepts no direction
|
||||
setLogisticMoveAndAcceptFilter(map, inPos, dir.frontLeft(), dir, dir.back());
|
||||
setLogisticMoveAndAcceptFilter(map, inPos, dir.frontRight(), dir, dir.back());
|
||||
}
|
||||
|
||||
addLogisticWarp(map, inPos, dir.back(), inPos, dir.frontLeft());
|
||||
addLogisticWarp(map, inPos, dir.back(), inPos, dir.frontRight());
|
||||
|
||||
map.getOrCreateLogisticGridCell(dir.frontLeft().offset(inPos, 0.25)).setBlockWarpToIfMove(true);
|
||||
map.getOrCreateLogisticGridCell(dir.frontRight().offset(inPos, 0.25)).setBlockWarpToIfMove(true);
|
||||
}
|
||||
|
||||
if (entity.json().has("filters") && !input) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.demod.fbsr.entity;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.demod.factorio.DataTable;
|
||||
@ -20,9 +21,11 @@ public class RailChainSignalRendering extends EntityRendererFactory {
|
||||
Sprite railSprite = RenderUtils.getSpriteFromAnimation(prototype.lua().get("rail_piece"));
|
||||
railSprite.source.x += railSprite.source.width * (entity.getDirection().ordinal());
|
||||
|
||||
Sprite sprite = RenderUtils.getSpriteFromAnimation(prototype.lua().get("animation"));
|
||||
sprite.source.y += sprite.source.height * (entity.getDirection().ordinal());
|
||||
sprite.source.x += sprite.source.width * (3);
|
||||
List<Sprite> sprites = RenderUtils.getSpritesFromAnimation(prototype.lua().get("animation"));
|
||||
for (Sprite sprite : sprites) {
|
||||
sprite.source.y += sprite.source.height * (entity.getDirection().ordinal());
|
||||
sprite.source.x += sprite.source.width * (3);
|
||||
}
|
||||
|
||||
// XXX This is a straight up hack
|
||||
Direction shiftDir = entity.getDirection().right();
|
||||
@ -33,11 +36,10 @@ public class RailChainSignalRendering extends EntityRendererFactory {
|
||||
}
|
||||
railSprite.bounds.x += shift.x;
|
||||
railSprite.bounds.y += shift.y;
|
||||
sprite.bounds.x += shift.x;
|
||||
sprite.bounds.y += shift.y;
|
||||
RenderUtils.shiftSprites(sprites, shift);
|
||||
|
||||
register.accept(RenderUtils.spriteRenderer(railSprite, entity, prototype));
|
||||
register.accept(RenderUtils.spriteRenderer(sprite, entity, prototype));
|
||||
register.accept(RenderUtils.spriteRenderer(sprites, entity, prototype));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.demod.fbsr.entity;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.demod.factorio.DataTable;
|
||||
@ -20,11 +21,13 @@ public class RailSignalRendering extends EntityRendererFactory {
|
||||
Sprite railSprite = RenderUtils.getSpriteFromAnimation(prototype.lua().get("rail_piece"));
|
||||
railSprite.source.x += railSprite.source.width * (entity.getDirection().ordinal());
|
||||
|
||||
Sprite sprite = RenderUtils.getSpriteFromAnimation(prototype.lua().get("animation"));
|
||||
sprite.source.y += sprite.source.height * (entity.getDirection().ordinal());
|
||||
List<Sprite> sprites = RenderUtils.getSpritesFromAnimation(prototype.lua().get("animation"));
|
||||
for (Sprite sprite : sprites) {
|
||||
sprite.source.y += sprite.source.height * (entity.getDirection().ordinal());
|
||||
}
|
||||
|
||||
register.accept(RenderUtils.spriteRenderer(railSprite, entity, prototype));
|
||||
register.accept(RenderUtils.spriteRenderer(sprite, entity, prototype));
|
||||
register.accept(RenderUtils.spriteRenderer(sprites, entity, prototype));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -163,10 +163,10 @@ public class SplitterRendering extends EntityRendererFactory {
|
||||
Point2D.Double leftPos = dir.left().offset(pos, 0.5);
|
||||
Point2D.Double rightPos = dir.right().offset(pos, 0.5);
|
||||
|
||||
setLogisticMove(map, leftPos, dir.frontLeft(), dir);
|
||||
setLogisticMove(map, leftPos, dir.frontRight(), dir);
|
||||
setLogisticMove(map, rightPos, dir.frontLeft(), dir);
|
||||
setLogisticMove(map, rightPos, dir.frontRight(), dir);
|
||||
setLogisticMoveAndAcceptFilter(map, leftPos, dir.frontLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, leftPos, dir.frontRight(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, rightPos, dir.frontLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, rightPos, dir.frontRight(), dir, dir);
|
||||
|
||||
if (entity.json().has("output_priority") && entity.json().has("filter")) {
|
||||
boolean right = entity.json().getString("output_priority").equals("right");
|
||||
@ -179,17 +179,21 @@ public class SplitterRendering extends EntityRendererFactory {
|
||||
map.getOrCreateLogisticGridCell(dir.frontLeft().offset(notOutPos, 0.25)).addBannedOutput(itemName);
|
||||
map.getOrCreateLogisticGridCell(dir.frontRight().offset(notOutPos, 0.25)).addBannedOutput(itemName);
|
||||
|
||||
setLogisticMove(map, notOutPos, dir.backLeft(), dir);
|
||||
setLogisticMove(map, notOutPos, dir.backRight(), dir);
|
||||
setLogisticMoveAndAcceptFilter(map, notOutPos, dir.backLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, notOutPos, dir.backRight(), dir, dir);
|
||||
|
||||
addLogisticWarp(map, outPos, dir.backLeft(), notOutPos, dir.frontLeft());
|
||||
addLogisticWarp(map, outPos, dir.backRight(), notOutPos, dir.frontRight());
|
||||
|
||||
// no sideloading
|
||||
setLogisticAcceptFilter(map, outPos, dir.backLeft(), dir);
|
||||
setLogisticAcceptFilter(map, outPos, dir.backRight(), dir);
|
||||
|
||||
} else {
|
||||
setLogisticMove(map, leftPos, dir.backLeft(), dir);
|
||||
setLogisticMove(map, leftPos, dir.backRight(), dir);
|
||||
setLogisticMove(map, rightPos, dir.backLeft(), dir);
|
||||
setLogisticMove(map, rightPos, dir.backRight(), dir);
|
||||
setLogisticMoveAndAcceptFilter(map, leftPos, dir.backLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, leftPos, dir.backRight(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, rightPos, dir.backLeft(), dir, dir);
|
||||
setLogisticMoveAndAcceptFilter(map, rightPos, dir.backRight(), dir, dir);
|
||||
|
||||
addLogisticWarp(map, leftPos, dir.backLeft(), rightPos, dir.frontLeft());
|
||||
addLogisticWarp(map, leftPos, dir.backRight(), rightPos, dir.frontRight());
|
||||
|
Loading…
x
Reference in New Issue
Block a user