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

Extensions for GameObject, Transform, and String to provide convience methods #416

Merged
merged 28 commits into from
Nov 18, 2023

Conversation

searica
Copy link
Contributor

@searica searica commented Nov 17, 2023

I had originally intended to break these into a few smaller PRs but since the goal is a release this weekend I merged them into a single PR. In general each commit corresponds to a set of related extension methods for each class and explains the rationale behind adding those methods, so that it's hopefully easier to accept/reject whatever subset of extensions are judged to be appropriate for Jotunn.

…improve readability of code or force null result to be a bool instead
… instance of any one of the given components
… component. Intended to improve readability or force null result to a bool if needed
JotunnLib/Extensions/GameObjectExtension.cs Outdated Show resolved Hide resolved
JotunnLib/Extensions/GameObjectExtension.cs Outdated Show resolved Hide resolved
JotunnLib/Extensions/GameObjectExtension.cs Outdated Show resolved Hide resolved
JotunnLib/Extensions/GameObjectExtension.cs Outdated Show resolved Hide resolved
JotunnLib/Extensions/GameObjectExtension.cs Outdated Show resolved Hide resolved
JotunnLib/Extensions/StringExtensions.cs Outdated Show resolved Hide resolved
JotunnLib/Extensions/TransformExtensions.cs Show resolved Hide resolved
@searica
Copy link
Contributor Author

searica commented Nov 18, 2023

I've pushed a new set of changes that hopefully incorporate the feedback you gave. I'm not sure that the way I rewrote HasAllComponents to avoid null checks is the best way though.

Edit: I did some more reading on MonoBehavior and how Unity handles implicitly casting them to a bool, so I removed the counter in HasAllComponents to optimize it a bit more.

Copy link
Member

@MSchmoecker MSchmoecker left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the extensions

@MSchmoecker MSchmoecker merged commit 7e80b9b into Valheim-Modding:dev Nov 18, 2023
1 check passed
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