Ejemplo n.º 1
0
 private void DoStageDropdown(WidgetRow row, int setI, Action <int> selectedAction)
 {
     if (row.ButtonText(Sel.stages[setI]?.label.CapitalizeFirst() ?? "TD.Invisible".Translate()))
     {
         List <FloatMenuOption> options      = new List <FloatMenuOption>();
         IEnumerable <int>      stageIndices = ContentsUtility.onlyAvailable ?
                                               ContentsUtility.AvailableInGame(t => ThoughtStagesForThing(t, Sel)) :
                                               Enumerable.Range(0, Sel.stages.Count);
         foreach (int i in stageIndices.Where(i => DebugSettings.godMode || (Sel.stages[i]?.visible ?? false)))
         {
             int localI = i;
             options.Add(new FloatMenuOption(Sel.stages[i]?.label.CapitalizeFirst() ?? "TD.Invisible".Translate(), () => selectedAction(localI)));
         }
         MainTabWindow_List.DoFloatMenu(options);
     }
 }
        protected bool parent;        //or child

        public override bool FilterApplies(Thing t)
        {
            if (parent)
            {
                IThingHolder parent = t.ParentHolder;
                while (parent.IsValidHolder())
                {
                    if (parent is Thing parentThing && base.FilterApplies(parentThing))
                    {
                        return(true);
                    }
                    parent = parent.ParentHolder;
                }
                return(false);
            }
            else
            {
                return(ContentsUtility.AllKnownThings(t as IThingHolder).Any(child => base.FilterApplies(child)));
            }
        }
Ejemplo n.º 3
0
        public List <Thing> Get(Map map)
        {
            IEnumerable <Thing> allThings = Enumerable.Empty <Thing>();

            switch (baseType)
            {
            case BaseListType.Selectable:
                allThings = map.listerThings.AllThings.Where(t => t.def.selectable);
                break;

            case BaseListType.All:
                allThings = ContentsUtility.AllKnownThings(map);
                break;

            case BaseListType.Buildings:
                allThings = map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial);
                break;

            case BaseListType.Natural:
                allThings = map.listerThings.AllThings.Where(t => t.def.filthLeaving == ThingDefOf.Filth_RubbleRock);
                break;

            case BaseListType.Plants:
                allThings = map.listerThings.ThingsInGroup(ThingRequestGroup.Plant);
                break;

            case BaseListType.Inventory:
                List <IThingHolder> holders = new List <IThingHolder>();
                map.GetChildHolders(holders);
                List <Thing> list = new List <Thing>();
                foreach (IThingHolder holder in holders.Where(ContentsUtility.CanPeekInventory))
                {
                    list.AddRange(ContentsUtility.AllKnownThings(holder));
                }
                allThings = list;
                break;

            case BaseListType.Items:
                allThings = map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways);
                break;

            case BaseListType.Everyone:
                allThings = map.mapPawns.AllPawnsSpawned.Cast <Thing>();
                break;

            case BaseListType.Colonists:
                allThings = map.mapPawns.FreeColonistsSpawned.Cast <Thing>();
                break;

            case BaseListType.Animals:
                allThings = map.mapPawns.AllPawnsSpawned.Where(p => !p.RaceProps.Humanlike).Cast <Thing>();
                break;

            //Devmode options:
            case BaseListType.Haulables:
                allThings = map.listerHaulables.ThingsPotentiallyNeedingHauling();
                break;

            case BaseListType.Mergables:
                allThings = map.listerMergeables.ThingsPotentiallyNeedingMerging();
                break;

            case BaseListType.FilthInHomeArea:
                allThings = map.listerFilthInHomeArea.FilthInHomeArea;
                break;
            }

            //Filters
            allThings = allThings.Where(t => !(t.ParentHolder is Corpse) && !(t.ParentHolder is MinifiedThing));
            if (!DebugSettings.godMode)
            {
                allThings = allThings.Where(t => ValidDef(t.def));
                allThings = allThings.Where(t => !t.PositionHeld.Fogged(map));
            }
            foreach (ListFilter filter in filters)
            {
                allThings = filter.Apply(allThings);
            }

            //Sort
            return(allThings.OrderBy(t => t.def.shortHash).ThenBy(t => t.Stuff?.shortHash ?? 0).ThenBy(t => t.Position.x + t.Position.z * 1000).ToList());
        }
Ejemplo n.º 4
0
 public override IEnumerable <TraitDef> Options() =>
 ContentsUtility.onlyAvailable
                         ? ContentsUtility.AvailableInGame(t => (t as Pawn)?.story?.traits.allTraits.Select(tr => tr.def) ?? Enumerable.Empty <TraitDef>())
                         : base.Options();
Ejemplo n.º 5
0
 public override IEnumerable <ThoughtDef> Options() =>
 ContentsUtility.onlyAvailable
                         ? ContentsUtility.AvailableInGame(ThoughtsForThing)
                         : base.Options();