Пример #1
0
        // Return the associate extended data for a given bill, creating a new association
        // if required.
        public ExtendedBillData GetExtendedDataFor(Bill_Production bill)
        {
            var loadId = GetBillId(bill);

            if (_store.TryGetValue(loadId, out ExtendedBillData data))
            {
                return(data);
            }

            ExtendedBillData newExtendedData;

            if (bill is IBillWithThingFilter)
            {
                Main.Instance.Logger.Warning(
                    "IW.FoundOldBillText".Translate() + " " + $"({bill.GetUniqueLoadID()})" + ", " + "IW.MigratingToNewFormat".Translate());

                newExtendedData = new ExtendedBillData(bill);
            }
            else
            {
                newExtendedData = new ExtendedBillData();
                if (CanOutputBeFiltered(bill))
                {
                    newExtendedData.SetDefaultFilter(bill);
                }
            }

            _store[loadId] = newExtendedData;
            return(newExtendedData);
        }
Пример #2
0
 public void CloneFrom(ExtendedBillData other, bool cloneName)
 {
     CountAway = other.CountAway;
     if (cloneName)
     {
         Name = other.Name;
     }
 }
 public void CloneFrom(ExtendedBillData other)
 {
     OutputFilter.CopyAllowancesFrom(other.OutputFilter);
     AllowDeadmansApparel = other.AllowDeadmansApparel;
     CountWornApparel     = other.CountWornApparel;
     UseInputFilter       = other.UseInputFilter;
     Worker             = other.Worker;
     Name               = other.Name;
     _countingStockpile = other._countingStockpile;
     _takeToStockpile   = other._takeToStockpile;
 }
        public Dialog_ThingFilter(ExtendedBillData e, Window w)
        {
            reOpenWindow = w;
            extendedBill = e;

            filter = new ThingFilter();
            if (extendedBill.ProductAdditionalFilter != null)
            {
                filter.CopyAllowancesFrom(extendedBill.ProductAdditionalFilter);
            }
        }
        // Return the associate extended data for a given bill, creating a new association
        // if required.
        public ExtendedBillData GetOrCreateExtendedDataFor(Bill_Production bill)
        {
            var data = GetExtendedDataFor(bill);

            if (data != null)
            {
                return(data);
            }

            var newExtendedData = new ExtendedBillData();

            _store[bill] = newExtendedData;
            return(newExtendedData);
        }
        public void CloneFrom(ExtendedBillData other, bool cloneName)
        {
            CountAway = other.CountAway;
            ProductAdditionalFilter = new ThingFilter();
            if (other.ProductAdditionalFilter != null)
            {
                ProductAdditionalFilter.CopyAllowancesFrom(other.ProductAdditionalFilter);
            }

            if (cloneName)
            {
                Name = other.Name;
            }
        }
        // Count other things on map for ProductAdditionalFilter
        // This is sadly most of CountProducts re-written with a for loop for the additional defs
        public static int CountAdditionalProducts(RecipeWorkerCounter counter, Bill_Production bill, ExtendedBillData extendedBillData)
        {
            ThingFilter filter    = extendedBillData.ProductAdditionalFilter;
            bool        countAway = extendedBillData.CountAway;

            Map      map = bill.Map;
            ThingDef defaultProductDef = counter.recipe.products[0].thingDef;
            int      count             = 0;

            foreach (ThingDef def in filter.AllowedThingDefs)
            {
                //Obviously skip the default product, it was already counted
                if (def == defaultProductDef)
                {
                    continue;
                }

                //Same as CountProducts but now with other products
                if (def.CountAsResource && !bill.includeEquipped && (bill.includeTainted || !def.IsApparel || !def.apparel.careIfWornByCorpse) && bill.includeFromZone == null && bill.hpRange.min == 0f && bill.hpRange.max == 1f && bill.qualityRange.min == QualityCategory.Awful && bill.qualityRange.max == QualityCategory.Legendary && !bill.limitToAllowedStuff)
                {
                    count += map.resourceCounter.GetCount(def);
                    foreach (Pawn pawn in map.mapPawns.FreeColonistsSpawned)
                    {
                        count += CountPawnThings(pawn, counter, bill, def, true);
                    }
                }
                else if (bill.includeFromZone == null)
                {
                    count += counter.CountValidThings(map.listerThings.ThingsOfDef(def), bill, def);
                    if (def.Minifiable)
                    {
                        List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.MinifiedThing);
                        for (int i = 0; i < list.Count; i++)
                        {
                            MinifiedThing minifiedThing = (MinifiedThing)list[i];
                            if (counter.CountValidThing(minifiedThing.InnerThing, bill, def))
                            {
                                count += minifiedThing.stackCount * minifiedThing.InnerThing.stackCount;
                            }
                        }
                    }

                    if (!bill.includeEquipped)
                    {
                        //Still count Carried Things
                        foreach (Pawn pawn in map.mapPawns.FreeColonistsSpawned)
                        {
                            count += CountPawnThings(pawn, counter, bill, def, true);
                        }
                    }
                }
                else
                {
                    foreach (Thing current in bill.includeFromZone.AllContainedThings)
                    {
                        Thing innerIfMinified = current.GetInnerIfMinified();
                        if (counter.CountValidThing(innerIfMinified, bill, def))
                        {
                            count += innerIfMinified.stackCount;
                        }
                    }
                }

                if (bill.includeEquipped)
                {
                    foreach (Pawn pawn in map.mapPawns.FreeColonistsSpawned)
                    {
                        count += CountPawnThings(pawn, counter, bill, def);
                    }
                }
                if (countAway)
                {
                    count += CountAway(map, counter, bill, def);
                }
            }
            return(count);
        }
Пример #8
0
 public Dialog_RenameBill(ExtendedBillData extendedBill, string currentName)
 {
     _extendedBill = extendedBill;
     _currentName  = currentName;
     curName       = currentName;
 }