private static void HandleExternVar(FoundryObject foundryObject, List <string> importLines, ref int currentIndex)
        {
            var externVar = new ExternalVariable();
            var text      = importLines[currentIndex];
            var endText   = text.Replace(Constants.Component.ExternalVar.Title, Constants.Component.ExternalVar.End);

            //go until it finds the end
            for (; currentIndex < importLines.Count - 1; currentIndex++)
            {
                var currentText = importLines[currentIndex];
                if (currentText.Equals(endText))
                {
                    currentIndex++;
                    return;
                }

                //it's either going to be ExternVar Type or Specific Value.  if it isn't then oops I didn't handle it and it will be ignored
                if (currentText.Contains(Constants.Component.ExternalVar.Title))
                {
                    var name = currentText.Trim().Replace(Constants.Component.ExternalVar.Title, "");
                    externVar.Name = name;
                }
                else if (currentText.Contains(Constants.Component.ExternalVar.Type))
                {
                    var type = currentText.Trim().Replace(Constants.Component.ExternalVar.Type, "");
                    externVar.Type = type;
                }
                else if (currentText.Contains(Constants.Component.ExternalVar.SpecificValue.Title))
                {
                    HandleSpecificValue(externVar, importLines, ref currentIndex);
                }
            }

            foundryObject.ExternalVariables.Add(externVar.Name, externVar);
        }
        private static void HandleWhen(FoundryObject foundryObject, List <string> importLines, ref int currentIndex)
        {
            //there are two types of Whens and those can be two types too
            //they are When and HideWhen
            //they are with parameters (MAP_START, MANUAL) or with parameters (everything else)

            List <Trigger> whenObjects = new List <Trigger>();
            var            split       = importLines[currentIndex].Split(new char[] { ' ' });

            var whenType    = split[0].Trim();
            var triggerType = Constants.Trigger.ObjectiveComplete.Title; //default is objective complete

            if (split.Length > 1)
            {
                triggerType = split[1];
            }

            //these triggers have no stats
            if (triggerType.Equals(Constants.Trigger.MapStart) ||
                triggerType.Equals(Constants.Trigger.Manual) ||
                triggerType.Equals(Constants.Trigger.Component.CurrentComponentComplete) ||
                triggerType.Equals(Constants.Trigger.ObjectiveStart) ||
                triggerType.Equals(Constants.Trigger.MissionStart))
            {
                whenObjects.Add(new Trigger(triggerType));
            }
            else
            {
                var obj = GetFoundryObjectByIndex(importLines, ref currentIndex, triggerType);
                //check the COMPONENT_ID and OBJECTIVE_ID fields.  need to see if there are multiple components or objectives (not sure if objective is possible)
                if (obj.Fields.ContainsKey(Constants.Trigger.Component.ComponentID))
                {
                    var fieldValue = obj.Fields[Constants.Trigger.Component.ComponentID].ToString();
                    if (fieldValue.Contains(","))
                    {
                        var ids = fieldValue.Split(new char[] { ',' });
                        foreach (var id in ids)
                        {
                            var trig = new ComponentTrigger(triggerType);
                            trig.Fields[Constants.Trigger.Component.ComponentID] = id;
                            whenObjects.Add(trig);
                        }
                    }
                    else
                    {
                        whenObjects.Add((Trigger)obj);
                    }
                }
                else if (obj.Fields.ContainsKey(Constants.Trigger.ObjectiveComplete.ObjectiveID))
                {
                    var fieldValue = obj.Fields[Constants.Trigger.ObjectiveComplete.ObjectiveID].ToString();
                    if (fieldValue.Contains(","))
                    {
                        var ids = fieldValue.Split(new char[] { ',' });
                        foreach (var id in ids)
                        {
                            var trig = new ObjectiveCompleteTrigger();

                            if (id == "-1") //sometimes it can be -1 so we need to drop back to the parent and get the OBjectiveId from that
                            {
                            }

                            trig.Fields[Constants.Trigger.ObjectiveComplete.ObjectiveID] = id;
                            whenObjects.Add(trig);
                        }
                    }
                    else
                    {
                        whenObjects.Add((Trigger)obj);
                    }
                }
                else
                {
                    //if it doesn't have any of them just add the trigger
                    whenObjects.Add((Trigger)obj);
                }
            }
            if (foundryObject.Title.Equals(Constants.Component.Title))
            {
                var component = (Component)foundryObject;
                //got the object now set it in the proper spot
                if (whenType.Equals(Constants.Trigger.When))
                {
                    component.When.AddRange(whenObjects);
                }
                else //if (whenType.Equals(Constants.Trigger.HideWhen))
                {
                    component.HideWhen.AddRange(whenObjects);
                }
            }
            else //if (foundryObject.Title.Equals(Constants.Dialog.Action.Title))
            {
                var action = (DialogAction)foundryObject;
                if (whenType.Equals(Constants.Component.ShowWhen.Title))
                {
                    action.ShowWhen.AddRange(whenObjects);
                }
                else //if (whenType.Equals(Constants.Trigger.HideWhen))
                {
                    action.HideWhen.AddRange(whenObjects);
                }
            }
        }