Esempio n. 1
0
 public Trigger()
 {
     Name        = "";
     _event      = null;
     _conditions = new TriggerConditions();
     _actions    = new TriggerActions();
 }
Esempio n. 2
0
 public void Configure(Trigger triggerToConfigure)
 {
     if ((triggerToConfigure == null) || (triggerToConfigure == _triggerToConfigure))
     {
         return;
     }
     _triggerToConfigure = triggerToConfigure;
     _conditions         = new TriggerConditions(_triggerToConfigure.TriggerConditions);
     SelectCondition(-1);
 }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
 public TriggerConditions(TriggerConditions other)
 {
     _conditions = new List <TriggerCondition>();
     foreach (TriggerCondition condition in other._conditions)
     {
         if (condition == null)
         {
             _conditions.Add(null);
         }
         else if (condition is TriggerConditionPart)
         {
             _conditions.Add(new TriggerConditionPart((TriggerConditionPart)condition));
         }
         else if (condition is TriggerConditionFlight)
         {
             _conditions.Add(new TriggerConditionFlight((TriggerConditionFlight)condition));
         }
         else if (condition is TriggerConditionTimer)
         {
             _conditions.Add(new TriggerConditionTimer((TriggerConditionTimer)condition));
         }
     }
     Combination = other.Combination;
 }