ContractConfigurator icon indicating copy to clipboard operation
ContractConfigurator copied to clipboard

Optimize contract requirement checks

Open siimav opened this issue 3 years ago • 3 comments

KSP will run them in a coroutine for every Update in the flight scene. Some of the checks aren't relevant at all for already accepted contracts.

siimav avatar Nov 29 '21 16:11 siimav

This seems questionable. Some of the checks don't apply for already accepted contracts, but some DO. So just checking the state I'd not going to do it.

The cooldownDuration check seems okay at a glance, but it's been a long while since I've looked at this stuff.

jrossignol avatar Nov 29 '21 16:11 jrossignol

At least for maxSimultaneous I think the player shouldn't be able to accept more instances than the limit so why check that for already accepted contracts? As for maxCompletions - I guess checking this for active contracts can be necessary when maxSimultaneous is also > 1 at the same time? This way if you complete an instance and reach the maxCompletions value then all the others will fail? CheckContractGroup is for disabling and enabling contracts groups through the stock difficulty settings menu. Here I don't think it's necessary to automatically fail contracts from groups that got disabled.

Edit: oops, I missed the fact that CheckContractGroup also has maxSimultaneous and maxCompletions checks. :/

siimav avatar Nov 29 '21 16:11 siimav

I have revised the PR with the changes I mentioned in the previous comment. At least for the contracts in RP-1 this should mostly eliminate the need to run those Linq queries.

siimav avatar Nov 30 '21 01:11 siimav