Example #1
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();
        }
Example #2
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 #3
0
 public override void MeasureOverride(Vector2 parentAvailableSize)
 {
     if (OuterClothing)
     {
         m_modelWidget.Model = CharacterSkinsManager.GetOuterClothingModel(PlayerClass);
     }
     else
     {
         m_modelWidget.Model = CharacterSkinsManager.GetPlayerModel(PlayerClass);
     }
     if (CameraShot == Shot.Body)
     {
         m_modelWidget.ViewPosition = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 1.46f, -3.2f) : new Vector3(0f, 1.39f, -3.04f));
         m_modelWidget.ViewTarget   = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 0.9f, 0f) : new Vector3(0f, 0.86f, 0f));
         m_modelWidget.ViewFov      = 0.57f;
     }
     else
     {
         if (CameraShot != Shot.Bust)
         {
             throw new InvalidOperationException("Unknown shot.");
         }
         m_modelWidget.ViewPosition = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 1.5f, -1.05f) : new Vector3(0f, 1.43f, -1f));
         m_modelWidget.ViewTarget   = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 1.5f, 0f) : new Vector3(0f, 1.43f, 0f));
         m_modelWidget.ViewFov      = 0.57f;
     }
     if (OuterClothing)
     {
         m_modelWidget.TextureOverride = OuterClothingTexture;
     }
     else
     {
         m_modelWidget.TextureOverride = ((CharacterSkinName != null) ? CharacterSkinsCache.GetTexture(CharacterSkinName) : CharacterSkinTexture);
     }
     if (AnimateHeadSeed != 0)
     {
         int     num    = (AnimateHeadSeed < 0) ? GetHashCode() : AnimateHeadSeed;
         float   num2   = (float)MathUtils.Remainder(Time.FrameStartTime + 1000.0 * (double)num, 10000.0);
         Vector2 vector = default(Vector2);
         vector.X = MathUtils.Lerp(-0.75f, 0.75f, SimplexNoise.OctavedNoise(num2 + 100f, 0.2f, 1, 2f, 0.5f));
         vector.Y = MathUtils.Lerp(-0.5f, 0.5f, SimplexNoise.OctavedNoise(num2 + 200f, 0.17f, 1, 2f, 0.5f));
         Matrix value = Matrix.CreateRotationX(vector.Y) * Matrix.CreateRotationZ(vector.X);
         m_modelWidget.SetBoneTransform(m_modelWidget.Model.FindBone("Head").Index, value);
     }
     if (!OuterClothing && AnimateHandsSeed != 0)
     {
         int     num3    = (AnimateHandsSeed < 0) ? GetHashCode() : AnimateHandsSeed;
         float   num4    = (float)MathUtils.Remainder(Time.FrameStartTime + 1000.0 * (double)num3, 10000.0);
         Vector2 vector2 = default(Vector2);
         vector2.X = MathUtils.Lerp(0.2f, 0f, SimplexNoise.OctavedNoise(num4 + 100f, 0.7f, 1, 2f, 0.5f));
         vector2.Y = MathUtils.Lerp(-0.3f, 0.3f, SimplexNoise.OctavedNoise(num4 + 200f, 0.7f, 1, 2f, 0.5f));
         Vector2 vector3 = default(Vector2);
         vector3.X = MathUtils.Lerp(-0.2f, 0f, SimplexNoise.OctavedNoise(num4 + 300f, 0.7f, 1, 2f, 0.5f));
         vector3.Y = MathUtils.Lerp(-0.3f, 0.3f, SimplexNoise.OctavedNoise(num4 + 400f, 0.7f, 1, 2f, 0.5f));
         Matrix value2 = Matrix.CreateRotationX(vector2.Y) * Matrix.CreateRotationY(vector2.X);
         Matrix value3 = Matrix.CreateRotationX(vector3.Y) * Matrix.CreateRotationY(vector3.X);
         m_modelWidget.SetBoneTransform(m_modelWidget.Model.FindBone("Hand1").Index, value2);
         m_modelWidget.SetBoneTransform(m_modelWidget.Model.FindBone("Hand2").Index, value3);
     }
     base.MeasureOverride(parentAvailableSize);
 }