private void Start() { SuitCombos sc = GameDatabase.Instance.GetComponent <SuitCombos>(); SuitVariants = sc.StockCombos; Debug.Log("[SuitedAndBooted]: Loaded " + sc.StockCombos.Count + " stock suit variants"); for (int i = 0; i < sc.ExtraCombos.Count; i++) { SuitVariants.Add(sc.ExtraCombos.ElementAt(i)); } Debug.Log("[SuitedAndBooted]: Loaded " + sc.ExtraCombos.Count + " modded suit variants"); ConfigNode baseNode = GameDatabase.Instance.GetConfigNode("SuitedAndBooted/SUITEDANDBOOTED"); ConfigNode[] ruleNodes = baseNode.GetNodes("RULE"); for (int i = 0; i < ruleNodes.Length; i++) { try { SuitRule sr = new SuitRule(ruleNodes.ElementAt(i)); if (Rules.ContainsKey(sr.Priority)) { Debug.Log("[SuitManager]: WARNING: Multiple rules defined with priority " + sr.Priority + " only one will be applied"); Debug.Log("[SuitManager]: Duplicate Values: " + sr.Name + " + " + Rules[sr.Priority].Name); } Rules.Add(sr.Priority, sr); } catch (Exception ex) { Debug.Log("[SuitManager]: " + ex); } } RunRules(); }
public void RunRules() { List <ProtoCrewMember> crewList = HighLogic.CurrentGame.CrewRoster.Kerbals().ToList(); //Run rules in reverse order - highest priority gets applied last for (int i = Rules.Count - 1; i >= 0; i--) { SuitRule r = Rules[i]; foreach (ProtoCrewMember p in crewList) { if (!r.RuleMatch(p)) { continue; } p.suit = GetCorrectSuitForVariant(r.suitType); p.ComboId = MatchSuitToId(p.gender, r.Suit); } } }