Exemplo n.º 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 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));
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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));
     }
 }