void Start() { Debug.Log("KSPTSThreadController registering with KSP events"); GameEvents.onVesselCreate.Add(ResetEndOfFrameManager); GameEvents.onVesselGoOffRails.Add(ResetEndOfFrameManager); GameEvents.onVesselGoOnRails.Add(ResetEndOfFrameManager); GameEvents.onVesselWasModified.Add(ResetEndOfFrameManager); GameEvents.onEditorShipModified.Add(ResetEndOfFrameManager); _threadPool = new KSPTSWorkerThreadPool((Environment.ProcessorCount)); //There has to be a cleaner way of doing this _postFunctions.Add(KSPTSThreadingGroup.IN_LOOP_UPDATE, new Queue<KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.IN_LOOP_LATE_UPDATE, new Queue<KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.IN_LOOP_FIXED_UPDATE, new Queue<KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.ACROSS_LOOP_UPDATE, new Queue<KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.ACROSS_LOOP_LATE_UPDATE, new Queue<KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.ACROSS_LOOP_FIXED_UPDATE, new Queue<KSPTSParametrizedPostFunction>()); _postFunctionsRemaining.Add(KSPTSThreadingGroup.IN_LOOP_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.IN_LOOP_LATE_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.IN_LOOP_FIXED_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.ACROSS_LOOP_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.ACROSS_LOOP_LATE_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.ACROSS_LOOP_FIXED_UPDATE, 0); }
void Start() { Debug.Log("KSPTSThreadController registering with KSP events"); GameEvents.onVesselCreate.Add(ResetEndOfFrameManager); GameEvents.onVesselGoOffRails.Add(ResetEndOfFrameManager); GameEvents.onVesselGoOnRails.Add(ResetEndOfFrameManager); GameEvents.onVesselWasModified.Add(ResetEndOfFrameManager); GameEvents.onEditorShipModified.Add(ResetEndOfFrameManager); _threadPool = new KSPTSWorkerThreadPool((Environment.ProcessorCount)); //There has to be a cleaner way of doing this _postFunctions.Add(KSPTSThreadingGroup.IN_LOOP_UPDATE, new Queue <KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.IN_LOOP_LATE_UPDATE, new Queue <KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.IN_LOOP_FIXED_UPDATE, new Queue <KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.ACROSS_LOOP_UPDATE, new Queue <KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.ACROSS_LOOP_LATE_UPDATE, new Queue <KSPTSParametrizedPostFunction>()); _postFunctions.Add(KSPTSThreadingGroup.ACROSS_LOOP_FIXED_UPDATE, new Queue <KSPTSParametrizedPostFunction>()); _postFunctionsRemaining.Add(KSPTSThreadingGroup.IN_LOOP_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.IN_LOOP_LATE_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.IN_LOOP_FIXED_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.ACROSS_LOOP_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.ACROSS_LOOP_LATE_UPDATE, 0); _postFunctionsRemaining.Add(KSPTSThreadingGroup.ACROSS_LOOP_FIXED_UPDATE, 0); }