intToBitsString() public static méthode

public static intToBitsString ( int n, int bitsSize ) : string
n int
bitsSize int
Résultat string
Exemple #1
0
        public static byte[] getRSIBytes(int[] rsiValues)
        {
            Hashtable rsiTable = new Hashtable();

            string[] keys = { "sex", "body", "hat", "face", "shirt", "coat", "pants", "shoes", "gloves", "glasses", "hair", "facialdetail", "shirtcolor", "pantscolor", "coatcolor", "shoecolor", "glassescolor", "haircolor", "skintone", "tattoo", "facialdetailcolor", "leggins" };

            for (int i = 0; i < keys.Length; i++)
            {
                rsiTable[keys[i]] = rsiValues[i];
            }

            /* ORDER:
             * sex body	hat face shirt coat	pants shoes	gloves glasses
             * hair	facialdetail shirtcolor pantscolor coatcolor shoecolor
             * glassescolor haircolor skintone tatto facialdetailcolor leggins */

            string unknown1 = "0";
            string unknown2 = "00";

            string binaryRSI = "";

            // Common part

            binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["sex"], 1);
            binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["body"], 2);
            binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["hat"], 6);
            binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["face"], 5);
            binaryRSI += unknown1;
            binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["shirt"], 5);


            if (rsiValues[0] == 0)           // Male part
            {
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["coat"], 6);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["pants"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["shoes"], 6);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["gloves"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["glasses"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["hair"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["facialdetail"], 4);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["shirtcolor"], 6);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["pantscolor"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["coatcolor"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["shoecolor"], 4);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["glassescolor"], 4);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["haircolor"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["skintone"], 5);
                binaryRSI += unknown2;
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["tattoo"], 3);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["facialdetailcolor"], 3);
                binaryRSI += "000000";
            }
            else             // Female part
            {
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["coat"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["pants"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["shoes"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["gloves"], 6);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["glasses"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["hair"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["leggins"], 4);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["facialdetail"], 4);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["shirtcolor"], 6);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["pantscolor"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["coatcolor"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["shoecolor"], 4);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["glassescolor"], 4);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["haircolor"], 5);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["skintone"], 5);
                binaryRSI += unknown2;
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["tattoo"], 3);
                binaryRSI += NumericalUtils.intToBitsString((int)rsiTable["facialdetailcolor"], 3);
                binaryRSI += "000";
            }


            return(NumericalUtils.bigBinaryStringToBytes(binaryRSI));
        }