Using layers to combine sprites with a shift fails for multiple directions

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 492
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Using layers to combine sprites with a shift fails for multiple directions

Post by Silari »

So I'm trying to fix some minor things in Modular Buildings, and that means I need to create a new corpse for the multi buildings so there isn't just a single remnant thrown into the center of the building, and fix the water_reflection so there isn't just a single reflection.

Easiest way seemed to be to just make a new corpse with the existing remnant with a layer for each building - no need to make new graphical assets for everything, just add layers with a shift to get them placed properly. This is actually how the modular buildings are setup. Unfortunately, corpses and water reflections use a single Types/RotatedAnimation instead of separate horizontal_animation and vertical_animation that the Generator type uses, and the shift part doesn't work when rotated - it's always shifted in the same direction. Anyone know if there's a way to define this so it works properly whether North/South or East/West? I've tried making animation an array, but that just seems to define variations, not directions.

Works fine East/West but not North/South
Works fine East/West but not North/South
layered.png (1.65 MiB) Viewed 1171 times

Code: Select all

    ["steam-turbine-remnants"] = {
      animation = {
          layers = {
            {
              axially_symmetrical = false,
              direction_count = 4,
              filename = "__base__/graphics/entity/steam-turbine/remnants/steam-turbine-remnants.png",
              frame_count = 1,
              height = 204,
              hr_version = {
                axially_symmetrical = false,
                direction_count = 4,
                filename = "__base__/graphics/entity/steam-turbine/remnants/hr-steam-turbine-remnants.png",
                frame_count = 1,
                height = 408,
                line_length = 1,
                scale = 0.5,
                shift = {
                  0.1875+2.5,
                  0
                },
                variation_count = 1,
                width = 460,
                y = 0
              },
              line_length = 1,
              shift = {
                0.1875+2.5,
                0
              },
              variation_count = 1,
              width = 230,
              y = 0
            },
            {
              axially_symmetrical = false,
              direction_count = 4,
              filename = "__base__/graphics/entity/steam-turbine/remnants/steam-turbine-remnants.png",
              frame_count = 1,
              height = 204,
              hr_version = {
                axially_symmetrical = false,
                direction_count = 4,
                filename = "__base__/graphics/entity/steam-turbine/remnants/hr-steam-turbine-remnants.png",
                frame_count = 1,
                height = 408,
                line_length = 1,
                scale = 0.5,
                shift = {
                  0.1875-2.5,
                  0
                },
                variation_count = 1,
                width = 460,
                y = 0
              },
              line_length = 1,
              shift = {
                0.1875-2.5,
                0
              },
              variation_count = 1,
              width = 230,
              y = 0
            }
          }
      },
      final_render_layer = "remnants",
      flags = {
        "placeable-neutral",
        "not-on-map"
      },
      icon = "__base__/graphics/icons/steam-turbine.png",
      icon_mipmaps = 4,
      icon_size = 64,
      localised_name = {
        "remnant-name",
        {
          "entity-name.steam-turbine"
        }
      },
      name = "double-steam-turbine-remnants",
      order = "a-h-a",
      remove_on_tile_placement = false,
      selectable_in_game = false,
      selection_box = {
        {
          -1.5,
          -2.5
        },
        {
          1.5,
          2.5
        }
      },
      subgroup = "energy-remnants",
      tile_height = 5,
      tile_width = 3,
      time_before_removed = 54000,
      type = "corpse"
    }
It's a minor thing but I'd prefer it look correct, and if I want to support a modular <anything that isn't a Generator/assembler> I'd need to get this layering working anyway.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Using layers to combine sprites with a shift fails for multiple directions

Post by DaveMcW »

Silari wrote:
Sat Jun 26, 2021 8:19 pm
the shift part doesn't work when rotated
You can always make a modding interface request to support it.

An alternative is to never rotate corpses, just make one corpse for each direction.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 492
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Using layers to combine sprites with a shift fails for multiple directions

Post by Silari »

I'm not rotating anything, the game does it to match the orientation of the building that was destroyed. And I can't make the request to add something unless I know it can't already be done, hence this thread.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Using layers to combine sprites with a shift fails for multiple directions

Post by DaveMcW »

Silari wrote:
Sun Jun 27, 2021 2:18 am
I'm not rotating anything, the game does it to match the orientation of the building that was destroyed.
Then listen to on_post_entity_died and undo the game's rotation.

Post Reply

Return to “Modding discussion”