public MultiplayerTexture(bool custom, string path, string texType, GearInfoType gearType, StreamWriter sw)
 {
     this.path        = path;
     this.isCustom    = custom;
     this.debugWriter = sw;
     this.textureType = texType;
     this.infoType    = gearType;
 }
Example #2
0
        public void ParseTextureStream(byte[] inTextureStream)
        {
            ushort currentMessage = BitConverter.ToUInt16(inTextureStream, 0);
            ushort totalMessages  = BitConverter.ToUInt16(inTextureStream, 2);

            for (int i = 4; i < inTextureStream.Length; i++)
            {
                gearStream.Add(inTextureStream[i]);
            }

            this.debugWriter.WriteLine($"Texture {currentMessage}/{totalMessages}");

            if (currentMessage != totalMessages)
            {
                return;
            }
            this.debugWriter.WriteLine($"Finished Texture loading");

            byte[] textureStream = gearStream.ToArray();

            ushort bodyTypeLen = BitConverter.ToUInt16(textureStream, 0);

            this.bodyType = Encoding.UTF8.GetString(textureStream, 2, bodyTypeLen);

            UnityModManagerNet.UnityModManager.Logger.Log($"Attempting to equip body with name length {bodyTypeLen} and name: {bodyType}!");

            CharacterBodyInfo bodyInfo = new CharacterBodyInfo("MP Temp body", this.bodyType, false, null, new string[0]);

            characterCustomizer.EquipGear(bodyInfo);

            int readBytes = 2 + bodyTypeLen;

            while (readBytes < textureStream.Length - 1)
            {
                UnityModManagerNet.UnityModManager.Logger.Log($"Read {readBytes} bytes of {textureStream.Length}");
                bool         customTex   = textureStream[readBytes] == 1 ? true : false;
                GearInfoType texInfotype = (GearInfoType)textureStream[readBytes + 1];

                readBytes += 2;
                if (customTex)
                {
                    ushort typeLen = BitConverter.ToUInt16(textureStream, readBytes);
                    int    dataLen = BitConverter.ToInt32(textureStream, readBytes + 2);

                    string texType = Encoding.UTF8.GetString(textureStream, readBytes + 6, typeLen);
                    readBytes += 6 + typeLen;

                    byte[] texData = new byte[dataLen];
                    Array.Copy(textureStream, readBytes, texData, 0, dataLen);
                    readBytes += dataLen;

                    MultiplayerRemoteTexture newTexture = new MultiplayerRemoteTexture(customTex, "", texType, texInfotype, this.debugWriter);
                    multiplayerTextures.Add(newTexture);
                    newTexture.SaveTexture(this.playerID, texData);
                }
            }
        }
        public void SetPlayerTexture(string path, string texType, GearInfoType infoType, bool useFull)
        {
            TextureChange texChange = new TextureChange("albedo", path);
            GearInfo      newInfo;

            if (infoType == GearInfoType.Board)
            {
                newInfo = new BoardGearInfo("MP Temp " + texType.ToString(), texType, true, new TextureChange[] { texChange }, new string[0]);
            }
            else
            {
                newInfo = new CharacterGearInfo("MP Temp " + texType.ToString(), texType, true, new TextureChange[] { texChange }, new string[0]);
            }

            characterCustomizer.EquipGear(newInfo);
        }
 public MultiplayerLocalTexture(bool custom, string path, string texType, GearInfoType gearType, StreamWriter sw) : base(custom, path, texType, gearType, sw)
 {
 }