diff --git a/FactorioBlueprintStringRenderer/src/com/demod/fbsr/EntityRendererFactory.java b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/EntityRendererFactory.java index dfb8bf5..06288e1 100644 --- a/FactorioBlueprintStringRenderer/src/com/demod/fbsr/EntityRendererFactory.java +++ b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/EntityRendererFactory.java @@ -57,6 +57,7 @@ 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; @@ -188,6 +189,7 @@ 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()); diff --git a/FactorioBlueprintStringRenderer/src/com/demod/fbsr/entity/LinkedBeltRendering.java b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/entity/LinkedBeltRendering.java new file mode 100644 index 0000000..172fbe3 --- /dev/null +++ b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/entity/LinkedBeltRendering.java @@ -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 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)); + } +}