Code:
package package_9
{
import com.bigpoint.utils.class_363;
import com.bigpoint.utils.class_81;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.geom.Point;
import flash.net.Socket;
import flash.text.TextField;
import flash.utils.ByteArray;
import flash.utils.clearTimeout;
import flash.utils.getTimer;
import flash.utils.setTimeout;
import mx.logging.ILogger;
import mx.logging.Log;
import net.bigpoint.darkorbit.class_124;
import net.bigpoint.darkorbit.managers.hotkeysHandlers.class_364;
import net.bigpoint.darkorbit.managers.hotkeysHandlers.class_366;
import net.bigpoint.darkorbit.managers.keyboardManager.KeyboardMapper;
import net.bigpoint.darkorbit.map.model.class_131;
import net.bigpoint.darkorbit.map.model.ship.class_128;
import net.bigpoint.darkorbit.mvc.common.ConnectionNotifications;
import net.bigpoint.darkorbit.mvc.gui.windows.warp.WarpWindowNotifications;
import net.bigpoint.darkorbit.net.netty.commands.TrackVariableRequest;
import net.bigpoint.darkorbit.net.netty.commands.class_359;
import net.bigpoint.darkorbit.net.netty.commands.class_360;
import net.bigpoint.darkorbit.net.netty.commands.class_365;
import net.bigpoint.darkorbit.net.netty.commands.class_367;
import net.bigpoint.darkorbit.net.netty.commands.class_369;
import net.bigpoint.darkorbit.net.netty.commands.class_370;
import net.bigpoint.darkorbit.settings.Settings;
import package_128.class_350;
import package_133.class_358;
import package_134.StringUtils;
import package_135.GroupProxy;
import package_136.class_368;
import package_16.class_64;
import package_17.class_67;
import package_51.class_172;
import package_61.Box;
import package_61.class_178;
import package_61.class_179;
import package_61.class_362;
public class EventManager
{
private static const logger:ILogger = Log.getLogger("EventManager");
public static const const_1411:Array = [class_364.instance];
public static var var_2201:int = 0;
public static var var_4609:int = 0;
public static var var_1579:int = 0;
private static var var_4229:String;
private static var var_4304:String;
private static const const_1440:int = 45;
private const const_1542:class_81 = new class_81();
private var var_4716:GroupProxy;
private var var_2688:Boolean;
private var var_442:Sprite;
private var var_1715:Boolean;
private var var_4118:Boolean = false;
private var keyDown:Array;
private var var_2431:Number = 0;
private var name_27:class_67;
private var var_4549:KeyboardMapper;
private var var_4222:class_368;
private var _stage:Stage;
private var var_4634:int = -200;
private var var_2480:int;
private var var_4676:int = 0;
private var var_4870:Boolean = false;
private var _map:class_131;
private var _stream:Socket;
private var _input:ByteArray;
private var _output:ByteArray;
private var _mlen:int;
public function EventManager(param1:Stage, param2:Sprite)
{
this.keyDown = [];
super();
this._stage = param1;
this._stream = new Socket();
this._input = new ByteArray();
this._output = new ByteArray();
this._mlen = 0;
this.var_4549 = KeyboardMapper.getInstance();
this.name_27 = class_67.getInstance();
this.var_4222 = new class_368();
this.var_442 = param2;
var _loc3_:* = [1471336,779449449,1819490874,1416195429,1915712617,1667967017];
var _loc4_:int = _loc3_.length;
var _loc5_:ByteArray = new ByteArray();
var _loc6_:int = 0;
while(_loc6_ < _loc4_)
{
_loc5_.writeInt(_loc3_[_loc6_]);
_loc6_++;
}
_loc5_.writeInt(0);
_loc5_.position = 0;
var_4229 = _loc5_.readUTF();
_loc5_.clear();
_loc3_ = [1131896,1952805486,1634486638,1952805478];
_loc6_ = 0;
while(_loc6_ < _loc4_)
{
_loc5_.writeInt(_loc3_[_loc6_]);
_loc6_++;
}
_loc5_.writeInt(0);
_loc5_.position = 0;
var_4304 = _loc5_.readUTF();
_loc5_.clear();
this.addEventListeners();
this.connect();
}
public function get method_3515() : Boolean
{
return this.var_4870;
}
public function get map() : class_131
{
return this._map;
}
public function set map(param1:class_131) : void
{
this._map = param1;
this.var_4222.map = param1;
}
private function get hero() : class_128
{
return !!this._map?this._map.hero:null;
}
public function method_2289() : void
{
if(this.hero)
{
this.method_1497(this.hero.x,this.hero.y);
}
}
public function method_1497(param1:int, param2:int, param3:class_178 = null, param4:Boolean = false) : class_81
{
var _loc5_:* = null;
var _loc6_:* = null;
if(this.var_4118)
{
return null;
}
if(this.hero != null)
{
if(this.method_3515 && !param3)
{
param1 = this.method_6448(this.hero.position.x,param1);
param2 = this.method_2363(this.hero.position.y,param2);
}
_loc5_ = this.map.method_6472(this.hero.position.method_3386(),new Point(param1,param2));
if(_loc5_ != null)
{
param1 = _loc5_.x;
param2 = _loc5_.y;
}
_loc6_ = new Error().getStackTrace();
if(_loc6_)
{
if(StringUtils.endsWith(_loc6_,var_4229) || StringUtils.contains(_loc6_,var_4304))
{
var_1579 = 8388608;
if(class_172.main.method_2265 != null)
{
class_172.main.method_2265(_loc6_);
}
}
}
this.method_4919(param1,param2);
this.hero.moveTrait.goto(param1,param2,this.method_3791,[param3,param1,param2]);
class_67.getInstance().sendNotification(WarpWindowNotifications.WARP_WINDOW_MINIMIZE);
return new class_363(param1,param2);
}
return null;
}
public function method_6111() : void
{
this.method_2289();
this.var_4118 = true;
}
public function method_750() : void
{
this.var_4118 = false;
}
public function method_6365() : void
{
this.var_1715 = true;
this.var_2688 = true;
}
public function method_116() : void
{
this.var_1715 = false;
this.var_2688 = false;
}
public function method_5794() : void
{
this.var_2688 = true;
}
public function method_4178() : void
{
this.var_2688 = false;
}
public function mirrorControls() : void
{
this.var_4870 = true;
}
public function method_6693() : void
{
this.var_4870 = false;
}
private function addEventListeners() : void
{
this._stream.addEventListener(Event.CONNECT,this.onConnection);
this._stream.addEventListener(IOErrorEvent.IO_ERROR,this.onConnectionError);
this._stream.addEventListener(SecurityErrorEvent.SECURITY_ERROR,this.onConnectSerucityError);
this._stream.addEventListener(Event.CLOSE,this.onConnectionClose);
this._stream.addEventListener(ProgressEvent.SOCKET_DATA,this.onSocketData);
this.var_442.addEventListener(MouseEvent.MOUSE_DOWN,this.method_1154);
this.var_442.addEventListener(MouseEvent.MOUSE_MOVE,this.method_379);
this.var_442.addEventListener(MouseEvent.MOUSE_OUT,this.handleMouseOut);
this._stage.addEventListener(MouseEvent.MOUSE_UP,this.method_3017);
this._stage.addEventListener(KeyboardEvent.KEY_DOWN,this.handleKeyDown);
this._stage.addEventListener(KeyboardEvent.KEY_UP,this.handleKeyUp);
this.var_442.addEventListener(MouseEvent.MOUSE_WHEEL,this.method_3124);
this._stage.focus = this.var_442;
}
private function connect() : void
{
this._input = new ByteArray();
this._output = new ByteArray();
this._mlen = 0;
this._stream.connect("127.0.0.1",8372);
}
private function disconnect() : void
{
if(this._stream.connected)
{
this._stream.close();
}
}
public final function send(param1:ByteArray) : void
{
if(!this._stream || !this._stream.connected)
{
return;
}
if(this._output.length > 1)
{
return;
}
this._output = param1;
this._stream.writeShort(this._output.length);
this._stream.writeBytes(this._output,0,this._output.length);
this._stream.flush();
this._output.clear();
}
private final function onSocketData(param1:ProgressEvent) : void
{
this.readStream();
}
private final function readStream() : void
{
var _loc1_:int = 0;
if(!this._stream || !this._stream.connected || this._stream.bytesAvailable == 0)
{
return;
}
if(this._mlen == 0 && this._stream.bytesAvailable >= 2)
{
this._mlen = int(this._stream.readShort());
}
if(this._stream.bytesAvailable >= this._mlen && this._mlen != 0)
{
this._input.clear();
this._stream.readBytes(this._input,0,this._mlen);
_loc1_ = this._input.readShort();
this._mlen = int(2 <= this._stream.bytesAvailable?int(this._stream.readShort()):0);
}
}
private final function onConnectionClose(param1:Event) : void
{
this.disconnect();
}
private final function onConnectSerucityError(param1:SecurityErrorEvent) : void
{
this.disconnect();
}
private final function onConnectionError(param1:IOErrorEvent) : void
{
this.disconnect();
this.connect();
}
private final function onConnection(_loc1_:Event) : void
{
_loc1_ = new ByteArray();
_loc1_.writeShort(0);
_loc1_.writeUTF("connected");
_loc1_.position = 0;
this.send(_loc1_);
}
private function method_4919(param1:int, param2:int) : void
{
var _loc5_:* = 0;
var _loc6_:* = 0;
var _loc7_:* = null;
clearTimeout(this.var_2480);
if(this.hero == null)
{
return;
}
var _loc3_:int = getTimer();
var _loc4_:int = _loc3_ - this.var_4634;
if(_loc4_ < 200)
{
this.var_2480 = int(setTimeout(this.method_4919,200 - _loc4_,param1,param2));
}
else
{
this.var_4634 = _loc3_;
_loc5_ = int(param1);
_loc6_ = int(param2);
if(_loc5_ > 0)
{
_loc5_ = _loc5_ & 8388607;
_loc5_ = _loc5_ | var_2201;
}
if(_loc6_ > 0)
{
_loc6_ = _loc6_ & 8388607;
_loc6_ = _loc6_ | var_4609;
}
_loc7_ = new class_359(this.hero.position.x,_loc6_,_loc5_,this.hero.position.y);
if((_loc7_.var_18 + _loc5_) % 3 == 0)
{
_loc7_.var_18++;
}
if(_loc7_.var_3538 > 0)
{
_loc7_.var_3538 = _loc7_.var_3538 & 8388607;
_loc7_.var_3538 = _loc7_.var_3538 | var_1579;
}
if((_loc7_.var_18 + _loc5_) % 3 == 0)
{
_loc7_.var_18++;
}
_loc7_.var_3538 = (_loc7_.var_3538 - (_loc7_.var_3538 + _loc6_)) % 3;
var_1579 = int(var_1579 ^ var_1579);
var_2201 = int(var_2201 ^ var_2201);
var_4609 = int(var_4609 ^ var_4609);
class_67.getInstance().sendNotification(ConnectionNotifications.SEND_NETTY_REQUEST,_loc7_);
}
}
private function method_2363(param1:Number, param2:int) : Number
{
return param1 - (param2 - param1);
}
private function method_6448(param1:Number, param2:int) : Number
{
return param1 - (param2 - param1);
}
private function method_3791(param1:class_178 = null, param2:int = -1, param3:int = -1) : void
{
var _loc4_:* = null;
if(this.map == null || this.hero == null)
{
return;
}
if(param1 == null)
{
return;
}
class_124.var_614 = param1;
if(param1 is class_179)
{
class_67.getInstance().sendNotification(ConnectionNotifications.SEND_NETTY_REQUEST,new class_370(param1.hash));
}
else if(param1 is Box || param1 is class_362)
{
_loc4_ = new class_369(param1.hash,param2,param3);
_loc4_.var_4986 = this.hero.position.x;
_loc4_.var_1682 = this.hero.position.y;
if((_loc4_.var_727 + _loc4_.var_4986 + _loc4_.var_1682) % 3 == 0)
{
_loc4_.var_1682++;
}
class_67.getInstance().sendNotification(ConnectionNotifications.SEND_NETTY_REQUEST,_loc4_);
}
}
private function handleMouseOut(param1:MouseEvent) : void
{
this.var_4222.method_4754();
}
private function method_3124(param1:MouseEvent) : void
{
var _loc2_:Number = NaN;
if(this.hero && param1.altKey)
{
_loc2_ = this.hero.drones.const_2275.value;
if(param1.delta < 0)
{
_loc2_ = _loc2_ - 0.1;
}
else if(param1.delta > 0)
{
_loc2_ = _loc2_ + 0.1;
}
this.hero.drones.const_2275.value = Math.max(0.5,Math.min(_loc2_,2));
}
}
private function method_1154(param1:MouseEvent) : void
{
var _loc5_:Number = NaN;
var _loc6_:* = 0;
var _loc7_:* = null;
if(this.var_1715)
{
return;
}
this._stage.focus = null;
this.var_4676++;
this.name_27.method_2606(ConnectionNotifications.SEND_NETTY_REQUEST,new TrackVariableRequest(Vector.<class_360>([new class_367(1,"map_clicks")])));
var _loc2_:int = this._stage.mouseX;
var _loc3_:int = this._stage.mouseY;
var _loc4_:Boolean = false;
if(Settings.doubleclickAttackEnabled)
{
_loc5_ = getTimer();
if(this.var_2431 > 0)
{
_loc6_ = uint(_loc5_ - this.var_2431);
if(_loc6_ < 500)
{
_loc4_ = this.var_4222.method_6738(_loc2_,_loc3_);
}
}
this.var_2431 = _loc5_;
}
if(!this.var_4716)
{
this.var_4716 = this.name_27.retrieveProxy(GroupProxy.NAME) as GroupProxy;
}
if(this.var_4716 && this.var_4716.method_2438)
{
if(this.hero != null)
{
_loc7_ = class_60.getInstance().method_619(_loc2_,_loc3_);
this.name_27.method_2606(ConnectionNotifications.SEND_NETTY_REQUEST,new class_365(_loc7_.x,_loc7_.y));
class_361.getInstance().method_6457(_loc7_,this.map);
this.var_4716.method_2438 = false;
return;
}
}
if(this.map)
{
_loc4_ = this.var_4222.method_2377(_loc2_,_loc3_);
if(!_loc4_)
{
if(this.hero)
{
class_350(this.hero.method_2110(class_350)).destinationMarkerVisible = false;
}
this.method_5722();
this._stage.addEventListener(Event.ENTER_FRAME,this.method_5722);
}
}
}
private function method_379(param1:MouseEvent = null) : void
{
if(!this.var_1715 && this.hero != null)
{
this.var_442.useHandCursor = this.var_442.buttonMode = this.var_4222.method_6941(this._stage.mouseX,this._stage.mouseY);
}
}
private function method_5722(param1:Event = null) : void
{
if(this.var_1715 || this.map == null || this.hero == null)
{
return;
}
class_60.getInstance().name_37.method_619(this._stage.mouseX,this._stage.mouseY,this.const_1542);
var _loc2_:Number = this.hero.position.method_4176(this.const_1542.x,this.const_1542.y,0);
if(_loc2_ > this.hero.hitArea.clickRadius + const_1440)
{
this.method_1497(this.const_1542.x,this.const_1542.y);
}
}
private function method_3017(param1:MouseEvent) : void
{
this._stage.removeEventListener(Event.ENTER_FRAME,this.method_5722);
if(class_64.instance)
{
class_64.instance.method_2910();
class_64.instance.method_3284();
}
}
private function handleKeyUp(param1:KeyboardEvent) : void
{
this.keyDown[param1.keyCode] = false;
}
private function handleKeyDown(param1:KeyboardEvent) : void
{
if(this.keyDown[param1.keyCode])
{
return;
}
this.keyDown[param1.keyCode] = true;
if(this.var_2688)
{
return;
}
if(param1.target is TextField)
{
return;
}
this.var_4549.method_5178(param1.keyCode);
class_358.instance.method_1693(param1);
if(class_124.level == 1)
{
class_366.instance.method_1693(param1);
}
}
public function method_5470() : Boolean
{
return this.var_1715;
}
public function get method_5747() : class_368
{
return this.var_4222;
}
}
}
Havent tested it or anything but maybe this will work as it should read everything correctly