protected StatusEffect(XElement element) { requiredItems = new List <RelatedItem>(); #if CLIENT particleEmitters = new List <ParticleEmitterPrefab>(); #endif IEnumerable <XAttribute> attributes = element.Attributes(); List <XAttribute> propertyAttributes = new List <XAttribute>(); foreach (XAttribute attribute in attributes) { switch (attribute.Name.ToString()) { case "type": try { type = (ActionType)Enum.Parse(typeof(ActionType), attribute.Value, true); } catch { string[] split = attribute.Value.Split('='); type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true); string[] containingNames = split[1].Split(','); onContainingNames = new HashSet <string>(); for (int i = 0; i < containingNames.Length; i++) { onContainingNames.Add(containingNames[i].Trim()); } } break; case "target": string[] Flags = attribute.Value.Split(','); foreach (string s in Flags) { targetTypes |= (TargetType)Enum.Parse(typeof(TargetType), s, true); } break; case "disabledeltatime": disableDeltaTime = ToolBox.GetAttributeBool(attribute, false); break; case "setvalue": setValue = ToolBox.GetAttributeBool(attribute, false); break; case "targetnames": string[] names = attribute.Value.Split(','); targetNames = new HashSet <string>(); for (int i = 0; i < names.Length; i++) { targetNames.Add(names[i].Trim()); } break; case "duration": duration = ToolBox.GetAttributeFloat(attribute, 0.0f); break; #if CLIENT case "sound": sound = Sound.Load(attribute.Value.ToString()); break; #endif default: propertyAttributes.Add(attribute); break; } } int count = propertyAttributes.Count; propertyNames = new string[count]; propertyEffects = new object[count]; int n = 0; foreach (XAttribute attribute in propertyAttributes) { propertyNames[n] = attribute.Name.ToString().ToLowerInvariant(); propertyEffects[n] = ToolBox.GetAttributeObject(attribute); n++; } foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "explosion": explosion = new Explosion(subElement); break; case "fire": FireSize = ToolBox.GetAttributeFloat(subElement, "size", 10.0f); break; case "use": case "useitem": useItem = true; break; case "requireditem": case "requireditems": RelatedItem newRequiredItem = RelatedItem.Load(subElement); if (newRequiredItem == null) { continue; } requiredItems.Add(newRequiredItem); break; #if CLIENT case "particleemitter": particleEmitters.Add(new ParticleEmitterPrefab(subElement)); break; #endif } } }