Пример #1
0
 public TriggerActionTimer(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type        = TriggerActionType.Timer;
     _timer       = null;
     _name        = "";
     _timerAction = TimerActionType.Start;
 }
Пример #2
0
 public TriggerActionFlight(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type            = TriggerActionType.Flight;
     _actionIndex     = -1;
     _methodInfo      = null;
     _fieldInfo       = null;
     _actionSource    = null;
     _methodParameter = null;
 }
Пример #3
0
 public TriggerActionPart(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type            = TriggerActionType.Part;
     _part            = null;
     _actionIndex     = -1;
     _methodInfo      = null;
     _fieldInfo       = null;
     _actionSource    = null;
     _methodParameter = null;
     _actionList      = null;
 }
Пример #4
0
 public TriggerConditionFlight(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type            = TriggerConditionType.Flight;
     _propertyIndex   = -1;
     _fieldInfo       = null;
     _propertyInfo    = null;
     _methodInfo      = null;
     _propertySource  = null;
     _methodParameter = null;
     _comparator      = ComparatorType.Equals;
     _targetValue     = null;
 }
Пример #5
0
        public void OnLoad(ConfigNode node, VesselTriggers triggerConfig)
        {
            bool              dataFound  = false;
            ConfigNode        childNode  = null;
            int               nbItem     = 0;
            TriggerActionType actionType = (TriggerActionType)(-1);

            dataFound = node.TryGetValue(KEY_NB_ACTIONS, ref nbItem);
            if (dataFound)
            {
                for (int i = 0; i < nbItem; i++)
                {
                    TriggerAction action = null;
                    dataFound = node.TryGetNode(KEY_PREF_ACTION + i, ref childNode);
                    if (dataFound)
                    {
                        dataFound = childNode.TryGetEnum <TriggerActionType>("type", ref actionType, (TriggerActionType)(-1));
                        if (dataFound)
                        {
                            switch (actionType)
                            {
                            case TriggerActionType.Part:
                                action = new TriggerActionPart(triggerConfig);
                                break;

                            case TriggerActionType.Flight:
                                action = new TriggerActionFlight(triggerConfig);
                                break;

                            case TriggerActionType.Message:
                                action = new TriggerActionMessage(triggerConfig);
                                break;

                            case TriggerActionType.Timer:
                                action = new TriggerActionTimer(triggerConfig);
                                break;

                            default:
                                break;
                            }
                            if (action != null)
                            {
                                dataFound = ConfigNode.LoadObjectFromConfig(action, childNode);
                                if (dataFound)
                                {
                                    _actions.Add(action);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
        public void Start()
        {
            Vessel vessel = FlightGlobals.ActiveVessel;

            foreach (VesselModule module in vessel.vesselModules)
            {
                if (module is VesselTriggers)
                {
                    _vesselTriggers = (VesselTriggers)module;
                    _vesselTriggers.LoadPersistentData();
                    _eventUI.VesselTriggers     = _vesselTriggers;
                    _conditionUI.VesselTriggers = _vesselTriggers;
                    _actionUI.VesselTriggers    = _vesselTriggers;
                    _timerUI.VesselTriggers     = _vesselTriggers;
                    break;
                }
            }
        }
Пример #7
0
        public TriggerEvent(TriggerEventType type, VesselTriggers vesselTriggers)
        {
            _type             = type;
            _hasBeenTriggered = false;
            AutoReset         = false;
            switch (_type)
            {
            case TriggerEventType.Part:
                _condition = new TriggerConditionPart(vesselTriggers);
                break;

            case TriggerEventType.Flight:
                _condition = new TriggerConditionFlight(vesselTriggers);
                break;

            case TriggerEventType.Timer:
                _condition = new TriggerConditionTimer(vesselTriggers);
                break;
            }
            _previousValue = true;
        }
Пример #8
0
        public void OnLoad(ConfigNode node, VesselTriggers triggerConfig)
        {
            bool             dataFound = false;
            ConfigNode       childNode = null;
            TriggerEventType eventType = (TriggerEventType)(-1);

            // Event
            dataFound = node.TryGetNode(KEY_EVENT, ref childNode);
            if (dataFound)
            {
                dataFound = childNode.TryGetEnum <TriggerEventType>("type", ref eventType, (TriggerEventType)(-1));
                if (dataFound)
                {
                    _event = new TriggerEvent(eventType, triggerConfig);
                    if (_event != null)
                    {
                        ConfigNode.LoadObjectFromConfig(_event, childNode);
                    }
                }
            }
            // Condition
            dataFound = node.TryGetNode(KEY_CONDITIONS, ref childNode);
            if (dataFound)
            {
                _conditions = new TriggerConditions();
                ConfigNode.LoadObjectFromConfig(_conditions, childNode);
                _conditions.OnLoad(childNode, triggerConfig);
            }
            // Actions
            dataFound = node.TryGetNode(KEY_ACTIONS, ref childNode);
            if (dataFound)
            {
                _actions = new TriggerActions();
                ConfigNode.LoadObjectFromConfig(_actions, childNode);
                _actions.OnLoad(childNode, triggerConfig);
            }
        }
Пример #9
0
 public TriggerConditionTimer(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type  = TriggerConditionType.Timer;
     _timer = null;
     _name  = "";
 }
Пример #10
0
        public void Awake()
        {
            _configFileDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), CONFIG_DIR);
            _configFile    = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), CONFIG_DIR, CONFIG_FILE);

            Vector2 eventUiPos     = _windowRect.position + new Vector2(100, 50);
            Vector2 conditionUiPos = _windowRect.position + new Vector2(200, 100);
            Vector2 actionUiPos    = _windowRect.position + new Vector2(300, 150);
            Vector2 timerConfUiPos = _windowRect.position + new Vector2(400, 200);
            Vector2 timerDispUiPos = new Vector2(Screen.width - 350, 20);

            try {
                Vector2    readPos      = Vector2.zero;
                ConfigNode addonConfig  = ConfigNode.Load(_configFile);
                ConfigNode windowConfig = addonConfig.GetNode(KEY_WINDOW_NODE);
                if (windowConfig.TryGetValue(KEY_TRIGGER_UI_POS, ref readPos))
                {
                    _windowRect.position = readPos;
                }
                if (windowConfig.TryGetValue(KEY_EVENT_UI_POS, ref readPos))
                {
                    eventUiPos = readPos;
                }
                if (windowConfig.TryGetValue(KEY_CONDITION_UI_POS, ref readPos))
                {
                    conditionUiPos = readPos;
                }
                if (windowConfig.TryGetValue(KEY_ACTION_UI_POS, ref readPos))
                {
                    actionUiPos = readPos;
                }
                if (windowConfig.TryGetValue(KEY_TIMER_CONF_UI_POS, ref readPos))
                {
                    timerConfUiPos = readPos;
                }
                if (windowConfig.TryGetValue(KEY_TIMER_DISP_UI_POS, ref readPos))
                {
                    timerDispUiPos = readPos;
                }
            } catch (Exception) { }

            if (TEXTURE_BUTTON == null)
            {
                TEXTURE_BUTTON = new Texture2D(1, 1);
                try {
                    byte[] bytes = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ICONE_FILE));
                    TEXTURE_BUTTON.LoadImage(bytes);
                } catch (Exception e) {
                    Debug.LogError(Utils.DEBUG_PREFIX + e.Message);
                    TEXTURE_BUTTON.SetPixel(0, 0, Color.blue);
                    TEXTURE_BUTTON.Apply();
                }
            }

            _mainButton = ApplicationLauncher.Instance.AddModApplication(
                () => { _displayWindow = true; }, () => { _displayWindow = false; },
                null, null, null, null,
                ApplicationLauncher.AppScenes.FLIGHT, TEXTURE_BUTTON);

            _eventUI        = new EventUI(eventUiPos);
            _conditionUI    = new ConditionUI(conditionUiPos);
            _actionUI       = new ActionUI(actionUiPos);
            _timerUI        = new TimerUI(timerConfUiPos, timerDispUiPos);
            _vesselTriggers = null;
        }
Пример #11
0
 public TriggerCondition(TriggerCondition other)
 {
     _vesselTriggers = other._vesselTriggers;
     _type           = (TriggerConditionType)(-1);
     _modified       = false;
 }
Пример #12
0
 public TriggerCondition(VesselTriggers vesselTriggers)
 {
     _vesselTriggers = vesselTriggers;
     _type           = (TriggerConditionType)(-1);
     _modified       = true;
 }
Пример #13
0
 public TriggerActionMessage(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type    = TriggerActionType.Message;
     _message = "";
 }