Example #1
0
        public TaleReference GetRandomTaleReferenceForArt(ArtGenerationContext source)
        {
            if (source == ArtGenerationContext.Outsider)
            {
                return(TaleReference.Taleless);
            }
            if (this.tales.Count == 0)
            {
                return(TaleReference.Taleless);
            }
            if (Rand.Value < 0.25f)
            {
                return(TaleReference.Taleless);
            }
            Tale tale;

            if (!(from x in this.tales
                  where x.def.usableForArt
                  select x).TryRandomElementByWeight((Tale ta) => ta.InterestLevel, out tale))
            {
                return(TaleReference.Taleless);
            }
            tale.Notify_NewlyUsed();
            return(new TaleReference(tale));
        }
Example #2
0
 private void InitializeArt(Thing relatedThing, ArtGenerationContext source)
 {
     if (taleRef != null)
     {
         taleRef.ReferenceDestroyed();
         taleRef = null;
     }
     if (CanShowArt)
     {
         if (Current.ProgramState == ProgramState.Playing)
         {
             if (relatedThing != null)
             {
                 taleRef = Find.TaleManager.GetRandomTaleReferenceForArtConcerning(relatedThing);
             }
             else
             {
                 taleRef = Find.TaleManager.GetRandomTaleReferenceForArt(source);
             }
         }
         else
         {
             taleRef = TaleReference.Taleless;
         }
         titleInt = GenerateTitle();
     }
     else
     {
         titleInt = null;
         taleRef  = null;
     }
 }
Example #3
0
        public static TaleData_Thing GenerateRandom()
        {
            ThingDef thingDef = DefDatabase <ThingDef> .AllDefs.Where(delegate(ThingDef d)
            {
                bool arg_36_0;
                if (d.comps != null)
                {
                    arg_36_0 = d.comps.Any((CompProperties cp) => cp.compClass == typeof(CompArt));
                }
                else
                {
                    arg_36_0 = false;
                }
                return(arg_36_0);
            }).RandomElement <ThingDef>();

            ThingDef             thingDef2   = GenStuff.RandomStuffFor(thingDef);
            Thing                thing       = ThingMaker.MakeThing(thingDef, thingDef2);
            ArtGenerationContext source      = (Rand.Value >= 0.5f) ? ArtGenerationContext.Outsider : ArtGenerationContext.Colony;
            CompQuality          compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null && compQuality.Quality < thing.TryGetComp <CompArt>().Props.minQualityForArtistic)
            {
                compQuality.SetQuality(thing.TryGetComp <CompArt>().Props.minQualityForArtistic, source);
            }
            thing.TryGetComp <CompArt>().InitializeArt(source);
            return(TaleData_Thing.GenerateFrom(thing));
        }
Example #4
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);
        }
        static void Postfix(CompQuality __instance, QualityCategory q, ArtGenerationContext source)
        {
            // Can we be infused?
            CompInfusion compInfusion = __instance.parent.TryGetComp <CompInfusion> ();

            if (compInfusion != null)
            {
                var thing = __instance.parent;
                var def   = __instance.parent.def;
                // Get those Infusions rolling
                var prefix = roll(thing, q);
                var suffix = roll(thing, q);

                var tierMult = def.techLevel < TechLevel.Industrial ? 3 : 1;

                if (prefix)
                {
                    compInfusion.InitializeInfusionPrefix(GenInfusion.GetTier(q, tierMult));
                }
                if (suffix)
                {
                    compInfusion.InitializeInfusionSuffix(GenInfusion.GetTier(q, tierMult));
                }
                if (prefix || suffix)
                {
                    __instance.parent.HitPoints = __instance.parent.MaxHitPoints;
                }
            }
        }
Example #6
0
        public void SetQuality(QualityCategory q, ArtGenerationContext source)
        {
            this.qualityInt = q;
            CompArt compArt = this.parent.TryGetComp <CompArt>();

            if (compArt != null)
            {
                compArt.InitializeArt(source);
            }
        }
Example #7
0
        public void SetNature(NatureCategory ccor, ArtGenerationContext source)
        {
            this.ccint = ccor;
            CompArt compArt = this.parent.TryGetComp <CompArt>();

            if (compArt != null)
            {
                compArt.InitializeArt(source);
            }
        }
Example #8
0
        static void Postfix(CompQuality __instance, QualityCategory q, ArtGenerationContext source)
        {
            // Can we be infused?
            var compInfused = __instance.parent.TryGetComp <CompInfused>();

            if (compInfused != null)
            {
                var thing = __instance.parent;

                // Get those Infused lucky rolls
                var pools = (
                    from pool in DefDatabase <PoolDef> .AllDefs
                    where pool.Allows(thing) && Rand.Value < pool.Chance(q) * Settings.mult
                    select pool
                    ).ToList();

                if (pools.Count == 0)
                {
                    return;
                }

                #if DEBUG
                Log.Message("Infused :: " + q + " " + thing.def.label + " got " + pools.Count + " lucky rolls");
                #endif

                var tier = RollTier(q);

                foreach (var pool in pools)
                {
                    var infusions = AvailableInfusions(pool, tier, thing);
                    if (infusions.Count == 0)
                    {
                        #if DEBUG
                        Log.Warning(" > Couldn't find any infusion to give to " + q + " " + thing.def.label);
                        #endif
                        return;
                    }
                    var infusion = infusions.RandomElementByWeight(i => i.weight);

                    #if DEBUG
                    Log.Message(" > Added " + infusion + " to " + q + " " + thing.def.label + " from " + pool.defName + "-" + infusion.tier);
                    #endif

                    compInfused.Attach(infusion);
                }

                if (compInfused.IsActive)
                {
                    __instance.parent.HitPoints = __instance.parent.MaxHitPoints;
                }
            }
        }
Example #9
0
        public static TaleData_Thing GenerateRandom()
        {
            ThingDef obj = DefDatabase <ThingDef> .AllDefs.Where((ThingDef d) => d.comps != null && d.comps.Any((CompProperties cp) => cp.compClass == typeof(CompArt))).RandomElement();

            ThingDef             thingDef    = GenStuff.RandomStuffFor(obj);
            Thing                thing       = ThingMaker.MakeThing(obj, thingDef);
            ArtGenerationContext source      = (Rand.Value < 0.5f) ? ArtGenerationContext.Colony : ArtGenerationContext.Outsider;
            CompQuality          compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null && (int)compQuality.Quality < (int)thing.TryGetComp <CompArt>().Props.minQualityForArtistic)
            {
                compQuality.SetQuality(thing.TryGetComp <CompArt>().Props.minQualityForArtistic, source);
            }
            thing.TryGetComp <CompArt>().InitializeArt(source);
            return(GenerateFrom(thing));
        }
        public static TaleData_Thing GenerateRandom()
        {
            ThingDef thingDef = (from d in DefDatabase <ThingDef> .AllDefs
                                 where d.comps != null && d.comps.Any((CompProperties cp) => cp.compClass == typeof(CompArt))
                                 select d).RandomElement();
            ThingDef             thingDef2   = GenStuff.RandomStuffFor(thingDef);
            Thing                thing       = ThingMaker.MakeThing(thingDef, thingDef2);
            ArtGenerationContext source      = (ArtGenerationContext)((Rand.Value < 0.5) ? 1 : 0);
            CompQuality          compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null && (int)compQuality.Quality < (int)thing.TryGetComp <CompArt>().Props.minQualityForArtistic)
            {
                compQuality.SetQuality(thing.TryGetComp <CompArt>().Props.minQualityForArtistic, source);
            }
            thing.TryGetComp <CompArt>().InitializeArt(source);
            return(TaleData_Thing.GenerateFrom(thing));
        }
Example #11
0
 public TaleReference GetRandomTaleReferenceForArt(ArtGenerationContext source)
 {
     if (source == ArtGenerationContext.Outsider)
     {
         return(TaleReference.Taleless);
     }
     if (tales.Count == 0)
     {
         return(TaleReference.Taleless);
     }
     if (Rand.Value < 0.25f)
     {
         return(TaleReference.Taleless);
     }
     if (!tales.Where((Tale x) => x.def.usableForArt).TryRandomElementByWeight((Tale ta) => ta.InterestLevel, out Tale result))
     {
         return(TaleReference.Taleless);
     }
     result.Notify_NewlyUsed();
     return(new TaleReference(result));
 }
Example #12
0
        private void InitializeArt(Thing relatedThing, ArtGenerationContext source)
        {
            if (taleRef != null)
            {
                //Is there any scenario where this should happen more than once?
                //Yes, theoretically. For example, we bury a corpse in a sarcophagus, then dig him up and bury another.
                //The art changes in response. But is this correct?
                taleRef.ReferenceDestroyed();
                taleRef = null;
            }

            if (CanShowArt)
            {
                if (Current.ProgramState == ProgramState.Playing)
                {
                    if (relatedThing != null)
                    {
                        taleRef = Find.TaleManager.GetRandomTaleReferenceForArtConcerning(relatedThing);
                    }
                    else
                    {
                        taleRef = Find.TaleManager.GetRandomTaleReferenceForArt(source);
                    }
                }
                else
                {
                    taleRef = TaleReference.Taleless;              //Todo add some chance of getting taleless art even in map play
                }
                titleInt = GenerateTitle();
            }
            else
            {
                titleInt = null;
                taleRef  = null;
            }
        }
Example #13
0
 public void SetQuality(QualityCategory q, ArtGenerationContext source)
 {
     qualityInt = q;
     parent.TryGetComp <CompArt>()?.InitializeArt(source);
 }
Example #14
0
 public void InitializeArt(ArtGenerationContext source)
 {
     InitializeArt(null, source);
 }
 // Token: 0x06000004 RID: 4 RVA: 0x00002071 File Offset: 0x00000271
 public void InitializeArt(Thing thing, ArtGenerationContext context)
 {
 }
 // Token: 0x06000002 RID: 2 RVA: 0x0000206B File Offset: 0x0000026B
 public new void InitializeArt(ArtGenerationContext context)
 {
 }