Changing graphics of entity at runtime
Posted: Mon Dec 19, 2016 12:06 pm
Question: What is the right way to change the graphics of an entity at runtime?
Context: The Bottleneck mod decorates different elements in the factory with a light each, indicating the state of the assembler/drill/furnace/whatever, with different colors for running/starved/congested. Currently, this is done by having different prototypes for each color of light. When the light changes, the old light is destroyed, and a new light is created with the right color. This seems wasteful to me, since the only difference between the old and the new is the graphics. Optimally, I would want something like the normal colored lamps, but it seems like those are tied very intimately into the game engine. The only thing I knew how to do was the destroy/create new cycle, but I hope there is a better way. Thoughts?
Context: The Bottleneck mod decorates different elements in the factory with a light each, indicating the state of the assembler/drill/furnace/whatever, with different colors for running/starved/congested. Currently, this is done by having different prototypes for each color of light. When the light changes, the old light is destroyed, and a new light is created with the right color. This seems wasteful to me, since the only difference between the old and the new is the graphics. Optimally, I would want something like the normal colored lamps, but it seems like those are tied very intimately into the game engine. The only thing I knew how to do was the destroy/create new cycle, but I hope there is a better way. Thoughts?