コード例 #1
0
ファイル: VesselTriggers.cs プロジェクト: Xaero86/KspTrigger
        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);
            }
        }