private static void UpdateArguments(StatusEffect se, AddStatusEffect script)
        {
            //New arguments
            foreach (var arg in se.Arguments)
            {
                if (script.Arguments.Where(a => a.Id == arg.Id).Count() == 0)
                {
                    script.Arguments.Add(new ScriptStatusEffectArgumentValue
                    {
                        Id       = arg.Id,
                        IsNumber = arg.IsNumber,
                        IsString = arg.IsString
                    });
                }
            }

            //Removed Arguments
            List <ScriptStatusEffectArgumentValue> markForDeletion = new List <ScriptStatusEffectArgumentValue>();

            foreach (var arg in script.Arguments)
            {
                if (se.Arguments.Where(a => a.Id == arg.Id).Count() == 0)
                {
                    markForDeletion.Add(arg);
                }
            }
            foreach (var arg in markForDeletion)
            {
                script.Arguments.Remove(arg);
            }

            //Update Argument Types and names if neccessary.

            foreach (var arg in se.Arguments)
            {
                var matching = script.Arguments.Where(a => a.Id == arg.Id).FirstOrDefault();
                if (matching != null)
                {
                    matching.Name     = arg.Name;
                    matching.IsNumber = arg.IsNumber;
                    matching.IsString = arg.IsString;
                }
            }
        }
        internal static ScriptLine FromXML(XElement xml)
        {
            AddStatusEffect ase = new AddStatusEffect();

            ase.AssociatedEffect.Ref = Guid.Parse(xml.Element("AssociatedEffect").Value);
            if (ase.AssociatedEffect.Value != null)
            {
                UpdateArguments(ase.AssociatedEffect.Value, ase);
                foreach (var arg in ase.Arguments)
                {
                    var element = xml.Element("Arguments").Elements("Argument").Where(a =>
                    {
                        Guid id;
                        if (Guid.TryParse(a.Element("Id").Value, out id))
                        {
                            return(id == arg.Id);
                        }
                        return(false);
                    });
                    if (element.Count() > 0)
                    {
                        if (arg.IsNumber)
                        {
                            int parse = 0;
                            if (Int32.TryParse(element.First().Element("Value").Value, out parse))
                            {
                                arg.NumberValue = parse;
                            }
                        }
                        else
                        {
                            arg.StringValue = element.First().Element("Value").Value;
                        }
                    }
                }
            }
            return(ase);
        }