Exemplo n.º 1
0
 public TriggerActionTimer(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type        = TriggerActionType.Timer;
     _timer       = null;
     _name        = "";
     _timerAction = TimerActionType.Start;
 }
Exemplo n.º 2
0
 public TriggerConditionTimer(TriggerConditionTimer other) : base(other)
 {
     _type  = TriggerConditionType.Timer;
     _timer = null;
     // Automatic call of Name_set
     Name = other.Name;
     _targetDate.ValueStr = other._targetDate.ValueStr;
     UpdatePersistentData();
 }
Exemplo n.º 3
0
 public TriggerActionTimer(TriggerActionTimer other) : base(other)
 {
     _type  = TriggerActionType.Timer;
     _timer = null;
     // Automatic call of Name_set
     Name         = other.Name;
     _timerAction = other._timerAction;
     _modified    = false;
     UpdatePersistentData();
 }
Exemplo n.º 4
0
 public override string Description(bool debug = false)
 {
     if (IsValid())
     {
         string result = _timer.ToString();
         if (debug)
         {
             result += " [" + _timer.DisplayedValue() + "/" + AbsTimer.DateToString((double)_targetDate.Value) + "]";
         }
         return(result);
     }
     else
     {
         return("invalid");
     }
 }
Exemplo n.º 5
0
 public TriggerConditionTimer(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type  = TriggerConditionType.Timer;
     _timer = null;
     _name  = "";
 }
Exemplo n.º 6
0
        protected override void OnLoad(ConfigNode node)
        {
            try {
                _triggers = new List <Trigger>();
                _timers   = new Dictionary <string, AbsTimer>();

                bool       dataFound = false;
                ConfigNode childNode = null;
                int        nbItem    = 0;
                string     type      = "";

                // Timers
                dataFound = node.TryGetValue(KEY_NB_TIMER, ref nbItem);
                if (dataFound)
                {
                    for (int i = 0; i < nbItem; i++)
                    {
                        AbsTimer timer = null;
                        dataFound = node.TryGetNode(KEY_PREF_TIMER + i, ref childNode);
                        if (dataFound)
                        {
                            dataFound = childNode.TryGetValue("type", ref type);
                            if (type == "T")
                            {
                                timer = ConfigNode.CreateObjectFromConfig <Timer>(childNode);
                            }
                            else if (type == "C")
                            {
                                timer = ConfigNode.CreateObjectFromConfig <Countdown>(childNode);
                                ((Countdown)timer).InitStrDate = ((Countdown)timer).InitDate.ToString();
                            }
                        }
                        if (timer != null)
                        {
                            _timers.Add(timer.Name, timer);
                        }
                        else
                        {
                            Debug.LogError(Utils.DEBUG_PREFIX + "OnLoad: Cannot load timer: " + childNode);
                        }
                    }
                }

                // Triggers
                dataFound = node.TryGetValue(KEY_NB_TRIG, ref nbItem);
                if (dataFound)
                {
                    for (int i = 0; i < nbItem; i++)
                    {
                        dataFound = node.TryGetNode(KEY_PREF_TRIG + i, ref childNode);

                        Trigger newTrigger = ConfigNode.CreateObjectFromConfig <Trigger>(childNode);
                        if (newTrigger != null)
                        {
                            newTrigger.OnLoad(childNode, this);
                            _triggers.Add(newTrigger);
                        }
                    }
                }
            } catch (Exception e) {
                Debug.LogError(Utils.DEBUG_PREFIX + e.Message);
            }
        }