Skip to content

ExperienceRequiredForLevel optimization#30

Open
Kusko25 wants to merge 1 commit intoVanilla-Expanded:mainfrom
Kusko25:main
Open

ExperienceRequiredForLevel optimization#30
Kusko25 wants to merge 1 commit intoVanilla-Expanded:mainfrom
Kusko25:main

Conversation

@Kusko25
Copy link

@Kusko25 Kusko25 commented Jul 11, 2025

I notice a visible performance hit when my pawns were meditating and decided to look into it a bit.
The way I understand it every tick a pawn is meditating it calls GainExperience -> ExperienceRequiredForLevel, which recursively calls itself 'level' times to produce the answer. Ideally that result should be cached so the calculation only needs to be made once, but I don't know enough about c# to do that, so instead I reduced it to two math operations and removed the recursion.

This is my first time having a deeper look at Rimworld c# modding, so I couldn't test this and don't know if it will actually have a positive impact, so I present it for your consideration in the hope it's helpful.

Love the mod and all of your hard work

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.

1 participant