I have been trying to turn a object around while it was 4 or more overlays . Whenever turned the overlays are not being properly turned , and are instead more to the NORTH/SOUTH of the sprite , when they are supposed to be in the exact middle.
Numbered Steps to Reproduce Problem:
1.Create a object with multiple overlays that have an offset
2.Create a matrix and turn the object
Code Snippet (if applicable) to Reproduce Problem:
The code turning the obj
/// Visually shows that the floodlight has been tipped and breaks all the lights in it.
/obj/machinery/floodlightcombat/proc/tip_over()
for(var/obj/item/light_bulb/tube/T in contents)
T.status = 2
update_icon()
density = FALSE
tipped = 1
transform = turn( NORTH, 90)
The code handling overlays
/obj/machinery/floodlightcombat/update_overlays()
. = ..()
var/offsetX
var/offsetY
/// Used to define which slot is targeted on the sprite and then adjust the overlay.
var/target_slot = 1
for(var/obj/item/light_bulb/tube/target in contents)
switch(target_slot)
if(1)
offsetX = 0
offsetY = 0
if(2)
offsetX = 6
offsetY = 0
if(3)
offsetX = 0
offsetY = 5
if(4)
offsetX = 6
offsetY = 5
. += image('icons/obj/machines/floodlight.dmi', src, "floodlightcombat_[target.status ? "brokenlight" : "workinglight"]", ABOVE_OBJ_LAYER, NORTH, offsetX, offsetY)
target_slot++
Expected Results:
All the overlays being properly turned
Actual Results:
All overlays shift upwards.
Does the problem occur:
Every time? Or how often?
Everytime i tried.
In other games?
Unknown , but it has happened in SS13 TGMC codebase.
When does the problem NOT occur?
Always occurs.
A photo of the issue if it helps.
https://imgur.com/a/MtXfVTn
The pixel offsets you're using for the floodlight also will not turn with the icon. The correct way to handle this would be to give the floodlight image a transform that adds those as a translation matrix instead of setting pixel_x/y offsets. Or, you could apply KEEP_TOGETHER to the parent. Which version is preferable depends on your use case.