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

Adds the DifficultyAPI #74

Merged
merged 4 commits into from
Nov 11, 2019
Merged

Adds the DifficultyAPI #74

merged 4 commits into from
Nov 11, 2019

Conversation

harbingerofme
Copy link
Collaborator

@harbingerofme harbingerofme commented Nov 9, 2019

Used for adding difficulties. This design can probably be generalized to all rule sections.
Because the Difficulty array is in static class as a static readonly array, modifying it is hard. Future patches might change this to a nonreadonly array, as said by Ghor. I'll keep an eye out.
Use:

DifficultyDef myDifficultyDef = new DifficultyDef(myScalingFactor /*(1f=drizzle,2f=rainstorm,3f=monsoon)*/, myNameToken, myIconPath, myDescriptionToken, hoverOverColor);
DifficultyIndex myDifficultyIndex = R2API.DifficultyAPI.AddDifficulty(myDifficultyDef);//pretend this is actual declared inside the valid scope
// Then at any point later you can 
if(Run.Instance && Run.Instance.selectedDifficulty == myDifficultyIndex)
{
//cool code that only happens in your difficulty here.
}

@tristanmcpherson tristanmcpherson merged commit aa29df6 into risk-of-thunder:master Nov 11, 2019
@tristanmcpherson
Copy link
Member

Nice! Looks good to me :)

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