Add GetPixel() for Icon#2524
Open
Sorrowfulwinds wants to merge 7 commits intoOpenDreamProject:masterfrom
Open
Conversation
prototype frame out
Near finish need to verify with an A-B test byond-opendream
wixoaGit
requested changes
Mar 6, 2026
| DreamIcon iconObj = ((DreamObjectIcon)src!).Icon; | ||
| //TODO BYONDISM: A non-existent icon_state will default to the empty string icon_state, | ||
| //or if one doesn't exist it will default to the first icon_state in the DMI. | ||
| if(!iconObj.States.TryGetValue(iconState ?? string.Empty, out var state)) |
Member
There was a problem hiding this comment.
Using DreamIcon.States is going to get you the textures before any sort of modifications like /icon.Blend() are applied. You need to use the result of iconObj.GenerateDMI() to get the final DMI.
Comment on lines
+144
to
+156
| AtomDirection atomDir = dir switch { | ||
| 0 or 2 => AtomDirection.South, | ||
| 1 => AtomDirection.North, | ||
| 4 => AtomDirection.East, | ||
| 5 => AtomDirection.Northeast, | ||
| 6 => AtomDirection.Southeast, | ||
| 8 => AtomDirection.West, | ||
| 9 => AtomDirection.Northwest, | ||
| 10 => AtomDirection.Southwest, | ||
| _ => AtomDirection.None | ||
| }; | ||
| //BYONDISM: Bad dir values just crash instantly :) | ||
| if (atomDir == AtomDirection.None) return DreamValue.Null; |
Member
There was a problem hiding this comment.
You can cast the value instead of having a switch
Suggested change
| AtomDirection atomDir = dir switch { | |
| 0 or 2 => AtomDirection.South, | |
| 1 => AtomDirection.North, | |
| 4 => AtomDirection.East, | |
| 5 => AtomDirection.Northeast, | |
| 6 => AtomDirection.Southeast, | |
| 8 => AtomDirection.West, | |
| 9 => AtomDirection.Northwest, | |
| 10 => AtomDirection.Southwest, | |
| _ => AtomDirection.None | |
| }; | |
| //BYONDISM: Bad dir values just crash instantly :) | |
| if (atomDir == AtomDirection.None) return DreamValue.Null; | |
| //BYONDISM: Bad dir values just crash instantly :) | |
| if (!Enum.IsDefined(typeof(AtomDirection), dir)) return DreamValue.Null; | |
| var atomDir = (AtomDirection)dir; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds proc/GetPixel(x, y, icon_state, dir = 0, frame = 0, moving = -1) for #2194.
It has 2 TODOs that cannot be implemented currently:
-The moving var does nothing as OD does not currently track that variable from DMI's
-If icon_state is not in the icon BYOND will either pull the empty string/null icon_state by default or if one does not exist it will pull the first icon_state in the dmi. OD does not track this so it only defaults to checking for an empty string state before failing.
Vars:
X&Y - Must be >1 and less than the max dimension +1 of the icon_state.
icon_state - Must be a string.
dir - Must be a valid integer of dirs N E S W NE NW SE SW (1,2,4,5,6,8,9,10) or 0. 0 counts as South.
frame - Values less than 1 count as 1. Must be less than the total frames +1 of the icon_state.
moving - not implemented