Skip to content

Added support for animated items to the map#170

Open
Rhoenicx wants to merge 2 commits into
JavidPack:1.4.4from
Rhoenicx:1.4.4
Open

Added support for animated items to the map#170
Rhoenicx wants to merge 2 commits into
JavidPack:1.4.4from
Rhoenicx:1.4.4

Conversation

@Rhoenicx

Copy link
Copy Markdown

Players of Gensokyo mod reported that the item animations of the bossbags were not displayed correctly on the minimap. The entire spritesheet is visible instead of the frame specified inside the ItemAnimation class. Added compatibility for ItemAnimations.

Comment thread MapHelper.cs Outdated

// Support for item animations.
if (ItemID.Sets.AnimatesAsSoul[item.type]) {
Rectangle itemFrame = Main.itemAnimations[item.type].GetFrame(itemTexture);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should just be Rectangle itemFrame = Main.itemAnimations[item.type]?.GetFrame(itemTexture) ?? itemTexture.Frame();. An item with an animation doesn't necessarily set ItemID.Sets.AnimatesAsSoul

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this is the proper solution. I was convinced ItemID.Sets.AnimatesAsSoul was needed for the item animation. I see Terraria gets the frame the same way like you suggested. I'll make an update.

Changed the draw code based on  the suggestion of JavidPack: replaced ItemID.Sets.AnimatesAsSoul with Main.GetItemDrawFrame. Also added safeguards against dividing by zero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants