Beispiel #1
0
 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, 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, 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);
                     MekClothData clothingData = MekClothingBlock.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;
         }
     }
 }
    private void UpdateList()
    {
        WorldsManager.UpdateWorldsList();
        List <ListItem> list = new List <ListItem>();

        if (m_filter == ExternalContentType.BlocksTexture || m_filter == ExternalContentType.Unknown)
        {
            BlocksTexturesManager.UpdateBlocksTexturesList();
            foreach (string name2 in BlocksTexturesManager.BlockTexturesNames)
            {
                list.Add(new ListItem
                {
                    Name         = name2,
                    IsBuiltIn    = BlocksTexturesManager.IsBuiltIn(name2),
                    Type         = ExternalContentType.BlocksTexture,
                    DisplayName  = BlocksTexturesManager.GetDisplayName(name2),
                    CreationTime = BlocksTexturesManager.GetCreationDate(name2),
                    UseCount     = WorldsManager.WorldInfos.Count((WorldInfo wi) => wi.WorldSettings.BlocksTextureName == name2)
                });
            }
        }
        if (m_filter == ExternalContentType.CharacterSkin || m_filter == ExternalContentType.Unknown)
        {
            CharacterSkinsManager.UpdateCharacterSkinsList();
            foreach (string name in CharacterSkinsManager.CharacterSkinsNames)
            {
                list.Add(new ListItem
                {
                    Name         = name,
                    IsBuiltIn    = CharacterSkinsManager.IsBuiltIn(name),
                    Type         = ExternalContentType.CharacterSkin,
                    DisplayName  = CharacterSkinsManager.GetDisplayName(name),
                    CreationTime = CharacterSkinsManager.GetCreationDate(name),
                    UseCount     = WorldsManager.WorldInfos.Count((WorldInfo wi) => wi.PlayerInfos.Any((PlayerInfo pi) => pi.CharacterSkinName == name))
                });
            }
        }
        if (m_filter == ExternalContentType.FurniturePack || m_filter == ExternalContentType.Unknown)
        {
            FurniturePacksManager.UpdateFurniturePacksList();
            foreach (string furniturePackName in FurniturePacksManager.FurniturePackNames)
            {
                list.Add(new ListItem
                {
                    Name         = furniturePackName,
                    IsBuiltIn    = false,
                    Type         = ExternalContentType.FurniturePack,
                    DisplayName  = FurniturePacksManager.GetDisplayName(furniturePackName),
                    CreationTime = FurniturePacksManager.GetCreationDate(furniturePackName)
                });
            }
        }
        list.Sort(delegate(ListItem o1, ListItem o2)
        {
            if (o1.IsBuiltIn && !o2.IsBuiltIn)
            {
                return(-1);
            }
            if (o2.IsBuiltIn && !o1.IsBuiltIn)
            {
                return(1);
            }
            if (string.IsNullOrEmpty(o1.Name) && !string.IsNullOrEmpty(o2.Name))
            {
                return(-1);
            }
            return((!string.IsNullOrEmpty(o1.Name) && string.IsNullOrEmpty(o2.Name)) ? 1 : string.Compare(o1.DisplayName, o2.DisplayName));
        });
        m_contentList.ClearItems();
        foreach (ListItem item in list)
        {
            m_contentList.AddItem(item);
        }
    }
Beispiel #3
0
        public override void Initialize()
        {
            int num = 0;
            Dictionary <int, MekClothData> dictionary = new Dictionary <int, MekClothData>();
            IEnumerator <XElement>         enumerator = XmlUtils.LoadXmlFromStream(ModsManager.GetEntries(".xclo")[0].Stream, Encoding.UTF8, true).Elements().GetEnumerator();

            while (enumerator.MoveNext())
            {
                XElement     current      = enumerator.Current;
                MekClothData clothingData = new MekClothData
                {
                    Index                    = XmlUtils.GetAttributeValue <int>(current, "Index"),
                    DisplayIndex             = num++,
                    DisplayName              = XmlUtils.GetAttributeValue <string>(current, "DisplayName"),
                    Slot                     = XmlUtils.GetAttributeValue <ClothingSlot>(current, "Slot"),
                    ArmorProtection          = XmlUtils.GetAttributeValue <float>(current, "ArmorProtection"),
                    Sturdiness               = XmlUtils.GetAttributeValue <float>(current, "Sturdiness"),
                    Insulation               = XmlUtils.GetAttributeValue <float>(current, "Insulation"),
                    MovementSpeedFactor      = XmlUtils.GetAttributeValue <float>(current, "MovementSpeedFactor"),
                    SteedMovementSpeedFactor = XmlUtils.GetAttributeValue <float>(current, "SteedMovementSpeedFactor"),
                    DensityModifier          = XmlUtils.GetAttributeValue <float>(current, "DensityModifier"),
                    IsOuter                  = XmlUtils.GetAttributeValue <bool>(current, "IsOuter"),
                    CanBeDyed                = XmlUtils.GetAttributeValue <bool>(current, "CanBeDyed"),
                    Layer                    = XmlUtils.GetAttributeValue <int>(current, "Layer"),
                    PlayerLevelRequired      = XmlUtils.GetAttributeValue <int>(current, "PlayerLevelRequired"),
                    Texture                  = ContentManager.Get <Texture2D>(XmlUtils.GetAttributeValue <string>(current, "TextureName")),
                    ImpactSoundsFolder       = XmlUtils.GetAttributeValue <string>(current, "ImpactSoundsFolder"),
                    Description              = XmlUtils.GetAttributeValue <string>(current, "Description")
                };
                dictionary[clothingData.Index] = clothingData;
            }
            clothingData = new MekClothData[dictionary.Count];
            int i = 0;

            foreach (KeyValuePair <int, MekClothData> keyValuePair in dictionary)
            {
                clothingData[i] = keyValuePair.Value;
                ++i;
            }
            Model playerModel = CharacterSkinsManager.GetPlayerModel(PlayerClass.Male);

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

            array[i]     = Matrix.CreateRotationY(0.1f) * array[i];
            array[index] = Matrix.CreateRotationY(-0.1f) * array[index];
            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 index2 = outerClothingModel.FindBone("Leg1").Index;
            int index3 = outerClothingModel.FindBone("Leg2").Index;

            array2[index2] = Matrix.CreateTranslation(-0.02f, 0f, 0f) * array2[index2];
            array2[index3] = Matrix.CreateTranslation(0.02f, 0f, 0f) * array2[index3];
            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);
                }
            }
        }