示例#1
0
            public FieldWrapper(UIPartActionFieldItem uiPartAction, Action <BaseField, bool> passthrough, bool ignoreDelay)
            {
                _uiPartAction = uiPartAction;
                SetDefaultListener();

                _passthrough  = passthrough;
                _ignoreDelay  = ignoreDelay;
                _wrappedField = new WrappedField(uiPartAction.Field, WrappedField.KspFieldFromBaseField(uiPartAction.Field));
            }
示例#2
0
        public override bool Pop(FlightComputer f)
        {
            if (BaseField != null)
            {
                try
                {
                    var field = (BaseField as WrappedField);
                    if (field == null) // we lost the Wrapped field instance, this is due to the fact that the command was loaded from a save
                    {
                        if (NewValue != null)
                        {
                            var newfield = new WrappedField(BaseField, WrappedField.KspFieldFromBaseField(BaseField));
                            if (newfield.NewValueFromString(NewValueString))
                            {
                                newfield.Invoke();
                            }
                        }
                    }
                    else
                    {
                        // invoke the field value change
                        field.Invoke();
                    }

                    if (UIPartActionController.Instance != null)
                    {
                        UIPartActionController.Instance.UpdateFlight();
                    }

#if !KSP131
                    for (int i = 0; i < f.Vessel.parts.Count; i++)
                    {
                        for (int j = 0; j < f.Vessel.parts[i].Modules.Count; j++)
                        {
                            if (f.Vessel.parts[i].Modules[j] is ModuleRoboticServoPiston)
                            {
                                // stock bug: targetExtension set by player in PartActionMenu is not passed to targetPosition unlike other robotic parts like hinge
                                var agModule = f.Vessel.parts[i].Modules[j] as ModuleRoboticServoPiston;
                                RTUtil.SetInstanceField(typeof(ModuleRoboticServoPiston), agModule, "targetPosition", agModule.targetExtension);
                            }
                        }
                    }
#endif
                }
                catch (Exception invokeException)
                {
                    RTLog.Notify("BaseField InvokeAction() by '{0}' with message: {1}",
                                 RTLogLevel.LVL1, this.BaseField.guiName, invokeException.Message);
                }
            }

            return(false);
        }
示例#3
0
        public override bool Pop(FlightComputer f)
        {
            if (BaseField != null)
            {
                try
                {
                    var field = (BaseField as WrappedField);
                    if (field == null) // we lost the Wrapped field instance, this is due to the fact that the command was loaded from a save
                    {
                        if (NewValue != null)
                        {
                            var newfield = new WrappedField(BaseField, WrappedField.KspFieldFromBaseField(BaseField));
                            if (newfield.NewValueFromString(NewValueString))
                            {
                                newfield.Invoke();
                            }
                        }
                    }
                    else
                    {
                        // invoke the field value change
                        field.Invoke();
                    }

                    if (UIPartActionController.Instance != null)
                    {
                        UIPartActionController.Instance.UpdateFlight();
                    }
                }
                catch (Exception invokeException)
                {
                    RTLog.Notify("BaseField InvokeAction() by '{0}' with message: {1}",
                                 RTLogLevel.LVL1, this.BaseField.guiName, invokeException.Message);
                }
            }

            return(false);
        }
        public override bool Pop(FlightComputer f)
        {
            if (BaseField != null)
            {
                try
                {
                    var field = (BaseField as WrappedField);
                    if (field == null) // we lost the Wrapped field instance, this is due to the fact that the command was loaded from a save
                    {                        
                        if (NewValue != null)
                        {
                            var newfield = new WrappedField(BaseField, WrappedField.KspFieldFromBaseField(BaseField));
                            if(newfield.NewValueFromString(NewValueString))
                            {
                                newfield.Invoke();
                            }
                        }
                    }
                    else
                    {
                        // invoke the field value change 
                        field.Invoke();
                    }

                    if (UIPartActionController.Instance != null)
                        UIPartActionController.Instance.UpdateFlight();
                }
                catch (Exception invokeException)
                {
                    RTLog.Notify("BaseField InvokeAction() by '{0}' with message: {1}",
                                 RTLogLevel.LVL1, this.BaseField.guiName, invokeException.Message);
                }
            }

            return false;
        }
 public override string AsString()
 {
     return(WrappedField.AsString());
 }
            public FieldWrapper(UIPartActionFieldItem uiPartAction, Action<BaseField, bool> passthrough, bool ignoreDelay)
            {
                _uiPartAction = uiPartAction;
                SetDefaultListener();

                _passthrough = passthrough;
                _ignoreDelay = ignoreDelay;
                _wrappedField = new WrappedField(uiPartAction.Field, WrappedField.KspFieldFromBaseField(uiPartAction.Field));
            }