Oh god, why are you pulling out differentiation and integration? It\'s only a percentage problem.
You\'re making this ten times more complex than what you\'re trying to defend.
At any tick through the game loop, with a linear calculation of shield regeneration, it will be as simple as:
CurrentShieldValue = CurrentShieldValue + ShieldRechargeIncrement;
ShieldRechargeIncrement will not change unless shield blocks are destroyed, or if there isn\'t enough power, so it doesn\'t always need to be recalculated with each iteration.
Addition is the simplest, easiest and fastest possible operator to process (compared with other mathematical operators).
With the percentage method it would be something more like:
CurrentShieldValue = CurrentShieldValue + ( ShieldRechargeIncrement x ( 0.4 - ((CurrentShieldValue / MaximumShieldValue) x 0.4 )
The increment to be added on each tick would have to be calculated with each iteration, because the value would be constantly changing.
You will notice how many extra operations a computer will have to process with that with each cycle. Also, division is incredibly slow next to simple addition, subtraction or even multiplication.
It probably won\'t make any difference, but once you start to consider multiple entities each with shields, turrets, stations, ships, and then on multiplayer, multiplying that higher, it can build up to the point where it does start to make a noticable difference. So small changes to small bits of code which seem insignificant now, can easily grow out of hand.
Afterall, we\'re only talking about the shields here, which is one small part of the game. It\'s best to get your head used to thinking like that because there are loads more systems which will be a lot more complex.
A lot of multiplayer games out there use simplified ways to calculate things precisely because of the number of times a server will need to calculate a particular algorithm.
For example, a very well known RPG style game uses a much simplified method of calculating combat damage.
Your character has a 50% hit chance, and a 50% crit chance.
You\'d naturally think that the game first takes your 50% to hit chance, calculates that like this:
/random 100, if 0-50, then hit, if 51-100, miss.
Then if you hit, it runs through another algorithm to determine if you crit.
/random 100, if 0-50, then crit, if 51-100, normal hit.
What actually happens is that they boil this down to a single algorithm, or random roll, which takes it all into account, such as:
/random 100, if 0-25, crit, if 26-50, normal hit, if 51-100, miss.
On those servers, while there are many attacks going on, they\'re not even as frequent as having to calculate it per game frame cycle, as you would need to with the shields.