示例#1
0
 public Trigger()
 {
     Name        = "";
     _event      = null;
     _conditions = new TriggerConditions();
     _actions    = new TriggerActions();
 }
示例#2
0
 public TriggerActions(TriggerActions other)
 {
     _actions = new List <TriggerAction>();
     foreach (TriggerAction action in other._actions)
     {
         if (action == null)
         {
             _actions.Add(null);
         }
         else if (action is TriggerActionPart)
         {
             _actions.Add(new TriggerActionPart((TriggerActionPart)action));
         }
         else if (action is TriggerActionFlight)
         {
             _actions.Add(new TriggerActionFlight((TriggerActionFlight)action));
         }
         else if (action is TriggerActionMessage)
         {
             _actions.Add(new TriggerActionMessage((TriggerActionMessage)action));
         }
         else if (action is TriggerActionTimer)
         {
             _actions.Add(new TriggerActionTimer((TriggerActionTimer)action));
         }
     }
 }
示例#3
0
 public void Configure(Trigger triggerToConfigure)
 {
     if ((triggerToConfigure == null) || (triggerToConfigure == _triggerToConfigure))
     {
         return;
     }
     _triggerToConfigure = triggerToConfigure;
     _actions            = new TriggerActions(_triggerToConfigure.TriggerActions);
     SelectAction(-1);
 }
示例#4
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);
            }
        }