Пример #1
0
        public void CutConnection()
        {
            if (connectedPump != null)
            {
                connectedPump.DisengageFromPair();
            }
            if (awaitingPump == this)
            {
                awaitingPump = null;
            }

            DisengageFromPair();
        }
Пример #2
0
        void DisengageFromPair()
        {
            connected = false;

            Events["FindPumpingCounterPart"].guiActive          = true;
            Events["FindPumpingCounterPart"].guiActiveUnfocused = true;

            Events["CutConnection"].guiActive          = false;
            Events["CutConnection"].guiActiveUnfocused = false;

            connectedPump = null;
            activeResourcePumpingRatedDict = new Dictionary <string, float>();

            Events.RemoveAll((BaseEvent a) => a.name.Contains("Pump_") && a.group.name == "EVARefuelingPump");
            part.Events.RemoveAll((BaseEvent a) => a.name.Contains("Pump_") && a.group.name == "EVARefuelingPump");
            part.PartActionWindow.displayDirty = true;
        }
Пример #3
0
        public void FindPumpingCounterPart()
        {
            if (awaitingPump == null)
            {
                awaitingPump = this;
            }
            else if (awaitingPump.isEVASide != isEVASide)
            {
                EngagePumpPair();
            }
            else
            {
                awaitingPump.CutConnection();
                awaitingPump = this;
            }

            Events["FindPumpingCounterPart"].guiActive          = false;
            Events["FindPumpingCounterPart"].guiActiveUnfocused = false;

            Events["CutConnection"].guiActive          = true;
            Events["CutConnection"].guiActiveUnfocused = true;
        }
Пример #4
0
        void EngagePumpPair()
        {
            if (isEVASide)
            {
                if (awaitingPump.isEVASide)
                {
                    Debug.LogError("[EVARefueling] Both pumps marked for engaging are EVA-Side. Normally this error message should NEVER arise as engaging is only called for EVA+nonEVA pump pairs");
                }
                else
                {
                    EVARefuelingPump tmp = awaitingPump;
                    awaitingPump = this;
                    tmp.EngagePumpPair();                       // Actual engaging is to be done by non-EVA-Side pump
                }
            }
            else
            {
                awaitingPump.connectedPump = this;
                awaitingPump.connected     = true;

                connectedPump = awaitingPump;
                connected     = true;

                awaitingPump = null;

                foreach (string resourceName in resourcePumpingRatesDict.Keys)
                {
                    if (part.Resources.Contains(resourceName) && connectedPump.part.Resources.Contains(resourceName))
                    {
                        KSPEvent attributeHolder = new KSPEvent();
                        #region Setting Attribs
                        attributeHolder.guiActive          = true;
                        attributeHolder.guiName            = $"Pump {part.Resources[resourceName].info.displayName} here";
                        attributeHolder.groupName          = "EVARefuelingPump";
                        attributeHolder.groupDisplayName   = "EVA Refueling";
                        attributeHolder.guiActiveUnfocused = true;
                        attributeHolder.requireFullControl = false;
                        attributeHolder.guiActiveUncommand = true;
                        #endregion
                        Events.Add(new BaseEvent(Events, $"InPump_{resourceName}", () =>
                        {
                            activeResourcePumpingRatedDict[resourceName] = resourcePumpingRatesDict[resourceName];

                            Events[$"InPump_{resourceName}"].guiActive          = false;
                            Events[$"InPump_{resourceName}"].guiActiveUnfocused = false;

                            Events[$"StopPump_{resourceName}"].guiActive          = true;
                            Events[$"StopPump_{resourceName}"].guiActiveUnfocused = true;

                            connectedPump.Events[$"InPump_{resourceName}"].guiActive          = true;
                            connectedPump.Events[$"InPump_{resourceName}"].guiActiveUnfocused = true;

                            connectedPump.Events[$"StopPump_{resourceName}"].guiActive          = true;
                            connectedPump.Events[$"StopPump_{resourceName}"].guiActiveUnfocused = true;
                        },
                                                 attributeHolder));

                        attributeHolder = new KSPEvent();
                        #region Setting Attribs
                        attributeHolder.guiActive          = true;
                        attributeHolder.guiName            = $"Pump {part.Resources[resourceName].info.displayName} here";
                        attributeHolder.groupName          = "EVARefuelingPump";
                        attributeHolder.groupDisplayName   = "EVA Refueling";
                        attributeHolder.guiActiveUnfocused = true;
                        attributeHolder.requireFullControl = false;
                        attributeHolder.guiActiveUncommand = true;
                        #endregion
                        connectedPump.Events.Add(new BaseEvent(connectedPump.Events, $"InPump_{resourceName}", () =>
                        {
                            activeResourcePumpingRatedDict[resourceName] = -resourcePumpingRatesDict[resourceName];

                            Events[$"InPump_{resourceName}"].guiActive          = true;
                            Events[$"InPump_{resourceName}"].guiActiveUnfocused = true;

                            Events[$"StopPump_{resourceName}"].guiActive          = true;
                            Events[$"StopPump_{resourceName}"].guiActiveUnfocused = true;

                            connectedPump.Events[$"InPump_{resourceName}"].guiActive          = false;
                            connectedPump.Events[$"InPump_{resourceName}"].guiActiveUnfocused = false;

                            connectedPump.Events[$"StopPump_{resourceName}"].guiActive          = true;
                            connectedPump.Events[$"StopPump_{resourceName}"].guiActiveUnfocused = true;
                        },
                                                               attributeHolder));

                        attributeHolder = new KSPEvent();
                        #region Setting Attribs
                        attributeHolder.guiActive          = false;
                        attributeHolder.guiName            = $"Stop Pumping {part.Resources[resourceName].info.displayName}";
                        attributeHolder.groupName          = "EVARefuelingPump";
                        attributeHolder.groupDisplayName   = "EVA Refueling";
                        attributeHolder.guiActiveUnfocused = false;
                        attributeHolder.requireFullControl = false;
                        attributeHolder.guiActiveUncommand = false;
                        #endregion
                        Events.Add(new BaseEvent(Events, $"StopPump_{resourceName}", () =>
                        {
                            activeResourcePumpingRatedDict[resourceName] = 0;

                            Events[$"InPump_{resourceName}"].guiActive          = true;
                            Events[$"InPump_{resourceName}"].guiActiveUnfocused = true;

                            Events[$"StopPump_{resourceName}"].guiActive          = false;
                            Events[$"StopPump_{resourceName}"].guiActiveUnfocused = false;

                            connectedPump.Events[$"InPump_{resourceName}"].guiActive          = true;
                            connectedPump.Events[$"InPump_{resourceName}"].guiActiveUnfocused = true;

                            connectedPump.Events[$"StopPump_{resourceName}"].guiActive          = false;
                            connectedPump.Events[$"StopPump_{resourceName}"].guiActiveUnfocused = false;
                        },
                                                 attributeHolder));

                        attributeHolder = new KSPEvent();
                        #region Setting Attribs
                        attributeHolder.guiActive          = false;
                        attributeHolder.guiName            = $"Stop Pumping {part.Resources[resourceName].info.displayName}";
                        attributeHolder.groupName          = "EVARefuelingPump";
                        attributeHolder.groupDisplayName   = "EVA Refueling";
                        attributeHolder.guiActiveUnfocused = false;
                        attributeHolder.requireFullControl = false;
                        attributeHolder.guiActiveUncommand = false;
                        #endregion
                        connectedPump.Events.Add(new BaseEvent(connectedPump.Events, $"StopPump_{resourceName}", () =>
                        {
                            activeResourcePumpingRatedDict[resourceName] = 0;

                            Events[$"InPump_{resourceName}"].guiActive          = true;
                            Events[$"InPump_{resourceName}"].guiActiveUnfocused = true;

                            Events[$"StopPump_{resourceName}"].guiActive          = false;
                            Events[$"StopPump_{resourceName}"].guiActiveUnfocused = false;

                            connectedPump.Events[$"InPump_{resourceName}"].guiActive          = true;
                            connectedPump.Events[$"InPump_{resourceName}"].guiActiveUnfocused = true;

                            connectedPump.Events[$"StopPump_{resourceName}"].guiActive          = false;
                            connectedPump.Events[$"StopPump_{resourceName}"].guiActiveUnfocused = false;
                        },
                                                               attributeHolder));
                    }
                }
            }
        }