Exemple #1
0
        private static List <DebugMenuOption> Options_AddAffix()
        {
            List <DebugMenuOption> debugMenuOptionList = new List <DebugMenuOption>();

            foreach (LootAffixDef affixDef in DefDatabase <LootAffixDef> .AllDefs.OrderBy(lad => lad.affixCost))
            {
                LootAffixDef localDef = affixDef;
                debugMenuOptionList.Add(new DebugMenuOption(localDef.defName, DebugMenuOptionMode.Tool, () => {
                    CompLootAffixableThing comp = Find.CurrentMap.thingGrid.
                                                  ThingsAt(UI.MouseCell()).
                                                  Where(t => t is ThingWithComps).Cast <ThingWithComps>().
                                                  Select(twc => twc.TryGetComp <CompLootAffixableThing>()).
                                                  Where(c => c is CompLootAffixableThing).
                                                  FirstOrDefault()
                    ;

                    var lads = comp.AllAffixDefs;
                    if (lads.Contains(localDef) || lads.Count >= 4)
                    {
                        return;
                    }
                    lads.Add(localDef);
                    comp.PostAffixCleanup();
                }));
            }
            return(debugMenuOptionList);
        }
Exemple #2
0
        private static List <DebugMenuOption> Options_RemoveAffix(CompLootAffixableThing comp)
        {
            List <DebugMenuOption> debugMenuOptionList = new List <DebugMenuOption>();

            foreach (LootAffixDef affixDef in comp.AllAffixDefs)
            {
                LootAffixDef localDef = affixDef;
                debugMenuOptionList.Add(new DebugMenuOption(comp.AllAffixesByAffixDefs[localDef], DebugMenuOptionMode.Action, () => {
                    int i = comp.AllAffixDefs.IndexOf(localDef);
                    comp.AllAffixDefs.RemoveAt(i);
                    comp.PostAffixCleanup();
                }));
            }
            return(debugMenuOptionList);
        }
 static public void InitializeAffixes(this CompLootAffixableThing comp, float affixPoints = 0, int ttlAffixes = 0)     // options for debug only
 {
     comp.affixes.Clear();
     comp.AddNewAffixes(affixPoints, ttlAffixes);
     comp.PostAffixCleanup();
 }