public void CheckForAllCustomActionsToRun(object os_obj) { OS os = (OS)os_obj; for (int index = 0; index < this.CustomActions.Count; ++index) { if (this.playerValue >= this.CustomActions[index].ValueRequiredForTrigger) { bool flag1 = true; if (!string.IsNullOrWhiteSpace(this.CustomActions[index].FlagsRequiredForTrigger)) { foreach (string flag2 in this.CustomActions[index].FlagsRequiredForTrigger.Split(Utils.commaDelim, StringSplitOptions.RemoveEmptyEntries)) { if (!os.Flags.HasFlag(flag2)) { flag1 = false; } } } if (flag1) { CustomFactionAction customAction = this.CustomActions[index]; this.CustomActions.RemoveAt(index); --index; customAction.Trigger((object)os); } } } }
public static CustomFaction DeserializeFromXmlReader(XmlReader rdr, string name, string id, int playerVal, bool playerHasPassed) { CustomFaction customFaction = new CustomFaction(name, 100); rdr.MoveToElement(); while (!rdr.EOF) { if (rdr.Name != "CustomFaction") { customFaction.CustomActions.Add(CustomFactionAction.Deserialize(rdr)); rdr.Read(); } else if (!(rdr.Name == "CustomFaction") || rdr.IsStartElement()) { rdr.Read(); } else { break; } while (!rdr.EOF && string.IsNullOrWhiteSpace(rdr.Name)) { rdr.Read(); } } return(customFaction); }
public static CustomFactionAction Deserialize(XmlReader rdr) { CustomFactionAction customFactionAction = new CustomFactionAction(); while (!rdr.EOF && (!(rdr.Name == "Action") || !rdr.IsStartElement())) { rdr.Read(); } if (rdr.EOF) { throw new FormatException("Expected Start element <Action> but did not find it in file!"); } if (rdr.MoveToAttribute("ValueRequired")) { customFactionAction.ValueRequiredForTrigger = rdr.ReadContentAsInt(); } if (rdr.MoveToAttribute("Flags")) { customFactionAction.FlagsRequiredForTrigger = rdr.ReadContentAsString(); } rdr.Read(); while (!rdr.EOF && (!(rdr.Name == "Action") || rdr.IsStartElement())) { if (string.IsNullOrWhiteSpace(rdr.Name)) { rdr.Read(); } else { SerializableAction serializableAction = SerializableAction.Deserialize(rdr); customFactionAction.TriggerActions.Add(serializableAction); rdr.Read(); while ((rdr.NodeType == XmlNodeType.Comment || rdr.NodeType == XmlNodeType.Whitespace || rdr.NodeType == XmlNodeType.SignificantWhitespace) && !rdr.EOF) { rdr.Read(); } } } if (rdr.EOF) { throw new FormatException("Unexpected end of file: No closing tag for </Action> Found!"); } return(customFactionAction); }