internal static ItemInstance FromXML(XElement xml, Game g)
        {
            ItemInstance i = new ItemInstance(new ItemRef {
                LinkedItemId = Guid.Parse(xml.Element("ItemId").Value)
            }.LinkedItem);

            if (xml.Element("Name").Value != null && xml.Element("Name").Value != "")
            {
                i.CurrentName = xml.Element("Name").Value;
            }
            if (xml.Element("IconPath").Value != null && xml.Element("IconPath").Value != "")
            {
                i.CurrentIconPath = new ImageRef {
                    Path = xml.Element("IconPath").Value
                };
            }
            if (xml.Element("CanBeDropped").Value != null && xml.Element("CanBeDropped").Value != "")
            {
                i.CanBeDropped = Convert.ToBoolean(xml.Element("IconPath").Value);
            }
            foreach (var property in xml.Element("Properties").Elements("Property").Where(a => i.Properties.ContainsKey(a.Element("Name").Value)))
            {
                var propObj = i.Properties[property.Element("Name").Value];
                var propVar = VariableWrapper.FromXML(property.Element("Value").Element("Variable"), g, propObj.VariableBase);
                propObj.CurrentCommonEventValue = propVar.CurrentCommonEventValue;
                propObj.CurrentStringValue      = propVar.CurrentStringValue;
                propObj.CurrentNumberValue      = propVar.CurrentNumberValue;
                propObj.CurrentItemValue        = propVar.CurrentItemValue;
            }

            return(i);
        }
        public static StatusEffectWrapper FromXML(XElement xml, Game g)
        {
            var seRef = GenericRef <StatusEffect> .GetStatusEffectRef();

            seRef.Ref = Guid.Parse(xml.Element("LinkedStatusEffect").Value);
            StatusEffectWrapper wrapper = new StatusEffectWrapper(seRef, g);

            foreach (var tempVariableXml in xml.Element("TempVariables").Elements())
            {
                var tempVariable = VariableWrapper.FromXML(tempVariableXml, g, g.VarById[Guid.Parse(tempVariableXml.Element("Id").Value)].VariableBase);
                foreach (var a in wrapper.TempVariables)
                {
                    if (a.VariableBase.Id == tempVariable.VariableBase.Id)
                    {
                        a.CurrentCommonEventValue = tempVariable.CurrentCommonEventValue;
                        a.CurrentDateTimeValue    = tempVariable.CurrentDateTimeValue;
                        a.CurrentItemValue        = tempVariable.CurrentItemValue;
                        a.CurrentNumberValue      = tempVariable.CurrentNumberValue;
                        a.CurrentStringValue      = tempVariable.CurrentStringValue;
                    }
                }
            }
            foreach (var a in xml.Element("Arguments").Elements("Argument"))
            {
                Guid id = Guid.Parse(a.Element("Id").Value);

                if (a.Element("Type").Value == "number")
                {
                    wrapper.numberArguments.Add(new ScriptStatusEffectArgumentValue {
                        IsNumber = true, Id = id, NumberValue = Convert.ToInt32(a.Element("Value").Value)
                    });
                }
                else
                {
                    wrapper.stringArguments.Add(new ScriptStatusEffectArgumentValue {
                        IsString = true, Id = id, StringValue = a.Element("Value").Value
                    });
                }
            }

            return(wrapper);
        }