Beispiel #1
0
        /// <summary>
        /// A small helper function to load materials (based on Tynans code)
        /// </summary>
        /// <param name="texturePath"></param>
        /// <returns></returns>
        public static Material LoadMaterial(string texturePath, ShaderType shaderType = ShaderType.Transparent, bool throwError = true)
        {
            Texture2D texture2D = ContentFinder <Texture2D> .Get(texturePath, throwError);

            if (texture2D == null)
            {
                return(null);
            }

            MaterialRequest materialRequest = new MaterialRequest(texture2D, ShaderDatabase.ShaderFromType(shaderType));

            return(MaterialPool.MatFrom(materialRequest));
        }
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     if (!this.Props.ExtrasEntries.NullOrEmpty())
     {
         extraPartEntry          = this.Props.ExtrasEntries.RandomElementByWeight((ExtraPartEntry x) => x.commonality);
         this.graphicPath        = extraPartEntry.extraTexPath;
         this.shader             = ShaderDatabase.LoadShader(extraPartEntry.shaderType.shaderPath);
         this.useSecondaryColor  = extraPartEntry.UseSecondaryColor;
         this.ExtraUseBodyOffset = extraPartEntry.UseBodytypeOffsets;
     }
     pauldronInitialized = true;
 }
 public override void SpawnSetup()
 {
     base.SpawnSetup();
     power  = GetComp <CompPowerTrader>();
     heater = GetComp <CompHeatPusher>();
     nextTemperatureCheck = -(thingIDNumber % 20);
     compDef = def as PalComponentDef;
     drawMatrix.SetTRS(DrawPos + Altitudes.AltIncVect /**(1+thingIDNumber*0.0001f)*/, Gen.ToQuat(90), Vector3.one);
     animationFrames = LoadAnimation();
     nullGraphic     = GraphicDatabase.Get <Graphic_Single>(def.graphicData.texPath, def.graphic.Shader, def.graphicData.drawSize, Color.clear);
     drawPosHeatPie  = DrawPos + Altitudes.AltIncVect * (1 + thingIDNumber * 0.0001f);
     heatPieMat      = MaterialPool.MatFrom("UI/HeatPieRed", ShaderDatabase.ShaderFromType(ShaderType.MetaOverlay));
 }
        public void GeneratePart()
        {
            StringBuilder msg = new StringBuilder();

            if (extraPartEntryint >= 0)
            {
                extraPartEntry = this.Props.ExtrasEntries[extraPartEntryint];
            }
            else
            {
                List <ExtraApparelPartProps> possibles = new List <ExtraApparelPartProps>();
                if (extraPartEntryint == -1)
                {
                    if (Apparel.TryGetQuality(out QualityCategory quality))
                    {
                        msg.AppendLine("            QualityCategory: " + quality);
                        possibles.AddRange(this.Props.ExtrasEntries.FindAll(x => x.AcceptableForQuality(quality)));
                    }
                    else
                    {
                        msg.AppendLine("            No CompQuality");
                        possibles = this.Props.ExtrasEntries;
                    }
                }
                msg.AppendLine("            possibles: " + possibles.Count);
                if (!possibles.NullOrEmpty())
                {
                    Rand.PushState();
                    extraPartEntry = possibles.RandomElementByWeight((ExtraApparelPartProps x) => x.commonality);
                    Rand.PopState();
                    extraPartEntryint = this.Props.ExtrasEntries.IndexOf(extraPartEntry);
                }
                else
                {
                    extraPartEntryint = -2;
                }
            }
            if (extraPartEntry != null)
            {
                this.shader              = ShaderDatabase.LoadShader(extraPartEntry.graphicData.shaderType.shaderPath);
                this.useSecondaryColor   = extraPartEntry.useParentSecondaryColor;
                this.ExtraUseBodyTexture = extraPartEntry.UseBodytypeTextures;
                msg.AppendLine("    Using: " + extraPartEntry + " at position: " + extraPartEntryint);
                msg.AppendLine("        shader: " + shader + " useSecondaryColor: " + useSecondaryColor + " ExtraUseBodyTexture: " + ExtraUseBodyTexture);
                partInitialized = true;
            }
            else
            {
                extraPartEntryint = -2;
            }
        }
        public override void PostSpawnSetup(bool respawningAfterLoad)
        {
            base.PostSpawnSetup(respawningAfterLoad);
            ShoulderPadEntry entry = this.pprops.PauldronEntries.RandomElementByWeight((ShoulderPadEntry x) => x.commonality);

            this.graphicPath = entry.padTexPath;

            if (entry.UseFactionTextures)
            {
                this.graphicPath += ("_" + this.apparel.Wearer.Faction.Name);
            }
            this.shader            = ShaderDatabase.ShaderFromType(entry.shaderType);
            this.useSecondaryColor = entry.UseSecondaryColor;
            this.padType           = entry.shoulderPadType;
        }
Beispiel #6
0
        // Token: 0x06000078 RID: 120 RVA: 0x00004AE0 File Offset: 0x00002CE0
        public void ResolveAllGraphics(float scale = 1f)
        {
            Shader shader = ShaderDatabase.LoadShader(this.data.shaderCutoutPath);

            this.ClearCache();
            this.nakedGraphic               = GraphicDatabase.Get <Graphic_Multi>(this.data.bodyType.bodyNakedGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, this.data.color);
            this.rottingGraphic             = GraphicDatabase.Get <Graphic_Multi>(this.data.bodyType.bodyNakedGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, PawnGraphicSet.RottingColor);
            this.dessicatedGraphic          = GraphicDatabase.Get <Graphic_Multi>(this.data.bodyType.bodyDessicatedGraphicPath, shader);
            this.headGraphic                = GraphicDatabaseHeadRecords_Zombiefied.GetHeadNamed(this.data.headGraphicPath, this.data.color);
            this.desiccatedHeadGraphic      = GraphicDatabaseHeadRecords_Zombiefied.GetHeadNamed(this.data.headGraphicPath, PawnGraphicSet.RottingColor);
            this.skullGraphic               = GraphicDatabaseHeadRecords.GetSkull();
            this.headStumpGraphic           = GraphicDatabaseHeadRecords.GetStump(this.data.color);
            this.desiccatedHeadStumpGraphic = GraphicDatabaseHeadRecords.GetStump(PawnGraphicSet.RottingColor);
            this.hairGraphic                = GraphicDatabase.Get <Graphic_Multi>(this.data.hairGraphicPath, shader, Vector2.one, this.data.hairColor);
            this.ResolveApparelGraphics();
        }
Beispiel #7
0
        // Token: 0x06000079 RID: 121 RVA: 0x00004BF8 File Offset: 0x00002DF8
        public void ResolveApparelGraphics()
        {
            /*
             * Shader shader = ShaderDatabase.LoadShader(this.data.shaderCutoutPath);
             * this.ClearCache();
             * this.apparelGraphics.Clear();
             * for(int i = 0; i < data.wornApparel.Count; i++)
             * {
             *  ApparelGraphicRecord item;
             *  if (ZombieGraphicSet.TryGetGraphicApparel(data.wornApparel[i], data.wornApparel[i].DrawColor, this.data.bodyType, shader, out item))
             *  {
             *      this.apparelGraphics.Add(item);
             *  }
             * }
             */
            Shader shader = ShaderDatabase.LoadShader(this.data.shaderCutoutPath);

            this.ClearCache();
            this.apparelGraphics.Clear();
            for (int i = 0; i < this.data.wornApparelDefs.Count; i++)
            {
                ApparelGraphicRecord item;
                Apparel newApparel = MakeApparel(i);
                if (ZombieGraphicSet.TryGetGraphicApparel(newApparel, newApparel.DrawColor, this.data.bodyType, shader, out item))
                {
                    this.apparelGraphics.Add(item);
                }
            }

            /*
             * using (List<ThingDef>.Enumerator enumerator = this.data.wornApparelDefs.GetEnumerator())
             * {
             *  while (enumerator.MoveNext())
             *  {
             *      ApparelGraphicRecord item;
             *      Apparel newApparel = ZombieGraphicSet.MakeApparel(enumerator.Current, this.data.color);
             *      if (ZombieGraphicSet.TryGetGraphicApparel(newApparel, newApparel.DrawColor, this.data.bodyType, shader, out item))
             *      {
             *          this.apparelGraphics.Add(item);
             *      }
             *  }
             * }
             */
        }
    void Start()
    {
        if (heightFogBeforeTransparentGO != null)
        {
            heightFogBeforeTransparentGO.SetActive(true);
        }

        if (!bloom)
        {
            bloom = GetComponent <MobileBloom> ();
        }
        if (!noise)
        {
            noise = GetComponent <ColoredNoise> ();
        }
        if (!depthOfField)
        {
            depthOfField = GetComponent <HeightDepthOfField> ();
        }
        if (!heightFog)
        {
            heightFog = gameObject.GetComponentInChildren <RenderFogPlane> ();
        }
        if (!shaders)
        {
            shaders = GetComponent <ShaderDatabase> ();
        }
        if (!reflection)
        {
            reflection = GetComponent("ReflectionFx") as MonoBehaviour;
        }

        if (autoChoseQualityOnStart)
        {
            AutoDetectQuality();
        }

        ApplyAndSetQuality(currentQuality);
    }
    void Start()
    {
        if (heightFogBeforeTransparentGO != null)
            heightFogBeforeTransparentGO.SetActive(true);

        if (!bloom)
            bloom = GetComponent<MobileBloom> ();
        if (!noise)
            noise = GetComponent<ColoredNoise> ();
        if (!depthOfField)
            depthOfField = GetComponent<HeightDepthOfField> ();
        if (!heightFog)
            heightFog = gameObject.GetComponentInChildren<RenderFogPlane> ();
        if (!shaders)
            shaders = GetComponent<ShaderDatabase> ();
        if (!reflection)
            reflection = GetComponent ("ReflectionFx") as MonoBehaviour;

        if (autoChoseQualityOnStart)
            AutoDetectQuality ();

        ApplyAndSetQuality (currentQuality);
    }
Beispiel #10
0
 public override void Draw()
 {
     base.Draw();
     if (currFrame != null)
     {
         Matrix4x4 matrix = default(Matrix4x4);
         Vector3   s      = new Vector3(def.graphicData.drawSize.x, 9f, def.graphicData.drawSize.y);
         Vector3   x      = new Vector3(0f, 0f, 0f);
         matrix.SetTRS(DrawPos + x + Altitudes.AltIncVect, Rotation.AsQuat, s);
         Graphics.DrawMesh(MeshPool.plane10, matrix, currFrame.GetColoredVersion(ShaderDatabase.ShaderFromType(def.graphicData.shaderType), Color, Color.white).MatSingle, 0);
     }
 }
Beispiel #11
0
        public static void Reload(Thing t, string texPath)
        {
            Graphic graphic = GraphicDatabase.Get(t.def.graphicData.graphicClass, texPath, ShaderDatabase.ShaderFromType(t.def.graphicData.shaderType), t.def.graphicData.drawSize, t.DrawColor, t.DrawColorTwo);

            typeof(Thing).GetField("graphicInt", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(t, graphic);
            if (t.Map != null)
            {
                t.DirtyMapMesh(t.Map);
            }
        }
        public static void Reload(Thing t, string texPath)
        {
            Graphic graphic = GraphicDatabase.Get(t.def.graphicData.graphicClass, texPath, ShaderDatabase.LoadShader(t.def.graphicData.shaderType.shaderPath), t.def.graphicData.drawSize, t.DrawColor, t.DrawColorTwo);

            typeof(Thing).GetField("graphicInt", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(t, graphic);
            if (t.Map != null)
            {
                t.Map.mapDrawer.MapMeshDirty(t.Position, MapMeshFlag.Things);
            }
        }
Beispiel #13
0
        private static bool PawnGraphicSet_ResolveAllGraphics_prefix(PawnGraphicSet __instance)
        {
            if (__instance.pawn.RaceProps.Animal)
            {
                Pawn pawn = __instance.pawn;
                PawnKindLifeStage curKindLifeStage = __instance.pawn.ageTracker.CurKindLifeStage;

                Graphic baseGraphic = pawn.gender != Gender.Female || curKindLifeStage.femaleGraphicData == null ? curKindLifeStage.bodyGraphicData.Graphic : curKindLifeStage.femaleGraphicData.Graphic;
                Color color = baseGraphic.color;
                Color ColorTwo = baseGraphic.colorTwo;
                Shader shader = ShaderDatabase.Cutout;

                if (__instance.pawn.ageTracker.CurKindLifeStage.bodyGraphicData.graphicClass == typeof(Graphic_MultiRandom))
                {
                    int TextureCountTotal = TextureCount(baseGraphic.path);
                    if (TextureCountTotal > 0)
                    {
                        int textureIndex = (new System.Random(pawn.thingIDNumber * 2)).Next() % TextureCountTotal;
                        string safeTextureIndex = (1 + textureIndex).ToString();

                        __instance.ClearCache();

                        if (curKindLifeStage.dessicatedBodyGraphicData is GraphicData dessicated)
                        {
                            __instance.dessicatedGraphic = dessicated.GraphicColoredFor(__instance.pawn);
                        }

                        __instance.nakedGraphic = (new Graphic_MultiRandom(baseGraphic)).GetColoredVersion(ShaderDatabase.ShaderFromType(shader), color, safeTextureIndex);
                        return false;

                    }
                }
                return true;
            }
            return true;
        }
Beispiel #14
0
 public override void Init(GraphicRequest req)
 {
     base.Init(req);
     baseData = data as SidedBaseGraphicData;
     if (baseData != null)
     {
         baseMatFront = MaterialPool.MatFrom(new MaterialRequest(baseData.BaseFrontTex, ShaderDatabase.ShaderFromType(baseData.shaderType), baseData.color));
         baseMatSide  = MaterialPool.MatFrom(new MaterialRequest(baseData.BaseSideTex, ShaderDatabase.ShaderFromType(baseData.shaderType), baseData.color));
     }
 }