Page 1 of 1

Turn on/off rendering of all entities with a specific flag/name/whatever

Posted: Wed Feb 20, 2019 6:16 am
by blankdiploma
Hello,

I am working on a mod that implements different layers of resources (e.g. shallow/mid/deep ore mining.)

I would like to be able to offer the player a way to switch between viewing different "depths" of ore deposits so that the screen isn't too cluttered at any given time, which means I need to be able to toggle on/off the visibility of entire classes of entity in a way that will not absolutely trash performance (so no iterating over the entire map and swapping out all ore entities for different ones...)

I would prefer this to be based off of a flag on the prototype, or the name of a prototype, or something like that - would it be possible to implement such a feature? Something like a RenderLayer that can be enabled/disabled from the GameScript or Surface would work just fine.

Re: Turn on/off rendering of all entities with a specific flag/name/whatever

Posted: Wed Feb 20, 2019 7:44 am
by blankdiploma
So on further reading, there already is a "renderlayer" property but it's only customizeable for decoratives.

So, I guess what I'm really asking for is:

1) Moddable Render Layer for resource entities
2) API call to hide everything in a given render layer

Thank you!

Re: Turn on/off rendering of all entities with a specific flag/name/whatever

Posted: Wed Feb 20, 2019 9:17 am
by Bilka
All of the things that you are requesting are very unlikely to be added, so I want to explain some alternatives for you. You could use the script rendering to draw all the resources and use the ability of the script rendering to only be rendered to who you want. This will be a bit janky because it means that the actual resource entity has to be invisible, so it shows as invisible when the player selects it. However, it is basically the only way that you can currently (in 0.17) implement conditional rendering. I hope this will work for you.

PS: A lot more things than decoratives can have custom render layers. See https://wiki.factorio.com/Special:WhatL ... enderLayer

Re: Turn on/off rendering of all entities with a specific flag/name/whatever

Posted: Wed Feb 20, 2019 6:05 pm
by blankdiploma
I expected a "not likely" reply, so I've been formulating a backup plan that's similar to what you're describing :)

Thank you for taking the time to reply, nonetheless!