Exemplo n.º 1
0
        public void FixedUpdate()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            maxGeeForce = Math.Max(maxGeeForce, FlightGlobals.ActiveVessel.geeForce);

            if (_showGui)
            {
                Events["ContextMenuOnOpenRecycler"].guiName = "Close Recycler";
            }
            else
            {
                Events["ContextMenuOnOpenRecycler"].guiName = "Open Recycler";
            }


            if (HighLogic.CurrentGame.Parameters.CustomParams <Workshop_Settings>().requireUnpacking || WorkshopUtils.PreLaunch())
            {
                if (wag != null)
                {
                    if (!wag.packed && !wag.Packing)
                    {
                        Events["ContextMenuOnOpenRecycler"].guiActive = true; // (_processedItem == null);
                    }
                    else
                    {
                        Events["ContextMenuOnOpenRecycler"].guiActive = false;
                    }
                }
            }
            if (wag != null)
            {
                wag.Busy = (_processedItem != null);
            }

            if (wag != null && wag.packed)
            {
                RecyclerStatus = "Packed";
            }
            else
            {
                RecyclerStatus = "Online";
            }



            try
            {
                UpdateProductivity();
                if (HighLogic.CurrentGame.Parameters.CustomParams <Workshop_Settings>().setRecycleKAC)
                {
                    updateKACAlarm();
                }

                ApplyPaging();

                if (lastUpdateTime == 0)
                {
                    lastUpdateTime = Planetarium.GetUniversalTime();
                    ProcessItem(TimeWarp.deltaTime);
                    Log.Info("After ProcessItem 1");
                    return;
                }

                //Get elapsed time
                double elapsedTime = Planetarium.GetUniversalTime() - lastUpdateTime;

                //Update last update time
                lastUpdateTime = Planetarium.GetUniversalTime();

                //If our elapsed time is > the background process interval, then we'll need to do some multiple processings.
                double timeRemaining = 0;
                while (elapsedTime > 0.1) // kBackgroundProcessInterval)
                {
                    timeRemaining = ProcessItem(elapsedTime);
                    if (_processedItem == null)
                    {
                        return;
                    }
                    if (elapsedTime == timeRemaining)
                    {
                        break;
                    }
                    elapsedTime = timeRemaining;
                    //elapsedTime -= kBackgroundProcessInterval;
                }

                //Process the remaining delta time
                if (elapsedTime > 0f)
                {
                    ProcessItem(elapsedTime);
                    Log.Info("After ProcessItem 2");
                }
            }
            catch (Exception ex)
            {
                WorkshopUtils.LogError("OseModuleWorkshop_OnUpdate", ex);
            }
        }