Example #1
0
        public override string GetDescription(int value)
        {
            int          data         = Terrain.ExtractData(value);
            ClothingData clothingData = GetClothingData(data);
            string       desc         = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, data), "Description");

            if (string.IsNullOrEmpty(desc))
            {
                desc = clothingData.Description;
            }
            return(desc);
        }
        public bool CanWearClothing(int value)
        {
            ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(value));
            IList <int>  list         = GetClothes(clothingData.Slot);

            if (list.Count == 0)
            {
                return(true);
            }
            ClothingData clothingData2 = ClothingBlock.GetClothingData(Terrain.ExtractData(list[list.Count - 1]));

            return(clothingData.Layer > clothingData2.Layer);
        }
Example #3
0
        public static void AddClothingFactor(int clothingValue, ref float clothingFactor, ICollection <Factor> factors)
        {
            ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(clothingValue));

            if (clothingData.MovementSpeedFactor != 1f)
            {
                clothingFactor *= clothingData.MovementSpeedFactor;
                factors?.Add(new Factor
                {
                    Value       = clothingData.MovementSpeedFactor,
                    Description = clothingData.DisplayName
                });
            }
        }
Example #4
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int          data          = Terrain.ExtractData(value);
            int          clothingColor = GetClothingColor(data);
            ClothingData clothingData  = GetClothingData(data);
            Matrix       matrix2       = m_slotTransforms[(int)clothingData.Slot] * Matrix.CreateScale(size) * matrix;

            if (clothingData.IsOuter)
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_outerMesh, clothingData.Texture, color * SubsystemPalette.GetFabricColor(environmentData, clothingColor), 1f, ref matrix2, environmentData);
            }
            else
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_innerMesh, clothingData.Texture, color * SubsystemPalette.GetFabricColor(environmentData, clothingColor), 1f, ref matrix2, environmentData);
            }
        }
Example #5
0
        public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
        {
            int          data          = Terrain.ExtractData(value);
            ClothingData clothingData  = GetClothingData(data);
            int          clothingColor = GetClothingColor(data);
            string       displayName   = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, data), "DisplayName");

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = clothingData.DisplayName;
            }
            if (clothingColor != 0)
            {
                return(SubsystemPalette.GetName(subsystemTerrain, clothingColor, displayName));
            }
            return(displayName);
        }
        public float ApplyArmorProtection(float attackPower)
        {
            float        num  = m_random.Float(0f, 1f);
            ClothingSlot slot = (num < 0.1f) ? ClothingSlot.Feet : ((num < 0.3f) ? ClothingSlot.Legs : ((num < 0.9f) ? ClothingSlot.Torso : ClothingSlot.Head));
            float        num2 = ((ClothingBlock)BlocksManager.Blocks[203]).Durability + 1;
            List <int>   list = new List <int>(GetClothes(slot));

            for (int i = 0; i < list.Count; i++)
            {
                int          value        = list[i];
                ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(value));
                float        x            = (num2 - (float)BlocksManager.Blocks[203].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.Float(-0.3f, 0.3f), m_componentBody.Position, 4f, 0.15f);
                    }
                }
            }
            int num4 = 0;

            while (num4 < list.Count)
            {
                if (Terrain.ExtractContents(list[num4]) != 203)
                {
                    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 void ProcessSlotItems(int slotIndex, int value, int count, int processCount, out int processedValue, out int processedCount)
        {
            processedCount = 0;
            processedValue = 0;
            if (processCount != 1)
            {
                return;
            }
            Block block = BlocksManager.Blocks[Terrain.ExtractContents(value)];

            if (block.GetNutritionalValue(value) > 0f)
            {
                if (block is BucketBlock)
                {
                    processedValue = Terrain.MakeBlockValue(90, 0, Terrain.ExtractData(value));
                    processedCount = 1;
                }
                if (count > 1 && processedCount > 0 && processedValue != value)
                {
                    processedValue = value;
                    processedCount = processCount;
                }
                else if (!m_componentVitalStats.Eat(value))
                {
                    processedValue = value;
                    processedCount = processCount;
                }
            }
            if (block is ClothingBlock)
            {
                ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(value));
                List <int>   list         = new List <int>(GetClothes(clothingData.Slot));
                list.Add(value);
                SetClothes(clothingData.Slot, list);
            }
        }
Example #8
0
        public override void Initialize()
        {
            if (Initialize1 != null)
            {
                Initialize1();
                return;
            }
            int num = 0;
            Dictionary <int, ClothingData> dictionary = new Dictionary <int, ClothingData>();
            IEnumerator <XElement>         enumerator = ModsManager.CombineXml(ContentManager.Get <XElement>("Clothes"), ModsManager.GetEntries(".clo"), "Index", "Clothes").Elements().GetEnumerator();

            while (enumerator.MoveNext())
            {
                XElement item           = enumerator.Current;
                string   newDescription = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, Index), "Description");
                string   newDisplayName = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, Index), "DisplayName");
                if (item.Attribute("DisplayName") != null && item.Attribute("Description") != null)
                {
                    newDisplayName = XmlUtils.GetAttributeValue <string>(item, "DisplayName");
                    newDescription = XmlUtils.GetAttributeValue <string>(item, "Description");
                }
                ClothingData clothingData = new ClothingData
                {
                    Index                    = XmlUtils.GetAttributeValue <int>(item, "Index"),
                    DisplayIndex             = num++,
                    DisplayName              = newDisplayName,
                    Slot                     = XmlUtils.GetAttributeValue <ClothingSlot>(item, "Slot"),
                    ArmorProtection          = XmlUtils.GetAttributeValue <float>(item, "ArmorProtection"),
                    Sturdiness               = XmlUtils.GetAttributeValue <float>(item, "Sturdiness"),
                    Insulation               = XmlUtils.GetAttributeValue <float>(item, "Insulation"),
                    MovementSpeedFactor      = XmlUtils.GetAttributeValue <float>(item, "MovementSpeedFactor"),
                    SteedMovementSpeedFactor = XmlUtils.GetAttributeValue <float>(item, "SteedMovementSpeedFactor"),
                    DensityModifier          = XmlUtils.GetAttributeValue <float>(item, "DensityModifier"),
                    IsOuter                  = XmlUtils.GetAttributeValue <bool>(item, "IsOuter"),
                    CanBeDyed                = XmlUtils.GetAttributeValue <bool>(item, "CanBeDyed"),
                    Layer                    = XmlUtils.GetAttributeValue <int>(item, "Layer"),
                    PlayerLevelRequired      = XmlUtils.GetAttributeValue <int>(item, "PlayerLevelRequired"),
                    Texture                  = ContentManager.Get <Texture2D>(XmlUtils.GetAttributeValue <string>(item, "TextureName")),
                    ImpactSoundsFolder       = XmlUtils.GetAttributeValue <string>(item, "ImpactSoundsFolder"),
                    Description              = newDescription
                };
                dictionary.Add(clothingData.Index, clothingData);
            }
            m_clothingData = new ClothingData[dictionary.Count];
            for (int i = 0; i < dictionary.Count; i++)
            {
                m_clothingData[i] = dictionary[i];
            }
            Model playerModel = CharacterSkinsManager.GetPlayerModel(PlayerClass.Male);

            Matrix[] array = new Matrix[playerModel.Bones.Count];
            playerModel.CopyAbsoluteBoneTransformsTo(array);
            int index  = playerModel.FindBone("Hand1").Index;
            int index2 = playerModel.FindBone("Hand2").Index;

            array[index]  = Matrix.CreateRotationY(0.1f) * array[index];
            array[index2] = Matrix.CreateRotationY(-0.1f) * array[index2];
            m_innerMesh   = new BlockMesh();
            foreach (ModelMesh mesh in playerModel.Meshes)
            {
                Matrix matrix = array[mesh.ParentBone.Index];
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    Color color = Color.White * 0.8f;
                    color.A = byte.MaxValue;
                    m_innerMesh.AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_innerMesh.AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, color);
                }
            }
            Model outerClothingModel = CharacterSkinsManager.GetOuterClothingModel(PlayerClass.Male);

            Matrix[] array2 = new Matrix[outerClothingModel.Bones.Count];
            outerClothingModel.CopyAbsoluteBoneTransformsTo(array2);
            int index3 = outerClothingModel.FindBone("Leg1").Index;
            int index4 = outerClothingModel.FindBone("Leg2").Index;

            array2[index3] = Matrix.CreateTranslation(-0.02f, 0f, 0f) * array2[index3];
            array2[index4] = Matrix.CreateTranslation(0.02f, 0f, 0f) * array2[index4];
            m_outerMesh    = new BlockMesh();
            foreach (ModelMesh mesh2 in outerClothingModel.Meshes)
            {
                Matrix matrix2 = array2[mesh2.ParentBone.Index];
                foreach (ModelMeshPart meshPart2 in mesh2.MeshParts)
                {
                    Color color2 = Color.White * 0.8f;
                    color2.A = byte.MaxValue;
                    m_outerMesh.AppendModelMeshPart(meshPart2, matrix2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_outerMesh.AppendModelMeshPart(meshPart2, matrix2, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, color2);
                }
            }
            base.Initialize();
        }
Example #9
0
        // Replace ClothingBlock.Initialize
        public override void Initialize()
        {
            var num        = 0;
            var dictionary = new Dictionary <int, ClothingData>();

            for (var i = ContentManager.CombineXml(ContentManager.Get <XElement>("Clothes"), ModsManager.GetEntries(".clo"), "Index", "DisplayName", "Clothes").Elements().GetEnumerator(); i.MoveNext();)
            {
                var element      = i.Current;
                var clothingData = new ClothingData
                {
                    Index                    = XmlUtils.GetAttributeValue <int>(element, "Index"),
                    DisplayIndex             = num++,
                    DisplayName              = XmlUtils.GetAttributeValue <string>(element, "DisplayName"),
                    Slot                     = XmlUtils.GetAttributeValue <ClothingSlot>(element, "Slot"),
                    ArmorProtection          = XmlUtils.GetAttributeValue <float>(element, "ArmorProtection"),
                    Sturdiness               = XmlUtils.GetAttributeValue <float>(element, "Sturdiness"),
                    Insulation               = XmlUtils.GetAttributeValue <float>(element, "Insulation"),
                    MovementSpeedFactor      = XmlUtils.GetAttributeValue <float>(element, "MovementSpeedFactor"),
                    SteedMovementSpeedFactor = XmlUtils.GetAttributeValue <float>(element, "SteedMovementSpeedFactor"),
                    DensityModifier          = XmlUtils.GetAttributeValue <float>(element, "DensityModifier"),
                    IsOuter                  = XmlUtils.GetAttributeValue <bool>(element, "IsOuter"),
                    CanBeDyed                = XmlUtils.GetAttributeValue <bool>(element, "CanBeDyed"),
                    Layer                    = XmlUtils.GetAttributeValue <int>(element, "Layer"),
                    PlayerLevelRequired      = XmlUtils.GetAttributeValue <int>(element, "PlayerLevelRequired"),
                    Texture                  = ContentManager.Get <Texture2D>(XmlUtils.GetAttributeValue <string>(element, "TextureName")),
                    ImpactSoundsFolder       = XmlUtils.GetAttributeValue <string>(element, "ImpactSoundsFolder"),
                    Description              = XmlUtils.GetAttributeValue <string>(element, "Description")
                };
                dictionary[clothingData.Index] = clothingData;
            }

            m_clothingData = new ClothingData[dictionary.Count];
            int index;

            for (index = 0; index < dictionary.Count; ++index)
            {
                m_clothingData[index] = dictionary[index];
            }
            var playerModel         = CharacterSkinsManager.GetPlayerModel(PlayerClass.Male);
            var absoluteTransforms1 = new Matrix[playerModel.Bones.Count];

            playerModel.CopyAbsoluteBoneTransformsTo(absoluteTransforms1);
            index = playerModel.FindBone("Hand1", true).Index;
            int index2 = playerModel.FindBone("Hand2", true).Index;

            absoluteTransforms1[index]  = Matrix.CreateRotationY(0.1f) * absoluteTransforms1[index];
            absoluteTransforms1[index2] = Matrix.CreateRotationY(-0.1f) * absoluteTransforms1[index2];
            m_innerMesh = new BlockMesh();
            foreach (var mesh in playerModel.Meshes)
            {
                var matrix = absoluteTransforms1[mesh.ParentBone.Index];
                foreach (var meshPart in mesh.MeshParts)
                {
                    var color = Color.White * 0.8f;
                    color.A = byte.MaxValue;
                    m_innerMesh.AppendModelMeshPart(meshPart, matrix, false, false, false, false, Color.White);
                    m_innerMesh.AppendModelMeshPart(meshPart, matrix, false, true, false, true, color);
                }
            }

            var outerClothingModel  = CharacterSkinsManager.GetOuterClothingModel(PlayerClass.Male);
            var absoluteTransforms2 = new Matrix[outerClothingModel.Bones.Count];

            outerClothingModel.CopyAbsoluteBoneTransformsTo(absoluteTransforms2);
            var index3 = outerClothingModel.FindBone("Leg1", true).Index;
            var index4 = outerClothingModel.FindBone("Leg2", true).Index;

            absoluteTransforms2[index3] = Matrix.CreateTranslation(-0.02f, 0.0f, 0.0f) * absoluteTransforms2[index3];
            absoluteTransforms2[index4] = Matrix.CreateTranslation(0.02f, 0.0f, 0.0f) * absoluteTransforms2[index4];
            m_outerMesh = new BlockMesh();
            foreach (var mesh in outerClothingModel.Meshes)
            {
                var matrix = absoluteTransforms2[mesh.ParentBone.Index];
                foreach (var meshPart in mesh.MeshParts)
                {
                    var color = Color.White * 0.8f;
                    color.A = byte.MaxValue;
                    m_outerMesh.AppendModelMeshPart(meshPart, matrix, false, false, false, false, Color.White);
                    m_outerMesh.AppendModelMeshPart(meshPart, matrix, false, true, false, true, color);
                }
            }

            base.Initialize();
        }
 public void UpdateRenderTargets()
 {
     if (m_skinTexture == null || m_componentPlayer.PlayerData.CharacterSkinName != m_skinTextureName)
     {
         m_skinTexture     = CharacterSkinsManager.LoadTexture(m_componentPlayer.PlayerData.CharacterSkinName);
         m_skinTextureName = m_componentPlayer.PlayerData.CharacterSkinName;
         Utilities.Dispose(ref m_innerClothedTexture);
         Utilities.Dispose(ref m_outerClothedTexture);
     }
     if (m_innerClothedTexture == null || m_innerClothedTexture.Width != m_skinTexture.Width || m_innerClothedTexture.Height != m_skinTexture.Height)
     {
         m_innerClothedTexture = new RenderTarget2D(m_skinTexture.Width, m_skinTexture.Height, 1, ColorFormat.Rgba8888, DepthFormat.None);
         m_componentHumanModel.TextureOverride = m_innerClothedTexture;
         m_clothedTexturesValid = false;
     }
     if (m_outerClothedTexture == null || m_outerClothedTexture.Width != m_skinTexture.Width || m_outerClothedTexture.Height != m_skinTexture.Height)
     {
         m_outerClothedTexture = new RenderTarget2D(m_skinTexture.Width, m_skinTexture.Height, 1, ColorFormat.Rgba8888, DepthFormat.None);
         m_componentOuterClothingModel.TextureOverride = m_outerClothedTexture;
         m_clothedTexturesValid = false;
     }
     if (DrawClothedTexture && !m_clothedTexturesValid)
     {
         m_clothedTexturesValid = true;
         Rectangle      scissorRectangle = Display.ScissorRectangle;
         RenderTarget2D renderTarget     = Display.RenderTarget;
         try
         {
             Display.RenderTarget = m_innerClothedTexture;
             Display.Clear(new Vector4(Color.Transparent));
             int             num             = 0;
             TexturedBatch2D texturedBatch2D = m_primitivesRenderer.TexturedBatch(m_skinTexture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp);
             texturedBatch2D.QueueQuad(Vector2.Zero, new Vector2(m_innerClothedTexture.Width, m_innerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, Color.White);
             ClothingSlot[] innerSlotsOrder = m_innerSlotsOrder;
             foreach (ClothingSlot slot in innerSlotsOrder)
             {
                 foreach (int clothe in GetClothes(slot))
                 {
                     int          data         = Terrain.ExtractData(clothe);
                     ClothingData clothingData = ClothingBlock.GetClothingData(data);
                     Color        fabricColor  = SubsystemPalette.GetFabricColor(m_subsystemTerrain, ClothingBlock.GetClothingColor(data));
                     texturedBatch2D = m_primitivesRenderer.TexturedBatch(clothingData.Texture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp);
                     if (!clothingData.IsOuter)
                     {
                         texturedBatch2D.QueueQuad(new Vector2(0f, 0f), new Vector2(m_innerClothedTexture.Width, m_innerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, fabricColor);
                     }
                 }
             }
             m_primitivesRenderer.Flush();
             Display.RenderTarget = m_outerClothedTexture;
             Display.Clear(new Vector4(Color.Transparent));
             num             = 0;
             innerSlotsOrder = m_outerSlotsOrder;
             foreach (ClothingSlot slot2 in innerSlotsOrder)
             {
                 foreach (int clothe2 in GetClothes(slot2))
                 {
                     int          data2         = Terrain.ExtractData(clothe2);
                     ClothingData clothingData2 = ClothingBlock.GetClothingData(data2);
                     Color        fabricColor2  = SubsystemPalette.GetFabricColor(m_subsystemTerrain, ClothingBlock.GetClothingColor(data2));
                     texturedBatch2D = m_primitivesRenderer.TexturedBatch(clothingData2.Texture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp);
                     if (clothingData2.IsOuter)
                     {
                         texturedBatch2D.QueueQuad(new Vector2(0f, 0f), new Vector2(m_outerClothedTexture.Width, m_outerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, fabricColor2);
                     }
                 }
             }
             m_primitivesRenderer.Flush();
         }
         finally
         {
             Display.RenderTarget     = renderTarget;
             Display.ScissorRectangle = scissorRectangle;
         }
     }
 }
 public void Update(float dt)
 {
     if (m_subsystemGameInfo.WorldSettings.GameMode != 0 && m_subsystemGameInfo.WorldSettings.AreAdventureSurvivalMechanicsEnabled && m_subsystemTime.PeriodicGameTimeEvent(0.5, 0.0))
     {
         foreach (int enumValue in EnumUtils.GetEnumValues(typeof(ClothingSlot)))
         {
             bool flag = false;
             m_clothesList.Clear();
             m_clothesList.AddRange(GetClothes((ClothingSlot)enumValue));
             int num = 0;
             while (num < m_clothesList.Count)
             {
                 int          value        = m_clothesList[num];
                 ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(value));
                 if ((float)clothingData.PlayerLevelRequired > m_componentPlayer.PlayerData.Level)
                 {
                     m_componentGui.DisplaySmallMessage(string.Format(LanguageControl.Get(fName, 1), clothingData.PlayerLevelRequired, clothingData.DisplayName), Color.White, blinking: true, playNotificationSound: true);
                     m_subsystemPickables.AddPickable(value, 1, m_componentBody.Position, null, null);
                     m_clothesList.RemoveAt(num);
                     flag = true;
                 }
                 else
                 {
                     num++;
                 }
             }
             if (flag)
             {
                 SetClothes((ClothingSlot)enumValue, m_clothesList);
             }
         }
     }
     if (m_subsystemGameInfo.WorldSettings.GameMode != 0 && m_subsystemGameInfo.WorldSettings.AreAdventureSurvivalMechanicsEnabled && m_subsystemTime.PeriodicGameTimeEvent(2.0, 0.0) && ((m_componentLocomotion.LastWalkOrder.HasValue && m_componentLocomotion.LastWalkOrder.Value != Vector2.Zero) || (m_componentLocomotion.LastSwimOrder.HasValue && m_componentLocomotion.LastSwimOrder.Value != Vector3.Zero) || m_componentLocomotion.LastJumpOrder != 0f))
     {
         if (m_lastTotalElapsedGameTime.HasValue)
         {
             foreach (int enumValue2 in EnumUtils.GetEnumValues(typeof(ClothingSlot)))
             {
                 bool flag2 = false;
                 m_clothesList.Clear();
                 m_clothesList.AddRange(GetClothes((ClothingSlot)enumValue2));
                 for (int i = 0; i < m_clothesList.Count; i++)
                 {
                     int          value2        = m_clothesList[i];
                     ClothingData clothingData2 = ClothingBlock.GetClothingData(Terrain.ExtractData(value2));
                     float        num2          = (m_componentVitalStats.Wetness > 0f) ? (10f * clothingData2.Sturdiness) : (20f * clothingData2.Sturdiness);
                     double       num3          = MathUtils.Floor(m_lastTotalElapsedGameTime.Value / (double)num2);
                     if (MathUtils.Floor(m_subsystemGameInfo.TotalElapsedGameTime / (double)num2) > num3 && m_random.Float(0f, 1f) < 0.75f)
                     {
                         m_clothesList[i] = BlocksManager.DamageItem(value2, 1);
                         flag2            = true;
                     }
                 }
                 int num4 = 0;
                 while (num4 < m_clothesList.Count)
                 {
                     if (Terrain.ExtractContents(m_clothesList[num4]) != 203)
                     {
                         m_clothesList.RemoveAt(num4);
                         m_subsystemParticles.AddParticleSystem(new BlockDebrisParticleSystem(m_subsystemTerrain, m_componentBody.Position + m_componentBody.BoxSize / 2f, 1f, 1f, Color.White, 0));
                         m_componentGui.DisplaySmallMessage(LanguageControl.Get(fName, 2), Color.White, blinking: true, playNotificationSound: true);
                     }
                     else
                     {
                         num4++;
                     }
                 }
                 if (flag2)
                 {
                     SetClothes((ClothingSlot)enumValue2, m_clothesList);
                 }
             }
         }
         m_lastTotalElapsedGameTime = m_subsystemGameInfo.TotalElapsedGameTime;
     }
     UpdateRenderTargets();
 }
 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)
             {
                 ClothingData clothingData = ClothingBlock.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))
         {
             ClothingData clothingData2 = ClothingBlock.GetClothingData(Terrain.ExtractData(clothe2));
             num3 += clothingData2.Insulation;
             SteedMovementSpeedFactor *= clothingData2.SteedMovementSpeedFactor;
         }
         foreach (int clothe3 in GetClothes(ClothingSlot.Torso))
         {
             ClothingData clothingData3 = ClothingBlock.GetClothingData(Terrain.ExtractData(clothe3));
             num4 += clothingData3.Insulation;
             SteedMovementSpeedFactor *= clothingData3.SteedMovementSpeedFactor;
         }
         foreach (int clothe4 in GetClothes(ClothingSlot.Legs))
         {
             ClothingData clothingData4 = ClothingBlock.GetClothingData(Terrain.ExtractData(clothe4));
             num5 += clothingData4.Insulation;
             SteedMovementSpeedFactor *= clothingData4.SteedMovementSpeedFactor;
         }
         foreach (int clothe5 in GetClothes(ClothingSlot.Feet))
         {
             ClothingData clothingData5 = ClothingBlock.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;
         }
     }
 }
Example #13
0
        public Dictionary <string, string> GetBlockProperties(int value)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            int   num   = Terrain.ExtractContents(value);
            Block block = BlocksManager.Blocks[num];

            if (block.DefaultEmittedLightAmount > 0)
            {
                dictionary.Add(LanguageControl.Get(fName, 1), block.DefaultEmittedLightAmount.ToString());
            }
            if (block.FuelFireDuration > 0f)
            {
                dictionary.Add(LanguageControl.Get(fName, 2), block.FuelFireDuration.ToString());
            }
            dictionary.Add(LanguageControl.Get(fName, 3), (block.MaxStacking > 1) ? string.Format(LanguageControl.Get(fName, 4), block.MaxStacking.ToString()) : LanguageControl.Get("Usual", "no"));
            dictionary.Add(LanguageControl.Get(fName, 5), (block.FireDuration > 0f) ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no"));
            if (block.GetNutritionalValue(value) > 0f)
            {
                dictionary.Add(LanguageControl.Get(fName, 6), block.GetNutritionalValue(value).ToString());
            }
            if (block.GetRotPeriod(value) > 0)
            {
                dictionary.Add(LanguageControl.Get(fName, 7), string.Format(LanguageControl.Get(fName, 25), $"{(2 * block.GetRotPeriod(value) * 60f / 1200f):0.0}"));
            }
            if (block.DigMethod != 0)
            {
                dictionary.Add(LanguageControl.Get(fName, 8), LanguageControl.Get("DigMethod", block.DigMethod.ToString()));
                dictionary.Add(LanguageControl.Get(fName, 9), block.DigResilience.ToString());
            }
            if (block.ExplosionResilience > 0f)
            {
                dictionary.Add(LanguageControl.Get(fName, 10), block.ExplosionResilience.ToString());
            }
            if (block.GetExplosionPressure(value) > 0f)
            {
                dictionary.Add(LanguageControl.Get(fName, 11), block.GetExplosionPressure(value).ToString());
            }
            bool flag = false;

            if (block.GetMeleePower(value) > 1f)
            {
                dictionary.Add(LanguageControl.Get(fName, 12), block.GetMeleePower(value).ToString());
                flag = true;
            }
            if (block.GetMeleePower(value) > 1f)
            {
                dictionary.Add(LanguageControl.Get(fName, 13), $"{100f * block.GetMeleeHitProbability(value):0}%");
                flag = true;
            }
            if (block.GetProjectilePower(value) > 1f)
            {
                dictionary.Add(LanguageControl.Get(fName, 14), block.GetProjectilePower(value).ToString());
                flag = true;
            }
            if (block.ShovelPower > 1f)
            {
                dictionary.Add(LanguageControl.Get(fName, 15), block.ShovelPower.ToString());
                flag = true;
            }
            if (block.HackPower > 1f)
            {
                dictionary.Add(LanguageControl.Get(fName, 16), block.HackPower.ToString());
                flag = true;
            }
            if (block.QuarryPower > 1f)
            {
                dictionary.Add(LanguageControl.Get(fName, 17), block.QuarryPower.ToString());
                flag = true;
            }
            if (flag && block.Durability > 0)
            {
                dictionary.Add(LanguageControl.Get(fName, 18), block.Durability.ToString());
            }
            if (block.DefaultExperienceCount > 0f)
            {
                dictionary.Add(LanguageControl.Get(fName, 19), block.DefaultExperienceCount.ToString());
            }
            if (block is ClothingBlock)
            {
                ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(value));
                dictionary.Add(LanguageControl.Get(fName, 20), clothingData.CanBeDyed ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no"));
                dictionary.Add(LanguageControl.Get(fName, 21), $"{(int)(clothingData.ArmorProtection * 100f)}%");
                dictionary.Add(LanguageControl.Get(fName, 22), clothingData.Sturdiness.ToString());
                dictionary.Add(LanguageControl.Get(fName, 23), $"{clothingData.Insulation:0.0} clo");
                dictionary.Add(LanguageControl.Get(fName, 24), $"{clothingData.MovementSpeedFactor * 100f:0}%");
            }
            return(dictionary);
        }