Advertisement
Standev

Untitled

Oct 11th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 4.27 KB | None | 0 0
  1.     /**
  2.      * This methods decodes the argued [buffer] and stores the details in this [ItemTemplate].
  3.      * The decode used to interpret the [buffer] is determined by the specified [revision].
  4.      *
  5.      * @param buffer the [Buffer] containing the animation details.
  6.      */
  7.     override fun decode(buffer: Buffer) {
  8.         while (true) {
  9.             val attributeId = buffer.unsignedByte
  10.  
  11.             if (attributeId == 0)
  12.                 break
  13.             when (attributeId) {
  14.                 1 -> modelID     = buffer.unsignedShort
  15.                 2 -> name        = buffer.string
  16.                 3 -> description = buffer.bytes!!.contentToString()
  17.                 4 -> zoom2d      = buffer.unsignedShort
  18.                 5 -> rotationX   = buffer.unsignedShort
  19.                 6 -> rotationY   = buffer.unsignedShort
  20.                 7 -> {
  21.                     offsetX2d = buffer.unsignedShort
  22.                     if (offsetX2d > 32767) offsetX2d -= 65536
  23.                 }
  24.                 8 -> {
  25.                     offsetY2d = buffer.unsignedShort
  26.                     if (offsetY2d > 32767) offsetY2d -= 65536
  27.                 }
  28.                 10 -> buffer.unsignedShort
  29.                 11 -> stackable  = true
  30.                 12 -> value      = buffer.int
  31.                 16 -> membersOnly= true
  32.                 23 -> {
  33.                     maleEquipPrimaryModel       = buffer.unsignedShort
  34.                     maleEquipOffset             = buffer.signedByte
  35.                 }
  36.                 24 -> maleEquipSecondaryModel   = buffer.unsignedShort
  37.                 25 -> {
  38.                     femaleEquipPrimaryModel     = buffer.unsignedShort
  39.                     femaleEquipOffset           = buffer.signedByte
  40.                 }
  41.                 26 -> femaleEquipSecondaryModel = buffer.unsignedShort
  42.                 in 30..34 -> {
  43.                     if(groundActions.isEmpty())
  44.                         groundActions = arrayOfNulls(5)
  45.                     groundActions[attributeId - 30] = buffer.string
  46.                     if (groundActions[attributeId - 30].equals("hidden", ignoreCase = true))
  47.                         groundActions[attributeId - 30] = ""
  48.                 }
  49.                 in 35..39 -> {
  50.                     if(inventoryActions.isEmpty())
  51.                         inventoryActions = arrayOfNulls(5)
  52.                     inventoryActions[attributeId - 35] = buffer.string
  53.                 }
  54.                 40 -> {
  55.                     val modelColorCount = buffer.unsignedByte
  56.                     modelColorsOriginal = IntArray(modelColorCount).toTypedArray()
  57.                     modelColorsModified = IntArray(modelColorCount).toTypedArray()
  58.                     for (modelColor in 0 until modelColorCount) {
  59.                         modelColorsOriginal[modelColor] = buffer.unsignedShort
  60.                         modelColorsModified[modelColor] = buffer.unsignedShort
  61.                     }
  62.                 }
  63.                 78 -> maleEmblem     = buffer.unsignedShort
  64.                 79 -> femaleEmblem   = buffer.unsignedShort
  65.                 90 -> maleDialogue   = buffer.unsignedShort
  66.                 91 -> femaleDialogue = buffer.unsignedShort
  67.                 92 -> maleDialogueHat    = buffer.unsignedShort
  68.                 93 -> femaleDialogueHat  = buffer.unsignedShort
  69.                 95 -> diagonalRotation   = buffer.unsignedShort
  70.                 97 -> noteID         = buffer.unsignedShort
  71.                 98 -> noteTemplateID = buffer.unsignedShort
  72.                 in 100..109 -> {
  73.                     if(!this::stackableIds.isInitialized || stackableIds.isEmpty()){
  74.                         stackableIds = IntArray(10)
  75.                         stackableAmounts = IntArray(10)
  76.                     }
  77.                     stackableIds[attributeId - 100] = buffer.unsignedShort
  78.                     stackableAmounts[attributeId - 100] = buffer.unsignedShort
  79.                 }
  80.                 110 -> modelSizeX = buffer.unsignedShort
  81.                 111 -> modelSizeY = buffer.unsignedShort
  82.                 112 -> modelSizeZ = buffer.unsignedShort
  83.                 113 -> lightModifier = buffer.signedByte.toInt()
  84.                 114 -> shadowModifier = buffer.signedByte * 5
  85.                 115 -> teamID = buffer.unsignedByte
  86.             }
  87.         }
  88.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement