I-Knight-I / Rimworld-MedicalOverhaul

MIT License
0 stars 1 forks source link

Miniscule performance impact (if any) by constantly setting DeathRattle hediff to 0.00f every second #59

Closed I-Knight-I closed 6 years ago

I-Knight-I commented 6 years ago

In order to prevent a pawn from dying from a DeathRattle hediff we need to constantly set that hediff to 0.00f severity. This means running a script every 60 ticks (about a second) to do just that. Whilst this is absolutely not a big problem at all (most mods do this far more often) it's still nice and better to be more efficient and optimised.

In some rare cases this can probably cause issues on players PC's if their setup is weak OR if they've got a significant amount of mods on - and I mean significant, probably 100+.

In more common cases - if a player places a lot of life-support machines and IV drips and all of them are active then their performance could be negatively impacted. Once again this isn't that large of a problem because it'd require all of those machines to be running scripts at once which wouldn't be the case if A) No pawn is nearby or B) If no pawn meets the requirements for the script to run (e.g if they've got a heart/lungs/kidneys/liver/etc...)

Some solutions to this would be finding a way to force set the hediff to 0.00f without having to require constant updates. Another would be stopping the hediff from ticking up altogether by using a Harmony patch to check whether the pawn has life-support and, if they do, to stop the vanilla Rimworld function from running that'd otherwise increase the severity of the Coma/No Pulse/Asphyxiation hediff(s).

ghost commented 6 years ago

Is there a way to affect the death rattle hediff by setting some sort of hediff progression chance/rate instead of having to constantly assign it to 0.00?

I-Knight-I commented 6 years ago

hediff progression chance/rate instead of having to constantly assign it to 0.00?

Yeah, that was solution 2.0:

to stop the vanilla Rimworld function from running that'd otherwise increase the severity of the Coma/No Pulse/Asphyxiation hediff(s).

However that'd likely not improve the bug that much given that it'd essentially be running at the same rate as the script would. Fortunately, like I said, this is almost so negligible that the chances we ever see this affecting anything is very slim but, if this is one of the only issues left on the "Issues" page then we could absolutely use that to patch it up and see some improvement, however minuscule.

I-Knight-I commented 6 years ago

This can't be fixed, unfortunately. The way we'd need to patch the code is by tapping into AdjustSeverity but not every single Hediff uses that function - DeathRattle is one of them that doesn't use it. There's no other way we can edit that.

Closing issue unless other solutions can be thought of.