Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.ankamagames.dofus.network.messages.game.context
  2. {
  3.    import com.ankamagames.jerakine.network.CustomDataWrapper;
  4.    import com.ankamagames.jerakine.network.ICustomDataInput;
  5.    import com.ankamagames.jerakine.network.ICustomDataOutput;
  6.    import com.ankamagames.jerakine.network.INetworkMessage;
  7.    import com.ankamagames.jerakine.network.NetworkMessage;
  8.    import com.ankamagames.jerakine.network.utils.FuncTree;
  9.    import flash.utils.ByteArray;
  10.    
  11.    public class GameMapMovementMessage extends NetworkMessage implements INetworkMessage
  12.    {
  13.      
  14.       public static const protocolId:uint = 951;
  15.        
  16.      
  17.       private var _isInitialized:Boolean = false;
  18.      
  19.       public var keyMovements:Vector.<uint>;
  20.      
  21.       public var forcedDirection:int = 0;
  22.      
  23.       public var actorId:Number = 0;
  24.      
  25.       private var _keyMovementstree:FuncTree;
  26.      
  27.       public function GameMapMovementMessage()
  28.       {
  29.          this.keyMovements = new Vector.<uint>();
  30.          super();
  31.       }
  32.      
  33.       override public function get isInitialized() : Boolean
  34.       {
  35.          return this._isInitialized;
  36.       }
  37.      
  38.       override public function getMessageId() : uint
  39.       {
  40.          return 951;
  41.       }
  42.      
  43.       public function initGameMapMovementMessage(keyMovements:Vector.<uint> = null, forcedDirection:int = 0, actorId:Number = 0) : GameMapMovementMessage
  44.       {
  45.          this.keyMovements = keyMovements;
  46.          this.forcedDirection = forcedDirection;
  47.          this.actorId = actorId;
  48.          this._isInitialized = true;
  49.          return this;
  50.       }
  51.      
  52.       override public function reset() : void
  53.       {
  54.          this.keyMovements = new Vector.<uint>();
  55.          this.forcedDirection = 0;
  56.          this.actorId = 0;
  57.          this._isInitialized = false;
  58.       }
  59.      
  60.       override public function pack(output:ICustomDataOutput) : void
  61.       {
  62.          var data:ByteArray = new ByteArray();
  63.          this.serialize(new CustomDataWrapper(data));
  64.          writePacket(output,this.getMessageId(),data);
  65.       }
  66.      
  67.       override public function unpack(input:ICustomDataInput, length:uint) : void
  68.       {
  69.          this.deserialize(input);
  70.       }
  71.      
  72.       override public function unpackAsync(input:ICustomDataInput, length:uint) : FuncTree
  73.       {
  74.          var tree:FuncTree = new FuncTree();
  75.          tree.setRoot(input);
  76.          this.deserializeAsync(tree);
  77.          return tree;
  78.       }
  79.      
  80.       public function serialize(output:ICustomDataOutput) : void
  81.       {
  82.          this.serializeAs_GameMapMovementMessage(output);
  83.       }
  84.      
  85.       public function serializeAs_GameMapMovementMessage(output:ICustomDataOutput) : void
  86.       {
  87.          output.writeShort(this.keyMovements.length);
  88.          for(var _i1:uint = 0; _i1 < this.keyMovements.length; _i1++)
  89.          {
  90.             if(this.keyMovements[_i1] < 0)
  91.             {
  92.                throw new Error("Forbidden value (" + this.keyMovements[_i1] + ") on element 1 (starting at 1) of keyMovements.");
  93.             }
  94.             output.writeShort(this.keyMovements[_i1]);
  95.          }
  96.          output.writeShort(this.forcedDirection);
  97.          if(this.actorId < -9007199254740990 || this.actorId > 9007199254740990)
  98.          {
  99.             throw new Error("Forbidden value (" + this.actorId + ") on element actorId.");
  100.          }
  101.          output.writeDouble(this.actorId);
  102.       }
  103.      
  104.       public function deserialize(input:ICustomDataInput) : void
  105.       {
  106.          this.deserializeAs_GameMapMovementMessage(input);
  107.       }
  108.      
  109.       public function deserializeAs_GameMapMovementMessage(input:ICustomDataInput) : void
  110.       {
  111.          var _val1:uint = 0;
  112.          var _keyMovementsLen:uint = input.readUnsignedShort();
  113.          for(var _i1:uint = 0; _i1 < _keyMovementsLen; _i1++)
  114.          {
  115.             _val1 = input.readShort();
  116.             if(_val1 < 0)
  117.             {
  118.                throw new Error("Forbidden value (" + _val1 + ") on elements of keyMovements.");
  119.             }
  120.             this.keyMovements.push(_val1);
  121.          }
  122.          this._forcedDirectionFunc(input);
  123.          this._actorIdFunc(input);
  124.       }
  125.      
  126.       public function deserializeAsync(tree:FuncTree) : void
  127.       {
  128.          this.deserializeAsyncAs_GameMapMovementMessage(tree);
  129.       }
  130.      
  131.       public function deserializeAsyncAs_GameMapMovementMessage(tree:FuncTree) : void
  132.       {
  133.          this._keyMovementstree = tree.addChild(this._keyMovementstreeFunc);
  134.          tree.addChild(this._forcedDirectionFunc);
  135.          tree.addChild(this._actorIdFunc);
  136.       }
  137.      
  138.       private function _keyMovementstreeFunc(input:ICustomDataInput) : void
  139.       {
  140.          var length:uint = input.readUnsignedShort();
  141.          for(var i:uint = 0; i < length; i++)
  142.          {
  143.             this._keyMovementstree.addChild(this._keyMovementsFunc);
  144.          }
  145.       }
  146.      
  147.       private function _keyMovementsFunc(input:ICustomDataInput) : void
  148.       {
  149.          var _val:uint = input.readShort();
  150.          if(_val < 0)
  151.          {
  152.             throw new Error("Forbidden value (" + _val + ") on elements of keyMovements.");
  153.          }
  154.          this.keyMovements.push(_val);
  155.       }
  156.      
  157.       private function _forcedDirectionFunc(input:ICustomDataInput) : void
  158.       {
  159.          this.forcedDirection = input.readShort();
  160.       }
  161.      
  162.       private function _actorIdFunc(input:ICustomDataInput) : void
  163.       {
  164.          this.actorId = input.readDouble();
  165.          if(this.actorId < -9007199254740990 || this.actorId > 9007199254740990)
  166.          {
  167.             throw new Error("Forbidden value (" + this.actorId + ") on element of GameMapMovementMessage.actorId.");
  168.          }
  169.       }
  170.    }
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement