Because Sharing Is Fun in Off Topic
|
|
[Edited for improved version]
proc/SouthTo8DirIcon() var/icon/baseIcon = new() var/icon/changeIcon var/icon/changeIconDiag for (var/thisState in icon_states(icon))
changeIcon = icon(icon,thisState) baseIcon.Insert(changeIcon,icon_state=thisState,dir=SOUTH) changeIcon.Turn(90) baseIcon.Insert(changeIcon,icon_state=thisState,dir=WEST) changeIcon.Turn(90) baseIcon.Insert(changeIcon,icon_state=thisState,dir=NORTH) changeIcon.Turn(90) baseIcon.Insert(changeIcon,icon_state=thisState,dir=EAST) changeIcon.Turn(90) changeIcon.Shift(NORTH,1) changeIconDiag = icon(icon,thisState) changeIconDiag.Blend(changeIcon,ICON_OVERLAY) changeIconDiag.Turn(45) baseIcon.Insert(changeIconDiag,icon_state=thisState,dir=SOUTHWEST) changeIconDiag.Turn(90) baseIcon.Insert(changeIconDiag,icon_state=thisState,dir=NORTHWEST) changeIconDiag.Turn(90) baseIcon.Insert(changeIconDiag,icon_state=thisState,dir=NORTHEAST) changeIconDiag.Turn(90) baseIcon.Insert(changeIconDiag,icon_state=thisState,dir=SOUTHEAST) icon = baseIcon
|
Seems to work like a charm. This is basically just a real quick way to build mob art assets with only a single direction mob. You can animate them with all the fancy icon_states you want, and it'll go through nicely.
An even more advanced way to do it is just keep a single-facing icon as it is and .turn it whenever the icon facing updates. You should be able to have icons that face in directions far more refined than just the 8 cardinal directions.
However, that is a bit heavier in terms of processing cost - the icons produced by the example code here are pretty much native BYOND handling. An even more efficient way to do it is to construct the icon only once, and then reference or copy them from a master copy every time a new mob of that type comes about.
|
Nice.