Exemplo n.º 1
0
        /*
         * UIPartActionMenuPatcher actions
         */

        private static void InvokeEvent(BaseEvent baseEvent, bool ignoreDelay)
        {
            // note: this gets called when the event is invoked through:
            // RemoteTech.FlightComputer.UIPartActionMenuPatcher.Wrapper.Invoke()

            var v = FlightGlobals.ActiveVessel;

            if (v == null || v.isEVA || RTCore.Instance == null)
            {
                baseEvent.Invoke();
                return;
            }

            VesselSatellite vs = null;

            if (RTCore.Instance != null)
            {
                vs = RTCore.Instance.Satellites[v];
            }

            if (vs == null || vs.HasLocalControl)
            {
                baseEvent.Invoke();
            }
            else if (EventWhiteList.Contains(baseEvent.name))
            {
                baseEvent.Invoke();
            }
            else if (vs.FlightComputer != null && vs.FlightComputer.InputAllowed)
            {
                if (ignoreDelay)
                {
                    baseEvent.Invoke();
                }
                else
                {
                    vs.SignalProcessor.FlightComputer.Enqueue(EventCommand.Event(baseEvent));
                }
            }
            else if (baseEvent.listParent.part.Modules.OfType <IAntenna>().Any() &&
                     !baseEvent.listParent.part.Modules.OfType <ModuleRTAntennaPassive>().Any() &&
                     RTSettings.Instance.ControlAntennaWithoutConnection)
            {
                baseEvent.Invoke();
            }
            else
            {
                ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#RT_ModuleUI_SPU_Msg"), 4.0f, ScreenMessageStyle.UPPER_LEFT));//"No connection to send command on."
            }
        }
Exemplo n.º 2
0
        public void DrawItem(string Filename, bool IsFolder)
        {
            int ItemColumn = -1;
            int ItemRow    = -1;

            for (int column = 0; column < DirGrid.Columns.Count; column++)
            {
                for (int row = 0; row < DirGrid.Rows.Count; row++)
                {
                    if (DirGrid.Widgets.Find(w => w.GridColumnStart == column && w.GridRowStart == row) == null)
                    {
                        // Free spot
                        ItemColumn = column;
                        ItemRow    = row;
                        break;
                    }
                }
                if (ItemColumn != -1 && ItemRow != -1)
                {
                    break;
                }
            }
            if (ItemColumn == -1 || ItemRow == -1)
            {
                // No free spot, so add row
                DirGrid.Rows.Add(new GridSize(102, Unit.Pixels));
                ItemColumn = 0;
                ItemRow    = DirGrid.Rows.Count - 1;
            }
            FileEntryWidget few = new FileEntryWidget(DirGrid);

            few.SetGrid(ItemRow, ItemColumn);
            few.SetMargin((int)Math.Floor(ColumnMargin), 4, 0, 0);
            if (!IsFolder)
            {
                few.SetFile(Filename);
            }
            else
            {
                few.SetFolder(Filename);
            }
            few.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                if (few.Selected)
                {
                    OnFileSelected?.Invoke(new BaseEventArgs());
                }
            };
            few.OnDoubleClick += delegate(BaseEventArgs e)
            {
                if (few.IsFolder)
                {
                    this.SetDirectory(few.Filename.Replace(this.BaseDirectory + '/', ""));
                }
                else
                {
                    OnFileDoubleClicked?.Invoke(new BaseEventArgs());
                }
            };
        }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            BaseEvent <T1> myTarget = (BaseEvent <T1>)target;

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Invoke value:");
                DrawInvokeValue(ref m_editorInvokeValue);
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Invoke"))
            {
                myTarget.Invoke(m_editorInvokeValue);
            }

            FieldInfo field = typeof(BaseEvent <T1>).GetField("m_actions", BindingFlags.NonPublic | BindingFlags.Instance);

            if (field == null)
            {
                return;
            }

            object actions = field.GetValue(myTarget);

            if (actions != null)
            {
                CustomScriptableEventDrawerUtils.DrawInvocationList(((Action <T1>)actions).GetInvocationList());
            }
        }
Exemplo n.º 4
0
 private void MerillEventDeployScienceEva()
 {
     MerillData.log("MerillEvaOnlyModule! MerillEventDeployScienceEva");
     if (btsmScienceEvent != null)
     {
         btsmScienceEvent.Invoke();
     }
 }
Exemplo n.º 5
0
 public void SetChecked(bool Checked)
 {
     if (this.Checked != Checked)
     {
         this.Checked = Checked;
         Redraw();
         OnCheckChanged?.Invoke(new BaseEventArgs());
     }
 }
Exemplo n.º 6
0
 public virtual void doScienceEvent()
 {
     if (canBeTested && btsmScienceEvent != null && isInstrumentOk())
     {
         //MerillData.log("SCIENCE! scienceDeployOrTest invoke");
         btsmScienceEvent.Invoke();
         //MerillData.log("SCIENCE! scienceDeployOrTest invoke done");
     }
 }
Exemplo n.º 7
0
 public void SetSelectedIndex(int SelectedIndex)
 {
     if (this.SelectedIndex != SelectedIndex)
     {
         this.SelectedIndex = SelectedIndex;
         this.Redraw();
         OnSelectionChanged?.Invoke(new BaseEventArgs());
     }
 }
Exemplo n.º 8
0
 public void TryClick(MouseEventArgs e)
 {
     if ((this.SelectedItem as MenuItem).LastClickable)
     {
         (SelectedItem as MenuItem).OnLeftClick?.Invoke(e);
         OnItemInvoked?.Invoke(new BaseEventArgs());
         this.Dispose();
     }
 }
Exemplo n.º 9
0
        public void SetSelectedFile(string Filename)
        {
            bool changed = false;

            foreach (FileEntryWidget few in DirGrid.Widgets)
            {
                if (few.Filename.EndsWith(Filename))
                {
                    SelectedFEW = few;
                    few.SetSelected(true);
                    OnFileSelected?.Invoke(new BaseEventArgs());
                    changed = true;
                    break;
                }
            }
            if (!changed)
            {
                throw new Exception("File not found.");
            }
        }
Exemplo n.º 10
0
Arquivo: API.cs Projeto: jvdnbus/SSAT2
 // this method provides a workaround for issue #437, it may be possible to remove it in the future
 public static void InvokeOriginalEvent(BaseEvent e)
 {
     if (e is WrappedEvent)
     {
         WrappedEvent wrappedEvent = e as WrappedEvent;
         wrappedEvent.InvokeOriginalEvent();
     }
     else
     {
         e.Invoke();
     }
 }
        //method deploy
        protected bool deployMirror()
        {
            //foreach (PartModule pm in part.Modules)
            //{
            //	MerillData.log("mirror as module " + pm.name);
            //	foreach (BaseEvent temp in pm.Events)
            //	{
            //		MerillData.log("mirror event " + temp.name + " " + temp.guiName + " " + temp.guiActive);
            //		//temp.guiActive = false;
            //	}
            //	foreach (BaseAction temp in pm.Actions)
            //	{
            //		MerillData.log("mirror action " + temp.name + " " + temp.guiName + " " + temp.active);
            //		//temp.active = false;
            //	}
            //}

            //MerillData.log("mirror situation : " + part.vessel.situation);
            //MerillData.log("mirror situation : " + vessel.situation);
            //MerillData.log("mirror situation needed : " + Vessel.Situations.LANDED);
            //MerillData.log("mirror vessel.mainBody : " + vessel.mainBody.name);
            //MerillData.log("mirror vessel.mainBody needed : Mun");
            //MerillData.log("mirror altitude : " + vessel.altitude);
            //MerillData.log("mirror splashed : " + vessel.Splashed);
            //MerillData.log("mirror llanded : " + vessel.Landed);
            //MerillData.log("mirror llandedat : " + vessel.landedAt);
            //MerillData.log("mirror landor splashed : " + vessel.LandedOrSplashed);
            //MerillData.log("mirror if : " + ((!(part.vessel.situation == Vessel.Situations.LANDED)) || part.vessel.mainBody.name.Equals("Mun")));
            //MerillData.log("mirror if : " + (!(part.vessel.situation == Vessel.Situations.LANDED)) +" || "+part.vessel.mainBody.name.Equals("Mun"));
            //check landing on mun
            if (part.vessel.situation != Vessel.Situations.LANDED || (!part.vessel.mainBody.name.Equals("Mun")))
            {
                //emit error message
                //ScreenMessages.PostScreenMessage("Experiment " + part.partInfo.title.ToString()
                //	+ " can't be deployed: need to be landed on the mun."
                //	, 10f, ScreenMessageStyle.UPPER_LEFT);
                ScreenMessages.PostScreenMessage(string.Format(MerillData.str_mirror_fail, part.partInfo.title.ToString())
                                                 , 10f, ScreenMessageStyle.UPPER_LEFT);
                return(false);
            }
            //MerillData.log("mirror landed : ok for deploy");
            //check orientation
            //TODO
            //check kerbin visibility
            //TODO
            //ok :
            //deploy the antenna
            deployMirrorEvent.Invoke();

            //launch the real exp (window with experiment)
            //MerillData.log("mirror check ok");
            return(true);
        }
Exemplo n.º 12
0
        public void Edit(BaseEvent Callback = null)
        {
            EditConditionsWindow edw = new EditConditionsWindow(this.Conditions);

            edw.OnClosed += delegate(BaseEventArgs e)
            {
                if (edw.NeedUpdate)
                {
                    SetConditions(edw.Conditions);
                }
                Callback?.Invoke(e);
            };
        }
    public static void TriggerEvent(string eventName, BaseMessage msg = null)
    {
        BaseEvent thisEvent = null;

        if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            Utils.Log("EventManager: Triggering `" + eventName + "`");
            thisEvent.Invoke(msg);
        }
        else
        {
            Utils.Log("EventManager: No listeners for:  `" + eventName + "`", LogType.WARNING);
        }
    }
Exemplo n.º 14
0
        /// <summary>
        /// Trigger whatever code the PartModule has attached to this Event, given the kOS name for the suffix.
        /// </summary>
        /// <param name="suffixName"></param>
        private void CallKSPEvent(string suffixName)
        {
            BaseEvent evt = GetEvent(suffixName);

            if (evt == null)
            {
                throw new KOSLookupFailException("EVENT", suffixName, this);
            }
            if (!EventIsVisible(evt))
            {
                throw new KOSLookupFailException("EVENT", suffixName, this, true);
            }
            evt.Invoke();
        }
Exemplo n.º 15
0
    public static void TriggerEvent(string eventName, BaseMessage msg = null)
    {
        BaseEvent thisEvent = null;

        if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            // TODO should cache this check, or simple use a dict
            if (!Instance.ignoredOutputEvents.Contains(eventName))
            {
                Utils.Log("EventManager: Triggering `" + eventName + "`");
            }
            thisEvent.Invoke(msg);
        }
        else
        {
            Utils.Log("EventManager: No listeners for:  `" + eventName + "`", LogType.WARNING);
        }
    }
Exemplo n.º 16
0
        /// <summary>
        /// Trigger whatever code the PartModule has attached to this Event, given the kOS name for the suffix.
        /// </summary>
        /// <param name="suffixName"></param>
        private void CallKSPEvent(StringValue suffixName)
        {
            ThrowIfNotCPUVessel();
            BaseEvent evt = GetEvent(suffixName);
            if (evt == null)
                throw new KOSLookupFailException("EVENT", suffixName, this);
            if (!EventIsVisible(evt))
                throw new KOSLookupFailException("EVENT", suffixName, this, true);

            if (RemoteTechHook.IsAvailable())
            {
                RemoteTechHook.Instance.InvokeOriginalEvent(evt);
            }
            else
            {
                evt.Invoke();
            }
        }
Exemplo n.º 17
0
 public void SetChecked(bool Checked)
 {
     if (this.Checked != Checked)
     {
         if (Checked)
         {
             foreach (Widget w in Parent.Widgets)
             {
                 if (w is RadioBox && w != this && ((RadioBox)w).Checked)
                 {
                     ((RadioBox)w).SetChecked(false);
                 }
             }
         }
         this.Checked = Checked;
         Redraw();
         OnCheckChanged?.Invoke(new BaseEventArgs());
     }
 }
Exemplo n.º 18
0
        private void DoEvent(Suffixed.Part.PartValue part, StringValue eventname)
        {
            CheckEvaController();
            var        mypart       = part.Part;
            PartModule mypartmodule = null;

            Debug.LogWarning("kOS-EVA: [DOEVENT] part: " + mypart.name + "dst: " + Math.Round((mypart.transform.position - kerbaleva.vessel.rootPart.transform.position).magnitude, 2));
            if (Vector3d.Magnitude(mypart.transform.position - kerbaleva.vessel.rootPart.transform.position) < 2.5)
            {
                Debug.LogWarning("kOS-EVA: [DOEVENT] distance ok:");
                PartModule[] allpartmodules = mypart.GetComponents <PartModule>();
                foreach (var pm in allpartmodules)
                {
                    if (pm.Events.Where(x => x.GUIName.ToLower().StartsWith(eventname.ToLower())).FirstOrDefault() == null)
                    {
                        continue;
                    }
                    Debug.Log("kOS-EVA: [DOEVENT] Partmodule found:" + pm.moduleName);
                    mypartmodule = pm;
                }

                if (mypartmodule == null)
                {
                    Debug.LogWarning("kOS-EVA: [DOEVENT] Partmodule not found ");
                    return;
                }
                BaseEvent my_event = mypartmodule.Events.Where(x => x.GUIName.ToLower().StartsWith(eventname.ToLower())).FirstOrDefault();
                if (my_event == null)
                {
                    Debug.LogWarning("kOS-EVA: [DOEVENT] Event not found ");
                    return;
                }
                else
                {
                    Debug.Log("kOS-EVA: [DOEVENT] Invoking:" + my_event.GUIName);
                    my_event.Invoke();
                }
            }
            else
            {
                Debug.LogWarning("kOS-EVA: [DOEVENT] Part Out of Range: " + Math.Round(Vector3d.Magnitude(mypart.transform.position - shared.Vessel.rootPart.transform.position), 2) + " > 2.5");
            }
        }
Exemplo n.º 19
0
 public void SetSelected(bool Selected)
 {
     if (!this.Selected && Selected)
     {
         SetTimer("double", 300);
     }
     else if (this.Selected && Selected)
     {
         if (TimerExists("double") && !TimerPassed("double"))
         {
             OnDoubleClick?.Invoke(new BaseEventArgs());
             DestroyTimer("double");
         }
         else if (TimerExists("double") && TimerPassed("double"))
         {
             ResetTimer("double");
         }
         else if (!TimerExists("double"))
         {
             SetTimer("double", 300);
         }
     }
     if (this.Selected != Selected)
     {
         this.Selected = Selected;
         if (this.Selected)
         {
             foreach (FileEntryWidget few in Parent.Widgets)
             {
                 if (few != this && few.Selected)
                 {
                     few.SetSelected(false);
                 }
             }
         }
         Sprites["outline"].Visible = this.Selected;
         Sprites["box"].Visible     = this.Selected;
         Sprites["hover"].Visible   = Hovering && !this.Selected;
         this.OnSelectionChanged?.Invoke(new BaseEventArgs());
     }
 }
Exemplo n.º 20
0
 public override void MouseUp(MouseEventArgs e)
 {
     base.MouseUp(e);
     if (e.LeftButton != e.OldLeftButton)
     {
         if (Hovering && Pressing && StartedPressingInside)
         {
             OnPressed?.Invoke(new BaseEventArgs());
             Pressing = false;
             StartedPressingInside = false;
             Redraw();
         }
         else
         {
             Pressing = false;
             StartedPressingInside = false;
             Hovering = false;
             Redraw();
         }
     }
 }
Exemplo n.º 21
0
        private IEnumerator WaitForEvent()
        {
            VideoPlayer.Prepare();

            while (!VideoPlayer.isPrepared)
            {
                yield return(null);
            }

            Debug.LogFormat("Video player is prepared using chapter: (id: {0}) (name: {1})!", CurrentChapter.Id, CurrentChapter.Name);

            VideoPlayer.Play();

            if (!VideoPlayer.isPlaying)
            {
                Debug.LogWarning("Started waiting for event while videoplayer is not playing");
            }

            BaseEvent previousEvent = null;

            foreach (TimelineEventData data in eventData)
            {
                while (VideoPlayer.time < data.InvokeTime)
                {
                    yield return(null);
                }

                if (previousEvent != null)
                {
                    Destroy(previousEvent.gameObject);
                }

                BaseEvent newEvent = BaseEvents.Find((BaseEvent e) => e.EventType == data.GetType());
                previousEvent  = newEvent = Instantiate(newEvent, Container);
                newEvent.Event = data;
                newEvent.Invoke();

                Debug.LogFormat("Invoke timelineEvent: (id: {0}) of (type: {1}) at (time: {2})", data.Id, data.Type, data.InvokeTime);
            }
        }
Exemplo n.º 22
0
 public override bool Pop(FlightComputer f)
 {
     BaseEvent.Invoke();
     return(false);
 }
Exemplo n.º 23
0
 public void BaseFireEvent(short arg)
 {
     BaseEvent?.Invoke(this, new TestEventArgs <short> {
         Arg = arg
     });
 }
Exemplo n.º 24
0
        private IEnumerator deployEvent()
        {
            if (USTwoScience)
            {
                RaycastHit hit;

                if (_raySource != null && Physics.Raycast(_raySource.position, _raySource.forward, out hit, 1f, LayerUtil.DefaultEquivalent))
                {
                    if (hit.collider != null)
                    {
                        bool primary   = false;
                        bool secondary = false;

                        if (hit.collider.gameObject.name == "PrimaryDoorCollider")
                        {
                            primary = true;
                        }
                        else if (hit.collider.gameObject.name == "SecondaryDoorCollider")
                        {
                            secondary = true;
                        }

                        if (primary || secondary)
                        {
                            Part p = FlightGlobals.GetPartUpwardsCached(hit.collider.gameObject);// Part.GetComponentUpwards<Part>(hit.collider.gameObject);

                            if (p != null)
                            {
                                IScalarModule scalar      = null;
                                float         deployLimit = 1;
                                PartModule    USAnimate   = null;

                                for (int i = p.Modules.Count - 1; i >= 0; i--)
                                {
                                    if (p.Modules[i].moduleName == "USAnimateGeneric")
                                    {
                                        USAnimate = p.Modules[i];

                                        if (USAnimate is IScalarModule)
                                        {
                                            scalar = USAnimate as IScalarModule;
                                        }

                                        break;
                                    }
                                }

                                if (USAnimate != null && scalar != null)
                                {
                                    BaseEvent doorEvent = null;
                                    BaseField doorLimit = null;

                                    if (primary)
                                    {
                                        doorEvent = USAnimate.Events["toggleEventPrimary"];

                                        doorLimit = USAnimate.Fields["primaryDeployLimit"];
                                    }
                                    else if (secondary)
                                    {
                                        doorEvent = USAnimate.Events["toggleEventSecondary"];

                                        doorLimit = USAnimate.Fields["secondaryDeployLimit"];
                                    }

                                    if (doorLimit != null)
                                    {
                                        deployLimit = doorLimit.GetValue <float>(USAnimate) * 0.01f;
                                    }

                                    if (doorEvent != null)
                                    {
                                        if (doorEvent.active && doorEvent.guiActive)
                                        {
                                            doorEvent.Invoke();

                                            DMUtils.Logging("Door Invoked");

                                            while (scalar.GetScalar < deployLimit)
                                            {
                                                yield return(null);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            var ownColliders = part.GetComponentsInChildren <Collider>();

                            bool flag = false;

                            for (int i = ownColliders.Length - 1; i >= 0; i--)
                            {
                                if (hit.collider == ownColliders[i])
                                {
                                    flag = true;

                                    break;
                                }
                            }

                            if (!flag)
                            {
                                ScreenMessages.PostScreenMessage(
                                    string.Format(
                                        "<b><color=orange>Obstruction detected preventing {0} from being deployed.</color></b>"
                                        , part.partInfo.title)
                                    , 5f, ScreenMessageStyle.UPPER_CENTER);

                                yield break;
                            }
                        }
                    }
                }
            }

            IsDeployed = true;

            animator(1f, 0f, Anim, animationName);

            if (USScience)
            {
                animator(1f, 0f, USAnim, USBayAnimation);
            }

            yield return(new WaitForSeconds(Anim[animationName].length));

            fullyDeployed = true;
        }
Exemplo n.º 25
0
 public void InvokeOriginalEvent()
 {
     _originalEvent.Invoke();
 }
Exemplo n.º 26
0
        public void EditWindow(BaseEvent CallBack = null)
        {
            if (this.Command == null || !this.CommandType.IsEditable)
            {
                return;
            }
            PopupWindow   = new PopupWindow();
            OldParameters = new Dictionary <string, object>(Command.Parameters);
            WindowUtility = GenerateUtility();
            dynamic basewidgets = this.CommandType.CallCreateWindow(WindowUtility);

            for (int i = 0; i < basewidgets.Count; i++)
            {
                dynamic widget = basewidgets[i];
                string  type   = widget.GetType().Name;
                Widget  parent = null;
                if (widget.Parent != null)
                {
                    foreach (string parentwidgetid in DynamicWindowWidgets.Keys)
                    {
                        if (parentwidgetid == widget.Parent.UniqueID)
                        {
                            parent = DynamicWindowWidgets[parentwidgetid];
                            break;
                        }
                    }
                }
                if (parent == null)
                {
                    parent = PopupWindow;
                }
                Widget w = ProcessWidgetType(widget, type, parent);
                ProcessWidget(w, widget, true, true);
                DynamicWindowWidgets.Add(widget.UniqueID, w);
                DynamicWindowWidgetObjects.Add(widget.UniqueID, widget);
            }
            int width  = CommandType.WindowWidth;
            int height = CommandType.WindowHeight;

            PopupWindow.SetTitle(CommandType.Name);
            PopupWindow.MinimumSize = PopupWindow.MaximumSize = new Size(width, height);
            PopupWindow.SetSize(PopupWindow.MaximumSize);
            PopupWindow.CreateButton("Cancel", delegate(BaseEventArgs e)
            {
                CloseWindow();
            });
            PopupWindow.CreateButton("OK", delegate(BaseEventArgs e)
            {
                SaveWindow(WindowUtility);
                if (!WindowUtility.AwaitCloseFlag)
                {
                    CloseWindow();
                }
            });
            PopupWindow.Center();
            PopupWindow.OnClosed += delegate(BaseEventArgs e)
            {
                Reload();
                CallBack?.Invoke(e);
            };
        }
Exemplo n.º 27
0
 // this method provides a workaround for issue #437, it may be possible to remove it in the future
 public static void InvokeOriginalEvent(BaseEvent e)
 {
     if (e is WrappedEvent)
     {
         WrappedEvent wrappedEvent = e as WrappedEvent;
         wrappedEvent.InvokeOriginalEvent();
     }
     else
     {
         e.Invoke();
     }
 }
Exemplo n.º 28
0
 public object InvokeBaseEvent()
 {
     return(BaseEvent.Invoke());
 }
Exemplo n.º 29
0
        public override void deployEvent()
        {
            IScalarModule scalar      = null;
            float         deployLimit = 0;

            RaycastHit hit;

            if (_raySource != null && Physics.Raycast(_raySource.position, _raySource.forward, out hit, 1f, LayerUtil.DefaultEquivalent))
            {
                if (hit.collider != null)
                {
                    bool primary   = false;
                    bool secondary = false;

                    if (hit.collider.gameObject.name == "PrimaryDoorCollider")
                    {
                        primary = true;
                    }
                    else if (hit.collider.gameObject.name == "SecondaryDoorCollider")
                    {
                        secondary = true;
                    }

                    if (primary || secondary)
                    {
                        Part p = Part.GetComponentUpwards <Part>(hit.collider.gameObject);

                        if (p != null)
                        {
                            PartModule USAnimate = null;

                            for (int i = p.Modules.Count - 1; i >= 0; i--)
                            {
                                if (p.Modules[i].moduleName == "USAnimateGeneric")
                                {
                                    USAnimate = p.Modules[i];

                                    if (USAnimate is IScalarModule)
                                    {
                                        scalar = USAnimate as IScalarModule;
                                    }

                                    break;
                                }
                            }

                            if (USAnimate != null)
                            {
                                BaseEvent doorEvent = null;
                                BaseField doorLimit = null;

                                if (primary)
                                {
                                    doorEvent = USAnimate.Events["toggleEventPrimary"];

                                    doorLimit = USAnimate.Fields["primaryDeployLimit"];
                                }
                                else if (secondary)
                                {
                                    doorEvent = USAnimate.Events["toggleEventSecondary"];

                                    doorLimit = USAnimate.Fields["secondaryDeployLimit"];
                                }

                                if (doorLimit != null)
                                {
                                    deployLimit = doorLimit.GetValue <float>(USAnimate) * 0.01f;
                                }
                                else
                                {
                                    deployLimit = 1;
                                }

                                if (doorEvent != null)
                                {
                                    if (doorEvent.active && doorEvent.guiActive)
                                    {
                                        doorEvent.Invoke();

                                        StartCoroutine(WaitForBayDoors(scalar, deployLimit));
                                    }
                                    else
                                    {
                                        base.deployEvent();
                                    }
                                }
                                else
                                {
                                    base.deployEvent();
                                }
                            }
                            else
                            {
                                base.deployEvent();
                            }
                        }
                        else
                        {
                            base.deployEvent();
                        }
                    }
                    else
                    {
                        var ownColliders = part.GetComponentsInChildren <Collider>();

                        bool flag = false;

                        for (int i = ownColliders.Length - 1; i >= 0; i--)
                        {
                            if (hit.collider == ownColliders[i])
                            {
                                flag = true;

                                break;
                            }
                        }

                        if (flag)
                        {
                            base.deployEvent();
                        }
                        else
                        {
                            ScreenMessages.PostScreenMessage(
                                string.Format(
                                    "<b><color=orange>Obstruction detected preventing {0} from being deployed.</color></b>"
                                    , part.partInfo.title)
                                , 5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                    }
                }
            }
            else
            {
                base.deployEvent();
            }
        }
Exemplo n.º 30
0
        /*
         * UIPartActionMenuPatcher actions
         */
        private static void InvokeEvent(BaseEvent baseEvent, bool ignoreDelay)
        {
            // note: this gets called when the event is invoked through:
            // RemoteTech.FlightComputer.UIPartActionMenuPatcher.Wrapper.Invoke()

            var v = FlightGlobals.ActiveVessel;
            if (v == null || v.isEVA || RTCore.Instance == null)
            {
                baseEvent.Invoke();
                return;
            }

            VesselSatellite vs = null;
            if (RTCore.Instance != null)
            {
                vs = RTCore.Instance.Satellites[v];
            }

            if (vs == null || vs.HasLocalControl)
            {
                baseEvent.Invoke();
            }
            else if (EventWhiteList.Contains(baseEvent.name))
            {
                baseEvent.Invoke();
            }
            else if (vs.FlightComputer != null && vs.FlightComputer.InputAllowed)
            {
                if (ignoreDelay)
                {
                    baseEvent.Invoke();
                }
                else
                {
                    vs.SignalProcessor.FlightComputer.Enqueue(EventCommand.Event(baseEvent));
                }
            }
            else if (baseEvent.listParent.part.Modules.OfType<IAntenna>().Any() &&
                     !baseEvent.listParent.part.Modules.OfType<ModuleRTAntennaPassive>().Any() &&
                     RTSettings.Instance.ControlAntennaWithoutConnection)
            {
                baseEvent.Invoke();
            }
            else
            {
                ScreenMessages.PostScreenMessage(new ScreenMessage("No connection to send command on.", 4.0f, ScreenMessageStyle.UPPER_LEFT));
            }
        }