Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixes dupe property copying. Adds IgnoreDupe #1811

Merged
merged 5 commits into from
Jun 2, 2024

Conversation

kamronbatman
Copy link
Contributor

@kamronbatman kamronbatman commented May 31, 2024

Summary

Changes

  • Adds [IgnoreDupe] and [SerializedIgnoreDupe]
  • Updates all known classes that need the attribute. Some might be missing, please helps us find them!
  • Adds Item.Dupe() command and encapsulates CopyProperties and OnAfterDuped. This is also overridable.
  • Updates Dupe command to use the new logic.
  • Fixes duping multiple kinds of objects that used to be outright broken.

Bug Fixes

  • Fixes issue with durability after duping
  • Fixes issue with hue after duping

Note

Developer Note
Customizing how duping an item works now requires two steps:

  1. Add [IgnoreDupe] or [SerializedIgnoreDupe] to the property/field
  2. Add custom logic in an OnAfterDuped override

When do you need to do this?
When the property being copied is not a primitive, and you need to manually deep-clone the contents of the property such as with Lists, Dictionaries, or sub classes.

@kamronbatman kamronbatman requested a review from Mink80 May 31, 2024 22:48
Comment on lines -542 to -548
book.Content = _content;
book.SpellCount = _spellCount;
book.Slayer = _slayer;
book.Slayer2 = _slayer2;
book.Quality = _quality;
book.EngravedText = _engravedText;
book.Crafter = _crafter;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed primitives that were copied afterwards that didn't need to be.

@kamronbatman kamronbatman merged commit 9c7cb5d into main Jun 2, 2024
12 of 13 checks passed
@kamronbatman kamronbatman deleted the kbatman/fix_dupe branch June 2, 2024 22:04
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.

None yet

1 participant