private void SetBody(ClothingSlot slot)
    {
        GameObject bodyObj = transform.GetChild(BodyObjects[slot]).gameObject;

        bodyObj.GetComponent <SkinnedMeshRenderer>().sharedMesh = GameMaster.Instance.CustomizationManager.Character.GetClothingSlotSO(slot).BodyMesh;
        bodyObj.GetComponent <SkinnedMeshRenderer>().enabled    = true;
    }
        private static void Prefix(Panel_Clothing __instance)
        {
            Transform container      = __instance.transform.Find(CONTAINER_PATH);
            Transform innerTransform = container?.Find(INNER_NAME);
            Transform outerTransform = container?.Find(OUTER_NAME);

            if (!innerTransform || !outerTransform || innerTransform.localPosition.x > outerTransform.localPosition.x)
            {
                Debug.LogWarning("[TLD-Bugfixes] Warning: Could not apply head clothing slot fix");
                return;
            }

            // Switch positions
            Vector3 innerPos = innerTransform.localPosition;
            Vector3 outerPos = outerTransform.localPosition;

            innerTransform.localPosition = outerPos;
            outerTransform.localPosition = innerPos;

            // Fix column indices
            ClothingSlot innerSlot = innerTransform.GetComponentInChildren <ClothingSlot>();
            ClothingSlot outerSlot = outerTransform.GetComponentInChildren <ClothingSlot>();

            COLUMN_FIELD.SetValue(innerSlot, 1);
            COLUMN_FIELD.SetValue(outerSlot, 0);
        }
    private void UnsetBody(ClothingSlot slot)
    {
        GameObject bodyObj = transform.GetChild(BodyObjects[slot]).gameObject;

        bodyObj.GetComponent <SkinnedMeshRenderer>().sharedMesh = null;
        bodyObj.GetComponent <SkinnedMeshRenderer>().enabled    = false;
    }
示例#4
0
 //===================================================================//
 //                            Booleans                               //
 //===================================================================//
 /// <summary>
 /// Determines if the <see cref="Clothes"/> contains some
 /// <see cref="Clothing"/> of the specified type.
 /// </summary>
 /// <param name="slot">the type to check for</param>
 /// <returns>
 /// true if the <see cref="Clothes"/> contains something
 /// of the specifed type; false otherwise
 /// </returns>
 public bool ContainsSomethingOfType(ClothingSlot slot)
 {
     foreach (Clothing item in this.GetContents()) {
         if (item.HasType(slot)) {
             return true; }
     } // end foreach
     return false;
 }
示例#5
0
        //===================================================================//
        //                         Constructors                              //
        //===================================================================//
        /// <summary>
        /// Creates a new clothing item with the specified name and description.
        /// </summary>
        /// <param name="name">the name of the clothing</param>
        /// <param name="description">a brief description of the thing</param>
        public Clothing(string name, string description, ClothingSlot[] slots,
            string[] parsedNames = null,
            bool isSpecific=false, bool isPlural=false, bool isProper=false,
            bool canBeTaken=true,bool canBeDropped=true,bool canBeRemoved=true)
            : base(name, description, parsedNames,
			isSpecific:isSpecific, isPlural:isPlural, isProper:isProper,
			canBeTaken:canBeTaken, canBeDropped:canBeDropped,isTwoHanded:false)
        {
            this.canBeRemoved = canBeRemoved;
            this.slots = new HashSet<ClothingSlot>(slots);
        }
    public void UnsetClothing(ClothingSlot slot)
    {
        GetClothingSlotScript(ClothingObjects[slot]).Unset();

        if (BodyObjects.ContainsKey(slot))
        {
            GetClothingSlotScript(BodyObjects[slot]).Unset();

            SetUpBodyObjects();
        }
    }
    /// <summary>
    /// Sets the color of clothing in the specified clothing slot to the specified color.
    /// </summary>
    /// <param name="slot"></param>
    /// <param name="newClothingColor"></param>
    public void UpdateClothingColor(ClothingSlot slot, Color newClothingColor)
    {
        ClothingSlotScript clothingSlotScript = transform.GetChild(ClothingObjects[slot]).gameObject.GetComponent <ClothingSlotScript>();

        if (!clothingSlotScript.HasCustomMaterial)
        {
            clothingSlotScript.gameObject.GetComponent <Renderer>().sharedMaterial.color = newClothingColor;
        }
        else
        {
            Debug.Log("***Cannot change color of clothing object with custom material!");
        }
    }
    public List <int> GetClothingIDsBySlot(ClothingSlot slot)
    {
        List <int> clothing = new List <int>();

        for (int i = 0; i < Clothing.Count; i++)
        {
            if (Clothing[i].ClothingSlot.Slot == slot)
            {
                clothing.Add(i);
            }
        }

        return(clothing);
    }
    public int?GetDefaultClothingBySlot(ClothingSlot slot)
    {
        int?clothingIndex = null;

        foreach (int iDefaultClothing in DefaultClothingIndexes)
        {
            if (Clothing[iDefaultClothing].ClothingSlot.Slot == slot)
            {
                clothingIndex = iDefaultClothing;
                break;
            }
        }

        return(clothingIndex);
    }
示例#10
0
        public static bool Prefix(ClothingSlot __instance)
        {
            ModClothingComponent clothingComponent = ModUtils.GetComponent <ModClothingComponent>(__instance.m_GearItem);

            if (clothingComponent == null)
            {
                return(true);
            }

            int actualDrawLayer = Mathf.Max(40, clothingComponent.DrawLayer);

            ModUtils.ExecuteMethod(__instance, "UpdatePaperDollTextureLayer", actualDrawLayer);

            return(false);
        }
示例#11
0
        static void ClothingSlot_DoClickAction_Postfix(ClothingSlot __instance)
        {
            if (!Input.GetMouseButtonUp(1) || !__instance.m_GearItem)
            {
                return;
            }

            if (!UIHelper.clothPanel.m_ItemDescriptionPage.CanDrop(__instance.m_GearItem))
            {
                return;
            }

            clothItemPlaceAfterDrop = __instance.m_GearItem;
            UIHelper.clothPanel.OnDropItem();
        }
    public CharacterClothingSlotSO GetClothingSlotSO(ClothingSlot slot)
    {
        CharacterClothingSlotSO slotSO = ClothingSlots[0];

        for (int i = 0; i < ClothingSlots.Count; i++)
        {
            if (ClothingSlots[i].Slot == slot)
            {
                slotSO = ClothingSlots[i];

                i = ClothingSlots.Count;
            }
        }

        return(slotSO);
    }
示例#13
0
        public float ApplyArmorProtection(float attackPower)
        {
            float        num  = m_random.UniformFloat(0f, 1f);
            ClothingSlot slot = (num < 0.1f) ? ClothingSlot.Feet : ((num < 0.3f) ? ClothingSlot.Legs : ((num < 0.9f) ? ClothingSlot.Torso : ClothingSlot.Head));
            float        num2 = ((MekClothingBlock)BlocksManager.Blocks[1011]).Durability + 1;
            List <int>   list = new List <int>(GetClothes(slot));

            for (int i = 0; i < list.Count; i++)
            {
                int          value        = list[i];
                MekClothData clothingData = MekClothingBlock.GetClothingData(Terrain.ExtractData(value));
                float        x            = (num2 - (float)BlocksManager.Blocks[1011].GetDamage(value)) / num2 * clothingData.Sturdiness;
                float        num3         = MathUtils.Min(attackPower * MathUtils.Saturate(clothingData.ArmorProtection), x);
                if (num3 > 0f)
                {
                    attackPower -= num3;
                    if (m_subsystemGameInfo.WorldSettings.GameMode != 0)
                    {
                        float x2          = num3 / clothingData.Sturdiness * num2 + 0.001f;
                        int   damageCount = (int)(MathUtils.Floor(x2) + (float)(m_random.Bool(MathUtils.Remainder(x2, 1f)) ? 1 : 0));
                        list[i] = BlocksManager.DamageItem(value, damageCount);
                    }
                    if (!string.IsNullOrEmpty(clothingData.ImpactSoundsFolder))
                    {
                        m_subsystemAudio.PlayRandomSound(clothingData.ImpactSoundsFolder, 1f, m_random.UniformFloat(-0.3f, 0.3f), m_componentBody.Position, 4f, 0.15f);
                    }
                }
            }
            int num4 = 0;

            while (num4 < list.Count)
            {
                if (Terrain.ExtractContents(list[num4]) != 1011)
                {
                    list.RemoveAt(num4);
                    m_subsystemParticles.AddParticleSystem(new BlockDebrisParticleSystem(m_subsystemTerrain, m_componentBody.Position + m_componentBody.BoxSize / 2f, 1f, 1f, Color.White, 0));
                }
                else
                {
                    num4++;
                }
            }
            SetClothes(slot, list);
            return(MathUtils.Max(attackPower, 0f));
        }
    public int GetRandomClothingBySlot(ClothingSlot slot, bool includeSpecial = false)
    {
        List <int> clothing = GetClothingIDsBySlot(slot);

        if (!includeSpecial)
        {
            for (int i = 0; i < clothing.Count; i++)
            {
                if (GameMaster.Instance.CustomizationManager.Character.Clothing[clothing[i]].Special)
                {
                    clothing.RemoveAt(i);
                    i--;
                }
            }
        }

        return(clothing[Random.Range(0, clothing.Count)]);
    }
示例#15
0
    void slots(CharacterClothingSO clothing)
    {
        int i = 0;

        clicked  = true;
        tempItem = clothing;
        foreach (CharacterClothingSO item in GameMaster.Instance.CustomizationManager.Character.Clothing)
        {
            if (item == clothing)
            {
                SetClothing(i, item.ClothingSlot.Slot);
                currentSlot = item.ClothingSlot.Slot;
                price.SetText(item.Price.ToString());
                break;
            }
            i++;
        }
    }
示例#16
0
        private static bool Prefix(ClothingSlot __instance)
        {
            ModClothingComponent clothingComponent = ModComponentUtils.ComponentUtils.GetComponent <ModClothingComponent>(__instance.m_GearItem);

            if (clothingComponent is null)
            {
                if (__instance.m_GearItem != null)
                {
                    int defaultDrawLayer = DefaultDrawLayers.GetDefaultDrawLayer(__instance.m_ClothingRegion, __instance.m_ClothingLayer);
                    __instance.UpdatePaperDollTextureLayer(defaultDrawLayer);
                }
                return(true);
            }

            int actualDrawLayer = clothingComponent.DrawLayer;

            __instance.UpdatePaperDollTextureLayer(actualDrawLayer);
            //Logger.Log("Set the draw layer for '{0}' to {1}", __instance.m_GearItem.name, actualDrawLayer);
            return(false);
        }
 /// <summary>
 /// Checks if the specified clothing slot is currently filled/in use.
 /// </summary>
 /// <param name="clothingSlot"></param>
 /// <returns></returns>
 public bool IsClothingSlotUsed(ClothingSlot clothingSlot)
 {
     return(GetClothingSlotScript(ClothingObjects[clothingSlot]).IsSet);
 }
示例#18
0
 public void SetClothes(ClothingSlot slot, IEnumerable <int> clothes)
 {
     if (!m_clothes[slot].SequenceEqual(clothes))
     {
         m_clothes[slot].Clear();
         m_clothes[slot].AddRange(clothes);
         m_clothedTexturesValid = false;
         float num = 0f;
         foreach (KeyValuePair <ClothingSlot, List <int> > clothe in m_clothes)
         {
             foreach (int item in clothe.Value)
             {
                 MekClothData clothingData = MekClothingBlock.GetClothingData(Terrain.ExtractData(item));
                 num += clothingData.DensityModifier;
             }
         }
         float num2 = num - m_densityModifierApplied;
         m_densityModifierApplied += num2;
         m_componentBody.Density  += num2;
         SteedMovementSpeedFactor  = 1f;
         float num3 = 2f;
         float num4 = 0.2f;
         float num5 = 0.4f;
         float num6 = 2f;
         foreach (int clothe2 in GetClothes(ClothingSlot.Head))
         {
             MekClothData clothingData2 = MekClothingBlock.GetClothingData(Terrain.ExtractData(clothe2));
             num3 += clothingData2.Insulation;
             SteedMovementSpeedFactor *= clothingData2.SteedMovementSpeedFactor;
         }
         foreach (int clothe3 in GetClothes(ClothingSlot.Torso))
         {
             MekClothData clothingData3 = MekClothingBlock.GetClothingData(Terrain.ExtractData(clothe3));
             num4 += clothingData3.Insulation;
             SteedMovementSpeedFactor *= clothingData3.SteedMovementSpeedFactor;
         }
         foreach (int clothe4 in GetClothes(ClothingSlot.Legs))
         {
             MekClothData clothingData4 = MekClothingBlock.GetClothingData(Terrain.ExtractData(clothe4));
             num5 += clothingData4.Insulation;
             SteedMovementSpeedFactor *= clothingData4.SteedMovementSpeedFactor;
         }
         foreach (int clothe5 in GetClothes(ClothingSlot.Feet))
         {
             MekClothData clothingData5 = MekClothingBlock.GetClothingData(Terrain.ExtractData(clothe5));
             num6 += clothingData5.Insulation;
             SteedMovementSpeedFactor *= clothingData5.SteedMovementSpeedFactor;
         }
         Insulation = 1f / (1f / num3 + 1f / num4 + 1f / num5 + 1f / num6);
         float num7 = MathUtils.Min(num3, num4, num5, num6);
         if (num3 == num7)
         {
             LeastInsulatedSlot = ClothingSlot.Head;
         }
         else if (num4 == num7)
         {
             LeastInsulatedSlot = ClothingSlot.Torso;
         }
         else if (num5 == num7)
         {
             LeastInsulatedSlot = ClothingSlot.Legs;
         }
         else if (num6 == num7)
         {
             LeastInsulatedSlot = ClothingSlot.Feet;
         }
     }
 }
 /// <summary>
 /// Returns the Index/ID of the clothing on the specified slot. A value of -1 being returned indicates there is no clothing.
 /// </summary>
 /// <param name="clothingSlot"></param>
 /// <returns></returns>
 public int GetClothingIndexBySlot(ClothingSlot clothingSlot)
 {
     return(GetClothingSlotScript(ClothingObjects[clothingSlot]).ClothingIndex);
 }
示例#20
0
 void SetClothing(int index, ClothingSlot slot)
 {
     playerCus.SetClothing(index);
     playerCus.UpdateClothingColor(slot, colour.textureColour);
 }
示例#21
0
 /// <summary>
 /// Determines if the clothing covers the specified slot.
 /// </summary>
 /// <param name="type">the slot to check</param>
 /// <returns>true if it covers the slot; false otherwise</returns>
 public bool HasType(ClothingSlot type)
 {
     if (this.slots.Contains(type))
     {
         return true;
     }
     return false;
 }
示例#22
0
 public ReadOnlyList <int> GetClothes(ClothingSlot slot)
 {
     return(new ReadOnlyList <int>(m_clothes[slot]));
 }