/// <summary> /// used as a delegate for GetMatchedTradables, this method adds a rule if it matches. /// It also adds all Things within the transferables onto the look list that matched. /// /// Worth noting that GetMatchedTradables ActionOnRule runs whether matched or not, but the Transferables list would be empty if no matches occured. /// </summary> /// <param name="Transferables"></param> /// <param name="Rule"></param> public static void DoOnRule(List <TransferableOneWay> Transferables, ANRule Rule) { if ((Rule.NotifyUnder && CacheCount < Rule.Quantity) || (!Rule.NotifyUnder && CacheCount > Rule.Quantity)) { CacheRuleMatchList.Add(Rule); CacheLookList.AddRange((from el in Transferables from li in el.things select li).ToList()); } CacheCount = 0; }
/// <summary> /// must be included, used for copying nodes/groups /// /// should also include inherited members Nodes_, Active_ and RuleLabel /// </summary> /// <returns></returns> public override IRule DeepCopy() { ANRule temp = new ANRule { Nodes_ = (from el in Nodes_ select el.DeepCopy()).ToList(), Active_ = Active_, IsChain_ = IsChain_, RuleChain_ = (from rc in RuleChain_ select rc.DeepCopy() as ANRule).ToList(), RuleLabel = RuleLabel, NotifyUnder_ = NotifyUnder_, Quant_ = Quant_, }; return(temp); }
public override void DoWindowContents(Rect inRect) { //create a 2 by 1 table ASTable table = new ASTable(inRect, 2, 1, 4, 0); Rect selectable = table.GetRectangle(0, 0); //seperate bottom part for cancel button Rect cancelrect = selectable.BottomPartPixels(30f); selectable.height -= 30f; CompBox.DrawListBox(selectable); if (Widgets.ButtonText(cancelrect, "Close".Translate())) { Close(); } //if something is selected, get comp, create label; if (CompBox.GetSelectedIndex != -1) { TradeRequestComp tc = CompBox.GetSelected; Widgets.Label(table.GetRectangle(1, 0), "RWAutoSell.NotifySummary".Translate(tc.parent.Faction.Name, tc.requestCount + "x " + tc.requestThingDef.LabelCap, tc.rewards.ContentsString) //"From: " + Environment.NewLine + tc.parent.Faction.Name + Environment.NewLine + Environment.NewLine + //"Request: " + Environment.NewLine + tc.requestCount + "x " + tc.requestThingDef.LabelCap + Environment.NewLine + Environment.NewLine + //"Reward: " + Environment.NewLine + tc.rewards.ContentsString ); //create rule, add rule to comp, notify Maintab needs a refresh, close dialog if (Widgets.ButtonText(table.GetRectangle(1, 0).BottomPartPixels(30f), "Create")) { ANRule newrule = new ANRule(CompBox.GetSelected); map.GetComponent <ANMapComp>().Add(newrule); ASLibMod.GuiRefresh = true; Close(); } } }
/// <summary> /// used as a delegate for GetMatchedTradables, this method simply increments if a transferable matches a rule. /// /// unlike ActionOnRule delegates, ActionOnTransferable delegates only runs if a match occurs /// </summary> /// <param name="Transferable"></param> /// <param name="Rule"></param> public static void TransferableMatched(TransferableOneWay Transferable, ANRule Rule) { CacheCount += Transferable.MaxCount; }