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

Use GetDerivedNonAbstract for CharacterAbilityGroup::ConstructCondition #186

Open
1 of 2 tasks
G-M-twostay opened this issue Jan 24, 2024 · 3 comments
Open
1 of 2 tasks
Assignees
Labels
feature New feature or request

Comments

@G-M-twostay
Copy link

Disclaimers

  • I have searched the issue tracker to check if the issue has already been reported.
  • My issue happened while using mods.

What happened?

In the current implementation it uses conditionType = Type.GetType("Barotrauma.Abilities." + type + "", false, true); to find the type of AbilityCondition. However, this is very hard coded and makes extending AbilityConditions, for example adding own new types of AbilityConditions, extremely hard. This is also not consistent with other places like AfflictionPrefab and ItemComponent, where both uses ReflectionUtils.GetDerivedNonAbstract. You may search "GetDerivedNonAbstract" to verify its usages. Given that lua for baro modifies this method to also include modded assemblies with the purposes of making the game more extendable, AbilityCondition should also be constructed using this method.

Therefore the change I propose to change the hard coded Type.GetType line to ReflectionUtils.GetDerivedNonAbstract<AbilityCondition>().First() (or smth like this). This should not change XML behaviors as all vanilla AbilityConditions are subclasses of AbilityCondition with the benefit of making creating new ones way more easier.

Reproduction steps

Problem described above.

Bug prevalence

Just once

Single player or multiplayer?

Single player

-

No response

Version

v1.2.8.0 (Winter Update hotfix 2)

-

No response

Which operating system did you encounter this bug on?

Windows

Relevant error messages and crash reports

No response

@evilfactory evilfactory added the feature New feature or request label Jan 24, 2024
@evilfactory
Copy link
Owner

If you could make a PR with the changes and do some basic QA (make sure it doesn't break anything), it would be nice.

@G-M-twostay
Copy link
Author

i will try to do some qa, but I haven't compiled baro before.

@MapleWheels
Copy link
Collaborator

This will be addressed in the Services Refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants