示例#1
0
            public bool CoatButNoShirt()
            {
                bool flag  = false;
                bool flag2 = false;

                for (int i = 0; i < aps.Count; i++)
                {
                    if (!aps[i].thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso))
                    {
                        continue;
                    }
                    for (int j = 0; j < aps[i].thing.apparel.layers.Count; j++)
                    {
                        ApparelLayerDef apparelLayerDef = aps[i].thing.apparel.layers[j];
                        if (apparelLayerDef == ApparelLayerDefOf.OnSkin)
                        {
                            flag2 = true;
                        }
                        if (apparelLayerDef == ApparelLayerDefOf.Shell || apparelLayerDef == ApparelLayerDefOf.Middle)
                        {
                            flag = true;
                        }
                    }
                }
                if (flag)
                {
                    return(!flag2);
                }
                return(false);
            }
示例#2
0
 public PawnLayer FindLayerForApparelLayer(ApparelLayerDef layer)
 {
     if (layer == ApparelLayerDefOf.OnSkin)
     {
         return(bottomClothingLayer);
     }
     else if (layer == ApparelLayerDefOf.Middle)
     {
         return(middleClothingLayer);
     }
     else if (layer == ApparelLayerDefOf.Shell)
     {
         return(topClothingLayer);
     }
     else if (layer == ApparelLayerDefOf.Overhead)
     {
         return(hatLayer);
     }
     else if (layer == ApparelLayerDefOf.Belt)
     {
         return(accessoryLayer);
     }
     else
     {
         return(null);
     }
 }
示例#3
0
            public bool CoatButNoShirt()
            {
                bool flag  = false;
                bool flag2 = false;

                for (int i = 0; i < aps.Count; i++)
                {
                    ThingStuffPair thingStuffPair = aps[i];
                    if (thingStuffPair.thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso))
                    {
                        int num = 0;
                        while (true)
                        {
                            int            num2            = num;
                            ThingStuffPair thingStuffPair2 = aps[i];
                            if (num2 >= thingStuffPair2.thing.apparel.layers.Count)
                            {
                                break;
                            }
                            ThingStuffPair  thingStuffPair3 = aps[i];
                            ApparelLayerDef apparelLayerDef = thingStuffPair3.thing.apparel.layers[num];
                            if (apparelLayerDef == ApparelLayerDefOf.OnSkin)
                            {
                                flag2 = true;
                            }
                            if (apparelLayerDef == ApparelLayerDefOf.Shell || apparelLayerDef == ApparelLayerDefOf.Middle)
                            {
                                flag = true;
                            }
                            num++;
                        }
                    }
                }
                return(flag && !flag2);
            }
示例#4
0
 public static void Postfix(ApparelLayerDef __instance, ref bool __result)
 {
     // check the settings to see if backpacks are enabled
     if (Controller.settings.ShowBackpacks)
     {
         __result = __result || __instance == CE_ApparelLayerDefOf.Backpack;
     }
 }
示例#5
0
 /// <summary>
 /// Used for rendering of CE custom apparel layers.
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 private static bool IsVisibleLayer_Internal(ApparelLayerDef layer)
 {
     /*
      * Belt is not actually a pre-shell layer, but we want to treat it as such in this patch,
      * to avoid rendering bugs with utility items (e.g: broadshield pack)
      */
     return(true &&
            layer.drawOrder >= ApparelLayerDefOf.Shell.drawOrder &&
            layer != ApparelLayerDefOf.Belt &&
            !(layer.GetModExtension <ApparelLayerExtension>()?.IsHeadwear ?? false));
 }
 public static void GenerateLayerGroupPairs(BodyDef body, ThingDef td, Action <ApparelUtility.LayerGroupPair> callback)
 {
     for (int i = 0; i < td.apparel.layers.Count; i++)
     {
         ApparelLayerDef    layer = td.apparel.layers[i];
         BodyPartGroupDef[] interferingBodyPartGroups = td.apparel.GetInterferingBodyPartGroups(body);
         for (int j = 0; j < interferingBodyPartGroups.Length; j++)
         {
             callback(new ApparelUtility.LayerGroupPair(layer, interferingBodyPartGroups[j]));
         }
     }
 }
示例#7
0
        /// <summary>
        /// Prepare apparel def by caching isVisibleLayer.
        /// </summary>
        /// <param name="def">Apparel def</param>
        private static void ProcessApparel(ThingDef def)
        {
            ApparelLayerDef layer = def.apparel.LastLayer;

            /*
             * set isVisibleLayerArray from the layer index since layers are processed first.
             */
            if (layer != null)
            {
                isVisibleLayerArray[def.index] = isVisibleLayerArray[layer.index];
            }
        }
        private static Color GetLayerColor(ApparelLayerDef layer, Pawn pawn)
        {
            int layerInt = ChangeMirror.Util.ToInt(layer);

            foreach (Apparel a in pawn.apparel.WornApparel)
            {
                if (a.def.apparel.LastLayer == layer)
                {
                    return(a.DrawColor);
                }
            }
            return(Color.white);
        }
示例#9
0
        public void SetLayerColor(ApparelLayerDef layer, Color c)
        {
            int layerInt = Util.ToInt(layer);

            this.InitApparelColor();
            if (this.ApparelColors != null && this.ApparelColors.Count > layerInt)
            {
                SlotColor sc = this.ApparelColors[layerInt];
                sc.Color      = c;
                sc.IsAssigned = true;
                this.ApparelColors[layerInt] = sc;
            }
        }
示例#10
0
 public void Add(ThingStuffPair pair)
 {
     aps.Add(pair);
     for (int i = 0; i < pair.thing.apparel.layers.Count; i++)
     {
         ApparelLayerDef    layer = pair.thing.apparel.layers[i];
         BodyPartGroupDef[] interferingBodyPartGroups = pair.thing.apparel.GetInterferingBodyPartGroups(body);
         for (int j = 0; j < interferingBodyPartGroups.Length; j++)
         {
             lgps.Add(new ApparelUtility.LayerGroupPair(layer, interferingBodyPartGroups[j]));
         }
     }
 }
示例#11
0
        public List <Material> UnderwearMatsBodyBaseAt(Rot4 facing, RotDrawMode bodyCondition = RotDrawMode.Fresh)
        {
            int num = facing.AsInt + 1000 * (int)bodyCondition;

            if (num != this._cachedSkinMatsBodyBaseHash)
            {
                this._cachedSkinMatsBodyBase.Clear();
                this._cachedSkinMatsBodyBaseHash = num;
                PawnGraphicSet graphics = this.Pawn.Drawer.renderer.graphics;
                if (bodyCondition == RotDrawMode.Fresh)
                {
                    this._cachedSkinMatsBodyBase.Add(graphics.nakedGraphic.MatAt(facing));
                }
                else if (bodyCondition == RotDrawMode.Rotting || graphics.dessicatedGraphic == null)
                {
                    this._cachedSkinMatsBodyBase.Add(graphics.rottingGraphic.MatAt(facing));
                }
                else if (bodyCondition == RotDrawMode.Dessicated)
                {
                    this._cachedSkinMatsBodyBase.Add(graphics.dessicatedGraphic.MatAt(facing));
                }

                for (int i = 0; i < graphics.apparelGraphics.Count; i++)
                {
                    ApparelLayerDef lastLayer = graphics.apparelGraphics[i].sourceApparel.def.apparel.LastLayer;

                    // if (lastLayer != ApparelLayerDefOf.Shell && lastLayer != ApparelLayerDefOf.Overhead)
                    if (lastLayer == ApparelLayerDefOf.OnSkin)
                    {
                        this._cachedSkinMatsBodyBase.Add(graphics.apparelGraphics[i].graphic.MatAt(facing));
                    }
                }
                // One more time to get at least one pieces of cloth
                if (this._cachedSkinMatsBodyBase.Count < 1)
                {
                    for (int i = 0; i < graphics.apparelGraphics.Count; i++)
                    {
                        ApparelLayerDef lastLayer = graphics.apparelGraphics[i].sourceApparel.def.apparel.LastLayer;

                        // if (lastLayer != ApparelLayerDefOf.Shell && lastLayer != ApparelLayerDefOf.Overhead)
                        if (lastLayer == ApparelLayerDefOf.Middle)
                        {
                            this._cachedSkinMatsBodyBase.Add(graphics.apparelGraphics[i].graphic.MatAt(facing));
                        }
                    }
                }
            }

            return(this._cachedSkinMatsBodyBase);
        }
 internal void UpdatePawn(object sender, object value)
 {
     if (sender is ApparelColorSelectionDTO)
     {
         ApparelColorSelectionDTO apparelColorSelectDto = (ApparelColorSelectionDTO)sender;
         Apparel         a     = apparelColorSelectDto.Apparel;
         ApparelLayerDef layer = this.PawnOutfitTracker.GetOuterMostLayer(a);
         foreach (ApparelLayerColorSelectionDTO dto in ApparelLayerSelections)
         {
             if (dto.ApparelLayerDef == layer)
             {
                 dto.SelectedColor = a.DrawColor;
             }
             //if (a.def.apparel.layers.Contains(dto.ApparelLayerDef))
         }
     }
 }
示例#13
0
        public PawnLayer FindLayerForApparel(ApparelProperties apparelProperties)
        {
            ApparelLayerDef layer = apparelProperties.LastLayer;

            if (layer == ApparelLayerDefOf.OnSkin && apparelProperties.bodyPartGroups.Count == 1)
            {
                if (apparelProperties.bodyPartGroups[0].Equals(BodyPartGroupDefOf.Legs))
                {
                    return(pantsLayer);
                }
                else if (apparelProperties.bodyPartGroups[0].defName == "Hands")
                {
                    return(null);
                }
                else if (apparelProperties.bodyPartGroups[0].defName == "Feet")
                {
                    return(null);
                }
            }
            if (layer == ApparelLayerDefOf.OnSkin)
            {
                return(bottomClothingLayer);
            }
            else if (layer == ApparelLayerDefOf.Middle)
            {
                return(middleClothingLayer);
            }
            else if (layer == ApparelLayerDefOf.Shell)
            {
                return(topClothingLayer);
            }
            else if (layer == ApparelLayerDefOf.Overhead)
            {
                return(hatLayer);
            }
            else if (layer == ApparelLayerDefOf.Belt)
            {
                return(accessoryLayer);
            }
            else
            {
                Log.Warning("Cannot find matching layer for apparel.  Last layer: " + apparelProperties.LastLayer);
                return(null);
            }
        }
示例#14
0
        public PawnLayer FindLayerForApparel(ApparelProperties apparelProperties)
        {
            ApparelLayerDef layer = apparelProperties.LastLayer;

            if (layer == ApparelLayerDefOf.OnSkin)
            {
                if (apparelProperties.bodyPartGroups.Any(x => x.Equals(BodyPartGroupDefOf.Legs)))
                {
                    if (apparelProperties.bodyPartGroups.Count == 1 ||
                        // YAYO's Combat 3 added Feet as a body part to pants, breaking this mod, so this fixes it
                        (apparelProperties.bodyPartGroups.Count == 2 && apparelProperties.bodyPartGroups.Any(x => x.defName == "Feet")))
                    {
                        return(pantsLayer);
                    }
                    // would have returned bottomClothingLayer here, but it's redundant.
                }
                // checks if not gloves or socks (1 body part, which is either hands or feet)
                else if (apparelProperties.bodyPartGroups.Count == 1 && apparelProperties.bodyPartGroups.All(x => x.defName == "Hands" || x.defName == "Feet"))
                {
                    return(null);
                }
                return(bottomClothingLayer);
            }
            else if (layer == ApparelLayerDefOf.Middle)
            {
                return(middleClothingLayer);
            }
            else if (layer == ApparelLayerDefOf.Shell)
            {
                return(topClothingLayer);
            }
            else if (layer == ApparelLayerDefOf.Overhead)
            {
                return(hatLayer);
            }
            else if (layer == ApparelLayerDefOf.Belt)
            {
                return(accessoryLayer);
            }
            else
            {
                Logger.Warning("Cannot find matching layer for apparel.  Last layer: " + apparelProperties.LastLayer);
                return(null);
            }
        }
 private static bool IsVisibleLayer(ApparelLayerDef def)
 {
     // If it's invisible skip everything
     if (!def.IsVisibleLayer())
     {
         return(false);
     }
     // Moved to since backpacks use
     if (def == CE_ApparelLayerDefOf.Backpack)
     {
         return(false);
     }
     // Enable toggling webbing rendering
     if (def == CE_ApparelLayerDefOf.Webbing && !Controller.settings.ShowTacticalVests)
     {
         return(false);
     }
     return(true);
 }
示例#16
0
 public bool PairOverlapsAnything(ThingStuffPair pair)
 {
     if (!lgps.Any())
     {
         return(false);
     }
     for (int i = 0; i < pair.thing.apparel.layers.Count; i++)
     {
         ApparelLayerDef    layer = pair.thing.apparel.layers[i];
         BodyPartGroupDef[] interferingBodyPartGroups = pair.thing.apparel.GetInterferingBodyPartGroups(body);
         for (int j = 0; j < interferingBodyPartGroups.Length; j++)
         {
             if (lgps.Contains(new ApparelUtility.LayerGroupPair(layer, interferingBodyPartGroups[j])))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#17
0
        public Color GetLayerColor(ApparelLayerDef layer, bool getFromWorn = false)
        {
            int layerInt = Util.ToInt(layer);

            if (this.ApparelColors != null && this.ApparelColors.Count > layerInt)
            {
                SlotColor sc = this.ApparelColors[layerInt];
                if (sc.IsAssigned)
                {
                    return(sc.Color);
                }
            }
            if (getFromWorn)
            {
                foreach (Apparel a in this.Pawn.apparel.WornApparel)
                {
                    if (a.def.apparel.LastLayer == layer)
                    {
                        return(a.DrawColor);
                    }
                }
            }
            return(Color.white);
        }
 private static bool IsPreShellLayer(ApparelLayerDef layer)
 {
     return(layer.drawOrder < ApparelLayerDefOf.Shell.drawOrder ||
            (layer.GetModExtension <ApparelLayerExtension>()?.IsHeadwear ?? false));
 }
示例#19
0
 /// <summary>
 /// Prepare apparellayerdef def by caching isVisibleLayer.
 /// </summary>
 /// <param name="def">Apparel def</param>
 private static void ProcessApparelLayer(ApparelLayerDef layer)
 {
     isVisibleLayerArray[layer.index] = IsVisibleLayer_Internal(layer);
 }
示例#20
0
 public static bool IsVisibleLayer(this ApparelLayerDef def)
 {
     return(isVisibleLayerArray[def.index]);
 }
 private static string <GetLayersString> m__4(ApparelLayerDef layer)
 {
     return(layer.label);
 }
示例#22
0
 private static bool IsHeadwear(ApparelLayerDef layer)
 {
     return(layer.GetModExtension <ApparelLayerExtension>()?.IsHeadwear ?? false);
 }
示例#23
0
 public static bool LastLayerShellOrHigher(ApparelLayerDef LastLayer, ApparelLayerDef Shell)
 {
     return(LastLayer.drawOrder >= Shell.drawOrder && LastLayer.drawOrder < ApparelLayerDefOf.Overhead.drawOrder && !(LastLayer.defName.Contains("Head") || LastLayer.defName.Contains("head")) && !LastLayer.IsUtilityLayer);
 }
 public LayerGroupPair(ApparelLayerDef layer, BodyPartGroupDef group)
 {
     this.layer = layer;
     this.group = group;
 }
示例#25
0
        public static void AddAppararelColorByLayerSelectionWidget(
            float left, float top, float width, Pawn pawn, ApparelLayerSelectionsContainer layerSelectionsContainer, ClearColorLayers clearColorLayers)
        {
            Text.Anchor = TextAnchor.MiddleCenter;
            if (layerSelectionsContainer.Count == 0)
            {
                GUI.Label(new Rect(left, top, width, SelectionRowHeight), "ChangeMirror.NoClothingIsWorn".Translate(), MiddleCenter);
            }
            else
            {
                const float cellHeight        = 38f;
                float       colorSampleHeight = (cellHeight - LayerColor.height) * 0.5f;
                Rect        apparelListRect   = new Rect(left, top, width, 250f);
                Rect        apparelScrollRect = new Rect(0f, 0f, width - 16f, layerSelectionsContainer.Count * cellHeight + SelectionRowHeight);

                GUI.BeginGroup(apparelListRect);
                scrollPos = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), scrollPos, apparelScrollRect);

                GUI.color = Color.white;
                Text.Font = GameFont.Small;
                if (Widgets.ButtonText(new Rect(10, 0, 100, SelectionRowHeight), "ChangeMirror.SelectAll".Translate()))
                {
                    layerSelectionsContainer.SelectAll();
                }
                if (Widgets.ButtonText(new Rect(apparelScrollRect.width - 140, 0, 100, SelectionRowHeight), "ChangeMirror.DeselectAll".Translate()))
                {
                    layerSelectionsContainer.DeselectAll();
                }
                if (clearColorLayers != null &&
                    Widgets.ButtonText(new Rect(apparelScrollRect.width - SelectionRowHeight, 0, SelectionRowHeight, SelectionRowHeight), "X"))
                {
                    clearColorLayers();
                }

                Text.Font = GameFont.Medium;

                for (int i = 0; i < layerSelectionsContainer.Count; ++i)
                {
                    ApparelLayerColorSelectionDTO dto = layerSelectionsContainer[i];
                    ApparelLayerDef layer             = dto.ApparelLayerDef;
                    GUI.BeginGroup(new Rect(0, SelectionRowHeight + 3f + i * cellHeight, apparelListRect.width, cellHeight));

                    GUI.color = GetLayerColor(dto.ApparelLayerDef, pawn);
                    Rect rect = new Rect(0f, colorSampleHeight, LayerColor.width, LayerColor.height);
                    GUI.Label(rect, new GUIContent(LayerColor));
                    GUI.color = Color.white;
                    //Widgets.DrawBox(rect, 1);

                    Text.Font   = GameFont.Small;
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Rect textRect = new Rect(rect.width + 5f, 0f, apparelScrollRect.width - 90f, cellHeight);
                    if (layerSelectionsContainer.IsSelected(dto))
                    {
                        GUI.color = Color.white;
                    }
                    else
                    {
                        GUI.color = Color.gray;
                    }
                    Widgets.Label(textRect, new GUIContent(dto.ApparelLayerDef.ToString().Translate(), "ChangeMirror.SelectMultipleApparel".Translate()));
                    if (Widgets.ButtonInvisible(textRect, false))
                    {
                        layerSelectionsContainer.Select(dto, Event.current.shift);
                    }
                    GUI.color = Color.white;
                    if (Widgets.ButtonImage(new Rect(apparelScrollRect.width - 40f, 0, 32f, 16f), copyIconTexture))
                    {
                        layerSelectionsContainer.CopyColor = GetLayerColor(dto.ApparelLayerDef, pawn);
                    }
                    if (layerSelectionsContainer.CopyColorSelected)
                    {
                        if (Widgets.ButtonImage(new Rect(apparelScrollRect.width - 40f, 16f, 32f, 16f), pasteIconTexture))
                        {
                            dto.SelectedColor = layerSelectionsContainer.CopyColor;
                        }
                    }
                    GUI.EndGroup();
                }
                GUI.EndScrollView();
                GUI.EndGroup();

                /*if (Settings.UseColorPickerV2)
                 * {
                 *  AddColorSelectorV2Widget(left, top + apparelListRect.height + 10f, width, apparelSelectionsContainer.SelectedApparel, apparelSelectionsContainer.ColorPresetsDTO);
                 * }
                 * else
                 * {*/
                AddColorSelectorWidget(left, top + apparelListRect.height + 10f, width, layerSelectionsContainer.SelectedApparel, layerSelectionsContainer.ColorPresetsDTO);
                //}
            }
            Text.Anchor = TextAnchor.UpperLeft;
        }
 public ApparelLayerColorSelectionDTO(ApparelLayerDef layer, PawnOutfitTracker po) : base((po != null) ? po.GetLayerColor(layer, true) : Color.white)
 {
     this.ApparelLayerDef   = layer;
     this.PawnOutfitTracker = po;
 }
 private static bool RenderSpecial(ApparelLayerDef layer)
 {
     return((layer.GetModExtension <ApparelLayerExtension>()?.IsHeadwear ?? false) ||
            layer.drawOrder > ApparelLayerDefOf.Shell.drawOrder);
 }
示例#28
0
 public static int ToInt(ApparelLayerDef layer)
 {
     InitDic();
     return(layerDictionary[layer]);
 }
示例#29
0
 private static bool IsPreShellLayer(ApparelLayerDef layer)
 {
     return(layer.drawOrder < ApparelLayerDefOf.Shell.drawOrder ||
            (layer.GetModExtension <ApparelLayerExtension>()?.IsHeadwear ?? false) ||
            layer == ApparelLayerDefOf.Belt);    //Belt is not actually a pre-shell layer, but we want to treat it as such in this patch, to avoid rendering bugs with utility items (e.g: broadshield pack)
 }
 public ApparelLayerColorSelectionDTO(ApparelLayerDef layer) : base(Color.white)
 {
     this.ApparelLayerDef = layer;
 }