Пример #1
0
        public static void DrawFactionButton(Rect rect, CompPauldronDrawer comp, ShoulderPadEntry entry, bool paintable = false)
        {
            Rect rect1 = rect.LeftHalf().LeftHalf();
            Rect rect2 = rect.LeftHalf().RightHalf();

            rect2.width *= 2;
            Rect rect3 = rect.RightHalf().RightHalf();

            Widgets.Label(rect1, comp.GetDescription(entry.shoulderPadType));
            Widgets.Dropdown <ShoulderPadEntry, PauldronTextureOption>
            (
                rect2,
                entry,
                (ShoulderPadEntry sp) => entry.Used,
                new Func <ShoulderPadEntry, IEnumerable <Widgets.DropdownMenuElement <PauldronTextureOption> > >(DrawFactionButton_GenerateMenu),
                entry.Used.Label,
                null,
                null,
                null,
                delegate()
            {
            },
                paintable
            );
        }
Пример #2
0
        public override void DrawWornExtras()
        {
            base.DrawWornExtras();
            CompPauldronDrawer comp = base.GetComp <CompPauldronDrawer>();

            if (comp != null)
            {
                comp.PostDraw();
            }
        }
Пример #3
0
        public static void DrawVariantButton(Rect rect, CompPauldronDrawer comp, ShoulderPadEntry entry, bool paintable)
        {
            Rect rect1 = rect.LeftHalf().LeftHalf();
            Rect rect2 = rect.LeftHalf().RightHalf();

            rect2.width *= 2;
            //   entry.Drawer = comp;
            Rect rect3 = rect.RightHalf().RightHalf();

            Widgets.Label(rect1, comp.GetDescription(entry.shoulderPadType));


            Widgets.Dropdown <ShoulderPadEntry, PauldronTextureOption>(rect2, entry, (ShoulderPadEntry p) => p.Used, new Func <ShoulderPadEntry, IEnumerable <Widgets.DropdownMenuElement <PauldronTextureOption> > >(DrawVariantButton_GenerateMenu), entry.Used.Label, null, null, null, null, true);

            /*
             * Widgets.Dropdown<ShoulderPadEntry, PauldronTextureOption>(rect2, entry,
             *  (ShoulderPadEntry sp) => sp.Used,
             *  new Func<ShoulderPadEntry, IEnumerable<Widgets.DropdownMenuElement<PauldronTextureOption>>>(DrawVariantButton_GenerateMenu),
             *  entry.VariantTextures.activeOption.Label, null, null, null, delegate ()
             *  {
             *
             *  }, paintable);
             */
        }
Пример #4
0
 public ShoulderPadEntry(ShoulderPadProperties entry, CompPauldronDrawer drawer)
 {
     UpdateProps(entry);
     this.drawer  = drawer;
     this.apparel = drawer.apparel;
 }
Пример #5
0
        private void FillMainRect(Rect mainRect)
        {
            Apparel apparel = this.thing as Apparel;

            Text.Font = GameFont.Small;
            float height         = 6f + 1 * 30f;
            Rect  scrollRect     = mainRect.LeftHalf();
            Rect  previewRect    = mainRect.RightHalf().TopPart(0.75f);
            Rect  scrollViewRect = new Rect(0f, 0f, scrollRect.width - 16f, height);

            if (apparel?.Wearer is Pawn Wearer)
            {
                GUI.DrawTexture(new Rect(previewRect.center.x - PawnPortraitSize.x / 2f, previewRect.yMin - 24f, PawnPortraitSize.x, PawnPortraitSize.y), PortraitsCache.Get(Wearer, PawnPortraitSize, default(Vector3), 1f, true, true));
            }
            else
            {
                Widgets.ThingIcon(new Rect(previewRect.center.x - PawnPortraitSize.x / 2f, previewRect.yMin - 24f, PawnPortraitSize.x, PawnPortraitSize.y), this.thing, 1f);
            }
            Widgets.BeginScrollView(scrollRect, ref this.scrollPosition, scrollViewRect, true);
            float num  = 6f;
            float num2 = this.scrollPosition.y - 30f;
            float num3 = this.scrollPosition.y + scrollRect.height;
            int   num4 = 0;

            if (this.thing is ApparelComposite composite)
            {
                if (composite.ColorableTwo != null)
                {
                    if (composite.ColorableFaction != null)
                    {
                        if (num > num2 && num < num3)
                        {
                            Rect rect = new Rect(0f, num, scrollViewRect.width, 30f);
                            AdeptusApparelUtility.DrawFactionColorsButton(rect, composite.ColorableFaction, false);
                        }
                        num += 30f;
                        num4++;
                    }
                }
                if (!composite.AltGraphics.NullOrEmpty())
                {
                    if (num > num2 && num < num3)
                    {
                        Rect rect = new Rect(0f, num, scrollViewRect.width, 30f);
                        AdeptusApparelUtility.DrawBaseTextureOptions(rect, "Main Texture:", composite);
                    }
                    num += 30f;
                    num4++;
                }
                if (!composite.Pauldrons.NullOrEmpty())
                {
                    for (int i = 0; i < composite.Pauldrons.Count; i++)
                    {
                        CompPauldronDrawer Drawer = composite.Pauldrons[i];
                        if (!Drawer.activeEntries.EnumerableNullOrEmpty())
                        {
                            foreach (ShoulderPadEntry entry in Drawer.activeEntries)
                            {
                                if (entry.Options.NullOrEmpty() && (entry.UseVariableTextures || entry.UseFactionTextures))
                                {
                                    if (entry.Options.NullOrEmpty())
                                    {
                                        if (Prefs.DevMode)
                                        {
                                            Log.Message(entry.Label + " no options");
                                        }
                                        continue;
                                    }
                                }
                                if (entry.Drawer == null)
                                {
                                    //entry.drawer = Drawer;
                                }
                                if (entry.UseFactionTextures)
                                {
                                    Rect rect = new Rect(0f, num, scrollViewRect.width, 30f);
                                    AdeptusApparelUtility.DrawFactionButton(rect, Drawer, entry, false);
                                    num += 30f;
                                    num4++;
                                }
                                else
                                if (entry.UseVariableTextures)
                                {
                                    Rect rect = new Rect(0f, num, scrollViewRect.width, 30f);
                                    AdeptusApparelUtility.DrawVariantButton(rect, Drawer, entry, false);
                                    num += 30f;
                                    num4++;
                                }
                            }
                        }
                    }
                }

                /*
                 * if (!composite.Extras.NullOrEmpty())
                 * {
                 *      for (int i = 0; i < composite.Extras.Count; i++)
                 *      {
                 *              CompApparelExtraPartDrawer Drawer = composite.Extras[i];
                 *              ExtraApparelPartProps entry = Drawer.ExtraPartEntry;
                 *              if (entry.Options.NullOrEmpty() && (entry.UseVariableTextures || entry.UseFactionTextures))
                 *              {
                 *                      if (entry.Options.NullOrEmpty())
                 *                      {
                 *                              if (Prefs.DevMode) Log.Message(entry.Label + " no options");
                 *                              continue;
                 *                      }
                 *              }
                 *              if (entry.Drawer == null)
                 *              {
                 *                      //entry.drawer = Drawer;
                 *              }
                 *              if (entry.UseFactionTextures)
                 *              {
                 *                      Rect rect = new Rect(0f, num, scrollViewRect.width, 30f);
                 *                      ITab_ToggleLivelry.DrawFactionButton(rect, Drawer, entry, false);
                 *                      num += 30f;
                 *                      num4++;
                 *              }
                 *              if (entry.UseVariableTextures)
                 *              {
                 *                      Rect rect = new Rect(0f, num, scrollViewRect.width, 30f);
                 *                      ITab_ToggleLivelry.DrawVariantButton(rect, Drawer, entry, false);
                 *                      num += 30f;
                 *                      num4++;
                 *              }
                 *
                 *      }
                 * }
                 */
            }

            /*
             * for (int i = 0; i < 10; i++)
             * {
             *      if (num > num2 && num < num3)
             *      {
             *              Rect rect = new Rect(0f, num, scrollViewRect.width, 30f);
             *              DrawSettings(rect, "box");
             *      }
             *      num += 30f;
             *      num4++;
             * }
             */
            Widgets.EndScrollView();
        }
Пример #6
0
        // RimWorld.CharacterCardUtility
        public void DrawCard(Rect rect, ThingWithComps selectedThing, CompPauldronDrawer Drawer)
        {
            GUI.BeginGroup(rect);

            if (Drawer != null)
            {
                if (!Drawer.pauldronInitialized)
                {
                    Drawer.Initialize();
                }
                if (Drawer.Props.PauldronEntries.Any(x => !x.options.NullOrEmpty()))
                {
                    var ts    = Text.CalcSize(selectedThing.def.LabelCap).x;
                    var y     = rect.y;
                    var rect2 = new Rect(rect.width / 2 - ts + SpacingOffset, y, rect.width, HeaderSize);
                    Text.Font = GameFont.Small;
                    int parts = Drawer.activeEntries.Where(x => !x.Options.NullOrEmpty()).Count();
                    Widgets.ListSeparator(ref y, rect2.width, "Customiseable Parts: " + (string)(!Drawer.activeEntries.EnumerableNullOrEmpty() ? "" + parts : ""));


                    if (!Drawer.activeEntries.EnumerableNullOrEmpty())
                    {
                        foreach (ShoulderPadEntry entry in Drawer.activeEntries)
                        {
                            if (entry.Options.NullOrEmpty() && (entry.UseVariableTextures || entry.UseFactionTextures))
                            {
                                if (entry.Options.NullOrEmpty())
                                {
                                    if (Prefs.DevMode)
                                    {
                                        Log.Message(entry.Label + " no options");
                                    }
                                    continue;
                                }
                            }
                            if (entry.Drawer == null)
                            {
                                //entry.drawer = Drawer;
                            }
                            if (entry.UseFactionTextures)
                            {
                                var rect3 = new Rect(0f, y, rect.width, 20f);
                                DrawFactionButton(rect3, Drawer, entry, false);
                                y += rect2.height;
                            }
                            if (entry.UseVariableTextures)
                            {
                                var rect3 = new Rect(0f, y, rect.width, 20f);
                                DrawVariantButton(rect3, Drawer, entry, false);
                                y += rect2.height;
                            }
                        }
                    }
                    else
                    {
                        Widgets.ListSeparator(ref y, rect2.width, "No Customiseable Parts:");
                    }
                }
            }

            GUI.EndGroup();
        }
Пример #7
0
        public override void DrawWornExtras()
        {
            if (Wearer == null || !Wearer.Spawned)
            {
                return;
            }
            Building_Bed bed = Wearer.CurrentBed();

            if (bed != null && !bed.def.building.bed_showSleeperBody && !onHead)
            {
                return;
            }

            //Since I haven't a head apparel item to test the drawing code against for now we throw an error (ONCE) and exit.
            if (this.onHead)
            {
                Log.ErrorOnce(string.Concat("AdeptusMechanicus :: Apparel_VisibleAccessory: The head drawing code is incomplete and the apparel '",
                                            this.Label, "' will not be drawn."), this.def.debugRandomId);
                return;
            }

            // compute drawVec, angle and Rot4 vars
            Rot4    rotation;
            Rot4    bedRotation = new Rot4();
            float   angle       = 0;
            Vector3 drawVec     = Wearer.Drawer.DrawPos;

            if (Wearer.GetPosture() != PawnPosture.Standing)
            {
                rotation = LayingFacing();
                if (bed != null)
                {
                    bedRotation        = bed.Rotation;
                    bedRotation.AsInt += 2;
                    angle              = bedRotation.AsAngle;
                    AltitudeLayer altitude = (AltitudeLayer)((byte)Mathf.Max((int)bed.def.altitudeLayer, 14));
                    drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(altitude).y;
                    drawVec  += bedRotation.FacingCell.ToVector3() * (-Wearer.Drawer.renderer.BaseHeadOffsetAt(Rot4.South).z);
                }
                else
                {
                    drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.LayingPawn).y;
                    if (Wearer.Downed)  // Wearer.Spawned == false when Pawn.Dead == true.
                    {
                        float?newAngle = (((((Wearer.Drawer == null) ? null : Wearer.Drawer.renderer) == null) ? null : Wearer.Drawer.renderer.wiggler) == null) ? (float?)null : Wearer.Drawer.renderer.wiggler.downedAngle;
                        if (newAngle != null)
                        {
                            angle = newAngle.Value;
                        }
                    }
                    else
                    {
                        angle = rotation.FacingCell.AngleFlat;
                    }
                }
                drawVec.y += 0.005f;
            }
            else
            {
                rotation  = Wearer.Rotation;
                drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.Pawn).y;
            }

            drawVec.y += GetAltitudeOffset(rotation);
            //    Log.Message(string.Format("{0} /n drawVec.y: {1}", this.def.label, drawVec.y));

            // Get the graphic path
            string  path    = def.graphicData.texPath + "_" + ((Wearer == null) ? null : Wearer.story.bodyType.ToString());
            Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.CutoutComplex, def.graphicData.drawSize, drawColor);
            ApparelGraphicRecord apparelGraphic = new ApparelGraphicRecord(graphic, this);

            Material mat = apparelGraphic.graphic.MatAt(rotation);
            Vector3  s   = new Vector3(1.5f, 1.5f, 1.5f);

            //mat.shader = ShaderDatabase.CutoutComplex;
            mat.color = drawColor;
            Matrix4x4 matrix = default(Matrix4x4);

            matrix.SetTRS(drawVec, Quaternion.AngleAxis(angle, Vector3.up), s);
            Graphics.DrawMesh(rotation == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0);

//            base.DrawWornExtras();
            CompPauldronDrawer comp = base.GetComp <CompPauldronDrawer>();

            if (comp != null)
            {
                /*
                 * // Get the graphic path
                 * string path2 = comp.graphicPath + "_" + ((Wearer == null) ? null : Wearer.story.bodyType.ToString());
                 * Graphic graphic2 = GraphicDatabase.Get<Graphic_Multi>(path2, ShaderDatabase.CutoutComplex, def.graphicData.drawSize, DrawColor);
                 * ApparelGraphicRecord apparelGraphic2 = new ApparelGraphicRecord(graphic2, this);
                 *
                 * Material mat2 = apparelGraphic2.graphic.MatAt(rotation);
                 * Vector3 s2 = new Vector3(1.5f, 1.5f, 1.5f);
                 *
                 * //mat.shader = ShaderDatabase.CutoutComplex;
                 * //mat.color = DrawColor;
                 * Matrix4x4 matrix2 = default(Matrix4x4);
                 * matrix.SetTRS(drawVec, Quaternion.AngleAxis(angle, Vector3.up), s2);
                 * Graphics.DrawMesh(rotation == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix2, mat2, 0);
                 */

                Comps_PostDraw();

                /*
                 * // Get the graphic path
                 * string path2 = comp.graphicData.texPath + "_" + ((Wearer == null) ? null : Wearer.story.bodyType.ToString());
                 * Graphic graphic2 = GraphicDatabase.Get<Graphic_Multi>(path, ShaderDatabase.CutoutComplex, def.graphicData.drawSize, DrawColor);
                 * ApparelGraphicRecord apparelGraphic2 = new ApparelGraphicRecord(graphic, this);
                 *
                 * Material mat2 = apparelGraphic.graphic.MatAt(rotation);
                 * Vector3 s2 = new Vector3(1.5f, 1.5f, 1.5f);
                 *
                 * //mat.shader = ShaderDatabase.CutoutComplex;
                 * //mat.color = DrawColor;
                 * Matrix4x4 matrix2 = default(Matrix4x4);
                 * matrix.SetTRS(drawVec, Quaternion.AngleAxis(angle, Vector3.up), s);
                 * Graphics.DrawMesh(rotation == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0);
                 */
            }
        }
        // Token: 0x06000241 RID: 577 RVA: 0x000145E4 File Offset: 0x000127E4
        public override void DrawWornExtras()
        {
            if (base.Wearer == null || !base.Wearer.Spawned)
            {
                return;
            }
            Building_Bed building_Bed = base.Wearer.CurrentBed();

            if (building_Bed != null && !building_Bed.def.building.bed_showSleeperBody && !this.onHead)
            {
                return;
            }
            if (this.onHead)
            {
                Log.ErrorOnce("Adeptus Mechanicus :: Apparel_VisibleAccessory: The head drawing code is incomplete and the apparel '" + this.Label + "' will not be drawn.", (int)this.def.debugRandomId, false);
                return;
            }
            Rot4    rot    = default(Rot4);
            float   angle  = 0f;
            Vector3 vector = base.Wearer.Drawer.DrawPos;
            Rot4    rot2;

            if (base.Wearer.GetPosture() != PawnPosture.Standing)
            {
                rot2 = this.LayingFacing();
                if (building_Bed != null)
                {
                    rot        = building_Bed.Rotation;
                    rot.AsInt += 2;
                    angle      = rot.AsAngle;
                    AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)building_Bed.def.altitudeLayer, 14);
                    vector.y = base.Wearer.Position.ToVector3ShiftedWithAltitude(altLayer).y;
                    vector  += rot.FacingCell.ToVector3() * -base.Wearer.Drawer.renderer.BaseHeadOffsetAt(Rot4.South).z;
                }
                else
                {
                    vector.y = base.Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.LayingPawn).y;
                    if (base.Wearer.Downed)
                    {
                        float?num = (((((base.Wearer.Drawer == null) ? null : base.Wearer.Drawer.renderer) == null) ? null : base.Wearer.Drawer.renderer.wiggler) == null) ? null : new float?(base.Wearer.Drawer.renderer.wiggler.downedAngle);
                        if (num != null)
                        {
                            angle = num.Value;
                        }
                    }
                    else
                    {
                        angle = rot2.FacingCell.AngleFlat;
                    }
                }
                vector.y += 0.005f;
            }
            else
            {
                rot2     = base.Wearer.Rotation;
                vector.y = base.Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.Pawn).y;
            }
            vector.y += this.GetAltitudeOffset(rot2);
            Graphic   graphic  = GraphicDatabase.Get <Graphic_Multi>(this.def.graphicData.texPath + "_" + ((base.Wearer == null) ? null : base.Wearer.story.bodyType.ToString()), ShaderDatabase.CutoutComplex, this.def.graphicData.drawSize, this.DrawColor);
            Material  material = new ApparelGraphicRecord(graphic, this).graphic.MatAt(rot2, null);
            Vector3   s        = new Vector3(1.5f, 1.5f, 1.5f);
            Matrix4x4 matrix   = default(Matrix4x4);

            matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s);
            //    Graphics.DrawMesh((rot2 == Rot4.West) ? MeshPool.plane10Flip : MeshPool.plane10, matrix, material, 0);

            CompPauldronDrawer comp = base.GetComp <CompPauldronDrawer>();

            if (comp != null)
            {
                //    comp.PostDraw_Pads(vector, rot2);
            }

            base.DrawWornExtras();
        }