Beispiel #1
0
        // Token: 0x0600000B RID: 11 RVA: 0x000020E0 File Offset: 0x000002E0
        public void SetQuality(QualityCategory q, ArtGenerationContext source)
        {
            this.qualityInt = QualityCategory.Normal;
            CompArt compArt = this.parent.TryGetComp <CompArt>();

            compArt.InitializeArt(source);
        }
Beispiel #2
0
        // Token: 0x06000004 RID: 4 RVA: 0x00002160 File Offset: 0x00000360
        private List <Thing> CreateLoot()
        {
            List <Thing> list = new List <Thing>();
            int          ItemCount;

            if (PropsResourceBox.spawnAll)
            {
                ItemCount = PropsResourceBox.possibleItems.Count;
            }
            else
            {
                ItemCount = Rand.RangeInclusive(PropsResourceBox.minItems, PropsResourceBox.maxItems);
            }
            for (int i = 0; i < ItemCount; i++)
            {
                ThingDef named = null;
                int      PerItemCount;
                int      j = 0;
                if (PropsResourceBox.PerItemCount != 0)
                {
                    PerItemCount = PropsResourceBox.PerItemCount;
                }
                else
                {
                    PerItemCount = Rand.RangeInclusive(PropsResourceBox.minPerItem, PropsResourceBox.maxPerItem);
                }
                if (!PropsResourceBox.possibleItems.NullOrEmpty())
                {
                    if (PropsResourceBox.spawnAll)
                    {
                        named = PropsResourceBox.possibleItems[i];
                    }
                    else
                    {
                        named = PropsResourceBox.possibleItems.RandomElement();
                    }
                }
                if (named != null)
                {
                    Thing thing = ThingMaker.MakeThing(named, GenStuff.RandomStuffFor(named));
                    thing.stackCount = PerItemCount;
                    CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing);
                    if (compQuality != null)
                    {
                        QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(Rand.RangeInclusive(0, 19), false);
                        compQuality.SetQuality(qualityCategory, 0);
                    }
                    CompArt compArt = ThingCompUtility.TryGetComp <CompArt>(thing);
                    if (compArt != null)
                    {
                        compArt.InitializeArt(0);
                    }
                    list.Add(thing);
                }
            }
            return(list);
        }
Beispiel #3
0
        public void SetNature(NatureCategory ccor, ArtGenerationContext source)
        {
            this.ccint = ccor;
            CompArt compArt = this.parent.TryGetComp <CompArt>();

            if (compArt != null)
            {
                compArt.InitializeArt(source);
            }
        }
Beispiel #4
0
        public static void FillTab(ITab_Art __instance)
        {
            Thing thing = Find.Selector.SingleSelectedThing;

            if (thing is MinifiedThing minifiedThing)
            {
                thing = minifiedThing.InnerThing;
            }
            CompArt art = thing?.TryGetComp <CompArt>();

            Rect rect1 = new Rect(10f, 270f, 100f, 20f);

            if (Widgets.ButtonText(rect1, "Reroll"))
            {
                art.InitializeArt(ArtGenerationContext.Colony);
            }

            // The following are much more involved and cannot use the default behavior
            Rect rect2 = new Rect(110f, 270f, 120f, 20f);

            if (Widgets.ButtonText(rect2, "Reroll Specific"))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (TaleDef taleDef in from def in DefDatabase <TaleDef> .AllDefs orderby def.defName select def)
                {
                    FloatMenuOption option = new FloatMenuOption(taleDef.defName, delegate
                    {
                        var tales    = Find.TaleManager.AllTalesListForReading.Where(it => it.def.defName == taleDef.defName);
                        var selected = tales.RandomElementByWeightWithFallback(it => it.InterestLevel + (1 / (1 + it.Uses)));
                        InitializeArt(art, selected);
                    });
                    options.Add(option);
                }
                Find.WindowStack.Add(new FloatMenu(options));
            }

            Rect rect3 = new Rect(230f, 270f, 120f, 20f);

            if (Widgets.ButtonText(rect3, "Reroll Colonist"))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (Pawn pawn in from p in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists orderby p.Name.ToStringShort select p)
                {
                    FloatMenuOption option = new FloatMenuOption(pawn.Name.ToStringShort, delegate
                    {
                        var tales    = Find.TaleManager.AllTalesListForReading.Where(it => it.Concerns(pawn));
                        var selected = tales.RandomElementByWeightWithFallback(it => it.InterestLevel + (1 / (1 + it.Uses)));
                        InitializeArt(art, selected);
                    });
                    options.Add(option);
                }
                Find.WindowStack.Add(new FloatMenu(options));
            }
        }
 internal static void _Notify_CorpseBuried(this Building_Grave _this, Pawn worker)
 {
     CompArt comp = _this.GetComp<CompArt>();
     if (comp != null && !comp.Active)
     {
         comp.JustCreatedBy(worker);
         comp.InitializeArt(_this.Corpse.InnerPawn);
         worker.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.FilledGraveBleedingHeart);
     }
     _this.Map.mapDrawer.MapMeshDirty(_this.Position, MapMeshFlag.Buildings);
 }
Beispiel #6
0
        // Token: 0x06000004 RID: 4 RVA: 0x00002160 File Offset: 0x00000360
        private List <Thing> CreateLoot()
        {
            List <Thing> list = new List <Thing>();
            int          ItemCount;

            if (PropsResourceBox.spawnAll)
            {
                ItemCount = PropsResourceBox.possibleItems.Count;
            }
            else
            {
                Rand.PushState();
                ItemCount = Rand.RangeInclusive(PropsResourceBox.minItems, PropsResourceBox.maxItems);
                Rand.PopState();
            }
            for (int i = 0; i < ItemCount; i++)
            {
                ThingDef named = null;
                int      PerItemCount;
                if (PropsResourceBox.PerItemCount != -1)
                {
                    PerItemCount = PropsResourceBox.PerItemCount;
                }
                else
                {
                    if (PropsResourceBox.randomCount)
                    {
                        Rand.PushState();
                        PerItemCount = Rand.RangeInclusive(PropsResourceBox.minPerItem, PropsResourceBox.maxPerItem);
                        Rand.PopState();
                    }
                    else
                    {
                        PerItemCount = PropsResourceBox.possibleItems[i].count;
                    }
                }
                if (!PropsResourceBox.possibleItems.NullOrEmpty())
                {
                    if (PropsResourceBox.spawnAll)
                    {
                        named = PropsResourceBox.possibleItems[i].thingDef;
                    }
                    else
                    {
                        Rand.PushState();
                        int element = Rand.RangeInclusive(0, PropsResourceBox.possibleItems.Count - 1);
                        Rand.PopState();
                        named = PropsResourceBox.possibleItems[element].thingDef;
                    }
                }
                if (named != null)
                {
                    Thing thing = ThingMaker.MakeThing(named, GenStuff.RandomStuffFor(named));
                    thing.stackCount = PerItemCount;
                    CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing);
                    if (compQuality != null)
                    {
                        QualityCategory qualityCategory = this.Quality;
                        compQuality.SetQuality(qualityCategory, 0);
                    }
                    CompArt compArt = ThingCompUtility.TryGetComp <CompArt>(thing);
                    if (compArt != null)
                    {
                        compArt.InitializeArt(0);
                    }
                    list.Add(thing);
                }
            }
            return(list);
        }
Beispiel #7
0
        // Token: 0x060000EF RID: 239 RVA: 0x00008640 File Offset: 0x00006840
        public static bool CompleteConstruction_Prefix(Frame __instance, Pawn worker)
        {
            bool flag = !worker.RaceProps.Humanlike;
            bool result;

            if (flag)
            {
                Thing thing = __instance.holdingOwner.Take(__instance);
                __instance.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
                Map map = worker.Map;
                __instance.Destroy(DestroyMode.Vanish);
                bool flag2 = __instance.GetStatValue(StatDefOf.WorkToBuild, true) > 150f && __instance.def.entityDefToBuild is ThingDef && ((ThingDef)__instance.def.entityDefToBuild).category == ThingCategory.Building;
                if (flag2)
                {
                    SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(thing.Position, map, false));
                }
                ThingDef thingDef = __instance.def.entityDefToBuild as ThingDef;
                Thing    thing2   = null;
                bool     flag3    = thingDef != null;
                if (flag3)
                {
                    thing2 = ThingMaker.MakeThing(thingDef, thing.Stuff);
                    thing2.SetFactionDirect(thing.Faction);
                    CompQuality compQuality = thing2.TryGetComp <CompQuality>();
                    bool        flag4       = compQuality != null;
                    if (flag4)
                    {
                        int             relevantSkillLevel = 1;
                        QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false);
                        compQuality.SetQuality(q, ArtGenerationContext.Colony);
                        QualityUtility.SendCraftNotification(thing2, worker);
                    }
                    CompArt compArt = thing2.TryGetComp <CompArt>();
                    bool    flag5   = compArt != null;
                    if (flag5)
                    {
                        bool flag6 = compQuality == null;
                        if (flag6)
                        {
                            compArt.InitializeArt(ArtGenerationContext.Colony);
                        }
                        compArt.JustCreatedBy(worker);
                    }
                    thing2.HitPoints = Mathf.CeilToInt((float)__instance.HitPoints / (float)thing.MaxHitPoints * (float)thing2.MaxHitPoints);
                    GenSpawn.Spawn(thing2, thing.Position, worker.Map, thing.Rotation, WipeMode.Vanish, false);
                }
                else
                {
                    map.terrainGrid.SetTerrain(thing.Position, (TerrainDef)__instance.def.entityDefToBuild);
                    FilthMaker.RemoveAllFilth(thing.Position, map);
                }
                worker.records.Increment(RecordDefOf.ThingsConstructed);
                bool flag7 = thing2 != null && thing2.GetStatValue(StatDefOf.WorkToBuild, true) >= 9500f;
                if (flag7)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, new object[]
                    {
                        worker,
                        thing2.def
                    });
                }
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
        private List <Thing> CreateLoot()
        {
            Dictionary <string, float> lootEntries = new Dictionary <string, float>();

            string[] arr       = GenMagic.Magic(LootTable).Split('|');
            int      setsMin   = int.Parse(arr[0]);
            int      setsMax   = int.Parse(arr[1]);
            int      setsCount = GenMagic.GetRealCount(parent, Rand.RangeInclusive(setsMin, Rand.RangeInclusive(setsMin, setsMax)));

            //Log.Message("min: " + setsMin + ", max: " + setsMax + ", final: " + setsCount);
            for (int i = 2, iLen = arr.Length; i < iLen; i++)
            {
                string str = arr[i];
                int    pos = str.FirstIndexOf(c => c == ';');
                lootEntries.Add(str.Substring(pos + 1), float.Parse(str.Substring(0, pos)));
                //Log.Message("key : " + str.Substring(pos + 1) + ", val: " + float.Parse(str.Substring(0, pos)));
            }
            List <Thing> lootList = new List <Thing>();

            for (int i = 0; i < setsCount; i++)
            {
                string chosenSet = lootEntries.RandomElementByWeight(kvp => kvp.Value * kvp.Value).Key;
                //Log.Message("chosen set: " + chosenSet);
                arr = chosenSet.Split(';');
                for (int j = 0, jLen = arr.Length; j < jLen; j++)
                {
                    string[] inner = arr[j].Split(',');
                    int      min   = (inner.Length <= 1) ? 1 : int.Parse(inner[1]);
                    int      max   = (inner.Length <= 2) ? min : int.Parse(inner[2]);
                    if (inner.Length >= 4)
                    {
                        max = Rand.RangeInclusive(max, int.Parse(inner[3]));
                    }
                    ThingDef def = DefDatabase <ThingDef> .GetNamed(inner[0]);

                    //Log.Message("def: " + def.defName + ", min: " + min + ", max: " + max);
                    if (def != null)
                    {
                        int countToDo = Rand.RangeInclusive(min, max);
                        while (countToDo > 0)
                        {
                            int count = Math.Min(countToDo, def.stackLimit);
                            countToDo -= count;
                            Thing thing = ThingMaker.MakeThing(def, GenStuff.RandomStuffFor(def));
                            thing.stackCount = count;
                            //Log.Message("thing: " + thing + ", stuff: " + thing.Stuff + ", count: " + count);
                            CompQuality compQuality = thing.TryGetComp <CompQuality>();
                            if (compQuality != null)
                            {
                                QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(Rand.RangeInclusive(0, 19), false);
                                compQuality.SetQuality(q, ArtGenerationContext.Outsider);
                            }
                            CompArt compArt = thing.TryGetComp <CompArt>();
                            if (compArt != null)
                            {
                                compArt.InitializeArt(ArtGenerationContext.Outsider);
                            }
                            lootList.Add(thing);
                        }
                    }
                }
            }
            return(lootList);
        }