Section 1
//Console (AKEngine.debug.Console)
package AKEngine.debug {
import AKEngine.*;
public class Console {
protected static var _stats:Stats;
protected static var commandListOrdered:Boolean = false;
protected static var commands:Object = {};
protected static var commandList:Array = [];
public static var verbosity:int = 0;
public static function processLine(_arg1:String):void{
var args:Array;
var line = _arg1;
ensureCommandsOrdered();
args = line.split(" ");
if (args.length == 0){
return;
};
var potentialCommand:ConsoleCommand = commands[args[0].toString().toLowerCase()];
if (!potentialCommand){
Logger.warn(Console, "processLine", (("No such command '" + args[0].toString()) + "'!"));
return;
};
try {
potentialCommand.callback.apply(null, args.slice(1));
} catch(e:Error) {
Logger.error(Console, args[0], ((("Error: " + e.toString()) + " - ") + e.getStackTrace()));
};
}
protected static function ensureCommandsOrdered():void{
if (commandListOrdered == true){
return;
};
if (commands.help == null){
init();
};
commandListOrdered = true;
commandList.sort(function (_arg1:ConsoleCommand, _arg2:ConsoleCommand):int{
if (_arg1.name > _arg2.name){
return (1);
};
return (-1);
});
}
public static function registerCommand(_arg1:String, _arg2:Function, _arg3:String=null):void{
if (_arg2 == null){
Logger.error(Console, "registerCommand", (("Command '" + _arg1) + "' has no callback!"));
};
if (((!(_arg1)) || ((_arg1.length == 0)))){
Logger.error(Console, "registerCommand", "Command has no name!");
};
if (_arg1.indexOf(" ") != -1){
Logger.error(Console, "registerCommand", (("Command '" + _arg1) + "' has a space in it, it will not work."));
};
var _local4:ConsoleCommand = new ConsoleCommand();
_local4.name = _arg1;
_local4.callback = _arg2;
_local4.docs = _arg3;
if (commands[_arg1.toLowerCase()]){
Logger.warn(Console, "registerCommand", (("Replacing existing command '" + _arg1) + "'."));
};
commands[_arg1.toLowerCase()] = _local4;
commandList.push(_local4);
commandListOrdered = false;
}
public static function getCommandList():Array{
ensureCommandsOrdered();
return (commandList);
}
public static function init():void{
registerCommand("help", function (_arg1:String=null):void{
var _local3:ConsoleCommand;
ensureCommandsOrdered();
Logger.print(Console, "Keyboard shortcuts: ");
Logger.print(Console, "[SHIFT]-TAB - Cycle through autocompleted commands.");
Logger.print(Console, "PGUP/PGDN - Page log view up/down a page.");
Logger.print(Console, "");
Logger.print(Console, "Commands:");
var _local2:int;
while (_local2 < commandList.length) {
_local3 = (commandList[_local2] as ConsoleCommand);
if (((((_arg1) && ((_arg1.length > 0)))) && (!((_local3.name.substr(0, _arg1.length) == _arg1))))){
} else {
Logger.print(Console, (((" " + _local3.name) + " - ") + (_local3.docs) ? _local3.docs : ""));
};
_local2++;
};
}, "[prefix] - List known commands, optionally filtering by prefix.");
registerCommand("version", function ():void{
Logger.print(Console, AKE.instance.VERSION);
}, "Echo AKEngine version information.");
registerCommand("fps", function ():void{
if (!_stats){
_stats = new Stats();
AKE.instance.stage.addChild(_stats);
Logger.print(Console, "Enabled FPS display.");
} else {
AKE.instance.stage.removeChild(_stats);
_stats = null;
};
}, "Toggle an FPS/Memory usage indicator.");
registerCommand("verbose", function (_arg1:int):void{
Console.verbosity = _arg1;
Logger.print(Console, ("Verbosity set to " + _arg1));
}, "Set verbosity level of console output.");
}
}
}//package AKEngine.debug
final class ConsoleCommand {
public var name:String;
public var callback:Function;
public var docs:String;
private function ConsoleCommand(){
}
}
Section 2
//ILogAppender (AKEngine.debug.ILogAppender)
package AKEngine.debug {
public interface ILogAppender {
function addLogMessage(_arg1:String, _arg2:String, _arg3:String):void;
}
}//package AKEngine.debug
Section 3
//LogColor (AKEngine.debug.LogColor)
package AKEngine.debug {
public class LogColor {
public static const WARN:String = "#FF6600";
public static const MESSAGE:String = "#000000";
public static const ERROR:String = "#FF0000";
public static const DEBUG:String = "#DDDDDD";
public static const INFO:String = "#222222";
public static const CMD:String = "#00DD00";
public static function getColor(_arg1:String):String{
switch (_arg1){
case LogEntry.DEBUG:
return (DEBUG);
case LogEntry.INFO:
return (INFO);
case LogEntry.WARNING:
return (WARN);
case LogEntry.ERROR:
return (ERROR);
case LogEntry.MESSAGE:
return (MESSAGE);
case "CMD":
return (CMD);
default:
return (MESSAGE);
};
}
}
}//package AKEngine.debug
Section 4
//LogEntry (AKEngine.debug.LogEntry)
package AKEngine.debug {
public class LogEntry {
public var method:String;// = ""
public var depth:int;// = 0
public var message:String;// = ""
public var reporter:Class;// = null
public var type:String;// = null
public static const DEBUG:String = "DEBUG";
public static const MESSAGE:String = "MESSAGE";
public static const ERROR:String = "ERROR";
public static const WARNING:String = "WARNING";
public static const INFO:String = "INFO";
public function get formattedMessage():String{
var _local1 = "";
var _local2:int;
while (_local2 < depth) {
_local1 = (_local1 + " ");
_local2++;
};
var _local3 = "";
if (_local3){
_local3 = (_local3 + ": ");
};
var _local4 = "";
if (((!((_local4 == null))) && (!((_local4 == ""))))){
_local4 = (_local4 + " - ");
};
return ((((_local1 + _local3) + _local4) + message));
}
}
}//package AKEngine.debug
Section 5
//Logger (AKEngine.debug.Logger)
package AKEngine.debug {
import AKEngine.*;
import AKEngine.helpers.*;
public class Logger {
public var enabled:Boolean;
protected var _owner:Class;
protected static var started:Boolean = false;
protected static var pendingEntries:Array = [];
protected static var disabled:Boolean = false;
protected static var listeners:Array = [];
public function Logger(_arg1:Class, _arg2:Boolean=true){
_owner = _arg1;
enabled = _arg2;
}
public function warn(_arg1:String, _arg2:String):void{
if (enabled){
Logger.warn(_owner, _arg1, _arg2);
};
}
public function print(_arg1:String):void{
if (enabled){
Logger.print(_owner, _arg1);
};
}
public function info(_arg1:String, _arg2:String):void{
if (enabled){
Logger.info(_owner, _arg1, _arg2);
};
}
public function error(_arg1:String, _arg2:String):void{
if (enabled){
Logger.error(_owner, _arg1, _arg2);
};
}
public static function printFooter(_arg1, _arg2:String):void{
print(_arg1, _arg2);
}
protected static function processEntry(_arg1:LogEntry):void{
if (disabled){
return;
};
if (!started){
pendingEntries.push(_arg1);
return;
};
var _local2:int;
while (_local2 < listeners.length) {
(listeners[_local2] as ILogAppender).addLogMessage(_arg1.type, TypeHelper.getObjectClassName(_arg1.reporter), _arg1.message);
_local2++;
};
}
public static function printCustom(_arg1, _arg2:String, _arg3:String, _arg4:String):void{
if (disabled){
return;
};
var _local5:LogEntry = new LogEntry();
_local5.reporter = TypeHelper.getClass(_arg1);
_local5.method = _arg2;
_local5.message = ((_arg2 + " - ") + _arg3);
_local5.type = _arg4;
processEntry(_local5);
}
public static function warn(_arg1, _arg2:String, _arg3:String):void{
if (disabled){
return;
};
var _local4:LogEntry = new LogEntry();
_local4.reporter = TypeHelper.getClass(_arg1);
_local4.method = _arg2;
_local4.message = ((_arg2 + " - ") + _arg3);
_local4.type = LogEntry.WARNING;
processEntry(_local4);
}
public static function disable():void{
pendingEntries = null;
started = false;
listeners = null;
disabled = true;
}
public static function print(_arg1, _arg2:String):void{
if (disabled){
return;
};
var _local3:LogEntry = new LogEntry();
_local3.reporter = TypeHelper.getClass(_arg1);
_local3.message = _arg2;
_local3.type = LogEntry.MESSAGE;
processEntry(_local3);
}
public static function info(_arg1, _arg2:String, _arg3:String):void{
if (disabled){
return;
};
var _local4:LogEntry = new LogEntry();
_local4.reporter = TypeHelper.getClass(_arg1);
_local4.method = _arg2;
_local4.message = ((_arg2 + " - ") + _arg3);
_local4.type = LogEntry.INFO;
processEntry(_local4);
}
public static function error(_arg1, _arg2:String, _arg3:String):void{
if (disabled){
return;
};
var _local4:LogEntry = new LogEntry();
_local4.reporter = TypeHelper.getClass(_arg1);
_local4.method = _arg2;
_local4.message = ((_arg2 + " - ") + _arg3);
_local4.type = LogEntry.ERROR;
processEntry(_local4);
}
public static function debug(_arg1, _arg2:String, _arg3:String):void{
if (disabled){
return;
};
var _local4:LogEntry = new LogEntry();
_local4.reporter = TypeHelper.getClass(_arg1);
_local4.method = _arg2;
_local4.message = ((_arg2 + " - ") + _arg3);
_local4.type = LogEntry.DEBUG;
processEntry(_local4);
}
public static function getCallStack():String{
var e:Error;
try {
e = new Error();
return (e.getStackTrace());
} catch(e:Error) {
};
return ("[no callstack available]");
}
public static function registerListener(_arg1:ILogAppender):void{
listeners.push(_arg1);
}
public static function printHeader(_arg1, _arg2:String):void{
print(_arg1, _arg2);
}
public static function startup():void{
if (AKE.instance.isDebugMode){
registerListener(new TraceAppender());
registerListener(new UIAppender());
};
started = true;
var _local1:int;
while (_local1 < pendingEntries.length) {
processEntry(pendingEntries[_local1]);
_local1++;
};
pendingEntries.length = 0;
pendingEntries = null;
}
}
}//package AKEngine.debug
Section 6
//LogViewer (AKEngine.debug.LogViewer)
package AKEngine.debug {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
import flash.text.*;
import AKEngine.helpers.*;
import flash.ui.*;
public class LogViewer extends Sprite implements ILogAppender {
protected var _truncating:Boolean;// = false
protected var tabCompletionPrefix:String;// = ""
protected var _height:uint;// = 150
protected var _width:uint;// = 500
protected var _input:TextField;
protected var tabCompletionCurrentEnd:int;// = 0
protected var tabCompletionCurrentStart:int;// = 0
protected var tabCompletionCurrentOffset:int;// = 0
protected var _consoleHistory:Array;
protected var _output:TextField;
protected var _messageQueue:Array;
protected var _maxLength:uint;// = 200000
protected var _historyIndex:uint;// = 0
public function LogViewer():void{
_messageQueue = [];
_consoleHistory = [];
super();
layout();
addListeners();
name = "Console";
Console.registerCommand("clear", onClearCommand, "Clears the console history.");
}
public function set maxLength(_arg1:uint):void{
_maxLength = _arg1;
truncateOutput();
}
protected function onClearCommand():void{
_output.htmlText = "";
}
protected function setHistory(_arg1:String):void{
_input.text = _arg1;
_input.setSelection(_input.length, _input.length);
}
protected function addListeners():void{
_input.addEventListener(KeyboardEvent.KEY_DOWN, inputKeyDownHandler, false, 1, true);
}
protected function truncateOutput():void{
if (_output.text.length > maxLength){
_output.text = _output.text.slice(-(maxLength));
if (!_truncating){
_truncating = true;
Logger.warn(this, "truncateOutput", ((((("You have exceeded " + _maxLength) + " characters in LogViewerAS. ") + "It will now only show the latest ") + _maxLength) + " characters of the log."));
};
};
}
public function deactivate():void{
removeListeners();
}
protected function removeListeners():void{
_input.removeEventListener(KeyboardEvent.KEY_DOWN, inputKeyDownHandler);
}
protected function processCommand():void{
addLogMessage("CMD", ">", _input.text);
Console.processLine(_input.text);
_consoleHistory.push(_input.text);
_historyIndex = _consoleHistory.length;
_input.text = "";
}
protected function createOutputField():TextField{
_output = new TextField();
_output.type = TextFieldType.DYNAMIC;
_output.multiline = true;
_output.wordWrap = true;
_output.condenseWhite = false;
var _local1:TextFormat = _output.getTextFormat();
_local1.font = "_typewriter";
_local1.size = 11;
_local1.color = 0;
_output.setTextFormat(_local1);
_output.defaultTextFormat = _local1;
_output.htmlText = "";
_output.embedFonts = false;
_output.name = "ConsoleOutput";
return (_output);
}
protected function layout():void{
if (!_output){
createOutputField();
};
if (!_input){
createInputField();
};
resize();
addChild(_output);
addChild(_input);
graphics.clear();
graphics.beginFill(0x666666, 0.95);
graphics.drawRoundRect(0, 0, _width, _height, 5);
graphics.endFill();
graphics.beginFill(0xFFFFFF, 1);
graphics.drawRoundRect(4, 4, (_width - 8), (_height - 30), 5);
graphics.endFill();
}
protected function createInputField():TextField{
_input = new TextField();
_input.type = TextFieldType.INPUT;
_input.border = true;
_input.borderColor = 0xFFFFFF;
_input.multiline = false;
_input.wordWrap = false;
_input.condenseWhite = false;
_input.background = true;
_input.backgroundColor = 0xFFFFFF;
var _local1:TextFormat = _input.getTextFormat();
_local1.font = "_typewriter";
_local1.size = 11;
_local1.color = 0;
_input.setTextFormat(_local1);
_input.defaultTextFormat = _local1;
_input.restrict = "^`";
_input.name = "ConsoleInput";
return (_input);
}
public function get maxLength():uint{
return (_maxLength);
}
protected function inputKeyDownHandler(_arg1:KeyboardEvent):void{
var _local2:Array;
var _local3:Boolean;
var _local4:*;
var _local5:int;
var _local6:String;
if (((!((_arg1.keyCode == Keyboard.TAB))) && (!((_arg1.keyCode == Keyboard.SHIFT))))){
tabCompletionPrefix = _input.text;
tabCompletionCurrentStart = -1;
tabCompletionCurrentOffset = 0;
};
if (_arg1.keyCode == Keyboard.ENTER){
if (_input.text.length <= 0){
addLogMessage("CMD", ">", _input.text);
return;
};
processCommand();
} else {
if (_arg1.keyCode == Keyboard.UP){
if (_historyIndex > 0){
setHistory(_consoleHistory[--_historyIndex]);
} else {
if (_consoleHistory.length > 0){
setHistory(_consoleHistory[0]);
};
};
_arg1.preventDefault();
} else {
if (_arg1.keyCode == Keyboard.DOWN){
if (_historyIndex < (_consoleHistory.length - 1)){
setHistory(_consoleHistory[++_historyIndex]);
} else {
if (_historyIndex == (_consoleHistory.length - 1)){
_input.text = "";
};
};
_arg1.preventDefault();
} else {
if (_arg1.keyCode == Keyboard.PAGE_UP){
_output.scrollV = (_output.scrollV - Math.floor((_output.height / _output.getLineMetrics(0).height)));
} else {
if (_arg1.keyCode == Keyboard.PAGE_DOWN){
_output.scrollV = (_output.scrollV + Math.floor((_output.height / _output.getLineMetrics(0).height)));
} else {
if (_arg1.keyCode == Keyboard.TAB){
_local2 = Console.getCommandList();
_local3 = false;
if (tabCompletionCurrentStart == -1){
tabCompletionPrefix = _input.text.toLowerCase();
tabCompletionCurrentStart = int.MAX_VALUE;
tabCompletionCurrentEnd = -1;
_local5 = 0;
while (_local5 < _local2.length) {
if (_local2[_local5].name.substr(0, tabCompletionPrefix.length).toLowerCase() == tabCompletionPrefix){
if (_local5 < tabCompletionCurrentStart){
tabCompletionCurrentStart = _local5;
};
if (_local5 > tabCompletionCurrentEnd){
tabCompletionCurrentEnd = _local5;
};
_local3 = true;
};
_local5++;
};
tabCompletionCurrentOffset = tabCompletionCurrentStart;
};
if (tabCompletionCurrentEnd != -1){
if (!_local3){
if (_arg1.shiftKey){
tabCompletionCurrentOffset--;
} else {
tabCompletionCurrentOffset++;
};
if (tabCompletionCurrentOffset < tabCompletionCurrentStart){
tabCompletionCurrentOffset = tabCompletionCurrentEnd;
} else {
if (tabCompletionCurrentOffset > tabCompletionCurrentEnd){
tabCompletionCurrentOffset = tabCompletionCurrentStart;
};
};
};
_local6 = _local2[tabCompletionCurrentOffset].name;
_input.text = _local6;
_input.setSelection((_local6.length + 1), (_local6.length + 1));
};
_local4 = stage.stageFocusRect;
stage.stageFocusRect = false;
stage.focus = _input;
stage.stageFocusRect = _local4;
} else {
if (_arg1.keyCode == InputManager.instance.TILDE){
stage.focus = stage;
parent.removeChild(this);
deactivate();
};
};
};
};
};
};
};
_arg1.stopImmediatePropagation();
}
public function activate():void{
layout();
_input.text = "";
addListeners();
stage.focus = _input;
}
protected function resize():void{
_output.x = 5;
_output.y = 0;
_input.x = 5;
if (stage){
_width = (stage.stageWidth - 1);
_height = ((stage.stageHeight / 3) * 2);
};
_output.height = (_height - 30);
_output.width = (_width - 10);
_input.height = 18;
_input.width = (_width - 10);
_input.y = (_output.height + 7);
}
public function addLogMessage(_arg1:String, _arg2:String, _arg3:String):void{
var _local6:int;
var _local7:String;
var _local4:String = LogColor.getColor(_arg1);
if (Console.verbosity < 2){
_local6 = _arg2.lastIndexOf("::");
if (_local6 != -1){
_arg2 = _arg2.substr((_local6 + 2));
};
};
var _local5:String = (((((Console.verbosity)>0) ? (_arg1 + ": ") : "" + _arg2) + " - ") + _arg3);
if (_output){
Profiler.enter("LogViewer.addLogMessage");
_local7 = (((((("<p><font size=\"" + _input.getTextFormat().size) + "\" color=\"") + _local4) + "\"><b>") + TextHelper.escapeHTMLText(_local5)) + "</b></font></p>");
_output.htmlText = (_output.htmlText + _local7);
truncateOutput();
_output.scrollV = _output.maxScrollV;
Profiler.exit("LogViewer.addLogMessage");
};
}
}
}//package AKEngine.debug
Section 7
//Profiler (AKEngine.debug.Profiler)
package AKEngine.debug {
import AKEngine.managers.*;
import flash.utils.*;
public class Profiler {
public static var enabled:Boolean = false;
private static var _wantReport:Boolean = false;
private static var _wantWipe:Boolean = false;
private static var _reallyEnabled:Boolean = true;
private static var _currentNode:ProfileInfo;
public static var nameFieldWidth:int = 50;
private static var _rootNode:ProfileInfo;
public static var indentAmount:int = 3;
private static var _stackDepth:int = 0;
public static function wipe():void{
if (_stackDepth){
_wantWipe = true;
return;
};
doWipe();
}
private static function report_R(_arg1:ProfileInfo, _arg2:int):void{
var _local6:ProfileInfo;
var _local3:Number = _arg1.totalTime;
var _local4:Boolean;
var _local5:Number = 0;
for each (_local6 in _arg1.children) {
_local4 = true;
_local3 = (_local3 - _local6.totalTime);
_local5 = (_local5 + _local6.totalTime);
};
if (_arg1.name == "Root"){
_arg1.totalTime = _local5;
};
var _local7:Number = -1;
if (_arg1.parent){
_local7 = ((Number(_arg1.totalTime) / Number(_rootNode.totalTime)) * 100);
};
var _local8:Number = -1;
if (_arg1.parent){
_local8 = ((_local3 / Number(_rootNode.totalTime)) * 100);
};
var _local9:String;
if (_arg2 == 0){
_local9 = "+Root";
} else {
_local9 = sprintf((((("%-" + (_arg2 * indentAmount)) + "s%-") + (nameFieldWidth - (_arg2 * indentAmount))) + "s%-8s%-8s%-8s%-8s%-8s%-8s"), "", ((_local4) ? "+" : "-" + _arg1.name), _arg1.activations, _local7.toFixed(2), _local8.toFixed(2), (Number(_arg1.totalTime) / Number(_arg1.activations)).toFixed(1), _arg1.minTime, _arg1.maxTime);
};
Logger.print(Profiler, _local9);
var _local10:Array = new Array();
for each (_local6 in _arg1.children) {
_local10.push(_local6);
};
_local10.sortOn("totalTime", (Array.NUMERIC | Array.DESCENDING));
for each (_local6 in _local10) {
report_R(_local6, (_arg2 + 1));
};
}
public static function ensureAtRoot():void{
if (_stackDepth){
throw (new Error("Not at root!"));
};
}
public static function enter(_arg1:String):void{
if (!_currentNode){
_rootNode = new ProfileInfo("Root");
_currentNode = _rootNode;
};
if (_stackDepth == 0){
if (InputManager.instance.isKeyPressed(InputManager.instance.P)){
if (!enabled){
_wantWipe = true;
enabled = true;
};
} else {
if (enabled){
_wantReport = true;
enabled = false;
};
};
_reallyEnabled = enabled;
if (_wantWipe){
doWipe();
};
if (_wantReport){
doReport();
};
};
_stackDepth++;
if (!_reallyEnabled){
return;
};
var _local2:ProfileInfo = _currentNode.children[_arg1];
if (!_local2){
_local2 = new ProfileInfo(_arg1, _currentNode);
_currentNode.children[_arg1] = _local2;
};
_currentNode = _local2;
_currentNode.startTime = getTimer();
}
private static function doReport():void{
_wantReport = false;
var _local1:String = sprintf((("%-" + nameFieldWidth) + "s%-8s%-8s%-8s%-8s%-8s%-8s"), "name", "Calls", "Total%", "NonSub%", "AvgMs", "MinMs", "MaxMs");
Logger.print(Profiler, _local1);
report_R(_rootNode, 0);
}
public static function exit(_arg1:String):void{
_stackDepth--;
if (!_reallyEnabled){
return;
};
if (_arg1 != _currentNode.name){
throw (new Error((((("Mismatched Profiler.enter/Profiler.exit calls, got '" + _currentNode.name) + "' but was expecting '") + _arg1) + "'")));
};
var _local2:int = (getTimer() - _currentNode.startTime);
_currentNode.activations++;
_currentNode.totalTime = (_currentNode.totalTime + _local2);
if (_local2 > _currentNode.maxTime){
_currentNode.maxTime = _local2;
};
if (_local2 < _currentNode.minTime){
_currentNode.minTime = _local2;
};
_currentNode = _currentNode.parent;
}
private static function doWipe(_arg1:ProfileInfo=null):void{
var _local2:ProfileInfo;
_wantWipe = false;
if (!_arg1){
doWipe(_rootNode);
return;
};
_arg1.wipe();
for each (_local2 in _arg1.children) {
doWipe(_local2);
};
}
public static function report():void{
if (_stackDepth){
_wantReport = true;
return;
};
doReport();
}
}
}//package AKEngine.debug
final class ProfileInfo {
public var minTime:int;// = 2147483647
public var parent:ProfileInfo;
public var name:String;
public var startTime:int;
public var totalTime:int;
public var maxTime:int;// = -2147483648
public var activations:int;
public var children:Object;
private function ProfileInfo(_arg1:String, _arg2:ProfileInfo=null){
children = {};
super();
name = _arg1;
parent = _arg2;
}
final public function wipe():void{
startTime = (totalTime = (activations = 0));
maxTime = int.MIN_VALUE;
minTime = int.MAX_VALUE;
}
}
Section 8
//sprintf (AKEngine.debug.sprintf)
package AKEngine.debug {
public function sprintf(_arg1:String, ... _args):String{
var _local6:String;
var _local7:*;
var _local8:String;
var _local9:Boolean;
var _local10:Boolean;
var _local11:Boolean;
var _local12:Boolean;
var _local13:Boolean;
var _local14:Boolean;
var _local15:Boolean;
var _local16:String;
var _local17:String;
var _local18:Boolean;
var _local19:Boolean;
var _local3 = "";
var _local4:int = _arg1.length;
var _local5:int;
while (_local5 < _local4) {
_local6 = _arg1.charAt(_local5);
if (_local6 == "%"){
_local9 = false;
_local10 = false;
_local11 = false;
_local12 = false;
_local13 = false;
_local14 = false;
_local15 = false;
_local16 = "";
_local17 = "";
++_local5;
_local6 = _arg1.charAt(_local5);
while (((((((((((((((((((((!((_local6 == "d"))) && (!((_local6 == "i"))))) && (!((_local6 == "o"))))) && (!((_local6 == "u"))))) && (!((_local6 == "x"))))) && (!((_local6 == "X"))))) && (!((_local6 == "f"))))) && (!((_local6 == "F"))))) && (!((_local6 == "c"))))) && (!((_local6 == "s"))))) && (!((_local6 == "%"))))) {
if (!_local10){
if (((!(_local11)) && ((_local6 == "#")))){
_local11 = true;
} else {
if (((!(_local12)) && ((_local6 == "0")))){
_local12 = true;
} else {
if (((!(_local13)) && ((_local6 == "-")))){
_local13 = true;
} else {
if (((!(_local14)) && ((_local6 == " ")))){
_local14 = true;
} else {
if (((!(_local15)) && ((_local6 == "+")))){
_local15 = true;
} else {
_local10 = true;
};
};
};
};
};
};
if (((!(_local9)) && ((_local6 == ".")))){
_local10 = true;
_local9 = true;
++_local5;
_local6 = _arg1.charAt(_local5);
} else {
if (_local10){
if (!_local9){
_local16 = (_local16 + _local6);
} else {
_local17 = (_local17 + _local6);
};
};
++_local5;
_local6 = _arg1.charAt(_local5);
};
};
switch (_local6){
case "d":
case "i":
_local7 = _args.shift();
_local8 = String(Math.abs(int(_local7)));
if (_local17 != ""){
_local8 = leftPad(_local8, int(_local17), "0");
};
if (int(_local7) < 0){
_local8 = ("-" + _local8);
} else {
if (((_local15) && ((int(_local7) >= 0)))){
_local8 = ("+" + _local8);
};
};
if (_local16 != ""){
if (_local13){
_local8 = rightPad(_local8, int(_local16));
} else {
if (((_local12) && ((_local17 == "")))){
_local8 = leftPad(_local8, int(_local16), "0");
} else {
_local8 = leftPad(_local8, int(_local16));
};
};
};
_local3 = (_local3 + _local8);
break;
case "o":
_local7 = _args.shift();
_local8 = uint(_local7).toString(8);
if (((_local11) && (!((_local8 == "0"))))){
_local8 = ("0" + _local8);
};
if (_local17 != ""){
_local8 = leftPad(_local8, int(_local17), "0");
};
if (_local16 != ""){
if (_local13){
_local8 = rightPad(_local8, int(_local16));
} else {
if (((_local12) && ((_local17 == "")))){
_local8 = leftPad(_local8, int(_local16), "0");
} else {
_local8 = leftPad(_local8, int(_local16));
};
};
};
_local3 = (_local3 + _local8);
break;
case "u":
_local7 = _args.shift();
_local8 = uint(_local7).toString(10);
if (_local17 != ""){
_local8 = leftPad(_local8, int(_local17), "0");
};
if (_local16 != ""){
if (_local13){
_local8 = rightPad(_local8, int(_local16));
} else {
if (((_local12) && ((_local17 == "")))){
_local8 = leftPad(_local8, int(_local16), "0");
} else {
_local8 = leftPad(_local8, int(_local16));
};
};
};
_local3 = (_local3 + _local8);
break;
case "X":
_local18 = true;
case "x":
_local7 = _args.shift();
_local8 = uint(_local7).toString(16);
if (_local17 != ""){
_local8 = leftPad(_local8, int(_local17), "0");
};
_local19 = ((_local11) && (!((uint(_local7) == 0))));
if (((((((!((_local16 == ""))) && (!(_local13)))) && (_local12))) && ((_local17 == "")))){
_local8 = leftPad(_local8, (_local19) ? (int(_local16) - 2) : int(_local16), "0");
};
if (_local19){
_local8 = ("0x" + _local8);
};
if (_local16 != ""){
if (_local13){
_local8 = rightPad(_local8, int(_local16));
} else {
_local8 = leftPad(_local8, int(_local16));
};
};
if (_local18){
_local8 = _local8.toUpperCase();
};
_local3 = (_local3 + _local8);
break;
case "f":
case "F":
_local7 = _args.shift();
_local8 = Math.abs(Number(_local7)).toFixed(((_local17)!="") ? int(_local17) : 6);
if (int(_local7) < 0){
_local8 = ("-" + _local8);
} else {
if (((_local15) && ((int(_local7) >= 0)))){
_local8 = ("+" + _local8);
};
};
if (((_local11) && ((_local8.indexOf(".") == -1)))){
_local8 = (_local8 + ".");
};
if (_local16 != ""){
if (_local13){
_local8 = rightPad(_local8, int(_local16));
} else {
if (((_local12) && ((_local17 == "")))){
_local8 = leftPad(_local8, int(_local16), "0");
} else {
_local8 = leftPad(_local8, int(_local16));
};
};
};
_local3 = (_local3 + _local8);
break;
case "c":
_local7 = _args.shift();
_local8 = String.fromCharCode(int(_local7));
if (_local16 != ""){
if (_local13){
_local8 = rightPad(_local8, int(_local16));
} else {
_local8 = leftPad(_local8, int(_local16));
};
};
_local3 = (_local3 + _local8);
break;
case "s":
_local7 = _args.shift();
_local8 = String(_local7);
if (_local17 != ""){
_local8 = _local8.substring(0, int(_local17));
};
if (_local16 != ""){
if (_local13){
_local8 = rightPad(_local8, int(_local16));
} else {
_local8 = leftPad(_local8, int(_local16));
};
};
_local3 = (_local3 + _local8);
break;
case "%":
_local3 = (_local3 + "%");
};
} else {
_local3 = (_local3 + _local6);
};
_local5++;
};
return (_local3);
}
}//package AKEngine.debug
private const leftPad:Function = function (_arg1:String, _arg2:int, _arg3:String=" "):String{
var _local4:String;
if (_arg1.length < _arg2){
_local4 = "";
while ((_local4.length + _arg1.length) < _arg2) {
_local4 = (_local4 + _arg3);
};
return ((_local4 + _arg1));
};
return (_arg1);
};
private const rightPad:Function = function (_arg1:String, _arg2:int, _arg3:String=" "):String{
while (_arg1.length < _arg2) {
_arg1 = (_arg1 + _arg3);
};
return (_arg1);
};
Section 9
//Stats (AKEngine.debug.Stats)
package AKEngine.debug {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.geom.*;
import flash.utils.*;
import flash.system.*;
public class Stats extends Sprite {
private var timer:int;
private var graph:BitmapData;
private var mem:Number;// = 0
private var memText:TextField;
private var ver:Sprite;
private var ms:int;
private var fps:int;
private var rectangle:Rectangle;
private var verText:TextField;
private var fpsText:TextField;
private var format:TextFormat;
private var msPrev:int;// = 0
private var msText:TextField;
public function Stats(){
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onMouseOver(_arg1:MouseEvent):void{
ver.visible = true;
}
private function update(_arg1:Event):void{
var _local2:int;
var _local3:Number;
var _local4:int;
timer = getTimer();
fps++;
if ((timer - 250) > msPrev){
msPrev = timer;
mem = Number((System.totalMemory * 9.54E-7).toFixed(3));
if (stage){
_local2 = Math.min(50, ((50 / stage.frameRate) * fps));
};
_local3 = (Math.min(50, Math.sqrt(Math.sqrt((mem * 5000)))) - 2);
graph.scroll(1, 0);
graph.fillRect(rectangle, 51);
if ((timer - ms) > 100){
_local4 = 0;
while (_local4 < graph.height) {
graph.setPixel32(0, (graph.height - _local4), 0xFF0000);
_local4++;
};
};
graph.setPixel32(0, (graph.height - _local2), 0xFFFF00);
graph.setPixel32(0, (graph.height - ((timer - ms) >> 1)), 0xFF00);
graph.setPixel32(0, (graph.height - _local3), 0xFFFF);
if (stage){
fpsText.text = ((("FPS: " + (fps * 4)) + " / ") + stage.frameRate);
};
memText.text = ("MEM: " + mem);
fps = 0;
};
msText.text = ("MS: " + (timer - ms));
ms = timer;
}
private function onMouseOut(_arg1:MouseEvent):void{
ver.visible = false;
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
graphics.beginFill(51);
graphics.drawRect(0, 0, 65, 40);
graphics.endFill();
ver = new Sprite();
ver.graphics.beginFill(51);
ver.graphics.drawRect(0, 0, 65, 30);
ver.graphics.endFill();
ver.y = 90;
ver.visible = false;
addChild(ver);
verText = new TextField();
fpsText = new TextField();
msText = new TextField();
memText = new TextField();
format = new TextFormat("_sans", 9);
verText.defaultTextFormat = (fpsText.defaultTextFormat = (msText.defaultTextFormat = (memText.defaultTextFormat = format)));
verText.width = (fpsText.width = (msText.width = (memText.width = 65)));
verText.selectable = (fpsText.selectable = (msText.selectable = (memText.selectable = false)));
verText.textColor = 0xFFFFFF;
verText.text = ((Capabilities.version.split(" ")[0] + "\n") + Capabilities.version.split(" ")[1]);
ver.addChild(verText);
fpsText.textColor = 0xFFFF00;
fpsText.text = "FPS: ";
addChild(fpsText);
msText.y = 10;
msText.textColor = 0xFF00;
msText.text = "MS: ";
addChild(msText);
memText.y = 20;
memText.textColor = 0xFFFF;
memText.text = "MEM: ";
addChild(memText);
graph = new BitmapData(65, 50, false, 51);
var _local2:Bitmap = new Bitmap(graph);
_local2.y = 40;
addChild(_local2);
rectangle = new Rectangle(0, 0, 1, graph.height);
addEventListener(MouseEvent.CLICK, onClick);
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
addEventListener(Event.ENTER_FRAME, update);
}
private function onClick(_arg1:MouseEvent):void{
if (this.mouseY > (this.height * 0.35)){
stage.frameRate--;
} else {
stage.frameRate++;
};
fpsText.text = ((("FPS: " + fps) + " / ") + stage.frameRate);
}
}
}//package AKEngine.debug
Section 10
//TraceAppender (AKEngine.debug.TraceAppender)
package AKEngine.debug {
public class TraceAppender implements ILogAppender {
public function addLogMessage(_arg1:String, _arg2:String, _arg3:String):void{
trace(((((_arg1 + ": ") + _arg2) + " - ") + _arg3));
}
}
}//package AKEngine.debug
Section 11
//UIAppender (AKEngine.debug.UIAppender)
package AKEngine.debug {
import flash.events.*;
import AKEngine.*;
import AKEngine.managers.*;
public class UIAppender implements ILogAppender {
protected var _logViewer:LogViewer;
protected static var _hotKey:uint;
public function UIAppender(){
AKE.instance.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
_hotKey = InputManager.instance.TILDE;
_logViewer = new LogViewer();
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode != _hotKey){
return;
};
if (_logViewer){
if (_logViewer.parent){
_logViewer.parent.removeChild(_logViewer);
_logViewer.deactivate();
} else {
AKE.instance.stage.addChild(_logViewer);
_logViewer.activate();
};
};
}
public function addLogMessage(_arg1:String, _arg2:String, _arg3:String):void{
if (_logViewer){
_logViewer.addLogMessage(_arg1, _arg2, _arg3);
};
}
public static function set hotKey(_arg1:uint):void{
Logger.print(UIAppender, ("Setting hotKey to: " + _arg1));
_hotKey = _arg1;
}
}
}//package AKEngine.debug
Section 12
//Circle (AKEngine.entity.box2d.custom.Circle)
package AKEngine.entity.box2d.custom {
import flash.display.*;
import AKEngine.managers.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Circle extends Box2DEntity {
public function Circle(_arg1:Box2DWorld, _arg2:CircleParams){
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local3:BitmapData;
var _local1:CircleParams = (params as CircleParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.textureName);
_local3 = (new _local2(0, 0) as BitmapData);
skin = new Sprite();
skin.graphics.beginBitmapFill(_local3, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
skin.graphics.drawCircle(0, 0, _local1.radius);
skin.graphics.endFill();
}
override public function changeSkin():void{
var _local1:CircleParams = (params as CircleParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.textureName);
var _local3:BitmapData = (new _local2(0, 0) as BitmapData);
skin.graphics.clear();
skin.graphics.beginBitmapFill(_local3, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
skin.graphics.drawCircle(0, 0, _local1.radius);
skin.graphics.endFill();
}
override protected function createBody():void{
var _local1:CircleParams;
_local1 = (params as CircleParams);
var _local2:b2CircleShape = new b2CircleShape((_local1.radius / (_world as Box2DWorld).physScale));
var _local3:b2BodyDef = new b2BodyDef();
_local3.position.Set((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local3.angle = _local1.rotation;
_local3.bullet = _local1.isBullet;
_local3.fixedRotation = _local1.isFixedRotation;
_local3.linearDamping = _local1.linearDamping;
_local3.angularDamping = _local1.angularDamping;
if (_local1.isStatic){
_local3.type = b2Body.b2_staticBody;
} else {
_local3.type = b2Body.b2_dynamicBody;
};
body = (_world as Box2DWorld).physWorld.CreateBody(_local3);
var _local4:b2FixtureDef = new b2FixtureDef();
_local4.shape = _local2;
_local4.density = _local1.density;
_local4.friction = _local1.friction;
_local4.restitution = _local1.restitution;
_local4.isSensor = _local1.isSensor;
_local4.filter.categoryBits = _local1.categoryBits;
_local4.filter.maskBits = _local1.maskBits;
_local4.filter.groupIndex = _local1.groupIndex;
_local4.userData = this;
body.CreateFixture(_local4);
}
}
}//package AKEngine.entity.box2d.custom
Section 13
//CircleParams (AKEngine.entity.box2d.custom.CircleParams)
package AKEngine.entity.box2d.custom {
import AKEngine.entity.box2d.*;
public class CircleParams extends Box2DEntityParams {
public var radius:Number;
public var textureName:String;
public function CircleParams(_arg1:Object=null){
radius = 0;
textureName = "";
super(_arg1);
customClass = Circle;
xmlTag = "Circle";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
radius = parseFloat(_arg1.@radius);
textureName = _arg1.@textureName;
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
rotation = parseFloat(_arg1.@rotation);
density = parseFloat(_arg1.@density);
friction = parseFloat(_arg1.@friction);
restitution = parseFloat(_arg1.@restitution);
linearDamping = parseFloat(_arg1.@linearDamping);
angularDamping = parseFloat(_arg1.@angularDamping);
isFixedRotation = (_arg1.@isFixedRotation.toLowerCase() == "true");
isStatic = (_arg1.@isStatic.toLowerCase() == "true");
isSensor = (_arg1.@isSensor.toLowerCase() == "true");
isBullet = (_arg1.@isBullet.toLowerCase() == "true");
categoryBits = parseInt(_arg1.@categoryBits);
maskBits = parseInt(_arg1.@maskBits);
groupIndex = parseInt(_arg1.@groupIndex);
}
override public function clone(){
return (new CircleParams({forcedName:forcedName, radius:radius, textureName:textureName, layer:layer, x:x, y:y, rotation:rotation, density:density, friction:friction, restitution:restitution, linearDamping:linearDamping, angularDamping:angularDamping, isFixedRotation:isFixedRotation, isStatic:isStatic, isSensor:isSensor, isBullet:isBullet, categoryBits:categoryBits, maskBits:maskBits, groupIndex:groupIndex}));
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@radius = radius;
_local1.@textureName = textureName;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@rotation = rotation;
_local1.@density = density;
_local1.@friction = friction;
_local1.@restitution = restitution;
_local1.@linearDamping = linearDamping;
_local1.@angularDamping = angularDamping;
_local1.@isFixedRotation = isFixedRotation;
_local1.@isStatic = isStatic;
_local1.@isSensor = isSensor;
_local1.@isBullet = isBullet;
_local1.@categoryBits = categoryBits;
_local1.@maskBits = maskBits;
_local1.@groupIndex = groupIndex;
return (_local1);
}
}
}//package AKEngine.entity.box2d.custom
Section 14
//DistanceJoint (AKEngine.entity.box2d.custom.DistanceJoint)
package AKEngine.entity.box2d.custom {
import flash.display.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
public class DistanceJoint extends Box2DJoint {
public function DistanceJoint(_arg1:Box2DWorld, _arg2:DistanceJointParams){
super(_arg1, _arg2);
}
override public function postUpdate(_arg1:Number):void{
if (isDead){
parent.removeChild(_name);
return;
};
var _local2:b2Vec2 = joint.GetAnchorA().Copy();
position.x = (_local2.x * (_world as Box2DWorld).physScale);
position.y = (_local2.y * (_world as Box2DWorld).physScale);
container.x = (position.x - (_world.camera.x - (_world.camera.width / 2)));
container.y = (position.y - (_world.camera.y - (_world.camera.height / 2)));
var _local3:b2Vec2 = joint.GetAnchorA().Copy();
var _local4:b2Vec2 = joint.GetAnchorB().Copy();
_local3.Multiply((_world as Box2DWorld).physScale);
_local4.Multiply((_world as Box2DWorld).physScale);
skin.graphics.clear();
skin.graphics.lineStyle(2, 16301068);
skin.graphics.moveTo(0, 0);
skin.graphics.lineTo((_local4.x - _local3.x), (_local4.y - _local3.y));
}
override protected function createSkin():void{
var _local1:DistanceJointParams = (params as DistanceJointParams);
skin = new Sprite();
var _local2:b2Vec2 = joint.GetAnchorA().Copy();
var _local3:b2Vec2 = joint.GetAnchorB().Copy();
_local2.Multiply((_world as Box2DWorld).physScale);
_local3.Multiply((_world as Box2DWorld).physScale);
skin.graphics.clear();
skin.graphics.lineStyle(2, 16301068);
skin.graphics.moveTo(0, 0);
skin.graphics.lineTo((_local3.x - _local2.x), (_local3.y - _local2.y));
}
override public function createJoint():void{
var _local2:b2Body;
var _local3:b2Body;
var _local6:Box2DEntity;
var _local7:b2Vec2;
var _local8:Array;
var _local9:Box2DEntity;
var _local10:b2DistanceJointDef;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local1:DistanceJointParams = (params as DistanceJointParams);
var _local4:b2Vec2 = _world.worldToScreen(new b2Vec2(_local1.x, _local1.y));
var _local5:Array = getBox2DEntitiesAtPoint(_local4.x, _local4.y);
if (_local5.length > 0){
_local6 = (_local5[0] as Box2DEntity);
_local2 = _local6.body;
_local7 = _world.worldToScreen(new b2Vec2(_local1.x2, _local1.y2));
_local8 = getBox2DEntitiesAtPoint(_local7.x, _local7.y);
if (_local8.length > 0){
_local9 = (_local8[0] as Box2DEntity);
_local3 = _local9.body;
_local10 = new b2DistanceJointDef();
_local11 = new b2Vec2((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local12 = new b2Vec2((_local1.x2 / (_world as Box2DWorld).physScale), (_local1.y2 / (_world as Box2DWorld).physScale));
_local10.collideConnected = _local1.collideConnected;
_local10.Initialize(_local2, _local3, _local11, _local12);
joint = ((_world as Box2DWorld).physWorld.CreateJoint(_local10) as b2DistanceJoint);
};
};
}
}
}//package AKEngine.entity.box2d.custom
Section 15
//DistanceJointParams (AKEngine.entity.box2d.custom.DistanceJointParams)
package AKEngine.entity.box2d.custom {
import AKEngine.entity.box2d.*;
public class DistanceJointParams extends Box2DJointParams {
public var y2:Number;
public var x2:Number;
public function DistanceJointParams(_arg1:Object=null){
x2 = 0;
y2 = 0;
super(_arg1);
customClass = DistanceJoint;
xmlTag = "DistanceJoint";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
x2 = parseFloat(_arg1.@x2);
y2 = parseFloat(_arg1.@y2);
collideConnected = (_arg1.@collideConnected.toLowerCase() == "true");
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@x2 = x2;
_local1.@y2 = y2;
_local1.@collideConnected = collideConnected;
return (_local1);
}
override public function clone(){
return (new DistanceJointParams({forcedName:forcedName, layer:layer, x:x, y:y, x2:x2, y2:y2, collideConnected:collideConnected}));
}
}
}//package AKEngine.entity.box2d.custom
Section 16
//Hinge (AKEngine.entity.box2d.custom.Hinge)
package AKEngine.entity.box2d.custom {
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
public class Hinge extends Box2DJoint {
public function Hinge(_arg1:Box2DWorld, _arg2:HingeParams){
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local1:HingeParams = (params as HingeParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.skinName);
skin = new (_local2);
}
override public function createJoint():void{
var _local2:b2Body;
var _local3:b2Body;
var _local6:b2RevoluteJointDef;
var _local7:b2Vec2;
var _local1:HingeParams = (params as HingeParams);
var _local4:b2Vec2 = _world.worldToScreen(new b2Vec2(_local1.x, _local1.y));
var _local5:Array = getBox2DEntitiesAtPoint(_local4.x, _local4.y);
if (_local5.length > 0){
_local2 = _local5[0].body;
if (_local5.length > 1){
_local3 = _local5[1].body;
} else {
_local3 = (_world as Box2DWorld).physWorld.GetGroundBody();
};
_local6 = new b2RevoluteJointDef();
_local7 = new b2Vec2((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local6.Initialize(_local2, _local3, _local7);
joint = ((_world as Box2DWorld).physWorld.CreateJoint(_local6) as b2RevoluteJoint);
};
}
}
}//package AKEngine.entity.box2d.custom
Section 17
//HingeParams (AKEngine.entity.box2d.custom.HingeParams)
package AKEngine.entity.box2d.custom {
import AKEngine.entity.box2d.*;
public class HingeParams extends Box2DJointParams {
public var skinName:String;
public function HingeParams(_arg1:Object=null){
skinName = "";
super(_arg1);
customClass = Hinge;
xmlTag = "Hinge";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
skinName = _arg1.@skinName;
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@skinName = skinName;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
return (_local1);
}
override public function clone(){
return (new HingeParams({forcedName:forcedName, skinName:skinName, layer:layer, x:x, y:y}));
}
}
}//package AKEngine.entity.box2d.custom
Section 18
//Motor (AKEngine.entity.box2d.custom.Motor)
package AKEngine.entity.box2d.custom {
import flash.display.*;
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
public class Motor extends Box2DJoint {
public var skinCW:Sprite;
public var skinCCW:Sprite;
public function Motor(_arg1:Box2DWorld, _arg2:MotorParams){
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local1:MotorParams = (params as MotorParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.skinName);
skin = new (_local2);
skinCW = (skin.getChildByName("CW") as Sprite);
skinCCW = (skin.getChildByName("CCW") as Sprite);
skinCW.visible = false;
skinCCW.visible = false;
if (_local1.isReversed){
skinCW.visible = true;
} else {
skinCCW.visible = true;
};
}
override public function createJoint():void{
var _local2:b2Body;
var _local3:b2Body;
var _local6:b2RevoluteJointDef;
var _local7:b2Vec2;
var _local1:MotorParams = (params as MotorParams);
var _local4:b2Vec2 = _world.worldToScreen(new b2Vec2(_local1.x, _local1.y));
var _local5:Array = getBox2DEntitiesAtPoint(_local4.x, _local4.y);
if (_local5.length > 0){
_local2 = _local5[0].body;
if (_local5.length > 1){
_local3 = _local5[1].body;
} else {
_local3 = (_world as Box2DWorld).physWorld.GetGroundBody();
};
_local6 = new b2RevoluteJointDef();
_local7 = new b2Vec2((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local6.Initialize(_local2, _local3, _local7);
_local6.enableMotor = true;
_local6.motorSpeed = _local1.motorSpeed;
_local6.maxMotorTorque = _local1.maxTorque;
joint = ((_world as Box2DWorld).physWorld.CreateJoint(_local6) as b2RevoluteJoint);
};
}
override public function dispose():void{
skinCW = null;
skinCCW = null;
super.dispose();
}
}
}//package AKEngine.entity.box2d.custom
Section 19
//MotorParams (AKEngine.entity.box2d.custom.MotorParams)
package AKEngine.entity.box2d.custom {
import AKEngine.entity.box2d.*;
public class MotorParams extends Box2DJointParams {
public var skinName:String;
public var isReversed:Boolean;
public var maxTorque:Number;
public var motorSpeed:Number;
public function MotorParams(_arg1:Object=null){
skinName = "";
motorSpeed = 0;
maxTorque = 0;
isReversed = false;
super(_arg1);
customClass = Motor;
xmlTag = "Motor";
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@skinName = skinName;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@motorSpeed = motorSpeed;
_local1.@maxTorque = maxTorque;
_local1.@isReversed = isReversed;
return (_local1);
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
skinName = _arg1.@skinName;
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
motorSpeed = parseFloat(_arg1.@motorSpeed);
maxTorque = parseFloat(_arg1.@maxTorque);
isReversed = (_arg1.@isReversed.toLowerCase() == "true");
}
override public function clone(){
return (new MotorParams({forcedName:forcedName, skinName:skinName, layer:layer, x:x, y:y, motorSpeed:motorSpeed, maxTorque:maxTorque, isReversed:isReversed}));
}
}
}//package AKEngine.entity.box2d.custom
Section 20
//Poly (AKEngine.entity.box2d.custom.Poly)
package AKEngine.entity.box2d.custom {
import flash.display.*;
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Poly extends Box2DEntity {
public function Poly(_arg1:Box2DWorld, _arg2:PolyParams){
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local1:PolyParams;
var _local5:b2Vec2;
_local1 = (params as PolyParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.textureName);
var _local3:BitmapData = (new _local2(0, 0) as BitmapData);
skin = new Sprite();
skin.graphics.beginBitmapFill(_local3, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
skin.graphics.moveTo(_local1.vertices[0].x, _local1.vertices[0].y);
var _local4 = 1;
while (_local4 < _local1.vertices.length) {
_local5 = _local1.vertices[_local4];
skin.graphics.lineTo(_local5.x, _local5.y);
_local4++;
};
skin.graphics.lineTo(_local1.vertices[0].x, _local1.vertices[0].y);
skin.graphics.endFill();
}
override public function changeSkin():void{
var _local5:b2Vec2;
var _local1:PolyParams = (params as PolyParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.textureName);
var _local3:BitmapData = (new _local2(0, 0) as BitmapData);
skin.graphics.clear();
skin.graphics.beginBitmapFill(_local3, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
skin.graphics.moveTo(_local1.vertices[0].x, _local1.vertices[0].y);
var _local4 = 1;
while (_local4 < _local1.vertices.length) {
_local5 = _local1.vertices[_local4];
skin.graphics.lineTo(_local5.x, _local5.y);
_local4++;
};
skin.graphics.lineTo(_local1.vertices[0].x, _local1.vertices[0].y);
skin.graphics.endFill();
}
override protected function createBody():void{
var _local1:PolyParams;
var _local5:b2BodyDef;
var _local7:b2Vec2;
_local1 = (params as PolyParams);
if (_local1.vertices.length < 3){
throw (new Error((("<PolyEntity> " + name) + " vertices count < 3!")));
};
var _local2:b2PolygonShape = new b2PolygonShape();
var _local3:Array = [];
var _local4:int;
while (_local4 < _local1.vertices.length) {
_local7 = (_local1.vertices[_local4] as b2Vec2).Copy();
_local7.Multiply((1 / (_world as Box2DWorld).physScale));
_local3.push(_local7);
_local4++;
};
_local2.SetAsArray(_local3);
_local5 = new b2BodyDef();
_local5.position.Set((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local5.angle = _local1.rotation;
_local5.bullet = _local1.isBullet;
_local5.fixedRotation = _local1.isFixedRotation;
_local5.linearDamping = _local1.linearDamping;
_local5.angularDamping = _local1.angularDamping;
if (_local1.isStatic){
_local5.type = b2Body.b2_staticBody;
} else {
_local5.type = b2Body.b2_dynamicBody;
};
body = (_world as Box2DWorld).physWorld.CreateBody(_local5);
var _local6:b2FixtureDef = new b2FixtureDef();
_local6.shape = _local2;
_local6.density = _local1.density;
_local6.friction = _local1.friction;
_local6.restitution = _local1.restitution;
_local6.isSensor = _local1.isSensor;
_local6.filter.categoryBits = _local1.categoryBits;
_local6.filter.maskBits = _local1.maskBits;
_local6.filter.groupIndex = _local1.groupIndex;
_local6.userData = this;
body.CreateFixture(_local6);
}
}
}//package AKEngine.entity.box2d.custom
Section 21
//PolyParams (AKEngine.entity.box2d.custom.PolyParams)
package AKEngine.entity.box2d.custom {
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
public class PolyParams extends Box2DEntityParams {
public var textureName:String;
public var vertices:Array;
public function PolyParams(_arg1:Object=null){
textureName = "";
super(_arg1);
customClass = Poly;
xmlTag = "Poly";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
var _local2:int = parseInt(_arg1.@numVerts);
var _local3:Array = [];
var _local4:int;
while (_local4 < _local2) {
_local3.push(new b2Vec2(parseFloat(_arg1.@[(("v" + _local4) + "x")]), parseFloat(_arg1.@[(("v" + _local4) + "y")])));
_local4++;
};
vertices = _local3;
textureName = _arg1.@textureName;
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
rotation = parseFloat(_arg1.@rotation);
density = parseFloat(_arg1.@density);
friction = parseFloat(_arg1.@friction);
restitution = parseFloat(_arg1.@restitution);
linearDamping = parseFloat(_arg1.@linearDamping);
angularDamping = parseFloat(_arg1.@angularDamping);
isFixedRotation = (_arg1.@isFixedRotation.toLowerCase() == "true");
isStatic = (_arg1.@isStatic.toLowerCase() == "true");
isSensor = (_arg1.@isSensor.toLowerCase() == "true");
isBullet = (_arg1.@isBullet.toLowerCase() == "true");
categoryBits = parseInt(_arg1.@categoryBits);
maskBits = parseInt(_arg1.@maskBits);
groupIndex = parseInt(_arg1.@groupIndex);
}
override public function clone(){
return (new PolyParams({forcedName:forcedName, vertices:vertices.concat(), textureName:textureName, layer:layer, x:x, y:y, rotation:rotation, density:density, friction:friction, restitution:restitution, linearDamping:linearDamping, angularDamping:angularDamping, isFixedRotation:isFixedRotation, isStatic:isStatic, isSensor:isSensor, isBullet:isBullet, categoryBits:categoryBits, maskBits:maskBits, groupIndex:groupIndex}));
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@numVerts = vertices.length;
var _local2:int;
while (_local2 < vertices.length) {
_local1.@[(("v" + _local2) + "x")] = vertices[_local2].x;
_local1.@[(("v" + _local2) + "y")] = vertices[_local2].y;
_local2++;
};
_local1.@textureName = textureName;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@rotation = rotation;
_local1.@density = density;
_local1.@friction = friction;
_local1.@restitution = restitution;
_local1.@linearDamping = linearDamping;
_local1.@angularDamping = angularDamping;
_local1.@isFixedRotation = isFixedRotation;
_local1.@isStatic = isStatic;
_local1.@isSensor = isSensor;
_local1.@isBullet = isBullet;
_local1.@categoryBits = categoryBits;
_local1.@maskBits = maskBits;
_local1.@groupIndex = groupIndex;
return (_local1);
}
}
}//package AKEngine.entity.box2d.custom
Section 22
//Rect (AKEngine.entity.box2d.custom.Rect)
package AKEngine.entity.box2d.custom {
import flash.display.*;
import AKEngine.managers.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Rect extends Box2DEntity {
public function Rect(_arg1:Box2DWorld, _arg2:RectParams){
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local3:BitmapData;
var _local1:RectParams = (params as RectParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.textureName);
_local3 = (new _local2(0, 0) as BitmapData);
skin = new Sprite();
skin.graphics.beginBitmapFill(_local3, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
skin.graphics.drawRect((-(_local1.width) / 2), (-(_local1.height) / 2), _local1.width, _local1.height);
skin.graphics.endFill();
skin.rotation = _local1.rotation;
}
override public function changeSkin():void{
var _local1:RectParams = (params as RectParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.textureName);
var _local3:BitmapData = (new _local2(0, 0) as BitmapData);
skin.graphics.clear();
skin.graphics.beginBitmapFill(_local3, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
skin.graphics.drawRect((-(_local1.width) / 2), (-(_local1.height) / 2), _local1.width, _local1.height);
skin.graphics.endFill();
}
override protected function createBody():void{
var _local1:RectParams;
_local1 = (params as RectParams);
var _local2:b2PolygonShape = new b2PolygonShape();
_local2.SetAsBox(((_local1.width / 2) / (_world as Box2DWorld).physScale), ((_local1.height / 2) / (_world as Box2DWorld).physScale));
var _local3:b2BodyDef = new b2BodyDef();
_local3.position.Set((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local3.angle = _local1.rotation;
_local3.bullet = _local1.isBullet;
_local3.fixedRotation = _local1.isFixedRotation;
_local3.linearDamping = _local1.linearDamping;
_local3.angularDamping = _local1.angularDamping;
if (_local1.isStatic){
_local3.type = b2Body.b2_staticBody;
} else {
_local3.type = b2Body.b2_dynamicBody;
};
body = (_world as Box2DWorld).physWorld.CreateBody(_local3);
var _local4:b2FixtureDef = new b2FixtureDef();
_local4.shape = _local2;
_local4.density = _local1.density;
_local4.friction = _local1.friction;
_local4.restitution = _local1.restitution;
_local4.isSensor = _local1.isSensor;
_local4.filter.categoryBits = _local1.categoryBits;
_local4.filter.maskBits = _local1.maskBits;
_local4.filter.groupIndex = _local1.groupIndex;
_local4.userData = this;
body.CreateFixture(_local4);
}
}
}//package AKEngine.entity.box2d.custom
Section 23
//RectParams (AKEngine.entity.box2d.custom.RectParams)
package AKEngine.entity.box2d.custom {
import AKEngine.entity.box2d.*;
public class RectParams extends Box2DEntityParams {
public var textureName:String;
public var height:Number;
public var width:Number;
public function RectParams(_arg1:Object=null){
width = 0;
height = 0;
textureName = "";
super(_arg1);
customClass = Rect;
xmlTag = "Rect";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
width = parseFloat(_arg1.@width);
height = parseFloat(_arg1.@height);
textureName = _arg1.@textureName;
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
rotation = parseFloat(_arg1.@rotation);
density = parseFloat(_arg1.@density);
friction = parseFloat(_arg1.@friction);
restitution = parseFloat(_arg1.@restitution);
linearDamping = parseFloat(_arg1.@linearDamping);
angularDamping = parseFloat(_arg1.@angularDamping);
isFixedRotation = (_arg1.@isFixedRotation.toLowerCase() == "true");
isStatic = (_arg1.@isStatic.toLowerCase() == "true");
isSensor = (_arg1.@isSensor.toLowerCase() == "true");
isBullet = (_arg1.@isBullet.toLowerCase() == "true");
categoryBits = parseInt(_arg1.@categoryBits);
maskBits = parseInt(_arg1.@maskBits);
groupIndex = parseInt(_arg1.@groupIndex);
}
override public function clone(){
return (new RectParams({forcedName:forcedName, width:width, height:height, textureName:textureName, layer:layer, x:x, y:y, rotation:rotation, density:density, friction:friction, restitution:restitution, linearDamping:linearDamping, angularDamping:angularDamping, isFixedRotation:isFixedRotation, isStatic:isStatic, isSensor:isSensor, isBullet:isBullet, categoryBits:categoryBits, maskBits:maskBits, groupIndex:groupIndex}));
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@width = width;
_local1.@height = height;
_local1.@textureName = textureName;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@rotation = rotation;
_local1.@density = density;
_local1.@friction = friction;
_local1.@restitution = restitution;
_local1.@linearDamping = linearDamping;
_local1.@angularDamping = angularDamping;
_local1.@isFixedRotation = isFixedRotation;
_local1.@isStatic = isStatic;
_local1.@isSensor = isSensor;
_local1.@isBullet = isBullet;
_local1.@categoryBits = categoryBits;
_local1.@maskBits = maskBits;
_local1.@groupIndex = groupIndex;
return (_local1);
}
}
}//package AKEngine.entity.box2d.custom
Section 24
//Box2DEntity (AKEngine.entity.box2d.Box2DEntity)
package AKEngine.entity.box2d {
import AKEngine.entity.*;
import Box2D.Dynamics.*;
public class Box2DEntity extends SkinnedEntity {
public var body:b2Body;
public function Box2DEntity(_arg1:Box2DWorld, _arg2:Box2DEntityParams){
super(_arg1, _arg2);
createBody();
}
override public function postUpdate(_arg1:Number):void{
position.x = (body.GetWorldCenter().x * (_world as Box2DWorld).physScale);
position.y = (body.GetWorldCenter().y * (_world as Box2DWorld).physScale);
rotation = ((body.GetAngle() * 180) / Math.PI);
super.postUpdate(_arg1);
}
protected function createBody():void{
throw (new Error((("<Entity> " + name) + ": You should override createBody()!")));
}
override public function dispose():void{
(_world as Box2DWorld).physWorld.DestroyBody(body);
body = null;
super.dispose();
}
}
}//package AKEngine.entity.box2d
Section 25
//Box2DEntityParams (AKEngine.entity.box2d.Box2DEntityParams)
package AKEngine.entity.box2d {
import AKEngine.entity.*;
public class Box2DEntityParams extends SkinnedEntityParams {
public var angularDamping:Number;
public var friction:Number;
public var isSensor:Boolean;
public var isFixedRotation:Boolean;
public var isBullet:Boolean;
public var maskBits:uint;
public var groupIndex:int;
public var linearDamping:Number;
public var categoryBits:uint;
public var density:Number;
public var restitution:Number;
public var isStatic:Boolean;
public static const GROUP_F_CATEGORY:uint = 32;
public static const GROUP_D_CATEGORY:uint = 8;
public static const GROUP_C_CATEGORY:uint = 4;
public static const GROUP_B_CATEGORY:uint = 2;
public static const GROUP_A_CATEGORY:uint = 1;
public static const GROUP_G_CATEGORY:uint = 64;
public static const GROUP_E_CATEGORY:uint = 16;
public function Box2DEntityParams(_arg1:Object=null){
density = 1;
friction = 0.2;
restitution = 0.2;
linearDamping = 0;
angularDamping = 0;
isFixedRotation = false;
isStatic = false;
isSensor = false;
isBullet = false;
categoryBits = GROUP_A_CATEGORY;
maskBits = GROUP_A_CATEGORY;
groupIndex = 0;
super(_arg1);
customClass = Box2DEntity;
xmlTag = "Box2DEntity";
}
}
}//package AKEngine.entity.box2d
Section 26
//Box2DJoint (AKEngine.entity.box2d.Box2DJoint)
package AKEngine.entity.box2d {
import flash.display.*;
import AKEngine.entity.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
public class Box2DJoint extends Entity {
public var container:Sprite;
public var position:b2Vec2;
public var joint:b2Joint;
protected var layer:int;
public var skin:Sprite;
public var rotation:Number;
public function Box2DJoint(_arg1:Box2DWorld, _arg2:Box2DJointParams){
super(_arg1, _arg2);
createJoint();
if (!joint){
isDead = true;
} else {
createSkin();
container = new Sprite();
container.addChild(skin);
position = new b2Vec2(_arg2.x, _arg2.y);
container.x = (position.x - (_world.camera.x - (_world.camera.width / 2)));
container.y = (position.y - (_world.camera.y - (_world.camera.height / 2)));
rotation = ((_arg2.rotation * 180) / Math.PI);
skin.rotation = rotation;
layer = _arg2.layer;
_world.getLayer(layer).addChild(container);
};
}
public function createJoint():void{
throw (new Error((("<Entity> " + name) + ": You should override createJoint()!")));
}
override public function postUpdate(_arg1:Number):void{
var _local2:b2Vec2;
if (isDead){
parent.removeChild(_name);
return;
};
_local2 = joint.GetAnchorA().Copy();
position.x = (_local2.x * (_world as Box2DWorld).physScale);
position.y = (_local2.y * (_world as Box2DWorld).physScale);
container.x = (position.x - (_world.camera.x - (_world.camera.width / 2)));
container.y = (position.y - (_world.camera.y - (_world.camera.height / 2)));
skin.rotation = rotation;
}
protected function getBox2DEntitiesAtPoint(_arg1:Number, _arg2:Number):Array{
var _local6:Box2DEntity;
var _local3:Array = [];
var _local4:Array = _world.getChildrenByType(Box2DEntity);
var _local5:int;
while (_local5 < _local4.length) {
_local6 = _local4[_local5];
if (_local6.skin.hitTestPoint(_arg1, _arg2, true)){
_local3.push(_local6);
};
_local5++;
};
_local3.sortOn("uniqueID", Array.DESCENDING);
return (_local3);
}
protected function createSkin():void{
throw (new Error((("<Entity> " + name) + ": You should override createSkin()!")));
}
public function getLayer():int{
if (layer == -1){
throw (new Error((("<Entity> " + name) + " cannot get layer. It has not been declared!")));
};
return (layer);
}
override public function dispose():void{
if (joint){
(_world as Box2DWorld).physWorld.DestroyJoint(joint);
joint = null;
};
_world.getLayer(layer).removeChild(container);
container = null;
skin = null;
super.dispose();
}
}
}//package AKEngine.entity.box2d
Section 27
//Box2DJointParams (AKEngine.entity.box2d.Box2DJointParams)
package AKEngine.entity.box2d {
import AKEngine.entity.*;
public class Box2DJointParams extends SkinnedEntityParams {
public var collideConnected:Boolean;
public function Box2DJointParams(_arg1:Object=null){
collideConnected = false;
super(_arg1);
customClass = Box2DJoint;
xmlTag = "Box2DJoint";
}
}
}//package AKEngine.entity.box2d
Section 28
//Box2DWorld (AKEngine.entity.box2d.Box2DWorld)
package AKEngine.entity.box2d {
import AKEngine.*;
import flash.display.*;
import AKEngine.debug.*;
import AKEngine.entity.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import flash.utils.*;
public class Box2DWorld extends World {
public var doDebagDraw:Boolean;
public var doSleep:Boolean;
public var gravity:b2Vec2;
public var physWorld:b2World;
public var iterations:int;
public var physScale:Number;
public var timeStep:Number;
public function Box2DWorld(_arg1:GameFactory, _arg2:Box2DWorldParams, _arg3:DisplayObjectContainer){
var _local4:b2DebugDraw;
var _local5:Sprite;
super(_arg1, _arg2, _arg3);
iterations = _arg2.iterations;
timeStep = _arg2.timeStep;
physScale = _arg2.physScale;
gravity = _arg2.gravity;
doSleep = _arg2.doSleep;
doDebagDraw = _arg2.doDebagDraw;
physWorld = new b2World(gravity, doSleep);
if (doDebagDraw){
_local4 = new b2DebugDraw();
_local5 = getLayer(MAX_LAYERS);
_local5.mouseEnabled = false;
_local5.mouseChildren = false;
_local4.SetSprite(_local5);
_local4.SetDrawScale(physScale);
_local4.SetFillAlpha(0.7);
_local4.SetLineThickness(1);
_local4.SetFlags(((b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit) | b2DebugDraw.e_centerOfMassBit));
physWorld.SetDebugDraw(_local4);
};
}
override public function dispose():void{
super.dispose();
physWorld = null;
}
override public function update(_arg1:Number):void{
Profiler.ensureAtRoot();
_platformTime = getTimer();
var _local2:Number = _platformTime;
if (lastTime < 0){
lastTime = _local2;
return;
};
var _local3:Number = (Number((_local2 - lastTime)) * _timeScale);
_elapsedTime = (_elapsedTime + _local3);
Profiler.enter("world_update");
updateChildren(_local3);
physWorld.Step(timeStep, iterations, iterations);
Profiler.exit("world_update");
Profiler.enter("world_postUpdate");
postUpdate(_local3);
Profiler.exit("world_postUpdate");
camera.update(_local3);
lastTime = _local2;
}
}
}//package AKEngine.entity.box2d
Section 29
//Box2DWorldParams (AKEngine.entity.box2d.Box2DWorldParams)
package AKEngine.entity.box2d {
import AKEngine.entity.*;
import Box2D.Common.Math.*;
public class Box2DWorldParams extends WorldParams {
public var doDebagDraw:Boolean;
public var doSleep:Boolean;
public var gravity:b2Vec2;
public var iterations:int;
public var physScale:Number;
public var timeStep:Number;
public function Box2DWorldParams(_arg1:Object=null){
iterations = (10 * 3);
timeStep = (1 / 30);
physScale = 30;
gravity = new b2Vec2(0, 10);
doSleep = true;
doDebagDraw = false;
super(_arg1);
customClass = Box2DWorld;
xmlTag = "Box2DWorld";
forcedName = "Box2DWorld";
}
}
}//package AKEngine.entity.box2d
Section 30
//IAnimated (AKEngine.entity.interfaces.IAnimated)
package AKEngine.entity.interfaces {
import flash.display.*;
import AKEngine.helpers.*;
public interface IAnimated {
function playAnimation(_arg1:String, _arg2:Boolean=false):void;
function addAnimation(_arg1:String, _arg2:MovieClip, _arg3:Number=0, _arg4:Boolean=true):void;
function getAnimations():Array;
function set defaultAnimation(_arg1:Animation):void;
function get defaultAnimation():Animation;
}
}//package AKEngine.entity.interfaces
Section 31
//IEntity (AKEngine.entity.interfaces.IEntity)
package AKEngine.entity.interfaces {
import flash.events.*;
import AKEngine.entity.*;
public interface IEntity extends IEventDispatcher {
function removeChildren():void;
function getChildrenByType(_arg1:Class):Array;
function getChildByName(_arg1:String):Entity;
function postUpdate(_arg1:Number):void;
function get parent():Entity;
function get name():String;
function update(_arg1:Number):void;
function removeChildrenByType(_arg1:Class):void;
function getChildren():Array;
function removeChild(_arg1:String):void;
function addChild(_arg1:Entity):void;
function dispose():void;
}
}//package AKEngine.entity.interfaces
Section 32
//ISpatial (AKEngine.entity.interfaces.ISpatial)
package AKEngine.entity.interfaces {
import flash.geom.*;
import AKEngine.helpers.*;
public interface ISpatial {
function containsPoint(_arg1:Point):Boolean;
function getX():Number;
function getY():Number;
function castRay(_arg1:Point, _arg2:Point, _arg3:RayHitInfo):Boolean;
function getBounds():Rectangle;
}
}//package AKEngine.entity.interfaces
Section 33
//IXMLSerializable (AKEngine.entity.interfaces.IXMLSerializable)
package AKEngine.entity.interfaces {
public interface IXMLSerializable {
function parseXML(_arg1:XML):void;
function toXML():XML;
}
}//package AKEngine.entity.interfaces
Section 34
//AnimatedEntity (AKEngine.entity.AnimatedEntity)
package AKEngine.entity {
import flash.display.*;
import AKEngine.helpers.*;
import flash.utils.*;
import AKEngine.entity.interfaces.*;
public class AnimatedEntity extends SkinnedEntity implements IAnimated {
private var _animations:Dictionary;
private var _finished:Boolean;
protected var _currentFrame:Number;
public var isAnimating:Boolean;
private var _defaultAnimation:Animation;
private var _elapsedTime:Number;
protected var _currentAnimation:Animation;
public function AnimatedEntity(_arg1:World, _arg2:AnimatedEntityParams){
super(_arg1, _arg2);
_animations = new Dictionary();
_currentAnimation = null;
_defaultAnimation = null;
_currentFrame = 0;
_elapsedTime = 0;
_finished = false;
isAnimating = false;
addAnimations();
}
public function get defaultAnimation():Animation{
return (_defaultAnimation);
}
public function set defaultAnimation(_arg1:Animation):void{
_defaultAnimation = _arg1;
}
override public function postUpdate(_arg1:Number):void{
if (((((!((_currentAnimation == null))) && ((_currentAnimation.delay > 0)))) && (((_currentAnimation.isLooped) || (!(_finished)))))){
_elapsedTime = (_elapsedTime + (_arg1 / 1000));
if (_elapsedTime > _currentAnimation.delay){
_elapsedTime = (_elapsedTime - _currentAnimation.delay);
if (_currentFrame >= _currentAnimation.movieClip.totalFrames){
_finished = true;
if (_currentAnimation.isLooped){
_currentFrame = 1;
} else {
playAnimation(_defaultAnimation.name);
};
} else {
_currentFrame++;
};
_currentAnimation.movieClip.gotoAndStop(_currentFrame);
};
};
super.postUpdate(_arg1);
}
override protected function createSkin():void{
skin = new Sprite();
}
public function addAnimation(_arg1:String, _arg2:MovieClip, _arg3:Number=0, _arg4:Boolean=true):void{
_animations[_arg1] = new Animation(_arg1, _arg2, _arg3, _arg4);
if (!_defaultAnimation){
_defaultAnimation = _animations[_arg1];
_currentAnimation = _animations[_arg1];
skin.addChild(_currentAnimation.movieClip);
};
}
protected function addAnimations():void{
throw (new Error((("<Entity> " + name) + ": You should override addAnimations()!")));
}
public function getAnimations():Array{
var _local2:Animation;
var _local1:Array = [];
for each (_local2 in _animations) {
_local1.push(_local2);
};
return (_local1);
}
public function playAnimation(_arg1:String, _arg2:Boolean=false):void{
if (((((!(_arg2)) && (!((_currentAnimation == null))))) && ((_arg1 == _currentAnimation.name)))){
return;
};
if (_animations[_arg1]){
skin.removeChild(_currentAnimation.movieClip);
_currentAnimation = _animations[_arg1];
skin.addChild(_currentAnimation.movieClip);
} else {
throw (new Error(((("<Entity> " + _arg1) + ": There was no animation with name: ") + _arg1)));
};
_currentFrame = 1;
_elapsedTime = 0;
if (_currentAnimation.delay <= 0){
_finished = true;
isAnimating = false;
} else {
_finished = false;
isAnimating = true;
};
_currentAnimation.movieClip.gotoAndStop(_currentFrame);
}
}
}//package AKEngine.entity
Section 35
//AnimatedEntityParams (AKEngine.entity.AnimatedEntityParams)
package AKEngine.entity {
public class AnimatedEntityParams extends SkinnedEntityParams {
public function AnimatedEntityParams(_arg1:Object=null){
super(_arg1);
customClass = AnimatedEntity;
xmlTag = "AnimatedEntity";
}
}
}//package AKEngine.entity
Section 36
//Camera (AKEngine.entity.Camera)
package AKEngine.entity {
import AKEngine.entity.interfaces.*;
public class Camera extends SpatialEntity {
public var target:ISpatial;// = null
public function Camera(_arg1:World, _arg2:CameraParams){
super(_arg1, _arg2);
}
override public function update(_arg1:Number):void{
if (target){
x = target.getX();
y = target.getY();
};
if ((x - (width / 2)) < 0){
x = (width / 2);
} else {
if ((x + (width / 2)) > _world.width){
x = (_world.width - (width / 2));
};
};
if ((y - (height / 2)) < 0){
y = (height / 2);
} else {
if ((y + (height / 2)) > _world.height){
y = (_world.height - (height / 2));
};
};
}
override public function dispose():void{
target = null;
super.dispose();
}
}
}//package AKEngine.entity
Section 37
//CameraParams (AKEngine.entity.CameraParams)
package AKEngine.entity {
public class CameraParams extends SpatialEntityParams {
public function CameraParams(_arg1:Object=null){
super(_arg1);
customClass = Camera;
xmlTag = "Camera";
}
}
}//package AKEngine.entity
Section 38
//Entity (AKEngine.entity.Entity)
package AKEngine.entity {
import flash.events.*;
import flash.utils.*;
import AKEngine.entity.interfaces.*;
public class Entity extends EventDispatcher implements IEntity {
protected var _name:String;
public var params:EntityParams;
protected var _parent:Entity;
protected var _world:World;
protected var _children:Dictionary;
public var uniqueID:Number;
public var isDead:Boolean;
protected static var _nextID:Number = 0;
public function Entity(_arg1:World, _arg2:EntityParams){
_world = _arg1;
this.params = _arg2;
_nextID++;
if ((((_arg2.forcedName == "null")) || ((_arg2.forcedName == null)))){
_name = ((this.params.xmlTag + "_") + _nextID);
} else {
_name = _arg2.forcedName;
};
uniqueID = _nextID;
_children = new Dictionary();
isDead = false;
}
override public function toString():String{
return ((("<" + _name) + ">"));
}
public function getChildByName(_arg1:String):Entity{
return (Entity(_children[_arg1]));
}
public function addChild(_arg1:Entity):void{
if (_arg1._parent == this){
return;
};
if (_arg1._parent){
delete _arg1._parent._children[_arg1._name];
};
if (_children[_arg1._name]){
throw (new Error("<Entity> There is an entity with this name already. Ensure names are unique."));
};
_arg1._parent = this;
_children[_arg1._name] = _arg1;
}
public function get name():String{
return (_name);
}
public function getChildrenByType(_arg1:Class):Array{
var _local3:Entity;
var _local2:Array = [];
for each (_local3 in _children) {
if ((_local3 is _arg1)){
_local2.push(_local3);
};
};
return (_local2);
}
public function update(_arg1:Number):void{
updateChildren(_arg1);
}
public function dispose():void{
var _local1:Entity;
params = null;
for each (_local1 in _children) {
_local1.dispose();
delete _children[_local1._name];
};
_children = null;
_parent = null;
_world = null;
}
public function removeChildren():void{
var _local1:Entity;
for each (_local1 in _children) {
_local1.dispose();
delete _children[_local1._name];
};
}
protected function updateChildren(_arg1:Number):void{
var _local2:Entity;
for each (_local2 in _children) {
_local2.update(_arg1);
};
}
public function postUpdate(_arg1:Number):void{
if (isDead){
parent.removeChild(_name);
} else {
postUpdateChildren(_arg1);
};
}
protected function postUpdateChildren(_arg1:Number):void{
var _local2:Entity;
for each (_local2 in _children) {
_local2.postUpdate(_arg1);
};
}
public function removeChildrenByType(_arg1:Class):void{
var _local2:Entity;
for each (_local2 in _children) {
if (!(_local2 is _arg1)){
} else {
_local2.dispose();
delete _children[_local2._name];
};
};
}
public function removeChild(_arg1:String):void{
var _local2:Entity = (_children[_arg1] as Entity);
if (_local2 == null){
throw (new Error("<Entity> There was no entity with a matching name."));
};
_local2.dispose();
delete _children[_arg1];
}
public function get parent():Entity{
return (_parent);
}
public function getChildren():Array{
var _local2:Entity;
var _local1:Array = [];
for each (_local2 in _children) {
_local1.push(_local2);
};
return (_local1);
}
}
}//package AKEngine.entity
Section 39
//EntityParams (AKEngine.entity.EntityParams)
package AKEngine.entity {
import AKEngine.entity.interfaces.*;
public class EntityParams implements IXMLSerializable {
public var xmlTag:String;
public var forcedName:String;
public var customClass:Class;
public var uniqueID:Number;// = 0
public function EntityParams(_arg1:Object=null){
customClass = Entity;
xmlTag = "Entity";
parseObject(_arg1);
}
public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
return (_local1);
}
public function parseXML(_arg1:XML):void{
}
private function parseObject(_arg1:Object):void{
var i:String;
var params = _arg1;
if (params){
for (i in params) {
try {
this[i] = params[i];
} catch(err:ReferenceError) {
trace(((("<EntityParams> " + "ERROR!: property \"") + i) + "\" does not exist!"));
};
};
};
}
public function clone(){
return (null);
}
}
}//package AKEngine.entity
Section 40
//SkinnedEntity (AKEngine.entity.SkinnedEntity)
package AKEngine.entity {
import flash.display.*;
import Box2D.Common.Math.*;
import flash.geom.*;
import AKEngine.helpers.*;
import AKEngine.entity.interfaces.*;
public class SkinnedEntity extends Entity implements ISpatial {
public var container:Sprite;
protected var layer:int;
public var position:b2Vec2;
public var skin:Sprite;
public var rotation:Number;
public function SkinnedEntity(_arg1:World, _arg2:SkinnedEntityParams){
super(_arg1, _arg2);
createSkin();
container = new Sprite();
container.addChild(skin);
position = new b2Vec2(_arg2.x, _arg2.y);
container.x = (position.x - (_world.camera.x - (_world.camera.width / 2)));
container.y = (position.y - (_world.camera.y - (_world.camera.height / 2)));
rotation = ((_arg2.rotation * 180) / Math.PI);
skin.rotation = rotation;
layer = _arg2.layer;
_world.getLayer(layer).addChild(container);
}
public function getX():Number{
return (position.x);
}
public function getY():Number{
return (position.y);
}
public function changeSkin():void{
throw (new Error((("<Entity> " + name) + ": You should override changeSkin()!")));
}
override public function postUpdate(_arg1:Number):void{
container.x = (position.x - (_world.camera.x - (_world.camera.width / 2)));
container.y = (position.y - (_world.camera.y - (_world.camera.height / 2)));
skin.rotation = rotation;
super.postUpdate(_arg1);
}
protected function createSkin():void{
throw (new Error((("<Entity> " + name) + ": You should override createSkin()!")));
}
public function getLayer():int{
if (layer == -1){
throw (new Error((("<Entity> " + name) + " cannot get layer. It has not been declared!")));
};
return (layer);
}
override public function dispose():void{
container.parent.removeChild(container);
container = null;
skin = null;
super.dispose();
}
public function getBounds():Rectangle{
return (skin.getBounds(_world.container));
}
public function containsPoint(_arg1:Point):Boolean{
var _local2:Rectangle = getBounds();
return (_local2.containsPoint(_arg1));
}
public function castRay(_arg1:Point, _arg2:Point, _arg3:RayHitInfo):Boolean{
return (false);
}
}
}//package AKEngine.entity
Section 41
//SkinnedEntityParams (AKEngine.entity.SkinnedEntityParams)
package AKEngine.entity {
public class SkinnedEntityParams extends EntityParams {
public var layer:int;
public var x:Number;
public var y:Number;
public var rotation:Number;
public function SkinnedEntityParams(_arg1:Object=null){
layer = 1;
x = 0;
y = 0;
rotation = 0;
super(_arg1);
customClass = SkinnedEntity;
xmlTag = "SkinnedEntity";
}
}
}//package AKEngine.entity
Section 42
//SpatialEntity (AKEngine.entity.SpatialEntity)
package AKEngine.entity {
import flash.geom.*;
import AKEngine.helpers.*;
import AKEngine.entity.interfaces.*;
public class SpatialEntity extends Entity implements ISpatial {
public var width:Number;
public var height:Number;
public var x:Number;
public var y:Number;
public function SpatialEntity(_arg1:World, _arg2:SpatialEntityParams){
super(_arg1, _arg2);
x = _arg2.x;
y = _arg2.y;
width = _arg2.width;
height = _arg2.height;
}
public function getX():Number{
return (x);
}
public function getY():Number{
return (y);
}
public function getBounds():Rectangle{
var _local1:Rectangle = new Rectangle((x - (width / 2)), (y - (height / 2)), width, height);
return (_local1);
}
public function castRay(_arg1:Point, _arg2:Point, _arg3:RayHitInfo):Boolean{
return (false);
}
public function containsPoint(_arg1:Point):Boolean{
var _local2:Rectangle = getBounds();
return (_local2.containsPoint(_arg1));
}
}
}//package AKEngine.entity
Section 43
//SpatialEntityParams (AKEngine.entity.SpatialEntityParams)
package AKEngine.entity {
public class SpatialEntityParams extends EntityParams {
public var width:Number;
public var height:Number;
public var x:Number;
public var y:Number;
public function SpatialEntityParams(_arg1:Object=null){
x = 0;
y = 0;
width = 0;
height = 0;
super(_arg1);
customClass = SpatialEntity;
xmlTag = "SpatialEntity";
}
}
}//package AKEngine.entity
Section 44
//World (AKEngine.entity.World)
package AKEngine.entity {
import AKEngine.*;
import flash.display.*;
import AKEngine.debug.*;
import Box2D.Common.Math.*;
import flash.utils.*;
public class World extends Entity {
public const MAX_LAYERS:int = 16;
public var container:Sprite;
public var stage:Stage;
public var width:Number;
public var factory:GameFactory;
protected var lastTime:int;// = -1
public var zoom:Number;// = 1
public var deepSprite:Sprite;
public var camera:Camera;
public var height:Number;
protected var _elapsedTime:Number;// = 0
public var entitiesParams:Array;
public var effectsSprite:Sprite;
protected var _timeScale:Number;// = 1
protected var _platformTime:int;// = 0
public function World(_arg1:GameFactory, _arg2:WorldParams, _arg3:DisplayObjectContainer){
var _local4:Sprite;
super(null, _arg2);
container = new Sprite();
deepSprite = new Sprite();
container.addChild(deepSprite);
var _local5:int;
while (_local5 < (MAX_LAYERS + 1)) {
_local4 = new Sprite();
container.addChild(_local4);
_local5++;
};
_arg3.addChild(container);
stage = container.stage;
effectsSprite = new Sprite();
container.addChild(effectsSprite);
this.factory = _arg1;
this.factory.world = this;
width = _arg2.width;
height = _arg2.height;
var _local6:CameraParams = new CameraParams({x:_arg2.cameraX, y:_arg2.cameraY, width:_arg2.cameraWidth, height:_arg2.cameraHeight});
camera = new Camera(this, _local6);
entitiesParams = [];
lastTime = -1;
_elapsedTime = 0;
}
public function getLayer(_arg1:int):Sprite{
if ((((_arg1 < 1)) || ((_arg1 > MAX_LAYERS)))){
throw (new Error(("<World> Value must be between 1 and " + MAX_LAYERS)));
};
return ((container.getChildAt(_arg1) as Sprite));
}
public function set timeScale(_arg1:Number):void{
_timeScale = _arg1;
}
public function screenToWorld(_arg1:b2Vec2):b2Vec2{
return (new b2Vec2((_arg1.x + (camera.x - (camera.width / 2))), (_arg1.y + (camera.y - (camera.height / 2)))));
}
override public function update(_arg1:Number):void{
Profiler.ensureAtRoot();
_platformTime = getTimer();
var _local2:Number = _platformTime;
if (lastTime < 0){
lastTime = _local2;
return;
};
var _local3:Number = (Number((_local2 - lastTime)) * _timeScale);
_elapsedTime = (_elapsedTime + _local3);
Profiler.enter("world_update");
updateChildren(_local3);
Profiler.exit("world_update");
Profiler.enter("world_postUpdate");
postUpdate(_local3);
Profiler.exit("world_postUpdate");
camera.update(_local3);
lastTime = _local2;
}
override public function dispose():void{
entitiesParams = [];
super.dispose();
factory = null;
camera = null;
effectsSprite = null;
}
public function get platformTime():Number{
return (_platformTime);
}
public function get elapsedTime():Number{
return (_elapsedTime);
}
override public function postUpdate(_arg1:Number):void{
var _local2:Entity;
var _local3:int;
for each (_local2 in _children) {
if (_local2.isDead){
_local3 = entitiesParams.indexOf(_local2.params);
entitiesParams.splice(_local3, 1);
removeChild(_local2.name);
} else {
_local2.postUpdate(_arg1);
};
};
}
public function createEntities():void{
var _local1:int;
while (_local1 < entitiesParams.length) {
factory.getEntity(entitiesParams[_local1], this);
_local1++;
};
}
public function worldToScreen(_arg1:b2Vec2):b2Vec2{
return (new b2Vec2(((_arg1.x - (camera.x - (camera.width / 2))) * zoom), ((_arg1.y - (camera.y - (camera.height / 2))) * zoom)));
}
public function get timeScale():Number{
return (_timeScale);
}
}
}//package AKEngine.entity
Section 45
//WorldParams (AKEngine.entity.WorldParams)
package AKEngine.entity {
public class WorldParams extends EntityParams {
public var cameraWidth:Number;
public var height:Number;
public var cameraHeight:Number;
public var width:Number;
public var cameraX:Number;
public var cameraY:Number;
public function WorldParams(_arg1:Object=null){
width = 640;
height = 480;
cameraX = 320;
cameraY = 240;
cameraWidth = 640;
cameraHeight = 480;
super(_arg1);
customClass = World;
xmlTag = "World";
forcedName = "World";
}
}
}//package AKEngine.entity
Section 46
//Animation (AKEngine.helpers.Animation)
package AKEngine.helpers {
import flash.display.*;
public class Animation {
public var movieClip:MovieClip;
public var delay:Number;
public var isLooped:Boolean;
public var name:String;
public function Animation(_arg1:String, _arg2:MovieClip, _arg3:Number=0, _arg4:Boolean=true){
this.name = _arg1;
delay = 0;
if (_arg3 > 0){
delay = (1 / _arg3);
};
this.movieClip = _arg2;
this.isLooped = _arg4;
}
}
}//package AKEngine.helpers
Section 47
//RayHitInfo (AKEngine.helpers.RayHitInfo)
package AKEngine.helpers {
import flash.geom.*;
import AKEngine.entity.interfaces.*;
public class RayHitInfo {
public var hitEntity:ISpatial;
public var normal:Point;
public var position:Point;
public var time:Number;
public function copyFrom(_arg1:RayHitInfo):void{
time = _arg1.time;
if (_arg1.position){
position = _arg1.position.clone();
} else {
position = null;
};
if (_arg1.normal){
normal = _arg1.normal.clone();
} else {
normal = null;
};
hitEntity = _arg1.hitEntity;
}
}
}//package AKEngine.helpers
Section 48
//TextHelper (AKEngine.helpers.TextHelper)
package AKEngine.helpers {
import flash.display.*;
import flash.text.*;
public class TextHelper {
public static function escapeHTMLText(_arg1:String):String{
var _local2:Array = [{char:"&", repl:"|amp|"}, {char:"<", repl:"<"}, {char:">", repl:">"}, {char:"'", repl:"'"}, {char:"\"", repl:"""}, {char:"|amp|", repl:"&"}];
var _local3:int;
while (_local3 < _local2.length) {
while (_arg1.indexOf(_local2[_local3].char) != -1) {
_arg1 = _arg1.replace(_local2[_local3].char, _local2[_local3].repl);
};
_local3++;
};
return (_arg1);
}
public static function createTextField(_arg1:DisplayObjectContainer=null, _arg2:int=0, _arg3:int=0, _arg4:Boolean=false, _arg5:Boolean=false):TextField{
var _local6:TextField = new TextField();
_local6.autoSize = TextFieldAutoSize.LEFT;
_local6.x = _arg2;
_local6.y = _arg3;
if (_arg4){
_local6.type = TextFieldType.INPUT;
};
_local6.mouseEnabled = _arg5;
if (_arg1){
_arg1.addChild(_local6);
};
return (_local6);
}
public static function createHtmlText(_arg1:String, _arg2:String="#000000", _arg3:int=12, _arg4:String="arial"):String{
return ((((((((("<font color='" + _arg2) + "' size='") + _arg3) + "' font='") + _arg4) + "' > ") + _arg1) + "</font>"));
}
public static function getFileExtension(_arg1:String):String{
var _local2:Number = _arg1.lastIndexOf(".");
if (_local2 == -1){
return ("");
};
return (_arg1.substr((_local2 + 1), _arg1.length));
}
}
}//package AKEngine.helpers
Section 49
//TypeHelper (AKEngine.helpers.TypeHelper)
package AKEngine.helpers {
import AKEngine.debug.*;
import flash.utils.*;
public class TypeHelper {
private static var _typeDescriptions:Dictionary = new Dictionary();
private static var _instantiators:Dictionary = new Dictionary();
public static function registerInstantiator(_arg1:String, _arg2:Function):void{
if (_instantiators[_arg1]){
Logger.warn("TypeHelper", "RegisterInstantiator", (("An instantiator for " + _arg1) + " has already been registered. It will be replaced."));
};
_instantiators[_arg1] = _arg2;
}
public static function getClassFromName(_arg1:String):Class{
return ((getDefinitionByName(_arg1) as Class));
}
public static function getClass(_arg1):Class{
if ((((_arg1 is Class)) || ((_arg1 == null)))){
return (_arg1);
};
return (Object(_arg1).constructor);
}
public static function instantiate(_arg1:String, _arg2:Boolean=false){
var className = _arg1;
var suppressError = _arg2;
if (className == "String"){
return ("");
};
if (className == "Class"){
return (Class);
};
if (_instantiators[className]){
return (_instantiators[className]());
};
try {
return (new (getDefinitionByName(className)));
} catch(e:Error) {
if (!suppressError){
Logger.warn(null, "Instantiate", ((("Failed to instantiate " + className) + " due to ") + e.toString()));
Logger.warn(null, "Instantiate", (((("Is " + className) + " included in your SWF? Make sure you call PBE.registerType(") + className) + "); somewhere in your project."));
};
};
return (null);
}
public static function getTypeDescription(_arg1):XML{
var _local2:String = getObjectClassName(_arg1);
if (!_typeDescriptions[_local2]){
_typeDescriptions[_local2] = describeType(_arg1);
};
return (_typeDescriptions[_local2]);
}
public static function getObjectClassName(_arg1):String{
return (getQualifiedClassName(_arg1));
}
public static function isDynamic(_arg1):Boolean{
if ((_arg1 is Class)){
Logger.error(_arg1, "isDynamic", "The object is a Class type, which is always dynamic");
return (true);
};
var _local2:XML = getTypeDescription(_arg1);
return ((_local2.@isDynamic == "true"));
}
public static function getTypeHint(_arg1, _arg2:String):String{
var _local4:XML;
var _local5:XML;
var _local3:XML = getTypeDescription(_arg1);
if (!_local3){
return (null);
};
for each (_local4 in _local3.*) {
if (_local4.@name != _arg2){
} else {
if (((!((_local4.name() == "variable"))) && (!((_local4.name() == "accessor"))))){
} else {
for each (_local5 in _local4.*) {
if (_local5.@name == "TypeHint"){
return (_local5.arg.@value.toString());
};
};
};
};
};
return (null);
}
public static function getClassDescription(_arg1:String):XML{
var className = _arg1;
if (!_typeDescriptions[className]){
try {
_typeDescriptions[className] = describeType(getDefinitionByName(className));
} catch(error:Error) {
return (null);
};
};
return (_typeDescriptions[className]);
}
public static function getFieldType(_arg1, _arg2:String):String{
var _local4:XML;
var _local5:XML;
var _local3:XML = getTypeDescription(_arg1);
for each (_local4 in _local3.child("accessor")) {
if (_local4.attribute("name") == _arg2){
return (_local4.attribute("type"));
};
};
for each (_local5 in _local3.child("variable")) {
if (_local5.attribute("name") == _arg2){
return (_local5.attribute("type"));
};
};
return (null);
}
}
}//package AKEngine.helpers
Section 50
//AssetsManager (AKEngine.managers.AssetsManager)
package AKEngine.managers {
import flash.events.*;
import flash.display.*;
import flash.system.*;
public class AssetsManager extends EventDispatcher {
private var Assets:Class;
private var appDomain:ApplicationDomain;
private static var _instance:AssetsManager;
public function AssetsManager(){
Assets = AssetsManager_Assets;
super();
}
public function initialize():void{
var _local1:Loader = new Loader();
_local1.contentLoaderInfo.addEventListener(Event.INIT, assetsInitHandler);
_local1.loadBytes(new Assets());
}
private function assetsInitHandler(_arg1:Event):void{
appDomain = _arg1.target.content.loaderInfo.applicationDomain;
dispatchEvent(new Event(Event.INIT));
}
public function getAssetClass(_arg1:String):Class{
if (!appDomain.hasDefinition(_arg1)){
trace((("<AssetsManager> Error: There is no definition of class '" + _arg1) + "'"));
return (null);
};
return ((appDomain.getDefinition(_arg1) as Class));
}
public static function get instance():AssetsManager{
if (_instance == null){
_instance = new (AssetsManager);
};
return (_instance);
}
}
}//package AKEngine.managers
Section 51
//AssetsManager_Assets (AKEngine.managers.AssetsManager_Assets)
package AKEngine.managers {
import mx.core.*;
public class AssetsManager_Assets extends ByteArrayAsset {
}
}//package AKEngine.managers
Section 52
//InputManager (AKEngine.managers.InputManager)
package AKEngine.managers {
import flash.events.*;
import flash.display.*;
public class InputManager {
public const BACKWARD_SLASH:int = 220;
public const LEFT:int = 37;
public const TWO:int = 50;
public const CLEAR:int = 12;
public const NUMPAD_DECIMAL:int = 110;
public const A:int = 65;
public const B:int = 66;
public const C:int = 67;
public const D:int = 68;
public const E:int = 69;
public const F:int = 70;
public const G:int = 71;
public const H:int = 72;
public const I:int = 73;
public const J:int = 74;
public const K:int = 75;
public const L:int = 76;
public const M:int = 77;
public const N:int = 78;
public const O:int = 79;
public const P:int = 80;
public const Q:int = 81;
public const R:int = 82;
public const S:int = 83;
public const T:int = 84;
public const U:int = 85;
public const V:int = 86;
public const W:int = 87;
public const X:int = 88;
public const Y:int = 89;
public const Z:int = 90;
public const ONE:int = 49;
public const SHIFT:int = 16;
public const PAGE_UP:int = 33;
public const NUM_LOCK:int = 144;
public const BACKSPACE:int = 8;
public const PAGE_DOWN:int = 34;
public const EIGHT:int = 56;
public const NUMPAD_ADD:int = 107;
public const UP:int = 38;
public const DOWN:int = 40;
public const F1:int = 112;
public const F3:int = 114;
public const ZERO:int = 48;
public const F7:int = 118;
public const F2:int = 113;
public const F4:int = 115;
public const F5:int = 116;
public const F6:int = 117;
public const ENTER:int = 13;
public const FIVE:int = 53;
public const F9:int = 120;
public const END:int = 35;
public const CLOSED_BRACKET:int = 221;
public const INSERT:int = 45;
public const NINE:int = 57;
public const SIX:int = 54;
public const UNDERSCORE:int = 189;
public const F8:int = 119;
public const NUMPAD_MULTIPLY:int = 106;
public const HOME:int = 36;
public const F10:int = 121;
public const F11:int = 122;
public const F12:int = 123;
public const F13:int = 124;
public const F14:int = 125;
public const F15:int = 126;
public const FOUR:int = 52;
public const TILDE:int = 192;
public const CONTROL:int = 17;
public const COLON:int = 186;
public const HELP:int = 47;
public const NUMPAD_ENTER:int = 108;
public const SPACEBAR:int = 32;
public const ESC:int = 27;
public const TAB:int = 9;
public const QUOTES:int = 222;
public const THREE:int = 51;
public const ALT:int = 18;
public const QUESTION_MARK:int = 191;
public const OPEN_BRACKET:int = 219;
public const NUMPAD_DIVIDE:int = 111;
public const DELETE:int = 46;
public const NUMPAD_0:int = 96;
public const NUMPAD_1:int = 97;
public const NUMPAD_2:int = 98;
public const NUMPAD_3:int = 99;
public const NUMPAD_4:int = 100;
public const NUMPAD_5:int = 101;
public const NUMPAD_6:int = 102;
public const NUMPAD_7:int = 103;
public const NUMPAD_8:int = 104;
public const NUMPAD_9:int = 105;
public const CAPS_LOCK:int = 20;
public const NUMPAD_SUBTRACT:int = 109;
public const EQUALS:int = 187;
public const SEVEN:int = 55;
public const RIGHT:int = 39;
private var _keyState:Array;
private var _stage:Stage;
private static var _instance:InputManager;
public function InputManager(){
_keyState = [];
var _local1:uint;
while (_local1 < 222) {
_keyState[_local1] = 0;
_local1++;
};
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
_keyState[_arg1.keyCode] = 1;
}
private function keyUpHandler(_arg1:KeyboardEvent):void{
_keyState[_arg1.keyCode] = -1;
}
public function isKeyReleased(_arg1:int):Boolean{
return ((_keyState[_arg1] == -1));
}
public function initialize(_arg1:Stage):void{
_stage = _arg1;
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
}
public function isKeyPressed(_arg1:int):Boolean{
return ((_keyState[_arg1] == 1));
}
public static function get instance():InputManager{
if (_instance == null){
_instance = new (InputManager);
};
return (_instance);
}
}
}//package AKEngine.managers
Section 53
//SoundManager (AKEngine.managers.SoundManager)
package AKEngine.managers {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class SoundManager extends EventDispatcher {
private var _soundChannels:Dictionary;
private var _currentMusic:Sound;
public var isMusicPlaying:Boolean;// = false
public var musicEnabled:Boolean;// = true
private var _pausedPosition:Number;
private var _sounds:Dictionary;
private var _musicTransform:SoundTransform;
private var _doesMusicLoop:Boolean;
public var soundEnabled:Boolean;// = true
private var _soundTransform:SoundTransform;
private var _musicChannel:SoundChannel;
private static var _instance:SoundManager;
public function SoundManager(){
_musicChannel = new SoundChannel();
_soundChannels = new Dictionary();
_musicTransform = new SoundTransform(1);
_soundTransform = new SoundTransform(1);
_sounds = new Dictionary();
}
public function playSound(_arg1:String, _arg2:Number=1, _arg3:int=0, _arg4:int=0):void{
if (_sounds[_arg1] == null){
throw (new Error((("<SoundManager> Sound: " + _arg1) + " does not exist!")));
};
if (musicEnabled){
_soundTransform.volume = _arg2;
_soundChannels[_arg1] = _sounds[_arg1].play(_arg3, _arg4, _soundTransform);
};
}
public function stopMusic():void{
_musicChannel.stop();
isMusicPlaying = false;
}
public function get soundVolume():Number{
return (_soundTransform.volume);
}
public function pauseMusic():void{
_pausedPosition = _musicChannel.position;
_musicChannel.stop();
isMusicPlaying = false;
}
public function playMusic(_arg1:String, _arg2:int=0, _arg3:Boolean=true):void{
if (_sounds[_arg1] == null){
throw (new Error((("<SoundManager> Sound: " + _arg1) + " does not exist!")));
};
this._doesMusicLoop = _arg3;
_currentMusic = _sounds[_arg1];
_musicChannel = _currentMusic.play(_arg2, (_doesMusicLoop) ? 9999 : 1, _musicTransform);
_musicChannel.addEventListener(Event.SOUND_COMPLETE, musicEndHandler);
isMusicPlaying = true;
}
public function set soundVolume(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
_soundTransform.volume = _arg1;
}
public function get musicVolume():Number{
return (_musicTransform.volume);
}
private function musicEndHandler(_arg1:Event):void{
isMusicPlaying = false;
dispatchEvent(_arg1.clone());
}
public function unpauseMusic():void{
_musicChannel = _currentMusic.play(_pausedPosition, (_doesMusicLoop) ? 9999 : 1, _musicTransform);
_musicChannel.addEventListener(Event.SOUND_COMPLETE, musicEndHandler);
isMusicPlaying = true;
}
public function stopSound(_arg1:String):void{
if (_soundChannels[_arg1] != null){
_soundChannels[_arg1].stop();
delete _soundChannels[_arg1];
};
}
public function registerSound(_arg1:Sound, _arg2:String):void{
_sounds[_arg2] = _arg1;
}
public function set musicVolume(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
_musicTransform.volume = (_arg1 * 0.5);
_musicChannel.soundTransform = _musicTransform;
}
public static function get instance():SoundManager{
if (_instance == null){
_instance = new (SoundManager);
};
return (_instance);
}
}
}//package AKEngine.managers
Section 54
//MathUtils (AKEngine.math.MathUtils)
package AKEngine.math {
import Box2D.Common.Math.*;
public class MathUtils {
public static function getRandomPolygon(_arg1:int, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):Array{
var _local6:Array;
var _local8:Number;
var _local12:Number;
var _local13:b2Vec2;
var _local14:b2Mat22;
_local6 = [];
var _local7:Number = ((_arg2 + _arg4) / 2);
_local8 = ((_arg3 + _arg5) / 2);
var _local9:Number = Math.min(_local7, _local8);
var _local10:Number = ((2 * Math.PI) / Number(_arg1));
var _local11:int;
while (_local11 < _arg1) {
_local12 = ((_local9 * 0.2) + Math.floor((Math.random() * ((_local9 - (_local9 * 0.2)) + 1))));
_local13 = new b2Vec2(_local12, 0);
_local14 = b2Mat22.FromAngle((_local11 * _local10));
var _temp1 = b2Math.MulMV(_local14, _local13);
_local13 = b2Math.MulMV(_local14, _local13);
_temp1.x = (_local13.x + _local7);
_local13.y = (_local13.y + _local8);
_local6.push(_local13);
_local11++;
};
return (_local6);
}
public static function isObjectOverlappingSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array):Boolean{
var _local4:int;
while (_local4 < _arg3.length) {
if (isLineIntersecting(_arg1, _arg2, _arg3[_local4], _arg3[(_local4 + 1)])){
return (true);
};
_local4++;
};
return (false);
}
public static function circleArea(_arg1:Number):Number{
return (((Math.PI * _arg1) * _arg1));
}
public static function doesRayIntersectCircle(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Boolean{
var _local5:b2Vec2 = b2Math.SubtractVV(_arg3, _arg1);
var _local6:Number = _local5.Length();
var _local7:Number = b2Math.Dot(_local5, _arg2);
var _local8:Number = ((_arg4 * _arg4) - ((_local6 * _local6) - (_local7 * _local7)));
return ((_local8 < 0));
}
public static function isCircleOverlapping(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Boolean{
var _local5:Number = b2Math.DistanceSquared(_arg1, _arg3);
var _local6:Number = (_arg2 + _arg4);
if (_local5 < (_local6 * _local6)){
return (true);
};
return (false);
}
public static function isLineIntersecting(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:b2Vec2):Boolean{
var _local5:Number = (((_arg1.y - _arg3.y) * (_arg4.x - _arg3.x)) - ((_arg1.x - _arg3.x) * (_arg4.y - _arg3.y)));
var _local6:Number = (((_arg1.y - _arg3.y) * (_arg2.x - _arg1.x)) - ((_arg1.x - _arg3.x) * (_arg2.y - _arg1.y)));
var _local7:Number = (((_arg2.x - _arg1.x) * (_arg4.y - _arg3.y)) - ((_arg2.y - _arg1.y) * (_arg4.x - _arg3.x)));
if (_local7 == 0){
return (false);
};
var _local8:Number = (1 / _local7);
var _local9:Number = (_local5 * _local8);
var _local10:Number = (_local6 * _local8);
if ((((((((_local9 > 0)) && ((_local9 < 1)))) && ((_local10 > 0)))) && ((_local10 < 1)))){
return (true);
};
return (false);
}
public static function isPointInCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2):Boolean{
var _local4:Number = b2Math.SubtractVV(_arg3, _arg1).LengthSquared();
if (_local4 < (_arg2 * _arg2)){
return (true);
};
return (false);
}
public static function getCircleIntersectionArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{
if (!isCircleOverlapping(_arg1, _arg2, _arg3, _arg4)){
return (0);
};
var _local5:Number = Math.sqrt((((_arg1.x - _arg3.x) * (_arg1.x - _arg3.x)) + ((_arg1.y - _arg3.y) * (_arg1.y - _arg3.y))));
var _local6:Number = (2 * Math.acos(((((_arg4 * _arg4) + (_local5 * _local5)) - (_arg2 * _arg2)) / ((_arg4 * _local5) * 2))));
var _local7:Number = (2 * Math.acos(((((_arg2 * _arg2) + (_local5 * _local5)) - (_arg4 * _arg4)) / ((_arg2 * _local5) * 2))));
var _local8:Number = ((((((0.5 * _local6) * _arg4) * _arg4) - (((0.5 * _arg4) * _arg4) * Math.sin(_local6))) + (((0.5 * _local7) * _arg2) * _arg2)) - (((0.5 * _arg2) * _arg2) * Math.sin(_local7)));
return (_local8);
}
public static function distToRayPlaneIntersect(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:b2Vec2):Number{
var _local5:Number = -(b2Math.Dot(_arg4, _arg3));
var _local6:Number = (b2Math.Dot(_arg4, _arg1) + _local5);
var _local7:Number = b2Math.Dot(_arg4, _arg2);
if ((((_local7 < 1E-5)) && ((_local7 > -1E-5)))){
return (-1);
};
return (-((_local6 / _local7)));
}
public static function isObjectsOverlapping(_arg1:Array, _arg2:Array):Boolean{
var _local4:int;
var _local3:int;
while (_local3 < _arg1.length) {
_local4 = 0;
while (_local4 < _arg2.length) {
if (isLineIntersecting(_arg2[_local4], _arg2[(_local4 + 1)], _arg1[_local3], _arg1[(_local3 + 1)])){
return (true);
};
_local4++;
};
_local3++;
};
return (false);
}
public static function getTangentPoints(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2):Boolean{
var _local9:Number;
var _local10:Number;
var _local6:b2Vec2 = b2Math.SubtractVV(_arg3, _arg1);
var _local7:Number = _local6.LengthSquared();
var _local8:Number = (_arg2 * _arg2);
if (_local7 <= _local8){
return (false);
};
_local9 = (1 / _local7);
_local10 = Math.sqrt(Math.abs((_local7 - _local8)));
_arg4.x = (_arg1.x + ((_arg2 * ((_arg2 * _local6.x) - (_local6.y * _local10))) * _local9));
_arg4.y = (_arg1.y + ((_arg2 * ((_arg2 * _local6.y) - (_local6.x * _local10))) * _local9));
_arg5.x = (_arg1.x + ((_arg2 * ((_arg2 * _local6.x) - (_local6.y * _local10))) * _local9));
_arg5.y = (_arg1.y + ((_arg2 * ((_arg2 * _local6.y) - (_local6.x * _local10))) * _local9));
return (true);
}
public static function isCircleOverlappingSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Boolean{
var _local5:Number = distToLineSegmentSq(_arg1, _arg2, _arg3);
if (_local5 < (_arg4 * _arg4)){
return (true);
};
return (false);
}
public static function getCircleIntersectionPoints(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number, _arg5:b2Vec2, _arg6:b2Vec2):Boolean{
if (!isCircleOverlapping(_arg1, _arg2, _arg3, _arg4)){
return (false);
};
var _local7:Number = b2Math.Distance(_arg1, _arg3);
var _local8:Number = (((_arg2 - _arg4) + (_local7 * _local7)) / (2 * _local7));
var _local9:Number = (((_arg4 - _arg2) + (_local7 * _local7)) / (2 * _local7));
var _local10:b2Vec2 = new b2Vec2();
_local10.x = (_arg1.x + ((_local8 * (_arg3.x - _arg1.x)) / _local7));
_local10.y = (_arg1.y + ((_local8 * (_arg3.y - _arg1.y)) / _local7));
var _local11:Number = Math.sqrt(((_arg2 * _arg2) - (_local8 * _local8)));
_arg5.x = (_local10.x - ((_local11 * (_arg3.y - _arg1.y)) / _local7));
_arg5.y = (_local10.y - ((_local11 * (_arg3.x - _arg1.x)) / _local7));
var _local12:Number = Math.sqrt(((_arg4 * _arg4) - (_local8 * _local8)));
_arg6.x = (_local10.x - ((_local12 * (_arg3.y - _arg1.y)) / _local7));
_arg6.y = (_local10.y - ((_local12 * (_arg3.x - _arg1.x)) / _local7));
return (true);
}
public static function getRayCircleIntersect(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Number{
var _local5:b2Vec2 = b2Math.SubtractVV(_arg3, _arg1);
var _local6:Number = _local5.Length();
var _local7:Number = b2Math.Dot(_local5, _arg2);
var _local8:Number = ((_arg4 * _arg4) - ((_local6 * _local6) - (_local7 * _local7)));
if (_local8 < 0){
return (-1);
};
return ((_local7 - Math.sqrt(_local8)));
}
public static function distToLineSegmentSq(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):Number{
var _local4:Number = (((_arg3.x - _arg1.x) * (_arg2.x - _arg1.x)) + ((_arg3.y - _arg1.y) * (_arg2.y - _arg1.y)));
if (_local4 <= 0){
return (b2Math.DistanceSquared(_arg1, _arg3));
};
var _local5:Number = (((_arg3.x - _arg2.x) * (_arg1.x - _arg2.x)) + ((_arg3.y - _arg2.y) * (_arg1.y - _arg2.y)));
if (_local5 <= 0){
return (b2Math.DistanceSquared(_arg2, _arg3));
};
var _local6:b2Vec2 = b2Math.SubtractVV(_arg2, _arg1);
_local6.Multiply(((_local4 / _local4) + _local5));
_local6.Add(_arg1);
return (b2Math.DistanceSquared(_arg3, _local6));
}
public static function lineIntersection(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2=null):Number{
var _local6:Number = (((_arg1.y - _arg3.y) * (_arg4.x - _arg3.x)) - ((_arg1.x - _arg3.x) * (_arg4.y - _arg3.y)));
var _local7:Number = (((_arg1.y - _arg3.y) * (_arg2.x - _arg1.x)) - ((_arg1.x - _arg3.x) * (_arg2.y - _arg1.y)));
var _local8:Number = (((_arg2.x - _arg1.x) * (_arg4.y - _arg3.y)) - ((_arg2.y - _arg1.y) * (_arg4.x - _arg3.x)));
var _local9:Number = (((_arg2.x - _arg1.x) * (_arg4.y - _arg3.y)) - ((_arg2.y - _arg1.y) * (_arg4.x - _arg3.x)));
if ((((_local8 == 0)) || ((_local9 == 0)))){
return (-1);
};
var _local10:Number = (_local6 / _local8);
var _local11:Number = (_local7 / _local9);
if ((((((((_local10 > 0)) && ((_local10 < 1)))) && ((_local11 > 0)))) && ((_local11 < 1)))){
if (_arg5){
_arg5.x = (_arg1.x + (_local10 * (_arg2.x - _arg1.x)));
_arg5.y = (_arg1.y + (_local10 * (_arg2.y - _arg1.y)));
};
return ((b2Math.Distance(_arg1, _arg2) * _local10));
};
return (0);
}
public static function distToLineSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):Number{
var _local4:Number = (((_arg3.x - _arg1.x) * (_arg2.x - _arg1.x)) + ((_arg3.y - _arg1.y) * (_arg2.y - _arg1.y)));
if (_local4 <= 0){
return (b2Math.Distance(_arg1, _arg3));
};
var _local5:Number = (((_arg3.x - _arg2.x) * (_arg1.x - _arg2.x)) + ((_arg3.y - _arg2.y) * (_arg1.y - _arg2.y)));
if (_local5 <= 0){
return (b2Math.Distance(_arg2, _arg3));
};
var _local6:b2Vec2 = b2Math.SubtractVV(_arg2, _arg1);
_local6.Multiply(((_local4 / _local4) + _local5));
_local6.Add(_arg1);
return (b2Math.Distance(_arg3, _local6));
}
public static function whereIsPoint(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):int{
var _local4:b2Vec2 = b2Math.SubtractVV(_arg2, _arg1);
var _local5:Number = b2Math.Dot(_local4, _arg3);
if (_local5 < -1E-5){
return (1);
};
if (_local5 > 1E-5){
return (-1);
};
return (0);
}
}
}//package AKEngine.math
Section 55
//AScreen (AKEngine.screens.AScreen)
package AKEngine.screens {
import flash.events.*;
import flash.display.*;
public class AScreen extends Sprite {
public function AScreen(){
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
addEventListener(Event.REMOVED_FROM_STAGE, dispose, false, 0, true);
} else {
init(null);
};
}
protected function init(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.focus = this;
}
protected function changeScreen(_arg1:AScreen):void{
parent.addChild(_arg1);
parent.removeChild(this);
}
protected function dispose(_arg1:Event):void{
}
}
}//package AKEngine.screens
Section 56
//RootScreen (AKEngine.screens.RootScreen)
package AKEngine.screens {
import flash.events.*;
import AKEngine.*;
import AKEngine.debug.*;
import AKEngine.managers.*;
public class RootScreen extends AScreen {
override protected function init(_arg1:Event):void{
super.init(_arg1);
var _local2:AssetsManager = AssetsManager.instance;
_local2.addEventListener(Event.INIT, assetsInitHandler, false, 0, true);
_local2.initialize();
}
protected function postInit():void{
}
protected function assetsInitHandler(_arg1:Event):void{
var _local2:AKE = AKE.instance;
_local2.initialize(stage);
stage.align = _local2.stageAlign;
stage.scaleMode = _local2.stageScaleMode;
stage.quality = _local2.stageQuality;
stage.stageFocusRect = false;
var _local3:SoundManager = SoundManager.instance;
var _local4:InputManager = InputManager.instance;
_local4.initialize(stage);
Logger.print(this, _local2.VERSION);
Logger.startup();
postInit();
}
}
}//package AKEngine.screens
Section 57
//AKE (AKEngine.AKE)
package AKEngine {
import flash.display.*;
public class AKE {
public const VERSION:String = "AKEngine v0.2.";
public var stageQuality:String;// = "high"
public var stage:Stage;
public var stageAlign:String;
public var isDebugMode:Boolean;// = true
public var stageScaleMode:String;
private static var _instance:AKE;
public function AKE(){
stageAlign = StageAlign.TOP_LEFT;
stageScaleMode = StageScaleMode.NO_SCALE;
super();
}
public function initialize(_arg1:Stage):void{
this.stage = _arg1;
}
public static function get instance():AKE{
if (_instance == null){
_instance = new (AKE);
};
return (_instance);
}
}
}//package AKEngine
Section 58
//GameFactory (AKEngine.GameFactory)
package AKEngine {
import AKEngine.entity.*;
public class GameFactory {
private var _world:World;
public function getEntity(_arg1:EntityParams, _arg2:Entity=null){
var _local3:Entity;
if (_world == null){
throw (new Error("<GameFactory> World must be initialized before calling getEntity!"));
};
_local3 = new _arg1.customClass(_world, _arg1);
if (!(_local3 is Entity)){
throw (new Error("<GameFactory> params.customClass must extend Entity!"));
};
if (_arg2 == null){
_world.addChild(_local3);
} else {
_arg2.addChild(_local3);
};
return (_local3);
}
public function set world(_arg1:World):void{
_world = _arg1;
}
public function dispose():void{
_world = null;
}
}
}//package AKEngine
Section 59
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2CircleShape extends b2Shape {
b2internal var m_p:b2Vec2;
public function b2CircleShape(_arg1:Number=0){
m_p = new b2Vec2();
super();
m_type = e_circleShape;
m_radius = _arg1;
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
var _local9:Number;
var _local5:b2Vec2 = b2Math.MulX(_arg3, m_p);
var _local6:Number = -((b2Math.Dot(_arg1, _local5) - _arg2));
if (_local6 < (-(m_radius) + Number.MIN_VALUE)){
return (0);
};
if (_local6 > m_radius){
_arg4.SetV(_local5);
return (((Math.PI * m_radius) * m_radius));
};
var _local7:Number = (m_radius * m_radius);
var _local8:Number = (_local6 * _local6);
_local9 = ((_local7 * (Math.asin((_local6 / m_radius)) + (Math.PI / 2))) + (_local6 * Math.sqrt((_local7 - _local8))));
var _local10:Number = (((-2 / 3) * Math.pow((_local7 - _local8), 1.5)) / _local9);
_arg4.x = (_local5.x + (_arg1.x * _local10));
_arg4.y = (_local5.y + (_arg1.y * _local10));
return (_local9);
}
override public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
var _local3:b2Mat22 = _arg1.R;
var _local4:Number = (_arg1.position.x + ((_local3.col1.x * m_p.x) + (_local3.col2.x * m_p.y)));
var _local5:Number = (_arg1.position.y + ((_local3.col1.y * m_p.x) + (_local3.col2.y * m_p.y)));
_local4 = (_arg2.x - _local4);
_local5 = (_arg2.y - _local5);
return ((((_local4 * _local4) + (_local5 * _local5)) <= (m_radius * m_radius)));
}
public function GetRadius():Number{
return (m_radius);
}
override public function Set(_arg1:b2Shape):void{
var _local2:b2CircleShape;
super.Set(_arg1);
if ((_arg1 is b2CircleShape)){
_local2 = (_arg1 as b2CircleShape);
m_p.SetV(_local2.m_p);
};
}
override public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
_arg1.mass = (((_arg2 * b2Settings.b2_pi) * m_radius) * m_radius);
_arg1.center.SetV(m_p);
_arg1.I = (_arg1.mass * (((0.5 * m_radius) * m_radius) + ((m_p.x * m_p.x) + (m_p.y * m_p.y))));
}
override public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
var _local8:Number;
var _local4:b2Mat22 = _arg3.R;
var _local5:Number = (_arg3.position.x + ((_local4.col1.x * m_p.x) + (_local4.col2.x * m_p.y)));
var _local6:Number = (_arg3.position.y + ((_local4.col1.y * m_p.x) + (_local4.col2.y * m_p.y)));
var _local7:Number = (_arg2.p1.x - _local5);
_local8 = (_arg2.p1.y - _local6);
var _local9:Number = (((_local7 * _local7) + (_local8 * _local8)) - (m_radius * m_radius));
var _local10:Number = (_arg2.p2.x - _arg2.p1.x);
var _local11:Number = (_arg2.p2.y - _arg2.p1.y);
var _local12:Number = ((_local7 * _local10) + (_local8 * _local11));
var _local13:Number = ((_local10 * _local10) + (_local11 * _local11));
var _local14:Number = ((_local12 * _local12) - (_local13 * _local9));
if ((((_local14 < 0)) || ((_local13 < Number.MIN_VALUE)))){
return (false);
};
var _local15:Number = -((_local12 + Math.sqrt(_local14)));
if ((((0 <= _local15)) && ((_local15 <= (_arg2.maxFraction * _local13))))){
_local15 = (_local15 / _local13);
_arg1.fraction = _local15;
_arg1.normal.x = (_local7 + (_local15 * _local10));
_arg1.normal.y = (_local8 + (_local15 * _local11));
_arg1.normal.Normalize();
return (true);
};
return (false);
}
public function SetLocalPosition(_arg1:b2Vec2):void{
m_p.SetV(_arg1);
}
public function SetRadius(_arg1:Number):void{
m_radius = _arg1;
}
override public function Copy():b2Shape{
var _local1:b2Shape = new b2CircleShape();
_local1.Set(this);
return (_local1);
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
var _local3:b2Mat22 = _arg2.R;
var _local4:Number = (_arg2.position.x + ((_local3.col1.x * m_p.x) + (_local3.col2.x * m_p.y)));
var _local5:Number = (_arg2.position.y + ((_local3.col1.y * m_p.x) + (_local3.col2.y * m_p.y)));
_arg1.lowerBound.Set((_local4 - m_radius), (_local5 - m_radius));
_arg1.upperBound.Set((_local4 + m_radius), (_local5 + m_radius));
}
public function GetLocalPosition():b2Vec2{
return (m_p);
}
}
}//package Box2D.Collision.Shapes
Section 60
//b2EdgeShape (Box2D.Collision.Shapes.b2EdgeShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2EdgeShape extends b2Shape {
b2internal var m_normal:b2Vec2;
b2internal var m_cornerConvex1:Boolean;
b2internal var m_cornerConvex2:Boolean;
b2internal var m_cornerDir1:b2Vec2;
b2internal var m_v1:b2Vec2;
b2internal var m_v2:b2Vec2;
private var s_supportVec:b2Vec2;
b2internal var m_coreV1:b2Vec2;
b2internal var m_coreV2:b2Vec2;
b2internal var m_cornerDir2:b2Vec2;
b2internal var m_nextEdge:b2EdgeShape;
b2internal var m_direction:b2Vec2;
b2internal var m_prevEdge:b2EdgeShape;
b2internal var m_length:Number;
public function b2EdgeShape(_arg1:b2Vec2, _arg2:b2Vec2){
s_supportVec = new b2Vec2();
m_v1 = new b2Vec2();
m_v2 = new b2Vec2();
m_coreV1 = new b2Vec2();
m_coreV2 = new b2Vec2();
m_normal = new b2Vec2();
m_direction = new b2Vec2();
m_cornerDir1 = new b2Vec2();
m_cornerDir2 = new b2Vec2();
super();
m_type = e_edgeShape;
m_prevEdge = null;
m_nextEdge = null;
m_v1 = _arg1;
m_v2 = _arg2;
m_direction.Set((m_v2.x - m_v1.x), (m_v2.y - m_v1.y));
m_length = m_direction.Normalize();
m_normal.Set(m_direction.y, -(m_direction.x));
m_coreV1.Set(((-(b2Settings.b2_toiSlop) * (m_normal.x - m_direction.x)) + m_v1.x), ((-(b2Settings.b2_toiSlop) * (m_normal.y - m_direction.y)) + m_v1.y));
m_coreV2.Set(((-(b2Settings.b2_toiSlop) * (m_normal.x + m_direction.x)) + m_v2.x), ((-(b2Settings.b2_toiSlop) * (m_normal.y + m_direction.y)) + m_v2.y));
m_cornerDir1 = m_normal;
m_cornerDir2.Set(-(m_normal.x), -(m_normal.y));
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
var _local5:b2Vec2 = new b2Vec2((_arg1.x * _arg2), (_arg1.y * _arg2));
var _local6:b2Vec2 = b2Math.MulX(_arg3, m_v1);
var _local7:b2Vec2 = b2Math.MulX(_arg3, m_v2);
var _local8:Number = (b2Math.Dot(_arg1, _local6) - _arg2);
var _local9:Number = (b2Math.Dot(_arg1, _local7) - _arg2);
if (_local8 > 0){
if (_local9 > 0){
return (0);
};
_local6.x = (((-(_local9) / (_local8 - _local9)) * _local6.x) + ((_local8 / (_local8 - _local9)) * _local7.x));
_local6.y = (((-(_local9) / (_local8 - _local9)) * _local6.y) + ((_local8 / (_local8 - _local9)) * _local7.y));
} else {
if (_local9 > 0){
_local7.x = (((-(_local9) / (_local8 - _local9)) * _local6.x) + ((_local8 / (_local8 - _local9)) * _local7.x));
_local7.y = (((-(_local9) / (_local8 - _local9)) * _local6.y) + ((_local8 / (_local8 - _local9)) * _local7.y));
};
};
_arg4.x = (((_local5.x + _local6.x) + _local7.x) / 3);
_arg4.y = (((_local5.y + _local6.y) + _local7.y) / 3);
return ((0.5 * (((_local6.x - _local5.x) * (_local7.y - _local5.y)) - ((_local6.y - _local5.y) * (_local7.x - _local5.x)))));
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local3:b2Mat22 = _arg2.R;
_local4 = (_arg2.position.x + ((_local3.col1.x * m_v1.x) + (_local3.col2.x * m_v1.y)));
_local5 = (_arg2.position.y + ((_local3.col1.y * m_v1.x) + (_local3.col2.y * m_v1.y)));
_local6 = (_arg2.position.x + ((_local3.col1.x * m_v2.x) + (_local3.col2.x * m_v2.y)));
_local7 = (_arg2.position.y + ((_local3.col1.y * m_v2.x) + (_local3.col2.y * m_v2.y)));
if (_local4 < _local6){
_arg1.lowerBound.x = _local4;
_arg1.upperBound.x = _local6;
} else {
_arg1.lowerBound.x = _local6;
_arg1.upperBound.x = _local4;
};
if (_local5 < _local7){
_arg1.lowerBound.y = _local5;
_arg1.upperBound.y = _local7;
} else {
_arg1.lowerBound.y = _local7;
_arg1.upperBound.y = _local5;
};
}
public function GetCorner1Vector():b2Vec2{
return (m_cornerDir1);
}
public function GetCorner2Vector():b2Vec2{
return (m_cornerDir2);
}
public function GetDirectionVector():b2Vec2{
return (m_direction);
}
public function GetCoreVertex1():b2Vec2{
return (m_coreV1);
}
public function GetCoreVertex2():b2Vec2{
return (m_coreV2);
}
public function GetFirstVertex(_arg1:b2Transform):b2Vec2{
var _local2:b2Mat22 = _arg1.R;
return (new b2Vec2((_arg1.position.x + ((_local2.col1.x * m_coreV1.x) + (_local2.col2.x * m_coreV1.y))), (_arg1.position.y + ((_local2.col1.y * m_coreV1.x) + (_local2.col2.y * m_coreV1.y)))));
}
public function GetNormalVector():b2Vec2{
return (m_normal);
}
public function GetNextEdge():b2EdgeShape{
return (m_nextEdge);
}
override public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
var _local4:b2Mat22;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local5:Number = (_arg2.p2.x - _arg2.p1.x);
var _local6:Number = (_arg2.p2.y - _arg2.p1.y);
_local4 = _arg3.R;
var _local7:Number = (_arg3.position.x + ((_local4.col1.x * m_v1.x) + (_local4.col2.x * m_v1.y)));
var _local8:Number = (_arg3.position.y + ((_local4.col1.y * m_v1.x) + (_local4.col2.y * m_v1.y)));
var _local9:Number = ((_arg3.position.y + ((_local4.col1.y * m_v2.x) + (_local4.col2.y * m_v2.y))) - _local8);
var _local10:Number = -(((_arg3.position.x + ((_local4.col1.x * m_v2.x) + (_local4.col2.x * m_v2.y))) - _local7));
var _local11:Number = (100 * Number.MIN_VALUE);
var _local12:Number = -(((_local5 * _local9) + (_local6 * _local10)));
if (_local12 > _local11){
_local13 = (_arg2.p1.x - _local7);
_local14 = (_arg2.p1.y - _local8);
_local15 = ((_local13 * _local9) + (_local14 * _local10));
if ((((0 <= _local15)) && ((_local15 <= (_arg2.maxFraction * _local12))))){
_local16 = ((-(_local5) * _local14) + (_local6 * _local13));
if (((((-(_local11) * _local12) <= _local16)) && ((_local16 <= (_local12 * (1 + _local11)))))){
_local15 = (_local15 / _local12);
_arg1.fraction = _local15;
_local17 = Math.sqrt(((_local9 * _local9) + (_local10 * _local10)));
_arg1.normal.x = (_local9 / _local17);
_arg1.normal.y = (_local10 / _local17);
return (true);
};
};
};
return (false);
}
override public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
_arg1.mass = 0;
_arg1.center.SetV(m_v1);
_arg1.I = 0;
}
public function Corner1IsConvex():Boolean{
return (m_cornerConvex1);
}
public function Corner2IsConvex():Boolean{
return (m_cornerConvex2);
}
public function Support(_arg1:b2Transform, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:b2Mat22 = _arg1.R;
var _local5:Number = (_arg1.position.x + ((_local4.col1.x * m_coreV1.x) + (_local4.col2.x * m_coreV1.y)));
var _local6:Number = (_arg1.position.y + ((_local4.col1.y * m_coreV1.x) + (_local4.col2.y * m_coreV1.y)));
var _local7:Number = (_arg1.position.x + ((_local4.col1.x * m_coreV2.x) + (_local4.col2.x * m_coreV2.y)));
var _local8:Number = (_arg1.position.y + ((_local4.col1.y * m_coreV2.x) + (_local4.col2.y * m_coreV2.y)));
if (((_local5 * _arg2) + (_local6 * _arg3)) > ((_local7 * _arg2) + (_local8 * _arg3))){
s_supportVec.x = _local5;
s_supportVec.y = _local6;
} else {
s_supportVec.x = _local7;
s_supportVec.y = _local8;
};
return (s_supportVec);
}
b2internal function SetNextEdge(_arg1:b2EdgeShape, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Boolean):void{
m_nextEdge = _arg1;
m_coreV2 = _arg2;
m_cornerDir2 = _arg3;
m_cornerConvex2 = _arg4;
}
public function GetPrevEdge():b2EdgeShape{
return (m_prevEdge);
}
public function GetVertex1():b2Vec2{
return (m_v1);
}
public function GetVertex2():b2Vec2{
return (m_v2);
}
b2internal function SetPrevEdge(_arg1:b2EdgeShape, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Boolean):void{
m_prevEdge = _arg1;
m_coreV1 = _arg2;
m_cornerDir1 = _arg3;
m_cornerConvex1 = _arg4;
}
public function GetLength():Number{
return (m_length);
}
override public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
return (false);
}
}
}//package Box2D.Collision.Shapes
Section 61
//b2MassData (Box2D.Collision.Shapes.b2MassData)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2MassData {
public var mass:Number;// = 0
public var center:b2Vec2;
public var I:Number;// = 0
public function b2MassData(){
center = new b2Vec2(0, 0);
super();
}
}
}//package Box2D.Collision.Shapes
Section 62
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolygonShape extends b2Shape {
b2internal var m_vertexCount:int;
b2internal var m_vertices:Array;
b2internal var m_centroid:b2Vec2;
b2internal var m_normals:Array;
private static var s_mat:b2Mat22 = new b2Mat22();
public function b2PolygonShape(){
m_type = e_polygonShape;
m_centroid = new b2Vec2();
m_vertices = new Array();
m_normals = new Array();
}
override public function Set(_arg1:b2Shape):void{
var _local2:b2PolygonShape;
var _local3:int;
super.Set(_arg1);
if ((_arg1 is b2PolygonShape)){
_local2 = (_arg1 as b2PolygonShape);
m_centroid.SetV(_local2.m_centroid);
m_vertexCount = _local2.m_vertexCount;
Reserve(m_vertexCount);
_local3 = 0;
while (_local3 < m_vertexCount) {
m_vertices[_local3].SetV(_local2.m_vertices[_local3]);
m_normals[_local3].SetV(_local2.m_normals[_local3]);
_local3++;
};
};
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
var _local10:Number;
var _local11:Number;
var _local3:b2Mat22 = _arg2.R;
var _local4:b2Vec2 = m_vertices[0];
var _local5:Number = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)));
var _local6:Number = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)));
var _local7:Number = _local5;
var _local8:Number = _local6;
var _local9 = 1;
while (_local9 < m_vertexCount) {
_local4 = m_vertices[_local9];
_local10 = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)));
_local11 = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)));
_local5 = ((_local5 < _local10)) ? _local5 : _local10;
_local6 = ((_local6 < _local11)) ? _local6 : _local11;
_local7 = ((_local7 > _local10)) ? _local7 : _local10;
_local8 = ((_local8 > _local11)) ? _local8 : _local11;
_local9++;
};
_arg1.lowerBound.x = (_local5 - m_radius);
_arg1.lowerBound.y = (_local6 - m_radius);
_arg1.upperBound.x = (_local7 + m_radius);
_arg1.upperBound.y = (_local8 + m_radius);
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
var _local12:int;
var _local22:b2Vec2;
var _local23:Boolean;
var _local24:b2MassData;
var _local25:Number;
var _local5:b2Vec2 = b2Math.MulTMV(_arg3.R, _arg1);
var _local6:Number = (_arg2 - b2Math.Dot(_arg1, _arg3.position));
var _local7:Array = new Array();
var _local8:int;
var _local9 = -1;
var _local10 = -1;
var _local11:Boolean;
_local12 = 0;
while (_local12 < m_vertexCount) {
_local7[_local12] = (b2Math.Dot(_local5, m_vertices[_local12]) - _local6);
_local23 = (_local7[_local12] < -(Number.MIN_VALUE));
if (_local12 > 0){
if (_local23){
if (!_local11){
_local9 = (_local12 - 1);
_local8++;
};
} else {
if (_local11){
_local10 = (_local12 - 1);
_local8++;
};
};
};
_local11 = _local23;
_local12++;
};
switch (_local8){
case 0:
if (_local11){
_local24 = new b2MassData();
ComputeMass(_local24, 1);
_arg4.SetV(b2Math.MulX(_arg3, _local24.center));
return (_local24.mass);
};
return (0);
case 1:
if (_local9 == -1){
_local9 = (m_vertexCount - 1);
} else {
_local10 = (m_vertexCount - 1);
};
break;
};
var _local13:int = ((_local9 + 1) % m_vertexCount);
var _local14:int = ((_local10 + 1) % m_vertexCount);
var _local15:Number = ((0 - _local7[_local9]) / (_local7[_local13] - _local7[_local9]));
var _local16:Number = ((0 - _local7[_local10]) / (_local7[_local14] - _local7[_local10]));
var _local17:b2Vec2 = new b2Vec2(((m_vertices[_local9].x * (1 - _local15)) + (m_vertices[_local13].x * _local15)), ((m_vertices[_local9].y * (1 - _local15)) + (m_vertices[_local13].y * _local15)));
var _local18:b2Vec2 = new b2Vec2(((m_vertices[_local10].x * (1 - _local16)) + (m_vertices[_local14].x * _local16)), ((m_vertices[_local10].y * (1 - _local16)) + (m_vertices[_local14].y * _local16)));
var _local19:Number = 0;
var _local20:b2Vec2 = new b2Vec2();
var _local21:b2Vec2 = m_vertices[_local13];
_local12 = _local13;
while (_local12 != _local14) {
_local12 = ((_local12 + 1) % m_vertexCount);
if (_local12 == _local14){
_local22 = _local18;
} else {
_local22 = m_vertices[_local12];
};
_local25 = (0.5 * (((_local21.x - _local17.x) * (_local22.y - _local17.y)) - ((_local21.y - _local17.y) * (_local22.x - _local17.x))));
_local19 = (_local19 + _local25);
_local20.x = (_local20.x + ((_local25 * ((_local17.x + _local21.x) + _local22.x)) / 3));
_local20.y = (_local20.y + ((_local25 * ((_local17.y + _local21.y) + _local22.y)) / 3));
_local21 = _local22;
};
_local20.Multiply((1 / _local19));
_arg4.SetV(b2Math.MulX(_arg3, _local20));
return (_local19);
}
public function GetVertices():Array{
return (m_vertices);
}
public function SetAsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):void{
m_vertexCount = 4;
Reserve(4);
m_vertices[0].Set(-(_arg1), -(_arg2));
m_vertices[1].Set(_arg1, -(_arg2));
m_vertices[2].Set(_arg1, _arg2);
m_vertices[3].Set(-(_arg1), _arg2);
m_normals[0].Set(0, -1);
m_normals[1].Set(1, 0);
m_normals[2].Set(0, 1);
m_normals[3].Set(-1, 0);
m_centroid = _arg3;
var _local5:b2Transform = new b2Transform();
_local5.position = _arg3;
_local5.R.Set(_arg4);
var _local6:int;
while (_local6 < m_vertexCount) {
m_vertices[_local6] = b2Math.MulX(_local5, m_vertices[_local6]);
m_normals[_local6] = b2Math.MulMV(_local5.R, m_normals[_local6]);
_local6++;
};
}
override public function Copy():b2Shape{
var _local1:b2PolygonShape = new b2PolygonShape();
_local1.Set(this);
return (_local1);
}
public function SetAsBox(_arg1:Number, _arg2:Number):void{
m_vertexCount = 4;
Reserve(4);
m_vertices[0].Set(-(_arg1), -(_arg2));
m_vertices[1].Set(_arg1, -(_arg2));
m_vertices[2].Set(_arg1, _arg2);
m_vertices[3].Set(-(_arg1), _arg2);
m_normals[0].Set(0, -1);
m_normals[1].Set(1, 0);
m_normals[2].Set(0, 1);
m_normals[3].Set(-1, 0);
m_centroid.SetZero();
}
private function Reserve(_arg1:int):void{
var _local2:int = m_vertices.length;
while (_local2 < _arg1) {
m_vertices[_local2] = new b2Vec2();
m_normals[_local2] = new b2Vec2();
_local2++;
};
}
public function GetNormals():Array{
return (m_normals);
}
public function SetAsArray(_arg1:Array, _arg2:Number=0):void{
var _local4:b2Vec2;
var _local3:Array = new Array();
for each (_local4 in _arg1) {
_local3.push(_local4);
};
SetAsVector(_local3, _arg2);
}
override public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
var _local6:Number;
var _local7:Number;
var _local8:b2Mat22;
var _local9:b2Vec2;
var _local18:Number;
var _local19:Number;
var _local4:Number = 0;
var _local5:Number = _arg2.maxFraction;
_local6 = (_arg2.p1.x - _arg3.position.x);
_local7 = (_arg2.p1.y - _arg3.position.y);
_local8 = _arg3.R;
var _local10:Number = ((_local6 * _local8.col1.x) + (_local7 * _local8.col1.y));
var _local11:Number = ((_local6 * _local8.col2.x) + (_local7 * _local8.col2.y));
_local6 = (_arg2.p2.x - _arg3.position.x);
_local7 = (_arg2.p2.y - _arg3.position.y);
_local8 = _arg3.R;
var _local12:Number = ((_local6 * _local8.col1.x) + (_local7 * _local8.col1.y));
var _local13:Number = ((_local6 * _local8.col2.x) + (_local7 * _local8.col2.y));
var _local14:Number = (_local12 - _local10);
var _local15:Number = (_local13 - _local11);
var _local16 = -1;
var _local17:int;
while (_local17 < m_vertexCount) {
_local9 = m_vertices[_local17];
_local6 = (_local9.x - _local10);
_local7 = (_local9.y - _local11);
_local9 = m_normals[_local17];
_local18 = ((_local9.x * _local6) + (_local9.y * _local7));
_local19 = ((_local9.x * _local14) + (_local9.y * _local15));
if (_local19 == 0){
if (_local18 < 0){
return (false);
};
} else {
if ((((_local19 < 0)) && ((_local18 < (_local4 * _local19))))){
_local4 = (_local18 / _local19);
_local16 = _local17;
} else {
if ((((_local19 > 0)) && ((_local18 < (_local5 * _local19))))){
_local5 = (_local18 / _local19);
};
};
};
if (_local5 < (_local4 - Number.MIN_VALUE)){
return (false);
};
_local17++;
};
if (_local16 >= 0){
_arg1.fraction = _local4;
_local8 = _arg3.R;
_local9 = m_normals[_local16];
_arg1.normal.x = ((_local8.col1.x * _local9.x) + (_local8.col2.x * _local9.y));
_arg1.normal.y = ((_local8.col1.y * _local9.x) + (_local8.col2.y * _local9.y));
return (true);
};
return (false);
}
override public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
if (m_vertexCount == 2){
_arg1.center.x = (0.5 * (m_vertices[0].x + m_vertices[1].x));
_arg1.center.y = (0.5 * (m_vertices[0].y + m_vertices[1].y));
_arg1.mass = 0;
_arg1.I = 0;
return;
};
var _local3:Number = 0;
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
var _local7:Number = 0;
var _local8:Number = 0;
var _local9:Number = (1 / 3);
var _local10:int;
while (_local10 < m_vertexCount) {
_local11 = m_vertices[_local10];
_local12 = (((_local10 + 1) < m_vertexCount)) ? m_vertices[int((_local10 + 1))] : m_vertices[0];
_local13 = (_local11.x - _local7);
_local14 = (_local11.y - _local8);
_local15 = (_local12.x - _local7);
_local16 = (_local12.y - _local8);
_local17 = ((_local13 * _local16) - (_local14 * _local15));
_local18 = (0.5 * _local17);
_local5 = (_local5 + _local18);
_local3 = (_local3 + ((_local18 * _local9) * ((_local7 + _local11.x) + _local12.x)));
_local4 = (_local4 + ((_local18 * _local9) * ((_local8 + _local11.y) + _local12.y)));
_local19 = _local7;
_local20 = _local8;
_local21 = _local13;
_local22 = _local14;
_local23 = _local15;
_local24 = _local16;
_local25 = ((_local9 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19));
_local26 = ((_local9 * ((0.25 * (((_local22 * _local22) + (_local24 * _local22)) + (_local24 * _local24))) + ((_local20 * _local22) + (_local20 * _local24)))) + ((0.5 * _local20) * _local20));
_local6 = (_local6 + (_local17 * (_local25 + _local26)));
_local10++;
};
_arg1.mass = (_arg2 * _local5);
_local3 = (_local3 * (1 / _local5));
_local4 = (_local4 * (1 / _local5));
_arg1.center.Set(_local3, _local4);
_arg1.I = (_arg2 * _local6);
}
public function SetAsEdge(_arg1:b2Vec2, _arg2:b2Vec2):void{
m_vertexCount = 2;
Reserve(2);
m_vertices[0].SetV(_arg1);
m_vertices[1].SetV(_arg2);
m_centroid.x = (0.5 * (_arg1.x + _arg2.x));
m_centroid.y = (0.5 * (_arg1.y + _arg2.y));
m_normals[0] = b2Math.CrossVF(b2Math.SubtractVV(_arg2, _arg1), 1);
m_normals[0].Normalize();
m_normals[1].x = -(m_normals[0].x);
m_normals[1].y = -(m_normals[0].y);
}
public function GetVertexCount():int{
return (m_vertexCount);
}
private function Validate():Boolean{
return (false);
}
public function SetAsVector(_arg1:Array, _arg2:Number=0):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:b2Vec2;
if (_arg2 == 0){
_arg2 = _arg1.length;
};
b2Settings.b2Assert((2 <= _arg2));
m_vertexCount = _arg2;
Reserve(_arg2);
_local3 = 0;
while (_local3 < m_vertexCount) {
m_vertices[_local3].SetV(_arg1[_local3]);
_local3++;
};
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = _local3;
_local5 = (((_local3 + 1) < m_vertexCount)) ? (_local3 + 1) : 0;
_local6 = b2Math.SubtractVV(m_vertices[_local5], m_vertices[_local4]);
b2Settings.b2Assert((_local6.LengthSquared() > Number.MIN_VALUE));
m_normals[_local3].SetV(b2Math.CrossVF(_local6, 1));
m_normals[_local3].Normalize();
_local3++;
};
m_centroid = ComputeCentroid(m_vertices, m_vertexCount);
}
public function GetSupport(_arg1:b2Vec2):int{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_vertexCount) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (_local2);
}
public function GetSupportVertex(_arg1:b2Vec2):b2Vec2{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_vertexCount) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (m_vertices[_local2]);
}
override public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
var _local3:b2Vec2;
var _local10:Number;
var _local4:b2Mat22 = _arg1.R;
var _local5:Number = (_arg2.x - _arg1.position.x);
var _local6:Number = (_arg2.y - _arg1.position.y);
var _local7:Number = ((_local5 * _local4.col1.x) + (_local6 * _local4.col1.y));
var _local8:Number = ((_local5 * _local4.col2.x) + (_local6 * _local4.col2.y));
var _local9:int;
while (_local9 < m_vertexCount) {
_local3 = m_vertices[_local9];
_local5 = (_local7 - _local3.x);
_local6 = (_local8 - _local3.y);
_local3 = m_normals[_local9];
_local10 = ((_local3.x * _local5) + (_local3.y * _local6));
if (_local10 > 0){
return (false);
};
_local9++;
};
return (true);
}
b2internal static function ComputeOBB(_arg1:b2OBB, _arg2:Array, _arg3:int):void{
var _local4:int;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:b2Mat22;
var _local5:Array = new Array((_arg3 + 1));
_local4 = 0;
while (_local4 < _arg3) {
_local5[_local4] = _arg2[_local4];
_local4++;
};
_local5[_arg3] = _local5[0];
var _local6:Number = Number.MAX_VALUE;
_local4 = 1;
while (_local4 <= _arg3) {
_local7 = _local5[int((_local4 - 1))];
_local8 = (_local5[_local4].x - _local7.x);
_local9 = (_local5[_local4].y - _local7.y);
_local10 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
_local8 = (_local8 / _local10);
_local9 = (_local9 / _local10);
_local11 = -(_local9);
_local12 = _local8;
_local13 = Number.MAX_VALUE;
_local14 = Number.MAX_VALUE;
_local15 = -(Number.MAX_VALUE);
_local16 = -(Number.MAX_VALUE);
_local17 = 0;
while (_local17 < _arg3) {
_local19 = (_local5[_local17].x - _local7.x);
_local20 = (_local5[_local17].y - _local7.y);
_local21 = ((_local8 * _local19) + (_local9 * _local20));
_local22 = ((_local11 * _local19) + (_local12 * _local20));
if (_local21 < _local13){
_local13 = _local21;
};
if (_local22 < _local14){
_local14 = _local22;
};
if (_local21 > _local15){
_local15 = _local21;
};
if (_local22 > _local16){
_local16 = _local22;
};
_local17++;
};
_local18 = ((_local15 - _local13) * (_local16 - _local14));
if (_local18 < (0.95 * _local6)){
_local6 = _local18;
_arg1.R.col1.x = _local8;
_arg1.R.col1.y = _local9;
_arg1.R.col2.x = _local11;
_arg1.R.col2.y = _local12;
_local23 = (0.5 * (_local13 + _local15));
_local24 = (0.5 * (_local14 + _local16));
_local25 = _arg1.R;
_arg1.center.x = (_local7.x + ((_local25.col1.x * _local23) + (_local25.col2.x * _local24)));
_arg1.center.y = (_local7.y + ((_local25.col1.y * _local23) + (_local25.col2.y * _local24)));
_arg1.extents.x = (0.5 * (_local15 - _local13));
_arg1.extents.y = (0.5 * (_local16 - _local14));
};
_local4++;
};
}
public static function AsVector(_arg1:Array, _arg2:Number):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsVector(_arg1, _arg2);
return (_local3);
}
public static function AsArray(_arg1:Array, _arg2:Number):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsArray(_arg1, _arg2);
return (_local3);
}
public static function AsBox(_arg1:Number, _arg2:Number):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsBox(_arg1, _arg2);
return (_local3);
}
public static function AsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):b2PolygonShape{
var _local5:b2PolygonShape = new (b2PolygonShape);
_local5.SetAsOrientedBox(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
public static function ComputeCentroid(_arg1:Array, _arg2:uint):b2Vec2{
var _local3:b2Vec2;
var _local7:Number;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local3 = new b2Vec2();
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
_local7 = (1 / 3);
var _local8:int;
while (_local8 < _arg2) {
_local9 = _arg1[_local8];
_local10 = (((_local8 + 1) < _arg2)) ? _arg1[int((_local8 + 1))] : _arg1[0];
_local11 = (_local9.x - _local5);
_local12 = (_local9.y - _local6);
_local13 = (_local10.x - _local5);
_local14 = (_local10.y - _local6);
_local15 = ((_local11 * _local14) - (_local12 * _local13));
_local16 = (0.5 * _local15);
_local4 = (_local4 + _local16);
_local3.x = (_local3.x + ((_local16 * _local7) * ((_local5 + _local9.x) + _local10.x)));
_local3.y = (_local3.y + ((_local16 * _local7) * ((_local6 + _local9.y) + _local10.y)));
_local8++;
};
_local3.x = (_local3.x * (1 / _local4));
_local3.y = (_local3.y * (1 / _local4));
return (_local3);
}
public static function AsEdge(_arg1:b2Vec2, _arg2:b2Vec2):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsEdge(_arg1, _arg2);
return (_local3);
}
}
}//package Box2D.Collision.Shapes
Section 63
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2Shape {
b2internal var m_radius:Number;
b2internal var m_type:int;
b2internal static const e_polygonShape:int = 1;
public static const e_hitCollide:int = 1;
public static const e_missCollide:int = 0;
b2internal static const e_edgeShape:int = 2;
b2internal static const e_shapeTypeCount:int = 3;
b2internal static const e_unknownShape:int = -1;
b2internal static const e_circleShape:int = 0;
public static const e_startsInsideCollide:int = -1;
public function b2Shape(){
m_type = e_unknownShape;
m_radius = b2Settings.b2_linearSlop;
}
public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
return (false);
}
public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
return (0);
}
public function Set(_arg1:b2Shape):void{
m_radius = _arg1.m_radius;
}
public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
}
public function GetType():int{
return (m_type);
}
public function Copy():b2Shape{
return (null);
}
public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
}
public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
return (false);
}
public static function TestOverlap(_arg1:b2Shape, _arg2:b2Transform, _arg3:b2Shape, _arg4:b2Transform):Boolean{
var _local5:b2DistanceInput = new b2DistanceInput();
_local5.proxyA = new b2DistanceProxy();
_local5.proxyA.Set(_arg1);
_local5.proxyB = new b2DistanceProxy();
_local5.proxyB.Set(_arg3);
_local5.transformA = _arg2;
_local5.transformB = _arg4;
_local5.useRadii = true;
var _local6:b2SimplexCache = new b2SimplexCache();
_local6.count = 0;
var _local7:b2DistanceOutput = new b2DistanceOutput();
b2Distance.Distance(_local7, _local6, _local5);
return ((_local7.distance < (10 * Number.MIN_VALUE)));
}
}
}//package Box2D.Collision.Shapes
Section 64
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var upperBound:b2Vec2;
public var lowerBound:b2Vec2;
public function b2AABB(){
lowerBound = new b2Vec2();
upperBound = new b2Vec2();
super();
}
public function Contains(_arg1:b2AABB):Boolean{
var _local2:Boolean;
_local2 = ((_local2) && ((lowerBound.x <= _arg1.lowerBound.x)));
_local2 = ((_local2) && ((lowerBound.y <= _arg1.lowerBound.y)));
_local2 = ((_local2) && ((_arg1.upperBound.x <= upperBound.x)));
_local2 = ((_local2) && ((_arg1.upperBound.y <= upperBound.y)));
return (_local2);
}
public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput):Boolean{
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local3:Number = -(Number.MAX_VALUE);
var _local4:Number = Number.MAX_VALUE;
var _local5:Number = _arg2.p1.x;
var _local6:Number = _arg2.p1.y;
var _local7:Number = (_arg2.p2.x - _arg2.p1.x);
var _local8:Number = (_arg2.p2.y - _arg2.p1.y);
var _local9:Number = Math.abs(_local7);
var _local10:Number = Math.abs(_local8);
_local11 = _arg1.normal;
if (_local9 < Number.MIN_VALUE){
if ((((_local5 < lowerBound.x)) || ((upperBound.x < _local5)))){
return (false);
};
} else {
_local12 = (1 / _local7);
_local13 = ((lowerBound.x - _local5) * _local12);
_local14 = ((upperBound.x - _local5) * _local12);
_local16 = -1;
if (_local13 > _local14){
_local15 = _local13;
_local13 = _local14;
_local14 = _local15;
_local16 = 1;
};
if (_local13 > _local3){
_local11.x = _local16;
_local11.y = 0;
_local3 = _local13;
};
_local4 = Math.min(_local4, _local14);
if (_local3 > _local4){
return (false);
};
};
if (_local10 < Number.MIN_VALUE){
if ((((_local6 < lowerBound.y)) || ((upperBound.y < _local6)))){
return (false);
};
} else {
_local12 = (1 / _local8);
_local13 = ((lowerBound.y - _local6) * _local12);
_local14 = ((upperBound.y - _local6) * _local12);
_local16 = -1;
if (_local13 > _local14){
_local15 = _local13;
_local13 = _local14;
_local14 = _local15;
_local16 = 1;
};
if (_local13 > _local3){
_local11.y = _local16;
_local11.x = 0;
_local3 = _local13;
};
_local4 = Math.min(_local4, _local14);
if (_local3 > _local4){
return (false);
};
};
_arg1.fraction = _local3;
return (true);
}
public function GetCenter():b2Vec2{
return (new b2Vec2(((lowerBound.x + upperBound.x) / 2), ((lowerBound.y + upperBound.y) / 2)));
}
public function IsValid():Boolean{
var _local1:Number = (upperBound.x - lowerBound.x);
var _local2:Number = (upperBound.y - lowerBound.y);
var _local3:Boolean = (((_local1 >= 0)) && ((_local2 >= 0)));
_local3 = ((((_local3) && (lowerBound.IsValid()))) && (upperBound.IsValid()));
return (_local3);
}
public function TestOverlap(_arg1:b2AABB):Boolean{
var _local2:Number = (_arg1.lowerBound.x - upperBound.x);
var _local3:Number = (_arg1.lowerBound.y - upperBound.y);
var _local4:Number = (lowerBound.x - _arg1.upperBound.x);
var _local5:Number = (lowerBound.y - _arg1.upperBound.y);
if ((((_local2 > 0)) || ((_local3 > 0)))){
return (false);
};
if ((((_local4 > 0)) || ((_local5 > 0)))){
return (false);
};
return (true);
}
public function GetExtents():b2Vec2{
return (new b2Vec2(((upperBound.x - lowerBound.x) / 2), ((upperBound.y - lowerBound.y) / 2)));
}
public function Combine(_arg1:b2AABB, _arg2:b2AABB):void{
lowerBound.x = Math.min(_arg1.lowerBound.x, _arg2.lowerBound.x);
lowerBound.y = Math.min(_arg1.lowerBound.y, _arg2.lowerBound.y);
upperBound.x = Math.max(_arg1.upperBound.x, _arg2.upperBound.x);
upperBound.y = Math.max(_arg1.upperBound.y, _arg2.upperBound.y);
}
public static function Combine(_arg1:b2AABB, _arg2:b2AABB):b2AABB{
var _local3:b2AABB = new (b2AABB);
_local3.Combine(_arg1, _arg2);
return (_local3);
}
}
}//package Box2D.Collision
Section 65
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
private static var s_v12:b2Vec2 = new b2Vec2();
private static var s_v11:b2Vec2 = new b2Vec2();
private static var s_edgeBO:Array = new Array(1);
private static var s_tangent2:b2Vec2 = new b2Vec2();
private static var s_planePoint:b2Vec2 = new b2Vec2();
private static var s_localTangent:b2Vec2 = new b2Vec2();
private static var s_clipPoints1:Array = MakeClipPointVector();
private static var s_clipPoints2:Array = MakeClipPointVector();
private static var s_localNormal:b2Vec2 = new b2Vec2();
private static var s_edgeAO:Array = new Array(1);
private static var s_tangent:b2Vec2 = new b2Vec2();
private static var s_normal:b2Vec2 = new b2Vec2();
private static var s_incidentEdge:Array = MakeClipPointVector();
public static function EdgeSeparation(_arg1:b2PolygonShape, _arg2:b2Transform, _arg3:int, _arg4:b2PolygonShape, _arg5:b2Transform):Number{
var _local11:b2Mat22;
var _local12:b2Vec2;
var _local25:Number;
var _local6:int = _arg1.m_vertexCount;
var _local7:Array = _arg1.m_vertices;
var _local8:Array = _arg1.m_normals;
var _local9:int = _arg4.m_vertexCount;
var _local10:Array = _arg4.m_vertices;
_local11 = _arg2.R;
_local12 = _local8[_arg3];
var _local13:Number = ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y));
var _local14:Number = ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y));
_local11 = _arg5.R;
var _local15:Number = ((_local11.col1.x * _local13) + (_local11.col1.y * _local14));
var _local16:Number = ((_local11.col2.x * _local13) + (_local11.col2.y * _local14));
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local12 = _local10[_local19];
_local25 = ((_local12.x * _local15) + (_local12.y * _local16));
if (_local25 < _local18){
_local18 = _local25;
_local17 = _local19;
};
_local19++;
};
_local12 = _local7[_arg3];
_local11 = _arg2.R;
var _local20:Number = (_arg2.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local21:Number = (_arg2.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local12 = _local10[_local17];
_local11 = _arg5.R;
var _local22:Number = (_arg5.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local23:Number = (_arg5.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local22 = (_local22 - _local20);
_local23 = (_local23 - _local21);
var _local24:Number = ((_local22 * _local13) + (_local23 * _local14));
return (_local24);
}
public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{
var _local5:ClipVertex;
var _local6:int;
var _local7:b2Vec2;
var _local9:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local13:ClipVertex;
_local6 = 0;
_local5 = _arg2[0];
_local7 = _local5.v;
_local5 = _arg2[1];
var _local8:b2Vec2 = _local5.v;
_local9 = (((_arg3.x * _local7.x) + (_arg3.y * _local7.y)) - _arg4);
var _local10:Number = (((_arg3.x * _local8.x) + (_arg3.y * _local8.y)) - _arg4);
if (_local9 <= 0){
var _temp1 = _local6;
_local6 = (_local6 + 1);
_arg1[_temp1].Set(_arg2[0]);
};
if (_local10 <= 0){
var _temp2 = _local6;
_local6 = (_local6 + 1);
_arg1[_temp2].Set(_arg2[1]);
};
if ((_local9 * _local10) < 0){
_local11 = (_local9 / (_local9 - _local10));
_local5 = _arg1[_local6];
_local12 = _local5.v;
_local12.x = (_local7.x + (_local11 * (_local8.x - _local7.x)));
_local12.y = (_local7.y + (_local11 * (_local8.y - _local7.y)));
_local5 = _arg1[_local6];
if (_local9 > 0){
_local13 = _arg2[0];
_local5.id = _local13.id;
} else {
_local13 = _arg2[1];
_local5.id = _local13.id;
};
_local6++;
};
return (_local6);
}
private static function MakeClipPointVector():Array{
var _local1:Array = new Array(2);
_local1[0] = new ClipVertex();
_local1[1] = new ClipVertex();
return (_local1);
}
public static function CollideCircles(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2Transform, _arg4:b2CircleShape, _arg5:b2Transform):void{
var _local6:b2Mat22;
var _local7:b2Vec2;
_arg1.m_pointCount = 0;
_local6 = _arg3.R;
_local7 = _arg2.m_p;
var _local8:Number = (_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local9:Number = (_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local6 = _arg5.R;
_local7 = _arg4.m_p;
var _local10:Number = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local11:Number = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
var _local12:Number = (_local10 - _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = ((_local12 * _local12) + (_local13 * _local13));
var _local15:Number = (_arg2.m_radius + _arg4.m_radius);
if (_local14 > (_local15 * _local15)){
return;
};
_arg1.m_type = b2Manifold.e_circles;
_arg1.m_localPoint.SetV(_arg2.m_p);
_arg1.m_localPlaneNormal.SetZero();
_arg1.m_pointCount = 1;
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
}
public static function FindIncidentEdge(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:int, _arg5:b2PolygonShape, _arg6:b2Transform):void{
var _local12:b2Mat22;
var _local13:b2Vec2;
var _local20:ClipVertex;
var _local23:Number;
var _local7:int = _arg2.m_vertexCount;
var _local8:Array = _arg2.m_normals;
var _local9:int = _arg5.m_vertexCount;
var _local10:Array = _arg5.m_vertices;
var _local11:Array = _arg5.m_normals;
_local12 = _arg3.R;
_local13 = _local8[_arg4];
var _local14:Number = ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y));
var _local15:Number = ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y));
_local12 = _arg6.R;
var _local16:Number = ((_local12.col1.x * _local14) + (_local12.col1.y * _local15));
_local15 = ((_local12.col2.x * _local14) + (_local12.col2.y * _local15));
_local14 = _local16;
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local13 = _local11[_local19];
_local23 = ((_local14 * _local13.x) + (_local15 * _local13.y));
if (_local23 < _local18){
_local18 = _local23;
_local17 = _local19;
};
_local19++;
};
var _local21:int = _local17;
var _local22:int = (((_local21 + 1) < _local9)) ? (_local21 + 1) : 0;
_local20 = _arg1[0];
_local13 = _local10[_local21];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local21;
_local20.id.features.incidentVertex = 0;
_local20 = _arg1[1];
_local13 = _local10[_local22];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local22;
_local20.id.features.incidentVertex = 1;
}
public static function CollidePolygonAndCircle(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2CircleShape, _arg5:b2Transform):void{
var _local6:b2ManifoldPoint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:b2Mat22;
var _local17:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
_arg1.m_pointCount = 0;
_local12 = _arg5.R;
_local11 = _arg4.m_p;
var _local13:Number = (_arg5.position.x + ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y)));
var _local14:Number = (_arg5.position.y + ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y)));
_local7 = (_local13 - _arg3.position.x);
_local8 = (_local14 - _arg3.position.y);
_local12 = _arg3.R;
var _local15:Number = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
var _local16:Number = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
var _local18:int;
var _local19:Number = -(Number.MAX_VALUE);
var _local20:Number = (_arg2.m_radius + _arg4.m_radius);
var _local21:int = _arg2.m_vertexCount;
var _local22:Array = _arg2.m_vertices;
var _local23:Array = _arg2.m_normals;
var _local24:int;
while (_local24 < _local21) {
_local11 = _local22[_local24];
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
_local11 = _local23[_local24];
_local31 = ((_local11.x * _local7) + (_local11.y * _local8));
if (_local31 > _local20){
return;
};
if (_local31 > _local19){
_local19 = _local31;
_local18 = _local24;
};
_local24++;
};
var _local25:int = _local18;
var _local26:int = (((_local25 + 1) < _local21)) ? (_local25 + 1) : 0;
var _local27:b2Vec2 = _local22[_local25];
var _local28:b2Vec2 = _local22[_local26];
if (_local19 < Number.MIN_VALUE){
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.SetV(_local23[_local18]);
_arg1.m_localPoint.x = (0.5 * (_local27.x + _local28.x));
_arg1.m_localPoint.y = (0.5 * (_local27.y + _local28.y));
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
return;
};
var _local29:Number = (((_local15 - _local27.x) * (_local28.x - _local27.x)) + ((_local16 - _local27.y) * (_local28.y - _local27.y)));
var _local30:Number = (((_local15 - _local28.x) * (_local27.x - _local28.x)) + ((_local16 - _local28.y) * (_local27.y - _local28.y)));
if (_local29 <= 0){
if ((((_local15 - _local27.x) * (_local15 - _local27.x)) + ((_local16 - _local27.y) * (_local16 - _local27.y))) > (_local20 * _local20)){
return;
};
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.x = (_local15 - _local27.x);
_arg1.m_localPlaneNormal.y = (_local16 - _local27.y);
_arg1.m_localPlaneNormal.Normalize();
_arg1.m_localPoint.SetV(_local27);
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
} else {
if (_local30 <= 0){
if ((((_local15 - _local28.x) * (_local15 - _local28.x)) + ((_local16 - _local28.y) * (_local16 - _local28.y))) > (_local20 * _local20)){
return;
};
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.x = (_local15 - _local28.x);
_arg1.m_localPlaneNormal.y = (_local16 - _local28.y);
_arg1.m_localPlaneNormal.Normalize();
_arg1.m_localPoint.SetV(_local28);
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
} else {
_local32 = (0.5 * (_local27.x + _local28.x));
_local33 = (0.5 * (_local27.y + _local28.y));
_local19 = (((_local15 - _local32) * _local23[_local25].x) + ((_local16 - _local33) * _local23[_local25].y));
if (_local19 > _local20){
return;
};
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.x = _local23[_local25].x;
_arg1.m_localPlaneNormal.y = _local23[_local25].y;
_arg1.m_localPlaneNormal.Normalize();
_arg1.m_localPoint.Set(_local32, _local33);
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
};
};
}
public static function CollidePolygons(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2PolygonShape, _arg5:b2Transform):void{
var _local6:ClipVertex;
var _local12:b2PolygonShape;
var _local13:b2PolygonShape;
var _local14:b2Transform;
var _local15:b2Transform;
var _local16:int;
var _local17:uint;
var _local20:b2Mat22;
var _local25:b2Vec2;
var _local39:int;
var _local42:Number;
var _local43:b2ManifoldPoint;
var _local44:Number;
var _local45:Number;
_arg1.m_pointCount = 0;
var _local7:Number = (_arg2.m_radius + _arg4.m_radius);
var _local8:int;
s_edgeAO[0] = _local8;
var _local9:Number = FindMaxSeparation(s_edgeAO, _arg2, _arg3, _arg4, _arg5);
_local8 = s_edgeAO[0];
if (_local9 > _local7){
return;
};
var _local10:int;
s_edgeBO[0] = _local10;
var _local11:Number = FindMaxSeparation(s_edgeBO, _arg4, _arg5, _arg2, _arg3);
_local10 = s_edgeBO[0];
if (_local11 > _local7){
return;
};
var _local18:Number = 0.98;
var _local19:Number = 0.001;
if (_local11 > ((_local18 * _local9) + _local19)){
_local12 = _arg4;
_local13 = _arg2;
_local14 = _arg5;
_local15 = _arg3;
_local16 = _local10;
_arg1.m_type = b2Manifold.e_faceB;
_local17 = 1;
} else {
_local12 = _arg2;
_local13 = _arg4;
_local14 = _arg3;
_local15 = _arg5;
_local16 = _local8;
_arg1.m_type = b2Manifold.e_faceA;
_local17 = 0;
};
var _local21:Array = s_incidentEdge;
FindIncidentEdge(_local21, _local12, _local14, _local16, _local13, _local15);
var _local22:int = _local12.m_vertexCount;
var _local23:Array = _local12.m_vertices;
var _local24:b2Vec2 = _local23[_local16];
if ((_local16 + 1) < _local22){
_local25 = _local23[int((_local16 + 1))];
} else {
_local25 = _local23[0];
};
var _local26:b2Vec2 = s_localTangent;
_local26.Set((_local25.x - _local24.x), (_local25.y - _local24.y));
_local26.Normalize();
var _local27:b2Vec2 = s_localNormal;
_local27.x = _local26.y;
_local27.y = -(_local26.x);
var _local28:b2Vec2 = s_planePoint;
_local28.Set((0.5 * (_local24.x + _local25.x)), (0.5 * (_local24.y + _local25.y)));
var _local29:b2Vec2 = s_tangent;
_local20 = _local14.R;
_local29.x = ((_local20.col1.x * _local26.x) + (_local20.col2.x * _local26.y));
_local29.y = ((_local20.col1.y * _local26.x) + (_local20.col2.y * _local26.y));
var _local30:b2Vec2 = s_tangent2;
_local30.x = -(_local29.x);
_local30.y = -(_local29.y);
var _local31:b2Vec2 = s_normal;
_local31.x = _local29.y;
_local31.y = -(_local29.x);
var _local32:b2Vec2 = s_v11;
var _local33:b2Vec2 = s_v12;
_local32.x = (_local14.position.x + ((_local20.col1.x * _local24.x) + (_local20.col2.x * _local24.y)));
_local32.y = (_local14.position.y + ((_local20.col1.y * _local24.x) + (_local20.col2.y * _local24.y)));
_local33.x = (_local14.position.x + ((_local20.col1.x * _local25.x) + (_local20.col2.x * _local25.y)));
_local33.y = (_local14.position.y + ((_local20.col1.y * _local25.x) + (_local20.col2.y * _local25.y)));
var _local34:Number = ((_local31.x * _local32.x) + (_local31.y * _local32.y));
var _local35:Number = (((-(_local29.x) * _local32.x) - (_local29.y * _local32.y)) + _local7);
var _local36:Number = (((_local29.x * _local33.x) + (_local29.y * _local33.y)) + _local7);
var _local37:Array = s_clipPoints1;
var _local38:Array = s_clipPoints2;
_local39 = ClipSegmentToLine(_local37, _local21, _local30, _local35);
if (_local39 < 2){
return;
};
_local39 = ClipSegmentToLine(_local38, _local37, _local29, _local36);
if (_local39 < 2){
return;
};
_arg1.m_localPlaneNormal.SetV(_local27);
_arg1.m_localPoint.SetV(_local28);
var _local40:int;
var _local41:int;
while (_local41 < b2Settings.b2_maxManifoldPoints) {
_local6 = _local38[_local41];
_local42 = (((_local31.x * _local6.v.x) + (_local31.y * _local6.v.y)) - _local34);
if (_local42 <= _local7){
_local43 = _arg1.m_points[_local40];
_local20 = _local15.R;
_local44 = (_local6.v.x - _local15.position.x);
_local45 = (_local6.v.y - _local15.position.y);
_local43.m_localPoint.x = ((_local44 * _local20.col1.x) + (_local45 * _local20.col1.y));
_local43.m_localPoint.y = ((_local44 * _local20.col2.x) + (_local45 * _local20.col2.y));
_local43.m_id.Set(_local6.id);
_local43.m_id.features.flip = _local17;
_local40++;
};
_local41++;
};
_arg1.m_pointCount = _local40;
}
public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2PolygonShape, _arg5:b2Transform):Number{
var _local8:b2Vec2;
var _local9:b2Mat22;
var _local22:int;
var _local23:Number;
var _local24:int;
var _local25:Number;
var _local6:int = _arg2.m_vertexCount;
var _local7:Array = _arg2.m_normals;
_local9 = _arg5.R;
_local8 = _arg4.m_centroid;
var _local10:Number = (_arg5.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y)));
var _local11:Number = (_arg5.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y)));
_local9 = _arg3.R;
_local8 = _arg2.m_centroid;
_local10 = (_local10 - (_arg3.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y))));
_local11 = (_local11 - (_arg3.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y))));
var _local12:Number = ((_local10 * _arg3.R.col1.x) + (_local11 * _arg3.R.col1.y));
var _local13:Number = ((_local10 * _arg3.R.col2.x) + (_local11 * _arg3.R.col2.y));
var _local14:int;
var _local15:Number = -(Number.MAX_VALUE);
var _local16:int;
while (_local16 < _local6) {
_local8 = _local7[_local16];
_local25 = ((_local8.x * _local12) + (_local8.y * _local13));
if (_local25 > _local15){
_local15 = _local25;
_local14 = _local16;
};
_local16++;
};
var _local17:Number = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
var _local18:int = (((_local14 - 1) >= 0)) ? (_local14 - 1) : (_local6 - 1);
var _local19:Number = EdgeSeparation(_arg2, _arg3, _local18, _arg4, _arg5);
var _local20:int = (((_local14 + 1) < _local6)) ? (_local14 + 1) : 0;
var _local21:Number = EdgeSeparation(_arg2, _arg3, _local20, _arg4, _arg5);
if ((((_local19 > _local17)) && ((_local19 > _local21)))){
_local24 = -1;
_local22 = _local18;
_local23 = _local19;
} else {
if (_local21 > _local17){
_local24 = 1;
_local22 = _local20;
_local23 = _local21;
} else {
_arg1[0] = _local14;
return (_local17);
};
};
while (true) {
if (_local24 == -1){
_local14 = (((_local22 - 1) >= 0)) ? (_local22 - 1) : (_local6 - 1);
} else {
_local14 = (((_local22 + 1) < _local6)) ? (_local22 + 1) : 0;
};
_local17 = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
if (_local17 > _local23){
_local22 = _local14;
_local23 = _local17;
} else {
break;
};
};
_arg1[0] = _local22;
return (_local23);
}
public static function TestOverlap(_arg1:b2AABB, _arg2:b2AABB):Boolean{
var _local3:b2Vec2 = _arg2.lowerBound;
var _local4:b2Vec2 = _arg1.upperBound;
var _local5:Number = (_local3.x - _local4.x);
var _local6:Number = (_local3.y - _local4.y);
_local3 = _arg1.lowerBound;
_local4 = _arg2.upperBound;
var _local7:Number = (_local3.x - _local4.x);
var _local8:Number = (_local3.y - _local4.y);
if ((((_local5 > 0)) || ((_local6 > 0)))){
return (false);
};
if ((((_local7 > 0)) || ((_local8 > 0)))){
return (false);
};
return (true);
}
}
}//package Box2D.Collision
Section 66
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
import Box2D.Common.*;
public class b2ContactID {
b2internal var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(_arg1:b2ContactID):void{
key = _arg1._key;
}
public function Copy():b2ContactID{
var _local1:b2ContactID = new b2ContactID();
_local1.key = key;
return (_local1);
}
public function set key(_arg1:uint):void{
_key = _arg1;
features._referenceEdge = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
public function get key():uint{
return (_key);
}
}
}//package Box2D.Collision
Section 67
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
public class b2ContactPoint {
public var friction:Number;
public var separation:Number;
public var normal:b2Vec2;
public var position:b2Vec2;
public var restitution:Number;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var id:b2ContactID;
public var velocity:b2Vec2;
public function b2ContactPoint(){
position = new b2Vec2();
velocity = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 68
//b2Distance (Box2D.Collision.b2Distance)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Distance {
private static var b2_gjkIters:int;
private static var b2_gjkMaxIters:int;
private static var s_saveB:Array = new Array(3);
private static var s_simplex:b2Simplex = new b2Simplex();
private static var b2_gjkCalls:int;
private static var s_saveA:Array = new Array(3);
public static function Distance(_arg1:b2DistanceOutput, _arg2:b2SimplexCache, _arg3:b2DistanceInput):void{
var _local17:int;
var _local18:b2Vec2;
var _local20:b2Vec2;
var _local21:b2SimplexVertex;
var _local22:Boolean;
var _local23:Number;
var _local24:Number;
var _local25:b2Vec2;
b2_gjkCalls++;
var _local4:b2DistanceProxy = _arg3.proxyA;
var _local5:b2DistanceProxy = _arg3.proxyB;
var _local6:b2Transform = _arg3.transformA;
var _local7:b2Transform = _arg3.transformB;
var _local8:b2Simplex = s_simplex;
_local8.ReadCache(_arg2, _local4, _local6, _local5, _local7);
var _local9:Array = _local8.m_vertices;
var _local10 = 20;
var _local11:Array = s_saveA;
var _local12:Array = s_saveB;
var _local13:int;
var _local14:b2Vec2 = _local8.GetClosestPoint();
var _local15:Number = _local14.LengthSquared();
var _local16:Number = _local15;
var _local19:int;
while (_local19 < _local10) {
_local13 = _local8.m_count;
_local17 = 0;
while (_local17 < _local13) {
_local11[_local17] = _local9[_local17].indexA;
_local12[_local17] = _local9[_local17].indexB;
_local17++;
};
switch (_local8.m_count){
case 1:
break;
case 2:
_local8.Solve2();
break;
case 3:
_local8.Solve3();
break;
default:
b2Settings.b2Assert(false);
};
if (_local8.m_count == 3){
break;
};
_local18 = _local8.GetClosestPoint();
_local16 = _local18.LengthSquared();
if (_local16 > _local15){
};
_local15 = _local16;
_local20 = _local8.GetSearchDirection();
if (_local20.LengthSquared() < (Number.MIN_VALUE * Number.MIN_VALUE)){
break;
};
_local21 = _local9[_local8.m_count];
_local21.indexA = _local4.GetSupport(b2Math.MulTMV(_local6.R, _local20.GetNegative()));
_local21.wA = b2Math.MulX(_local6, _local4.GetVertex(_local21.indexA));
_local21.indexB = _local5.GetSupport(b2Math.MulTMV(_local7.R, _local20));
_local21.wB = b2Math.MulX(_local7, _local5.GetVertex(_local21.indexB));
_local21.w = b2Math.SubtractVV(_local21.wB, _local21.wA);
_local19++;
b2_gjkIters++;
_local22 = false;
_local17 = 0;
while (_local17 < _local13) {
if ((((_local21.indexA == _local11[_local17])) && ((_local21.indexB == _local12[_local17])))){
_local22 = true;
break;
};
_local17++;
};
if (_local22){
break;
};
_local8.m_count++;
};
b2_gjkMaxIters = b2Math.Max(b2_gjkMaxIters, _local19);
_local8.GetWitnessPoints(_arg1.pointA, _arg1.pointB);
_arg1.distance = b2Math.SubtractVV(_arg1.pointA, _arg1.pointB).Length();
_arg1.iterations = _local19;
_local8.WriteCache(_arg2);
if (_arg3.useRadii){
_local23 = _local4.m_radius;
_local24 = _local5.m_radius;
if ((((_arg1.distance > (_local23 + _local24))) && ((_arg1.distance > Number.MIN_VALUE)))){
_arg1.distance = (_arg1.distance - (_local23 + _local24));
_local25 = b2Math.SubtractVV(_arg1.pointB, _arg1.pointA);
_local25.Normalize();
_arg1.pointA.x = (_arg1.pointA.x + (_local23 * _local25.x));
_arg1.pointA.y = (_arg1.pointA.y + (_local23 * _local25.y));
_arg1.pointB.x = (_arg1.pointB.x - (_local24 * _local25.x));
_arg1.pointB.y = (_arg1.pointB.y - (_local24 * _local25.y));
} else {
_local18 = new b2Vec2();
_local18.x = (0.5 * (_arg1.pointA.x + _arg1.pointB.x));
_local18.y = (0.5 * (_arg1.pointA.y + _arg1.pointB.y));
_arg1.pointA.x = (_arg1.pointB.x = _local18.x);
_arg1.pointA.y = (_arg1.pointB.y = _local18.y);
_arg1.distance = 0;
};
};
}
}
}//package Box2D.Collision
Section 69
//b2DistanceInput (Box2D.Collision.b2DistanceInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DistanceInput {
public var proxyA:b2DistanceProxy;
public var proxyB:b2DistanceProxy;
public var transformA:b2Transform;
public var transformB:b2Transform;
public var useRadii:Boolean;
}
}//package Box2D.Collision
Section 70
//b2DistanceOutput (Box2D.Collision.b2DistanceOutput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DistanceOutput {
public var pointA:b2Vec2;
public var distance:Number;
public var iterations:int;
public var pointB:b2Vec2;
public function b2DistanceOutput(){
pointA = new b2Vec2();
pointB = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 71
//b2DistanceProxy (Box2D.Collision.b2DistanceProxy)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2DistanceProxy {
public var m_radius:Number;
public var m_vertices:Array;
public var m_count:int;
public function GetVertex(_arg1:int):b2Vec2{
b2Settings.b2Assert((((0 <= _arg1)) && ((_arg1 < m_count))));
return (m_vertices[_arg1]);
}
public function Set(_arg1:b2Shape):void{
var _local2:b2CircleShape;
var _local3:b2PolygonShape;
switch (_arg1.GetType()){
case b2Shape.e_circleShape:
_local2 = (_arg1 as b2CircleShape);
m_vertices = new Array(1, true);
m_vertices[0] = _local2.m_p;
m_count = 1;
m_radius = _local2.m_radius;
break;
case b2Shape.e_polygonShape:
_local3 = (_arg1 as b2PolygonShape);
m_vertices = _local3.m_vertices;
m_count = _local3.m_vertexCount;
m_radius = _local3.m_radius;
break;
default:
b2Settings.b2Assert(false);
};
}
public function GetSupportVertex(_arg1:b2Vec2):b2Vec2{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_count) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (m_vertices[_local2]);
}
public function GetVertexCount():int{
return (m_count);
}
public function GetSupport(_arg1:b2Vec2):Number{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_count) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (_local2);
}
}
}//package Box2D.Collision
Section 72
//b2DynamicTree (Box2D.Collision.b2DynamicTree)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2DynamicTree {
private var m_insertionCount:int;
private var m_root:b2DynamicTreeNode;
private var m_freeList:b2DynamicTreeNode;
private var m_path:uint;
public function b2DynamicTree(){
m_root = null;
m_freeList = null;
m_path = 0;
m_insertionCount = 0;
}
private function RemoveLeaf(_arg1:b2DynamicTreeNode):void{
var _local4:b2DynamicTreeNode;
var _local5:b2AABB;
if (_arg1 == m_root){
m_root = null;
return;
};
var _local2:b2DynamicTreeNode = _arg1.parent;
var _local3:b2DynamicTreeNode = _local2.parent;
if (_local2.child1 == _arg1){
_local4 = _local2.child2;
} else {
_local4 = _local2.child1;
};
if (_local3){
if (_local3.child1 == _local2){
_local3.child1 = _local4;
} else {
_local3.child2 = _local4;
};
_local4.parent = _local3;
FreeNode(_local2);
while (_local3) {
_local5 = _local3.aabb;
_local3.aabb = b2AABB.Combine(_local3.child1.aabb, _local3.child2.aabb);
if (_local5.Contains(_local3.aabb)){
break;
};
_local3 = _local3.parent;
};
} else {
m_root = _local4;
_local4.parent = null;
FreeNode(_local2);
};
}
public function GetFatAABB(_arg1:b2DynamicTreeNode):b2AABB{
return (_arg1.aabb);
}
public function Query(_arg1:Function, _arg2:b2AABB):void{
var _local5:b2DynamicTreeNode;
var _local6:Boolean;
if (m_root == null){
return;
};
var _local3:Array = new Array();
var _local4:int;
var _temp1 = _local4;
_local4 = (_local4 + 1);
var _local7 = _temp1;
_local3[_local7] = m_root;
while (_local4 > 0) {
--_local4;
_local5 = _local3[_local4];
if (_local5.aabb.TestOverlap(_arg2)){
if (_local5.IsLeaf()){
_local6 = _arg1(_local5);
if (!_local6){
return;
};
} else {
var _temp2 = _local4;
_local4 = (_local4 + 1);
var _local8 = _temp2;
_local3[_local8] = _local5.child1;
var _temp3 = _local4;
_local4 = (_local4 + 1);
var _local9 = _temp3;
_local3[_local9] = _local5.child2;
};
};
};
}
public function RayCast(_arg1:Function, _arg2:b2RayCastInput):void{
var _local3:b2Vec2;
var _local9:b2AABB;
var _local10:Number;
var _local11:Number;
var _local14:b2DynamicTreeNode;
var _local15:b2Vec2;
var _local16:b2Vec2;
var _local17:Number;
var _local18:b2RayCastInput;
if (m_root == null){
return;
};
_local3 = _arg2.p1;
var _local4:b2Vec2 = _arg2.p2;
var _local5:b2Vec2 = b2Math.SubtractVV(_local3, _local4);
_local5.Normalize();
var _local6:b2Vec2 = b2Math.CrossFV(1, _local5);
var _local7:b2Vec2 = b2Math.AbsV(_local6);
var _local8:Number = _arg2.maxFraction;
_local9 = new b2AABB();
_local10 = (_local3.x + (_local8 * (_local4.x - _local3.x)));
_local11 = (_local3.y + (_local8 * (_local4.y - _local3.y)));
_local9.lowerBound.x = Math.min(_local3.x, _local10);
_local9.lowerBound.y = Math.min(_local3.y, _local11);
_local9.upperBound.x = Math.max(_local3.x, _local10);
_local9.upperBound.y = Math.max(_local3.y, _local11);
var _local12:Array = new Array();
var _local13:int;
var _temp1 = _local13;
_local13 = (_local13 + 1);
var _local19 = _temp1;
_local12[_local19] = m_root;
while (_local13 > 0) {
--_local13;
_local14 = _local12[_local13];
if (_local14.aabb.TestOverlap(_local9) == false){
} else {
_local15 = _local14.aabb.GetCenter();
_local16 = _local14.aabb.GetExtents();
_local17 = ((Math.abs(((_local6.x * (_local3.x - _local15.x)) + (_local6.y * (_local3.y - _local15.y)))) - (_local7.x * _local16.x)) - (_local7.y * _local16.y));
if (_local17 > 0){
} else {
if (_local14.IsLeaf()){
_local18 = new b2RayCastInput();
_local18.p1 = _arg2.p1;
_local18.p2 = _arg2.p2;
_local18.maxFraction = _arg2.maxFraction;
_local8 = _arg1(_local18, _local14);
if (_local8 == 0){
return;
};
_local10 = (_local3.x + (_local8 * (_local4.x - _local3.x)));
_local11 = (_local3.y + (_local8 * (_local4.y - _local3.y)));
_local9.lowerBound.x = Math.min(_local3.x, _local10);
_local9.lowerBound.y = Math.min(_local3.y, _local11);
_local9.upperBound.x = Math.max(_local3.x, _local10);
_local9.upperBound.y = Math.max(_local3.y, _local11);
} else {
var _temp2 = _local13;
_local13 = (_local13 + 1);
var _local20 = _temp2;
_local12[_local20] = _local14.child1;
var _temp3 = _local13;
_local13 = (_local13 + 1);
var _local21 = _temp3;
_local12[_local21] = _local14.child2;
};
};
};
};
}
public function GetUserData(_arg1:b2DynamicTreeNode){
return (_arg1.userData);
}
private function FreeNode(_arg1:b2DynamicTreeNode):void{
_arg1.parent = m_freeList;
m_freeList = _arg1;
}
public function Rebalance(_arg1:int):void{
var _local3:b2DynamicTreeNode;
var _local4:uint;
if (m_root == null){
return;
};
var _local2:int;
while (_local2 < _arg1) {
_local3 = m_root;
_local4 = 0;
while (_local3.IsLeaf() == false) {
_local3 = (((m_path >> _local4) & 1)) ? _local3.child2 : _local3.child1;
_local4 = ((_local4 + 1) & 31);
};
m_path++;
RemoveLeaf(_local3);
InsertLeaf(_local3);
_local2++;
};
}
public function CreateProxy(_arg1:b2AABB, _arg2):b2DynamicTreeNode{
var _local3:b2DynamicTreeNode;
var _local4:Number;
var _local5:Number;
_local3 = AllocateNode();
_local4 = b2Settings.b2_aabbExtension;
_local5 = b2Settings.b2_aabbExtension;
_local3.aabb.lowerBound.x = (_arg1.lowerBound.x - _local4);
_local3.aabb.lowerBound.y = (_arg1.lowerBound.y - _local5);
_local3.aabb.upperBound.x = (_arg1.upperBound.x + _local4);
_local3.aabb.upperBound.y = (_arg1.upperBound.y + _local5);
_local3.userData = _arg2;
InsertLeaf(_local3);
return (_local3);
}
public function DestroyProxy(_arg1:b2DynamicTreeNode):void{
RemoveLeaf(_arg1);
FreeNode(_arg1);
}
private function InsertLeaf(_arg1:b2DynamicTreeNode):void{
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
m_insertionCount++;
if (m_root == null){
m_root = _arg1;
m_root.parent = null;
return;
};
var _local2:b2Vec2 = _arg1.aabb.GetCenter();
var _local3:b2DynamicTreeNode = m_root;
if (_local3.IsLeaf() == false){
do {
_local6 = _local3.child1;
_local7 = _local3.child2;
_local8 = (Math.abs((((_local6.aabb.lowerBound.x + _local6.aabb.upperBound.x) / 2) - _local2.x)) + Math.abs((((_local6.aabb.lowerBound.y + _local6.aabb.upperBound.y) / 2) - _local2.y)));
_local9 = (Math.abs((((_local7.aabb.lowerBound.x + _local7.aabb.upperBound.x) / 2) - _local2.x)) + Math.abs((((_local7.aabb.lowerBound.y + _local7.aabb.upperBound.y) / 2) - _local2.y)));
if (_local8 < _local9){
_local3 = _local6;
} else {
_local3 = _local7;
};
} while (_local3.IsLeaf() == false);
};
var _local4:b2DynamicTreeNode = _local3.parent;
var _local5:b2DynamicTreeNode = AllocateNode();
_local5.parent = _local4;
_local5.userData = null;
_local5.aabb.Combine(_arg1.aabb, _local3.aabb);
if (_local4){
if (_local3.parent.child1 == _local3){
_local4.child1 = _local5;
} else {
_local4.child2 = _local5;
};
_local5.child1 = _local3;
_local5.child2 = _arg1;
_local3.parent = _local5;
_arg1.parent = _local5;
do {
} while (!(_local4.aabb.Contains(_local5.aabb)));
} else {
_local5.child1 = _local3;
_local5.child2 = _arg1;
_local3.parent = _local5;
_arg1.parent = _local5;
m_root = _local5;
};
}
public function MoveProxy(_arg1:b2DynamicTreeNode, _arg2:b2AABB, _arg3:b2Vec2):Boolean{
var _local4:Number;
var _local5:Number;
b2Settings.b2Assert(_arg1.IsLeaf());
if (_arg1.aabb.Contains(_arg2)){
return (false);
};
RemoveLeaf(_arg1);
_local4 = (b2Settings.b2_aabbExtension + (b2Settings.b2_aabbMultiplier * ((_arg3.x > 0)) ? _arg3.x : -(_arg3.x)));
_local5 = (b2Settings.b2_aabbExtension + (b2Settings.b2_aabbMultiplier * ((_arg3.y > 0)) ? _arg3.y : -(_arg3.y)));
_arg1.aabb.lowerBound.x = (_arg2.lowerBound.x - _local4);
_arg1.aabb.lowerBound.y = (_arg2.lowerBound.y - _local5);
_arg1.aabb.upperBound.x = (_arg2.upperBound.x + _local4);
_arg1.aabb.upperBound.y = (_arg2.upperBound.y + _local5);
InsertLeaf(_arg1);
return (true);
}
private function AllocateNode():b2DynamicTreeNode{
var _local1:b2DynamicTreeNode;
if (m_freeList){
_local1 = m_freeList;
m_freeList = _local1.parent;
_local1.parent = null;
_local1.child1 = null;
_local1.child2 = null;
return (_local1);
};
return (new b2DynamicTreeNode());
}
}
}//package Box2D.Collision
Section 73
//b2DynamicTreeBroadPhase (Box2D.Collision.b2DynamicTreeBroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DynamicTreeBroadPhase implements IBroadPhase {
private var m_moveBuffer:Array;
private var m_tree:b2DynamicTree;
private var m_pairBuffer:Array;
private var m_pairCount:int;// = 0
private var m_proxyCount:int;
public function b2DynamicTreeBroadPhase(){
m_tree = new b2DynamicTree();
m_moveBuffer = new Array();
m_pairBuffer = new Array();
super();
}
public function Validate():void{
}
private function UnBufferMove(_arg1:b2DynamicTreeNode):void{
var _local2:int = m_moveBuffer.indexOf(_arg1);
m_moveBuffer.splice(_local2, 1);
}
private function BufferMove(_arg1:b2DynamicTreeNode):void{
m_moveBuffer[m_moveBuffer.length] = _arg1;
}
private function ComparePairs(_arg1:b2DynamicTreePair, _arg2:b2DynamicTreePair):int{
return (0);
}
public function GetProxyCount():int{
return (m_proxyCount);
}
public function GetFatAABB(_arg1):b2AABB{
return (m_tree.GetFatAABB(_arg1));
}
public function Query(_arg1:Function, _arg2:b2AABB):void{
m_tree.Query(_arg1, _arg2);
}
public function Rebalance(_arg1:int):void{
m_tree.Rebalance(_arg1);
}
public function TestOverlap(_arg1, _arg2):Boolean{
var _local3:b2AABB = m_tree.GetFatAABB(_arg1);
var _local4:b2AABB = m_tree.GetFatAABB(_arg2);
return (_local3.TestOverlap(_local4));
}
public function UpdatePairs(_arg1:Function):void{
var queryProxy:b2DynamicTreeNode;
var i:int;
var fatAABB:b2AABB;
var primaryPair:b2DynamicTreePair;
var userDataA:*;
var userDataB:*;
var pair:b2DynamicTreePair;
var callback = _arg1;
m_pairCount = 0;
for each (queryProxy in m_moveBuffer) {
var QueryCallback:Function = function (_arg1:b2DynamicTreeNode):Boolean{
if (_arg1 == queryProxy){
return (true);
};
if (m_pairCount == m_pairBuffer.length){
m_pairBuffer[m_pairCount] = new b2DynamicTreePair();
};
var _local2:b2DynamicTreePair = m_pairBuffer[m_pairCount];
_local2.proxyA = ((_arg1 < queryProxy)) ? _arg1 : queryProxy;
_local2.proxyB = ((_arg1 >= queryProxy)) ? _arg1 : queryProxy;
m_pairCount++;
return (true);
};
fatAABB = m_tree.GetFatAABB(queryProxy);
m_tree.Query(QueryCallback, fatAABB);
};
m_moveBuffer.length = 0;
i = 0;
while (i < m_pairCount) {
primaryPair = m_pairBuffer[i];
userDataA = m_tree.GetUserData(primaryPair.proxyA);
userDataB = m_tree.GetUserData(primaryPair.proxyB);
callback(userDataA, userDataB);
i = (i + 1);
while (i < m_pairCount) {
pair = m_pairBuffer[i];
if (((!((pair.proxyA == primaryPair.proxyA))) || (!((pair.proxyB == primaryPair.proxyB))))){
break;
};
i = (i + 1);
};
};
}
public function RayCast(_arg1:Function, _arg2:b2RayCastInput):void{
m_tree.RayCast(_arg1, _arg2);
}
public function CreateProxy(_arg1:b2AABB, _arg2){
var _local3:b2DynamicTreeNode = m_tree.CreateProxy(_arg1, _arg2);
m_proxyCount++;
BufferMove(_local3);
return (_local3);
}
public function GetUserData(_arg1){
return (m_tree.GetUserData(_arg1));
}
public function DestroyProxy(_arg1):void{
UnBufferMove(_arg1);
m_proxyCount--;
m_tree.DestroyProxy(_arg1);
}
public function MoveProxy(_arg1, _arg2:b2AABB, _arg3:b2Vec2):void{
var _local4:Boolean = m_tree.MoveProxy(_arg1, _arg2, _arg3);
if (_local4){
BufferMove(_arg1);
};
}
}
}//package Box2D.Collision
Section 74
//b2DynamicTreeNode (Box2D.Collision.b2DynamicTreeNode)
package Box2D.Collision {
public class b2DynamicTreeNode {
public var aabb:b2AABB;
public var parent:b2DynamicTreeNode;
public var userData;
public var child2:b2DynamicTreeNode;
public var child1:b2DynamicTreeNode;
public function b2DynamicTreeNode(){
aabb = new b2AABB();
super();
}
public function IsLeaf():Boolean{
return ((child1 == null));
}
}
}//package Box2D.Collision
Section 75
//b2DynamicTreePair (Box2D.Collision.b2DynamicTreePair)
package Box2D.Collision {
public class b2DynamicTreePair {
public var proxyA:b2DynamicTreeNode;
public var proxyB:b2DynamicTreeNode;
}
}//package Box2D.Collision
Section 76
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var m_pointCount:int;// = 0
public var m_localPlaneNormal:b2Vec2;
public var m_type:int;
public var m_points:Array;
public var m_localPoint:b2Vec2;
public static const e_circles:int = 1;
public static const e_faceA:int = 2;
public static const e_faceB:int = 4;
public function b2Manifold(){
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
m_points[_local1] = new b2ManifoldPoint();
_local1++;
};
m_localPlaneNormal = new b2Vec2();
m_localPoint = new b2Vec2();
}
public function Set(_arg1:b2Manifold):void{
m_pointCount = _arg1.m_pointCount;
var _local2:int;
while (_local2 < b2Settings.b2_maxManifoldPoints) {
(m_points[_local2] as b2ManifoldPoint).Set(_arg1.m_points[_local2]);
_local2++;
};
m_localPlaneNormal.SetV(_arg1.m_localPlaneNormal);
m_localPoint.SetV(_arg1.m_localPoint);
m_type = _arg1.m_type;
}
public function Reset():void{
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
(m_points[_local1] as b2ManifoldPoint).Reset();
_local1++;
};
m_localPlaneNormal.SetZero();
m_localPoint.SetZero();
m_type = 0;
m_pointCount = 0;
}
public function Copy():b2Manifold{
var _local1:b2Manifold = new b2Manifold();
_local1.Set(this);
return (_local1);
}
}
}//package Box2D.Collision
Section 77
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ManifoldPoint {
public var m_localPoint:b2Vec2;
public var m_tangentImpulse:Number;
public var m_normalImpulse:Number;
public var m_id:b2ContactID;
public function b2ManifoldPoint(){
m_localPoint = new b2Vec2();
m_id = new b2ContactID();
super();
Reset();
}
public function Set(_arg1:b2ManifoldPoint):void{
m_localPoint.SetV(_arg1.m_localPoint);
m_normalImpulse = _arg1.m_normalImpulse;
m_tangentImpulse = _arg1.m_tangentImpulse;
m_id.Set(_arg1.m_id);
}
public function Reset():void{
m_localPoint.SetZero();
m_normalImpulse = 0;
m_tangentImpulse = 0;
m_id.key = 0;
}
}
}//package Box2D.Collision
Section 78
//b2OBB (Box2D.Collision.b2OBB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2OBB {
public var R:b2Mat22;
public var center:b2Vec2;
public var extents:b2Vec2;
public function b2OBB(){
R = new b2Mat22();
center = new b2Vec2();
extents = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 79
//b2RayCastInput (Box2D.Collision.b2RayCastInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2RayCastInput {
public var p1:b2Vec2;
public var maxFraction:Number;
public var p2:b2Vec2;
public function b2RayCastInput(_arg1:b2Vec2=null, _arg2:b2Vec2=null, _arg3:Number=1){
p1 = new b2Vec2();
p2 = new b2Vec2();
super();
if (_arg1){
this.p1.SetV(_arg1);
};
if (_arg2){
this.p2.SetV(_arg2);
};
this.maxFraction = _arg3;
}
}
}//package Box2D.Collision
Section 80
//b2RayCastOutput (Box2D.Collision.b2RayCastOutput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2RayCastOutput {
public var fraction:Number;
public var normal:b2Vec2;
public function b2RayCastOutput(){
normal = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 81
//b2SeparationFunction (Box2D.Collision.b2SeparationFunction)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
class b2SeparationFunction {
public var m_proxyA:b2DistanceProxy;
public var m_proxyB:b2DistanceProxy;
public var m_type:int;
public var m_axis:b2Vec2;
public var m_localPoint:b2Vec2;
public static const e_faceA:int = 2;
public static const e_faceB:int = 4;
public static const e_points:int = 1;
function b2SeparationFunction(){
m_localPoint = new b2Vec2();
m_axis = new b2Vec2();
super();
}
public function Initialize(_arg1:b2SimplexCache, _arg2:b2DistanceProxy, _arg3:b2Transform, _arg4:b2DistanceProxy, _arg5:b2Transform):void{
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:b2Mat22;
var _local20:b2Vec2;
var _local21:Number;
var _local22:Number;
var _local23:b2Vec2;
var _local24:b2Vec2;
var _local25:b2Vec2;
var _local26:b2Vec2;
var _local27:Number;
var _local28:Number;
var _local29:b2Vec2;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
m_proxyA = _arg2;
m_proxyB = _arg4;
var _local6:int = _arg1.count;
b2Settings.b2Assert((((0 < _local6)) && ((_local6 < 3))));
if (_local6 == 1){
m_type = e_points;
_local7 = m_proxyA.GetVertex(_arg1.indexA[0]);
_local10 = m_proxyB.GetVertex(_arg1.indexB[0]);
_local20 = _local7;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local10;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
m_axis.x = (_local15 - _local13);
m_axis.y = (_local16 - _local14);
m_axis.Normalize();
} else {
if (_arg1.indexB[0] == _arg1.indexB[1]){
m_type = e_faceA;
_local8 = m_proxyA.GetVertex(_arg1.indexA[0]);
_local9 = m_proxyA.GetVertex(_arg1.indexA[1]);
_local10 = m_proxyB.GetVertex(_arg1.indexB[0]);
m_localPoint.x = (0.5 * (_local8.x + _local9.x));
m_localPoint.y = (0.5 * (_local8.y + _local9.y));
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local9, _local8), 1);
m_axis.Normalize();
_local20 = m_axis;
_local19 = _arg3.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local10;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local21 = (((_local15 - _local13) * _local17) + ((_local16 - _local14) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
} else {
if (_arg1.indexA[0] == _arg1.indexA[0]){
m_type = e_faceB;
_local11 = m_proxyB.GetVertex(_arg1.indexB[0]);
_local12 = m_proxyB.GetVertex(_arg1.indexB[1]);
_local7 = m_proxyA.GetVertex(_arg1.indexA[0]);
m_localPoint.x = (0.5 * (_local11.x + _local12.x));
m_localPoint.y = (0.5 * (_local11.y + _local12.y));
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local12, _local11), 1);
m_axis.Normalize();
_local20 = m_axis;
_local19 = _arg5.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local7;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local21 = (((_local13 - _local15) * _local17) + ((_local14 - _local16) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
} else {
_local8 = m_proxyA.GetVertex(_arg1.indexA[0]);
_local9 = m_proxyA.GetVertex(_arg1.indexA[1]);
_local11 = m_proxyB.GetVertex(_arg1.indexB[0]);
_local12 = m_proxyB.GetVertex(_arg1.indexB[1]);
_local23 = b2Math.MulX(_arg3, _local7);
_local24 = b2Math.MulMV(_arg3.R, b2Math.SubtractVV(_local9, _local8));
_local25 = b2Math.MulX(_arg5, _local10);
_local26 = b2Math.MulMV(_arg5.R, b2Math.SubtractVV(_local12, _local11));
_local27 = ((_local24.x * _local24.x) + (_local24.y * _local24.y));
_local28 = ((_local26.x * _local26.x) + (_local26.y * _local26.y));
_local29 = b2Math.SubtractVV(_local26, _local24);
_local30 = ((_local24.x * _local29.x) + (_local24.y * _local29.y));
_local31 = ((_local26.x * _local29.x) + (_local26.y * _local29.y));
_local32 = ((_local24.x * _local26.x) + (_local24.y * _local26.y));
_local33 = ((_local27 * _local28) - (_local32 * _local32));
_local21 = 0;
if (_local33 != 0){
_local21 = b2Math.Clamp((((_local32 * _local31) - (_local30 * _local28)) / _local33), 0, 1);
};
_local34 = (((_local32 * _local21) + _local31) / _local28);
if (_local34 < 0){
_local34 = 0;
_local21 = b2Math.Clamp(((_local32 - _local30) / _local27), 0, 1);
};
_local7 = new b2Vec2();
_local7.x = (_local8.x + (_local21 * (_local9.x - _local8.x)));
_local7.y = (_local8.y + (_local21 * (_local9.y - _local8.y)));
_local10 = new b2Vec2();
_local10.x = (_local11.x + (_local21 * (_local12.x - _local11.x)));
_local10.y = (_local11.y + (_local21 * (_local12.y - _local11.y)));
if ((((_local21 == 0)) || ((_local21 == 1)))){
m_type = e_faceB;
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local12, _local11), 1);
m_localPoint = _local10;
_local20 = m_axis;
_local19 = _arg5.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local7;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local22 = (((_local13 - _local15) * _local17) + ((_local14 - _local16) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
} else {
m_type = e_faceA;
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local9, _local8), 1);
m_localPoint = _local7;
_local20 = m_axis;
_local19 = _arg3.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local10;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local22 = (((_local15 - _local13) * _local17) + ((_local16 - _local14) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
};
};
};
};
}
public function Evaluate(_arg1:b2Transform, _arg2:b2Transform):Number{
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:Number;
var _local10:b2Vec2;
switch (m_type){
case e_points:
_local3 = b2Math.MulTMV(_arg1.R, m_axis);
_local4 = b2Math.MulTMV(_arg2.R, m_axis.GetNegative());
_local5 = m_proxyA.GetSupportVertex(_local3);
_local6 = m_proxyB.GetSupportVertex(_local4);
_local7 = b2Math.MulX(_arg1, _local5);
_local8 = b2Math.MulX(_arg2, _local6);
_local9 = (((_local8.x - _local7.x) * m_axis.x) + ((_local8.y - _local7.y) * m_axis.y));
return (_local9);
case e_faceA:
_local10 = b2Math.MulMV(_arg1.R, m_axis);
_local7 = b2Math.MulX(_arg1, m_localPoint);
_local4 = b2Math.MulTMV(_arg2.R, _local10.GetNegative());
_local6 = m_proxyB.GetSupportVertex(_local4);
_local8 = b2Math.MulX(_arg2, _local6);
_local9 = (((_local8.x - _local7.x) * _local10.x) + ((_local8.y - _local7.y) * _local10.y));
return (_local9);
case e_faceB:
_local10 = b2Math.MulMV(_arg2.R, m_axis);
_local8 = b2Math.MulX(_arg2, m_localPoint);
_local3 = b2Math.MulTMV(_arg1.R, _local10.GetNegative());
_local5 = m_proxyA.GetSupportVertex(_local3);
_local7 = b2Math.MulX(_arg1, _local5);
_local9 = (((_local7.x - _local8.x) * _local10.x) + ((_local7.y - _local8.y) * _local10.y));
return (_local9);
default:
b2Settings.b2Assert(false);
return (0);
};
}
}
}//package Box2D.Collision
Section 82
//b2Simplex (Box2D.Collision.b2Simplex)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
class b2Simplex {
public var m_v1:b2SimplexVertex;
public var m_v2:b2SimplexVertex;
public var m_v3:b2SimplexVertex;
public var m_vertices:Array;
public var m_count:int;
function b2Simplex(){
m_v1 = new b2SimplexVertex();
m_v2 = new b2SimplexVertex();
m_v3 = new b2SimplexVertex();
m_vertices = new Array(3);
super();
m_vertices[0] = m_v1;
m_vertices[1] = m_v2;
m_vertices[2] = m_v3;
}
public function GetSearchDirection():b2Vec2{
var _local1:b2Vec2;
var _local2:Number;
switch (m_count){
case 1:
return (m_v1.w.GetNegative());
case 2:
_local1 = b2Math.SubtractVV(m_v2.w, m_v1.w);
_local2 = b2Math.CrossVV(_local1, m_v1.w.GetNegative());
if (_local2 > 0){
return (b2Math.CrossFV(1, _local1));
};
return (b2Math.CrossVF(_local1, 1));
default:
b2Settings.b2Assert(false);
return (new b2Vec2());
};
}
public function WriteCache(_arg1:b2SimplexCache):void{
_arg1.metric = GetMetric();
_arg1.count = uint(m_count);
var _local2:Array = m_vertices;
var _local3:int;
while (_local3 < m_count) {
_arg1.indexA[_local3] = uint(_local2[_local3].indexA);
_arg1.indexB[_local3] = uint(_local2[_local3].indexB);
_local3++;
};
}
public function GetMetric():Number{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
return (0);
case 1:
return (0);
case 2:
return (b2Math.SubtractVV(m_v1.w, m_v2.w).Length());
case 3:
return (b2Math.CrossVV(b2Math.SubtractVV(m_v2.w, m_v1.w), b2Math.SubtractVV(m_v3.w, m_v1.w)));
default:
b2Settings.b2Assert(false);
return (0);
};
}
public function ReadCache(_arg1:b2SimplexCache, _arg2:b2DistanceProxy, _arg3:b2Transform, _arg4:b2DistanceProxy, _arg5:b2Transform):void{
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local10:b2SimplexVertex;
var _local11:Number;
var _local12:Number;
b2Settings.b2Assert((((0 <= _arg1.count)) && ((_arg1.count <= 3))));
m_count = _arg1.count;
var _local8:Array = m_vertices;
var _local9:int;
while (_local9 < m_count) {
_local10 = _local8[_local9];
_local10.indexA = _arg1.indexA[_local9];
_local10.indexB = _arg1.indexB[_local9];
_local6 = _arg2.GetVertex(_local10.indexA);
_local7 = _arg4.GetVertex(_local10.indexB);
_local10.wA = b2Math.MulX(_arg3, _local6);
_local10.wB = b2Math.MulX(_arg5, _local6);
_local10.w = b2Math.SubtractVV(_local10.wB, _local10.wA);
_local10.a = 0;
_local9++;
};
if (m_count > 1){
_local11 = _arg1.metric;
_local12 = GetMetric();
if ((((((_local12 < (0.5 * _local11))) || (((2 * _local11) < _local12)))) || ((_local12 < Number.MIN_VALUE)))){
m_count = 0;
};
};
if (m_count == 0){
_local10 = _local8[0];
_local10.indexA = 0;
_local10.indexB = 0;
_local6 = _arg2.GetVertex(0);
_local7 = _arg4.GetVertex(0);
_local10.wA = b2Math.MulX(_arg3, _local6);
_local10.wB = b2Math.MulX(_arg5, _local7);
_local10.w = b2Math.SubtractVV(_local10.wB, _local10.wA);
m_count = 1;
};
}
public function GetWitnessPoints(_arg1:b2Vec2, _arg2:b2Vec2):void{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
break;
case 1:
_arg1.SetV(m_v1.wA);
_arg2.SetV(m_v1.wB);
break;
case 2:
_arg1.x = ((m_v1.a * m_v1.wA.x) + (m_v2.a * m_v2.wA.x));
_arg1.y = ((m_v1.a * m_v1.wA.y) + (m_v2.a * m_v2.wA.y));
_arg2.x = ((m_v1.a * m_v1.wB.x) + (m_v2.a * m_v2.wB.x));
_arg2.y = ((m_v1.a * m_v1.wB.y) + (m_v2.a * m_v2.wB.y));
break;
case 3:
_arg2.x = (_arg1.x = (((m_v1.a * m_v1.wA.x) + (m_v2.a * m_v2.wA.x)) + (m_v3.a * m_v3.wA.x)));
_arg2.y = (_arg1.y = (((m_v1.a * m_v1.wA.y) + (m_v2.a * m_v2.wA.y)) + (m_v3.a * m_v3.wA.y)));
break;
default:
b2Settings.b2Assert(false);
break;
};
}
public function Solve2():void{
var _local1:b2Vec2 = m_v1.w;
var _local2:b2Vec2 = m_v2.w;
var _local3:b2Vec2 = b2Math.SubtractVV(_local2, _local1);
var _local4:Number = -(((_local1.x * _local3.x) + (_local1.y * _local3.y)));
if (_local4 <= 0){
m_v1.a = 1;
m_count = 1;
return;
};
var _local5:Number = ((_local2.x * _local3.x) + (_local2.y * _local3.y));
if (_local5 <= 0){
m_v2.a = 1;
m_count = 1;
m_v1.Set(m_v2);
return;
};
var _local6:Number = (1 / (_local5 + _local4));
m_v1.a = (_local5 * _local6);
m_v2.a = (_local4 * _local6);
m_count = 2;
}
public function Solve3():void{
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local1:b2Vec2 = m_v1.w;
var _local2:b2Vec2 = m_v2.w;
var _local3:b2Vec2 = m_v3.w;
var _local4:b2Vec2 = b2Math.SubtractVV(_local2, _local1);
var _local5:Number = b2Math.Dot(_local1, _local4);
var _local6:Number = b2Math.Dot(_local2, _local4);
var _local7:Number = _local6;
var _local8:Number = -(_local5);
var _local9:b2Vec2 = b2Math.SubtractVV(_local3, _local1);
var _local10:Number = b2Math.Dot(_local1, _local9);
var _local11:Number = b2Math.Dot(_local3, _local9);
var _local12:Number = _local11;
var _local13:Number = -(_local10);
var _local14:b2Vec2 = b2Math.SubtractVV(_local3, _local2);
var _local15:Number = b2Math.Dot(_local2, _local14);
var _local16:Number = b2Math.Dot(_local3, _local14);
var _local17:Number = _local16;
var _local18:Number = -(_local15);
var _local19:Number = b2Math.CrossVV(_local4, _local9);
var _local20:Number = (_local19 * b2Math.CrossVV(_local2, _local3));
var _local21:Number = (_local19 * b2Math.CrossVV(_local3, _local1));
var _local22:Number = (_local19 * b2Math.CrossVV(_local1, _local2));
if ((((_local8 <= 0)) && ((_local13 <= 0)))){
m_v1.a = 1;
m_count = 1;
return;
};
if ((((((_local7 > 0)) && ((_local8 > 0)))) && ((_local22 <= 0)))){
_local24 = (1 / (_local7 + _local8));
m_v1.a = (_local7 * _local24);
m_v2.a = (_local8 * _local24);
m_count = 2;
return;
};
if ((((((_local12 > 0)) && ((_local13 > 0)))) && ((_local21 <= 0)))){
_local25 = (1 / (_local12 + _local13));
m_v1.a = (_local12 * _local25);
m_v3.a = (_local13 * _local25);
m_count = 2;
m_v2.Set(m_v3);
return;
};
if ((((_local7 <= 0)) && ((_local18 <= 0)))){
m_v2.a = 1;
m_count = 1;
m_v1.Set(m_v2);
return;
};
if ((((_local12 <= 0)) && ((_local17 <= 0)))){
m_v3.a = 1;
m_count = 1;
m_v1.Set(m_v3);
return;
};
if ((((((_local17 > 0)) && ((_local18 > 0)))) && ((_local20 <= 0)))){
_local26 = (1 / (_local17 + _local18));
m_v2.a = (_local17 * _local26);
m_v3.a = (_local18 * _local26);
m_count = 2;
m_v1.Set(m_v3);
return;
};
var _local23:Number = (1 / ((_local20 + _local21) + _local22));
m_v1.a = (_local20 * _local23);
m_v2.a = (_local21 * _local23);
m_v3.a = (_local22 * _local23);
m_count = 3;
}
public function GetClosestPoint():b2Vec2{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
return (new b2Vec2());
case 1:
return (m_v1.w);
case 2:
return (new b2Vec2(((m_v1.a * m_v1.w.x) + (m_v2.a * m_v2.w.x)), ((m_v1.a * m_v1.w.y) + (m_v2.a * m_v2.w.y))));
default:
b2Settings.b2Assert(false);
return (new b2Vec2());
};
}
}
}//package Box2D.Collision
Section 83
//b2SimplexCache (Box2D.Collision.b2SimplexCache)
package Box2D.Collision {
public class b2SimplexCache {
public var metric:Number;
public var count:uint;
public var indexB:Array;
public var indexA:Array;
public function b2SimplexCache(){
indexA = new Array(3);
indexB = new Array(3);
super();
}
}
}//package Box2D.Collision
Section 84
//b2SimplexVertex (Box2D.Collision.b2SimplexVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
class b2SimplexVertex {
public var a:Number;
public var wA:b2Vec2;
public var wB:b2Vec2;
public var indexA:int;
public var indexB:int;
public var w:b2Vec2;
public function Set(_arg1:b2SimplexVertex):void{
wA.SetV(_arg1.wA);
wB.SetV(_arg1.wB);
w.SetV(_arg1.w);
a = _arg1.a;
indexA = _arg1.indexA;
indexB = _arg1.indexB;
}
}
}//package Box2D.Collision
Section 85
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2TimeOfImpact {
private static var b2_toiCalls:int = 0;
private static var s_xfA:b2Transform = new b2Transform();
private static var s_distanceInput:b2DistanceInput = new b2DistanceInput();
private static var s_xfB:b2Transform = new b2Transform();
private static var s_distanceOutput:b2DistanceOutput = new b2DistanceOutput();
private static var b2_toiMaxRootIters:int = 0;
private static var s_cache:b2SimplexCache = new b2SimplexCache();
private static var b2_toiRootIters:int = 0;
private static var b2_toiIters:int = 0;
private static var b2_toiMaxIters:int = 0;
private static var s_fcn:b2SeparationFunction = new b2SeparationFunction();
public static function TimeOfImpact(_arg1:b2TOIInput):Number{
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:Number;
var _local20:Number;
b2_toiCalls++;
var _local2:b2DistanceProxy = _arg1.proxyA;
var _local3:b2DistanceProxy = _arg1.proxyB;
var _local4:b2Sweep = _arg1.sweepA;
var _local5:b2Sweep = _arg1.sweepB;
b2Settings.b2Assert((_local4.t0 == _local5.t0));
b2Settings.b2Assert(((1 - _local4.t0) > Number.MIN_VALUE));
var _local6:Number = (_local2.m_radius + _local3.m_radius);
var _local7:Number = _arg1.tolerance;
var _local8:Number = 0;
var _local9 = 1000;
var _local10:int;
var _local11:Number = 0;
s_cache.count = 0;
s_distanceInput.useRadii = false;
while (true) {
_local4.GetTransform(s_xfA, _local8);
_local5.GetTransform(s_xfB, _local8);
s_distanceInput.proxyA = _local2;
s_distanceInput.proxyB = _local3;
s_distanceInput.transformA = s_xfA;
s_distanceInput.transformB = s_xfB;
b2Distance.Distance(s_distanceOutput, s_cache, s_distanceInput);
if (s_distanceOutput.distance <= 0){
_local8 = 1;
break;
};
s_fcn.Initialize(s_cache, _local2, s_xfA, _local3, s_xfB);
_local12 = s_fcn.Evaluate(s_xfA, s_xfB);
if (_local12 <= 0){
_local8 = 1;
break;
};
if (_local10 == 0){
if (_local12 > _local6){
_local11 = b2Math.Max((_local6 - _local7), (0.75 * _local6));
} else {
_local11 = b2Math.Max((_local12 - _local7), (0.02 * _local6));
};
};
if ((_local12 - _local11) < (0.5 * _local7)){
if (_local10 == 0){
_local8 = 1;
break;
};
break;
};
_local13 = _local8;
_local14 = _local8;
_local15 = 1;
_local16 = _local12;
_local4.GetTransform(s_xfA, _local15);
_local5.GetTransform(s_xfB, _local15);
_local17 = s_fcn.Evaluate(s_xfA, s_xfB);
if (_local17 >= _local11){
_local8 = 1;
break;
};
_local18 = 0;
while (true) {
if ((_local18 & 1)){
_local19 = (_local14 + (((_local11 - _local16) * (_local15 - _local14)) / (_local17 - _local16)));
} else {
_local19 = (0.5 * (_local14 + _local15));
};
_local4.GetTransform(s_xfA, _local19);
_local5.GetTransform(s_xfB, _local19);
_local20 = s_fcn.Evaluate(s_xfA, s_xfB);
if (b2Math.Abs((_local20 - _local11)) < (0.025 * _local7)){
_local13 = _local19;
break;
};
if (_local20 > _local11){
_local14 = _local19;
_local16 = _local20;
} else {
_local15 = _local19;
_local17 = _local20;
};
_local18++;
b2_toiRootIters++;
if (_local18 == 50){
break;
};
};
b2_toiMaxRootIters = b2Math.Max(b2_toiMaxRootIters, _local18);
if (_local13 < ((1 + (100 * Number.MIN_VALUE)) * _local8)){
break;
};
_local8 = _local13;
_local10++;
b2_toiIters++;
if (_local10 == _local9){
break;
};
};
b2_toiMaxIters = b2Math.Max(b2_toiMaxIters, _local10);
return (_local8);
}
}
}//package Box2D.Collision
Section 86
//b2TOIInput (Box2D.Collision.b2TOIInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2TOIInput {
public var proxyA:b2DistanceProxy;
public var proxyB:b2DistanceProxy;
public var sweepA:b2Sweep;
public var sweepB:b2Sweep;
public var tolerance:Number;
public function b2TOIInput(){
proxyA = new b2DistanceProxy();
proxyB = new b2DistanceProxy();
sweepA = new b2Sweep();
sweepB = new b2Sweep();
super();
}
}
}//package Box2D.Collision
Section 87
//b2WorldManifold (Box2D.Collision.b2WorldManifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2WorldManifold {
public var m_normal:b2Vec2;
public var m_points:Array;
public function b2WorldManifold(){
m_normal = new b2Vec2();
super();
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
m_points[_local1] = new b2Vec2();
_local1++;
};
}
public function Initialize(_arg1:b2Manifold, _arg2:b2Transform, _arg3:Number, _arg4:b2Transform, _arg5:Number):void{
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Mat22;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
if (_arg1.m_pointCount == 0){
return;
};
switch (_arg1.m_type){
case b2Manifold.e_circles:
_local8 = _arg2.R;
_local7 = _arg1.m_localPoint;
_local15 = ((_arg2.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local16 = ((_arg2.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
_local8 = _arg4.R;
_local7 = _arg1.m_points[0].m_localPoint;
_local17 = ((_arg4.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local18 = ((_arg4.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
_local19 = (_local17 - _local15);
_local20 = (_local18 - _local16);
_local21 = ((_local19 * _local19) + (_local20 * _local20));
if (_local21 > (Number.MIN_VALUE * Number.MIN_VALUE)){
_local26 = Math.sqrt(_local21);
m_normal.x = (_local19 / _local26);
m_normal.y = (_local20 / _local26);
} else {
m_normal.x = 1;
m_normal.y = 0;
};
_local22 = (_local15 + (_arg3 * m_normal.x));
_local23 = (_local16 + (_arg3 * m_normal.y));
_local24 = (_local17 - (_arg5 * m_normal.x));
_local25 = (_local18 - (_arg5 * m_normal.y));
m_points[0].x = (0.5 * (_local22 + _local24));
m_points[0].y = (0.5 * (_local23 + _local25));
break;
case b2Manifold.e_faceA:
_local8 = _arg2.R;
_local7 = _arg1.m_localPlaneNormal;
_local9 = ((_local8.col1.x * _local7.x) + (_local8.col2.x * _local7.y));
_local10 = ((_local8.col1.y * _local7.x) + (_local8.col2.y * _local7.y));
_local8 = _arg2.R;
_local7 = _arg1.m_localPoint;
_local11 = ((_arg2.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local12 = ((_arg2.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_normal.x = _local9;
m_normal.y = _local10;
_local6 = 0;
while (_local6 < _arg1.m_pointCount) {
_local8 = _arg4.R;
_local7 = _arg1.m_points[_local6].m_localPoint;
_local13 = ((_arg4.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local14 = ((_arg4.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_points[_local6].x = (_local13 + ((0.5 * (((_arg3 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg5)) * _local9));
m_points[_local6].y = (_local14 + ((0.5 * (((_arg3 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg5)) * _local10));
_local6++;
};
break;
case b2Manifold.e_faceB:
_local8 = _arg4.R;
_local7 = _arg1.m_localPlaneNormal;
_local9 = ((_local8.col1.x * _local7.x) + (_local8.col2.x * _local7.y));
_local10 = ((_local8.col1.y * _local7.x) + (_local8.col2.y * _local7.y));
_local8 = _arg4.R;
_local7 = _arg1.m_localPoint;
_local11 = ((_arg4.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local12 = ((_arg4.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_normal.x = -(_local9);
m_normal.y = -(_local10);
_local6 = 0;
while (_local6 < _arg1.m_pointCount) {
_local8 = _arg2.R;
_local7 = _arg1.m_points[_local6].m_localPoint;
_local13 = ((_arg2.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local14 = ((_arg2.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_points[_local6].x = (_local13 + ((0.5 * (((_arg5 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg3)) * _local9));
m_points[_local6].y = (_local14 + ((0.5 * (((_arg5 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg3)) * _local10));
_local6++;
};
break;
};
}
}
}//package Box2D.Collision
Section 88
//ClipVertex (Box2D.Collision.ClipVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class ClipVertex {
public var id:b2ContactID;
public var v:b2Vec2;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
public function Set(_arg1:ClipVertex):void{
v.SetV(_arg1.v);
id.Set(_arg1.id);
}
}
}//package Box2D.Collision
Section 89
//Features (Box2D.Collision.Features)
package Box2D.Collision {
import Box2D.Common.*;
public class Features {
b2internal var _referenceEdge:int;
b2internal var _incidentEdge:int;
b2internal var _flip:int;
b2internal var _incidentVertex:int;
b2internal var _m_id:b2ContactID;
public function get referenceEdge():int{
return (_referenceEdge);
}
public function set incidentVertex(_arg1:int):void{
_incidentVertex = _arg1;
_m_id._key = ((_m_id._key & 4278255615) | ((_incidentVertex << 16) & 0xFF0000));
}
public function get flip():int{
return (_flip);
}
public function get incidentEdge():int{
return (_incidentEdge);
}
public function set referenceEdge(_arg1:int):void{
_referenceEdge = _arg1;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceEdge & 0xFF));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set flip(_arg1:int):void{
_flip = _arg1;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function set incidentEdge(_arg1:int):void{
_incidentEdge = _arg1;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Box2D.Collision
Section 90
//IBroadPhase (Box2D.Collision.IBroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
public interface IBroadPhase {
function GetFatAABB(_arg1):b2AABB;
function Query(_arg1:Function, _arg2:b2AABB):void;
function Rebalance(_arg1:int):void;
function GetUserData(_arg1);
function UpdatePairs(_arg1:Function):void;
function CreateProxy(_arg1:b2AABB, _arg2);
function DestroyProxy(_arg1):void;
function TestOverlap(_arg1, _arg2):Boolean;
function Validate():void;
function GetProxyCount():int;
function RayCast(_arg1:Function, _arg2:b2RayCastInput):void;
function MoveProxy(_arg1, _arg2:b2AABB, _arg3:b2Vec2):void;
}
}//package Box2D.Collision
Section 91
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(){
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
col1.x = (col2.y = 1);
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function SetVV(_arg1:b2Vec2, _arg2:b2Vec2):void{
col1.SetV(_arg1);
col2.SetV(_arg2);
}
public function Set(_arg1:Number):void{
var _local2:Number;
_local2 = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
col1.x = _local2;
col2.x = -(_local3);
col1.y = _local3;
col2.y = _local2;
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col1.y = 0;
col2.y = 0;
}
public function SetM(_arg1:b2Mat22):void{
col1.SetV(_arg1.col1);
col2.SetV(_arg1.col2);
}
public function AddM(_arg1:b2Mat22):void{
col1.x = (col1.x + _arg1.col1.x);
col1.y = (col1.y + _arg1.col1.y);
col2.x = (col2.x + _arg1.col2.x);
col2.y = (col2.y + _arg1.col2.y);
}
public function Abs():void{
col1.Abs();
col2.Abs();
}
public function Copy():b2Mat22{
var _local1:b2Mat22 = new b2Mat22();
_local1.SetM(this);
return (_local1);
}
public function GetInverse(_arg1:b2Mat22):b2Mat22{
var _local3:Number;
var _local6:Number;
var _local2:Number = col1.x;
_local3 = col2.x;
var _local4:Number = col1.y;
var _local5:Number = col2.y;
_local6 = ((_local2 * _local5) - (_local3 * _local4));
if (_local6 != 0){
_local6 = (1 / _local6);
};
_arg1.col1.x = (_local6 * _local5);
_arg1.col2.x = (-(_local6) * _local3);
_arg1.col1.y = (-(_local6) * _local4);
_arg1.col2.y = (_local6 * _local2);
return (_arg1);
}
public function GetAngle():Number{
return (Math.atan2(col1.y, col1.x));
}
public function Solve(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number = col1.x;
var _local5:Number = col2.x;
var _local6:Number = col1.y;
var _local7:Number = col2.y;
var _local8:Number = ((_local4 * _local7) - (_local5 * _local6));
if (_local8 != 0){
_local8 = (1 / _local8);
};
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
public static function FromAngle(_arg1:Number):b2Mat22{
var _local2:b2Mat22 = new (b2Mat22);
_local2.Set(_arg1);
return (_local2);
}
public static function FromVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Mat22{
var _local3:b2Mat22 = new (b2Mat22);
_local3.SetVV(_arg1, _arg2);
return (_local3);
}
}
}//package Box2D.Common.Math
Section 92
//b2Mat33 (Box2D.Common.Math.b2Mat33)
package Box2D.Common.Math {
public class b2Mat33 {
public var col1:b2Vec3;
public var col2:b2Vec3;
public var col3:b2Vec3;
public function b2Mat33(_arg1:b2Vec3=null, _arg2:b2Vec3=null, _arg3:b2Vec3=null){
col1 = new b2Vec3();
col2 = new b2Vec3();
col3 = new b2Vec3();
super();
if (((((!(_arg1)) && (!(_arg2)))) && (!(_arg3)))){
col1.SetZero();
col2.SetZero();
col3.SetZero();
} else {
col1.SetV(_arg1);
col2.SetV(_arg2);
col3.SetV(_arg3);
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col3.x = 0;
col1.y = 0;
col2.y = 1;
col3.y = 0;
col1.z = 0;
col2.z = 0;
col3.z = 1;
}
public function Solve22(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number;
var _local6:Number;
_local4 = col1.x;
var _local5:Number = col2.x;
_local6 = col1.y;
var _local7:Number = col2.y;
var _local8:Number = ((_local4 * _local7) - (_local5 * _local6));
if (_local8 != 0){
_local8 = (1 / _local8);
};
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col3.x = 0;
col1.y = 0;
col2.y = 0;
col3.y = 0;
col1.z = 0;
col2.z = 0;
col3.z = 0;
}
public function SetM(_arg1:b2Mat33):void{
col1.SetV(_arg1.col1);
col2.SetV(_arg1.col2);
col3.SetV(_arg1.col3);
}
public function AddM(_arg1:b2Mat33):void{
col1.x = (col1.x + _arg1.col1.x);
col1.y = (col1.y + _arg1.col1.y);
col1.z = (col1.z + _arg1.col1.z);
col2.x = (col2.x + _arg1.col2.x);
col2.y = (col2.y + _arg1.col2.y);
col2.z = (col2.z + _arg1.col2.z);
col3.x = (col3.x + _arg1.col3.x);
col3.y = (col3.y + _arg1.col3.y);
col3.z = (col3.z + _arg1.col3.z);
}
public function SetVVV(_arg1:b2Vec3, _arg2:b2Vec3, _arg3:b2Vec3):void{
col1.SetV(_arg1);
col2.SetV(_arg2);
col3.SetV(_arg3);
}
public function Copy():b2Mat33{
return (new b2Mat33(col1, col2, col3));
}
public function Solve33(_arg1:b2Vec3, _arg2:Number, _arg3:Number, _arg4:Number):b2Vec3{
var _local5:Number = col1.x;
var _local6:Number = col1.y;
var _local7:Number = col1.z;
var _local8:Number = col2.x;
var _local9:Number = col2.y;
var _local10:Number = col2.z;
var _local11:Number = col3.x;
var _local12:Number = col3.y;
var _local13:Number = col3.z;
var _local14:Number = (((_local5 * ((_local9 * _local13) - (_local10 * _local12))) + (_local6 * ((_local10 * _local11) - (_local8 * _local13)))) + (_local7 * ((_local8 * _local12) - (_local9 * _local11))));
if (_local14 != 0){
_local14 = (1 / _local14);
};
_arg1.x = (_local14 * (((_arg2 * ((_local9 * _local13) - (_local10 * _local12))) + (_arg3 * ((_local10 * _local11) - (_local8 * _local13)))) + (_arg4 * ((_local8 * _local12) - (_local9 * _local11)))));
_arg1.y = (_local14 * (((_local5 * ((_arg3 * _local13) - (_arg4 * _local12))) + (_local6 * ((_arg4 * _local11) - (_arg2 * _local13)))) + (_local7 * ((_arg2 * _local12) - (_arg3 * _local11)))));
_arg1.z = (_local14 * (((_local5 * ((_local9 * _arg4) - (_local10 * _arg3))) + (_local6 * ((_local10 * _arg2) - (_local8 * _arg4)))) + (_local7 * ((_local8 * _arg3) - (_local9 * _arg2)))));
return (_arg1);
}
}
}//package Box2D.Common.Math
Section 93
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public static const b2Transform_identity:b2Transform = new b2Transform(b2Vec2_zero, b2Mat22_identity);
public static const b2Mat22_identity:b2Mat22 = b2Mat22.FromVV(new b2Vec2(1, 0), new b2Vec2(0, 1));
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0, 0);
public static function AddVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x + _arg2.x), (_arg1.y + _arg2.y));
return (_local3);
}
public static function AbsM(_arg1:b2Mat22):b2Mat22{
var _local2:b2Mat22 = b2Mat22.FromVV(AbsV(_arg1.col1), AbsV(_arg1.col2));
return (_local2);
}
public static function SubtractVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x - _arg2.x), (_arg1.y - _arg2.y));
return (_local3);
}
public static function MulMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = b2Mat22.FromVV(MulMV(_arg1, _arg2.col1), MulMV(_arg1, _arg2.col2));
return (_local3);
}
public static function NextPowerOfTwo(_arg1:uint):uint{
_arg1 = (_arg1 | ((_arg1 >> 1) & 2147483647));
_arg1 = (_arg1 | ((_arg1 >> 2) & 1073741823));
_arg1 = (_arg1 | ((_arg1 >> 4) & 268435455));
_arg1 = (_arg1 | ((_arg1 >> 8) & 0xFFFFFF));
_arg1 = (_arg1 | ((_arg1 >> 16) & 0xFFFF));
return ((_arg1 + 1));
}
public static function Max(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function MulMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(((_arg1.col1.x * _arg2.x) + (_arg1.col2.x * _arg2.y)), ((_arg1.col1.y * _arg2.x) + (_arg1.col2.y * _arg2.y)));
return (_local3);
}
public static function CrossVF(_arg1:b2Vec2, _arg2:Number):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg2 * _arg1.y), (-(_arg2) * _arg1.x));
return (_local3);
}
public static function MaxV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(Max(_arg1.x, _arg2.x), Max(_arg1.y, _arg2.y));
return (_local3);
}
public static function AbsV(_arg1:b2Vec2):b2Vec2{
var _local2:b2Vec2 = new b2Vec2(Abs(_arg1.x), Abs(_arg1.y));
return (_local2);
}
public static function Distance(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (Math.sqrt(((_local3 * _local3) + (_local4 * _local4))));
}
public static function MulTMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Vec2 = new b2Vec2(Dot(_arg1.col1, _arg2.col1), Dot(_arg1.col2, _arg2.col1));
var _local4:b2Vec2 = new b2Vec2(Dot(_arg1.col1, _arg2.col2), Dot(_arg1.col2, _arg2.col2));
var _local5:b2Mat22 = b2Mat22.FromVV(_local3, _local4);
return (_local5);
}
public static function DistanceSquared(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (((_local3 * _local3) + (_local4 * _local4)));
}
public static function RandomRange(_arg1:Number, _arg2:Number):Number{
var _local3:Number = Math.random();
_local3 = (((_arg2 - _arg1) * _local3) + _arg1);
return (_local3);
}
public static function Clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (((_arg1 < _arg2)) ? _arg2 : ((_arg1 > _arg3)) ? _arg3 : _arg1);
}
public static function MulXT(_arg1:b2Transform, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
var _local4:Number;
_local3 = SubtractVV(_arg2, _arg1.position);
_local4 = ((_local3.x * _arg1.R.col1.x) + (_local3.y * _arg1.R.col1.y));
_local3.y = ((_local3.x * _arg1.R.col2.x) + (_local3.y * _arg1.R.col2.y));
_local3.x = _local4;
return (_local3);
}
public static function AddMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = b2Mat22.FromVV(AddVV(_arg1.col1, _arg2.col1), AddVV(_arg1.col2, _arg2.col2));
return (_local3);
}
public static function Random():Number{
return (((Math.random() * 2) - 1));
}
public static function MinV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(Min(_arg1.x, _arg2.x), Min(_arg1.y, _arg2.y));
return (_local3);
}
public static function CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
public static function MulTMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(Dot(_arg2, _arg1.col1), Dot(_arg2, _arg1.col2));
return (_local3);
}
public static function Dot(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function Abs(_arg1:Number):Number{
return (((_arg1 > 0)) ? _arg1 : -(_arg1));
}
public static function CrossFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((-(_arg1) * _arg2.y), (_arg1 * _arg2.x));
return (_local3);
}
public static function Min(_arg1:Number, _arg2:Number):Number{
return (((_arg1 < _arg2)) ? _arg1 : _arg2);
}
public static function ClampV(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):b2Vec2{
return (MaxV(_arg2, MinV(_arg1, _arg3)));
}
public static function MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y));
return (_local3);
}
public static function Swap(_arg1:Array, _arg2:Array):void{
var _local3:* = _arg1[0];
_arg1[0] = _arg2[0];
_arg2[0] = _local3;
}
public static function MulX(_arg1:b2Transform, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = MulMV(_arg1.R, _arg2);
_local3.x = (_local3.x + _arg1.position.x);
_local3.y = (_local3.y + _arg1.position.y);
return (_local3);
}
public static function IsPowerOfTwo(_arg1:uint):Boolean{
var _local2:Boolean = (((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)));
return (_local2);
}
public static function IsValid(_arg1:Number):Boolean{
return (isFinite(_arg1));
}
}
}//package Box2D.Common.Math
Section 94
//b2Sweep (Box2D.Common.Math.b2Sweep)
package Box2D.Common.Math {
public class b2Sweep {
public var localCenter:b2Vec2;
public var a:Number;
public var c:b2Vec2;
public var c0:b2Vec2;
public var a0:Number;
public var t0:Number;
public function b2Sweep(){
localCenter = new b2Vec2();
c0 = new b2Vec2();
c = new b2Vec2();
super();
}
public function Advance(_arg1:Number):void{
var _local2:Number;
if ((((t0 < _arg1)) && (((1 - t0) > Number.MIN_VALUE)))){
_local2 = ((_arg1 - t0) / (1 - t0));
c0.x = (((1 - _local2) * c0.x) + (_local2 * c.x));
c0.y = (((1 - _local2) * c0.y) + (_local2 * c.y));
a0 = (((1 - _local2) * a0) + (_local2 * a));
t0 = _arg1;
};
}
public function Set(_arg1:b2Sweep):void{
localCenter.SetV(_arg1.localCenter);
c0.SetV(_arg1.c0);
c.SetV(_arg1.c);
a0 = _arg1.a0;
a = _arg1.a;
t0 = _arg1.t0;
}
public function Copy():b2Sweep{
var _local1:b2Sweep = new b2Sweep();
_local1.localCenter.SetV(localCenter);
_local1.c0.SetV(c0);
_local1.c.SetV(c);
_local1.a0 = a0;
_local1.a = a;
_local1.t0 = t0;
return (_local1);
}
public function GetTransform(_arg1:b2Transform, _arg2:Number):void{
_arg1.position.x = (((1 - _arg2) * c0.x) + (_arg2 * c.x));
_arg1.position.y = (((1 - _arg2) * c0.y) + (_arg2 * c.y));
var _local3:Number = (((1 - _arg2) * a0) + (_arg2 * a));
_arg1.R.Set(_local3);
var _local4:b2Mat22 = _arg1.R;
_arg1.position.x = (_arg1.position.x - ((_local4.col1.x * localCenter.x) + (_local4.col2.x * localCenter.y)));
_arg1.position.y = (_arg1.position.y - ((_local4.col1.y * localCenter.x) + (_local4.col2.y * localCenter.y)));
}
}
}//package Box2D.Common.Math
Section 95
//b2Transform (Box2D.Common.Math.b2Transform)
package Box2D.Common.Math {
public class b2Transform {
public var position:b2Vec2;
public var R:b2Mat22;
public function b2Transform(_arg1:b2Vec2=null, _arg2:b2Mat22=null):void{
position = new b2Vec2();
R = new b2Mat22();
super();
if (_arg1){
position.SetV(_arg1);
R.SetM(_arg2);
};
}
public function Initialize(_arg1:b2Vec2, _arg2:b2Mat22):void{
position.SetV(_arg1);
R.SetM(_arg2);
}
public function Set(_arg1:b2Transform):void{
position.SetV(_arg1.position);
R.SetM(_arg1.R);
}
public function SetIdentity():void{
position.SetZero();
R.SetIdentity();
}
public function GetAngle():Number{
return (Math.atan2(R.col1.y, R.col1.x));
}
}
}//package Box2D.Common.Math
Section 96
//b2Vec2 (Box2D.Common.Math.b2Vec2)
package Box2D.Common.Math {
public class b2Vec2 {
public var y:Number;
public var x:Number;
public function b2Vec2(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function NegativeSelf():void{
x = -(x);
y = -(y);
}
public function Set(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function LengthSquared():Number{
return (((x * x) + (y * y)));
}
public function Multiply(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function Length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function Add(_arg1:b2Vec2):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function MulM(_arg1:b2Mat22):void{
var _local2:Number = x;
x = ((_arg1.col1.x * _local2) + (_arg1.col2.x * y));
y = ((_arg1.col1.y * _local2) + (_arg1.col2.y * y));
}
public function SetZero():void{
x = 0;
y = 0;
}
public function GetNegative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function Normalize():Number{
var _local1:Number = Math.sqrt(((x * x) + (y * y)));
if (_local1 < Number.MIN_VALUE){
return (0);
};
var _local2:Number = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
return (_local1);
}
public function CrossVF(_arg1:Number):void{
var _local2:Number = x;
x = (_arg1 * y);
y = (-(_arg1) * _local2);
}
public function MaxV(_arg1:b2Vec2):void{
x = ((x > _arg1.x)) ? x : _arg1.x;
y = ((y > _arg1.y)) ? y : _arg1.y;
}
public function SetV(_arg1:b2Vec2):void{
x = _arg1.x;
y = _arg1.y;
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function CrossFV(_arg1:Number):void{
var _local2:Number = x;
x = (-(_arg1) * y);
y = (_arg1 * _local2);
}
public function Abs():void{
if (x < 0){
x = -(x);
};
if (y < 0){
y = -(y);
};
}
public function Subtract(_arg1:b2Vec2):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function MinV(_arg1:b2Vec2):void{
x = ((x < _arg1.x)) ? x : _arg1.x;
y = ((y < _arg1.y)) ? y : _arg1.y;
}
public function MulTM(_arg1:b2Mat22):void{
var _local2:Number = b2Math.Dot(this, _arg1.col1);
y = b2Math.Dot(this, _arg1.col2);
x = _local2;
}
public function IsValid():Boolean{
return (((b2Math.IsValid(x)) && (b2Math.IsValid(y))));
}
public static function Make(_arg1:Number, _arg2:Number):b2Vec2{
return (new b2Vec2(_arg1, _arg2));
}
}
}//package Box2D.Common.Math
Section 97
//b2Vec3 (Box2D.Common.Math.b2Vec3)
package Box2D.Common.Math {
public class b2Vec3 {
public var x:Number;
public var y:Number;
public var z:Number;
public function b2Vec3(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function NegativeSelf():void{
x = -(x);
y = -(y);
z = -(z);
}
public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function Multiply(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
}
public function Add(_arg1:b2Vec3):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
}
public function SetZero():void{
x = (y = (z = 0));
}
public function GetNegative():b2Vec3{
return (new b2Vec3(-(x), -(y), -(z)));
}
public function SetV(_arg1:b2Vec3):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
public function Copy():b2Vec3{
return (new b2Vec3(x, y, z));
}
public function Subtract(_arg1:b2Vec3):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
z = (z - _arg1.z);
}
}
}//package Box2D.Common.Math
Section 98
//b2Color (Box2D.Common.b2Color)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Color {
private var _r:uint;// = 0
private var _g:uint;// = 0
private var _b:uint;// = 0
public function b2Color(_arg1:Number, _arg2:Number, _arg3:Number){
_r = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.Clamp(_arg3, 0, 1)));
}
public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{
_r = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.Clamp(_arg3, 0, 1)));
}
public function set b(_arg1:Number):void{
_b = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
}
public function get color():uint{
return ((((_r << 16) | (_g << 8)) | _b));
}
public function set r(_arg1:Number):void{
_r = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
}
public function set g(_arg1:Number):void{
_g = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
}
}
}//package Box2D.Common
Section 99
//b2internal (Box2D.Common.b2internal)
package Box2D.Common {
public namespace b2internal = "http://www.box2d.org/ns/b2internal";
}//package Box2D.Common
Section 100
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
public class b2Settings {
public static const b2_polygonRadius:Number = (2 * b2_linearSlop);
public static const b2_pi:Number = 3.14159265358979;
public static const b2_aabbExtension:Number = 0.1;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_maxTranslationSquared:Number = 4;
public static const b2_angularSlop:Number = 0.0349065850398866;
public static const b2_linearSlop:Number = 0.005;
public static const b2_maxRotation:Number = 1.5707963267949;
public static const b2_maxRotationSquared:Number = 2.46740110027234;
public static const b2_angularSleepTolerance:Number = 0.0349065850398866;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_maxTOIJointsPerIsland:int = 32;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxTOIContactsPerIsland:int = 32;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const b2_velocityThreshold:Number = 1;
public static const USHRT_MAX:int = 0xFFFF;
public static const VERSION:String = "2.1alpha";
public static const b2_toiSlop:Number = 0.04;
public static const b2_maxTranslation:Number = 2;
public static const b2_aabbMultiplier:Number = 2;
public static const b2_maxLinearCorrection:Number = 0.2;
public static function b2MixFriction(_arg1:Number, _arg2:Number):Number{
return (Math.sqrt((_arg1 * _arg2)));
}
public static function b2MixRestitution(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function b2Assert(_arg1:Boolean):void{
if (!_arg1){
throw ("Assertion Failed");
};
}
}
}//package Box2D.Common
Section 101
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2Collision.CollideCircles(m_manifold, (m_fixtureA.GetShape() as b2CircleShape), _local1.m_xf, (m_fixtureB.GetShape() as b2CircleShape), _local2.m_xf);
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2CircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 102
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Contact {
b2internal var m_prev:b2Contact;
b2internal var m_next:b2Contact;
b2internal var m_oldManifold:b2Manifold;
b2internal var m_manifold:b2Manifold;
b2internal var m_fixtureB:b2Fixture;
b2internal var m_fixtureA:b2Fixture;
b2internal var m_nodeA:b2ContactEdge;
b2internal var m_flags:uint;
b2internal var m_toi:Number;
b2internal var m_nodeB:b2ContactEdge;
b2internal static var e_sensorFlag:uint = 1;
private static var s_input:b2TOIInput = new b2TOIInput();
b2internal static var e_touchingFlag:uint = 16;
b2internal static var e_enabledFlag:uint = 32;
b2internal static var e_continuousFlag:uint = 2;
b2internal static var e_toiFlag:uint = 8;
b2internal static var e_islandFlag:uint = 4;
b2internal static var e_filterFlag:uint = 64;
public function b2Contact(){
m_nodeA = new b2ContactEdge();
m_nodeB = new b2ContactEdge();
m_manifold = new b2Manifold();
m_oldManifold = new b2Manifold();
super();
}
public function IsContinuous():Boolean{
return (((m_flags & e_continuousFlag) == e_continuousFlag));
}
public function GetNext():b2Contact{
return (m_next);
}
public function FlagForFiltering():void{
m_flags = (m_flags | e_filterFlag);
}
public function IsEnabled():Boolean{
return (((m_flags & e_enabledFlag) == e_enabledFlag));
}
public function SetSensor(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_sensorFlag);
} else {
m_flags = (m_flags & ~(e_sensorFlag));
};
}
public function SetEnabled(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_enabledFlag);
} else {
m_flags = (m_flags & ~(e_enabledFlag));
};
}
public function IsSensor():Boolean{
return (((m_flags & e_sensorFlag) == e_sensorFlag));
}
public function GetManifold():b2Manifold{
return (m_manifold);
}
b2internal function Update(_arg1:b2ContactListener):void{
var _local8:b2Shape;
var _local9:b2Shape;
var _local10:b2Transform;
var _local11:b2Transform;
var _local12:int;
var _local13:b2ManifoldPoint;
var _local14:b2ContactID;
var _local15:int;
var _local16:b2ManifoldPoint;
var _local2:b2Manifold = m_oldManifold;
m_oldManifold = m_manifold;
m_manifold = _local2;
m_flags = (m_flags | e_enabledFlag);
var _local3:Boolean;
var _local4 = ((m_flags & e_touchingFlag) == e_touchingFlag);
var _local5:b2Body = m_fixtureA.m_body;
var _local6:b2Body = m_fixtureB.m_body;
var _local7:Boolean = m_fixtureA.m_aabb.TestOverlap(m_fixtureB.m_aabb);
if ((m_flags & e_sensorFlag)){
if (_local7){
_local8 = m_fixtureA.GetShape();
_local9 = m_fixtureB.GetShape();
_local10 = _local5.GetTransform();
_local11 = _local6.GetTransform();
_local3 = b2Shape.TestOverlap(_local8, _local10, _local9, _local11);
};
m_manifold.m_pointCount = 0;
} else {
if (((((((!((_local5.GetType() == b2Body.b2_dynamicBody))) || (_local5.IsBullet()))) || (!((_local6.GetType() == b2Body.b2_dynamicBody))))) || (_local6.IsBullet()))){
m_flags = (m_flags | e_continuousFlag);
} else {
m_flags = (m_flags & ~(e_continuousFlag));
};
if (_local7){
Evaluate();
_local3 = (m_manifold.m_pointCount > 0);
_local12 = 0;
while (_local12 < m_manifold.m_pointCount) {
_local13 = m_manifold.m_points[_local12];
_local13.m_normalImpulse = 0;
_local13.m_tangentImpulse = 0;
_local14 = _local13.m_id;
_local15 = 0;
while (_local15 < m_oldManifold.m_pointCount) {
_local16 = m_oldManifold.m_points[_local15];
if (_local16.m_id.key == _local14.key){
_local13.m_normalImpulse = _local16.m_normalImpulse;
_local13.m_tangentImpulse = _local16.m_tangentImpulse;
break;
};
_local15++;
};
_local12++;
};
} else {
m_manifold.m_pointCount = 0;
};
if (_local3 != _local4){
_local5.SetAwake(true);
_local6.SetAwake(true);
};
};
if (_local3){
m_flags = (m_flags | e_touchingFlag);
} else {
m_flags = (m_flags & ~(e_touchingFlag));
};
if ((((_local4 == false)) && ((_local3 == true)))){
_arg1.BeginContact(this);
};
if ((((_local4 == true)) && ((_local3 == false)))){
_arg1.EndContact(this);
};
if ((m_flags & e_sensorFlag) == 0){
_arg1.PreSolve(this, m_oldManifold);
};
}
public function GetWorldManifold(_arg1:b2WorldManifold):void{
var _local2:b2Body = m_fixtureA.GetBody();
var _local3:b2Body = m_fixtureB.GetBody();
var _local4:b2Shape = m_fixtureA.GetShape();
var _local5:b2Shape = m_fixtureB.GetShape();
_arg1.Initialize(m_manifold, _local2.GetTransform(), _local4.m_radius, _local3.GetTransform(), _local5.m_radius);
}
public function IsTouching():Boolean{
return (((m_flags & e_touchingFlag) == e_touchingFlag));
}
public function GetFixtureA():b2Fixture{
return (m_fixtureA);
}
public function GetFixtureB():b2Fixture{
return (m_fixtureB);
}
b2internal function Reset(_arg1:b2Fixture=null, _arg2:b2Fixture=null):void{
m_flags = e_enabledFlag;
if (((!(_arg1)) || (!(_arg2)))){
m_fixtureA = null;
m_fixtureB = null;
return;
};
if (((_arg1.IsSensor()) || (_arg2.IsSensor()))){
m_flags = (m_flags | e_sensorFlag);
};
var _local3:b2Body = _arg1.GetBody();
var _local4:b2Body = _arg2.GetBody();
if (((((((!((_local3.GetType() == b2Body.b2_dynamicBody))) || (_local3.IsBullet()))) || (!((_local4.GetType() == b2Body.b2_dynamicBody))))) || (_local4.IsBullet()))){
m_flags = (m_flags | e_continuousFlag);
};
m_fixtureA = _arg1;
m_fixtureB = _arg2;
m_manifold.m_pointCount = 0;
m_prev = null;
m_next = null;
m_nodeA.contact = null;
m_nodeA.prev = null;
m_nodeA.next = null;
m_nodeA.other = null;
m_nodeB.contact = null;
m_nodeB.prev = null;
m_nodeB.next = null;
m_nodeB.other = null;
}
b2internal function ComputeTOI(_arg1:b2Sweep, _arg2:b2Sweep):Number{
s_input.proxyA.Set(m_fixtureA.GetShape());
s_input.proxyB.Set(m_fixtureB.GetShape());
s_input.sweepA = _arg1;
s_input.sweepB = _arg2;
s_input.tolerance = b2Settings.b2_linearSlop;
return (b2TimeOfImpact.TimeOfImpact(s_input));
}
b2internal function Evaluate():void{
}
}
}//package Box2D.Dynamics.Contacts
Section 103
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var type:int;
public var normalMass:b2Mat22;
public var K:b2Mat22;
public var manifold:b2Manifold;
public var radius:Number;
public var bodyA:b2Body;
public var bodyB:b2Body;
public var points:Array;
public var localPoint:b2Vec2;
public var pointCount:int;
public var normal:b2Vec2;
public var restitution:Number;
public var localPlaneNormal:b2Vec2;
public var friction:Number;
public function b2ContactConstraint(){
localPlaneNormal = new b2Vec2();
localPoint = new b2Vec2();
normal = new b2Vec2();
normalMass = new b2Mat22();
K = new b2Mat22();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactConstraintPoint();
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 104
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var localPoint:b2Vec2;
public var normalImpulse:Number;
public var rA:b2Vec2;
public var rB:b2Vec2;
public var tangentImpulse:Number;
public var equalizedMass:Number;
public var tangentMass:Number;
public var normalMass:Number;
public var velocityBias:Number;
public function b2ContactConstraintPoint(){
localPoint = new b2Vec2();
rA = new b2Vec2();
rB = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 105
//b2ContactEdge (Box2D.Dynamics.Contacts.b2ContactEdge)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactEdge {
public var other:b2Body;
public var prev:b2ContactEdge;
public var contact:b2Contact;
public var next:b2ContactEdge;
}
}//package Box2D.Dynamics.Contacts
Section 106
//b2ContactFactory (Box2D.Dynamics.Contacts.b2ContactFactory)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2ContactFactory {
private var m_allocator;
private var m_registers:Array;
public function b2ContactFactory(_arg1){
m_allocator = _arg1;
InitializeRegisters();
}
b2internal function InitializeRegisters():void{
var _local2:int;
m_registers = new Array(b2Shape.e_shapeTypeCount);
var _local1:int;
while (_local1 < b2Shape.e_shapeTypeCount) {
m_registers[_local1] = new Array(b2Shape.e_shapeTypeCount);
_local2 = 0;
while (_local2 < b2Shape.e_shapeTypeCount) {
m_registers[_local1][_local2] = new b2ContactRegister();
_local2++;
};
_local1++;
};
AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape);
AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape);
AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, b2Shape.e_edgeShape, b2Shape.e_circleShape);
AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape);
}
public function Destroy(_arg1:b2Contact):void{
if (_arg1.m_manifold.m_pointCount > 0){
_arg1.m_fixtureA.m_body.SetAwake(true);
_arg1.m_fixtureB.m_body.SetAwake(true);
};
var _local2:int = _arg1.m_fixtureA.GetType();
var _local3:int = _arg1.m_fixtureB.GetType();
var _local4:b2ContactRegister = m_registers[_local2][_local3];
_local4.poolCount++;
_arg1.m_next = _local4.pool;
_local4.pool = _arg1;
var _local5:Function = _local4.destroyFcn;
_local5(_arg1, m_allocator);
}
b2internal function AddType(_arg1:Function, _arg2:Function, _arg3:int, _arg4:int):void{
m_registers[_arg3][_arg4].createFcn = _arg1;
m_registers[_arg3][_arg4].destroyFcn = _arg2;
m_registers[_arg3][_arg4].primary = true;
if (_arg3 != _arg4){
m_registers[_arg4][_arg3].createFcn = _arg1;
m_registers[_arg4][_arg3].destroyFcn = _arg2;
m_registers[_arg4][_arg3].primary = false;
};
}
public function Create(_arg1:b2Fixture, _arg2:b2Fixture):b2Contact{
var _local6:b2Contact;
var _local3:int = _arg1.GetType();
var _local4:int = _arg2.GetType();
var _local5:b2ContactRegister = m_registers[_local3][_local4];
if (_local5.pool){
_local6 = _local5.pool;
_local5.pool = _local6.m_next;
_local5.poolCount--;
_local6.Reset(_arg1, _arg2);
return (_local6);
};
var _local7:Function = _local5.createFcn;
if (_local7 != null){
if (_local5.primary){
_local6 = _local7(m_allocator);
_local6.Reset(_arg1, _arg2);
return (_local6);
};
_local6 = _local7(m_allocator);
_local6.Reset(_arg2, _arg1);
return (_local6);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 107
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var poolCount:int;
public var createFcn:Function;
public var destroyFcn:Function;
public var pool:b2Contact;
}
}//package Box2D.Dynamics.Contacts
Section 108
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2ContactSolver {
private var m_constraintCount:int;
b2internal var m_constraints:Array;
private var m_allocator;
private var m_step:b2TimeStep;
private static var s_psm:b2PositionSolverManifold = new b2PositionSolverManifold();
private static var s_worldManifold:b2WorldManifold = new b2WorldManifold();
public function b2ContactSolver(){
m_step = new b2TimeStep();
m_constraints = new Array();
super();
}
public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2Mat22;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:b2ContactConstraintPoint;
var _local21:Number;
var _local22:Number;
var _local23:b2ContactConstraintPoint;
var _local5:int;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.bodyA;
_local8 = _local6.bodyB;
_local9 = _local7.m_invMass;
_local10 = _local7.m_invI;
_local11 = _local8.m_invMass;
_local12 = _local8.m_invI;
_local13 = _local6.normal.x;
_local14 = _local6.normal.y;
_local15 = _local14;
_local16 = -(_local13);
if (_arg1.warmStarting){
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local20 = _local6.points[_local18];
_local6.points[_local18].normalImpulse = (_local20.normalImpulse * _arg1.dtRatio);
_local20.tangentImpulse = (_local20.tangentImpulse * _arg1.dtRatio);
_local21 = ((_local20.normalImpulse * _local13) + (_local20.tangentImpulse * _local15));
_local22 = ((_local20.normalImpulse * _local14) + (_local20.tangentImpulse * _local16));
_local7.m_angularVelocity = (_local7.m_angularVelocity - (_local10 * ((_local20.rA.x * _local22) - (_local20.rA.y * _local21))));
_local7.m_linearVelocity.x = (_local7.m_linearVelocity.x - (_local9 * _local21));
_local7.m_linearVelocity.y = (_local7.m_linearVelocity.y - (_local9 * _local22));
_local8.m_angularVelocity = (_local8.m_angularVelocity + (_local12 * ((_local20.rB.x * _local22) - (_local20.rB.y * _local21))));
_local8.m_linearVelocity.x = (_local8.m_linearVelocity.x + (_local11 * _local21));
_local8.m_linearVelocity.y = (_local8.m_linearVelocity.y + (_local11 * _local22));
_local18++;
};
} else {
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local23 = _local6.points[_local18];
_local23.normalImpulse = 0;
_local23.tangentImpulse = 0;
_local18++;
};
};
_local5++;
};
}
public function SolvePositionConstraints(_arg1:Number):Boolean{
var _local4:b2ContactConstraint;
var _local5:b2Body;
var _local6:b2Body;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:int;
var _local13:b2ContactConstraintPoint;
var _local14:b2Vec2;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local2:Number = 0;
var _local3:int;
while (_local3 < m_constraintCount) {
_local4 = m_constraints[_local3];
_local5 = _local4.bodyA;
_local6 = _local4.bodyB;
_local7 = (_local5.m_mass * _local5.m_invMass);
_local8 = (_local5.m_mass * _local5.m_invI);
_local9 = (_local6.m_mass * _local6.m_invMass);
_local10 = (_local6.m_mass * _local6.m_invI);
s_psm.Initialize(_local4);
_local11 = s_psm.m_normal;
_local12 = 0;
while (_local12 < _local4.pointCount) {
_local13 = _local4.points[_local12];
_local14 = s_psm.m_points[_local12];
_local15 = s_psm.m_separations[_local12];
_local16 = (_local14.x - _local5.m_sweep.c.x);
_local17 = (_local14.y - _local5.m_sweep.c.y);
_local18 = (_local14.x - _local6.m_sweep.c.x);
_local19 = (_local14.y - _local6.m_sweep.c.y);
_local2 = ((_local2 < _local15)) ? _local2 : _local15;
_local20 = b2Math.Clamp((_arg1 * (_local15 + b2Settings.b2_linearSlop)), -(b2Settings.b2_maxLinearCorrection), 0);
_local21 = (-(_local13.equalizedMass) * _local20);
_local22 = (_local21 * _local11.x);
_local23 = (_local21 * _local11.y);
_local5.m_sweep.c.x = (_local5.m_sweep.c.x - (_local7 * _local22));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y - (_local7 * _local23));
_local5.m_sweep.a = (_local5.m_sweep.a - (_local8 * ((_local16 * _local23) - (_local17 * _local22))));
_local5.SynchronizeTransform();
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_local9 * _local22));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_local9 * _local23));
_local6.m_sweep.a = (_local6.m_sweep.a + (_local10 * ((_local18 * _local23) - (_local19 * _local22))));
_local6.SynchronizeTransform();
_local12++;
};
_local3++;
};
return ((_local2 > (-1.5 * b2Settings.b2_linearSlop)));
}
public function Initialize(_arg1:b2TimeStep, _arg2:Array, _arg3:int, _arg4):void{
var _local5:b2Contact;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Mat22;
var _local9:b2Fixture;
var _local10:b2Fixture;
var _local11:b2Shape;
var _local12:b2Shape;
var _local13:Number;
var _local14:Number;
var _local15:b2Body;
var _local16:b2Body;
var _local17:b2Manifold;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:b2ContactConstraint;
var _local29:uint;
var _local30:b2ManifoldPoint;
var _local31:b2ContactConstraintPoint;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:Number;
var _local47:Number;
var _local48:b2ContactConstraintPoint;
var _local49:b2ContactConstraintPoint;
var _local50:Number;
var _local51:Number;
var _local52:Number;
var _local53:Number;
var _local54:Number;
var _local55:Number;
var _local56:Number;
var _local57:Number;
var _local58:Number;
var _local59:Number;
var _local60:Number;
var _local61:Number;
m_step.Set(_arg1);
m_allocator = _arg4;
m_constraintCount = _arg3;
while (m_constraints.length < m_constraintCount) {
m_constraints[m_constraints.length] = new b2ContactConstraint();
};
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
_local9 = _local5.m_fixtureA;
_local10 = _local5.m_fixtureB;
_local11 = _local9.m_shape;
_local12 = _local10.m_shape;
_local13 = _local11.m_radius;
_local14 = _local12.m_radius;
_local15 = _local9.m_body;
_local16 = _local10.m_body;
_local17 = _local5.GetManifold();
_local18 = b2Settings.b2MixFriction(_local9.GetFriction(), _local10.GetFriction());
_local19 = b2Settings.b2MixRestitution(_local9.GetRestitution(), _local10.GetRestitution());
_local20 = _local15.m_linearVelocity.x;
_local21 = _local15.m_linearVelocity.y;
_local22 = _local16.m_linearVelocity.x;
_local23 = _local16.m_linearVelocity.y;
_local24 = _local15.m_angularVelocity;
_local25 = _local16.m_angularVelocity;
b2Settings.b2Assert((_local17.m_pointCount > 0));
s_worldManifold.Initialize(_local17, _local15.m_xf, _local13, _local16.m_xf, _local14);
_local26 = s_worldManifold.m_normal.x;
_local27 = s_worldManifold.m_normal.y;
_local28 = m_constraints[_local6];
_local28.bodyA = _local15;
_local28.bodyB = _local16;
_local28.manifold = _local17;
_local28.normal.x = _local26;
_local28.normal.y = _local27;
_local28.pointCount = _local17.m_pointCount;
_local28.friction = _local18;
_local28.restitution = _local19;
_local28.localPlaneNormal.x = _local17.m_localPlaneNormal.x;
_local28.localPlaneNormal.y = _local17.m_localPlaneNormal.y;
_local28.localPoint.x = _local17.m_localPoint.x;
_local28.localPoint.y = _local17.m_localPoint.y;
_local28.radius = (_local13 + _local14);
_local28.type = _local17.m_type;
_local29 = 0;
while (_local29 < _local28.pointCount) {
_local30 = _local17.m_points[_local29];
_local31 = _local28.points[_local29];
_local31.normalImpulse = _local30.m_normalImpulse;
_local31.tangentImpulse = _local30.m_tangentImpulse;
_local31.localPoint.SetV(_local30.m_localPoint);
_local32 = (_local31.rA.x = (s_worldManifold.m_points[_local29].x - _local15.m_sweep.c.x));
_local33 = (_local31.rA.y = (s_worldManifold.m_points[_local29].y - _local15.m_sweep.c.y));
_local34 = (_local31.rB.x = (s_worldManifold.m_points[_local29].x - _local16.m_sweep.c.x));
_local35 = (_local31.rB.y = (s_worldManifold.m_points[_local29].y - _local16.m_sweep.c.y));
_local36 = ((_local32 * _local27) - (_local33 * _local26));
_local37 = ((_local34 * _local27) - (_local35 * _local26));
_local36 = (_local36 * _local36);
_local37 = (_local37 * _local37);
_local38 = (((_local15.m_invMass + _local16.m_invMass) + (_local15.m_invI * _local36)) + (_local16.m_invI * _local37));
_local31.normalMass = (1 / _local38);
_local39 = ((_local15.m_mass * _local15.m_invMass) + (_local16.m_mass * _local16.m_invMass));
_local39 = (_local39 + (((_local15.m_mass * _local15.m_invI) * _local36) + ((_local16.m_mass * _local16.m_invI) * _local37)));
_local31.equalizedMass = (1 / _local39);
_local40 = _local27;
_local41 = -(_local26);
_local42 = ((_local32 * _local41) - (_local33 * _local40));
_local43 = ((_local34 * _local41) - (_local35 * _local40));
_local42 = (_local42 * _local42);
_local43 = (_local43 * _local43);
_local44 = (((_local15.m_invMass + _local16.m_invMass) + (_local15.m_invI * _local42)) + (_local16.m_invI * _local43));
_local31.tangentMass = (1 / _local44);
_local31.velocityBias = 0;
_local45 = (((_local22 + (-(_local25) * _local35)) - _local20) - (-(_local24) * _local33));
_local46 = (((_local23 + (_local25 * _local34)) - _local21) - (_local24 * _local32));
_local47 = ((_local28.normal.x * _local45) + (_local28.normal.y * _local46));
if (_local47 < -(b2Settings.b2_velocityThreshold)){
_local31.velocityBias = (_local31.velocityBias + (-(_local28.restitution) * _local47));
};
_local29++;
};
if (_local28.pointCount == 2){
_local48 = _local28.points[0];
_local49 = _local28.points[1];
_local50 = _local15.m_invMass;
_local51 = _local15.m_invI;
_local52 = _local16.m_invMass;
_local53 = _local16.m_invI;
_local54 = ((_local48.rA.x * _local27) - (_local48.rA.y * _local26));
_local55 = ((_local48.rB.x * _local27) - (_local48.rB.y * _local26));
_local56 = ((_local49.rA.x * _local27) - (_local49.rA.y * _local26));
_local57 = ((_local49.rB.x * _local27) - (_local49.rB.y * _local26));
_local58 = (((_local50 + _local52) + ((_local51 * _local54) * _local54)) + ((_local53 * _local55) * _local55));
_local59 = (((_local50 + _local52) + ((_local51 * _local56) * _local56)) + ((_local53 * _local57) * _local57));
_local60 = (((_local50 + _local52) + ((_local51 * _local54) * _local56)) + ((_local53 * _local55) * _local57));
_local61 = 100;
if ((_local58 * _local58) < (_local61 * ((_local58 * _local59) - (_local60 * _local60)))){
_local28.K.col1.Set(_local58, _local60);
_local28.K.col2.Set(_local60, _local59);
_local28.K.GetInverse(_local28.normalMass);
} else {
_local28.pointCount = 1;
};
};
_local6++;
};
}
public function SolveVelocityConstraints():void{
var _local1:int;
var _local2:b2ContactConstraintPoint;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:b2Mat22;
var _local23:b2Vec2;
var _local25:b2ContactConstraint;
var _local26:b2Body;
var _local27:b2Body;
var _local28:Number;
var _local29:Number;
var _local30:b2Vec2;
var _local31:b2Vec2;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:int;
var _local43:b2ContactConstraintPoint;
var _local44:b2ContactConstraintPoint;
var _local45:Number;
var _local46:Number;
var _local47:Number;
var _local48:Number;
var _local49:Number;
var _local50:Number;
var _local51:Number;
var _local52:Number;
var _local53:Number;
var _local54:Number;
var _local55:Number;
var _local56:Number;
var _local57:Number;
var _local24:int;
while (_local24 < m_constraintCount) {
_local25 = m_constraints[_local24];
_local26 = _local25.bodyA;
_local27 = _local25.bodyB;
_local28 = _local26.m_angularVelocity;
_local29 = _local27.m_angularVelocity;
_local30 = _local26.m_linearVelocity;
_local31 = _local27.m_linearVelocity;
_local32 = _local26.m_invMass;
_local33 = _local26.m_invI;
_local34 = _local27.m_invMass;
_local35 = _local27.m_invI;
_local36 = _local25.normal.x;
_local37 = _local25.normal.y;
_local38 = _local37;
_local39 = -(_local36);
_local40 = _local25.friction;
_local1 = 0;
while (_local1 < _local25.pointCount) {
_local2 = _local25.points[_local1];
_local7 = (((_local31.x - (_local29 * _local2.rB.y)) - _local30.x) + (_local28 * _local2.rA.y));
_local8 = (((_local31.y + (_local29 * _local2.rB.x)) - _local30.y) - (_local28 * _local2.rA.x));
_local10 = ((_local7 * _local38) + (_local8 * _local39));
_local11 = (_local2.tangentMass * -(_local10));
_local12 = (_local40 * _local2.normalImpulse);
_local13 = b2Math.Clamp((_local2.tangentImpulse + _local11), -(_local12), _local12);
_local11 = (_local13 - _local2.tangentImpulse);
_local14 = (_local11 * _local38);
_local15 = (_local11 * _local39);
_local30.x = (_local30.x - (_local32 * _local14));
_local30.y = (_local30.y - (_local32 * _local15));
_local28 = (_local28 - (_local33 * ((_local2.rA.x * _local15) - (_local2.rA.y * _local14))));
_local31.x = (_local31.x + (_local34 * _local14));
_local31.y = (_local31.y + (_local34 * _local15));
_local29 = (_local29 + (_local35 * ((_local2.rB.x * _local15) - (_local2.rB.y * _local14))));
_local2.tangentImpulse = _local13;
_local1++;
};
_local42 = _local25.pointCount;
if (_local25.pointCount == 1){
_local2 = _local25.points[0];
_local7 = (((_local31.x + (-(_local29) * _local2.rB.y)) - _local30.x) - (-(_local28) * _local2.rA.y));
_local8 = (((_local31.y + (_local29 * _local2.rB.x)) - _local30.y) - (_local28 * _local2.rA.x));
_local9 = ((_local7 * _local36) + (_local8 * _local37));
_local11 = (-(_local2.normalMass) * (_local9 - _local2.velocityBias));
_local13 = (_local2.normalImpulse + _local11);
_local13 = ((_local13 > 0)) ? _local13 : 0;
_local11 = (_local13 - _local2.normalImpulse);
_local14 = (_local11 * _local36);
_local15 = (_local11 * _local37);
_local30.x = (_local30.x - (_local32 * _local14));
_local30.y = (_local30.y - (_local32 * _local15));
_local28 = (_local28 - (_local33 * ((_local2.rA.x * _local15) - (_local2.rA.y * _local14))));
_local31.x = (_local31.x + (_local34 * _local14));
_local31.y = (_local31.y + (_local34 * _local15));
_local29 = (_local29 + (_local35 * ((_local2.rB.x * _local15) - (_local2.rB.y * _local14))));
_local2.normalImpulse = _local13;
} else {
_local43 = _local25.points[0];
_local44 = _local25.points[1];
_local45 = _local43.normalImpulse;
_local46 = _local44.normalImpulse;
_local47 = (((_local31.x - (_local29 * _local43.rB.y)) - _local30.x) + (_local28 * _local43.rA.y));
_local48 = (((_local31.y + (_local29 * _local43.rB.x)) - _local30.y) - (_local28 * _local43.rA.x));
_local49 = (((_local31.x - (_local29 * _local44.rB.y)) - _local30.x) + (_local28 * _local44.rA.y));
_local50 = (((_local31.y + (_local29 * _local44.rB.x)) - _local30.y) - (_local28 * _local44.rA.x));
_local51 = ((_local47 * _local36) + (_local48 * _local37));
_local52 = ((_local49 * _local36) + (_local50 * _local37));
_local53 = (_local51 - _local43.velocityBias);
_local54 = (_local52 - _local44.velocityBias);
_local22 = _local25.K;
_local53 = (_local53 - ((_local22.col1.x * _local45) + (_local22.col2.x * _local46)));
_local54 = (_local54 - ((_local22.col1.y * _local45) + (_local22.col2.y * _local46)));
_local55 = 0.001;
while (true) {
_local22 = _local25.normalMass;
_local56 = -(((_local22.col1.x * _local53) + (_local22.col2.x * _local54)));
_local57 = -(((_local22.col1.y * _local53) + (_local22.col2.y * _local54)));
if ((((_local56 >= 0)) && ((_local57 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
_local56 = (-(_local43.normalMass) * _local53);
_local57 = 0;
_local51 = 0;
_local52 = ((_local25.K.col1.y * _local56) + _local54);
if ((((_local56 >= 0)) && ((_local52 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
_local56 = 0;
_local57 = (-(_local44.normalMass) * _local54);
_local51 = ((_local25.K.col2.x * _local57) + _local53);
_local52 = 0;
if ((((_local57 >= 0)) && ((_local51 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
_local56 = 0;
_local57 = 0;
_local51 = _local53;
_local52 = _local54;
if ((((_local51 >= 0)) && ((_local52 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
break;
};
};
_local26.m_angularVelocity = _local28;
_local27.m_angularVelocity = _local29;
_local24++;
};
}
public function FinalizeVelocityConstraints():void{
var _local2:b2ContactConstraint;
var _local3:b2Manifold;
var _local4:int;
var _local5:b2ManifoldPoint;
var _local6:b2ContactConstraintPoint;
var _local1:int;
while (_local1 < m_constraintCount) {
_local2 = m_constraints[_local1];
_local3 = _local2.manifold;
_local4 = 0;
while (_local4 < _local2.pointCount) {
_local5 = _local3.m_points[_local4];
_local6 = _local2.points[_local4];
_local5.m_normalImpulse = _local6.normalImpulse;
_local5.m_tangentImpulse = _local6.tangentImpulse;
_local4++;
};
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 109
//b2EdgeAndCircleContact (Box2D.Dynamics.Contacts.b2EdgeAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2EdgeAndCircleContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2CollideEdgeAndCircle(m_manifold, (m_fixtureA.GetShape() as b2EdgeShape), _local1.m_xf, (m_fixtureB.GetShape() as b2CircleShape), _local2.m_xf);
}
private function b2CollideEdgeAndCircle(_arg1:b2Manifold, _arg2:b2EdgeShape, _arg3:b2Transform, _arg4:b2CircleShape, _arg5:b2Transform):void{
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2EdgeAndCircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 110
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.m_body;
var _local2:b2Body = m_fixtureB.m_body;
b2Collision.CollidePolygonAndCircle(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), _local1.m_xf, (m_fixtureB.GetShape() as b2CircleShape), _local2.m_xf);
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
b2Settings.b2Assert((_arg1.GetType() == b2Shape.e_polygonShape));
b2Settings.b2Assert((_arg2.GetType() == b2Shape.e_circleShape));
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2PolyAndCircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 111
//b2PolyAndEdgeContact (Box2D.Dynamics.Contacts.b2PolyAndEdgeContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndEdgeContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2CollidePolyAndEdge(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), _local1.m_xf, (m_fixtureB.GetShape() as b2EdgeShape), _local2.m_xf);
}
private function b2CollidePolyAndEdge(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2EdgeShape, _arg5:b2Transform):void{
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
b2Settings.b2Assert((_arg1.GetType() == b2Shape.e_polygonShape));
b2Settings.b2Assert((_arg2.GetType() == b2Shape.e_edgeShape));
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2PolyAndEdgeContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 112
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolygonContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2Collision.CollidePolygons(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), _local1.m_xf, (m_fixtureB.GetShape() as b2PolygonShape), _local2.m_xf);
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2PolygonContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 113
//b2PositionSolverManifold (Box2D.Dynamics.Contacts.b2PositionSolverManifold)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
class b2PositionSolverManifold {
public var m_points:Array;
public var m_normal:b2Vec2;
public var m_separations:Array;
private static var circlePointA:b2Vec2 = new b2Vec2();
private static var circlePointB:b2Vec2 = new b2Vec2();
function b2PositionSolverManifold(){
m_normal = new b2Vec2();
m_separations = new Array(b2Settings.b2_maxManifoldPoints);
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
m_points[_local1] = new b2Vec2();
_local1++;
};
}
public function Initialize(_arg1:b2ContactConstraint):void{
var _local2:int;
var _local3:Number;
var _local4:Number;
var _local5:b2Mat22;
var _local6:b2Vec2;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
b2Settings.b2Assert((_arg1.pointCount > 0));
switch (_arg1.type){
case b2Manifold.e_circles:
_local5 = _arg1.bodyA.m_xf.R;
_local6 = _arg1.localPoint;
_local9 = (_arg1.bodyA.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local10 = (_arg1.bodyA.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local5 = _arg1.bodyB.m_xf.R;
_local6 = _arg1.points[0].localPoint;
_local11 = (_arg1.bodyB.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local12 = (_arg1.bodyB.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local13 = (_local11 - _local9);
_local14 = (_local12 - _local10);
_local15 = ((_local13 * _local13) + (_local14 * _local14));
if (_local15 > (Number.MIN_VALUE * Number.MIN_VALUE)){
_local16 = Math.sqrt(_local15);
m_normal.x = (_local13 / _local16);
m_normal.y = (_local14 / _local16);
} else {
m_normal.x = 1;
m_normal.y = 0;
};
m_points[0].x = (0.5 * (_local9 + _local11));
m_points[0].y = (0.5 * (_local10 + _local12));
m_separations[0] = (((_local13 * m_normal.x) + (_local14 * m_normal.y)) - _arg1.radius);
break;
case b2Manifold.e_faceA:
_local5 = _arg1.bodyA.m_xf.R;
_local6 = _arg1.localPlaneNormal;
m_normal.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y));
m_normal.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y));
_local5 = _arg1.bodyA.m_xf.R;
_local6 = _arg1.localPoint;
_local7 = (_arg1.bodyA.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local8 = (_arg1.bodyA.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local5 = _arg1.bodyB.m_xf.R;
_local2 = 0;
while (_local2 < _arg1.pointCount) {
_local6 = _arg1.points[_local2].localPoint;
_local3 = (_arg1.bodyB.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local4 = (_arg1.bodyB.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
m_separations[_local2] = ((((_local3 - _local7) * m_normal.x) + ((_local4 - _local8) * m_normal.y)) - _arg1.radius);
m_points[_local2].x = _local3;
m_points[_local2].y = _local4;
_local2++;
};
break;
case b2Manifold.e_faceB:
_local5 = _arg1.bodyB.m_xf.R;
_local6 = _arg1.localPlaneNormal;
m_normal.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y));
m_normal.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y));
_local5 = _arg1.bodyB.m_xf.R;
_local6 = _arg1.localPoint;
_local7 = (_arg1.bodyB.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local8 = (_arg1.bodyB.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local5 = _arg1.bodyA.m_xf.R;
_local2 = 0;
while (_local2 < _arg1.pointCount) {
_local6 = _arg1.points[_local2].localPoint;
_local3 = (_arg1.bodyA.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local4 = (_arg1.bodyA.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
m_separations[_local2] = ((((_local3 - _local7) * m_normal.x) + ((_local4 - _local8) * m_normal.y)) - _arg1.radius);
m_points[_local2].Set(_local3, _local4);
_local2++;
};
m_normal.x = (m_normal.x * -1);
m_normal.y = (m_normal.y * -1);
break;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 114
//b2Controller (Box2D.Dynamics.Controllers.b2Controller)
package Box2D.Dynamics.Controllers {
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2Controller {
b2internal var m_world:b2World;
b2internal var m_prev:b2Controller;
b2internal var m_next:b2Controller;
protected var m_bodyList:b2ControllerEdge;
protected var m_bodyCount:int;
public function AddBody(_arg1:b2Body):void{
var _local2:b2ControllerEdge = new b2ControllerEdge();
_local2.controller = this;
_local2.body = _arg1;
_local2.nextBody = m_bodyList;
_local2.prevBody = null;
m_bodyList = _local2;
if (_local2.nextBody){
_local2.nextBody.prevBody = _local2;
};
m_bodyCount++;
_local2.nextController = _arg1.m_controllerList;
_local2.prevController = null;
_arg1.m_controllerList = _local2;
if (_local2.nextController){
_local2.nextController.prevController = _local2;
};
_arg1.m_controllerCount++;
}
public function Draw(_arg1:b2DebugDraw):void{
}
public function RemoveBody(_arg1:b2Body):void{
var _local2:b2ControllerEdge = _arg1.m_controllerList;
while (((_local2) && (!((_local2.controller == this))))) {
_local2 = _local2.nextController;
};
if (_local2.prevBody){
_local2.prevBody.nextBody = _local2.nextBody;
};
if (_local2.nextBody){
_local2.nextBody.prevBody = _local2.prevBody;
};
if (_local2.nextController){
_local2.nextController.prevController = _local2.prevController;
};
if (_local2.prevController){
_local2.prevController.nextController = _local2.nextController;
};
if (m_bodyList == _local2){
m_bodyList = _local2.nextBody;
};
if (_arg1.m_controllerList == _local2){
_arg1.m_controllerList = _local2.nextController;
};
_arg1.m_controllerCount--;
m_bodyCount--;
}
public function GetNext():b2Controller{
return (m_next);
}
public function Clear():void{
while (m_bodyList) {
RemoveBody(m_bodyList.body);
};
}
public function Step(_arg1:b2TimeStep):void{
}
public function GetBodyList():b2ControllerEdge{
return (m_bodyList);
}
public function GetWorld():b2World{
return (m_world);
}
}
}//package Box2D.Dynamics.Controllers
Section 115
//b2ControllerEdge (Box2D.Dynamics.Controllers.b2ControllerEdge)
package Box2D.Dynamics.Controllers {
import Box2D.Dynamics.*;
public class b2ControllerEdge {
public var body:b2Body;
public var nextBody:b2ControllerEdge;
public var nextController:b2ControllerEdge;
public var prevBody:b2ControllerEdge;
public var prevController:b2ControllerEdge;
public var controller:b2Controller;
}
}//package Box2D.Dynamics.Controllers
Section 116
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_length:Number;
private var m_mass:Number;
private var m_bias:Number;
private var m_gamma:Number;
private var m_u:b2Vec2;
private var m_impulse:Number;
private var m_dampingRatio:Number;
private var m_frequencyHz:Number;
public function b2DistanceJoint(_arg1:b2DistanceJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u = new b2Vec2();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_length = _arg1.length;
m_frequencyHz = _arg1.frequencyHz;
m_dampingRatio = _arg1.dampingRatio;
m_impulse = 0;
m_gamma = 0;
m_bias = 0;
}
public function SetFrequency(_arg1:Number):void{
m_frequencyHz = _arg1;
}
public function GetFrequency():Number{
return (m_frequencyHz);
}
public function SetLength(_arg1:Number):void{
m_length = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local7:Number;
var _local9:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
_local4 = m_bodyA;
_local5 = m_bodyB;
_local2 = _local4.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
_local7 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
m_u.x = (((_local5.m_sweep.c.x + _local8) - _local4.m_sweep.c.x) - _local6);
m_u.y = (((_local5.m_sweep.c.y + _local9) - _local4.m_sweep.c.y) - _local7);
var _local10:Number = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (_local10 > b2Settings.b2_linearSlop){
m_u.Multiply((1 / _local10));
} else {
m_u.SetZero();
};
var _local11:Number = ((_local6 * m_u.y) - (_local7 * m_u.x));
var _local12:Number = ((_local8 * m_u.y) - (_local9 * m_u.x));
var _local13:Number = (((_local4.m_invMass + ((_local4.m_invI * _local11) * _local11)) + _local5.m_invMass) + ((_local5.m_invI * _local12) * _local12));
m_mass = ((_local13)!=0) ? (1 / _local13) : 0;
if (m_frequencyHz > 0){
_local14 = (_local10 - m_length);
_local15 = ((2 * Math.PI) * m_frequencyHz);
_local16 = (((2 * m_mass) * m_dampingRatio) * _local15);
_local17 = ((m_mass * _local15) * _local15);
m_gamma = (_arg1.dt * (_local16 + (_arg1.dt * _local17)));
m_gamma = ((m_gamma)!=0) ? (1 / m_gamma) : 0;
m_bias = (((_local14 * _arg1.dt) * _local17) * m_gamma);
m_mass = (_local13 + m_gamma);
m_mass = ((m_mass)!=0) ? (1 / m_mass) : 0;
};
if (_arg1.warmStarting){
m_impulse = (m_impulse * _arg1.dtRatio);
_local18 = (m_impulse * m_u.x);
_local19 = (m_impulse * m_u.y);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local4.m_invMass * _local18));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local4.m_invMass * _local19));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local4.m_invI * ((_local6 * _local19) - (_local7 * _local18))));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local5.m_invMass * _local18));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local5.m_invMass * _local19));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local5.m_invI * ((_local8 * _local19) - (_local9 * _local18))));
} else {
m_impulse = 0;
};
}
public function SetDampingRatio(_arg1:Number):void{
m_dampingRatio = _arg1;
}
public function GetLength():Number{
return (m_length);
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2(((_arg1 * m_impulse) * m_u.x), ((_arg1 * m_impulse) * m_u.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:b2Mat22;
if (m_frequencyHz > 0){
return (true);
};
var _local3:b2Body = m_bodyA;
var _local4:b2Body = m_bodyB;
_local2 = _local3.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (((_local4.m_sweep.c.x + _local8) - _local3.m_sweep.c.x) - _local5);
var _local11:Number = (((_local4.m_sweep.c.y + _local9) - _local3.m_sweep.c.y) - _local6);
var _local12:Number = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
_local10 = (_local10 / _local12);
_local11 = (_local11 / _local12);
var _local13:Number = (_local12 - m_length);
_local13 = b2Math.Clamp(_local13, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var _local14:Number = (-(m_mass) * _local13);
m_u.Set(_local10, _local11);
var _local15:Number = (_local14 * m_u.x);
var _local16:Number = (_local14 * m_u.y);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x - (_local3.m_invMass * _local15));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y - (_local3.m_invMass * _local16));
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * ((_local5 * _local16) - (_local6 * _local15))));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + (_local4.m_invMass * _local15));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + (_local4.m_invMass * _local16));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * ((_local8 * _local16) - (_local9 * _local15))));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
return ((b2Math.Abs(_local13) < b2Settings.b2_linearSlop));
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:b2Body = m_bodyA;
var _local4:b2Body = m_bodyB;
_local2 = _local3.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local6));
var _local11:Number = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local5));
var _local12:Number = (_local4.m_linearVelocity.x + (-(_local4.m_angularVelocity) * _local9));
var _local13:Number = (_local4.m_linearVelocity.y + (_local4.m_angularVelocity * _local8));
var _local14:Number = ((m_u.x * (_local12 - _local10)) + (m_u.y * (_local13 - _local11)));
var _local15:Number = (-(m_mass) * ((_local14 + m_bias) + (m_gamma * m_impulse)));
m_impulse = (m_impulse + _local15);
var _local16:Number = (_local15 * m_u.x);
var _local17:Number = (_local15 * m_u.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x - (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y - (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity - (_local3.m_invI * ((_local5 * _local17) - (_local6 * _local16))));
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + (_local4.m_invMass * _local16));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + (_local4.m_invMass * _local17));
_local4.m_angularVelocity = (_local4.m_angularVelocity + (_local4.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
}
public function GetDampingRatio():Number{
return (m_dampingRatio);
}
}
}//package Box2D.Dynamics.Joints
Section 117
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2DistanceJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var length:Number;
public var dampingRatio:Number;
public var localAnchorB:b2Vec2;
public var frequencyHz:Number;
public function b2DistanceJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
length = 1;
frequencyHz = 0;
dampingRatio = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA.SetV(bodyA.GetLocalPoint(_arg3));
localAnchorB.SetV(bodyB.GetLocalPoint(_arg4));
var _local5:Number = (_arg4.x - _arg3.x);
var _local6:Number = (_arg4.y - _arg3.y);
length = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
frequencyHz = 0;
dampingRatio = 0;
}
}
}//package Box2D.Dynamics.Joints
Section 118
//b2FrictionJoint (Box2D.Dynamics.Joints.b2FrictionJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2FrictionJoint extends b2Joint {
private var m_maxTorque:Number;
private var m_angularImpulse:Number;
public var m_linearMass:b2Mat22;
private var m_localAnchorA:b2Vec2;
private var m_localAnchorB:b2Vec2;
public var m_angularMass:Number;
private var m_maxForce:Number;
private var m_linearImpulse:b2Vec2;
public function b2FrictionJoint(_arg1:b2FrictionJointDef){
m_localAnchorA = new b2Vec2();
m_localAnchorB = new b2Vec2();
m_linearMass = new b2Mat22();
m_linearImpulse = new b2Vec2();
super(_arg1);
m_localAnchorA.SetV(_arg1.localAnchorA);
m_localAnchorB.SetV(_arg1.localAnchorB);
m_linearMass.SetZero();
m_angularMass = 0;
m_linearImpulse.SetZero();
m_angularImpulse = 0;
m_maxForce = _arg1.maxForce;
m_maxTorque = _arg1.maxTorque;
}
public function SetMaxForce(_arg1:Number):void{
m_maxForce = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local6:Number;
var _local8:Number;
var _local10:Number;
var _local12:Number;
var _local13:Number;
var _local14:b2Mat22;
var _local15:b2Vec2;
_local4 = m_bodyA;
_local5 = m_bodyB;
_local2 = _local4.m_xf.R;
_local6 = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
_local8 = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
_local10 = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
_local12 = _local4.m_invI;
_local13 = _local5.m_invI;
_local14 = new b2Mat22();
_local14.col1.x = (_local10 + _local11);
_local14.col2.x = 0;
_local14.col1.y = 0;
_local14.col2.y = (_local10 + _local11);
_local14.col1.x = (_local14.col1.x + ((_local12 * _local7) * _local7));
_local14.col2.x = (_local14.col2.x + ((-(_local12) * _local6) * _local7));
_local14.col1.y = (_local14.col1.y + ((-(_local12) * _local6) * _local7));
_local14.col2.y = (_local14.col2.y + ((_local12 * _local6) * _local6));
_local14.col1.x = (_local14.col1.x + ((_local13 * _local9) * _local9));
_local14.col2.x = (_local14.col2.x + ((-(_local13) * _local8) * _local9));
_local14.col1.y = (_local14.col1.y + ((-(_local13) * _local8) * _local9));
_local14.col2.y = (_local14.col2.y + ((_local13 * _local8) * _local8));
_local14.GetInverse(m_linearMass);
m_angularMass = (_local12 + _local13);
if (m_angularMass > 0){
m_angularMass = (1 / m_angularMass);
};
if (_arg1.warmStarting){
m_linearImpulse.x = (m_linearImpulse.x * _arg1.dtRatio);
m_linearImpulse.y = (m_linearImpulse.y * _arg1.dtRatio);
m_angularImpulse = (m_angularImpulse * _arg1.dtRatio);
_local15 = m_linearImpulse;
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local10 * _local15.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local10 * _local15.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local12 * (((_local6 * _local15.y) - (_local7 * _local15.x)) + m_angularImpulse)));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local11 * _local15.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local11 * _local15.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local13 * (((_local8 * _local15.y) - (_local9 * _local15.x)) + m_angularImpulse)));
} else {
m_linearImpulse.SetZero();
m_angularImpulse = 0;
};
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchorB));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchorA));
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_angularImpulse));
}
public function SetMaxTorque(_arg1:Number):void{
m_maxTorque = _arg1;
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
return (true);
}
public function GetMaxTorque():Number{
return (m_maxTorque);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local18:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_linearVelocity;
var _local7:Number = _local4.m_angularVelocity;
var _local8:b2Vec2 = _local5.m_linearVelocity;
var _local9:Number = _local5.m_angularVelocity;
var _local10:Number = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
var _local12:Number = _local4.m_invI;
var _local13:Number = _local5.m_invI;
_local2 = _local4.m_xf.R;
var _local14:Number = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local15:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local14) + (_local2.col2.x * _local15));
_local15 = ((_local2.col1.y * _local14) + (_local2.col2.y * _local15));
_local14 = _local3;
_local2 = _local5.m_xf.R;
var _local16:Number = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local17:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local16) + (_local2.col2.x * _local17));
_local17 = ((_local2.col1.y * _local16) + (_local2.col2.y * _local17));
_local16 = _local3;
var _local19:Number = (_local9 - _local7);
var _local20:Number = (-(m_angularMass) * _local19);
var _local21:Number = m_angularImpulse;
_local18 = (_arg1.dt * m_maxTorque);
m_angularImpulse = b2Math.Clamp((m_angularImpulse + _local20), -(_local18), _local18);
_local20 = (m_angularImpulse - _local21);
_local7 = (_local7 - (_local12 * _local20));
_local9 = (_local9 + (_local13 * _local20));
var _local22:Number = (((_local8.x - (_local9 * _local17)) - _local6.x) + (_local7 * _local15));
var _local23:Number = (((_local8.y + (_local9 * _local16)) - _local6.y) - (_local7 * _local14));
var _local24:b2Vec2 = b2Math.MulMV(m_linearMass, new b2Vec2(-(_local22), -(_local23)));
var _local25:b2Vec2 = m_linearImpulse.Copy();
m_linearImpulse.Add(_local24);
_local18 = (_arg1.dt * m_maxForce);
if (m_linearImpulse.LengthSquared() > (_local18 * _local18)){
m_linearImpulse.Normalize();
m_linearImpulse.Multiply(_local18);
};
_local24 = b2Math.SubtractVV(m_linearImpulse, _local25);
_local6.x = (_local6.x - (_local10 * _local24.x));
_local6.y = (_local6.y - (_local10 * _local24.y));
_local7 = (_local7 - (_local12 * ((_local14 * _local24.y) - (_local15 * _local24.x))));
_local8.x = (_local8.x + (_local11 * _local24.x));
_local8.y = (_local8.y + (_local11 * _local24.y));
_local9 = (_local9 + (_local13 * ((_local16 * _local24.y) - (_local17 * _local24.x))));
_local4.m_angularVelocity = _local7;
_local5.m_angularVelocity = _local9;
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_linearImpulse.x), (_arg1 * m_linearImpulse.y)));
}
public function GetMaxForce():Number{
return (m_maxForce);
}
}
}//package Box2D.Dynamics.Joints
Section 119
//b2FrictionJointDef (Box2D.Dynamics.Joints.b2FrictionJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2FrictionJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var maxTorque:Number;
public var maxForce:Number;
public var localAnchorB:b2Vec2;
public function b2FrictionJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_frictionJoint;
maxForce = 0;
maxTorque = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA.SetV(bodyA.GetLocalPoint(_arg3));
localAnchorB.SetV(bodyB.GetLocalPoint(_arg3));
}
}
}//package Box2D.Dynamics.Joints
Section 120
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
private var m_ground2:b2Body;
private var m_groundAnchor1:b2Vec2;
private var m_groundAnchor2:b2Vec2;
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_ratio:Number;
private var m_mass:Number;
private var m_impulse:Number;
private var m_prismatic2:b2PrismaticJoint;
private var m_ground1:b2Body;
private var m_revolute1:b2RevoluteJoint;
private var m_revolute2:b2RevoluteJoint;
private var m_prismatic1:b2PrismaticJoint;
private var m_constant:Number;
private var m_J:b2Jacobian;
public function b2GearJoint(_arg1:b2GearJointDef){
var _local4:Number;
var _local5:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(_arg1);
var _local2:int = _arg1.joint1.m_type;
var _local3:int = _arg1.joint2.m_type;
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = _arg1.joint1.GetBodyA();
m_bodyA = _arg1.joint1.GetBodyB();
if (_local2 == b2Joint.e_revoluteJoint){
m_revolute1 = (_arg1.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
_local4 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (_arg1.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
_local4 = m_prismatic1.GetJointTranslation();
};
m_ground2 = _arg1.joint2.GetBodyA();
m_bodyB = _arg1.joint2.GetBodyB();
if (_local3 == b2Joint.e_revoluteJoint){
m_revolute2 = (_arg1.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
_local5 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (_arg1.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
_local5 = m_prismatic2.GetJointTranslation();
};
m_ratio = _arg1.ratio;
m_constant = (_local4 + (m_ratio * _local5));
m_impulse = 0;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Body;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local2:b2Body = m_ground1;
var _local3:b2Body = m_ground2;
_local4 = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local14:Number = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angularA = -1;
_local14 = (_local14 + _local4.m_invI);
} else {
_local10 = _local2.m_xf.R;
_local11 = m_prismatic1.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local4.m_xf.R;
_local8 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linearA.Set(-(_local6), -(_local7));
m_J.angularA = -(_local12);
_local14 = (_local14 + (_local4.m_invMass + ((_local4.m_invI * _local12) * _local12)));
};
if (m_revolute2){
m_J.angularB = -(m_ratio);
_local14 = (_local14 + ((m_ratio * m_ratio) * _local5.m_invI));
} else {
_local10 = _local3.m_xf.R;
_local11 = m_prismatic2.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local5.m_xf.R;
_local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linearB.Set((-(m_ratio) * _local6), (-(m_ratio) * _local7));
m_J.angularB = (-(m_ratio) * _local12);
_local14 = (_local14 + ((m_ratio * m_ratio) * (_local5.m_invMass + ((_local5.m_invI * _local12) * _local12))));
};
m_mass = ((_local14 > 0)) ? (1 / _local14) : 0;
if (_arg1.warmStarting){
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * m_impulse) * m_J.linearA.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * m_impulse) * m_J.linearA.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * m_impulse) * m_J.angularA));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + ((_local5.m_invMass * m_impulse) * m_J.linearB.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + ((_local5.m_invMass * m_impulse) * m_J.linearB.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + ((_local5.m_invI * m_impulse) * m_J.angularB));
} else {
m_impulse = 0;
};
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local4:Number = m_J.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
var _local5:Number = (-(m_mass) * _local4);
m_impulse = (m_impulse + _local5);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local2.m_invMass * _local5) * m_J.linearA.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local2.m_invMass * _local5) * m_J.linearA.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local2.m_invI * _local5) * m_J.angularA));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * _local5) * m_J.linearB.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * _local5) * m_J.linearB.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _local5) * m_J.angularB));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function SetRatio(_arg1:Number):void{
m_ratio = _arg1;
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2(((_arg1 * m_impulse) * m_J.linearB.x), ((_arg1 * m_impulse) * m_J.linearB.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local5:Number;
var _local6:Number;
var _local2:Number = 0;
var _local3:b2Body = m_bodyA;
var _local4:b2Body = m_bodyB;
if (m_revolute1){
_local5 = m_revolute1.GetJointAngle();
} else {
_local5 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
_local6 = m_revolute2.GetJointAngle();
} else {
_local6 = m_prismatic2.GetJointTranslation();
};
var _local7:Number = (m_constant - (_local5 + (m_ratio * _local6)));
var _local8:Number = (-(m_mass) * _local7);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local3.m_invMass * _local8) * m_J.linearA.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local3.m_invMass * _local8) * m_J.linearA.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local3.m_invI * _local8) * m_J.angularA));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local4.m_invMass * _local8) * m_J.linearB.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local4.m_invMass * _local8) * m_J.linearB.y));
_local4.m_sweep.a = (_local4.m_sweep.a + ((_local4.m_invI * _local8) * m_J.angularB));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
return ((_local2 < b2Settings.b2_linearSlop));
}
override public function GetReactionTorque(_arg1:Number):Number{
var _local2:b2Mat22 = m_bodyB.m_xf.R;
var _local3:Number = (m_localAnchor1.x - m_bodyB.m_sweep.localCenter.x);
var _local4:Number = (m_localAnchor1.y - m_bodyB.m_sweep.localCenter.y);
var _local5:Number = ((_local2.col1.x * _local3) + (_local2.col2.x * _local4));
_local4 = ((_local2.col1.y * _local3) + (_local2.col2.y * _local4));
_local3 = _local5;
var _local6:Number = (m_impulse * m_J.linearB.x);
var _local7:Number = (m_impulse * m_J.linearB.y);
return ((_arg1 * (((m_impulse * m_J.angularB) - (_local3 * _local7)) + (_local4 * _local6))));
}
public function GetRatio():Number{
return (m_ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 121
//b2GearJointDef (Box2D.Dynamics.Joints.b2GearJointDef)
package Box2D.Dynamics.Joints {
public class b2GearJointDef extends b2JointDef {
public var joint1:b2Joint;
public var joint2:b2Joint;
public var ratio:Number;
public function b2GearJointDef(){
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Box2D.Dynamics.Joints
Section 122
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var angularB:Number;
public var linearA:b2Vec2;
public var linearB:b2Vec2;
public var angularA:Number;
public function b2Jacobian(){
linearA = new b2Vec2();
linearB = new b2Vec2();
super();
}
public function Set(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):void{
linearA.SetV(_arg1);
angularA = _arg2;
linearB.SetV(_arg3);
angularB = _arg4;
}
public function SetZero():void{
linearA.SetZero();
angularA = 0;
linearB.SetZero();
angularB = 0;
}
public function Compute(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{
return ((((((linearA.x * _arg1.x) + (linearA.y * _arg1.y)) + (angularA * _arg2)) + ((linearB.x * _arg3.x) + (linearB.y * _arg3.y))) + (angularB * _arg4)));
}
}
}//package Box2D.Dynamics.Joints
Section 123
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2Joint {
b2internal var m_islandFlag:Boolean;
b2internal var m_prev:b2Joint;
b2internal var m_invMassA:Number;
b2internal var m_localCenterA:b2Vec2;
b2internal var m_type:int;
b2internal var m_bodyA:b2Body;
b2internal var m_bodyB:b2Body;
b2internal var m_edgeA:b2JointEdge;
b2internal var m_edgeB:b2JointEdge;
b2internal var m_next:b2Joint;
private var m_userData;
b2internal var m_invMassB:Number;
b2internal var m_localCenterB:b2Vec2;
b2internal var m_invIB:Number;
b2internal var m_collideConnected:Boolean;
b2internal var m_invIA:Number;
b2internal static const e_prismaticJoint:int = 2;
b2internal static const e_weldJoint:int = 8;
b2internal static const e_equalLimits:int = 3;
b2internal static const e_frictionJoint:int = 9;
b2internal static const e_lineJoint:int = 7;
b2internal static const e_gearJoint:int = 6;
b2internal static const e_atUpperLimit:int = 2;
b2internal static const e_atLowerLimit:int = 1;
b2internal static const e_revoluteJoint:int = 1;
b2internal static const e_inactiveLimit:int = 0;
b2internal static const e_pulleyJoint:int = 4;
b2internal static const e_unknownJoint:int = 0;
b2internal static const e_distanceJoint:int = 3;
b2internal static const e_mouseJoint:int = 5;
public function b2Joint(_arg1:b2JointDef){
m_edgeA = new b2JointEdge();
m_edgeB = new b2JointEdge();
m_localCenterA = new b2Vec2();
m_localCenterB = new b2Vec2();
super();
b2Settings.b2Assert(!((_arg1.bodyA == _arg1.bodyB)));
m_type = _arg1.type;
m_prev = null;
m_next = null;
m_bodyA = _arg1.bodyA;
m_bodyB = _arg1.bodyB;
m_collideConnected = _arg1.collideConnected;
m_islandFlag = false;
m_userData = _arg1.userData;
}
b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
}
public function GetBodyB():b2Body{
return (m_bodyB);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetAnchorA():b2Vec2{
return (null);
}
public function GetType():int{
return (m_type);
}
public function GetAnchorB():b2Vec2{
return (null);
}
public function GetBodyA():b2Body{
return (m_bodyA);
}
public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce(_arg1:Number):b2Vec2{
return (null);
}
b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
return (false);
}
public function IsActive():Boolean{
return (((m_bodyA.IsActive()) && (m_bodyB.IsActive())));
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
}
b2internal function FinalizeVelocityConstraints():void{
}
b2internal static function Destroy(_arg1:b2Joint, _arg2):void{
}
b2internal static function Create(_arg1:b2JointDef, _arg2):b2Joint{
var _local3:b2Joint;
switch (_arg1.type){
case e_distanceJoint:
_local3 = new b2DistanceJoint((_arg1 as b2DistanceJointDef));
break;
case e_mouseJoint:
_local3 = new b2MouseJoint((_arg1 as b2MouseJointDef));
break;
case e_prismaticJoint:
_local3 = new b2PrismaticJoint((_arg1 as b2PrismaticJointDef));
break;
case e_revoluteJoint:
_local3 = new b2RevoluteJoint((_arg1 as b2RevoluteJointDef));
break;
case e_pulleyJoint:
_local3 = new b2PulleyJoint((_arg1 as b2PulleyJointDef));
break;
case e_gearJoint:
_local3 = new b2GearJoint((_arg1 as b2GearJointDef));
break;
case e_lineJoint:
_local3 = new b2LineJoint((_arg1 as b2LineJointDef));
break;
case e_weldJoint:
_local3 = new b2WeldJoint((_arg1 as b2WeldJointDef));
break;
case e_frictionJoint:
_local3 = new b2FrictionJoint((_arg1 as b2FrictionJointDef));
break;
default:
break;
};
return (_local3);
}
}
}//package Box2D.Dynamics.Joints
Section 124
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var bodyB:b2Body;
public var type:int;
public var userData;
public var collideConnected:Boolean;
public var bodyA:b2Body;
public function b2JointDef(){
type = b2Joint.e_unknownJoint;
userData = null;
bodyA = null;
bodyB = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 125
//b2JointEdge (Box2D.Dynamics.Joints.b2JointEdge)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointEdge {
public var other:b2Body;
public var next:b2JointEdge;
public var prev:b2JointEdge;
public var joint:b2Joint;
}
}//package Box2D.Dynamics.Joints
Section 126
//b2LineJoint (Box2D.Dynamics.Joints.b2LineJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2LineJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_perp:b2Vec2;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_impulse:b2Vec2;
private var m_enableLimit:Boolean;
private var m_maxMotorForce:Number;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_axis:b2Vec2;
private var m_motorMass:Number;
private var m_s1:Number;
private var m_upperTranslation:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_motorImpulse:Number;
private var m_motorSpeed:Number;
private var m_enableMotor:Boolean;
private var m_K:b2Mat22;
public function b2LineJoint(_arg1:b2LineJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_axis = new b2Vec2();
m_perp = new b2Vec2();
m_K = new b2Mat22();
m_impulse = new b2Vec2();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_localXAxis1.SetV(_arg1.localAxisA);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_impulse.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.maxMotorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
m_limitState = e_inactiveLimit;
m_axis.SetZero();
m_perp.SetZero();
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:b2Vec2;
var _local19:b2Vec2;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local4:b2Vec2 = _local2.m_linearVelocity;
var _local5:Number = _local2.m_angularVelocity;
var _local6:b2Vec2 = _local3.m_linearVelocity;
var _local7:Number = _local3.m_angularVelocity;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local13 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local14 = (m_motorMass * (m_motorSpeed - _local13));
_local15 = m_motorImpulse;
_local16 = (_arg1.dt * m_maxMotorForce);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + _local14), -(_local16), _local16);
_local14 = (m_motorImpulse - _local15);
_local8 = (_local14 * m_axis.x);
_local9 = (_local14 * m_axis.y);
_local10 = (_local14 * m_a1);
_local11 = (_local14 * m_a2);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
var _local12:Number = ((((m_perp.x * (_local6.x - _local4.x)) + (m_perp.y * (_local6.y - _local4.y))) + (m_s2 * _local7)) - (m_s1 * _local5));
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local17 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local18 = m_impulse.Copy();
_local19 = m_K.Solve(new b2Vec2(), -(_local12), -(_local17));
m_impulse.Add(_local19);
if (m_limitState == e_atLowerLimit){
m_impulse.y = b2Math.Max(m_impulse.y, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.y = b2Math.Min(m_impulse.y, 0);
};
};
_local20 = (-(_local12) - ((m_impulse.y - _local18.y) * m_K.col2.x));
if (m_K.col1.x != 0){
_local21 = ((_local20 / m_K.col1.x) + _local18.x);
} else {
_local21 = _local18.x;
};
m_impulse.x = _local21;
_local19.x = (m_impulse.x - _local18.x);
_local19.y = (m_impulse.y - _local18.y);
_local8 = ((_local19.x * m_perp.x) + (_local19.y * m_axis.x));
_local9 = ((_local19.x * m_perp.y) + (_local19.y * m_axis.y));
_local10 = ((_local19.x * m_s1) + (_local19.y * m_a1));
_local11 = ((_local19.x * m_s2) + (_local19.y * m_a2));
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
} else {
if (m_K.col1.x != 0){
_local22 = (-(_local12) / m_K.col1.x);
} else {
_local22 = 0;
};
m_impulse.x = (m_impulse.x + _local22);
_local8 = (_local22 * m_perp.x);
_local9 = (_local22 * m_perp.y);
_local10 = (_local22 * m_s1);
_local11 = (_local22 * m_s2);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
_local2.m_linearVelocity.SetV(_local4);
_local2.m_angularVelocity = _local5;
_local3.m_linearVelocity.SetV(_local6);
_local3.m_angularVelocity = _local7;
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableMotor = _arg1;
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function GetJointTranslation():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
var _local4:b2Vec2 = _local1.GetWorldPoint(m_localAnchor1);
var _local5:b2Vec2 = _local2.GetWorldPoint(m_localAnchor2);
var _local6:Number = (_local5.x - _local4.x);
var _local7:Number = (_local5.y - _local4.y);
var _local8:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local9:Number = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.y) * m_axis.x))), (_arg1 * ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.y) * m_axis.y)))));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_sweep.c;
var _local7:Number = _local4.m_sweep.a;
var _local8:b2Vec2 = _local5.m_sweep.c;
var _local9:Number = _local5.m_sweep.a;
var _local16:Number = 0;
var _local17:Number = 0;
var _local18:Boolean;
var _local19:Number = 0;
var _local20:b2Mat22 = b2Mat22.FromAngle(_local7);
var _local21:b2Mat22 = b2Mat22.FromAngle(_local9);
_local10 = _local20;
var _local22:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local23:Number = (m_localAnchor1.y - m_localCenterA.y);
_local11 = ((_local10.col1.x * _local22) + (_local10.col2.x * _local23));
_local23 = ((_local10.col1.y * _local22) + (_local10.col2.y * _local23));
_local22 = _local11;
_local10 = _local21;
var _local24:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local25:Number = (m_localAnchor2.y - m_localCenterB.y);
_local11 = ((_local10.col1.x * _local24) + (_local10.col2.x * _local25));
_local25 = ((_local10.col1.y * _local24) + (_local10.col2.y * _local25));
_local24 = _local11;
var _local26:Number = (((_local8.x + _local24) - _local6.x) - _local22);
var _local27:Number = (((_local8.y + _local25) - _local6.y) - _local23);
if (m_enableLimit){
m_axis = b2Math.MulMV(_local20, m_localXAxis1);
m_a1 = (((_local26 + _local22) * m_axis.y) - ((_local27 + _local23) * m_axis.x));
m_a2 = ((_local24 * m_axis.y) - (_local25 * m_axis.x));
_local34 = ((m_axis.x * _local26) + (m_axis.y * _local27));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
_local19 = b2Math.Clamp(_local34, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local16 = b2Math.Abs(_local34);
_local18 = true;
} else {
if (_local34 <= m_lowerTranslation){
_local19 = b2Math.Clamp(((_local34 - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local16 = (m_lowerTranslation - _local34);
_local18 = true;
} else {
if (_local34 >= m_upperTranslation){
_local19 = b2Math.Clamp(((_local34 - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local16 = (_local34 - m_upperTranslation);
_local18 = true;
};
};
};
};
m_perp = b2Math.MulMV(_local20, m_localYAxis1);
m_s1 = (((_local26 + _local22) * m_perp.y) - ((_local27 + _local23) * m_perp.x));
m_s2 = ((_local24 * m_perp.y) - (_local25 * m_perp.x));
var _local28:b2Vec2 = new b2Vec2();
var _local29:Number = ((m_perp.x * _local26) + (m_perp.y * _local27));
_local16 = b2Math.Max(_local16, b2Math.Abs(_local29));
_local17 = 0;
if (_local18){
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
m_K.col1.x = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
m_K.col1.y = (((_local14 * m_s1) * m_a1) + ((_local15 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (((_local12 + _local13) + ((_local14 * m_a1) * m_a1)) + ((_local15 * m_a2) * m_a2));
m_K.Solve(_local28, -(_local29), -(_local19));
} else {
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
_local35 = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
if (_local35 != 0){
_local36 = (-(_local29) / _local35);
} else {
_local36 = 0;
};
_local28.x = _local36;
_local28.y = 0;
};
var _local30:Number = ((_local28.x * m_perp.x) + (_local28.y * m_axis.x));
var _local31:Number = ((_local28.x * m_perp.y) + (_local28.y * m_axis.y));
var _local32:Number = ((_local28.x * m_s1) + (_local28.y * m_a1));
var _local33:Number = ((_local28.x * m_s2) + (_local28.y * m_a2));
_local6.x = (_local6.x - (m_invMassA * _local30));
_local6.y = (_local6.y - (m_invMassA * _local31));
_local7 = (_local7 - (m_invIA * _local32));
_local8.x = (_local8.x + (m_invMassB * _local30));
_local8.y = (_local8.y + (m_invMassB * _local31));
_local9 = (_local9 + (m_invIB * _local33));
_local4.m_sweep.a = _local7;
_local5.m_sweep.a = _local9;
_local4.SynchronizeTransform();
_local5.SynchronizeTransform();
return ((((_local16 <= b2Settings.b2_linearSlop)) && ((_local17 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
_local3 = _local1.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local7) + (_local3.col2.x * _local8));
_local8 = ((_local3.col1.y * _local7) + (_local3.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (_local1.m_sweep.c.x + _local4);
var _local10:Number = (_local1.m_sweep.c.y + _local5);
var _local11:Number = (_local2.m_sweep.c.x + _local7);
var _local12:Number = (_local2.m_sweep.c.y + _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local16:b2Vec2 = _local1.m_linearVelocity;
var _local17:b2Vec2 = _local2.m_linearVelocity;
var _local18:Number = _local1.m_angularVelocity;
var _local19:Number = _local2.m_angularVelocity;
var _local20:Number = (((_local13 * (-(_local18) * _local15.y)) + (_local14 * (_local18 * _local15.x))) + ((_local15.x * (((_local17.x + (-(_local19) * _local8)) - _local16.x) - (-(_local18) * _local5))) + (_local15.y * (((_local17.y + (_local19 * _local7)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
m_localCenterA.SetV(_local2.GetLocalCenter());
m_localCenterB.SetV(_local3.GetLocalCenter());
var _local6:b2Transform = _local2.GetTransform();
var _local7:b2Transform = _local3.GetTransform();
_local4 = _local2.m_xf.R;
var _local8:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local9:Number = (m_localAnchor1.y - m_localCenterA.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
_local4 = _local3.m_xf.R;
var _local10:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local11:Number = (m_localAnchor2.y - m_localCenterB.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
var _local12:Number = (((_local3.m_sweep.c.x + _local10) - _local2.m_sweep.c.x) - _local8);
var _local13:Number = (((_local3.m_sweep.c.y + _local11) - _local2.m_sweep.c.y) - _local9);
m_invMassA = _local2.m_invMass;
m_invMassB = _local3.m_invMass;
m_invIA = _local2.m_invI;
m_invIB = _local3.m_invI;
m_axis.SetV(b2Math.MulMV(_local6.R, m_localXAxis1));
m_a1 = (((_local12 + _local8) * m_axis.y) - ((_local13 + _local9) * m_axis.x));
m_a2 = ((_local10 * m_axis.y) - (_local11 * m_axis.x));
m_motorMass = (((m_invMassA + m_invMassB) + ((m_invIA * m_a1) * m_a1)) + ((m_invIB * m_a2) * m_a2));
m_motorMass = ((m_motorMass > Number.MIN_VALUE)) ? (1 / m_motorMass) : 0;
m_perp.SetV(b2Math.MulMV(_local6.R, m_localYAxis1));
m_s1 = (((_local12 + _local8) * m_perp.y) - ((_local13 + _local9) * m_perp.x));
m_s2 = ((_local10 * m_perp.y) - (_local11 * m_perp.x));
var _local14:Number = m_invMassA;
var _local15:Number = m_invMassB;
var _local16:Number = m_invIA;
var _local17:Number = m_invIB;
m_K.col1.x = (((_local14 + _local15) + ((_local16 * m_s1) * m_s1)) + ((_local17 * m_s2) * m_s2));
m_K.col1.y = (((_local16 * m_s1) * m_a1) + ((_local17 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (((_local14 + _local15) + ((_local16 * m_a1) * m_a1)) + ((_local17 * m_a2) * m_a2));
if (m_enableLimit){
_local18 = ((m_axis.x * _local12) + (m_axis.y * _local13));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local18 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitState = e_atLowerLimit;
m_impulse.y = 0;
};
} else {
if (_local18 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitState = e_atUpperLimit;
m_impulse.y = 0;
};
} else {
m_limitState = e_inactiveLimit;
m_impulse.y = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_motorImpulse = (m_motorImpulse * _arg1.dtRatio);
_local19 = ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.y) * m_axis.x));
_local20 = ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.y) * m_axis.y));
_local21 = ((m_impulse.x * m_s1) + ((m_motorImpulse + m_impulse.y) * m_a1));
_local22 = ((m_impulse.x * m_s2) + ((m_motorImpulse + m_impulse.y) * m_a2));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (m_invMassA * _local19));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (m_invMassA * _local20));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (m_invIA * _local21));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (m_invMassB * _local19));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (m_invMassB * _local20));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (m_invIB * _local22));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
public function SetMaxMotorForce(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_maxMotorForce = _arg1;
}
public function EnableLimit(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableLimit = _arg1;
}
public function GetMaxMotorForce():Number{
return (m_maxMotorForce);
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.y));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 127
//b2LineJointDef (Box2D.Dynamics.Joints.b2LineJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2LineJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var localAnchorB:b2Vec2;
public var upperTranslation:Number;
public var enableMotor:Boolean;
public var localAxisA:b2Vec2;
public var enableLimit:Boolean;
public var motorSpeed:Number;
public var maxMotorForce:Number;
public var lowerTranslation:Number;
public function b2LineJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
localAxisA = new b2Vec2();
super();
type = b2Joint.e_lineJoint;
localAxisA.Set(1, 0);
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA = bodyA.GetLocalPoint(_arg3);
localAnchorB = bodyB.GetLocalPoint(_arg3);
localAxisA = bodyA.GetLocalVector(_arg4);
}
}
}//package Box2D.Dynamics.Joints
Section 128
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2MouseJoint extends b2Joint {
private var K2:b2Mat22;
private var K1:b2Mat22;
private var m_beta:Number;
private var K:b2Mat22;
private var m_target:b2Vec2;
private var m_gamma:Number;
private var m_mass:b2Mat22;
private var m_impulse:b2Vec2;
private var m_localAnchor:b2Vec2;
private var m_C:b2Vec2;
private var m_maxForce:Number;
private var m_dampingRatio:Number;
private var m_frequencyHz:Number;
public function b2MouseJoint(_arg1:b2MouseJointDef){
var _local2:Number;
var _local4:b2Mat22;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_mass = new b2Mat22();
m_C = new b2Vec2();
super(_arg1);
m_target.SetV(_arg1.target);
_local2 = (m_target.x - m_bodyB.m_xf.position.x);
var _local3:Number = (m_target.y - m_bodyB.m_xf.position.y);
_local4 = m_bodyB.m_xf.R;
m_localAnchor.x = ((_local2 * _local4.col1.x) + (_local3 * _local4.col1.y));
m_localAnchor.y = ((_local2 * _local4.col2.x) + (_local3 * _local4.col2.y));
m_maxForce = _arg1.maxForce;
m_impulse.SetZero();
m_frequencyHz = _arg1.frequencyHz;
m_dampingRatio = _arg1.dampingRatio;
m_beta = 0;
m_gamma = 0;
}
public function SetFrequency(_arg1:Number):void{
m_frequencyHz = _arg1;
}
public function SetTarget(_arg1:b2Vec2):void{
if (m_bodyB.IsAwake() == false){
m_bodyB.SetAwake(true);
};
m_target = _arg1;
}
public function GetFrequency():Number{
return (m_frequencyHz);
}
public function SetMaxForce(_arg1:Number):void{
m_maxForce = _arg1;
}
public function SetDampingRatio(_arg1:Number):void{
m_dampingRatio = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local7:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local2:b2Body = m_bodyB;
var _local3:Number = _local2.GetMass();
var _local4:Number = ((2 * Math.PI) * m_frequencyHz);
var _local5:Number = (((2 * _local3) * m_dampingRatio) * _local4);
var _local6:Number = ((_local3 * _local4) * _local4);
m_gamma = (_arg1.dt * (_local5 + (_arg1.dt * _local6)));
m_gamma = ((m_gamma)!=0) ? (1 / m_gamma) : 0;
m_beta = ((_arg1.dt * _local6) * m_gamma);
_local7 = _local2.m_xf.R;
var _local8:Number = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
var _local10:Number = ((_local7.col1.x * _local8) + (_local7.col2.x * _local9));
_local9 = ((_local7.col1.y * _local8) + (_local7.col2.y * _local9));
_local8 = _local10;
_local11 = _local2.m_invMass;
_local12 = _local2.m_invI;
K1.col1.x = _local11;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = _local11;
K2.col1.x = ((_local12 * _local9) * _local9);
K2.col2.x = ((-(_local12) * _local8) * _local9);
K2.col1.y = ((-(_local12) * _local8) * _local9);
K2.col2.y = ((_local12 * _local8) * _local8);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.GetInverse(m_mass);
m_C.x = ((_local2.m_sweep.c.x + _local8) - m_target.x);
m_C.y = ((_local2.m_sweep.c.y + _local9) - m_target.y);
_local2.m_angularVelocity = (_local2.m_angularVelocity * 0.98);
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local11 * m_impulse.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local11 * m_impulse.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local12 * ((_local8 * m_impulse.y) - (_local9 * m_impulse.x))));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor));
}
override public function GetAnchorA():b2Vec2{
return (m_target);
}
public function GetTarget():b2Vec2{
return (m_target);
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
return (true);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local2:b2Body = m_bodyB;
_local3 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
_local4 = ((_local3.col1.x * _local6) + (_local3.col2.x * _local7));
_local7 = ((_local3.col1.y * _local6) + (_local3.col2.y * _local7));
_local6 = _local4;
var _local8:Number = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local7));
var _local9:Number = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local6));
_local3 = m_mass;
_local4 = ((_local8 + (m_beta * m_C.x)) + (m_gamma * m_impulse.x));
_local5 = ((_local9 + (m_beta * m_C.y)) + (m_gamma * m_impulse.y));
var _local10:Number = -(((_local3.col1.x * _local4) + (_local3.col2.x * _local5)));
var _local11:Number = -(((_local3.col1.y * _local4) + (_local3.col2.y * _local5)));
var _local12:Number = m_impulse.x;
var _local13:Number = m_impulse.y;
m_impulse.x = (m_impulse.x + _local10);
m_impulse.y = (m_impulse.y + _local11);
var _local14:Number = (_arg1.dt * m_maxForce);
if (m_impulse.LengthSquared() > (_local14 * _local14)){
m_impulse.Multiply((_local14 / m_impulse.Length()));
};
_local10 = (m_impulse.x - _local12);
_local11 = (m_impulse.y - _local13);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local10));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local11));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local6 * _local11) - (_local7 * _local10))));
}
public function GetMaxForce():Number{
return (m_maxForce);
}
public function GetDampingRatio():Number{
return (m_dampingRatio);
}
}
}//package Box2D.Dynamics.Joints
Section 129
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var target:b2Vec2;
public var maxForce:Number;
public var dampingRatio:Number;
public var frequencyHz:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
}
}
}//package Box2D.Dynamics.Joints
Section 130
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_perp:b2Vec2;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_refAngle:Number;
private var m_impulse:b2Vec3;
private var m_enableLimit:Boolean;
private var m_maxMotorForce:Number;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_axis:b2Vec2;
private var m_motorMass:Number;
private var m_s1:Number;
private var m_upperTranslation:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_motorImpulse:Number;
private var m_motorSpeed:Number;
private var m_enableMotor:Boolean;
private var m_K:b2Mat33;
public function b2PrismaticJoint(_arg1:b2PrismaticJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_axis = new b2Vec2();
m_perp = new b2Vec2();
m_K = new b2Mat33();
m_impulse = new b2Vec3();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_localXAxis1.SetV(_arg1.localAxisA);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_refAngle = _arg1.referenceAngle;
m_impulse.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.maxMotorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
m_limitState = e_inactiveLimit;
m_axis.SetZero();
m_perp.SetZero();
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:b2Vec3;
var _local20:b2Vec3;
var _local21:Number;
var _local22:Number;
var _local23:b2Vec2;
var _local24:b2Vec2;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local4:b2Vec2 = _local2.m_linearVelocity;
var _local5:Number = _local2.m_angularVelocity;
var _local6:b2Vec2 = _local3.m_linearVelocity;
var _local7:Number = _local3.m_angularVelocity;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local14 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local15 = (m_motorMass * (m_motorSpeed - _local14));
_local16 = m_motorImpulse;
_local17 = (_arg1.dt * m_maxMotorForce);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + _local15), -(_local17), _local17);
_local15 = (m_motorImpulse - _local16);
_local8 = (_local15 * m_axis.x);
_local9 = (_local15 * m_axis.y);
_local10 = (_local15 * m_a1);
_local11 = (_local15 * m_a2);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
var _local12:Number = ((((m_perp.x * (_local6.x - _local4.x)) + (m_perp.y * (_local6.y - _local4.y))) + (m_s2 * _local7)) - (m_s1 * _local5));
var _local13:Number = (_local7 - _local5);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local18 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local19 = m_impulse.Copy();
_local20 = m_K.Solve33(new b2Vec3(), -(_local12), -(_local13), -(_local18));
m_impulse.Add(_local20);
if (m_limitState == e_atLowerLimit){
m_impulse.z = b2Math.Max(m_impulse.z, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.z = b2Math.Min(m_impulse.z, 0);
};
};
_local21 = (-(_local12) - ((m_impulse.z - _local19.z) * m_K.col3.x));
_local22 = (-(_local13) - ((m_impulse.z - _local19.z) * m_K.col3.y));
_local23 = m_K.Solve22(new b2Vec2(), _local21, _local22);
m_K.Solve22(new b2Vec2(), _local21, _local22).x = (_local23.x + _local19.x);
_local23.y = (_local23.y + _local19.y);
m_impulse.x = _local23.x;
m_impulse.y = _local23.y;
_local20.x = (m_impulse.x - _local19.x);
_local20.y = (m_impulse.y - _local19.y);
_local20.z = (m_impulse.z - _local19.z);
_local8 = ((_local20.x * m_perp.x) + (_local20.z * m_axis.x));
_local9 = ((_local20.x * m_perp.y) + (_local20.z * m_axis.y));
_local10 = (((_local20.x * m_s1) + _local20.y) + (_local20.z * m_a1));
_local11 = (((_local20.x * m_s2) + _local20.y) + (_local20.z * m_a2));
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
} else {
_local24 = m_K.Solve22(new b2Vec2(), -(_local12), -(_local13));
m_impulse.x = (m_impulse.x + _local24.x);
m_impulse.y = (m_impulse.y + _local24.y);
_local8 = (_local24.x * m_perp.x);
_local9 = (_local24.x * m_perp.y);
_local10 = ((_local24.x * m_s1) + _local24.y);
_local11 = ((_local24.x * m_s2) + _local24.y);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
_local2.m_linearVelocity.SetV(_local4);
_local2.m_angularVelocity = _local5;
_local3.m_linearVelocity.SetV(_local6);
_local3.m_angularVelocity = _local7;
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableMotor = _arg1;
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function GetJointTranslation():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
var _local4:b2Vec2 = _local1.GetWorldPoint(m_localAnchor1);
var _local5:b2Vec2 = _local2.GetWorldPoint(m_localAnchor2);
var _local6:Number = (_local5.x - _local4.x);
var _local7:Number = (_local5.y - _local4.y);
var _local8:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local9:Number = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x))), (_arg1 * ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y)))));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:b2Vec2;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_sweep.c;
var _local7:Number = _local4.m_sweep.a;
var _local8:b2Vec2 = _local5.m_sweep.c;
var _local9:Number = _local5.m_sweep.a;
var _local16:Number = 0;
var _local17:Number = 0;
var _local18:Boolean;
var _local19:Number = 0;
var _local20:b2Mat22 = b2Mat22.FromAngle(_local7);
var _local21:b2Mat22 = b2Mat22.FromAngle(_local9);
_local10 = _local20;
var _local22:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local23:Number = (m_localAnchor1.y - m_localCenterA.y);
_local11 = ((_local10.col1.x * _local22) + (_local10.col2.x * _local23));
_local23 = ((_local10.col1.y * _local22) + (_local10.col2.y * _local23));
_local22 = _local11;
_local10 = _local21;
var _local24:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local25:Number = (m_localAnchor2.y - m_localCenterB.y);
_local11 = ((_local10.col1.x * _local24) + (_local10.col2.x * _local25));
_local25 = ((_local10.col1.y * _local24) + (_local10.col2.y * _local25));
_local24 = _local11;
var _local26:Number = (((_local8.x + _local24) - _local6.x) - _local22);
var _local27:Number = (((_local8.y + _local25) - _local6.y) - _local23);
if (m_enableLimit){
m_axis = b2Math.MulMV(_local20, m_localXAxis1);
m_a1 = (((_local26 + _local22) * m_axis.y) - ((_local27 + _local23) * m_axis.x));
m_a2 = ((_local24 * m_axis.y) - (_local25 * m_axis.x));
_local35 = ((m_axis.x * _local26) + (m_axis.y * _local27));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
_local19 = b2Math.Clamp(_local35, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local16 = b2Math.Abs(_local35);
_local18 = true;
} else {
if (_local35 <= m_lowerTranslation){
_local19 = b2Math.Clamp(((_local35 - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local16 = (m_lowerTranslation - _local35);
_local18 = true;
} else {
if (_local35 >= m_upperTranslation){
_local19 = b2Math.Clamp(((_local35 - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local16 = (_local35 - m_upperTranslation);
_local18 = true;
};
};
};
};
m_perp = b2Math.MulMV(_local20, m_localYAxis1);
m_s1 = (((_local26 + _local22) * m_perp.y) - ((_local27 + _local23) * m_perp.x));
m_s2 = ((_local24 * m_perp.y) - (_local25 * m_perp.x));
var _local28:b2Vec3 = new b2Vec3();
var _local29:Number = ((m_perp.x * _local26) + (m_perp.y * _local27));
var _local30:Number = ((_local9 - _local7) - m_refAngle);
_local16 = b2Math.Max(_local16, b2Math.Abs(_local29));
_local17 = b2Math.Abs(_local30);
if (_local18){
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
m_K.col1.x = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
m_K.col1.y = ((_local14 * m_s1) + (_local15 * m_s2));
m_K.col1.z = (((_local14 * m_s1) * m_a1) + ((_local15 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (_local14 + _local15);
m_K.col2.z = ((_local14 * m_a1) + (_local15 * m_a2));
m_K.col3.x = m_K.col1.z;
m_K.col3.y = m_K.col2.z;
m_K.col3.z = (((_local12 + _local13) + ((_local14 * m_a1) * m_a1)) + ((_local15 * m_a2) * m_a2));
m_K.Solve33(_local28, -(_local29), -(_local30), -(_local19));
} else {
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
_local36 = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
_local37 = ((_local14 * m_s1) + (_local15 * m_s2));
_local38 = (_local14 + _local15);
m_K.col1.Set(_local36, _local37, 0);
m_K.col2.Set(_local37, _local38, 0);
_local39 = m_K.Solve22(new b2Vec2(), -(_local29), -(_local30));
_local28.x = _local39.x;
_local28.y = _local39.y;
_local28.z = 0;
};
var _local31:Number = ((_local28.x * m_perp.x) + (_local28.z * m_axis.x));
var _local32:Number = ((_local28.x * m_perp.y) + (_local28.z * m_axis.y));
var _local33:Number = (((_local28.x * m_s1) + _local28.y) + (_local28.z * m_a1));
var _local34:Number = (((_local28.x * m_s2) + _local28.y) + (_local28.z * m_a2));
_local6.x = (_local6.x - (m_invMassA * _local31));
_local6.y = (_local6.y - (m_invMassA * _local32));
_local7 = (_local7 - (m_invIA * _local33));
_local8.x = (_local8.x + (m_invMassB * _local31));
_local8.y = (_local8.y + (m_invMassB * _local32));
_local9 = (_local9 + (m_invIB * _local34));
_local4.m_sweep.a = _local7;
_local5.m_sweep.a = _local9;
_local4.SynchronizeTransform();
_local5.SynchronizeTransform();
return ((((_local16 <= b2Settings.b2_linearSlop)) && ((_local17 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
_local3 = _local1.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local7) + (_local3.col2.x * _local8));
_local8 = ((_local3.col1.y * _local7) + (_local3.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (_local1.m_sweep.c.x + _local4);
var _local10:Number = (_local1.m_sweep.c.y + _local5);
var _local11:Number = (_local2.m_sweep.c.x + _local7);
var _local12:Number = (_local2.m_sweep.c.y + _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local16:b2Vec2 = _local1.m_linearVelocity;
var _local17:b2Vec2 = _local2.m_linearVelocity;
var _local18:Number = _local1.m_angularVelocity;
var _local19:Number = _local2.m_angularVelocity;
var _local20:Number = (((_local13 * (-(_local18) * _local15.y)) + (_local14 * (_local18 * _local15.x))) + ((_local15.x * (((_local17.x + (-(_local19) * _local8)) - _local16.x) - (-(_local18) * _local5))) + (_local15.y * (((_local17.y + (_local19 * _local7)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
m_localCenterA.SetV(_local2.GetLocalCenter());
m_localCenterB.SetV(_local3.GetLocalCenter());
var _local6:b2Transform = _local2.GetTransform();
var _local7:b2Transform = _local3.GetTransform();
_local4 = _local2.m_xf.R;
var _local8:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local9:Number = (m_localAnchor1.y - m_localCenterA.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
_local4 = _local3.m_xf.R;
var _local10:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local11:Number = (m_localAnchor2.y - m_localCenterB.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
var _local12:Number = (((_local3.m_sweep.c.x + _local10) - _local2.m_sweep.c.x) - _local8);
var _local13:Number = (((_local3.m_sweep.c.y + _local11) - _local2.m_sweep.c.y) - _local9);
m_invMassA = _local2.m_invMass;
m_invMassB = _local3.m_invMass;
m_invIA = _local2.m_invI;
m_invIB = _local3.m_invI;
m_axis.SetV(b2Math.MulMV(_local6.R, m_localXAxis1));
m_a1 = (((_local12 + _local8) * m_axis.y) - ((_local13 + _local9) * m_axis.x));
m_a2 = ((_local10 * m_axis.y) - (_local11 * m_axis.x));
m_motorMass = (((m_invMassA + m_invMassB) + ((m_invIA * m_a1) * m_a1)) + ((m_invIB * m_a2) * m_a2));
if (m_motorMass > Number.MIN_VALUE){
m_motorMass = (1 / m_motorMass);
};
m_perp.SetV(b2Math.MulMV(_local6.R, m_localYAxis1));
m_s1 = (((_local12 + _local8) * m_perp.y) - ((_local13 + _local9) * m_perp.x));
m_s2 = ((_local10 * m_perp.y) - (_local11 * m_perp.x));
var _local14:Number = m_invMassA;
var _local15:Number = m_invMassB;
var _local16:Number = m_invIA;
var _local17:Number = m_invIB;
m_K.col1.x = (((_local14 + _local15) + ((_local16 * m_s1) * m_s1)) + ((_local17 * m_s2) * m_s2));
m_K.col1.y = ((_local16 * m_s1) + (_local17 * m_s2));
m_K.col1.z = (((_local16 * m_s1) * m_a1) + ((_local17 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (_local16 + _local17);
m_K.col2.z = ((_local16 * m_a1) + (_local17 * m_a2));
m_K.col3.x = m_K.col1.z;
m_K.col3.y = m_K.col2.z;
m_K.col3.z = (((_local14 + _local15) + ((_local16 * m_a1) * m_a1)) + ((_local17 * m_a2) * m_a2));
if (m_enableLimit){
_local18 = ((m_axis.x * _local12) + (m_axis.y * _local13));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local18 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitState = e_atLowerLimit;
m_impulse.z = 0;
};
} else {
if (_local18 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitState = e_atUpperLimit;
m_impulse.z = 0;
};
} else {
m_limitState = e_inactiveLimit;
m_impulse.z = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_motorImpulse = (m_motorImpulse * _arg1.dtRatio);
_local19 = ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x));
_local20 = ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y));
_local21 = (((m_impulse.x * m_s1) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a1));
_local22 = (((m_impulse.x * m_s2) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a2));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (m_invMassA * _local19));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (m_invMassA * _local20));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (m_invIA * _local21));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (m_invMassB * _local19));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (m_invMassB * _local20));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (m_invIB * _local22));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
public function SetMaxMotorForce(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_maxMotorForce = _arg1;
}
public function EnableLimit(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableLimit = _arg1;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.y));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 131
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PrismaticJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var motorSpeed:Number;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public var upperTranslation:Number;
public var lowerTranslation:Number;
public var localAxisA:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorForce:Number;
public function b2PrismaticJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
localAxisA = new b2Vec2();
super();
type = b2Joint.e_prismaticJoint;
localAxisA.Set(1, 0);
referenceAngle = 0;
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA = bodyA.GetLocalPoint(_arg3);
localAnchorB = bodyB.GetLocalPoint(_arg3);
localAxisA = bodyA.GetLocalVector(_arg4);
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 132
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
private var m_limitState1:int;
private var m_limitState2:int;
private var m_ground:b2Body;
private var m_maxLength2:Number;
private var m_maxLength1:Number;
private var m_impulse:Number;
private var m_constant:Number;
private var m_state:int;
private var m_ratio:Number;
private var m_groundAnchor1:b2Vec2;
private var m_groundAnchor2:b2Vec2;
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_limitMass1:Number;
private var m_limitMass2:Number;
private var m_pulleyMass:Number;
private var m_limitImpulse1:Number;
private var m_limitImpulse2:Number;
private var m_u1:b2Vec2;
private var m_u2:b2Vec2;
b2internal static const b2_minPulleyLength:Number = 2;
public function b2PulleyJoint(_arg1:b2PulleyJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u1 = new b2Vec2();
m_u2 = new b2Vec2();
super(_arg1);
m_ground = m_bodyA.m_world.m_groundBody;
m_groundAnchor1.x = (_arg1.groundAnchorA.x - m_ground.m_xf.position.x);
m_groundAnchor1.y = (_arg1.groundAnchorA.y - m_ground.m_xf.position.y);
m_groundAnchor2.x = (_arg1.groundAnchorB.x - m_ground.m_xf.position.x);
m_groundAnchor2.y = (_arg1.groundAnchorB.y - m_ground.m_xf.position.y);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_ratio = _arg1.ratio;
m_constant = (_arg1.lengthA + (m_ratio * _arg1.lengthB));
m_maxLength1 = b2Math.Min(_arg1.maxLengthA, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.Min(_arg1.maxLengthB, ((m_constant - b2_minPulleyLength) / m_ratio));
m_impulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
}
public function GetGroundAnchorB():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor2);
return (_local1);
}
public function GetGroundAnchorA():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor1);
return (_local1);
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2(((_arg1 * m_impulse) * m_u2.x), ((_arg1 * m_impulse) * m_u2.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local4:b2Mat22;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local5:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local6:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local7:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local8:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local24:Number = 0;
if (m_state == e_atUpperLimit){
_local4 = _local2.m_xf.R;
_local9 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local10 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local23;
_local4 = _local3.m_xf.R;
_local11 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local12 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local11) + (_local4.col2.x * _local12));
_local12 = ((_local4.col1.y * _local11) + (_local4.col2.y * _local12));
_local11 = _local23;
_local13 = (_local2.m_sweep.c.x + _local9);
_local14 = (_local2.m_sweep.c.y + _local10);
_local15 = (_local3.m_sweep.c.x + _local11);
_local16 = (_local3.m_sweep.c.y + _local12);
m_u1.Set((_local13 - _local5), (_local14 - _local6));
m_u2.Set((_local15 - _local7), (_local16 - _local8));
_local17 = m_u1.Length();
_local18 = m_u2.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local17));
} else {
m_u1.SetZero();
};
if (_local18 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local18));
} else {
m_u2.SetZero();
};
_local19 = ((m_constant - _local17) - (m_ratio * _local18));
_local24 = b2Math.Max(_local24, -(_local19));
_local19 = b2Math.Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local20 = (-(m_pulleyMass) * _local19);
_local13 = (-(_local20) * m_u1.x);
_local14 = (-(_local20) * m_u1.y);
_local15 = ((-(m_ratio) * _local20) * m_u2.x);
_local16 = ((-(m_ratio) * _local20) * m_u2.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local13));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local14));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local9 * _local14) - (_local10 * _local13))));
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local15));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local16));
_local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local11 * _local16) - (_local12 * _local15))));
_local2.SynchronizeTransform();
_local3.SynchronizeTransform();
};
if (m_limitState1 == e_atUpperLimit){
_local4 = _local2.m_xf.R;
_local9 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local10 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local23;
_local13 = (_local2.m_sweep.c.x + _local9);
_local14 = (_local2.m_sweep.c.y + _local10);
m_u1.Set((_local13 - _local5), (_local14 - _local6));
_local17 = m_u1.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / _local17));
m_u1.y = (m_u1.y * (1 / _local17));
} else {
m_u1.SetZero();
};
_local19 = (m_maxLength1 - _local17);
_local24 = b2Math.Max(_local24, -(_local19));
_local19 = b2Math.Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local20 = (-(m_limitMass1) * _local19);
_local13 = (-(_local20) * m_u1.x);
_local14 = (-(_local20) * m_u1.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local13));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local14));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local9 * _local14) - (_local10 * _local13))));
_local2.SynchronizeTransform();
};
if (m_limitState2 == e_atUpperLimit){
_local4 = _local3.m_xf.R;
_local11 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local12 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local11) + (_local4.col2.x * _local12));
_local12 = ((_local4.col1.y * _local11) + (_local4.col2.y * _local12));
_local11 = _local23;
_local15 = (_local3.m_sweep.c.x + _local11);
_local16 = (_local3.m_sweep.c.y + _local12);
m_u2.Set((_local15 - _local7), (_local16 - _local8));
_local18 = m_u2.Length();
if (_local18 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / _local18));
m_u2.y = (m_u2.y * (1 / _local18));
} else {
m_u2.SetZero();
};
_local19 = (m_maxLength2 - _local18);
_local24 = b2Math.Max(_local24, -(_local19));
_local19 = b2Math.Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local20 = (-(m_limitMass2) * _local19);
_local15 = (-(_local20) * m_u2.x);
_local16 = (-(_local20) * m_u2.y);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local15));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local16));
_local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local11 * _local16) - (_local12 * _local15))));
_local3.SynchronizeTransform();
};
return ((_local24 < b2Settings.b2_linearSlop));
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local6:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local2 = m_bodyA;
_local3 = m_bodyB;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local6 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local2.m_sweep.c.x + _local5);
var _local11:Number = (_local2.m_sweep.c.y + _local6);
var _local12:Number = (_local3.m_sweep.c.x + _local8);
var _local13:Number = (_local3.m_sweep.c.y + _local9);
var _local14:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local15:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local16:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local17:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
m_u1.Set((_local10 - _local14), (_local11 - _local15));
m_u2.Set((_local12 - _local16), (_local13 - _local17));
var _local18:Number = m_u1.Length();
var _local19:Number = m_u2.Length();
if (_local18 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local18));
} else {
m_u1.SetZero();
};
if (_local19 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local19));
} else {
m_u2.SetZero();
};
var _local20:Number = ((m_constant - _local18) - (m_ratio * _local19));
if (_local20 > 0){
m_state = e_inactiveLimit;
m_impulse = 0;
} else {
m_state = e_atUpperLimit;
};
if (_local18 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitImpulse1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
};
if (_local19 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitImpulse2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
};
var _local21:Number = ((_local5 * m_u1.y) - (_local6 * m_u1.x));
var _local22:Number = ((_local8 * m_u2.y) - (_local9 * m_u2.x));
m_limitMass1 = (_local2.m_invMass + ((_local2.m_invI * _local21) * _local21));
m_limitMass2 = (_local3.m_invMass + ((_local3.m_invI * _local22) * _local22));
m_pulleyMass = (m_limitMass1 + ((m_ratio * m_ratio) * m_limitMass2));
m_limitMass1 = (1 / m_limitMass1);
m_limitMass2 = (1 / m_limitMass2);
m_pulleyMass = (1 / m_pulleyMass);
if (_arg1.warmStarting){
m_impulse = (m_impulse * _arg1.dtRatio);
m_limitImpulse1 = (m_limitImpulse1 * _arg1.dtRatio);
m_limitImpulse2 = (m_limitImpulse2 * _arg1.dtRatio);
_local23 = ((-(m_impulse) - m_limitImpulse1) * m_u1.x);
_local24 = ((-(m_impulse) - m_limitImpulse1) * m_u1.y);
_local25 = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.x);
_local26 = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local24) - (_local6 * _local23))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local25));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local26));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local26) - (_local9 * _local25))));
} else {
m_impulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
};
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
public function GetLength2():Number{
var _local1:b2Vec2 = m_bodyB.GetWorldPoint(m_localAnchor2);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
if (m_state == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = (-(((m_u1.x * _local10) + (m_u1.y * _local11))) - (m_ratio * ((m_u2.x * _local12) + (m_u2.y * _local13))));
_local19 = (m_pulleyMass * -(_local18));
_local20 = m_impulse;
m_impulse = b2Math.Max(0, (m_impulse + _local19));
_local19 = (m_impulse - _local20);
_local14 = (-(_local19) * m_u1.x);
_local15 = (-(_local19) * m_u1.y);
_local16 = ((-(m_ratio) * _local19) * m_u2.x);
_local17 = ((-(m_ratio) * _local19) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
if (m_limitState1 == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local18 = -(((m_u1.x * _local10) + (m_u1.y * _local11)));
_local19 = (-(m_limitMass1) * _local18);
_local20 = m_limitImpulse1;
m_limitImpulse1 = b2Math.Max(0, (m_limitImpulse1 + _local19));
_local19 = (m_limitImpulse1 - _local20);
_local14 = (-(_local19) * m_u1.x);
_local15 = (-(_local19) * m_u1.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
};
if (m_limitState2 == e_atUpperLimit){
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = -(((m_u2.x * _local12) + (m_u2.y * _local13)));
_local19 = (-(m_limitMass2) * _local18);
_local20 = m_limitImpulse2;
m_limitImpulse2 = b2Math.Max(0, (m_limitImpulse2 + _local19));
_local19 = (m_limitImpulse2 - _local20);
_local16 = (-(_local19) * m_u2.x);
_local17 = (-(_local19) * m_u2.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
}
public function GetLength1():Number{
var _local1:b2Vec2 = m_bodyA.GetWorldPoint(m_localAnchor1);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
}
}//package Box2D.Dynamics.Joints
Section 133
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PulleyJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var groundAnchorA:b2Vec2;
public var groundAnchorB:b2Vec2;
public var localAnchorB:b2Vec2;
public var ratio:Number;
public var maxLengthA:Number;
public var lengthA:Number;
public var lengthB:Number;
public var maxLengthB:Number;
public function b2PulleyJointDef(){
groundAnchorA = new b2Vec2();
groundAnchorB = new b2Vec2();
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundAnchorA.Set(-1, 1);
groundAnchorB.Set(1, 1);
localAnchorA.Set(-1, 0);
localAnchorB.Set(1, 0);
lengthA = 0;
maxLengthA = 0;
lengthB = 0;
maxLengthB = 0;
ratio = 1;
collideConnected = true;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2, _arg6:b2Vec2, _arg7:Number):void{
bodyA = _arg1;
bodyB = _arg2;
groundAnchorA.SetV(_arg3);
groundAnchorB.SetV(_arg4);
localAnchorA = bodyA.GetLocalPoint(_arg5);
localAnchorB = bodyB.GetLocalPoint(_arg6);
var _local8:Number = (_arg5.x - _arg3.x);
var _local9:Number = (_arg5.y - _arg3.y);
lengthA = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
var _local10:Number = (_arg6.x - _arg4.x);
var _local11:Number = (_arg6.y - _arg4.y);
lengthB = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
ratio = _arg7;
var _local12:Number = (lengthA + (ratio * lengthB));
maxLengthA = (_local12 - (ratio * b2PulleyJoint.b2_minPulleyLength));
maxLengthB = ((_local12 - b2PulleyJoint.b2_minPulleyLength) / ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 134
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
private var m_mass:b2Mat33;
private var m_impulse:b2Vec3;
private var m_enableLimit:Boolean;
private var m_limitState:int;
private var m_motorMass:Number;
private var reduced:b2Vec2;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
private var m_motorImpulse:Number;
private var impulse2:b2Vec2;
private var impulse3:b2Vec3;
private var m_enableMotor:Boolean;
private var m_referenceAngle:Number;
private var m_upperAngle:Number;
private var m_motorSpeed:Number;
private var m_lowerAngle:Number;
private var m_maxMotorTorque:Number;
private static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(_arg1:b2RevoluteJointDef){
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
impulse3 = new b2Vec3();
impulse2 = new b2Vec2();
reduced = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_impulse = new b2Vec3();
m_mass = new b2Mat33();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_referenceAngle = _arg1.referenceAngle;
m_impulse.SetZero();
m_motorImpulse = 0;
m_lowerAngle = _arg1.lowerAngle;
m_upperAngle = _arg1.upperAngle;
m_maxMotorTorque = _arg1.maxMotorTorque;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
m_limitState = e_inactiveLimit;
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local11:b2Vec2 = _local2.m_linearVelocity;
var _local12:Number = _local2.m_angularVelocity;
var _local13:b2Vec2 = _local3.m_linearVelocity;
var _local14:Number = _local3.m_angularVelocity;
var _local15:Number = _local2.m_invMass;
var _local16:Number = _local3.m_invMass;
var _local17:Number = _local2.m_invI;
var _local18:Number = _local3.m_invI;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local19 = ((_local14 - _local12) - m_motorSpeed);
_local20 = (m_motorMass * -(_local19));
_local21 = m_motorImpulse;
_local22 = (_arg1.dt * m_maxMotorTorque);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + _local20), -(_local22), _local22);
_local20 = (m_motorImpulse - _local21);
_local12 = (_local12 - (_local17 * _local20));
_local14 = (_local14 + (_local18 * _local20));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local4 = _local2.m_xf.R;
_local7 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local8 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local7) + (_local4.col2.x * _local8));
_local8 = ((_local4.col1.y * _local7) + (_local4.col2.y * _local8));
_local7 = _local5;
_local4 = _local3.m_xf.R;
_local9 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local10 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local5;
_local23 = (((_local13.x + (-(_local14) * _local10)) - _local11.x) - (-(_local12) * _local8));
_local24 = (((_local13.y + (_local14 * _local9)) - _local11.y) - (_local12 * _local7));
_local25 = (_local14 - _local12);
m_mass.Solve33(impulse3, -(_local23), -(_local24), -(_local25));
if (m_limitState == e_equalLimits){
m_impulse.Add(impulse3);
} else {
if (m_limitState == e_atLowerLimit){
_local6 = (m_impulse.z + impulse3.z);
if (_local6 < 0){
m_mass.Solve22(reduced, -(_local23), -(_local24));
impulse3.x = reduced.x;
impulse3.y = reduced.y;
impulse3.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + reduced.x);
m_impulse.y = (m_impulse.y + reduced.y);
m_impulse.z = 0;
};
} else {
if (m_limitState == e_atUpperLimit){
_local6 = (m_impulse.z + impulse3.z);
if (_local6 > 0){
m_mass.Solve22(reduced, -(_local23), -(_local24));
impulse3.x = reduced.x;
impulse3.y = reduced.y;
impulse3.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + reduced.x);
m_impulse.y = (m_impulse.y + reduced.y);
m_impulse.z = 0;
};
};
};
};
_local11.x = (_local11.x - (_local15 * impulse3.x));
_local11.y = (_local11.y - (_local15 * impulse3.y));
_local12 = (_local12 - (_local17 * (((_local7 * impulse3.y) - (_local8 * impulse3.x)) + impulse3.z)));
_local13.x = (_local13.x + (_local16 * impulse3.x));
_local13.y = (_local13.y + (_local16 * impulse3.y));
_local14 = (_local14 + (_local18 * (((_local9 * impulse3.y) - (_local10 * impulse3.x)) + impulse3.z)));
} else {
_local4 = _local2.m_xf.R;
_local7 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local8 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local7) + (_local4.col2.x * _local8));
_local8 = ((_local4.col1.y * _local7) + (_local4.col2.y * _local8));
_local7 = _local5;
_local4 = _local3.m_xf.R;
_local9 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local10 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local5;
_local26 = (((_local13.x + (-(_local14) * _local10)) - _local11.x) - (-(_local12) * _local8));
_local27 = (((_local13.y + (_local14 * _local9)) - _local11.y) - (_local12 * _local7));
m_mass.Solve22(impulse2, -(_local26), -(_local27));
m_impulse.x = (m_impulse.x + impulse2.x);
m_impulse.y = (m_impulse.y + impulse2.y);
_local11.x = (_local11.x - (_local15 * impulse2.x));
_local11.y = (_local11.y - (_local15 * impulse2.y));
_local12 = (_local12 - (_local17 * ((_local7 * impulse2.y) - (_local8 * impulse2.x))));
_local13.x = (_local13.x + (_local16 * impulse2.x));
_local13.y = (_local13.y + (_local16 * impulse2.y));
_local14 = (_local14 + (_local18 * ((_local9 * impulse2.y) - (_local10 * impulse2.x))));
};
_local2.m_linearVelocity.SetV(_local11);
_local2.m_angularVelocity = _local12;
_local3.m_linearVelocity.SetV(_local13);
_local3.m_angularVelocity = _local14;
}
public function GetUpperLimit():Number{
return (m_upperAngle);
}
public function GetLowerLimit():Number{
return (m_lowerAngle);
}
public function EnableMotor(_arg1:Boolean):void{
m_enableMotor = _arg1;
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:b2Mat22;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local5:b2Body = m_bodyA;
var _local6:b2Body = m_bodyB;
var _local7:Number = 0;
var _local8:Number = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local25 = ((_local6.m_sweep.a - _local5.m_sweep.a) - m_referenceAngle);
_local26 = 0;
if (m_limitState == e_equalLimits){
_local3 = b2Math.Clamp((_local25 - m_lowerAngle), -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local3);
_local7 = b2Math.Abs(_local3);
} else {
if (m_limitState == e_atLowerLimit){
_local3 = (_local25 - m_lowerAngle);
_local7 = -(_local3);
_local3 = b2Math.Clamp((_local3 + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
_local26 = (-(m_motorMass) * _local3);
} else {
if (m_limitState == e_atUpperLimit){
_local3 = (_local25 - m_upperAngle);
_local7 = _local3;
_local3 = b2Math.Clamp((_local3 - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local3);
};
};
};
_local5.m_sweep.a = (_local5.m_sweep.a - (_local5.m_invI * _local26));
_local6.m_sweep.a = (_local6.m_sweep.a + (_local6.m_invI * _local26));
_local5.SynchronizeTransform();
_local6.SynchronizeTransform();
};
_local4 = _local5.m_xf.R;
var _local12:Number = (m_localAnchor1.x - _local5.m_sweep.localCenter.x);
var _local13:Number = (m_localAnchor1.y - _local5.m_sweep.localCenter.y);
_local9 = ((_local4.col1.x * _local12) + (_local4.col2.x * _local13));
_local13 = ((_local4.col1.y * _local12) + (_local4.col2.y * _local13));
_local12 = _local9;
_local4 = _local6.m_xf.R;
var _local14:Number = (m_localAnchor2.x - _local6.m_sweep.localCenter.x);
var _local15:Number = (m_localAnchor2.y - _local6.m_sweep.localCenter.y);
_local9 = ((_local4.col1.x * _local14) + (_local4.col2.x * _local15));
_local15 = ((_local4.col1.y * _local14) + (_local4.col2.y * _local15));
_local14 = _local9;
var _local16:Number = (((_local6.m_sweep.c.x + _local14) - _local5.m_sweep.c.x) - _local12);
var _local17:Number = (((_local6.m_sweep.c.y + _local15) - _local5.m_sweep.c.y) - _local13);
var _local18:Number = ((_local16 * _local16) + (_local17 * _local17));
var _local19:Number = Math.sqrt(_local18);
_local8 = _local19;
var _local20:Number = _local5.m_invMass;
var _local21:Number = _local6.m_invMass;
var _local22:Number = _local5.m_invI;
var _local23:Number = _local6.m_invI;
var _local24:Number = (10 * b2Settings.b2_linearSlop);
if (_local18 > (_local24 * _local24)){
_local27 = (_local16 / _local19);
_local28 = (_local17 / _local19);
_local29 = (_local20 + _local21);
_local30 = (1 / _local29);
_local10 = (_local30 * -(_local16));
_local11 = (_local30 * -(_local17));
_local31 = 0.5;
_local5.m_sweep.c.x = (_local5.m_sweep.c.x - ((_local31 * _local20) * _local10));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y - ((_local31 * _local20) * _local11));
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + ((_local31 * _local21) * _local10));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + ((_local31 * _local21) * _local11));
_local16 = (((_local6.m_sweep.c.x + _local14) - _local5.m_sweep.c.x) - _local12);
_local17 = (((_local6.m_sweep.c.y + _local15) - _local5.m_sweep.c.y) - _local13);
};
K1.col1.x = (_local20 + _local21);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local20 + _local21);
K2.col1.x = ((_local22 * _local13) * _local13);
K2.col2.x = ((-(_local22) * _local12) * _local13);
K2.col1.y = ((-(_local22) * _local12) * _local13);
K2.col2.y = ((_local22 * _local12) * _local12);
K3.col1.x = ((_local23 * _local15) * _local15);
K3.col2.x = ((-(_local23) * _local14) * _local15);
K3.col1.y = ((-(_local23) * _local14) * _local15);
K3.col2.y = ((_local23 * _local14) * _local14);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(_local16), -(_local17));
_local10 = tImpulse.x;
_local11 = tImpulse.y;
_local5.m_sweep.c.x = (_local5.m_sweep.c.x - (_local5.m_invMass * _local10));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y - (_local5.m_invMass * _local11));
_local5.m_sweep.a = (_local5.m_sweep.a - (_local5.m_invI * ((_local12 * _local11) - (_local13 * _local10))));
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_local6.m_invMass * _local10));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_local6.m_invMass * _local11));
_local6.m_sweep.a = (_local6.m_sweep.a + (_local6.m_invI * ((_local14 * _local11) - (_local15 * _local10))));
_local5.SynchronizeTransform();
_local6.SynchronizeTransform();
return ((((_local8 <= b2Settings.b2_linearSlop)) && ((_local7 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = _arg1;
}
public function SetMaxMotorTorque(_arg1:Number):void{
m_maxMotorTorque = _arg1;
}
public function GetJointAngle():Number{
return (((m_bodyB.m_sweep.a - m_bodyA.m_sweep.a) - m_referenceAngle));
}
public function GetJointSpeed():Number{
return ((m_bodyB.m_angularVelocity - m_bodyA.m_angularVelocity));
}
public function GetMotorTorque():Number{
return (m_maxMotorTorque);
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local7:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local2 = m_bodyA;
_local3 = m_bodyB;
if (((m_enableMotor) || (m_enableLimit))){
};
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local7 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local10:Number = _local2.m_invMass;
var _local11:Number = _local3.m_invMass;
var _local12:Number = _local2.m_invI;
var _local13:Number = _local3.m_invI;
m_mass.col1.x = (((_local10 + _local11) + ((_local7 * _local7) * _local12)) + ((_local9 * _local9) * _local13));
m_mass.col2.x = (((-(_local7) * _local6) * _local12) - ((_local9 * _local8) * _local13));
m_mass.col3.x = ((-(_local7) * _local12) - (_local9 * _local13));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((_local10 + _local11) + ((_local6 * _local6) * _local12)) + ((_local8 * _local8) * _local13));
m_mass.col3.y = ((_local6 * _local12) + (_local8 * _local13));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (_local12 + _local13);
m_motorMass = (1 / (_local12 + _local13));
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit){
_local14 = ((_local3.m_sweep.a - _local2.m_sweep.a) - m_referenceAngle);
if (b2Math.Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (_local14 <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_impulse.z = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local14 >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_impulse.z = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_impulse.z = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_motorImpulse = (m_motorImpulse * _arg1.dtRatio);
_local15 = m_impulse.x;
_local16 = m_impulse.y;
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (_local10 * _local15));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (_local10 * _local16));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local12 * ((((_local6 * _local16) - (_local7 * _local15)) + m_motorImpulse) + m_impulse.z)));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local11 * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local11 * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local13 * ((((_local8 * _local16) - (_local9 * _local15)) + m_motorImpulse) + m_impulse.z)));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function EnableLimit(_arg1:Boolean):void{
m_enableLimit = _arg1;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.z));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_lowerAngle = _arg1;
m_upperAngle = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 135
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2RevoluteJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public var motorSpeed:Number;
public var upperAngle:Number;
public var lowerAngle:Number;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorTorque:Number;
public function b2RevoluteJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_revoluteJoint;
localAnchorA.Set(0, 0);
localAnchorB.Set(0, 0);
referenceAngle = 0;
lowerAngle = 0;
upperAngle = 0;
maxMotorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA = bodyA.GetLocalPoint(_arg3);
localAnchorB = bodyB.GetLocalPoint(_arg3);
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 136
//b2WeldJoint (Box2D.Dynamics.Joints.b2WeldJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2WeldJoint extends b2Joint {
private var m_impulse:b2Vec3;
private var m_referenceAngle:Number;
private var m_localAnchorA:b2Vec2;
private var m_localAnchorB:b2Vec2;
private var m_mass:b2Mat33;
public function b2WeldJoint(_arg1:b2WeldJointDef){
m_localAnchorA = new b2Vec2();
m_localAnchorB = new b2Vec2();
m_impulse = new b2Vec3();
m_mass = new b2Mat33();
super(_arg1);
m_localAnchorA.SetV(_arg1.localAnchorA);
m_localAnchorB.SetV(_arg1.localAnchorB);
m_referenceAngle = _arg1.referenceAngle;
m_impulse.SetZero();
m_mass = new b2Mat33();
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_linearVelocity;
var _local7:Number = _local4.m_angularVelocity;
var _local8:b2Vec2 = _local5.m_linearVelocity;
var _local9:Number = _local5.m_angularVelocity;
var _local10:Number = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
var _local12:Number = _local4.m_invI;
var _local13:Number = _local5.m_invI;
_local2 = _local4.m_xf.R;
var _local14:Number = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local15:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local14) + (_local2.col2.x * _local15));
_local15 = ((_local2.col1.y * _local14) + (_local2.col2.y * _local15));
_local14 = _local3;
_local2 = _local5.m_xf.R;
var _local16:Number = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local17:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local16) + (_local2.col2.x * _local17));
_local17 = ((_local2.col1.y * _local16) + (_local2.col2.y * _local17));
_local16 = _local3;
var _local18:Number = (((_local8.x - (_local9 * _local17)) - _local6.x) + (_local7 * _local15));
var _local19:Number = (((_local8.y + (_local9 * _local16)) - _local6.y) - (_local7 * _local14));
var _local20:Number = (_local9 - _local7);
var _local21:b2Vec3 = new b2Vec3();
m_mass.Solve33(_local21, -(_local18), -(_local19), -(_local20));
m_impulse.Add(_local21);
_local6.x = (_local6.x - (_local10 * _local21.x));
_local6.y = (_local6.y - (_local10 * _local21.y));
_local7 = (_local7 - (_local12 * (((_local14 * _local21.y) - (_local15 * _local21.x)) + _local21.z)));
_local8.x = (_local8.x + (_local11 * _local21.x));
_local8.y = (_local8.y + (_local11 * _local21.y));
_local9 = (_local9 + (_local13 * (((_local16 * _local21.y) - (_local17 * _local21.x)) + _local21.z)));
_local4.m_angularVelocity = _local7;
_local5.m_angularVelocity = _local9;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.z));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
_local2 = _local4.m_xf.R;
var _local6:Number = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
var _local8:Number = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
var _local10:Number = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
var _local12:Number = _local4.m_invI;
var _local13:Number = _local5.m_invI;
var _local14:Number = (((_local5.m_sweep.c.x + _local8) - _local4.m_sweep.c.x) - _local6);
var _local15:Number = (((_local5.m_sweep.c.y + _local9) - _local4.m_sweep.c.y) - _local7);
var _local16:Number = ((_local5.m_sweep.a - _local4.m_sweep.a) - m_referenceAngle);
var _local17:Number = (10 * b2Settings.b2_linearSlop);
var _local18:Number = Math.sqrt(((_local14 * _local14) + (_local15 * _local15)));
var _local19:Number = b2Math.Abs(_local16);
if (_local18 > _local17){
_local12 = (_local12 * 1);
_local13 = (_local13 * 1);
};
m_mass.col1.x = (((_local10 + _local11) + ((_local7 * _local7) * _local12)) + ((_local9 * _local9) * _local13));
m_mass.col2.x = (((-(_local7) * _local6) * _local12) - ((_local9 * _local8) * _local13));
m_mass.col3.x = ((-(_local7) * _local12) - (_local9 * _local13));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((_local10 + _local11) + ((_local6 * _local6) * _local12)) + ((_local8 * _local8) * _local13));
m_mass.col3.y = ((_local6 * _local12) + (_local8 * _local13));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (_local12 + _local13);
var _local20:b2Vec3 = new b2Vec3();
m_mass.Solve33(_local20, -(_local14), -(_local15), -(_local16));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x - (_local10 * _local20.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y - (_local10 * _local20.y));
_local4.m_sweep.a = (_local4.m_sweep.a - (_local12 * (((_local6 * _local20.y) - (_local7 * _local20.x)) + _local20.z)));
_local5.m_sweep.c.x = (_local5.m_sweep.c.x + (_local11 * _local20.x));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y + (_local11 * _local20.y));
_local5.m_sweep.a = (_local5.m_sweep.a + (_local13 * (((_local8 * _local20.y) - (_local9 * _local20.x)) + _local20.z)));
_local4.SynchronizeTransform();
_local5.SynchronizeTransform();
return ((((_local18 <= b2Settings.b2_linearSlop)) && ((_local19 <= b2Settings.b2_angularSlop))));
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
_local4 = m_bodyA;
_local5 = m_bodyB;
_local2 = _local4.m_xf.R;
_local6 = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
_local7 = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
_local8 = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
_local10 = _local4.m_invMass;
_local11 = _local5.m_invMass;
_local12 = _local4.m_invI;
_local13 = _local5.m_invI;
m_mass.col1.x = (((_local10 + _local11) + ((_local7 * _local7) * _local12)) + ((_local9 * _local9) * _local13));
m_mass.col2.x = (((-(_local7) * _local6) * _local12) - ((_local9 * _local8) * _local13));
m_mass.col3.x = ((-(_local7) * _local12) - (_local9 * _local13));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((_local10 + _local11) + ((_local6 * _local6) * _local12)) + ((_local8 * _local8) * _local13));
m_mass.col3.y = ((_local6 * _local12) + (_local8 * _local13));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (_local12 + _local13);
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_impulse.z = (m_impulse.z * _arg1.dtRatio);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local10 * m_impulse.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local10 * m_impulse.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local12 * (((_local6 * m_impulse.y) - (_local7 * m_impulse.x)) + m_impulse.z)));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local11 * m_impulse.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local11 * m_impulse.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local13 * (((_local8 * m_impulse.y) - (_local9 * m_impulse.x)) + m_impulse.z)));
} else {
m_impulse.SetZero();
};
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchorA));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchorB));
}
}
}//package Box2D.Dynamics.Joints
Section 137
//b2WeldJointDef (Box2D.Dynamics.Joints.b2WeldJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2WeldJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public function b2WeldJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_weldJoint;
referenceAngle = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA.SetV(bodyA.GetLocalPoint(_arg3));
localAnchorB.SetV(bodyB.GetLocalPoint(_arg3));
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 138
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Body {
b2internal var m_xf:b2Transform;
b2internal var m_controllerCount:int;
b2internal var m_contactList:b2ContactEdge;
b2internal var m_invI:Number;
b2internal var m_fixtureCount:int;
b2internal var m_torque:Number;
b2internal var m_angularVelocity:Number;
b2internal var m_flags:uint;
b2internal var m_linearVelocity:b2Vec2;
b2internal var m_world:b2World;
b2internal var m_inertiaScale:Number;
b2internal var m_controllerList:b2ControllerEdge;
b2internal var m_fixtureList:b2Fixture;
b2internal var m_mass:Number;
b2internal var m_next:b2Body;
b2internal var m_force:b2Vec2;
b2internal var m_sweep:b2Sweep;
private var m_userData;
b2internal var m_invMass:Number;
b2internal var m_prev:b2Body;
b2internal var m_linearDamping:Number;
b2internal var m_type:int;
b2internal var m_angularDamping:Number;
b2internal var m_islandIndex:int;
b2internal var m_jointList:b2JointEdge;
b2internal var m_sleepTime:Number;
b2internal var m_I:Number;
b2internal static var e_fixedRotationFlag:uint = 16;
public static var b2_kinematicBody:uint = 1;
b2internal static var e_bulletFlag:uint = 8;
b2internal static var e_activeFlag:uint = 32;
b2internal static var e_allowSleepFlag:uint = 4;
b2internal static var e_awakeFlag:uint = 2;
public static var b2_dynamicBody:uint = 2;
b2internal static var e_islandFlag:uint = 1;
private static var s_xf1:b2Transform = new b2Transform();
public static var b2_staticBody:uint = 0;
public function b2Body(_arg1:b2BodyDef, _arg2:b2World){
m_xf = new b2Transform();
m_sweep = new b2Sweep();
m_linearVelocity = new b2Vec2();
m_force = new b2Vec2();
super();
m_flags = 0;
if (_arg1.bullet){
m_flags = (m_flags | e_bulletFlag);
};
if (_arg1.fixedRotation){
m_flags = (m_flags | e_fixedRotationFlag);
};
if (_arg1.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (_arg1.awake){
m_flags = (m_flags | e_awakeFlag);
};
if (_arg1.active){
m_flags = (m_flags | e_activeFlag);
};
m_world = _arg2;
m_xf.position.SetV(_arg1.position);
m_xf.R.Set(_arg1.angle);
m_sweep.localCenter.SetZero();
m_sweep.t0 = 1;
m_sweep.a0 = (m_sweep.a = _arg1.angle);
var _local3:b2Mat22 = m_xf.R;
var _local4:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_jointList = null;
m_controllerList = null;
m_contactList = null;
m_controllerCount = 0;
m_prev = null;
m_next = null;
m_linearVelocity.SetV(_arg1.linearVelocity);
m_angularVelocity = _arg1.angularVelocity;
m_linearDamping = _arg1.linearDamping;
m_angularDamping = _arg1.angularDamping;
m_force.Set(0, 0);
m_torque = 0;
m_sleepTime = 0;
m_type = _arg1.type;
if (m_type == b2_dynamicBody){
m_mass = 1;
m_invMass = 1;
} else {
m_mass = 0;
m_invMass = 0;
};
m_I = 0;
m_invI = 0;
m_inertiaScale = _arg1.inertiaScale;
m_userData = _arg1.userData;
m_fixtureList = null;
m_fixtureCount = 0;
}
public function SetLinearVelocity(_arg1:b2Vec2):void{
if (m_type == b2_staticBody){
return;
};
m_linearVelocity.SetV(_arg1);
}
public function ResetMassData():void{
var _local4:b2MassData;
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_sweep.localCenter.SetZero();
if ((((m_type == b2_staticBody)) || ((m_type == b2_kinematicBody)))){
return;
};
var _local1:b2Vec2 = b2Vec2.Make(0, 0);
var _local2:b2Fixture = m_fixtureList;
while (_local2) {
if (_local2.m_density == 0){
} else {
_local4 = _local2.GetMassData();
m_mass = (m_mass + _local4.mass);
_local1.x = (_local1.x + (_local4.center.x * _local4.mass));
_local1.y = (_local1.y + (_local4.center.y * _local4.mass));
m_I = (m_I + _local4.I);
};
_local2 = _local2.m_next;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
_local1.x = (_local1.x * m_invMass);
_local1.y = (_local1.y * m_invMass);
} else {
m_mass = 1;
m_invMass = 1;
};
if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (m_I - (m_mass * ((_local1.x * _local1.x) + (_local1.y * _local1.y))));
m_I = (m_I * m_inertiaScale);
b2Settings.b2Assert((m_I > 0));
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
var _local3:b2Vec2 = m_sweep.c.Copy();
m_sweep.localCenter.SetV(_local1);
m_sweep.c0.SetV(b2Math.MulX(m_xf, m_sweep.localCenter));
m_sweep.c.SetV(m_sweep.c0);
m_linearVelocity.x = (m_linearVelocity.x + (m_angularVelocity * -((m_sweep.c.y - _local3.y))));
m_linearVelocity.y = (m_linearVelocity.y + (m_angularVelocity * (m_sweep.c.x - _local3.x)));
}
public function GetMassData(_arg1:b2MassData):void{
_arg1.mass = m_mass;
_arg1.I = m_I;
_arg1.center.SetV(m_sweep.localCenter);
}
public function Merge(_arg1:b2Body):void{
var _local2:b2Fixture;
var _local3:b2Body;
var _local4:b2Body;
var _local11:b2Fixture;
_local2 = _arg1.m_fixtureList;
while (_local2) {
_local11 = _local2.m_next;
_arg1.m_fixtureCount--;
_local2.m_next = m_fixtureList;
m_fixtureList = _local2;
m_fixtureCount++;
_local2.m_body = _local4;
_local2 = _local11;
};
_local3.m_fixtureCount = 0;
_local3 = this;
_local4 = _arg1;
var _local5:b2Vec2 = _local3.GetWorldCenter();
var _local6:b2Vec2 = _local4.GetWorldCenter();
var _local7:b2Vec2 = _local3.GetLinearVelocity().Copy();
var _local8:b2Vec2 = _local4.GetLinearVelocity().Copy();
var _local9:Number = _local3.GetAngularVelocity();
var _local10:Number = _local4.GetAngularVelocity();
_local3.ResetMassData();
SynchronizeFixtures();
}
b2internal function SynchronizeTransform():void{
m_xf.R.Set(m_sweep.a);
var _local1:b2Mat22 = m_xf.R;
var _local2:b2Vec2 = m_sweep.localCenter;
m_xf.position.x = (m_sweep.c.x - ((_local1.col1.x * _local2.x) + (_local1.col2.x * _local2.y)));
m_xf.position.y = (m_sweep.c.y - ((_local1.col1.y * _local2.x) + (_local1.col2.y * _local2.y)));
}
public function SetMassData(_arg1:b2MassData):void{
b2Settings.b2Assert((m_world.IsLocked() == false));
if (m_world.IsLocked() == true){
return;
};
if (m_type != b2_dynamicBody){
return;
};
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.mass;
if (m_mass <= 0){
m_mass = 1;
};
m_invMass = (1 / m_mass);
if ((((_arg1.I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (_arg1.I - (m_mass * ((_arg1.center.x * _arg1.center.x) + (_arg1.center.y * _arg1.center.y))));
m_invI = (1 / m_I);
};
var _local2:b2Vec2 = m_sweep.c.Copy();
m_sweep.localCenter.SetV(_arg1.center);
m_sweep.c0.SetV(b2Math.MulX(m_xf, m_sweep.localCenter));
m_sweep.c.SetV(m_sweep.c0);
m_linearVelocity.x = (m_linearVelocity.x + (m_angularVelocity * -((m_sweep.c.y - _local2.y))));
m_linearVelocity.y = (m_linearVelocity.y + (m_angularVelocity * (m_sweep.c.x - _local2.x)));
}
public function GetDefinition():b2BodyDef{
var _local1:b2BodyDef = new b2BodyDef();
_local1.type = GetType();
_local1.allowSleep = ((m_flags & e_allowSleepFlag) == e_allowSleepFlag);
_local1.angle = GetAngle();
_local1.angularDamping = m_angularDamping;
_local1.angularVelocity = m_angularVelocity;
_local1.fixedRotation = ((m_flags & e_fixedRotationFlag) == e_fixedRotationFlag);
_local1.bullet = ((m_flags & e_bulletFlag) == e_bulletFlag);
_local1.awake = ((m_flags & e_awakeFlag) == e_awakeFlag);
_local1.linearDamping = m_linearDamping;
_local1.linearVelocity.SetV(GetLinearVelocity());
_local1.position = GetPosition();
_local1.userData = GetUserData();
return (_local1);
}
public function GetControllerList():b2ControllerEdge{
return (m_controllerList);
}
public function GetFixtureList():b2Fixture{
return (m_fixtureList);
}
public function SetAngularVelocity(_arg1:Number):void{
if (m_type == b2_staticBody){
return;
};
m_angularVelocity = _arg1;
}
public function GetAngle():Number{
return (m_sweep.a);
}
public function GetLinearVelocityFromLocalPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (_local3.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (_local3.x - m_sweep.c.x)))));
}
public function GetNext():b2Body{
return (m_next);
}
public function GetMass():Number{
return (m_mass);
}
public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_force.x = (m_force.x + _arg1.x);
m_force.y = (m_force.y + _arg1.y);
m_torque = (m_torque + (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x)));
}
public function CreateFixture(_arg1:b2FixtureDef):b2Fixture{
var _local3:IBroadPhase;
if (m_world.IsLocked() == true){
return (null);
};
var _local2:b2Fixture = new b2Fixture();
_local2.Create(this, m_xf, _arg1);
if ((m_flags & e_activeFlag)){
_local3 = m_world.m_contactManager.m_broadPhase;
_local2.CreateProxy(_local3, m_xf);
};
_local2.m_next = m_fixtureList;
m_fixtureList = _local2;
m_fixtureCount++;
_local2.m_body = this;
if (_local2.m_density > 0){
ResetMassData();
};
m_world.m_flags = (m_world.m_flags | b2World.e_newFixture);
return (_local2);
}
public function SetTransform(_arg1:b2Transform):void{
SetPositionAndAngle(_arg1.position, _arg1.GetAngle());
}
public function IsAwake():Boolean{
return (((m_flags & e_awakeFlag) == e_awakeFlag));
}
public function GetWorldVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.MulMV(m_xf.R, _arg1));
}
b2internal function Advance(_arg1:Number):void{
m_sweep.Advance(_arg1);
m_sweep.c.SetV(m_sweep.c0);
m_sweep.a = m_sweep.a0;
SynchronizeTransform();
}
public function SetAwake(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_awakeFlag);
m_sleepTime = 0;
} else {
m_flags = (m_flags & ~(e_awakeFlag));
m_sleepTime = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_force.SetZero();
m_torque = 0;
};
}
public function GetUserData(){
return (m_userData);
}
public function GetWorldCenter():b2Vec2{
return (m_sweep.c);
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetLocalVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.MulTMV(m_xf.R, _arg1));
}
public function GetPosition():b2Vec2{
return (m_xf.position);
}
public function GetLinearVelocityFromWorldPoint(_arg1:b2Vec2):b2Vec2{
return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (_arg1.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (_arg1.x - m_sweep.c.x)))));
}
public function CreateFixture2(_arg1:b2Shape, _arg2:Number=0):b2Fixture{
var _local3:b2FixtureDef = new b2FixtureDef();
_local3.shape = _arg1;
_local3.density = _arg2;
return (CreateFixture(_local3));
}
public function GetLinearDamping():Number{
return (m_linearDamping);
}
public function GetLocalCenter():b2Vec2{
return (m_sweep.localCenter);
}
public function SetPosition(_arg1:b2Vec2):void{
SetPositionAndAngle(_arg1, GetAngle());
}
private function connectEdges(_arg1:b2EdgeShape, _arg2:b2EdgeShape, _arg3:Number):Number{
var _local4:Number = Math.atan2(_arg2.GetDirectionVector().y, _arg2.GetDirectionVector().x);
var _local5:Number = Math.tan(((_local4 - _arg3) * 0.5));
var _local6:b2Vec2 = b2Math.MulFV(_local5, _arg2.GetDirectionVector());
_local6 = b2Math.SubtractVV(_local6, _arg2.GetNormalVector());
_local6 = b2Math.MulFV(b2Settings.b2_toiSlop, _local6);
_local6 = b2Math.AddVV(_local6, _arg2.GetVertex1());
var _local7:b2Vec2 = b2Math.AddVV(_arg1.GetDirectionVector(), _arg2.GetDirectionVector());
_local7.Normalize();
var _local8 = (b2Math.Dot(_arg1.GetDirectionVector(), _arg2.GetNormalVector()) > 0);
_arg1.SetNextEdge(_arg2, _local6, _local7, _local8);
_arg2.SetPrevEdge(_arg1, _local6, _local7, _local8);
return (_local4);
}
public function GetType():uint{
return (m_type);
}
public function GetAngularDamping():Number{
return (m_angularDamping);
}
public function SetType(_arg1:uint):void{
if (m_type == _arg1){
return;
};
m_type = _arg1;
ResetMassData();
if (m_type == b2_staticBody){
m_linearVelocity.SetZero();
m_angularVelocity = 0;
};
SetAwake(true);
m_force.SetZero();
m_torque = 0;
var _local2:b2ContactEdge = m_contactList;
while (_local2) {
_local2.contact.FlagForFiltering();
_local2 = _local2.next;
};
}
public function SetAngularDamping(_arg1:Number):void{
m_angularDamping = _arg1;
}
public function GetInertia():Number{
return (m_I);
}
public function SetAngle(_arg1:Number):void{
SetPositionAndAngle(GetPosition(), _arg1);
}
public function GetJointList():b2JointEdge{
return (m_jointList);
}
public function GetLocalPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.MulXT(m_xf, _arg1));
}
public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_linearVelocity.x = (m_linearVelocity.x + (m_invMass * _arg1.x));
m_linearVelocity.y = (m_linearVelocity.y + (m_invMass * _arg1.y));
m_angularVelocity = (m_angularVelocity + (m_invI * (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x))));
}
public function GetContactList():b2ContactEdge{
return (m_contactList);
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function DestroyFixture(_arg1:b2Fixture):void{
var _local6:b2Contact;
var _local7:b2Fixture;
var _local8:b2Fixture;
var _local9:IBroadPhase;
if (m_world.IsLocked() == true){
return;
};
var _local2:b2Fixture = m_fixtureList;
var _local3:b2Fixture;
var _local4:Boolean;
while (_local2 != null) {
if (_local2 == _arg1){
if (_local3){
_local3.m_next = _arg1.m_next;
} else {
m_fixtureList = _arg1.m_next;
};
_local4 = true;
break;
};
_local3 = _local2;
_local2 = _local2.m_next;
};
var _local5:b2ContactEdge = m_contactList;
while (_local5) {
_local6 = _local5.contact;
_local5 = _local5.next;
_local7 = _local6.GetFixtureA();
_local8 = _local6.GetFixtureB();
if ((((_arg1 == _local7)) || ((_arg1 == _local8)))){
m_world.m_contactManager.Destroy(_local6);
};
};
if ((m_flags & e_activeFlag)){
_local9 = m_world.m_contactManager.m_broadPhase;
_arg1.DestroyProxy(_local9);
};
_arg1.Destroy();
_arg1.m_body = null;
_arg1.m_next = null;
m_fixtureCount--;
ResetMassData();
}
public function IsSleepingAllowed():Boolean{
return (((m_flags & e_allowSleepFlag) == e_allowSleepFlag));
}
public function GetTransform():b2Transform{
return (m_xf);
}
b2internal function SynchronizeFixtures():void{
var _local4:b2Fixture;
var _local1:b2Transform = s_xf1;
_local1.R.Set(m_sweep.a0);
var _local2:b2Mat22 = _local1.R;
var _local3:b2Vec2 = m_sweep.localCenter;
_local1.position.x = (m_sweep.c0.x - ((_local2.col1.x * _local3.x) + (_local2.col2.x * _local3.y)));
_local1.position.y = (m_sweep.c0.y - ((_local2.col1.y * _local3.x) + (_local2.col2.y * _local3.y)));
var _local5:IBroadPhase = m_world.m_contactManager.m_broadPhase;
_local4 = m_fixtureList;
while (_local4) {
_local4.Synchronize(_local5, _local1, m_xf);
_local4 = _local4.m_next;
};
}
public function SetSleepingAllowed(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
SetAwake(true);
};
}
public function SetBullet(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_bulletFlag);
} else {
m_flags = (m_flags & ~(e_bulletFlag));
};
}
public function SetPositionAndAngle(_arg1:b2Vec2, _arg2:Number):void{
var _local3:b2Fixture;
if (m_world.IsLocked() == true){
return;
};
m_xf.R.Set(_arg2);
m_xf.position.SetV(_arg1);
var _local4:b2Mat22 = m_xf.R;
var _local5:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local4.col1.x * _local5.x) + (_local4.col2.x * _local5.y));
m_sweep.c.y = ((_local4.col1.y * _local5.x) + (_local4.col2.y * _local5.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_sweep.a0 = (m_sweep.a = _arg2);
var _local6:IBroadPhase = m_world.m_contactManager.m_broadPhase;
_local3 = m_fixtureList;
while (_local3) {
_local3.Synchronize(_local6, m_xf, m_xf);
_local3 = _local3.m_next;
};
m_world.m_contactManager.FindNewContacts();
}
public function IsFixedRotation():Boolean{
return (((m_flags & e_fixedRotationFlag) == e_fixedRotationFlag));
}
public function SetActive(_arg1:Boolean):void{
var _local2:IBroadPhase;
var _local3:b2Fixture;
var _local4:b2ContactEdge;
var _local5:b2ContactEdge;
if (_arg1 == IsActive()){
return;
};
if (_arg1){
m_flags = (m_flags | e_activeFlag);
_local2 = m_world.m_contactManager.m_broadPhase;
_local3 = m_fixtureList;
while (_local3) {
_local3.CreateProxy(_local2, m_xf);
_local3 = _local3.m_next;
};
} else {
m_flags = (m_flags & ~(e_activeFlag));
_local2 = m_world.m_contactManager.m_broadPhase;
_local3 = m_fixtureList;
while (_local3) {
_local3.DestroyProxy(_local2);
_local3 = _local3.m_next;
};
_local4 = m_contactList;
while (_local4) {
_local5 = _local4;
_local4 = _local4.next;
m_world.m_contactManager.Destroy(_local5.contact);
};
m_contactList = null;
};
}
public function IsActive():Boolean{
return (((m_flags & e_activeFlag) == e_activeFlag));
}
b2internal function ShouldCollide(_arg1:b2Body):Boolean{
if (((!((m_type == b2_dynamicBody))) && (!((_arg1.m_type == b2_dynamicBody))))){
return (false);
};
var _local2:b2JointEdge = m_jointList;
while (_local2) {
if (_local2.other == _arg1){
if (_local2.joint.m_collideConnected == false){
return (false);
};
};
_local2 = _local2.next;
};
return (true);
}
public function IsBullet():Boolean{
return (((m_flags & e_bulletFlag) == e_bulletFlag));
}
public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (_local3);
}
public function SetFixedRotation(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_fixedRotationFlag);
} else {
m_flags = (m_flags & ~(e_fixedRotationFlag));
};
ResetMassData();
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function Split(_arg1:Function):b2Body{
var _local7:b2Fixture;
var _local13:b2Fixture;
var _local2:b2Vec2 = GetLinearVelocity().Copy();
var _local3:Number = GetAngularVelocity();
var _local4:b2Vec2 = GetWorldCenter();
var _local5:b2Body = this;
var _local6:b2Body = m_world.CreateBody(GetDefinition());
var _local8:b2Fixture = _local5.m_fixtureList;
while (_local8) {
if (_arg1(_local8)){
_local13 = _local8.m_next;
if (_local7){
_local7.m_next = _local13;
} else {
_local5.m_fixtureList = _local13;
};
_local5.m_fixtureCount--;
_local8.m_next = _local6.m_fixtureList;
_local6.m_fixtureList = _local8;
_local6.m_fixtureCount++;
_local8.m_body = _local6;
_local8 = _local13;
} else {
_local7 = _local8;
_local8 = _local8.m_next;
};
};
_local5.ResetMassData();
_local6.ResetMassData();
var _local9:b2Vec2 = _local5.GetWorldCenter();
var _local10:b2Vec2 = _local6.GetWorldCenter();
var _local11:b2Vec2 = b2Math.AddVV(_local2, b2Math.CrossFV(_local3, b2Math.SubtractVV(_local9, _local4)));
var _local12:b2Vec2 = b2Math.AddVV(_local2, b2Math.CrossFV(_local3, b2Math.SubtractVV(_local10, _local4)));
_local5.SetLinearVelocity(_local11);
_local6.SetLinearVelocity(_local12);
_local5.SetAngularVelocity(_local3);
_local6.SetAngularVelocity(_local3);
_local5.SynchronizeFixtures();
_local6.SynchronizeFixtures();
return (_local6);
}
public function SetLinearDamping(_arg1:Number):void{
m_linearDamping = _arg1;
}
public function GetWorld():b2World{
return (m_world);
}
public function ApplyTorque(_arg1:Number):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_torque = (m_torque + _arg1);
}
}
}//package Box2D.Dynamics
Section 139
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
public class b2BodyDef {
public var angularDamping:Number;
public var bullet:Boolean;
public var awake:Boolean;
public var active:Boolean;
public var allowSleep:Boolean;
public var angle:Number;
public var userData;
public var fixedRotation:Boolean;
public var linearDamping:Number;
public var angularVelocity:Number;
public var linearVelocity:b2Vec2;
public var position:b2Vec2;
public var inertiaScale:Number;
public var type:uint;
public function b2BodyDef(){
position = new b2Vec2();
linearVelocity = new b2Vec2();
super();
userData = null;
position.Set(0, 0);
angle = 0;
linearVelocity.Set(0, 0);
angularVelocity = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
awake = true;
fixedRotation = false;
bullet = false;
type = b2Body.b2_staticBody;
active = true;
inertiaScale = 1;
}
}
}//package Box2D.Dynamics
Section 140
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter)
package Box2D.Dynamics {
import Box2D.Common.*;
public class b2ContactFilter {
b2internal static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter);
;
public function ShouldCollide(_arg1:b2Fixture, _arg2:b2Fixture):Boolean{
var _local3:b2FilterData = _arg1.GetFilterData();
var _local4:b2FilterData = _arg2.GetFilterData();
if ((((_local3.groupIndex == _local4.groupIndex)) && (!((_local3.groupIndex == 0))))){
return ((_local3.groupIndex > 0));
};
var _local5:Boolean = ((!(((_local3.maskBits & _local4.categoryBits) == 0))) && (!(((_local3.categoryBits & _local4.maskBits) == 0))));
return (_local5);
}
public function RayCollide(_arg1, _arg2:b2Fixture):Boolean{
if (!_arg1){
return (true);
};
return (ShouldCollide((_arg1 as b2Fixture), _arg2));
}
}
}//package Box2D.Dynamics
Section 141
//b2ContactImpulse (Box2D.Dynamics.b2ContactImpulse)
package Box2D.Dynamics {
import Box2D.Common.*;
public class b2ContactImpulse {
public var tangentImpulses:Array;
public var normalImpulses:Array;
public function b2ContactImpulse(){
normalImpulses = new Array(b2Settings.b2_maxManifoldPoints);
tangentImpulses = new Array(b2Settings.b2_maxManifoldPoints);
super();
}
}
}//package Box2D.Dynamics
Section 142
//b2ContactListener (Box2D.Dynamics.b2ContactListener)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2ContactListener {
b2internal static var b2_defaultListener:b2ContactListener = new (b2ContactListener);
;
public function PreSolve(_arg1:b2Contact, _arg2:b2Manifold):void{
}
public function EndContact(_arg1:b2Contact):void{
}
public function PostSolve(_arg1:b2Contact, _arg2:b2ContactImpulse):void{
}
public function BeginContact(_arg1:b2Contact):void{
}
}
}//package Box2D.Dynamics
Section 143
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2ContactManager {
b2internal var m_world:b2World;
b2internal var m_contactCount:int;
b2internal var m_contactFactory:b2ContactFactory;
b2internal var m_contactFilter:b2ContactFilter;
b2internal var m_broadPhase:IBroadPhase;
b2internal var m_contactList:b2Contact;
b2internal var m_contactListener:b2ContactListener;
b2internal var m_allocator;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2ContactManager(){
m_world = null;
m_contactCount = 0;
m_contactFilter = b2ContactFilter.b2_defaultFilter;
m_contactListener = b2ContactListener.b2_defaultListener;
m_contactFactory = new b2ContactFactory(m_allocator);
m_broadPhase = new b2DynamicTreeBroadPhase();
}
public function FindNewContacts():void{
m_broadPhase.UpdatePairs(AddPair);
}
public function Destroy(_arg1:b2Contact):void{
var _local2:b2Fixture = _arg1.GetFixtureA();
var _local3:b2Fixture = _arg1.GetFixtureB();
var _local4:b2Body = _local2.GetBody();
var _local5:b2Body = _local3.GetBody();
if (_arg1.m_manifold.m_pointCount > 0){
m_contactListener.EndContact(_arg1);
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_world.m_contactList){
m_world.m_contactList = _arg1.m_next;
};
if (_arg1.m_nodeA.prev){
_arg1.m_nodeA.prev.next = _arg1.m_nodeA.next;
};
if (_arg1.m_nodeA.next){
_arg1.m_nodeA.next.prev = _arg1.m_nodeA.prev;
};
if (_arg1.m_nodeA == _local4.m_contactList){
_local4.m_contactList = _arg1.m_nodeA.next;
};
if (_arg1.m_nodeB.prev){
_arg1.m_nodeB.prev.next = _arg1.m_nodeB.next;
};
if (_arg1.m_nodeB.next){
_arg1.m_nodeB.next.prev = _arg1.m_nodeB.prev;
};
if (_arg1.m_nodeB == _local5.m_contactList){
_local5.m_contactList = _arg1.m_nodeB.next;
};
m_contactFactory.Destroy(_arg1);
m_contactCount--;
}
public function AddPair(_arg1, _arg2):void{
var _local9:b2Fixture;
var _local10:b2Fixture;
var _local3:b2Fixture = (_arg1 as b2Fixture);
var _local4:b2Fixture = (_arg2 as b2Fixture);
var _local5:b2Body = _local3.GetBody();
var _local6:b2Body = _local4.GetBody();
if (_local5 == _local6){
return;
};
var _local7:b2ContactEdge = _local6.GetContactList();
while (_local7) {
if (_local7.other == _local5){
_local9 = _local7.contact.GetFixtureA();
_local10 = _local7.contact.GetFixtureB();
if ((((_local9 == _local3)) && ((_local10 == _local4)))){
return;
};
if ((((_local9 == _local4)) && ((_local10 == _local3)))){
return;
};
};
_local7 = _local7.next;
};
if (_local6.ShouldCollide(_local5) == false){
return;
};
if (m_contactFilter.ShouldCollide(_local3, _local4) == false){
return;
};
var _local8:b2Contact = m_contactFactory.Create(_local3, _local4);
_local3 = _local8.GetFixtureA();
_local4 = _local8.GetFixtureB();
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local8.m_prev = null;
_local8.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = _local8;
};
m_world.m_contactList = _local8;
_local8.m_nodeA.contact = _local8;
_local8.m_nodeA.other = _local6;
_local8.m_nodeA.prev = null;
_local8.m_nodeA.next = _local5.m_contactList;
if (_local5.m_contactList != null){
_local5.m_contactList.prev = _local8.m_nodeA;
};
_local5.m_contactList = _local8.m_nodeA;
_local8.m_nodeB.contact = _local8;
_local8.m_nodeB.other = _local5;
_local8.m_nodeB.prev = null;
_local8.m_nodeB.next = _local6.m_contactList;
if (_local6.m_contactList != null){
_local6.m_contactList.prev = _local8.m_nodeB;
};
_local6.m_contactList = _local8.m_nodeB;
m_world.m_contactCount++;
}
public function Collide():void{
var _local2:b2Fixture;
var _local3:b2Fixture;
var _local4:b2Body;
var _local5:b2Body;
var _local6:*;
var _local7:*;
var _local8:Boolean;
var _local9:b2Contact;
var _local1:b2Contact = m_world.m_contactList;
while (_local1) {
_local2 = _local1.GetFixtureA();
_local3 = _local1.GetFixtureB();
_local4 = _local2.GetBody();
_local5 = _local3.GetBody();
if ((((_local4.IsAwake() == false)) && ((_local5.IsAwake() == false)))){
_local1 = _local1.GetNext();
} else {
if ((_local1.m_flags & b2Contact.e_filterFlag)){
if (_local5.ShouldCollide(_local4) == false){
_local9 = _local1;
_local1 = _local9.GetNext();
Destroy(_local9);
continue;
};
if (m_contactFilter.ShouldCollide(_local2, _local3) == false){
_local9 = _local1;
_local1 = _local9.GetNext();
Destroy(_local9);
continue;
};
_local1.m_flags = (_local1.m_flags & ~(b2Contact.e_filterFlag));
};
_local6 = _local2.m_proxy;
_local7 = _local3.m_proxy;
_local8 = m_broadPhase.TestOverlap(_local6, _local7);
if (_local8 == false){
_local9 = _local1;
_local1 = _local9.GetNext();
Destroy(_local9);
} else {
_local1.Update(m_contactListener);
_local1 = _local1.GetNext();
};
};
};
}
}
}//package Box2D.Dynamics
Section 144
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw)
package Box2D.Dynamics {
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2DebugDraw {
private var m_xformScale:Number;// = 1
private var m_fillAlpha:Number;// = 1
private var m_alpha:Number;// = 1
private var m_lineThickness:Number;// = 1
private var m_drawFlags:uint;
b2internal var m_sprite:Sprite;
private var m_drawScale:Number;// = 1
public static var e_centerOfMassBit:uint = 16;
public static var e_shapeBit:uint = 1;
public static var e_aabbBit:uint = 4;
public static var e_controllerBit:uint = 32;
public static var e_pairBit:uint = 8;
public static var e_jointBit:uint = 2;
public function b2DebugDraw(){
m_drawFlags = 0;
}
public function SetDrawScale(_arg1:Number):void{
m_drawScale = _arg1;
}
public function GetFillAlpha():Number{
return (m_fillAlpha);
}
public function GetAlpha():Number{
return (m_alpha);
}
public function GetLineThickness():Number{
return (m_lineThickness);
}
public function GetDrawScale():Number{
return (m_drawScale);
}
public function DrawSolidPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.beginFill(_arg3.color, m_fillAlpha);
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.endFill();
}
public function DrawCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
}
public function DrawSolidCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg4.color, m_alpha);
m_sprite.graphics.moveTo(0, 0);
m_sprite.graphics.beginFill(_arg4.color, m_fillAlpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
m_sprite.graphics.endFill();
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.x + (_arg3.x * _arg2)) * m_drawScale), ((_arg1.y + (_arg3.y * _arg2)) * m_drawScale));
}
public function ClearFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags & ~(_arg1));
}
public function GetSprite():Sprite{
return (m_sprite);
}
public function GetXFormScale():Number{
return (m_xformScale);
}
public function SetFlags(_arg1:uint):void{
m_drawFlags = _arg1;
}
public function SetSprite(_arg1:Sprite):void{
m_sprite = _arg1;
}
public function DrawTransform(_arg1:b2Transform):void{
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF0000, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col1.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col1.y)) * m_drawScale));
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF00, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col2.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col2.y)) * m_drawScale));
}
public function AppendFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags | _arg1);
}
public function DrawSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo((_arg2.x * m_drawScale), (_arg2.y * m_drawScale));
}
public function SetXFormScale(_arg1:Number):void{
m_xformScale = _arg1;
}
public function GetFlags():uint{
return (m_drawFlags);
}
public function DrawPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
}
public function SetFillAlpha(_arg1:Number):void{
m_fillAlpha = _arg1;
}
public function SetAlpha(_arg1:Number):void{
m_alpha = _arg1;
}
public function SetLineThickness(_arg1:Number):void{
m_lineThickness = _arg1;
}
}
}//package Box2D.Dynamics
Section 145
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener)
package Box2D.Dynamics {
import Box2D.Dynamics.Joints.*;
public class b2DestructionListener {
public function SayGoodbyeFixture(_arg1:b2Fixture):void{
}
public function SayGoodbyeJoint(_arg1:b2Joint):void{
}
}
}//package Box2D.Dynamics
Section 146
//b2FilterData (Box2D.Dynamics.b2FilterData)
package Box2D.Dynamics {
public class b2FilterData {
public var maskBits:uint;// = 0xFFFF
public var groupIndex:int;// = 0
public var categoryBits:uint;// = 1
public function Copy():b2FilterData{
var _local1:b2FilterData = new b2FilterData();
_local1.categoryBits = categoryBits;
_local1.maskBits = maskBits;
_local1.groupIndex = groupIndex;
return (_local1);
}
}
}//package Box2D.Dynamics
Section 147
//b2Fixture (Box2D.Dynamics.b2Fixture)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Fixture {
b2internal var m_next:b2Fixture;
b2internal var m_shape:b2Shape;
b2internal var m_restitution:Number;
b2internal var m_friction:Number;
b2internal var m_proxy;
b2internal var m_filter:b2FilterData;
b2internal var m_density:Number;
private var m_massData:b2MassData;
b2internal var m_isSensor:Boolean;
b2internal var m_userData;
b2internal var m_aabb:b2AABB;
b2internal var m_body:b2Body;
public function b2Fixture(){
m_filter = new b2FilterData();
super();
m_aabb = new b2AABB();
m_userData = null;
m_body = null;
m_next = null;
m_shape = null;
m_density = 0;
m_friction = 0;
m_restitution = 0;
}
public function TestPoint(_arg1:b2Vec2):Boolean{
return (m_shape.TestPoint(m_body.GetTransform(), _arg1));
}
public function SetDensity(_arg1:Number):void{
m_density = _arg1;
}
public function SetRestitution(_arg1:Number):void{
m_restitution = _arg1;
}
public function GetNext():b2Fixture{
return (m_next);
}
public function GetShape():b2Shape{
return (m_shape);
}
public function GetFriction():Number{
return (m_friction);
}
public function GetDensity():Number{
return (m_density);
}
public function GetMassData(_arg1:b2MassData=null):b2MassData{
if (_arg1 == null){
_arg1 = new b2MassData();
};
m_shape.ComputeMass(_arg1, m_density);
return (_arg1);
}
public function GetAABB():b2AABB{
return (m_aabb);
}
public function GetType():int{
return (m_shape.GetType());
}
public function GetFilterData():b2FilterData{
return (m_filter.Copy());
}
b2internal function Destroy():void{
m_shape = null;
}
public function GetRestitution():Number{
return (m_restitution);
}
public function SetFriction(_arg1:Number):void{
m_friction = _arg1;
}
b2internal function Create(_arg1:b2Body, _arg2:b2Transform, _arg3:b2FixtureDef):void{
m_userData = _arg3.userData;
m_friction = _arg3.friction;
m_restitution = _arg3.restitution;
m_body = _arg1;
m_next = null;
m_filter = _arg3.filter.Copy();
m_isSensor = _arg3.isSensor;
m_shape = _arg3.shape.Copy();
m_density = _arg3.density;
}
public function IsSensor():Boolean{
return (m_isSensor);
}
public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput):Boolean{
return (m_shape.RayCast(_arg1, _arg2, m_body.GetTransform()));
}
public function GetUserData(){
return (m_userData);
}
b2internal function Synchronize(_arg1:IBroadPhase, _arg2:b2Transform, _arg3:b2Transform):void{
if (!m_proxy){
return;
};
var _local4:b2AABB = new b2AABB();
var _local5:b2AABB = new b2AABB();
m_shape.ComputeAABB(_local4, _arg2);
m_shape.ComputeAABB(_local5, _arg3);
m_aabb.Combine(_local4, _local5);
var _local6:b2Vec2 = b2Math.SubtractVV(_arg3.position, _arg2.position);
_arg1.MoveProxy(m_proxy, m_aabb, _local6);
}
b2internal function CreateProxy(_arg1:IBroadPhase, _arg2:b2Transform):void{
m_shape.ComputeAABB(m_aabb, _arg2);
m_proxy = _arg1.CreateProxy(m_aabb, this);
}
public function SetFilterData(_arg1:b2FilterData):void{
var _local3:b2Contact;
var _local4:b2Fixture;
var _local5:b2Fixture;
m_filter = _arg1.Copy();
if (m_body){
return;
};
var _local2:b2ContactEdge = m_body.GetContactList();
while (_local2) {
_local3 = _local2.contact;
_local4 = _local3.GetFixtureA();
_local5 = _local3.GetFixtureB();
if ((((_local4 == this)) || ((_local5 == this)))){
_local3.FlagForFiltering();
};
_local2 = _local2.next;
};
}
b2internal function DestroyProxy(_arg1:IBroadPhase):void{
if (m_proxy == null){
return;
};
_arg1.DestroyProxy(m_proxy);
m_proxy = null;
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetBody():b2Body{
return (m_body);
}
public function SetSensor(_arg1:Boolean):void{
var _local3:b2Contact;
var _local4:b2Fixture;
var _local5:b2Fixture;
if (m_isSensor == _arg1){
return;
};
m_isSensor = _arg1;
if (m_body == null){
return;
};
var _local2:b2ContactEdge = m_body.GetContactList();
while (_local2) {
_local3 = _local2.contact;
_local4 = _local3.GetFixtureA();
_local5 = _local3.GetFixtureB();
if ((((_local4 == this)) || ((_local5 == this)))){
_local3.SetSensor(((_local4.IsSensor()) || (_local5.IsSensor())));
};
_local2 = _local2.next;
};
}
}
}//package Box2D.Dynamics
Section 148
//b2FixtureDef (Box2D.Dynamics.b2FixtureDef)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2FixtureDef {
public var shape:b2Shape;
public var isSensor:Boolean;
public var density:Number;
public var restitution:Number;
public var userData;
public var filter:b2FilterData;
public var friction:Number;
public function b2FixtureDef(){
filter = new b2FilterData();
super();
shape = null;
userData = null;
friction = 0.2;
restitution = 0;
density = 0;
filter.categoryBits = 1;
filter.maskBits = 0xFFFF;
filter.groupIndex = 0;
isSensor = false;
}
}
}//package Box2D.Dynamics
Section 149
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Island {
private var m_contactSolver:b2ContactSolver;
private var m_listener:b2ContactListener;
private var m_bodyCapacity:int;
b2internal var m_bodies:Array;
b2internal var m_bodyCount:int;
b2internal var m_jointCapacity:int;
b2internal var m_contactCount:int;
b2internal var m_contacts:Array;
b2internal var m_contactCapacity:int;
b2internal var m_jointCount:int;
private var m_allocator;
b2internal var m_joints:Array;
private static var s_impulse:b2ContactImpulse = new b2ContactImpulse();
public function b2Island(){
m_bodies = new Array();
m_contacts = new Array();
m_joints = new Array();
}
public function AddBody(_arg1:b2Body):void{
_arg1.m_islandIndex = m_bodyCount;
var _local2 = m_bodyCount++;
m_bodies[_local2] = _arg1;
}
public function AddJoint(_arg1:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = _arg1;
}
public function Report(_arg1:Array):void{
var _local3:b2Contact;
var _local4:b2ContactConstraint;
var _local5:int;
if (m_listener == null){
return;
};
var _local2:int;
while (_local2 < m_contactCount) {
_local3 = m_contacts[_local2];
_local4 = _arg1[_local2];
_local5 = 0;
while (_local5 < _local4.pointCount) {
s_impulse.normalImpulses[_local5] = _local4.points[_local5].normalImpulse;
s_impulse.tangentImpulses[_local5] = _local4.points[_local5].tangentImpulse;
_local5++;
};
m_listener.PostSolve(_local3, s_impulse);
_local2++;
};
}
public function AddContact(_arg1:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = _arg1;
}
public function Solve(_arg1:b2TimeStep, _arg2:b2Vec2, _arg3:Boolean):void{
var _local4:int;
var _local5:int;
var _local6:b2Body;
var _local7:b2Joint;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Boolean;
var _local13:Boolean;
var _local14:Boolean;
var _local15:Number;
var _local16:Number;
var _local17:Number;
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.GetType() != b2Body.b2_dynamicBody){
} else {
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x + (_arg1.dt * (_arg2.x + (_local6.m_invMass * _local6.m_force.x))));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y + (_arg1.dt * (_arg2.y + (_local6.m_invMass * _local6.m_force.y))));
_local6.m_angularVelocity = (_local6.m_angularVelocity + ((_arg1.dt * _local6.m_invI) * _local6.m_torque));
_local6.m_linearVelocity.Multiply(b2Math.Clamp((1 - (_arg1.dt * _local6.m_linearDamping)), 0, 1));
_local6.m_angularVelocity = (_local6.m_angularVelocity * b2Math.Clamp((1 - (_arg1.dt * _local6.m_angularDamping)), 0, 1));
};
_local4++;
};
m_contactSolver.Initialize(_arg1, m_contacts, m_contactCount, m_allocator);
var _local8:b2ContactSolver = m_contactSolver;
_local8.InitVelocityConstraints(_arg1);
_local4 = 0;
while (_local4 < m_jointCount) {
_local7 = m_joints[_local4];
_local7.InitVelocityConstraints(_arg1);
_local4++;
};
_local4 = 0;
while (_local4 < _arg1.velocityIterations) {
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local7.SolveVelocityConstraints(_arg1);
_local5++;
};
_local8.SolveVelocityConstraints();
_local4++;
};
_local4 = 0;
while (_local4 < m_jointCount) {
_local7 = m_joints[_local4];
_local7.FinalizeVelocityConstraints();
_local4++;
};
_local8.FinalizeVelocityConstraints();
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.GetType() == b2Body.b2_staticBody){
} else {
_local9 = (_arg1.dt * _local6.m_linearVelocity.x);
_local10 = (_arg1.dt * _local6.m_linearVelocity.y);
if (((_local9 * _local9) + (_local10 * _local10)) > b2Settings.b2_maxTranslationSquared){
_local6.m_linearVelocity.Normalize();
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
};
_local11 = (_arg1.dt * _local6.m_angularVelocity);
if (((_arg1.dt * _local6.m_angularVelocity) * _local11) > b2Settings.b2_maxRotationSquared){
if (_local6.m_angularVelocity < 0){
_local6.m_angularVelocity = (-(b2Settings.b2_maxRotation) * _arg1.inv_dt);
} else {
_local6.m_angularVelocity = (b2Settings.b2_maxRotation * _arg1.inv_dt);
};
};
_local6.m_sweep.c0.SetV(_local6.m_sweep.c);
_local6.m_sweep.a0 = _local6.m_sweep.a;
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y));
_local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity));
_local6.SynchronizeTransform();
};
_local4++;
};
_local4 = 0;
while (_local4 < _arg1.positionIterations) {
_local12 = _local8.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local13 = true;
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local14 = _local7.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local13 = ((_local13) && (_local14));
_local5++;
};
if (((_local12) && (_local13))){
break;
};
_local4++;
};
Report(_local8.m_constraints);
if (_arg3){
_local15 = Number.MAX_VALUE;
_local16 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
_local17 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.GetType() == b2Body.b2_staticBody){
} else {
if ((_local6.m_flags & b2Body.e_allowSleepFlag) == 0){
_local6.m_sleepTime = 0;
_local15 = 0;
};
if (((((((_local6.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local6.m_angularVelocity * _local6.m_angularVelocity) > _local17)))) || ((b2Math.Dot(_local6.m_linearVelocity, _local6.m_linearVelocity) > _local16)))){
_local6.m_sleepTime = 0;
_local15 = 0;
} else {
_local6.m_sleepTime = (_local6.m_sleepTime + _arg1.dt);
_local15 = b2Math.Min(_local15, _local6.m_sleepTime);
};
};
_local4++;
};
if (_local15 >= b2Settings.b2_timeToSleep){
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
_local6.SetAwake(false);
_local4++;
};
};
};
}
public function Clear():void{
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function SolveTOI(_arg1:b2TimeStep):void{
var _local2:int;
var _local3:int;
var _local6:b2Body;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Boolean;
var _local11:Boolean;
var _local12:Boolean;
m_contactSolver.Initialize(_arg1, m_contacts, m_contactCount, m_allocator);
var _local4:b2ContactSolver = m_contactSolver;
_local2 = 0;
while (_local2 < m_jointCount) {
m_joints[_local2].InitVelocityConstraints(_arg1);
_local2++;
};
_local2 = 0;
while (_local2 < _arg1.velocityIterations) {
_local4.SolveVelocityConstraints();
_local3 = 0;
while (_local3 < m_jointCount) {
m_joints[_local3].SolveVelocityConstraints(_arg1);
_local3++;
};
_local2++;
};
_local2 = 0;
while (_local2 < m_bodyCount) {
_local6 = m_bodies[_local2];
if (_local6.GetType() == b2Body.b2_staticBody){
} else {
_local7 = (_arg1.dt * _local6.m_linearVelocity.x);
_local8 = (_arg1.dt * _local6.m_linearVelocity.y);
if (((_local7 * _local7) + (_local8 * _local8)) > b2Settings.b2_maxTranslationSquared){
_local6.m_linearVelocity.Normalize();
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
};
_local9 = (_arg1.dt * _local6.m_angularVelocity);
if (((_arg1.dt * _local6.m_angularVelocity) * _local9) > b2Settings.b2_maxRotationSquared){
if (_local6.m_angularVelocity < 0){
_local6.m_angularVelocity = (-(b2Settings.b2_maxRotation) * _arg1.inv_dt);
} else {
_local6.m_angularVelocity = (b2Settings.b2_maxRotation * _arg1.inv_dt);
};
};
_local6.m_sweep.c0.SetV(_local6.m_sweep.c);
_local6.m_sweep.a0 = _local6.m_sweep.a;
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y));
_local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity));
_local6.SynchronizeTransform();
};
_local2++;
};
var _local5:Number = 0.75;
_local2 = 0;
while (_local2 < _arg1.positionIterations) {
_local10 = _local4.SolvePositionConstraints(_local5);
_local11 = true;
_local3 = 0;
while (_local3 < m_jointCount) {
_local12 = m_joints[_local3].SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local11 = ((_local11) && (_local12));
_local3++;
};
if (((_local10) && (_local11))){
break;
};
_local2++;
};
Report(_local4.m_constraints);
}
public function Initialize(_arg1:int, _arg2:int, _arg3:int, _arg4, _arg5:b2ContactListener, _arg6:b2ContactSolver):void{
var _local7:int;
m_bodyCapacity = _arg1;
m_contactCapacity = _arg2;
m_jointCapacity = _arg3;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_allocator = _arg4;
m_listener = _arg5;
m_contactSolver = _arg6;
_local7 = m_bodies.length;
while (_local7 < _arg1) {
m_bodies[_local7] = null;
_local7++;
};
_local7 = m_contacts.length;
while (_local7 < _arg2) {
m_contacts[_local7] = null;
_local7++;
};
_local7 = m_joints.length;
while (_local7 < _arg3) {
m_joints[_local7] = null;
_local7++;
};
}
}
}//package Box2D.Dynamics
Section 150
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var warmStarting:Boolean;
public var inv_dt:Number;
public var dt:Number;
public var velocityIterations:int;
public var dtRatio:Number;
public var positionIterations:int;
public function Set(_arg1:b2TimeStep):void{
dt = _arg1.dt;
inv_dt = _arg1.inv_dt;
positionIterations = _arg1.positionIterations;
velocityIterations = _arg1.velocityIterations;
warmStarting = _arg1.warmStarting;
}
}
}//package Box2D.Dynamics
Section 151
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2World {
private var m_inv_dt0:Number;
private var m_contactSolver:b2ContactSolver;
private var m_controllerList:b2Controller;
b2internal var m_contactList:b2Contact;
private var m_controllerCount:int;
private var m_allowSleep:Boolean;
private var m_island:b2Island;
b2internal var m_flags:int;
private var m_jointCount:int;
private var m_bodyCount:int;
private var s_stack:Array;
private var m_destructionListener:b2DestructionListener;
b2internal var m_groundBody:b2Body;
b2internal var m_contactCount:int;
private var m_debugDraw:b2DebugDraw;
b2internal var m_bodyList:b2Body;
private var m_jointList:b2Joint;
private var m_gravity:b2Vec2;
b2internal var m_contactManager:b2ContactManager;
public static const e_newFixture:int = 1;
public static const e_locked:int = 2;
private static var s_timestep:b2TimeStep = new b2TimeStep();
private static var s_queue:Array = new Array();
private static var s_timestep2:b2TimeStep = new b2TimeStep();
private static var s_backupA:b2Sweep = new b2Sweep();
private static var m_continuousPhysics:Boolean;
private static var m_warmStarting:Boolean;
private static var s_xf:b2Transform = new b2Transform();
private static var s_backupB:b2Sweep = new b2Sweep();
private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8);
public function b2World(_arg1:b2Vec2, _arg2:Boolean){
s_stack = new Array();
m_contactManager = new b2ContactManager();
m_contactSolver = new b2ContactSolver();
m_island = new b2Island();
super();
m_destructionListener = null;
m_debugDraw = null;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_controllerList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_controllerCount = 0;
m_warmStarting = true;
m_continuousPhysics = true;
m_allowSleep = _arg2;
m_gravity = _arg1;
m_inv_dt0 = 0;
m_contactManager.m_world = this;
var _local3:b2BodyDef = new b2BodyDef();
m_groundBody = CreateBody(_local3);
}
b2internal function DrawJoint(_arg1:b2Joint):void{
var _local11:b2PulleyJoint;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local2:b2Body = _arg1.GetBodyA();
var _local3:b2Body = _arg1.GetBodyB();
var _local4:b2Transform = _local2.m_xf;
var _local5:b2Transform = _local3.m_xf;
var _local6:b2Vec2 = _local4.position;
var _local7:b2Vec2 = _local5.position;
var _local8:b2Vec2 = _arg1.GetAnchorA();
var _local9:b2Vec2 = _arg1.GetAnchorB();
var _local10:b2Color = s_jointColor;
switch (_arg1.m_type){
case b2Joint.e_distanceJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
case b2Joint.e_pulleyJoint:
_local11 = (_arg1 as b2PulleyJoint);
_local12 = _local11.GetGroundAnchorA();
_local13 = _local11.GetGroundAnchorB();
m_debugDraw.DrawSegment(_local12, _local8, _local10);
m_debugDraw.DrawSegment(_local13, _local9, _local10);
m_debugDraw.DrawSegment(_local12, _local13, _local10);
break;
case b2Joint.e_mouseJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
default:
if (_local2 != m_groundBody){
m_debugDraw.DrawSegment(_local6, _local8, _local10);
};
m_debugDraw.DrawSegment(_local8, _local9, _local10);
if (_local3 != m_groundBody){
m_debugDraw.DrawSegment(_local7, _local9, _local10);
};
};
}
public function RayCastAll(_arg1:b2Vec2, _arg2:b2Vec2):Array{
var result:Array;
var RayCastAllWrapper:Function;
var point1 = _arg1;
var point2 = _arg2;
RayCastAllWrapper = function (_arg1:b2Fixture, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Number{
result[result.length] = _arg1;
return (1);
};
result = new Array();
RayCast(RayCastAllWrapper, point1, point2);
return (result);
}
public function QueryAABB(_arg1:Function, _arg2:b2AABB):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = _arg1;
var aabb = _arg2;
WorldQueryWrapper = function (_arg1):Boolean{
return (callback(broadPhase.GetUserData(_arg1)));
};
broadPhase = m_contactManager.m_broadPhase;
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function GetJointCount():int{
return (m_jointCount);
}
public function SetDebugDraw(_arg1:b2DebugDraw):void{
m_debugDraw = _arg1;
}
public function SetContinuousPhysics(_arg1:Boolean):void{
m_continuousPhysics = _arg1;
}
public function GetProxyCount():int{
return (m_contactManager.m_broadPhase.GetProxyCount());
}
public function DrawDebugData():void{
var _local2:int;
var _local3:b2Body;
var _local4:b2Fixture;
var _local5:b2Shape;
var _local6:b2Joint;
var _local7:IBroadPhase;
var _local11:b2Transform;
var _local16:b2Controller;
var _local17:b2Contact;
var _local18:b2Fixture;
var _local19:b2Fixture;
var _local20:b2Vec2;
var _local21:b2Vec2;
var _local22:b2AABB;
if (m_debugDraw == null){
return;
};
m_debugDraw.m_sprite.graphics.clear();
var _local1:uint = m_debugDraw.GetFlags();
var _local8:b2Vec2 = new b2Vec2();
var _local9:b2Vec2 = new b2Vec2();
var _local10:b2Vec2 = new b2Vec2();
var _local12:b2AABB = new b2AABB();
var _local13:b2AABB = new b2AABB();
var _local14:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
var _local15:b2Color = new b2Color(0, 0, 0);
if ((_local1 & b2DebugDraw.e_shapeBit)){
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetFixtureList();
while (_local4) {
_local5 = _local4.GetShape();
if (_local3.IsActive() == false){
_local15.Set(0.5, 0.5, 0.3);
DrawShape(_local5, _local11, _local15);
} else {
if (_local3.GetType() == b2Body.b2_staticBody){
_local15.Set(0.5, 0.9, 0.5);
DrawShape(_local5, _local11, _local15);
} else {
if (_local3.GetType() == b2Body.b2_kinematicBody){
_local15.Set(0.5, 0.5, 0.9);
DrawShape(_local5, _local11, _local15);
} else {
if (_local3.IsAwake() == false){
_local15.Set(0.6, 0.6, 0.6);
DrawShape(_local5, _local11, _local15);
} else {
_local15.Set(0.9, 0.7, 0.7);
DrawShape(_local5, _local11, _local15);
};
};
};
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
if ((_local1 & b2DebugDraw.e_jointBit)){
_local6 = m_jointList;
while (_local6) {
DrawJoint(_local6);
_local6 = _local6.m_next;
};
};
if ((_local1 & b2DebugDraw.e_controllerBit)){
_local16 = m_controllerList;
while (_local16) {
_local16.Draw(m_debugDraw);
_local16 = _local16.m_next;
};
};
if ((_local1 & b2DebugDraw.e_pairBit)){
_local15.Set(0.3, 0.9, 0.9);
_local17 = m_contactManager.m_contactList;
while (_local17) {
_local18 = _local17.GetFixtureA();
_local19 = _local17.GetFixtureB();
_local20 = _local18.GetAABB().GetCenter();
_local21 = _local19.GetAABB().GetCenter();
m_debugDraw.DrawSegment(_local20, _local21, _local15);
_local17 = _local17.GetNext();
};
};
if ((_local1 & b2DebugDraw.e_aabbBit)){
_local7 = m_contactManager.m_broadPhase;
_local14 = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
_local3 = m_bodyList;
while (_local3) {
if (_local3.IsActive() == false){
} else {
_local4 = _local3.GetFixtureList();
while (_local4) {
_local22 = _local7.GetFatAABB(_local4.m_proxy);
_local14[0].Set(_local22.lowerBound.x, _local22.lowerBound.y);
_local14[1].Set(_local22.upperBound.x, _local22.lowerBound.y);
_local14[2].Set(_local22.upperBound.x, _local22.upperBound.y);
_local14[3].Set(_local22.lowerBound.x, _local22.upperBound.y);
m_debugDraw.DrawPolygon(_local14, 4, _local15);
_local4 = _local4.GetNext();
};
};
_local3 = _local3.GetNext();
};
};
if ((_local1 & b2DebugDraw.e_centerOfMassBit)){
_local3 = m_bodyList;
while (_local3) {
_local11 = s_xf;
_local11.R = _local3.m_xf.R;
_local11.position = _local3.GetWorldCenter();
m_debugDraw.DrawTransform(_local11);
_local3 = _local3.m_next;
};
};
}
public function DestroyBody(_arg1:b2Body):void{
var _local6:b2JointEdge;
var _local7:b2ControllerEdge;
var _local8:b2ContactEdge;
var _local9:b2Fixture;
if (IsLocked() == true){
return;
};
var _local2:b2JointEdge = _arg1.m_jointList;
while (_local2) {
_local6 = _local2;
_local2 = _local2.next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeJoint(_local6.joint);
};
DestroyJoint(_local6.joint);
};
var _local3:b2ControllerEdge = _arg1.m_controllerList;
while (_local3) {
_local7 = _local3;
_local3 = _local3.nextController;
_local7.controller.RemoveBody(_arg1);
};
var _local4:b2ContactEdge = _arg1.m_contactList;
while (_local4) {
_local8 = _local4;
_local4 = _local4.next;
m_contactManager.Destroy(_local8.contact);
};
_arg1.m_contactList = null;
var _local5:b2Fixture = _arg1.m_fixtureList;
while (_local5) {
_local9 = _local5;
_local5 = _local5.m_next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeFixture(_local9);
};
_local9.DestroyProxy(m_contactManager.m_broadPhase);
_local9.Destroy();
};
_arg1.m_fixtureList = null;
_arg1.m_fixtureCount = 0;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_bodyList){
m_bodyList = _arg1.m_next;
};
m_bodyCount--;
}
b2internal function DrawShape(_arg1:b2Shape, _arg2:b2Transform, _arg3:b2Color):void{
var _local4:b2CircleShape;
var _local5:b2Vec2;
var _local6:Number;
var _local7:b2Vec2;
var _local8:int;
var _local9:b2PolygonShape;
var _local10:int;
var _local11:Array;
var _local12:Array;
var _local13:b2EdgeShape;
switch (_arg1.m_type){
case b2Shape.e_circleShape:
_local4 = (_arg1 as b2CircleShape);
_local5 = b2Math.MulX(_arg2, _local4.m_p);
_local6 = _local4.m_radius;
_local7 = _arg2.R.col1;
m_debugDraw.DrawSolidCircle(_local5, _local6, _local7, _arg3);
break;
case b2Shape.e_polygonShape:
_local9 = (_arg1 as b2PolygonShape);
_local10 = _local9.GetVertexCount();
_local11 = _local9.GetVertices();
_local12 = new Array(_local10);
_local8 = 0;
while (_local8 < _local10) {
_local12[_local8] = b2Math.MulX(_arg2, _local11[_local8]);
_local8++;
};
m_debugDraw.DrawSolidPolygon(_local12, _local10, _arg3);
break;
case b2Shape.e_edgeShape:
_local13 = (_arg1 as b2EdgeShape);
m_debugDraw.DrawSegment(b2Math.MulX(_arg2, _local13.GetVertex1()), b2Math.MulX(_arg2, _local13.GetVertex2()), _arg3);
break;
};
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function DestroyController(_arg1:b2Controller):void{
_arg1.Clear();
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1 == m_controllerList){
m_controllerList = _arg1.m_next;
};
m_controllerCount--;
}
b2internal function Solve(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local10:int;
var _local11:int;
var _local12:b2Body;
var _local13:b2ContactEdge;
var _local14:b2JointEdge;
var _local3:b2Controller = m_controllerList;
while (_local3) {
_local3.Step(_arg1);
_local3 = _local3.m_next;
};
var _local4:b2Island = m_island;
_local4.Initialize(m_bodyCount, m_contactCount, m_jointCount, null, m_contactManager.m_contactListener, m_contactSolver);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2 = _local2.m_next;
};
var _local5:b2Contact = m_contactList;
while (_local5) {
_local5.m_flags = (_local5.m_flags & ~(b2Contact.e_islandFlag));
_local5 = _local5.m_next;
};
var _local6:b2Joint = m_jointList;
while (_local6) {
_local6.m_islandFlag = false;
_local6 = _local6.m_next;
};
var _local7:int = m_bodyCount;
var _local8:Array = s_stack;
var _local9:b2Body = m_bodyList;
while (_local9) {
if ((_local9.m_flags & b2Body.e_islandFlag)){
} else {
if ((((_local9.IsAwake() == false)) || ((_local9.IsActive() == false)))){
} else {
if (_local9.GetType() == b2Body.b2_staticBody){
} else {
_local4.Clear();
_local10 = 0;
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local15 = _temp1;
_local8[_local15] = _local9;
_local9.m_flags = (_local9.m_flags | b2Body.e_islandFlag);
while (_local10 > 0) {
--_local10;
_local2 = _local8[_local10];
_local4.AddBody(_local2);
if (_local2.IsAwake() == false){
_local2.SetAwake(true);
};
if (_local2.GetType() == b2Body.b2_staticBody){
} else {
_local13 = _local2.m_contactList;
while (_local13) {
if ((_local13.contact.m_flags & b2Contact.e_islandFlag)){
} else {
if ((((((_local13.contact.IsSensor() == true)) || ((_local13.contact.IsEnabled() == false)))) || ((_local13.contact.IsTouching() == false)))){
} else {
_local4.AddContact(_local13.contact);
_local13.contact.m_flags = (_local13.contact.m_flags | b2Contact.e_islandFlag);
_local12 = _local13.other;
if ((_local12.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = _local10;
_local10 = (_local10 + 1);
var _local16 = _temp2;
_local8[_local16] = _local12;
_local12.m_flags = (_local12.m_flags | b2Body.e_islandFlag);
};
};
};
_local13 = _local13.next;
};
_local14 = _local2.m_jointList;
while (_local14) {
if (_local14.joint.m_islandFlag == true){
} else {
_local12 = _local14.other;
if (_local12.IsActive() == false){
} else {
_local4.AddJoint(_local14.joint);
_local14.joint.m_islandFlag = true;
if ((_local12.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = _local10;
_local10 = (_local10 + 1);
_local16 = _temp3;
_local8[_local16] = _local12;
_local12.m_flags = (_local12.m_flags | b2Body.e_islandFlag);
};
};
};
_local14 = _local14.next;
};
};
};
_local4.Solve(_arg1, m_gravity, m_allowSleep);
_local11 = 0;
while (_local11 < _local4.m_bodyCount) {
_local2 = _local4.m_bodies[_local11];
if (_local2.GetType() == b2Body.b2_staticBody){
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
};
_local11++;
};
};
};
};
_local9 = _local9.m_next;
};
_local11 = 0;
while (_local11 < _local8.length) {
if (!_local8[_local11]){
break;
};
_local8[_local11] = null;
_local11++;
};
_local2 = m_bodyList;
while (_local2) {
if ((((_local2.IsAwake() == false)) || ((_local2.IsActive() == false)))){
} else {
if (_local2.GetType() == b2Body.b2_staticBody){
} else {
_local2.SynchronizeFixtures();
};
};
_local2 = _local2.m_next;
};
m_contactManager.FindNewContacts();
}
public function SetGravity(_arg1:b2Vec2):void{
m_gravity = _arg1;
}
public function SetContactFilter(_arg1:b2ContactFilter):void{
m_contactManager.m_contactFilter = _arg1;
}
b2internal function SolveTOI(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Fixture;
var _local4:b2Fixture;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactEdge;
var _local8:b2Joint;
var _local11:b2Contact;
var _local12:b2Contact;
var _local13:Number;
var _local14:b2Body;
var _local15:int;
var _local16:int;
var _local17:b2JointEdge;
var _local18:b2TimeStep;
var _local19:int;
var _local20:Number;
var _local21:Number;
var _local22:b2Body;
var _local9:b2Island = m_island;
_local9.Initialize(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, null, m_contactManager.m_contactListener, m_contactSolver);
var _local10:Array = s_queue;
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2.m_sweep.t0 = 0;
_local2 = _local2.m_next;
};
_local11 = m_contactList;
while (_local11) {
_local11.m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local11 = _local11.m_next;
};
_local8 = m_jointList;
while (_local8) {
_local8.m_islandFlag = false;
_local8 = _local8.m_next;
};
while (true) {
_local12 = null;
_local13 = 1;
_local11 = m_contactList;
for (;_local11;(_local11 = _local11.m_next)) {
if ((((((_local11.IsSensor() == true)) || ((_local11.IsEnabled() == false)))) || ((_local11.IsContinuous() == false)))){
} else {
_local20 = 1;
if ((_local11.m_flags & b2Contact.e_toiFlag)){
_local20 = _local11.m_toi;
} else {
_local3 = _local11.m_fixtureA;
_local4 = _local11.m_fixtureB;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
if (((((!((_local5.GetType() == b2Body.b2_dynamicBody))) || ((_local5.IsAwake() == false)))) && (((!((_local6.GetType() == b2Body.b2_dynamicBody))) || ((_local6.IsAwake() == false)))))){
continue;
};
_local21 = _local5.m_sweep.t0;
if (_local5.m_sweep.t0 < _local6.m_sweep.t0){
_local21 = _local6.m_sweep.t0;
_local5.m_sweep.Advance(_local21);
} else {
if (_local6.m_sweep.t0 < _local5.m_sweep.t0){
_local21 = _local5.m_sweep.t0;
_local6.m_sweep.Advance(_local21);
};
};
_local20 = _local11.ComputeTOI(_local5.m_sweep, _local6.m_sweep);
b2Settings.b2Assert((((0 <= _local20)) && ((_local20 <= 1))));
if ((((_local20 > 0)) && ((_local20 < 1)))){
_local20 = (((1 - _local20) * _local21) + _local20);
if (_local20 > 1){
_local20 = 1;
};
};
_local11.m_toi = _local20;
_local11.m_flags = (_local11.m_flags | b2Contact.e_toiFlag);
};
if ((((Number.MIN_VALUE < _local20)) && ((_local20 < _local13)))){
_local12 = _local11;
_local13 = _local20;
};
};
};
if ((((_local12 == null)) || (((1 - (100 * Number.MIN_VALUE)) < _local13)))){
break;
};
_local3 = _local12.m_fixtureA;
_local4 = _local12.m_fixtureB;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
s_backupA.Set(_local5.m_sweep);
s_backupB.Set(_local6.m_sweep);
_local5.Advance(_local13);
_local6.Advance(_local13);
_local12.Update(m_contactManager.m_contactListener);
_local12.m_flags = (_local12.m_flags & ~(b2Contact.e_toiFlag));
if ((((_local12.IsSensor() == true)) || ((_local12.IsEnabled() == false)))){
_local5.m_sweep.Set(s_backupA);
_local6.m_sweep.Set(s_backupB);
_local5.SynchronizeTransform();
_local6.SynchronizeTransform();
} else {
if (_local12.IsTouching() == false){
} else {
_local14 = _local5;
if (_local14.GetType() != b2Body.b2_dynamicBody){
_local14 = _local6;
};
_local9.Clear();
_local15 = 0;
_local16 = 0;
var _temp1 = _local16;
_local16 = (_local16 + 1);
_local10[(_local15 + _temp1)] = _local14;
_local14.m_flags = (_local14.m_flags | b2Body.e_islandFlag);
while (_local16 > 0) {
var _temp2 = _local15;
_local15 = (_local15 + 1);
_local2 = _local10[_temp2];
_local16--;
_local9.AddBody(_local2);
if (_local2.IsAwake() == false){
_local2.SetAwake(true);
};
if (_local2.GetType() != b2Body.b2_dynamicBody){
} else {
_local7 = _local2.m_contactList;
while (_local7) {
if (_local9.m_contactCount == _local9.m_contactCapacity){
break;
};
if ((_local7.contact.m_flags & b2Contact.e_islandFlag)){
} else {
if ((((((_local7.contact.IsSensor() == true)) || ((_local7.contact.IsEnabled() == false)))) || ((_local7.contact.IsTouching() == false)))){
} else {
_local9.AddContact(_local7.contact);
_local7.contact.m_flags = (_local7.contact.m_flags | b2Contact.e_islandFlag);
_local22 = _local7.other;
if ((_local22.m_flags & b2Body.e_islandFlag)){
} else {
if (_local22.GetType() != b2Body.b2_staticBody){
_local22.Advance(_local13);
_local22.SetAwake(true);
};
_local10[(_local15 + _local16)] = _local22;
_local16++;
_local22.m_flags = (_local22.m_flags | b2Body.e_islandFlag);
};
};
};
_local7 = _local7.next;
};
};
};
_local17 = _local2.m_jointList;
while (_local17) {
if (_local9.m_jointCount == _local9.m_jointCapacity){
} else {
if (_local17.joint.m_islandFlag == true){
} else {
_local22 = _local17.other;
if (_local22.IsActive() == false){
} else {
_local9.AddJoint(_local17.joint);
_local17.joint.m_islandFlag = true;
if ((_local22.m_flags & b2Body.e_islandFlag)){
} else {
if (_local22.GetType() != b2Body.b2_staticBody){
_local22.Advance(_local13);
_local22.SetAwake(true);
};
_local10[(_local15 + _local16)] = _local22;
_local16++;
_local22.m_flags = (_local22.m_flags | b2Body.e_islandFlag);
};
};
};
};
_local17 = _local17.next;
};
_local18 = s_timestep;
_local18.warmStarting = false;
_local18.dt = ((1 - _local13) * _arg1.dt);
_local18.inv_dt = (1 / _local18.dt);
_local18.dtRatio = 0;
_local18.velocityIterations = _arg1.velocityIterations;
_local18.positionIterations = _arg1.positionIterations;
_local9.SolveTOI(_local18);
_local19 = 0;
while (_local19 < _local9.m_bodyCount) {
_local2 = _local9.m_bodies[_local19];
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
if (_local2.IsAwake() == false){
} else {
if (_local2.GetType() != b2Body.b2_dynamicBody){
} else {
_local2.SynchronizeFixtures();
_local7 = _local2.m_contactList;
while (_local7) {
_local7.contact.m_flags = (_local7.contact.m_flags & ~(b2Contact.e_toiFlag));
_local7 = _local7.next;
};
};
};
_local19++;
};
_local19 = 0;
while (_local19 < _local9.m_contactCount) {
_local11 = _local9.m_contacts[_local19];
_local9.m_contacts[_local19].m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local19++;
};
_local19 = 0;
while (_local19 < _local9.m_jointCount) {
_local8 = _local9.m_joints[_local19];
_local8.m_islandFlag = false;
_local19++;
};
m_contactManager.FindNewContacts();
};
};
};
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function GetContactCount():int{
return (m_contactCount);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
public function GetGravity():b2Vec2{
return (m_gravity);
}
public function RayCastOne(_arg1:b2Vec2, _arg2:b2Vec2):b2Fixture{
var result:b2Fixture;
var RayCastOneWrapper:Function;
var point1 = _arg1;
var point2 = _arg2;
RayCastOneWrapper = function (_arg1:b2Fixture, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Number{
result = _arg1;
return (_arg4);
};
RayCast(RayCastOneWrapper, point1, point2);
return (result);
}
public function Validate():void{
m_contactManager.m_broadPhase.Validate();
}
public function SetWarmStarting(_arg1:Boolean):void{
m_warmStarting = _arg1;
}
public function QueryPoint(_arg1:Function, _arg2:b2Vec2):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = _arg1;
var p = _arg2;
WorldQueryWrapper = function (_arg1):Boolean{
var _local2:b2Fixture = (broadPhase.GetUserData(_arg1) as b2Fixture);
if (_local2.TestPoint(p)){
return (callback(_local2));
};
return (true);
};
broadPhase = m_contactManager.m_broadPhase;
var aabb:b2AABB = new b2AABB();
aabb.lowerBound.Set((p.x - b2Settings.b2_linearSlop), (p.y - b2Settings.b2_linearSlop));
aabb.upperBound.Set((p.x + b2Settings.b2_linearSlop), (p.y + b2Settings.b2_linearSlop));
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function CreateJoint(_arg1:b2JointDef):b2Joint{
var _local5:b2ContactEdge;
var _local2:b2Joint = b2Joint.Create(_arg1, null);
_local2.m_prev = null;
_local2.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = _local2;
};
m_jointList = _local2;
m_jointCount++;
_local2.m_edgeA.joint = _local2;
_local2.m_edgeA.other = _local2.m_bodyB;
_local2.m_edgeA.prev = null;
_local2.m_edgeA.next = _local2.m_bodyA.m_jointList;
if (_local2.m_bodyA.m_jointList){
_local2.m_bodyA.m_jointList.prev = _local2.m_edgeA;
};
_local2.m_bodyA.m_jointList = _local2.m_edgeA;
_local2.m_edgeB.joint = _local2;
_local2.m_edgeB.other = _local2.m_bodyA;
_local2.m_edgeB.prev = null;
_local2.m_edgeB.next = _local2.m_bodyB.m_jointList;
if (_local2.m_bodyB.m_jointList){
_local2.m_bodyB.m_jointList.prev = _local2.m_edgeB;
};
_local2.m_bodyB.m_jointList = _local2.m_edgeB;
var _local3:b2Body = _arg1.bodyA;
var _local4:b2Body = _arg1.bodyB;
if (_arg1.collideConnected == false){
_local5 = _local4.GetContactList();
while (_local5) {
if (_local5.other == _local3){
_local5.contact.FlagForFiltering();
};
_local5 = _local5.next;
};
};
return (_local2);
}
public function GetContactList():b2Contact{
return (m_contactList);
}
public function DestroyJoint(_arg1:b2Joint):void{
var _local5:b2ContactEdge;
var _local2:Boolean = _arg1.m_collideConnected;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_jointList){
m_jointList = _arg1.m_next;
};
var _local3:b2Body = _arg1.m_bodyA;
var _local4:b2Body = _arg1.m_bodyB;
_local3.SetAwake(true);
_local4.SetAwake(true);
if (_arg1.m_edgeA.prev){
_arg1.m_edgeA.prev.next = _arg1.m_edgeA.next;
};
if (_arg1.m_edgeA.next){
_arg1.m_edgeA.next.prev = _arg1.m_edgeA.prev;
};
if (_arg1.m_edgeA == _local3.m_jointList){
_local3.m_jointList = _arg1.m_edgeA.next;
};
_arg1.m_edgeA.prev = null;
_arg1.m_edgeA.next = null;
if (_arg1.m_edgeB.prev){
_arg1.m_edgeB.prev.next = _arg1.m_edgeB.next;
};
if (_arg1.m_edgeB.next){
_arg1.m_edgeB.next.prev = _arg1.m_edgeB.prev;
};
if (_arg1.m_edgeB == _local4.m_jointList){
_local4.m_jointList = _arg1.m_edgeB.next;
};
_arg1.m_edgeB.prev = null;
_arg1.m_edgeB.next = null;
b2Joint.Destroy(_arg1, null);
m_jointCount--;
if (_local2 == false){
_local5 = _local4.GetContactList();
while (_local5) {
if (_local5.other == _local3){
_local5.contact.FlagForFiltering();
};
_local5 = _local5.next;
};
};
}
public function SetContactListener(_arg1:b2ContactListener):void{
m_contactManager.m_contactListener = _arg1;
}
public function CreateController(_arg1:b2Controller):b2Controller{
if (_arg1.m_world != this){
throw (new Error("Controller can only be a member of one world"));
};
_arg1.m_next = m_controllerList;
_arg1.m_prev = null;
if (m_controllerList){
m_controllerList.m_prev = _arg1;
};
m_controllerList = _arg1;
m_controllerCount++;
_arg1.m_world = this;
return (_arg1);
}
public function QueryShape(_arg1:Function, _arg2:b2Shape, _arg3:b2Transform=null):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = _arg1;
var shape = _arg2;
var transform = _arg3;
WorldQueryWrapper = function (_arg1):Boolean{
var _local2:b2Fixture = (broadPhase.GetUserData(_arg1) as b2Fixture);
if (b2Shape.TestOverlap(shape, transform, _local2.GetShape(), _local2.GetBody().GetTransform())){
return (callback(_local2));
};
return (true);
};
if (transform == null){
transform = new b2Transform();
transform.SetIdentity();
};
broadPhase = m_contactManager.m_broadPhase;
var aabb:b2AABB = new b2AABB();
shape.ComputeAABB(aabb, transform);
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function CreateBody(_arg1:b2BodyDef):b2Body{
if (IsLocked() == true){
return (null);
};
var _local2:b2Body = new b2Body(_arg1, this);
_local2.m_prev = null;
_local2.m_next = m_bodyList;
if (m_bodyList){
m_bodyList.m_prev = _local2;
};
m_bodyList = _local2;
m_bodyCount++;
return (_local2);
}
public function RemoveController(_arg1:b2Controller):void{
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (m_controllerList == _arg1){
m_controllerList = _arg1.m_next;
};
m_controllerCount--;
}
public function SetDestructionListener(_arg1:b2DestructionListener):void{
m_destructionListener = _arg1;
}
public function RayCast(_arg1:Function, _arg2:b2Vec2, _arg3:b2Vec2):void{
var broadPhase:IBroadPhase;
var output:b2RayCastOutput;
var RayCastWrapper:Function;
var callback = _arg1;
var point1 = _arg2;
var point2 = _arg3;
RayCastWrapper = function (_arg1:b2RayCastInput, _arg2):Number{
var _local6:Number;
var _local7:b2Vec2;
var _local3:* = broadPhase.GetUserData(_arg2);
var _local4:b2Fixture = (_local3 as b2Fixture);
var _local5:Boolean = _local4.RayCast(output, _arg1);
if (_local5){
_local6 = output.fraction;
_local7 = new b2Vec2((((1 - _local6) * point1.x) + (_local6 * point2.x)), (((1 - _local6) * point1.y) + (_local6 * point2.y)));
return (callback(_local4, _local7, output.normal, _local6));
};
return (_arg1.maxFraction);
};
broadPhase = m_contactManager.m_broadPhase;
output = new b2RayCastOutput();
var input:b2RayCastInput = new b2RayCastInput(point1, point2);
broadPhase.RayCast(RayCastWrapper, input);
}
public function Step(_arg1:Number, _arg2:int, _arg3:int):void{
if ((m_flags & e_newFixture)){
m_contactManager.FindNewContacts();
m_flags = (m_flags & ~(e_newFixture));
};
m_flags = (m_flags | e_locked);
var _local4:b2TimeStep = s_timestep2;
_local4.dt = _arg1;
_local4.velocityIterations = _arg2;
_local4.positionIterations = _arg3;
if (_arg1 > 0){
_local4.inv_dt = (1 / _arg1);
} else {
_local4.inv_dt = 0;
};
_local4.dtRatio = (m_inv_dt0 * _arg1);
_local4.warmStarting = m_warmStarting;
m_contactManager.Collide();
if (_local4.dt > 0){
Solve(_local4);
};
if (((m_continuousPhysics) && ((_local4.dt > 0)))){
SolveTOI(_local4);
};
if (_local4.dt > 0){
m_inv_dt0 = _local4.inv_dt;
};
m_flags = (m_flags & ~(e_locked));
}
public function IsLocked():Boolean{
return (((m_flags & e_locked) > 0));
}
public function ClearForces():void{
var _local1:b2Body = m_bodyList;
while (_local1) {
_local1.m_force.SetZero();
_local1.m_torque = 0;
_local1 = _local1.m_next;
};
}
public function GetBodyCount():int{
return (m_bodyCount);
}
public function SetBroadPhase(_arg1:IBroadPhase):void{
var _local4:b2Fixture;
var _local2:IBroadPhase = m_contactManager.m_broadPhase;
m_contactManager.m_broadPhase = _arg1;
var _local3:b2Body = m_bodyList;
while (_local3) {
_local4 = _local3.m_fixtureList;
while (_local4) {
_local4.m_proxy = _arg1.CreateProxy(_local2.GetFatAABB(_local4.m_proxy), _local4);
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
}
public function AddController(_arg1:b2Controller):b2Controller{
_arg1.m_next = m_controllerList;
_arg1.m_prev = null;
m_controllerList = _arg1;
_arg1.m_world = this;
m_controllerCount++;
return (_arg1);
}
}
}//package Box2D.Dynamics
Section 152
//AuxFunctions (caurina.transitions.AuxFunctions)
package caurina.transitions {
public class AuxFunctions {
public static function getObjectLength(_arg1:Object):uint{
var _local3:String;
var _local2:uint;
for (_local3 in _arg1) {
_local2++;
};
return (_local2);
}
public static function numberToG(_arg1:Number):Number{
return (((_arg1 & 0xFF00) >> 8));
}
public static function numberToB(_arg1:Number):Number{
return ((_arg1 & 0xFF));
}
public static function numberToR(_arg1:Number):Number{
return (((_arg1 & 0xFF0000) >> 16));
}
public static function concatObjects(... _args):Object{
var _local3:Object;
var _local5:String;
var _local2:Object = {};
var _local4:int;
while (_local4 < _args.length) {
_local3 = _args[_local4];
for (_local5 in _local3) {
if (_local3[_local5] == null){
delete _local2[_local5];
} else {
_local2[_local5] = _local3[_local5];
};
};
_local4++;
};
return (_local2);
}
}
}//package caurina.transitions
Section 153
//Equations (caurina.transitions.Equations)
package caurina.transitions {
public class Equations {
public function Equations(){
trace("Equations is a static class and should not be instantiated.");
}
public static function easeOutBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
if (_arg1 < (1 / 2.75)){
return (((_arg3 * ((7.5625 * _arg1) * _arg1)) + _arg2));
};
if (_arg1 < (2 / 2.75)){
_arg1 = (_arg1 - (1.5 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.75)) + _arg2));
};
if (_arg1 < (2.5 / 2.75)){
_arg1 = (_arg1 - (2.25 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.9375)) + _arg2));
};
_arg1 = (_arg1 - (2.625 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.984375)) + _arg2));
}
public static function easeInOutElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local7:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 == 2){
return ((_arg2 + _arg3));
};
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * (0.3 * 1.5)) : _arg5.period;
var _local8:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
if (_arg1 < 1){
--_arg1;
return (((-0.5 * ((_local8 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6)))) + _arg2));
};
--_arg1;
return ((((((_local8 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6))) * 0.5) + _arg3) + _arg2));
}
public static function easeInOutQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * _arg1) * _arg1) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
public static function easeInOutBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (((easeInBounce((_arg1 * 2), 0, _arg3, _arg4) * 0.5) + _arg2));
};
return ((((easeOutBounce(((_arg1 * 2) - _arg4), 0, _arg3, _arg4) * 0.5) + (_arg3 * 0.5)) + _arg2));
}
public static function easeInOutBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
_local6 = (_local6 * 1.525);
return ((((_arg3 / 2) * ((_arg1 * _arg1) * (((_local6 + 1) * _arg1) - _local6))) + _arg2));
};
_arg1 = (_arg1 - 2);
_local6 = (_local6 * 1.525);
return ((((_arg3 / 2) * (((_arg1 * _arg1) * (((_local6 + 1) * _arg1) + _local6)) + 2)) + _arg2));
}
public static function easeOutInCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutCubic((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInCubic(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeOutBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((_arg1 * _arg1) * (((_local6 + 1) * _arg1) + _local6)) + 1)) + _arg2));
}
public static function easeInOutSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((-(_arg3) / 2) * (Math.cos(((Math.PI * _arg1) / _arg4)) - 1)) + _arg2));
}
public static function easeInBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = (_arg1 / _arg4);
return (((((_arg3 * _arg1) * _arg1) * (((_local6 + 1) * _arg1) - _local6)) + _arg2));
}
public static function easeInQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeOutInQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuint((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuint(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutInBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutBounce((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInBounce(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function init():void{
Tweener.registerTransition("easenone", easeNone);
Tweener.registerTransition("linear", easeNone);
Tweener.registerTransition("easeinquad", easeInQuad);
Tweener.registerTransition("easeoutquad", easeOutQuad);
Tweener.registerTransition("easeinoutquad", easeInOutQuad);
Tweener.registerTransition("easeoutinquad", easeOutInQuad);
Tweener.registerTransition("easeincubic", easeInCubic);
Tweener.registerTransition("easeoutcubic", easeOutCubic);
Tweener.registerTransition("easeinoutcubic", easeInOutCubic);
Tweener.registerTransition("easeoutincubic", easeOutInCubic);
Tweener.registerTransition("easeinquart", easeInQuart);
Tweener.registerTransition("easeoutquart", easeOutQuart);
Tweener.registerTransition("easeinoutquart", easeInOutQuart);
Tweener.registerTransition("easeoutinquart", easeOutInQuart);
Tweener.registerTransition("easeinquint", easeInQuint);
Tweener.registerTransition("easeoutquint", easeOutQuint);
Tweener.registerTransition("easeinoutquint", easeInOutQuint);
Tweener.registerTransition("easeoutinquint", easeOutInQuint);
Tweener.registerTransition("easeinsine", easeInSine);
Tweener.registerTransition("easeoutsine", easeOutSine);
Tweener.registerTransition("easeinoutsine", easeInOutSine);
Tweener.registerTransition("easeoutinsine", easeOutInSine);
Tweener.registerTransition("easeincirc", easeInCirc);
Tweener.registerTransition("easeoutcirc", easeOutCirc);
Tweener.registerTransition("easeinoutcirc", easeInOutCirc);
Tweener.registerTransition("easeoutincirc", easeOutInCirc);
Tweener.registerTransition("easeinexpo", easeInExpo);
Tweener.registerTransition("easeoutexpo", easeOutExpo);
Tweener.registerTransition("easeinoutexpo", easeInOutExpo);
Tweener.registerTransition("easeoutinexpo", easeOutInExpo);
Tweener.registerTransition("easeinelastic", easeInElastic);
Tweener.registerTransition("easeoutelastic", easeOutElastic);
Tweener.registerTransition("easeinoutelastic", easeInOutElastic);
Tweener.registerTransition("easeoutinelastic", easeOutInElastic);
Tweener.registerTransition("easeinback", easeInBack);
Tweener.registerTransition("easeoutback", easeOutBack);
Tweener.registerTransition("easeinoutback", easeInOutBack);
Tweener.registerTransition("easeoutinback", easeOutInBack);
Tweener.registerTransition("easeinbounce", easeInBounce);
Tweener.registerTransition("easeoutbounce", easeOutBounce);
Tweener.registerTransition("easeinoutbounce", easeInOutBounce);
Tweener.registerTransition("easeoutinbounce", easeOutInBounce);
}
public static function easeOutExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg1)==_arg4) ? (_arg2 + _arg3) : (((_arg3 * 1.001) * (-(Math.pow(2, ((-10 * _arg1) / _arg4))) + 1)) + _arg2));
}
public static function easeOutInBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutBack((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInBack(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg1)==0) ? _arg2 : (((_arg3 * Math.pow(2, (10 * ((_arg1 / _arg4) - 1)))) + _arg2) - (_arg3 * 0.001)));
}
public static function easeInCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((((_arg3 * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeInQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeInOutCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((-(_arg3) / 2) * (Math.sqrt((1 - (_arg1 * _arg1))) - 1)) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (Math.sqrt((1 - (_arg1 * _arg1))) + 1)) + _arg2));
}
public static function easeInQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _arg1) * _arg1) + _arg2));
}
public static function easeInBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg3 - easeOutBounce((_arg4 - _arg1), 0, _arg3, _arg4)) + _arg2));
}
public static function easeOutInExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutExpo((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInExpo(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((-(_arg3) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 1)) + _arg2));
}
public static function easeInSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((-(_arg3) * Math.cos(((_arg1 / _arg4) * (Math.PI / 2)))) + _arg3) + _arg2));
}
public static function easeInOutQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((-(_arg3) / 2) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 2)) + _arg2));
}
public static function easeOutQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function easeOutInElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutElastic((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInElastic(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local7:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * 0.3) : _arg5.period;
var _local8:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
--_arg1;
return ((-(((_local8 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6)))) + _arg2));
}
public static function easeOutCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((_arg1 * _arg1) * _arg1) + 1)) + _arg2));
}
public static function easeOutQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 1)) + _arg2));
}
public static function easeOutInQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuad((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuad(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg3 * Math.sin(((_arg1 / _arg4) * (Math.PI / 2)))) + _arg2));
}
public static function easeInOutCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (((_arg1 * _arg1) * _arg1) + 2)) + _arg2));
}
public static function easeInOutQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 2)) + _arg2));
}
public static function easeInCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((-(_arg3) * (Math.sqrt((1 - (_arg1 * _arg1))) - 1)) + _arg2));
}
public static function easeOutInSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutSine((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInSine(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInOutExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 == 0){
return (_arg2);
};
if (_arg1 == _arg4){
return ((_arg2 + _arg3));
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * Math.pow(2, (10 * (_arg1 - 1)))) + _arg2) - (_arg3 * 0.0005)));
};
--_arg1;
return (((((_arg3 / 2) * 1.0005) * (-(Math.pow(2, (-10 * _arg1))) + 2)) + _arg2));
}
public static function easeOutElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local7:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * 0.3) : _arg5.period;
var _local8:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
return (((((_local8 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6))) + _arg3) + _arg2));
}
public static function easeOutCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * Math.sqrt((1 - (_arg1 * _arg1)))) + _arg2));
}
public static function easeOutInQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuart((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuart(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutInCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutCirc((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInCirc(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
}
}//package caurina.transitions
Section 154
//PropertyInfoObj (caurina.transitions.PropertyInfoObj)
package caurina.transitions {
public class PropertyInfoObj {
public var modifierParameters:Array;
public var isSpecialProperty:Boolean;
public var valueComplete:Number;
public var modifierFunction:Function;
public var extra:Object;
public var valueStart:Number;
public var hasModifier:Boolean;
public var arrayIndex:Number;
public var originalValueComplete:Object;
public function PropertyInfoObj(_arg1:Number, _arg2:Number, _arg3:Object, _arg4:Number, _arg5:Object, _arg6:Boolean, _arg7:Function, _arg8:Array){
valueStart = _arg1;
valueComplete = _arg2;
originalValueComplete = _arg3;
arrayIndex = _arg4;
extra = _arg5;
isSpecialProperty = _arg6;
hasModifier = Boolean(_arg7);
modifierFunction = _arg7;
modifierParameters = _arg8;
}
public function toString():String{
var _local1 = "\n[PropertyInfoObj ";
_local1 = (_local1 + ("valueStart:" + String(valueStart)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("valueComplete:" + String(valueComplete)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("originalValueComplete:" + String(originalValueComplete)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("arrayIndex:" + String(arrayIndex)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("extra:" + String(extra)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("isSpecialProperty:" + String(isSpecialProperty)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("hasModifier:" + String(hasModifier)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("modifierFunction:" + String(modifierFunction)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("modifierParameters:" + String(modifierParameters)));
_local1 = (_local1 + "]\n");
return (_local1);
}
public function clone():PropertyInfoObj{
var _local1:PropertyInfoObj = new PropertyInfoObj(valueStart, valueComplete, originalValueComplete, arrayIndex, extra, isSpecialProperty, modifierFunction, modifierParameters);
return (_local1);
}
}
}//package caurina.transitions
Section 155
//SpecialProperty (caurina.transitions.SpecialProperty)
package caurina.transitions {
public class SpecialProperty {
public var parameters:Array;
public var getValue:Function;
public var preProcess:Function;
public var setValue:Function;
public function SpecialProperty(_arg1:Function, _arg2:Function, _arg3:Array=null, _arg4:Function=null){
getValue = _arg1;
setValue = _arg2;
parameters = _arg3;
preProcess = _arg4;
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + "[SpecialProperty ");
_local1 = (_local1 + ("getValue:" + String(getValue)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("setValue:" + String(setValue)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("parameters:" + String(parameters)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("preProcess:" + String(preProcess)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 156
//SpecialPropertyModifier (caurina.transitions.SpecialPropertyModifier)
package caurina.transitions {
public class SpecialPropertyModifier {
public var getValue:Function;
public var modifyValues:Function;
public function SpecialPropertyModifier(_arg1:Function, _arg2:Function){
modifyValues = _arg1;
getValue = _arg2;
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + "[SpecialPropertyModifier ");
_local1 = (_local1 + ("modifyValues:" + String(modifyValues)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("getValue:" + String(getValue)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 157
//SpecialPropertySplitter (caurina.transitions.SpecialPropertySplitter)
package caurina.transitions {
public class SpecialPropertySplitter {
public var parameters:Array;
public var splitValues:Function;
public function SpecialPropertySplitter(_arg1:Function, _arg2:Array){
splitValues = _arg1;
parameters = _arg2;
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + "[SpecialPropertySplitter ");
_local1 = (_local1 + ("splitValues:" + String(splitValues)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("parameters:" + String(parameters)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 158
//Tweener (caurina.transitions.Tweener)
package caurina.transitions {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Tweener {
private static var _timeScale:Number = 1;
private static var _currentTimeFrame:Number;
private static var _specialPropertySplitterList:Object;
public static var autoOverwrite:Boolean = true;
private static var _engineExists:Boolean = false;
private static var _currentTime:Number;
private static var _tweenList:Array;
private static var _specialPropertyModifierList:Object;
private static var _specialPropertyList:Object;
private static var _transitionList:Object;
private static var _inited:Boolean = false;
private static var __tweener_controller__:MovieClip;
public function Tweener(){
trace("Tweener is a static class and should not be instantiated.");
}
public static function registerSpecialPropertyModifier(_arg1:String, _arg2:Function, _arg3:Function):void{
if (!_inited){
init();
};
var _local4:SpecialPropertyModifier = new SpecialPropertyModifier(_arg2, _arg3);
_specialPropertyModifierList[_arg1] = _local4;
}
public static function registerSpecialProperty(_arg1:String, _arg2:Function, _arg3:Function, _arg4:Array=null, _arg5:Function=null):void{
if (!_inited){
init();
};
var _local6:SpecialProperty = new SpecialProperty(_arg2, _arg3, _arg4, _arg5);
_specialPropertyList[_arg1] = _local6;
}
public static function init(... _args):void{
_inited = true;
_transitionList = new Object();
Equations.init();
_specialPropertyList = new Object();
_specialPropertyModifierList = new Object();
_specialPropertySplitterList = new Object();
}
private static function updateTweens():Boolean{
var _local1:int;
if (_tweenList.length == 0){
return (false);
};
_local1 = 0;
while (_local1 < _tweenList.length) {
if ((((_tweenList[_local1] == undefined)) || (!(_tweenList[_local1].isPaused)))){
if (!updateTweenByIndex(_local1)){
removeTweenByIndex(_local1);
};
if (_tweenList[_local1] == null){
removeTweenByIndex(_local1, true);
_local1--;
};
};
_local1++;
};
return (true);
}
public static function addCaller(_arg1:Object=null, _arg2:Object=null):Boolean{
var _local3:Number;
var _local4:Array;
var _local8:Function;
var _local9:TweenListObj;
var _local10:Number;
var _local11:String;
if (!Boolean(_arg1)){
return (false);
};
if ((_arg1 is Array)){
_local4 = _arg1.concat();
} else {
_local4 = [_arg1];
};
var _local5:Object = _arg2;
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var _local6:Number = (isNaN(_local5.time)) ? 0 : _local5.time;
var _local7:Number = (isNaN(_local5.delay)) ? 0 : _local5.delay;
if (typeof(_local5.transition) == "string"){
_local11 = _local5.transition.toLowerCase();
_local8 = _transitionList[_local11];
} else {
_local8 = _local5.transition;
};
if (!Boolean(_local8)){
_local8 = _transitionList["easeoutexpo"];
};
_local3 = 0;
while (_local3 < _local4.length) {
if (_local5.useFrames == true){
_local9 = new TweenListObj(_local4[_local3], (_currentTimeFrame + (_local7 / _timeScale)), (_currentTimeFrame + ((_local7 + _local6) / _timeScale)), true, _local8, _local5.transitionParams);
} else {
_local9 = new TweenListObj(_local4[_local3], (_currentTime + ((_local7 * 1000) / _timeScale)), (_currentTime + (((_local7 * 1000) + (_local6 * 1000)) / _timeScale)), false, _local8, _local5.transitionParams);
};
_local9.properties = null;
_local9.onStart = _local5.onStart;
_local9.onUpdate = _local5.onUpdate;
_local9.onComplete = _local5.onComplete;
_local9.onOverwrite = _local5.onOverwrite;
_local9.onStartParams = _local5.onStartParams;
_local9.onUpdateParams = _local5.onUpdateParams;
_local9.onCompleteParams = _local5.onCompleteParams;
_local9.onOverwriteParams = _local5.onOverwriteParams;
_local9.onStartScope = _local5.onStartScope;
_local9.onUpdateScope = _local5.onUpdateScope;
_local9.onCompleteScope = _local5.onCompleteScope;
_local9.onOverwriteScope = _local5.onOverwriteScope;
_local9.onErrorScope = _local5.onErrorScope;
_local9.isCaller = true;
_local9.count = _local5.count;
_local9.waitFrames = _local5.waitFrames;
_tweenList.push(_local9);
if ((((_local6 == 0)) && ((_local7 == 0)))){
_local10 = (_tweenList.length - 1);
updateTweenByIndex(_local10);
removeTweenByIndex(_local10);
};
_local3++;
};
return (true);
}
public static function pauseAllTweens():Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
var _local1:Boolean;
_local2 = 0;
while (_local2 < _tweenList.length) {
pauseTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
public static function removeTweens(_arg1:Object, ... _args):Boolean{
var _local4:uint;
var _local5:SpecialPropertySplitter;
var _local6:Array;
var _local7:uint;
var _local3:Array = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && ((_local3.indexOf(_args[_local4]) == -1)))){
if (_specialPropertySplitterList[_args[_local4]]){
_local5 = _specialPropertySplitterList[_args[_local4]];
_local6 = _local5.splitValues(_arg1, null);
_local7 = 0;
while (_local7 < _local6.length) {
_local3.push(_local6[_local7].name);
_local7++;
};
} else {
_local3.push(_args[_local4]);
};
};
_local4++;
};
return (affectTweens(removeTweenByIndex, _arg1, _local3));
}
public static function updateFrame():void{
_currentTimeFrame++;
}
public static function splitTweens(_arg1:Number, _arg2:Array):uint{
var _local5:uint;
var _local6:String;
var _local7:Boolean;
var _local3:TweenListObj = _tweenList[_arg1];
var _local4:TweenListObj = _local3.clone(false);
_local5 = 0;
while (_local5 < _arg2.length) {
_local6 = _arg2[_local5];
if (Boolean(_local3.properties[_local6])){
_local3.properties[_local6] = undefined;
delete _local3.properties[_local6];
};
_local5++;
};
for (_local6 in _local4.properties) {
_local7 = false;
_local5 = 0;
while (_local5 < _arg2.length) {
if (_arg2[_local5] == _local6){
_local7 = true;
break;
};
_local5++;
};
if (!_local7){
_local4.properties[_local6] = undefined;
delete _local4.properties[_local6];
};
};
_tweenList.push(_local4);
return ((_tweenList.length - 1));
}
public static function resumeTweenByIndex(_arg1:Number):Boolean{
var _local2:TweenListObj = _tweenList[_arg1];
if ((((_local2 == null)) || (!(_local2.isPaused)))){
return (false);
};
var _local3:Number = getCurrentTweeningTime(_local2);
_local2.timeStart = (_local2.timeStart + (_local3 - _local2.timePaused));
_local2.timeComplete = (_local2.timeComplete + (_local3 - _local2.timePaused));
_local2.timePaused = undefined;
_local2.isPaused = false;
return (true);
}
public static function getVersion():String{
return ("AS3 1.33.74");
}
public static function onEnterFrame(_arg1:Event):void{
updateTime();
updateFrame();
var _local2:Boolean;
_local2 = updateTweens();
if (!_local2){
stopEngine();
};
}
public static function updateTime():void{
_currentTime = getTimer();
}
private static function updateTweenByIndex(_arg1:Number):Boolean{
var tTweening:TweenListObj;
var mustUpdate:Boolean;
var nv:Number;
var t:Number;
var b:Number;
var c:Number;
var d:Number;
var pName:String;
var eventScope:Object;
var tScope:Object;
var tProperty:Object;
var pv:Number;
var i = _arg1;
tTweening = _tweenList[i];
if ((((tTweening == null)) || (!(Boolean(tTweening.scope))))){
return (false);
};
var isOver:Boolean;
var cTime:Number = getCurrentTweeningTime(tTweening);
if (cTime >= tTweening.timeStart){
tScope = tTweening.scope;
if (tTweening.isCaller){
do {
t = (((tTweening.timeComplete - tTweening.timeStart) / tTweening.count) * (tTweening.timesCalled + 1));
b = tTweening.timeStart;
c = (tTweening.timeComplete - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d);
} while (!(cTime >= nv));
} else {
mustUpdate = (((((tTweening.skipUpdates < 1)) || (!(tTweening.skipUpdates)))) || ((tTweening.updatesSkipped >= tTweening.skipUpdates)));
if (cTime >= tTweening.timeComplete){
isOver = true;
mustUpdate = true;
};
if (!tTweening.hasStarted){
if (Boolean(tTweening.onStart)){
eventScope = (Boolean(tTweening.onStartScope)) ? tTweening.onStartScope : tScope;
try {
tTweening.onStart.apply(eventScope, tTweening.onStartParams);
} catch(e2:Error) {
handleError(tTweening, e2, "onStart");
};
};
for (pName in tTweening.properties) {
if (tTweening.properties[pName].isSpecialProperty){
if (Boolean(_specialPropertyList[pName].preProcess)){
tTweening.properties[pName].valueComplete = _specialPropertyList[pName].preProcess(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].originalValueComplete, tTweening.properties[pName].extra);
};
pv = _specialPropertyList[pName].getValue(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
pv = tScope[pName];
};
tTweening.properties[pName].valueStart = (isNaN(pv)) ? tTweening.properties[pName].valueComplete : pv;
};
mustUpdate = true;
tTweening.hasStarted = true;
};
if (mustUpdate){
for (pName in tTweening.properties) {
tProperty = tTweening.properties[pName];
if (isOver){
nv = tProperty.valueComplete;
} else {
if (tProperty.hasModifier){
t = (cTime - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, 0, 1, d, tTweening.transitionParams);
nv = tProperty.modifierFunction(tProperty.valueStart, tProperty.valueComplete, nv, tProperty.modifierParameters);
} else {
t = (cTime - tTweening.timeStart);
b = tProperty.valueStart;
c = (tProperty.valueComplete - tProperty.valueStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d, tTweening.transitionParams);
};
};
if (tTweening.rounded){
nv = Math.round(nv);
};
if (tProperty.isSpecialProperty){
_specialPropertyList[pName].setValue(tScope, nv, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
tScope[pName] = nv;
};
};
tTweening.updatesSkipped = 0;
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
try {
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
} catch(e3:Error) {
handleError(tTweening, e3, "onUpdate");
};
};
} else {
tTweening.updatesSkipped++;
};
};
if (((isOver) && (Boolean(tTweening.onComplete)))){
eventScope = (Boolean(tTweening.onCompleteScope)) ? tTweening.onCompleteScope : tScope;
try {
tTweening.onComplete.apply(eventScope, tTweening.onCompleteParams);
} catch(e4:Error) {
handleError(tTweening, e4, "onComplete");
};
};
return (!(isOver));
};
return (true);
}
public static function setTimeScale(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (isNaN(_arg1)){
_arg1 = 1;
};
if (_arg1 < 1E-5){
_arg1 = 1E-5;
};
if (_arg1 != _timeScale){
if (_tweenList != null){
_local2 = 0;
while (_local2 < _tweenList.length) {
_local3 = getCurrentTweeningTime(_tweenList[_local2]);
_tweenList[_local2].timeStart = (_local3 - (((_local3 - _tweenList[_local2].timeStart) * _timeScale) / _arg1));
_tweenList[_local2].timeComplete = (_local3 - (((_local3 - _tweenList[_local2].timeComplete) * _timeScale) / _arg1));
if (_tweenList[_local2].timePaused != undefined){
_tweenList[_local2].timePaused = (_local3 - (((_local3 - _tweenList[_local2].timePaused) * _timeScale) / _arg1));
};
_local2++;
};
};
_timeScale = _arg1;
};
}
public static function resumeAllTweens():Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
var _local1:Boolean;
_local2 = 0;
while (_local2 < _tweenList.length) {
resumeTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
private static function handleError(_arg1:TweenListObj, _arg2:Error, _arg3:String):void{
var eventScope:Object;
var pTweening = _arg1;
var pError = _arg2;
var pCallBackName = _arg3;
if (((Boolean(pTweening.onError)) && ((pTweening.onError is Function)))){
eventScope = (Boolean(pTweening.onErrorScope)) ? pTweening.onErrorScope : pTweening.scope;
try {
pTweening.onError.apply(eventScope, [pTweening.scope, pError]);
} catch(metaError:Error) {
printError(((((String(pTweening.scope) + " raised an error while executing the 'onError' handler. Original error:\n ") + pError.getStackTrace()) + "\nonError error: ") + metaError.getStackTrace()));
};
} else {
if (!Boolean(pTweening.onError)){
printError(((((String(pTweening.scope) + " raised an error while executing the '") + pCallBackName) + "'handler. \n") + pError.getStackTrace()));
};
};
}
private static function startEngine():void{
_engineExists = true;
_tweenList = new Array();
__tweener_controller__ = new MovieClip();
__tweener_controller__.addEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
_currentTimeFrame = 0;
updateTime();
}
public static function removeAllTweens():Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
var _local1:Boolean;
_local2 = 0;
while (_local2 < _tweenList.length) {
removeTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
public static function addTween(_arg1:Object=null, _arg2:Object=null):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:String;
var _local6:Array;
var _local13:Function;
var _local14:Object;
var _local15:TweenListObj;
var _local16:Number;
var _local17:Array;
var _local18:Array;
var _local19:Array;
var _local20:String;
if (!Boolean(_arg1)){
return (false);
};
if ((_arg1 is Array)){
_local6 = _arg1.concat();
} else {
_local6 = [_arg1];
};
var _local7:Object = TweenListObj.makePropertiesChain(_arg2);
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var _local8:Number = (isNaN(_local7.time)) ? 0 : _local7.time;
var _local9:Number = (isNaN(_local7.delay)) ? 0 : _local7.delay;
var _local10:Array = new Array();
var _local11:Object = {overwrite:true, time:true, delay:true, useFrames:true, skipUpdates:true, transition:true, transitionParams:true, onStart:true, onUpdate:true, onComplete:true, onOverwrite:true, onError:true, rounded:true, onStartParams:true, onUpdateParams:true, onCompleteParams:true, onOverwriteParams:true, onStartScope:true, onUpdateScope:true, onCompleteScope:true, onOverwriteScope:true, onErrorScope:true};
var _local12:Object = new Object();
for (_local5 in _local7) {
if (!_local11[_local5]){
if (_specialPropertySplitterList[_local5]){
_local17 = _specialPropertySplitterList[_local5].splitValues(_local7[_local5], _specialPropertySplitterList[_local5].parameters);
_local3 = 0;
while (_local3 < _local17.length) {
if (_specialPropertySplitterList[_local17[_local3].name]){
_local18 = _specialPropertySplitterList[_local17[_local3].name].splitValues(_local17[_local3].value, _specialPropertySplitterList[_local17[_local3].name].parameters);
_local4 = 0;
while (_local4 < _local18.length) {
_local10[_local18[_local4].name] = {valueStart:undefined, valueComplete:_local18[_local4].value, arrayIndex:_local18[_local4].arrayIndex, isSpecialProperty:false};
_local4++;
};
} else {
_local10[_local17[_local3].name] = {valueStart:undefined, valueComplete:_local17[_local3].value, arrayIndex:_local17[_local3].arrayIndex, isSpecialProperty:false};
};
_local3++;
};
} else {
if (_specialPropertyModifierList[_local5] != undefined){
_local19 = _specialPropertyModifierList[_local5].modifyValues(_local7[_local5]);
_local3 = 0;
while (_local3 < _local19.length) {
_local12[_local19[_local3].name] = {modifierParameters:_local19[_local3].parameters, modifierFunction:_specialPropertyModifierList[_local5].getValue};
_local3++;
};
} else {
_local10[_local5] = {valueStart:undefined, valueComplete:_local7[_local5]};
};
};
};
};
for (_local5 in _local10) {
if (_specialPropertyList[_local5] != undefined){
_local10[_local5].isSpecialProperty = true;
} else {
if (_local6[0][_local5] == undefined){
printError((((("The property '" + _local5) + "' doesn't seem to be a normal object property of ") + String(_local6[0])) + " or a registered special property."));
};
};
};
for (_local5 in _local12) {
if (_local10[_local5] != undefined){
_local10[_local5].modifierParameters = _local12[_local5].modifierParameters;
_local10[_local5].modifierFunction = _local12[_local5].modifierFunction;
};
};
if (typeof(_local7.transition) == "string"){
_local20 = _local7.transition.toLowerCase();
_local13 = _transitionList[_local20];
} else {
_local13 = _local7.transition;
};
if (!Boolean(_local13)){
_local13 = _transitionList["easeoutexpo"];
};
_local3 = 0;
while (_local3 < _local6.length) {
_local14 = new Object();
for (_local5 in _local10) {
_local14[_local5] = new PropertyInfoObj(_local10[_local5].valueStart, _local10[_local5].valueComplete, _local10[_local5].valueComplete, _local10[_local5].arrayIndex, {}, _local10[_local5].isSpecialProperty, _local10[_local5].modifierFunction, _local10[_local5].modifierParameters);
};
if (_local7.useFrames == true){
_local15 = new TweenListObj(_local6[_local3], (_currentTimeFrame + (_local9 / _timeScale)), (_currentTimeFrame + ((_local9 + _local8) / _timeScale)), true, _local13, _local7.transitionParams);
} else {
_local15 = new TweenListObj(_local6[_local3], (_currentTime + ((_local9 * 1000) / _timeScale)), (_currentTime + (((_local9 * 1000) + (_local8 * 1000)) / _timeScale)), false, _local13, _local7.transitionParams);
};
_local15.properties = _local14;
_local15.onStart = _local7.onStart;
_local15.onUpdate = _local7.onUpdate;
_local15.onComplete = _local7.onComplete;
_local15.onOverwrite = _local7.onOverwrite;
_local15.onError = _local7.onError;
_local15.onStartParams = _local7.onStartParams;
_local15.onUpdateParams = _local7.onUpdateParams;
_local15.onCompleteParams = _local7.onCompleteParams;
_local15.onOverwriteParams = _local7.onOverwriteParams;
_local15.onStartScope = _local7.onStartScope;
_local15.onUpdateScope = _local7.onUpdateScope;
_local15.onCompleteScope = _local7.onCompleteScope;
_local15.onOverwriteScope = _local7.onOverwriteScope;
_local15.onErrorScope = _local7.onErrorScope;
_local15.rounded = _local7.rounded;
_local15.skipUpdates = _local7.skipUpdates;
if (((_local7.overwrite == undefined)) ? autoOverwrite : _local7.overwrite){
removeTweensByTime(_local15.scope, _local15.properties, _local15.timeStart, _local15.timeComplete);
};
_tweenList.push(_local15);
if ((((_local8 == 0)) && ((_local9 == 0)))){
_local16 = (_tweenList.length - 1);
updateTweenByIndex(_local16);
removeTweenByIndex(_local16);
};
_local3++;
};
return (true);
}
public static function registerTransition(_arg1:String, _arg2:Function):void{
if (!_inited){
init();
};
_transitionList[_arg1] = _arg2;
}
public static function printError(_arg1:String):void{
trace(("## [Tweener] Error: " + _arg1));
}
private static function affectTweens(_arg1:Function, _arg2:Object, _arg3:Array):Boolean{
var _local5:uint;
var _local6:Array;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local4:Boolean;
if (!Boolean(_tweenList)){
return (false);
};
_local5 = 0;
while (_local5 < _tweenList.length) {
if (((_tweenList[_local5]) && ((_tweenList[_local5].scope == _arg2)))){
if (_arg3.length == 0){
_arg1(_local5);
_local4 = true;
} else {
_local6 = new Array();
_local7 = 0;
while (_local7 < _arg3.length) {
if (Boolean(_tweenList[_local5].properties[_arg3[_local7]])){
_local6.push(_arg3[_local7]);
};
_local7++;
};
if (_local6.length > 0){
_local8 = AuxFunctions.getObjectLength(_tweenList[_local5].properties);
if (_local8 == _local6.length){
_arg1(_local5);
_local4 = true;
} else {
_local9 = splitTweens(_local5, _local6);
_arg1(_local9);
_local4 = true;
};
};
};
};
_local5++;
};
return (_local4);
}
public static function getTweens(_arg1:Object):Array{
var _local2:uint;
var _local3:String;
if (!Boolean(_tweenList)){
return ([]);
};
var _local4:Array = new Array();
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
for (_local3 in _tweenList[_local2].properties) {
_local4.push(_local3);
};
};
_local2++;
};
return (_local4);
}
public static function isTweening(_arg1:Object):Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
return (true);
};
_local2++;
};
return (false);
}
public static function pauseTweenByIndex(_arg1:Number):Boolean{
var _local2:TweenListObj = _tweenList[_arg1];
if ((((_local2 == null)) || (_local2.isPaused))){
return (false);
};
_local2.timePaused = getCurrentTweeningTime(_local2);
_local2.isPaused = true;
return (true);
}
public static function getCurrentTweeningTime(_arg1:Object):Number{
return ((_arg1.useFrames) ? _currentTimeFrame : _currentTime);
}
public static function getTweenCount(_arg1:Object):Number{
var _local2:uint;
if (!Boolean(_tweenList)){
return (0);
};
var _local3:Number = 0;
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
_local3 = (_local3 + AuxFunctions.getObjectLength(_tweenList[_local2].properties));
};
_local2++;
};
return (_local3);
}
private static function stopEngine():void{
_engineExists = false;
_tweenList = null;
_currentTime = 0;
_currentTimeFrame = 0;
__tweener_controller__.removeEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
__tweener_controller__ = null;
}
public static function removeTweensByTime(_arg1:Object, _arg2:Object, _arg3:Number, _arg4:Number):Boolean{
var removedLocally:Boolean;
var i:uint;
var pName:String;
var eventScope:Object;
var p_scope = _arg1;
var p_properties = _arg2;
var p_timeStart = _arg3;
var p_timeComplete = _arg4;
var removed:Boolean;
var tl:uint = _tweenList.length;
i = 0;
while (i < tl) {
if (((Boolean(_tweenList[i])) && ((p_scope == _tweenList[i].scope)))){
if ((((p_timeComplete > _tweenList[i].timeStart)) && ((p_timeStart < _tweenList[i].timeComplete)))){
removedLocally = false;
for (pName in _tweenList[i].properties) {
if (Boolean(p_properties[pName])){
if (Boolean(_tweenList[i].onOverwrite)){
eventScope = (Boolean(_tweenList[i].onOverwriteScope)) ? _tweenList[i].onOverwriteScope : _tweenList[i].scope;
try {
_tweenList[i].onOverwrite.apply(eventScope, _tweenList[i].onOverwriteParams);
} catch(e:Error) {
handleError(_tweenList[i], e, "onOverwrite");
};
};
_tweenList[i].properties[pName] = undefined;
delete _tweenList[i].properties[pName];
removedLocally = true;
removed = true;
};
};
if (removedLocally){
if (AuxFunctions.getObjectLength(_tweenList[i].properties) == 0){
removeTweenByIndex(i);
};
};
};
};
i = (i + 1);
};
return (removed);
}
public static function registerSpecialPropertySplitter(_arg1:String, _arg2:Function, _arg3:Array=null):void{
if (!_inited){
init();
};
var _local4:SpecialPropertySplitter = new SpecialPropertySplitter(_arg2, _arg3);
_specialPropertySplitterList[_arg1] = _local4;
}
public static function removeTweenByIndex(_arg1:Number, _arg2:Boolean=false):Boolean{
_tweenList[_arg1] = null;
if (_arg2){
_tweenList.splice(_arg1, 1);
};
return (true);
}
public static function resumeTweens(_arg1:Object, ... _args):Boolean{
var _local4:uint;
var _local3:Array = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && ((_local3.indexOf(_args[_local4]) == -1)))){
_local3.push(_args[_local4]);
};
_local4++;
};
return (affectTweens(resumeTweenByIndex, _arg1, _local3));
}
public static function pauseTweens(_arg1:Object, ... _args):Boolean{
var _local4:uint;
var _local3:Array = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && ((_local3.indexOf(_args[_local4]) == -1)))){
_local3.push(_args[_local4]);
};
_local4++;
};
return (affectTweens(pauseTweenByIndex, _arg1, _local3));
}
}
}//package caurina.transitions
Section 159
//TweenListObj (caurina.transitions.TweenListObj)
package caurina.transitions {
public class TweenListObj {
public var hasStarted:Boolean;
public var onUpdate:Function;
public var useFrames:Boolean;
public var count:Number;
public var onOverwriteParams:Array;
public var timeStart:Number;
public var timeComplete:Number;
public var onStartParams:Array;
public var onUpdateScope:Object;
public var rounded:Boolean;
public var onUpdateParams:Array;
public var properties:Object;
public var onComplete:Function;
public var transitionParams:Object;
public var updatesSkipped:Number;
public var onStart:Function;
public var onOverwriteScope:Object;
public var skipUpdates:Number;
public var onStartScope:Object;
public var scope:Object;
public var isCaller:Boolean;
public var timePaused:Number;
public var transition:Function;
public var onCompleteParams:Array;
public var onError:Function;
public var timesCalled:Number;
public var onErrorScope:Object;
public var onOverwrite:Function;
public var isPaused:Boolean;
public var waitFrames:Boolean;
public var onCompleteScope:Object;
public function TweenListObj(_arg1:Object, _arg2:Number, _arg3:Number, _arg4:Boolean, _arg5:Function, _arg6:Object){
scope = _arg1;
timeStart = _arg2;
timeComplete = _arg3;
useFrames = _arg4;
transition = _arg5;
transitionParams = _arg6;
properties = new Object();
isPaused = false;
timePaused = undefined;
isCaller = false;
updatesSkipped = 0;
timesCalled = 0;
skipUpdates = 0;
hasStarted = false;
}
public function clone(_arg1:Boolean):TweenListObj{
var _local3:String;
var _local2:TweenListObj = new TweenListObj(scope, timeStart, timeComplete, useFrames, transition, transitionParams);
_local2.properties = new Array();
for (_local3 in properties) {
_local2.properties[_local3] = properties[_local3].clone();
};
_local2.skipUpdates = skipUpdates;
_local2.updatesSkipped = updatesSkipped;
if (!_arg1){
_local2.onStart = onStart;
_local2.onUpdate = onUpdate;
_local2.onComplete = onComplete;
_local2.onOverwrite = onOverwrite;
_local2.onError = onError;
_local2.onStartParams = onStartParams;
_local2.onUpdateParams = onUpdateParams;
_local2.onCompleteParams = onCompleteParams;
_local2.onOverwriteParams = onOverwriteParams;
_local2.onStartScope = onStartScope;
_local2.onUpdateScope = onUpdateScope;
_local2.onCompleteScope = onCompleteScope;
_local2.onOverwriteScope = onOverwriteScope;
_local2.onErrorScope = onErrorScope;
};
_local2.rounded = rounded;
_local2.isPaused = isPaused;
_local2.timePaused = timePaused;
_local2.isCaller = isCaller;
_local2.count = count;
_local2.timesCalled = timesCalled;
_local2.waitFrames = waitFrames;
_local2.hasStarted = hasStarted;
return (_local2);
}
public function toString():String{
var _local3:String;
var _local1 = "\n[TweenListObj ";
_local1 = (_local1 + ("scope:" + String(scope)));
_local1 = (_local1 + ", properties:");
var _local2:Boolean;
for (_local3 in properties) {
if (!_local2){
_local1 = (_local1 + ",");
};
_local1 = (_local1 + ("[name:" + properties[_local3].name));
_local1 = (_local1 + (",valueStart:" + properties[_local3].valueStart));
_local1 = (_local1 + (",valueComplete:" + properties[_local3].valueComplete));
_local1 = (_local1 + "]");
_local2 = false;
};
_local1 = (_local1 + (", timeStart:" + String(timeStart)));
_local1 = (_local1 + (", timeComplete:" + String(timeComplete)));
_local1 = (_local1 + (", useFrames:" + String(useFrames)));
_local1 = (_local1 + (", transition:" + String(transition)));
_local1 = (_local1 + (", transitionParams:" + String(transitionParams)));
if (skipUpdates){
_local1 = (_local1 + (", skipUpdates:" + String(skipUpdates)));
};
if (updatesSkipped){
_local1 = (_local1 + (", updatesSkipped:" + String(updatesSkipped)));
};
if (Boolean(onStart)){
_local1 = (_local1 + (", onStart:" + String(onStart)));
};
if (Boolean(onUpdate)){
_local1 = (_local1 + (", onUpdate:" + String(onUpdate)));
};
if (Boolean(onComplete)){
_local1 = (_local1 + (", onComplete:" + String(onComplete)));
};
if (Boolean(onOverwrite)){
_local1 = (_local1 + (", onOverwrite:" + String(onOverwrite)));
};
if (Boolean(onError)){
_local1 = (_local1 + (", onError:" + String(onError)));
};
if (onStartParams){
_local1 = (_local1 + (", onStartParams:" + String(onStartParams)));
};
if (onUpdateParams){
_local1 = (_local1 + (", onUpdateParams:" + String(onUpdateParams)));
};
if (onCompleteParams){
_local1 = (_local1 + (", onCompleteParams:" + String(onCompleteParams)));
};
if (onOverwriteParams){
_local1 = (_local1 + (", onOverwriteParams:" + String(onOverwriteParams)));
};
if (onStartScope){
_local1 = (_local1 + (", onStartScope:" + String(onStartScope)));
};
if (onUpdateScope){
_local1 = (_local1 + (", onUpdateScope:" + String(onUpdateScope)));
};
if (onCompleteScope){
_local1 = (_local1 + (", onCompleteScope:" + String(onCompleteScope)));
};
if (onOverwriteScope){
_local1 = (_local1 + (", onOverwriteScope:" + String(onOverwriteScope)));
};
if (onErrorScope){
_local1 = (_local1 + (", onErrorScope:" + String(onErrorScope)));
};
if (rounded){
_local1 = (_local1 + (", rounded:" + String(rounded)));
};
if (isPaused){
_local1 = (_local1 + (", isPaused:" + String(isPaused)));
};
if (timePaused){
_local1 = (_local1 + (", timePaused:" + String(timePaused)));
};
if (isCaller){
_local1 = (_local1 + (", isCaller:" + String(isCaller)));
};
if (count){
_local1 = (_local1 + (", count:" + String(count)));
};
if (timesCalled){
_local1 = (_local1 + (", timesCalled:" + String(timesCalled)));
};
if (waitFrames){
_local1 = (_local1 + (", waitFrames:" + String(waitFrames)));
};
if (hasStarted){
_local1 = (_local1 + (", hasStarted:" + String(hasStarted)));
};
_local1 = (_local1 + "]\n");
return (_local1);
}
public static function makePropertiesChain(_arg1:Object):Object{
var _local3:Object;
var _local4:Object;
var _local5:Object;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local2:Object = _arg1.base;
if (_local2){
_local3 = {};
if ((_local2 is Array)){
_local4 = [];
_local8 = 0;
while (_local8 < _local2.length) {
_local4.push(_local2[_local8]);
_local8++;
};
} else {
_local4 = [_local2];
};
_local4.push(_arg1);
_local6 = _local4.length;
_local7 = 0;
while (_local7 < _local6) {
if (_local4[_local7]["base"]){
_local5 = AuxFunctions.concatObjects(makePropertiesChain(_local4[_local7]["base"]), _local4[_local7]);
} else {
_local5 = _local4[_local7];
};
_local3 = AuxFunctions.concatObjects(_local3, _local5);
_local7++;
};
if (_local3["base"]){
delete _local3["base"];
};
return (_local3);
//unresolved jump
};
return (_arg1);
}
}
}//package caurina.transitions
Section 160
//CubicBezier (com.cartogrammar.drawing.CubicBezier)
package com.cartogrammar.drawing {
import flash.display.*;
import flash.geom.*;
import fl.motion.*;
public class CubicBezier {
public static function curveThroughPoints(_arg1:Graphics, _arg2:Array, _arg3:Number=0.5, _arg4:Number=0.75, _arg5:Boolean=true):void{
var p:Array;
var duplicates:Array;
var i:*;
var firstPt:*;
var lastPt:*;
var controlPts:Array;
var straightLines:Boolean;
var p0:*;
var p1:*;
var p2:*;
var a:*;
var b:*;
var c:*;
var cos:*;
var C:*;
var aPt:*;
var bPt:*;
var cPt:*;
var ax:*;
var ay:*;
var bx:*;
var by:*;
var rx:*;
var ry:*;
var r:*;
var theta:*;
var controlDist:*;
var controlScaleFactor:*;
var controlAngle:*;
var controlPoint2:*;
var controlPoint1:*;
var isStraight:Boolean;
var bezier:BezierSegment;
var t:*;
var val:*;
var g = _arg1;
var points = _arg2;
var z = _arg3;
var angleFactor = _arg4;
var moveTo = _arg5;
try {
p = points.slice();
duplicates = new Array();
i = 0;
while (i < p.length) {
if (!(p[i] is Point)){
throw (new Error("Array must contain Point objects"));
};
if (i > 0){
if ((((p[i].x == p[(i - 1)].x)) && ((p[i].y == p[(i - 1)].y)))){
duplicates.push(i);
};
};
i = (i + 1);
};
i = (duplicates.length - 1);
while (i >= 0) {
p.splice(duplicates[i], 1);
i = (i - 1);
};
if (z <= 0){
z = 0.5;
} else {
if (z > 1){
z = 1;
};
};
if (angleFactor < 0){
angleFactor = 0;
} else {
if (angleFactor > 1){
angleFactor = 1;
};
};
if (p.length > 2){
firstPt = 1;
lastPt = (p.length - 1);
if ((((p[0].x == p[(p.length - 1)].x)) && ((p[0].y == p[(p.length - 1)].y)))){
firstPt = 0;
lastPt = p.length;
};
controlPts = new Array();
i = firstPt;
while (i < lastPt) {
p0 = (((i - 1))<0) ? p[(p.length - 2)] : p[(i - 1)];
p1 = p[i];
p2 = (((i + 1))==p.length) ? p[1] : p[(i + 1)];
a = Point.distance(p0, p1);
if (a < 0.001){
a = 0.001;
};
b = Point.distance(p1, p2);
if (b < 0.001){
b = 0.001;
};
c = Point.distance(p0, p2);
if (c < 0.001){
c = 0.001;
};
cos = ((((b * b) + (a * a)) - (c * c)) / ((2 * b) * a));
if (cos < -1){
cos = -1;
} else {
if (cos > 1){
cos = 1;
};
};
C = Math.acos(cos);
aPt = new Point((p0.x - p1.x), (p0.y - p1.y));
bPt = new Point(p1.x, p1.y);
cPt = new Point((p2.x - p1.x), (p2.y - p1.y));
if (a > b){
aPt.normalize(b);
} else {
if (b > a){
cPt.normalize(a);
};
};
aPt.offset(p1.x, p1.y);
cPt.offset(p1.x, p1.y);
ax = (bPt.x - aPt.x);
ay = (bPt.y - aPt.y);
bx = (bPt.x - cPt.x);
by = (bPt.y - cPt.y);
rx = (ax + bx);
ry = (ay + by);
if ((((rx == 0)) && ((ry == 0)))){
rx = -(bx);
ry = by;
};
if ((((ay == 0)) && ((by == 0)))){
rx = 0;
ry = 1;
} else {
if ((((ax == 0)) && ((bx == 0)))){
rx = 1;
ry = 0;
};
};
r = Math.sqrt(((rx * rx) + (ry * ry)));
theta = Math.atan2(ry, rx);
controlDist = (Math.min(a, b) * z);
controlScaleFactor = (C / Math.PI);
controlDist = (controlDist * ((1 - angleFactor) + (angleFactor * controlScaleFactor)));
controlAngle = (theta + (Math.PI / 2));
controlPoint2 = Point.polar(controlDist, controlAngle);
controlPoint1 = Point.polar(controlDist, (controlAngle + Math.PI));
controlPoint1.offset(p1.x, p1.y);
controlPoint2.offset(p1.x, p1.y);
if (Point.distance(controlPoint2, p2) > Point.distance(controlPoint1, p2)){
controlPts[i] = new Array(controlPoint2, controlPoint1);
} else {
controlPts[i] = new Array(controlPoint1, controlPoint2);
};
i = (i + 1);
};
if (moveTo){
g.moveTo(p[0].x, p[0].y);
} else {
g.lineTo(p[0].x, p[0].y);
};
if (firstPt == 1){
g.curveTo(controlPts[1][0].x, controlPts[1][0].y, p[1].x, p[1].y);
};
straightLines = true;
i = firstPt;
while (i < (lastPt - 1)) {
isStraight = (((((i > 0)) && ((Math.atan2((p[i].y - p[(i - 1)].y), (p[i].x - p[(i - 1)].x)) == Math.atan2((p[(i + 1)].y - p[i].y), (p[(i + 1)].x - p[i].x)))))) || ((((i < (p.length - 2))) && ((Math.atan2((p[(i + 2)].y - p[(i + 1)].y), (p[(i + 2)].x - p[(i + 1)].x)) == Math.atan2((p[(i + 1)].y - p[i].y), (p[(i + 1)].x - p[i].x)))))));
if (((straightLines) && (isStraight))){
g.lineTo(p[(i + 1)].x, p[(i + 1)].y);
} else {
bezier = new BezierSegment(p[i], controlPts[i][1], controlPts[(i + 1)][0], p[(i + 1)]);
t = 0.01;
while (t < 1.01) {
val = bezier.getValue(t);
g.lineTo(val.x, val.y);
t = (t + 0.01);
};
};
i = (i + 1);
};
if (lastPt == (p.length - 1)){
g.curveTo(controlPts[i][1].x, controlPts[i][1].y, p[(i + 1)].x, p[(i + 1)].y);
};
} else {
if (p.length == 2){
g.moveTo(p[0].x, p[0].y);
g.lineTo(p[1].x, p[1].y);
};
};
} catch(e) {
trace(e.getStackTrace());
};
}
public static function drawCurve(_arg1:Graphics, _arg2:Point, _arg3:Point, _arg4:Point, _arg5:Point):void{
var _local8:*;
var _local6:* = new BezierSegment(_arg2, _arg3, _arg4, _arg5);
_arg1.moveTo(_arg2.x, _arg2.y);
var _local7:* = 0.01;
while (_local7 < 1.01) {
_local8 = _local6.getValue(_local7);
_arg1.lineTo(_local8.x, _local8.y);
_local7 = (_local7 + 0.01);
};
}
}
}//package com.cartogrammar.drawing
Section 161
//AWorld (entities.worlds.AWorld)
package entities.worlds {
import flash.events.*;
import AKEngine.*;
import flash.display.*;
import helpers.*;
import AKEngine.entity.box2d.*;
public class AWorld extends Box2DWorld {
public function AWorld(_arg1:GameFactory, _arg2:Box2DWorldParams, _arg3:DisplayObjectContainer){
super(_arg1, _arg2, _arg3);
loadLevel((GameData.instance.currentLevelNum + 1));
}
protected function levelLoadedHandler(_arg1:Event):void{
}
override public function createEntities():void{
super.createEntities();
}
private function loadLevel(_arg1:Number):void{
var _local2:XMLLevelParser = new XMLLevelParser(this);
_local2.addEventListener(Event.COMPLETE, levelLoadedHandler);
_local2.loadLevel(_arg1);
}
}
}//package entities.worlds
Section 162
//GameWorld (entities.worlds.GameWorld)
package entities.worlds {
import flash.events.*;
import AKEngine.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import tools.*;
import entities.*;
import flash.utils.*;
public class GameWorld extends AWorld {
public const SIMULATING_STATE:Number = 1;
public const BUILDING_STATE:Number = 0;
public var woodRemain:Number;
public var coins:Array;
private var _elapsedFrames:int;
private var magnets:Array;
public var collectedCoinsNum:Number;
public var currentState:Number;
private var _lastTime:int;// = -1
public var magnetCoinEffects:Array;
private var contactsManager:ContactsManager;
public var stickRemoveEffects:Array;
private var _currentTool:ATool;
public var hero:Hero;
public function GameWorld(_arg1:GameFactory, _arg2:Box2DWorldParams, _arg3:DisplayObjectContainer){
super(_arg1, _arg2, _arg3);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == InputManager.instance.SPACEBAR){
if (currentState == SIMULATING_STATE){
stopSimulation();
} else {
if (currentState == BUILDING_STATE){
startSimulation();
};
};
dispatchEvent(new GameEvent(GameEvent.UPDATE_UI));
};
}
private function reset():void{
var _local1:int;
coins = [];
collectedCoinsNum = 0;
magnets = [];
if (magnetCoinEffects){
_local1 = (magnetCoinEffects.length - 1);
while (_local1 >= 0) {
magnetCoinEffects[_local1].dispose();
magnetCoinEffects.splice(_local1, 1);
_local1--;
};
};
magnetCoinEffects = [];
if (stickRemoveEffects){
_local1 = (stickRemoveEffects.length - 1);
while (_local1 >= 0) {
stickRemoveEffects[_local1].dispose();
stickRemoveEffects.splice(_local1, 1);
_local1--;
};
};
stickRemoveEffects = [];
}
public function startSimulation():void{
_elapsedFrames = 0;
if (_currentTool){
_currentTool.dispose();
_currentTool = null;
};
currentState = SIMULATING_STATE;
}
public function setTool(_arg1:ATool):void{
if (_currentTool){
_currentTool.dispose();
};
_currentTool = _arg1;
}
override public function createEntities():void{
super.createEntities();
if (getChildrenByType(Hero).length > 0){
hero = (getChildrenByType(Hero)[0] as Hero);
};
coins = getChildrenByType(Coin);
magnets = getChildrenByType(Magnet);
initMCEffects();
}
override public function dispose():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
if (_currentTool){
_currentTool.dispose();
_currentTool = null;
};
coins = null;
hero = null;
magnets = null;
magnetCoinEffects = null;
stickRemoveEffects = null;
super.dispose();
}
override protected function levelLoadedHandler(_arg1:Event):void{
dispatchEvent(new GameEvent(GameEvent.LEVEL_LOADED));
magnetCoinEffects = [];
stickRemoveEffects = [];
createEntities();
currentState = BUILDING_STATE;
var _local2:DynamicRectTool = new DynamicRectTool(this);
setTool(_local2);
woodRemain = (GameData.instance.levelInfos[GameData.instance.currentLevelNum] as LevelInfo).woodMax;
collectedCoinsNum = 0;
_elapsedFrames = 0;
contactsManager = new ContactsManager();
physWorld.SetContactListener(contactsManager);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, false, 0, true);
}
override public function update(_arg1:Number):void{
var _local2:MCEffect;
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:Coin;
var _local7:int;
var _local8:int;
var _local9:String;
var _local10:LevelInfo;
var _local11:StickRemoveEffect;
_elapsedFrames++;
if (currentState == BUILDING_STATE){
_local4 = getTimer();
if (_lastTime < 0){
_lastTime = _local4;
return;
};
_local5 = (Number((_local4 - lastTime)) * timeScale);
super.postUpdate(_local5);
_lastTime = _local4;
} else {
if (currentState == SIMULATING_STATE){
super.update(_arg1);
_local3 = (coins.length - 1);
while (_local3 >= 0) {
_local6 = coins[_local3];
if (hero.heroCollisionArea.hitTestPoint((_local6.body.GetPosition().x * physScale), (_local6.body.GetPosition().y * physScale))){
_local7 = (magnetCoinEffects.length - 1);
while (_local7 >= 0) {
_local2 = magnetCoinEffects[_local7];
if (_local2.coin == _local6){
magnetCoinEffects[_local7].dispose();
magnetCoinEffects.splice(_local7, 1);
};
_local7--;
};
collectedCoinsNum++;
removeChild(_local6.name);
coins.splice(_local3, 1);
_local8 = (1 + Math.floor((Math.random() * 2)));
_local9 = ("catch" + _local8.toString());
hero.playAnimation(_local9, true);
dispatchEvent(new GameEvent(GameEvent.UPDATE_UI));
_local10 = (GameData.instance.levelInfos[GameData.instance.currentLevelNum] as LevelInfo);
if (collectedCoinsNum == _local10.coinsToWin){
levelComplete();
} else {
SoundManager.instance.playSound("coinCollectedSound");
};
};
_local3--;
};
};
};
_local3 = 0;
while (_local3 < magnetCoinEffects.length) {
_local2 = magnetCoinEffects[_local3];
_local2.update();
_local3++;
};
_local3 = 0;
while (_local3 < stickRemoveEffects.length) {
_local11 = stickRemoveEffects[_local3];
_local11.update();
_local3++;
};
}
private function levelComplete():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
SoundManager.instance.playSound("levelCompleteSound");
var _local1:Number = (500 - Math.round((_elapsedFrames / 15)));
_local1 = (_local1 + Math.floor(woodRemain));
if (_local1 < 0){
_local1 = 0;
};
GameData.instance.updateLevelInfos(_local1);
GameData.instance.saveData();
hero.levelComplete();
dispatchEvent(new GameEvent(GameEvent.LEVEL_COMPLETE));
}
public function RayCastClosest(_arg1:b2Vec2, _arg2:b2Vec2):b2Fixture{
var closestFraction:Number;
var result:b2Fixture;
var RayCastClosestWrapper:Function;
var point1 = _arg1;
var point2 = _arg2;
RayCastClosestWrapper = function (_arg1:b2Fixture, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Number{
if ((((((_arg4 < closestFraction)) && (!((_arg1.GetUserData() is DynamicRect))))) && (!((_arg1.GetUserData() == "nabaldashnik"))))){
closestFraction = _arg4;
result = _arg1;
return (_arg4);
};
return (closestFraction);
};
closestFraction = 1;
physWorld.RayCast(RayCastClosestWrapper, point1, point2);
return (result);
}
public function stopSimulation():void{
removeChildren();
reset();
createEntities();
if (getChildrenByType(Hero).length > 0){
hero = (getChildrenByType(Hero)[0] as Hero);
};
coins = getChildrenByType(Coin);
var _local1:DynamicRectTool = new DynamicRectTool(this);
setTool(_local1);
currentState = BUILDING_STATE;
}
private function initMCEffects():void{
var _local2:int;
var _local3:MCEffect;
var _local1:int;
while (_local1 < magnets.length) {
_local2 = 0;
while (_local2 < coins.length) {
_local3 = new MCEffect(magnets[_local1], coins[_local2], effectsSprite);
magnetCoinEffects.push(_local3);
_local2++;
};
_local1++;
};
}
}
}//package entities.worlds
Section 163
//PreviewWorld (entities.worlds.PreviewWorld)
package entities.worlds {
import flash.events.*;
import AKEngine.*;
import flash.display.*;
import AKEngine.entity.box2d.*;
public class PreviewWorld extends AWorld {
public function PreviewWorld(_arg1:GameFactory, _arg2:Box2DWorldParams, _arg3:DisplayObjectContainer){
super(_arg1, _arg2, _arg3);
}
override protected function levelLoadedHandler(_arg1:Event):void{
createEntities();
dispatchEvent(new Event(Event.COMPLETE));
}
}
}//package entities.worlds
Section 164
//Coin (entities.Coin)
package entities {
import flash.display.*;
import AKEngine.managers.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Coin extends Box2DEntity {
private var _coinFlash:MovieClip;
private var _isAnimating:Boolean;
private var _idleFrame:Number;
private var _flashFrame:Number;
public function Coin(_arg1:Box2DWorld, _arg2:CoinParams){
super(_arg1, _arg2);
var _local3:Class = AssetsManager.instance.getAssetClass("CoinFlashAsset");
_coinFlash = (new (_local3) as MovieClip);
_coinFlash["animation"].gotoAndStop(1);
_isAnimating = false;
_idleFrame = 0;
_flashFrame = (50 + (Math.random() * 100));
}
override public function postUpdate(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
super.postUpdate(_arg1);
if (!_isAnimating){
_idleFrame++;
} else {
if (_coinFlash["animation"].currentFrame == _coinFlash["animation"].totalFrames){
_isAnimating = false;
_coinFlash["animation"].gotoAndStop(1);
container.removeChild(_coinFlash);
};
};
if (_idleFrame >= _flashFrame){
_isAnimating = true;
_idleFrame = 0;
_flashFrame = (50 + (Math.random() * 100));
container.addChild(_coinFlash);
_local2 = ((Math.random() * container.width) / 2);
_local3 = ((Math.random() * 2) * Math.PI);
_coinFlash.x = (_local2 * Math.cos(_local3));
_coinFlash.y = (_local2 * Math.sin(_local3));
_coinFlash["animation"].gotoAndPlay(1);
};
}
override protected function createSkin():void{
var _local1:CoinParams = (params as CoinParams);
var _local2:Class = AssetsManager.instance.getAssetClass("CoinAsset");
skin = (new (_local2) as MovieClip);
skin.scaleX = (skin.scaleY = (_local1.radius / 28));
}
override protected function createBody():void{
var _local1:CoinParams;
_local1 = (params as CoinParams);
var _local2:b2CircleShape = new b2CircleShape((_local1.radius / (_world as Box2DWorld).physScale));
var _local3:b2BodyDef = new b2BodyDef();
_local3.position.Set((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local3.angle = _local1.rotation;
_local3.bullet = _local1.isBullet;
_local3.fixedRotation = _local1.isFixedRotation;
_local3.linearDamping = _local1.linearDamping;
_local3.angularDamping = _local1.angularDamping;
if (_local1.isStatic){
_local3.type = b2Body.b2_staticBody;
} else {
_local3.type = b2Body.b2_dynamicBody;
};
body = (_world as Box2DWorld).physWorld.CreateBody(_local3);
var _local4:b2FixtureDef = new b2FixtureDef();
_local4.shape = _local2;
_local4.density = _local1.density;
_local4.friction = _local1.friction;
_local4.restitution = _local1.restitution;
_local4.isSensor = _local1.isSensor;
_local4.filter.categoryBits = _local1.categoryBits;
_local4.filter.maskBits = _local1.maskBits;
_local4.filter.groupIndex = _local1.groupIndex;
_local4.userData = this;
body.CreateFixture(_local4);
}
}
}//package entities
Section 165
//CoinParams (entities.CoinParams)
package entities {
import AKEngine.entity.box2d.*;
public class CoinParams extends Box2DEntityParams {
public var radius:Number;
public function CoinParams(_arg1:Object=null){
radius = 28;
super(_arg1);
customClass = Coin;
xmlTag = "Coin";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
radius = parseFloat(_arg1.@radius);
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
rotation = parseFloat(_arg1.@rotation);
density = parseFloat(_arg1.@density);
friction = parseFloat(_arg1.@friction);
restitution = parseFloat(_arg1.@restitution);
linearDamping = parseFloat(_arg1.@linearDamping);
angularDamping = parseFloat(_arg1.@angularDamping);
isFixedRotation = (_arg1.@isFixedRotation.toLowerCase() == "true");
isStatic = (_arg1.@isStatic.toLowerCase() == "true");
isSensor = (_arg1.@isSensor.toLowerCase() == "true");
isBullet = (_arg1.@isBullet.toLowerCase() == "true");
categoryBits = parseInt(_arg1.@categoryBits);
maskBits = parseInt(_arg1.@maskBits);
groupIndex = parseInt(_arg1.@groupIndex);
}
override public function clone(){
return (new CoinParams({forcedName:forcedName, radius:radius, layer:layer, x:x, y:y, rotation:rotation, density:density, friction:friction, restitution:restitution, linearDamping:linearDamping, angularDamping:angularDamping, isFixedRotation:isFixedRotation, isStatic:isStatic, isSensor:isSensor, isBullet:isBullet, categoryBits:categoryBits, maskBits:maskBits, groupIndex:groupIndex}));
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@radius = radius;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@rotation = rotation;
_local1.@density = density;
_local1.@friction = friction;
_local1.@restitution = restitution;
_local1.@linearDamping = linearDamping;
_local1.@angularDamping = angularDamping;
_local1.@isFixedRotation = isFixedRotation;
_local1.@isStatic = isStatic;
_local1.@isSensor = isSensor;
_local1.@isBullet = isBullet;
_local1.@categoryBits = categoryBits;
_local1.@maskBits = maskBits;
_local1.@groupIndex = groupIndex;
return (_local1);
}
}
}//package entities
Section 166
//CoinsEmitter (entities.CoinsEmitter)
package entities {
import flash.display.*;
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import entities.worlds.*;
public class CoinsEmitter extends Box2DEntity {
private var _emittedCoinsNum:Number;
private var _framesFromLastCoin:Number;
public function CoinsEmitter(_arg1:Box2DWorld, _arg2:CoinsEmitterParams){
_framesFromLastCoin = 0;
_emittedCoinsNum = 0;
super(_arg1, _arg2);
}
override public function update(_arg1:Number):void{
var _local2:CoinsEmitterParams = (params as CoinsEmitterParams);
if (_emittedCoinsNum == _local2.coinsNum){
return;
};
_framesFromLastCoin++;
if (_framesFromLastCoin >= _local2.delay){
_framesFromLastCoin = 0;
emitCoin();
_emittedCoinsNum++;
};
}
private function emitCoin():void{
var _local1:CoinsEmitterParams = (params as CoinsEmitterParams);
var _local2:Number = ((-(_local1.randomAngle) / 2) + (Math.random() * _local1.randomAngle));
var _local3:b2Mat22 = b2Mat22.FromAngle(((_local2 * Math.PI) / 180));
var _local4:b2Vec2 = b2Math.MulMV(_local3, new b2Vec2(_local1.directionX, _local1.directionY));
_local4.Normalize();
var _local5:b2Vec2 = b2Math.MulFV((_world as Box2DWorld).physScale, body.GetWorldCenter());
var _local6:CoinParams = new CoinParams({x:_local5.x, y:_local5.y});
_world.entitiesParams.push(_local6);
var _local7:Coin = _world.factory.getEntity(_local6, _world);
(_world as GameWorld).coins.push(_local7);
var _local8:Number = (_local1.minImpulse + (Math.random() * (_local1.maxImpulse - _local1.minImpulse)));
var _local9:b2Vec2 = b2Math.MulFV(_local8, _local4);
_local7.body.ApplyImpulse(_local9, _local7.body.GetWorldCenter());
}
override protected function createSkin():void{
var _local1:CoinsEmitterParams = (params as CoinsEmitterParams);
var _local2:Class = AssetsManager.instance.getAssetClass("CoinsEmitterAsset");
skin = (new (_local2) as MovieClip);
}
override protected function createBody():void{
var _local2:b2CircleShape;
var _local1:CoinsEmitterParams = (params as CoinsEmitterParams);
_local2 = new b2CircleShape((22.5 / (_world as Box2DWorld).physScale));
var _local3:b2BodyDef = new b2BodyDef();
_local3.position.Set((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local3.angle = _local1.rotation;
_local3.bullet = _local1.isBullet;
_local3.fixedRotation = _local1.isFixedRotation;
_local3.linearDamping = _local1.linearDamping;
_local3.angularDamping = _local1.angularDamping;
if (_local1.isStatic){
_local3.type = b2Body.b2_staticBody;
} else {
_local3.type = b2Body.b2_dynamicBody;
};
body = (_world as Box2DWorld).physWorld.CreateBody(_local3);
var _local4:b2FixtureDef = new b2FixtureDef();
_local4.shape = _local2;
_local4.density = _local1.density;
_local4.friction = _local1.friction;
_local4.restitution = _local1.restitution;
_local4.isSensor = true;
_local4.filter.categoryBits = _local1.categoryBits;
_local4.filter.maskBits = _local1.maskBits;
_local4.filter.groupIndex = _local1.groupIndex;
_local4.userData = this;
body.CreateFixture(_local4);
}
}
}//package entities
Section 167
//CoinsEmitterParams (entities.CoinsEmitterParams)
package entities {
import AKEngine.entity.box2d.*;
public class CoinsEmitterParams extends Box2DEntityParams {
public var minImpulse:Number;
public var coinsNum:Number;
public var delay:Number;
public var randomAngle:Number;
public var maxImpulse:Number;
public var directionX:Number;
public var directionY:Number;
public function CoinsEmitterParams(_arg1:Object=null){
coinsNum = 5;
delay = 100;
minImpulse = 5;
maxImpulse = 10;
directionX = 0;
directionY = -1;
randomAngle = 45;
super(_arg1);
customClass = CoinsEmitter;
xmlTag = "CoinsEmitter";
}
override public function clone(){
return (new CoinsEmitterParams({forcedName:forcedName, coinsNum:coinsNum, delay:delay, minImpulse:minImpulse, maxImpulse:maxImpulse, directionX:directionX, directionY:directionY, randomAngle:randomAngle, layer:layer, x:x, y:y, rotation:rotation, density:density, friction:friction, restitution:restitution, linearDamping:linearDamping, angularDamping:angularDamping, isFixedRotation:isFixedRotation, isStatic:isStatic, isSensor:isSensor, isBullet:isBullet, categoryBits:categoryBits, maskBits:maskBits, groupIndex:groupIndex}));
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@coinsNum = coinsNum;
_local1.@delay = delay;
_local1.@minImpulse = minImpulse;
_local1.@maxImpulse = maxImpulse;
_local1.@directionX = directionX;
_local1.@directionY = directionY;
_local1.@randomAngle = randomAngle;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@rotation = rotation;
_local1.@density = density;
_local1.@friction = friction;
_local1.@restitution = restitution;
_local1.@linearDamping = linearDamping;
_local1.@angularDamping = angularDamping;
_local1.@isFixedRotation = isFixedRotation;
_local1.@isStatic = isStatic;
_local1.@isSensor = isSensor;
_local1.@isBullet = isBullet;
_local1.@categoryBits = categoryBits;
_local1.@maskBits = maskBits;
_local1.@groupIndex = groupIndex;
return (_local1);
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
coinsNum = parseFloat(_arg1.@coinsNum);
delay = parseFloat(_arg1.@delay);
minImpulse = parseFloat(_arg1.@minImpulse);
maxImpulse = parseFloat(_arg1.@maxImpulse);
directionX = parseFloat(_arg1.@directionX);
directionY = parseFloat(_arg1.@directionY);
randomAngle = parseFloat(_arg1.@randomAngle);
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
rotation = parseFloat(_arg1.@rotation);
density = parseFloat(_arg1.@density);
friction = parseFloat(_arg1.@friction);
restitution = parseFloat(_arg1.@restitution);
linearDamping = parseFloat(_arg1.@linearDamping);
angularDamping = parseFloat(_arg1.@angularDamping);
isFixedRotation = (_arg1.@isFixedRotation.toLowerCase() == "true");
isStatic = (_arg1.@isStatic.toLowerCase() == "true");
isSensor = (_arg1.@isSensor.toLowerCase() == "true");
isBullet = (_arg1.@isBullet.toLowerCase() == "true");
categoryBits = parseInt(_arg1.@categoryBits);
maskBits = parseInt(_arg1.@maskBits);
groupIndex = parseInt(_arg1.@groupIndex);
}
}
}//package entities
Section 168
//DynamicHinge (entities.DynamicHinge)
package entities {
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
public class DynamicHinge extends Box2DJoint {
public function DynamicHinge(_arg1:Box2DWorld, _arg2:DynamicHingeParams){
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local1:DynamicHingeParams = (params as DynamicHingeParams);
var _local2:Class = AssetsManager.instance.getAssetClass("HingeAsset");
skin = new (_local2);
}
override public function createJoint():void{
var _local2:b2Body;
var _local3:b2Body;
var _local7:DynamicRect;
var _local8:DynamicRectParams;
var _local9:b2RevoluteJointDef;
var _local10:b2Vec2;
var _local1:DynamicHingeParams = (params as DynamicHingeParams);
var _local4:b2Vec2 = _world.worldToScreen(new b2Vec2(_local1.x, _local1.y));
var _local5:Array = getDynamicRectsAtPoint(_local4.x, _local4.y);
var _local6:int;
while (_local6 < _local5.length) {
_local7 = (_local5[_local6] as DynamicRect);
_local8 = (_local7.params as DynamicRectParams);
if (_local8.uniqueID == _local1.uniqueNum1){
_local2 = _local7.body;
} else {
if (_local8.uniqueID == _local1.uniqueNum2){
_local3 = _local7.body;
};
};
_local6++;
};
if (((_local2) && (_local3))){
_local9 = new b2RevoluteJointDef();
_local10 = new b2Vec2((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local9.Initialize(_local2, _local3, _local10);
joint = ((_world as Box2DWorld).physWorld.CreateJoint(_local9) as b2RevoluteJoint);
joint.SetUserData(this);
};
}
private function getDynamicRectsAtPoint(_arg1:Number, _arg2:Number):Array{
var _local6:DynamicRect;
var _local3:Array = [];
var _local4:Array = _world.getChildrenByType(DynamicRect);
var _local5:int;
while (_local5 < _local4.length) {
_local6 = _local4[_local5];
if (_local6.skin.hitTestPoint(_arg1, _arg2, true)){
_local3.push(_local6);
};
_local5++;
};
_local3.sortOn("uniqueID", Array.DESCENDING);
return (_local3);
}
}
}//package entities
Section 169
//DynamicHingeParams (entities.DynamicHingeParams)
package entities {
import AKEngine.entity.box2d.custom.*;
public class DynamicHingeParams extends HingeParams {
public var uniqueNum1:Number;
public var uniqueNum2:Number;
public function DynamicHingeParams(_arg1:Object=null){
super(_arg1);
customClass = DynamicHinge;
xmlTag = "DynamicHinge";
}
}
}//package entities
Section 170
//DynamicRect (entities.DynamicRect)
package entities {
import flash.display.*;
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class DynamicRect extends Box2DEntity {
public var isCtrld:Boolean;
public function DynamicRect(_arg1:Box2DWorld, _arg2:DynamicRectParams){
super(_arg1, _arg2);
}
public function notUnderMouse():void{
var _local1:ColorTransform = skin.transform.colorTransform;
_local1.redMultiplier = 1;
_local1.greenMultiplier = 1;
_local1.blueMultiplier = 1;
skin.transform.colorTransform = _local1;
}
override public function dispose():void{
var _local1:Object;
if (isCtrld){
(_world as Box2DWorld).physWorld.DestroyBody(body);
body = null;
params = null;
for (_local1 in _children) {
_children[_local1].dispose();
delete _children[_local1];
};
_children = null;
_parent = null;
_world = null;
} else {
super.dispose();
};
}
override protected function createSkin():void{
var _local1:DynamicRectParams = (params as DynamicRectParams);
var _local2:Class = AssetsManager.instance.getAssetClass(_local1.textureName);
var _local3:BitmapData = (new _local2(0, 0) as BitmapData);
skin = new Sprite();
skin.graphics.lineStyle(0, 0, 1);
var _local4:Matrix = new Matrix(1, 0, 0, 1, 0, -6);
skin.graphics.beginBitmapFill(_local3, _local4, true, true);
skin.graphics.moveTo((-(_local1.width) / 2), (-(_local1.height) / 2));
skin.graphics.lineTo((_local1.width / 2), (-(_local1.height) / 2));
skin.graphics.curveTo(((_local1.width / 2) + _local1.height), 0, (_local1.width / 2), (_local1.height / 2));
skin.graphics.lineTo((-(_local1.width) / 2), (_local1.height / 2));
skin.graphics.curveTo(((-(_local1.width) / 2) - _local1.height), 0, (-(_local1.width) / 2), (-(_local1.height) / 2));
skin.graphics.endFill();
skin.rotation = _local1.rotation;
}
public function underMouse():void{
var _local1:ColorTransform = skin.transform.colorTransform;
_local1.redMultiplier = 1;
_local1.greenMultiplier = 0.7;
_local1.blueMultiplier = 0.7;
skin.transform.colorTransform = _local1;
}
override protected function createBody():void{
var _local1:DynamicRectParams;
_local1 = (params as DynamicRectParams);
var _local2:b2PolygonShape = new b2PolygonShape();
_local2.SetAsBox(((_local1.width / 2) / (_world as Box2DWorld).physScale), ((_local1.height / 2) / (_world as Box2DWorld).physScale));
var _local3:b2BodyDef = new b2BodyDef();
_local3.position.Set((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local3.angle = _local1.rotation;
_local3.bullet = _local1.isBullet;
_local3.fixedRotation = _local1.isFixedRotation;
_local3.linearDamping = _local1.linearDamping;
_local3.angularDamping = _local1.angularDamping;
if (_local1.isStatic){
_local3.type = b2Body.b2_staticBody;
} else {
_local3.type = b2Body.b2_dynamicBody;
};
body = (_world as Box2DWorld).physWorld.CreateBody(_local3);
var _local4:b2FixtureDef = new b2FixtureDef();
_local4.shape = _local2;
_local4.density = _local1.density;
_local4.friction = _local1.friction;
_local4.restitution = _local1.restitution;
_local4.isSensor = _local1.isSensor;
_local4.filter.categoryBits = _local1.categoryBits;
_local4.filter.maskBits = _local1.maskBits;
_local4.filter.groupIndex = _local1.groupIndex;
_local4.userData = this;
body.CreateFixture(_local4);
var _local5:b2FixtureDef = new b2FixtureDef();
_local5.density = _local1.density;
_local5.friction = _local1.friction;
_local5.restitution = _local1.restitution;
_local5.isSensor = _local1.isSensor;
_local5.filter.categoryBits = _local1.categoryBits;
_local5.filter.maskBits = _local1.maskBits;
_local5.filter.groupIndex = _local1.groupIndex;
_local5.userData = this;
var _local6:b2CircleShape = new b2CircleShape(((_local1.height / 2) / (_world as Box2DWorld).physScale));
_local6.SetLocalPosition(new b2Vec2(((-(_local1.width) / 2) / (_world as Box2DWorld).physScale), 0));
_local5.shape = _local6;
body.CreateFixture(_local5);
_local6 = new b2CircleShape(((_local1.height / 2) / (_world as Box2DWorld).physScale));
_local6.SetLocalPosition(new b2Vec2(((_local1.width / 2) / (_world as Box2DWorld).physScale), 0));
_local5.shape = _local6;
body.CreateFixture(_local5);
}
}
}//package entities
Section 171
//DynamicRectParams (entities.DynamicRectParams)
package entities {
import AKEngine.entity.box2d.*;
public class DynamicRectParams extends Box2DEntityParams {
public var textureName:String;
public var height:Number;
public var width:Number;
public function DynamicRectParams(_arg1:Object=null){
width = 0;
height = 0;
textureName = "StickTextureAsset";
super(_arg1);
customClass = DynamicRect;
xmlTag = "DynamicRect";
}
}
}//package entities
Section 172
//Hero (entities.Hero)
package entities {
import flash.display.*;
import AKEngine.managers.*;
import AKEngine.entity.*;
public class Hero extends AnimatedEntity {
public var heroCollisionArea:MovieClip;
private var _newIdleAnimFrame:Number;
private var startWinAnim:Boolean;
private var _idleFrame:Number;
public function Hero(_arg1:World, _arg2:HeroParams){
super(_arg1, _arg2);
var _local3:Class = AssetsManager.instance.getAssetClass("heroCollisionArea");
heroCollisionArea = (new (_local3) as MovieClip);
heroCollisionArea.x = -44;
heroCollisionArea.y = -90;
heroCollisionArea.alpha = 0.01;
container.addChild(heroCollisionArea);
startWinAnim = false;
_idleFrame = 0;
_newIdleAnimFrame = (50 + (Math.random() * 100));
}
override protected function addAnimations():void{
var _local1:Class = AssetsManager.instance.getAssetClass("heroStatic");
var _local2:MovieClip = (new (_local1) as MovieClip);
_local2.x = -80;
_local2.y = -118;
addAnimation("static", _local2, 0, false);
var _local3:Class = AssetsManager.instance.getAssetClass("heroCatch1");
var _local4:MovieClip = (new (_local3) as MovieClip);
_local4.x = -80;
_local4.y = -118;
addAnimation("catch1", _local4, 100, false);
var _local5:Class = AssetsManager.instance.getAssetClass("heroCatch2");
var _local6:MovieClip = (new (_local5) as MovieClip);
_local6.x = -80;
_local6.y = -118;
addAnimation("catch2", _local6, 100, false);
var _local7:Class = AssetsManager.instance.getAssetClass("heroIdle1");
var _local8:MovieClip = (new (_local7) as MovieClip);
_local8.x = -80;
_local8.y = -118;
addAnimation("idle1", _local8, 100, false);
var _local9:Class = AssetsManager.instance.getAssetClass("heroIdle2");
var _local10:MovieClip = (new (_local9) as MovieClip);
_local10.x = -80;
_local10.y = -118;
addAnimation("idle2", _local10, 100, false);
var _local11:Class = AssetsManager.instance.getAssetClass("heroIdle3");
var _local12:MovieClip = (new (_local11) as MovieClip);
_local12.x = -80;
_local12.y = -118;
addAnimation("idle3", _local12, 100, false);
var _local13:Class = AssetsManager.instance.getAssetClass("heroIdle4");
var _local14:MovieClip = (new (_local13) as MovieClip);
_local14.x = -80;
_local14.y = -118;
addAnimation("idle4", _local14, 100, false);
var _local15:Class = AssetsManager.instance.getAssetClass("HeroWinAsset");
var _local16:MovieClip = new (_local15);
_local16.x = -80;
_local16.y = -118;
addAnimation("win", _local16, 100, true);
}
override public function postUpdate(_arg1:Number):void{
var _local2:int;
var _local3:String;
super.postUpdate(_arg1);
if (!isAnimating){
if (startWinAnim){
playAnimation("win", true);
startWinAnim = false;
};
_idleFrame++;
};
if ((((((_currentAnimation.name == "idle3")) && ((_currentFrame == 15)))) || ((((_currentAnimation.name == "idle4")) && ((_currentFrame == 20)))))){
SoundManager.instance.playSound("sndClothingRustle");
};
if (_idleFrame >= _newIdleAnimFrame){
_local2 = (1 + Math.floor((Math.random() * 4)));
_local3 = ("idle" + _local2.toString());
playAnimation(_local3, true);
_idleFrame = 0;
_newIdleAnimFrame = (50 + (Math.random() * 100));
};
}
public function levelComplete():void{
startWinAnim = true;
}
}
}//package entities
Section 173
//HeroParams (entities.HeroParams)
package entities {
import AKEngine.entity.*;
public class HeroParams extends AnimatedEntityParams {
public function HeroParams(_arg1:Object=null){
super(_arg1);
customClass = Hero;
xmlTag = "Hero";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
rotation = parseFloat(_arg1.@rotation);
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@rotation = rotation;
return (_local1);
}
override public function clone(){
return (new HeroParams({forcedName:forcedName, layer:layer, x:x, y:y, rotation:rotation}));
}
}
}//package entities
Section 174
//Magnet (entities.Magnet)
package entities {
import flash.display.*;
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Magnet extends Box2DEntity {
public function Magnet(_arg1:Box2DWorld, _arg2:MagnetParams){
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local1:MagnetParams = (params as MagnetParams);
var _local2:Class = AssetsManager.instance.getAssetClass("MagnetAsset");
skin = (new (_local2) as MovieClip);
}
override public function postUpdate(_arg1:Number):void{
var _local2:MagnetParams = (params as MagnetParams);
super.postUpdate(_arg1);
}
override public function update(_arg1:Number):void{
var _local6:Coin;
var _local7:b2Body;
var _local8:b2Vec2;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local2:MagnetParams = (params as MagnetParams);
var _local3:b2Vec2 = body.GetWorldCenter();
var _local4:Array = _world.getChildrenByType(Coin);
var _local5:int;
while (_local5 < _local4.length) {
_local6 = (_local4[_local5] as Coin);
_local7 = _local6.body;
_local8 = _local7.GetWorldCenter();
_local9 = (_local8.x - _local3.x);
_local10 = (_local8.y - _local3.y);
_local11 = Math.sqrt(((_local9 * _local9) + (_local10 * _local10)));
if ((((_local11 < Number.MIN_VALUE)) || ((_local11 > (_local2.maxDistance / (_world as Box2DWorld).physScale))))){
} else {
_local12 = new b2Vec2(_local9, _local10);
_local12.Multiply(((-(_local2.strength) / _local11) / _local11));
_local7.ApplyImpulse(_local12, _local8);
};
_local5++;
};
}
override protected function createBody():void{
var _local1:MagnetParams;
_local1 = (params as MagnetParams);
var _local2:b2CircleShape = new b2CircleShape((32 / (_world as Box2DWorld).physScale));
var _local3:b2BodyDef = new b2BodyDef();
_local3.position.Set((_local1.x / (_world as Box2DWorld).physScale), (_local1.y / (_world as Box2DWorld).physScale));
_local3.angle = _local1.rotation;
_local3.bullet = _local1.isBullet;
_local3.fixedRotation = _local1.isFixedRotation;
_local3.linearDamping = _local1.linearDamping;
_local3.angularDamping = _local1.angularDamping;
if (_local1.isStatic){
_local3.type = b2Body.b2_staticBody;
} else {
_local3.type = b2Body.b2_dynamicBody;
};
body = (_world as Box2DWorld).physWorld.CreateBody(_local3);
var _local4:b2FixtureDef = new b2FixtureDef();
_local4.shape = _local2;
_local4.density = _local1.density;
_local4.friction = _local1.friction;
_local4.restitution = _local1.restitution;
_local4.isSensor = _local1.isSensor;
_local4.filter.categoryBits = _local1.categoryBits;
_local4.filter.maskBits = _local1.maskBits;
_local4.filter.groupIndex = _local1.groupIndex;
_local4.userData = this;
body.CreateFixture(_local4);
}
}
}//package entities
Section 175
//MagnetParams (entities.MagnetParams)
package entities {
import AKEngine.entity.box2d.*;
public class MagnetParams extends Box2DEntityParams {
public var strength:Number;
public var maxDistance:Number;
public function MagnetParams(_arg1:Object=null){
strength = 2;
maxDistance = 200;
super(_arg1);
customClass = Magnet;
xmlTag = "Magnet";
}
override public function parseXML(_arg1:XML):void{
forcedName = _arg1.@forcedName;
strength = parseFloat(_arg1.@strength);
maxDistance = parseFloat(_arg1.@maxDistance);
layer = parseInt(_arg1.@layer);
x = parseFloat(_arg1.@x);
y = parseFloat(_arg1.@y);
rotation = parseFloat(_arg1.@rotation);
density = parseFloat(_arg1.@density);
friction = parseFloat(_arg1.@friction);
restitution = parseFloat(_arg1.@restitution);
linearDamping = parseFloat(_arg1.@linearDamping);
angularDamping = parseFloat(_arg1.@angularDamping);
isFixedRotation = (_arg1.@isFixedRotation.toLowerCase() == "true");
isStatic = (_arg1.@isStatic.toLowerCase() == "true");
isSensor = (_arg1.@isSensor.toLowerCase() == "true");
isBullet = (_arg1.@isBullet.toLowerCase() == "true");
categoryBits = parseInt(_arg1.@categoryBits);
maskBits = parseInt(_arg1.@maskBits);
groupIndex = parseInt(_arg1.@groupIndex);
}
override public function toXML():XML{
var _local1:XML = XML((("<" + xmlTag) + "/>"));
_local1.@forcedName = forcedName;
_local1.@strength = strength;
_local1.@maxDistance = maxDistance;
_local1.@layer = layer;
_local1.@x = x;
_local1.@y = y;
_local1.@rotation = rotation;
_local1.@density = density;
_local1.@friction = friction;
_local1.@restitution = restitution;
_local1.@linearDamping = linearDamping;
_local1.@angularDamping = angularDamping;
_local1.@isFixedRotation = isFixedRotation;
_local1.@isStatic = isStatic;
_local1.@isSensor = isSensor;
_local1.@isBullet = isBullet;
_local1.@categoryBits = categoryBits;
_local1.@maskBits = maskBits;
_local1.@groupIndex = groupIndex;
return (_local1);
}
override public function clone(){
return (new MagnetParams({forcedName:forcedName, strength:strength, maxDistance:maxDistance, layer:layer, x:x, y:y, rotation:rotation, density:density, friction:friction, restitution:restitution, linearDamping:linearDamping, angularDamping:angularDamping, isFixedRotation:isFixedRotation, isStatic:isStatic, isSensor:isSensor, isBullet:isBullet, categoryBits:categoryBits, maskBits:maskBits, groupIndex:groupIndex}));
}
}
}//package entities
Section 176
//BezierSegment (fl.motion.BezierSegment)
package fl.motion {
import flash.geom.*;
public class BezierSegment {
public var a:Point;
public var c:Point;
public var b:Point;
public var d:Point;
public function BezierSegment(_arg1:Point, _arg2:Point, _arg3:Point, _arg4:Point){
this.a = _arg1;
this.b = _arg2;
this.c = _arg3;
this.d = _arg4;
}
public function getValue(_arg1:Number):Point{
var _local2:Number = this.a.x;
var _local3:Number = (((((_arg1 * _arg1) * (this.d.x - _local2)) + ((3 * (1 - _arg1)) * ((_arg1 * (this.c.x - _local2)) + ((1 - _arg1) * (this.b.x - _local2))))) * _arg1) + _local2);
var _local4:Number = this.a.y;
var _local5:Number = (((((_arg1 * _arg1) * (this.d.y - _local4)) + ((3 * (1 - _arg1)) * ((_arg1 * (this.c.y - _local4)) + ((1 - _arg1) * (this.b.y - _local4))))) * _arg1) + _local4);
return (new Point(_local3, _local5));
}
public function getYForX(_arg1:Number, _arg2:Array=null):Number{
var _local6:Number;
if (this.a.x < this.d.x){
if (_arg1 <= (this.a.x + 1E-16)){
return (this.a.y);
};
if (_arg1 >= (this.d.x - 1E-16)){
return (this.d.y);
};
} else {
if (_arg1 >= (this.a.x + 1E-16)){
return (this.a.y);
};
if (_arg1 <= (this.d.x - 1E-16)){
return (this.d.y);
};
};
if (!_arg2){
_arg2 = getCubicCoefficients(this.a.x, this.b.x, this.c.x, this.d.x);
};
var _local3:Array = getCubicRoots(_arg2[0], _arg2[1], _arg2[2], (_arg2[3] - _arg1));
var _local4:Number = NaN;
if (_local3.length == 0){
_local4 = 0;
} else {
if (_local3.length == 1){
_local4 = _local3[0];
} else {
for each (_local6 in _local3) {
if ((((0 <= _local6)) && ((_local6 <= 1)))){
_local4 = _local6;
break;
};
};
};
};
if (isNaN(_local4)){
return (NaN);
};
var _local5:Number = getSingleValue(_local4, this.a.y, this.b.y, this.c.y, this.d.y);
return (_local5);
}
public static function getCubicCoefficients(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Array{
return ([(((-(_arg1) + (3 * _arg2)) - (3 * _arg3)) + _arg4), (((3 * _arg1) - (6 * _arg2)) + (3 * _arg3)), ((-3 * _arg1) + (3 * _arg2)), _arg1]);
}
public static function getSingleValue(_arg1:Number, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0):Number{
return ((((((_arg1 * _arg1) * (_arg5 - _arg2)) + ((3 * (1 - _arg1)) * ((_arg1 * (_arg4 - _arg2)) + ((1 - _arg1) * (_arg3 - _arg2))))) * _arg1) + _arg2));
}
public static function getCubicRoots(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):Array{
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:int;
var _local16:Number;
if (!_arg1){
return (BezierSegment.getQuadraticRoots(_arg2, _arg3, _arg4));
};
if (_arg1 != 1){
_arg2 = (_arg2 / _arg1);
_arg3 = (_arg3 / _arg1);
_arg4 = (_arg4 / _arg1);
};
var _local5:Number = (((_arg2 * _arg2) - (3 * _arg3)) / 9);
var _local6:Number = (((((_arg2 * _arg2) - (3 * _arg3)) / 9) * _local5) * _local5);
var _local7:Number = ((((((2 * _arg2) * _arg2) * _arg2) - ((9 * _arg2) * _arg3)) + (27 * _arg4)) / 54);
var _local8:Number = (_local6 - (_local7 * _local7));
if (_local8 >= 0){
if (!_local5){
return ([0]);
};
_local9 = Math.acos((_local7 / Math.sqrt(_local6)));
_local10 = Math.sqrt(_local5);
_local11 = (((-2 * _local10) * Math.cos((_local9 / 3))) - (_arg2 / 3));
_local12 = (((-2 * _local10) * Math.cos(((_local9 + (2 * Math.PI)) / 3))) - (_arg2 / 3));
_local13 = (((-2 * _local10) * Math.cos(((_local9 + (4 * Math.PI)) / 3))) - (_arg2 / 3));
return ([_local11, _local12, _local13]);
//unresolved jump
};
_local14 = Math.pow((Math.sqrt(-(_local8)) + Math.abs(_local7)), (1 / 3));
_local15 = ((_local7)>0) ? 1 : ((_local7 < 0)) ? -1 : 0;
_local16 = ((-(_local15) * (_local14 + (_local5 / _local14))) - (_arg2 / 3));
return ([_local16]);
}
public static function getQuadraticRoots(_arg1:Number, _arg2:Number, _arg3:Number):Array{
var _local7:Number;
var _local4:Array = [];
if (!_arg1){
if (!_arg2){
return ([]);
};
_local4[0] = (-(_arg3) / _arg2);
return (_local4);
};
var _local5:Number = ((_arg2 * _arg2) - ((4 * _arg1) * _arg3));
var _local6:int = ((_local5)>0) ? 1 : ((_local5 < 0)) ? -1 : 0;
if (_local6 < 0){
return ([]);
};
if (!_local6){
_local4[0] = (-(_arg2) / (2 * _arg1));
} else {
_local4[0] = (_local4[1] = (-(_arg2) / (2 * _arg1)));
_local7 = (Math.sqrt(_local5) / (2 * _arg1));
_local4[0] = (_local4[0] - _local7);
_local4[1] = (_local4[1] + _local7);
};
return (_local4);
}
}
}//package fl.motion
Section 177
//BezierPoint (helpers.BezierPoint)
package helpers {
import flash.geom.*;
public class BezierPoint extends Point {
public var ix:Number;
public var iy:Number;
public var distMult:Number;
public var timeMult:Number;
public var isAnchor:Boolean;
public function BezierPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):void{
this.x = _arg1;
this.y = _arg2;
this.isAnchor = _arg3;
init();
}
public function update(_arg1:Number):void{
var _local3:Number;
var _local2:Number = 0;
x = (ix + _local2);
if (!isAnchor){
_local3 = (distMult * Math.sin((_arg1 * timeMult)));
y = (iy + _local3);
};
}
private function init():void{
ix = x;
iy = y;
timeMult = (1 + (Math.random() * 2));
distMult = (5 + (Math.random() * 20));
}
}
}//package helpers
Section 178
//Fader (helpers.Fader)
package helpers {
import flash.display.*;
import AKEngine.managers.*;
import caurina.transitions.*;
public class Fader {
private var window:Sprite;
private var fadeTime:Number;
private var callbackFunc:Function;
private static var instance:Fader;
public function Fader():void{
init();
}
private function fadeInComplete():void{
Tweener.addTween(window, {alpha:0, time:fadeTime, transition:"linear", onComplete:fadeOutComplete});
callbackFunc();
}
private function fadeOutComplete():void{
window.visible = false;
}
public function fade(_arg1:Function, _arg2:Number=0.3):void{
this.callbackFunc = _arg1;
this.fadeTime = _arg2;
window.visible = true;
window.alpha = 0;
Tweener.addTween(window, {alpha:1, time:_arg2, transition:"linear", onComplete:fadeInComplete});
}
private function init():void{
var _local1:Class = AssetsManager.instance.getAssetClass("FaderWindow");
window = new (_local1);
Sticks.faderContainer.addChild(window);
window.visible = false;
}
public static function getInstance():Fader{
if (instance == null){
instance = new (Fader);
};
return (instance);
}
}
}//package helpers
Section 179
//LevelInfo (helpers.LevelInfo)
package helpers {
public class LevelInfo {
public var isCompleted:Boolean;
public var lastScore:int;
public var num:Number;
public var name:String;
public var bestScore:int;
public var isOpen:Boolean;
public var woodMax:Number;
public var coinsToWin:Number;
public function LevelInfo(_arg1:Number, _arg2:String){
this.num = _arg1;
this.name = _arg2;
clear();
}
public function clear():void{
isOpen = false;
isCompleted = false;
bestScore = 0;
lastScore = 0;
coinsToWin = 0;
woodMax = 0;
}
}
}//package helpers
Section 180
//MCEffect (helpers.MCEffect)
package helpers {
import flash.display.*;
import entities.*;
import com.cartogrammar.drawing.*;
public class MCEffect {
private var container:Sprite;
private var points:Array;
private var holst:Sprite;
public var magnet:Magnet;
private var circle:Sprite;
public var coin:Coin;
private var line:Sprite;
private var time:Number;
public function MCEffect(_arg1:Magnet, _arg2:Coin, _arg3:Sprite){
this.magnet = _arg1;
this.coin = _arg2;
this.container = _arg3;
init();
}
private function updatePoints(_arg1:Number):void{
var _local3:Number;
var _local4:BezierPoint;
var _local2:int;
while (_local2 < points.length) {
_local3 = ((_arg1 / 10) * _local2);
_local4 = points[_local2];
_local4.ix = _local3;
_local2++;
};
}
private function drawCurve(_arg1:Number):void{
var _local3:BezierPoint;
time = (time + 0.1);
var _local2:int;
while (_local2 < points.length) {
_local3 = points[_local2];
_local3.update(time);
_local2++;
};
line.graphics.clear();
line.graphics.lineStyle(_arg1, 13408563);
CubicBezier.curveThroughPoints(line.graphics, points);
}
private function drawCircle(_arg1:Number):void{
circle.x = (coin.body.GetPosition().x * 30);
circle.y = (coin.body.GetPosition().y * 30);
circle.graphics.clear();
circle.graphics.lineStyle(_arg1, 13408563);
circle.graphics.drawCircle(0, 0, ((coin.params as CoinParams).radius + 2));
}
private function init():void{
var _local7:Number;
var _local8:Boolean;
var _local9:BezierPoint;
holst = new Sprite();
holst.mouseEnabled = false;
holst.mouseChildren = false;
container.addChild(holst);
line = new Sprite();
holst.addChild(line);
circle = new Sprite();
holst.addChild(circle);
line.x = (magnet.body.GetPosition().x * 30);
line.y = (magnet.body.GetPosition().y * 30);
var _local1:Number = ((coin.body.GetPosition().x - magnet.body.GetPosition().x) * 30);
var _local2:Number = ((coin.body.GetPosition().y - magnet.body.GetPosition().y) * 30);
var _local3:Number = Math.atan2(_local2, _local1);
line.rotation = ((_local3 * 180) / Math.PI);
time = 0;
var _local4:Number = ((Math.sqrt(((_local1 * _local1) + (_local2 * _local2))) - (coin.params as CoinParams).radius) - 2);
points = [];
var _local5:Number = 10;
var _local6:int;
while (_local6 <= _local5) {
_local7 = ((_local4 / _local5) * _local6);
_local8 = ((((_local6 == 0)) || ((_local6 == _local5)))) ? true : false;
_local9 = new BezierPoint(_local7, 0, _local8);
points.push(_local9);
_local6++;
};
}
public function update():void{
var _local5:Number;
var _local1:Number = Math.atan2(((coin.body.GetPosition().y - magnet.body.GetPosition().y) * 30), ((coin.body.GetPosition().x - magnet.body.GetPosition().x) * 30));
line.rotation = ((_local1 * 180) / Math.PI);
var _local2:Number = ((coin.body.GetPosition().x - magnet.body.GetPosition().x) * 30);
var _local3:Number = ((coin.body.GetPosition().y - magnet.body.GetPosition().y) * 30);
var _local4:Number = ((Math.sqrt(((_local2 * _local2) + (_local3 * _local3))) - (coin.params as CoinParams).radius) - 2);
if ((((_local4 > 0)) && ((_local4 < (magnet.params as MagnetParams).maxDistance)))){
_local5 = (0.3 * Math.floor(((((magnet.params as MagnetParams).maxDistance - _local4) / (magnet.params as MagnetParams).maxDistance) * 10)));
holst.visible = true;
updatePoints(_local4);
drawCurve(_local5);
drawCircle(_local5);
} else {
holst.visible = false;
};
}
public function dispose():void{
container.removeChild(holst);
}
}
}//package helpers
Section 181
//StickRemoveEffect (helpers.StickRemoveEffect)
package helpers {
import flash.display.*;
import entities.worlds.*;
import flash.filters.*;
public class StickRemoveEffect {
private var container:Sprite;
private var damping:Number;// = 0.98
private var vy:Number;
private var time:Number;
private var dangle:Number;
private var vx:Number;
private var world:GameWorld;
public function StickRemoveEffect(_arg1:GameWorld, _arg2:Sprite){
this.world = _arg1;
this.container = _arg2;
_arg2.parent.removeChild(_arg2);
_arg1.deepSprite.addChild(_arg2);
dangle = (-10 + (Math.random() * 20));
vx = (-5 + (Math.random() * 10));
vy = (-10 + (Math.random() * 8));
time = 0;
_arg1.stickRemoveEffects.push(this);
}
public function update():void{
container.rotation = (container.rotation + dangle);
container.x = (container.x + vx);
container.y = (container.y + vy);
container.scaleX = (container.scaleX * damping);
container.scaleY = (container.scaleY * damping);
vy = (vy + 0.5);
dangle = (dangle * damping);
time = (time + 1);
if (container.y > (480 + 200)){
dispose();
};
var _local1:Number = Math.floor((time / 5));
var _local2:BlurFilter = new BlurFilter(_local1, _local1, 2);
container.filters = [_local2];
}
public function dispose():void{
container.parent.removeChild(container);
var _local1:int = world.stickRemoveEffects.indexOf(this);
world.stickRemoveEffects.splice(_local1, 1);
}
}
}//package helpers
Section 182
//XMLLevelParser (helpers.XMLLevelParser)
package helpers {
import flash.events.*;
import AKEngine.entity.*;
import entities.*;
import AKEngine.entity.box2d.custom.*;
public class XMLLevelParser extends EventDispatcher {
private var _world:World;
public function XMLLevelParser(_arg1:World){
_world = _arg1;
}
public function parseXML(_arg1:XML):void{
var _local4:EntityParams;
var _local5:XML;
var _local2:Number = GameData.instance.currentLevelNum;
var _local3:LevelInfo = (GameData.instance.levelInfos[_local2] as LevelInfo);
_local3.coinsToWin = parseInt(_arg1.LevelSettings.@coinsToWin);
_local3.woodMax = parseInt(_arg1.LevelSettings.@woodMax);
for each (_local5 in _arg1.elements()) {
if (_local5.name() == "Circle"){
_local4 = new CircleParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "Rect"){
_local4 = new RectParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "Poly"){
_local4 = new PolyParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "Hinge"){
_local4 = new HingeParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "Motor"){
_local4 = new MotorParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "DistanceJoint"){
_local4 = new DistanceJointParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "Coin"){
_local4 = new CoinParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "Hero"){
_local4 = new HeroParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "Magnet"){
_local4 = new MagnetParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
} else {
if (_local5.name() == "CoinsEmitter"){
_local4 = new CoinsEmitterParams();
_local4.parseXML(_local5);
_world.entitiesParams.push(_local4);
};
};
};
};
};
};
};
};
};
};
};
}
public function loadLevel(_arg1:Number):void{
parseXML((GameData.instance.levels[(_arg1 - 1)] as XML));
dispatchEvent(new Event(Event.COMPLETE));
}
}
}//package helpers
Section 183
//ContactsManager (managers.ContactsManager)
package managers {
import AKEngine.managers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Contacts.*;
import entities.*;
import AKEngine.entity.box2d.custom.*;
public class ContactsManager extends b2ContactListener {
public function ContactsManager():void{
}
protected function getHitVolume(_arg1:Box2DEntity, _arg2:Box2DEntity, _arg3:b2Vec2):Number{
var _local4:b2Vec2 = _arg1.body.GetLinearVelocity().Copy();
_local4.Multiply(_arg1.body.GetMass());
var _local5:b2Vec2 = _arg2.body.GetLinearVelocity().Copy();
_local5.Multiply(_arg2.body.GetMass());
_local4.Subtract(_local5);
var _local6:Number = Math.abs(b2Math.Dot(_local4, _arg3));
if (_local6 > 40){
_local6 = 40;
};
_local6 = (_local6 / 40);
return (_local6);
}
private function coinHit(_arg1:Box2DEntity, _arg2:Box2DEntity, _arg3:b2ContactImpulse):void{
var _local4:Number = Math.sqrt(((_arg3.normalImpulses[0] * _arg3.normalImpulses[0]) + (_arg3.tangentImpulses[0] * _arg3.tangentImpulses[0])));
var _local5:Number = _local4;
if (_local5 > 20){
_local5 = 20;
};
if (_local5 > 2){
_local5 = (_local5 / 20);
SoundManager.instance.playSound("sndCoinHit", _local5);
};
}
private function checkObjs(_arg1:Box2DEntity, _arg2:Box2DEntity, _arg3:b2ContactImpulse):void{
if ((_arg1 is DynamicRect)){
if ((((_arg2 is DynamicRect)) || ((_arg2 is Poly)))){
woodHit(_arg1, _arg2, _arg3);
} else {
if ((_arg2 is Coin)){
coinHit(_arg1, _arg2, _arg3);
};
};
} else {
if ((_arg1 is Poly)){
if ((_arg2 is DynamicRect)){
woodHit(_arg1, _arg2, _arg3);
} else {
if ((_arg2 is Coin)){
coinHit(_arg1, _arg2, _arg3);
};
};
} else {
if ((_arg1 is Coin)){
if ((((((_arg2 is DynamicRect)) || ((_arg2 is Poly)))) || ((_arg2 is Coin)))){
coinHit(_arg1, _arg2, _arg3);
};
};
};
};
}
private function woodHit(_arg1:Box2DEntity, _arg2:Box2DEntity, _arg3:b2ContactImpulse):void{
var _local4:Number = Math.sqrt(((_arg3.normalImpulses[0] * _arg3.normalImpulses[0]) + (_arg3.tangentImpulses[0] * _arg3.tangentImpulses[0])));
var _local5:Number = _local4;
if (_local5 > 50){
_local5 = 50;
};
if (_local5 > 2){
_local5 = (_local5 / 50);
SoundManager.instance.playSound("sndWoodHit", _local5);
};
}
override public function PostSolve(_arg1:b2Contact, _arg2:b2ContactImpulse):void{
var _local3:b2Fixture = _arg1.GetFixtureA();
var _local4:b2Fixture = _arg1.GetFixtureB();
var _local5:Box2DEntity = (_local3.GetUserData() as Box2DEntity);
var _local6:Box2DEntity = (_local4.GetUserData() as Box2DEntity);
if ((((((_local5 is Box2DEntity)) && ((_local6 is Box2DEntity)))) && (_arg1.IsTouching()))){
checkObjs(_local5, _local6, _arg2);
};
}
}
}//package managers
Section 184
//HintsAssetsManager (managers.HintsAssetsManager)
package managers {
import flash.events.*;
import flash.display.*;
import flash.system.*;
public class HintsAssetsManager extends EventDispatcher {
private var Assets:Class;
private var appDomain:ApplicationDomain;
private static var _instance:HintsAssetsManager;
public function HintsAssetsManager(){
Assets = HintsAssetsManager_Assets;
super();
}
public function initialize():void{
var _local1:Loader = new Loader();
_local1.contentLoaderInfo.addEventListener(Event.INIT, assetsInitHandler);
_local1.loadBytes(new Assets());
}
private function assetsInitHandler(_arg1:Event):void{
appDomain = _arg1.target.content.loaderInfo.applicationDomain;
dispatchEvent(new Event(Event.INIT));
}
public function getAssetClass(_arg1:String):Class{
if (!appDomain.hasDefinition(_arg1)){
trace((("<HintsAssetsManager> Error: There is no definition of class '" + _arg1) + "'"));
return (null);
};
return ((appDomain.getDefinition(_arg1) as Class));
}
public static function get instance():HintsAssetsManager{
if (!_instance){
_instance = new (HintsAssetsManager);
};
return (_instance);
}
}
}//package managers
Section 185
//HintsAssetsManager_Assets (managers.HintsAssetsManager_Assets)
package managers {
import mx.core.*;
public class HintsAssetsManager_Assets extends ByteArrayAsset {
}
}//package managers
Section 186
//HintsManager (managers.HintsManager)
package managers {
import flash.display.*;
import caurina.transitions.*;
public class HintsManager {
private var _parent:DisplayObjectContainer;
private var _time:int;
private var _hints:Array;
private var _delayTime:int;
public function HintsManager(_arg1:DisplayObjectContainer){
_parent = _arg1;
init();
}
public function update():void{
if (_time >= _delayTime){
_time = 0;
if (_hints.length > 0){
startHint();
};
};
_time++;
}
private function startHint():void{
var _local1:Sprite = _hints[0];
_hints.splice(0, 1);
parseHintProps(_local1);
}
private function init():void{
var _local3:Sprite;
_delayTime = 80;
_delayTime = (_delayTime * 1);
_time = (_delayTime - 10);
_hints = [];
var _local1 = (("Hints" + GameData.instance.currentLevelNum) + "Asset");
var _local2:Class = HintsAssetsManager.instance.getAssetClass(_local1);
if (_local2){
_local3 = (new (_local2) as Sprite);
_parent.addChild(_local3);
_local3.mouseEnabled = false;
_local3.mouseChildren = false;
getHintsList(_local3);
};
}
private function getHintsList(_arg1:Sprite):void{
var _local2:int;
var _local4:Sprite;
var _local5:int;
var _local6:Sprite;
_local2 = 0;
while (_local2 < _arg1.numChildren) {
_local4 = (_arg1.getChildAt(_local2) as Sprite);
_local5 = getHintIndex(_local4);
if (!isNaN(_local5)){
_hints[_local5] = _local4;
_local4.alpha = 0;
if ((_local4 is MovieClip)){
(_local4 as MovieClip).stop();
};
};
_local2++;
};
var _local3:Boolean;
_local2 = 0;
while (_local2 < _hints.length) {
_local6 = _hints[_local2];
if (!_local6){
_local3 = false;
break;
};
_local2++;
};
if (!_local3){
trace("HINTS ERROR! some hints are missing");
};
}
private function getHintIndex(_arg1:Sprite):int{
var _local2:Array = _arg1.name.split("_");
var _local3:String = _local2[0];
var _local4:int = int(_local3.substr(1, _local3.length));
return (_local4);
}
private function parseHintProps(_arg1:Sprite):void{
var _local8:String;
var _local9:Array;
var _local10:String;
var _local11:Number;
var _local2:Number = 40;
var _local3:Number = 30;
var _local4:String = _arg1.name;
var _local5:Array = _local4.split("_");
var _local6 = 1;
while (_local6 < _local5.length) {
_local8 = _local5[_local6];
_local9 = _local8.split("I");
_local10 = _local9[0];
_local11 = _local9[1];
switch (_local10){
case "a":
_local2 = _local11;
break;
case "v":
_local3 = _local11;
break;
case "p":
_time = (_time + _local11);
break;
case "m":
_time = (_time - _local11);
break;
};
_local6++;
};
if ((_arg1 is MovieClip)){
(_arg1 as MovieClip).play();
};
_local2 = (_local2 / 40);
var _local7:Number = _arg1.y;
_arg1.y = (_arg1.y - _local3);
Tweener.addTween(_arg1, {alpha:1, y:_local7, time:_local2, transition:"easeoutquad"});
}
}
}//package managers
Section 187
//IntroAssetsManager (managers.IntroAssetsManager)
package managers {
import flash.events.*;
import flash.display.*;
import flash.system.*;
public class IntroAssetsManager extends EventDispatcher {
private var Assets:Class;
private var appDomain:ApplicationDomain;
private static var _instance:IntroAssetsManager;
public function IntroAssetsManager(){
Assets = IntroAssetsManager_Assets;
super();
}
public function initialize():void{
var _local1:Loader = new Loader();
_local1.contentLoaderInfo.addEventListener(Event.INIT, assetsInitHandler);
_local1.loadBytes(new Assets());
}
private function assetsInitHandler(_arg1:Event):void{
appDomain = _arg1.target.content.loaderInfo.applicationDomain;
dispatchEvent(new Event(Event.INIT));
}
public function getAssetClass(_arg1:String):Class{
if (!appDomain.hasDefinition(_arg1)){
trace((("<IntroAssetsManager> Error: There is no definition of class '" + _arg1) + "'"));
return (null);
};
return ((appDomain.getDefinition(_arg1) as Class));
}
public static function get instance():IntroAssetsManager{
if (!_instance){
_instance = new (IntroAssetsManager);
};
return (_instance);
}
}
}//package managers
Section 188
//IntroAssetsManager_Assets (managers.IntroAssetsManager_Assets)
package managers {
import mx.core.*;
public class IntroAssetsManager_Assets extends ByteArrayAsset {
}
}//package managers
Section 189
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 190
//EdgeMetrics (mx.core.EdgeMetrics)
package mx.core {
public class EdgeMetrics {
public var top:Number;
public var left:Number;
public var bottom:Number;
public var right:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0);
;
public function EdgeMetrics(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0){
this.left = _arg1;
this.top = _arg2;
this.right = _arg3;
this.bottom = _arg4;
}
public function clone():EdgeMetrics{
return (new EdgeMetrics(left, top, right, bottom));
}
}
}//package mx.core
Section 191
//FlexMovieClip (mx.core.FlexMovieClip)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexMovieClip extends MovieClip {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexMovieClip(){
super();
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 192
//FlexSprite (mx.core.FlexSprite)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexSprite extends Sprite {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexSprite(){
super();
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 193
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 194
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 195
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(_arg1:Point):Point;
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(_arg1:String):void;
function set scaleX(_arg1:Number):void;
function set scaleY(_arg1:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(_arg1:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(_arg1:Point):Point;
function get height():Number;
function set blendMode(_arg1:String):void;
function get parent():DisplayObjectContainer;
function getBounds(_arg1:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(_arg1:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(_arg1:Number):void;
function set accessibilityProperties(_arg1:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(_arg1:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(_arg1:Number):void;
function set mask(_arg1:DisplayObject):void;
function getRect(_arg1:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(_arg1:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(_arg1:DisplayObject):Boolean;
function set opaqueBackground(_arg1:Object):void;
function set visible(_arg1:Boolean):void;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function get transform():Transform;
function set filters(_arg1:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(_arg1:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 196
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 197
//MovieClipAsset (mx.core.MovieClipAsset)
package mx.core {
public class MovieClipAsset extends FlexMovieClip implements IFlexAsset, IFlexDisplayObject, IBorder {
private var _measuredHeight:Number;
private var _measuredWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function MovieClipAsset(){
_measuredWidth = width;
_measuredHeight = height;
}
public function get measuredWidth():Number{
return (_measuredWidth);
}
public function get measuredHeight():Number{
return (_measuredHeight);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function get borderMetrics():EdgeMetrics{
if (scale9Grid == null){
return (EdgeMetrics.EMPTY);
};
return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom))));
}
}
}//package mx.core
Section 198
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 199
//SpriteAsset (mx.core.SpriteAsset)
package mx.core {
public class SpriteAsset extends FlexSprite implements IFlexAsset, IFlexDisplayObject, IBorder {
private var _measuredHeight:Number;
private var _measuredWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function SpriteAsset(){
_measuredWidth = width;
_measuredHeight = height;
}
public function get measuredWidth():Number{
return (_measuredWidth);
}
public function get measuredHeight():Number{
return (_measuredHeight);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function get borderMetrics():EdgeMetrics{
if (scale9Grid == null){
return (EdgeMetrics.EMPTY);
};
return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom))));
}
}
}//package mx.core
Section 200
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import mx.core.*;
import flash.display.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var _local2:String;
var _local4:String;
var _local5:Array;
var _local3:DisplayObject = _arg1;
while (_local3 != null) {
if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){
break;
};
_local4 = _local3.name;
if ((_local3 is IRepeaterClient)){
_local5 = IRepeaterClient(_local3).instanceIndices;
if (_local5){
_local4 = (_local4 + (("[" + _local5.join("][")) + "]"));
};
};
_local2 = ((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2);
_local3 = _local3.parent;
};
return (_local2);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 201
//Link (Playtomic.Link)
package Playtomic {
import flash.net.*;
public final class Link {
private static var Clicks:Array = new Array();
public static function Open(_arg1:String, _arg2:String, _arg3:String):Boolean{
var result:Boolean;
var url = _arg1;
var name = _arg2;
var group = _arg3;
var unique:int;
var bunique:int;
var total:int;
var btotal:int;
var fail:int;
var bfail:int;
var key:String = ((url + ".") + name);
var baseurl:String = url;
baseurl = baseurl.replace("http://", "");
if (baseurl.indexOf("/") > -1){
baseurl = baseurl.substring(0, baseurl.indexOf("/"));
};
if (baseurl.indexOf("?") > -1){
baseurl = baseurl.substring(0, baseurl.indexOf("?"));
};
baseurl = (("http://" + baseurl) + "/");
var baseurlname:String = baseurl;
if (baseurlname.indexOf("//") > -1){
baseurlname = baseurlname.substring((baseurlname.indexOf("//") + 2));
};
baseurlname = baseurlname.replace("www.", "");
if (baseurlname.indexOf("/") > -1){
baseurlname = baseurlname.substring(0, baseurlname.indexOf("/"));
};
try {
navigateToURL(new URLRequest(url));
if (Clicks.indexOf(key) > -1){
total = 1;
} else {
total = 1;
unique = 1;
Clicks.push(key);
};
if (Clicks.indexOf(baseurlname) > -1){
btotal = 1;
} else {
btotal = 1;
bunique = 1;
Clicks.push(baseurlname);
};
result = true;
} catch(err) {
fail = 1;
bfail = 1;
result = false;
};
Log.Link(baseurl, baseurlname.toLowerCase(), "DomainTotals", bunique, btotal, bfail);
Log.Link(url, name, group, unique, total, fail);
Log.ForceSend();
return (result);
}
}
}//package Playtomic
Section 202
//Log (Playtomic.Log)
package Playtomic {
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
import flash.external.*;
public final class Log {
private static const PingR:Timer = new Timer(30000);
private static const PingF:Timer = new Timer(60000);
private static var LevelAverages:Array = new Array();
private static var Customs:Array = new Array();
public static var Cookie:SharedObject;
public static var GUID:String = "";
private static var LevelRangeds:Array = new Array();
private static var Plays:int = 0;
public static var Enabled:Boolean = false;
private static var Pings:int = 0;
private static var FrozenQueue:Array = new Array();
public static var SourceUrl:String;
private static var HighestGoal:int = 0;
private static var FirstPing:Boolean = true;
private static var Frozen:Boolean = false;
public static var BaseUrl:String;
public static var Request:LogRequest;
public static var Queue:Boolean = true;
private static var LevelCounters:Array = new Array();
public static var SWFID:int = 0;
public static function Link(_arg1:String, _arg2:String, _arg3:String, _arg4:int, _arg5:int, _arg6:int):void{
if (!Enabled){
return;
};
Send(((((((((((("l/" + Clean(_arg2)) + "/") + Clean(_arg3)) + "/") + Clean(_arg1)) + "/") + _arg4) + "/") + _arg5) + "/") + _arg6));
}
public static function LevelAverageMetric(_arg1:String, _arg2, _arg3:int, _arg4:Boolean=false):void{
if (!Enabled){
return;
};
if (_arg4){
if (LevelAverages.indexOf(_arg1) > -1){
return;
};
LevelAverages.push(_arg1);
};
Send(((((("la/" + Clean(_arg1)) + "/") + Clean(_arg2)) + "/") + _arg3));
}
private static function Send(_arg1:String, _arg2:Boolean=false):void{
if (Frozen){
FrozenQueue.push(_arg1);
return;
};
Request.Queue(_arg1);
if (((((Request.Ready) || (_arg2))) || (!(Queue)))){
Request.Send();
Request = LogRequest.Create();
};
}
public static function CustomMetric(_arg1:String, _arg2:String=null, _arg3:Boolean=false):void{
if (!Enabled){
return;
};
if (_arg2 == null){
_arg2 = "";
};
if (_arg3){
if (Customs.indexOf(_arg1) > -1){
return;
};
Customs.push(_arg1);
};
Send(((("c/" + Clean(_arg1)) + "/") + Clean(_arg2)));
}
private static function Clean(_arg1:String):String{
while (_arg1.indexOf("/") > -1) {
_arg1 = _arg1.replace("/", "\\");
};
while (_arg1.indexOf("~") > -1) {
_arg1 = _arg1.replace("~", "-");
};
return (escape(_arg1));
}
public static function UnFreeze():void{
Frozen = false;
Request.MassQueue(FrozenQueue);
}
private static function GetCookie(_arg1:String):int{
if (Cookie.data[_arg1] == undefined){
return (0);
};
return (int(Cookie.data[_arg1]));
}
public static function View(_arg1:int=0, _arg2:String="", _arg3:String=""):void{
if (SWFID > 0){
return;
};
SWFID = _arg1;
GUID = _arg2;
Enabled = true;
if ((((SWFID == 0)) || ((GUID == "")))){
Enabled = false;
return;
};
if (((((!((_arg3.indexOf("http://") == 0))) && (!((Security.sandboxType == "localWithNetwork"))))) && (!((Security.sandboxType == "localTrusted"))))){
Enabled = false;
return;
};
SourceUrl = GetUrl(_arg3);
if ((((((SourceUrl == null)) || ((SourceUrl == "")))) || ((SourceUrl.indexOf("https://") == 0)))){
Enabled = false;
return;
};
Security.allowDomain((("http://g" + Log.GUID) + ".api.playtomic.com/"));
Security.allowInsecureDomain((("http://g" + Log.GUID) + ".api.playtomic.com/"));
Security.loadPolicyFile((("http://g" + Log.GUID) + ".api.playtomic.com/crossdomain.xml"));
Request = LogRequest.Create();
Cookie = SharedObject.getLocal("playtomic");
var _local4:int = GetCookie("views");
_local4++;
SaveCookie("views", _local4);
Send(("v/" + _local4), true);
PingF.addEventListener(TimerEvent.TIMER, PingServer);
PingF.start();
}
public static function Freeze():void{
Frozen = true;
}
public static function LevelCounterMetric(_arg1:String, _arg2, _arg3:Boolean=false):void{
if (!Enabled){
return;
};
if (_arg3){
if (LevelCounters.indexOf(_arg1) > -1){
return;
};
LevelCounters.push(_arg1);
};
Send(((("lc/" + Clean(_arg1)) + "/") + Clean(_arg2)));
}
public static function Play():void{
if (!Enabled){
return;
};
LevelCounters = new Array();
LevelAverages = new Array();
LevelRangeds = new Array();
Plays++;
Send(("p/" + Plays));
}
private static function GetUrl(_arg1:String):String{
var url:String;
var defaulturl = _arg1;
if (ExternalInterface.available){
try {
url = String(ExternalInterface.call("window.location.href.toString"));
} catch(s:Error) {
url = defaulturl;
};
} else {
if ((((defaulturl.indexOf("http://") == 0)) || ((defaulturl.indexOf("https://") == 0)))){
url = defaulturl;
};
};
if ((((((url == null)) || ((url == "")))) || ((url == "null")))){
if ((((Security.sandboxType == "localWithNetwork")) || ((Security.sandboxType == "localTrusted")))){
url = "http://local-testing/";
} else {
url = null;
};
};
return (escape(url));
}
public static function LevelRangedMetric(_arg1:String, _arg2, _arg3:int, _arg4:Boolean=false):void{
if (!Enabled){
return;
};
if (_arg4){
if (LevelRangeds.indexOf(_arg1) > -1){
return;
};
LevelRangeds.push(_arg1);
};
Send(((((("lr/" + Clean(_arg1)) + "/") + Clean(_arg2)) + "/") + _arg3));
}
private static function SaveCookie(_arg1:String, _arg2:int):void{
var _local3:SharedObject = SharedObject.getLocal("swfstats");
_local3.data[_arg1] = _arg2.toString();
_local3.flush();
}
public static function ForceSend():void{
if (!Enabled){
return;
};
Request.Send();
Request = LogRequest.Create();
if (FrozenQueue.length > 0){
Request.MassQueue(FrozenQueue);
};
}
private static function PingServer(... _args):void{
if (!Enabled){
return;
};
Pings++;
Send(((("t/" + (FirstPing) ? "y" : "n") + "/") + Pings), true);
if (FirstPing){
PingF.stop();
PingR.addEventListener(TimerEvent.TIMER, PingServer);
PingR.start();
FirstPing = false;
};
}
}
}//package Playtomic
Section 203
//LogRequest (Playtomic.LogRequest)
package Playtomic {
import flash.events.*;
import flash.net.*;
public final class LogRequest {
public var Ready:Boolean;// = false
private var Data:String;// = ""
private var Target:URLRequest;
private var Sender:URLLoader;
private var BaseUrl:String;
private static var Pool:Array = new Array();
private static var Failed:int = 0;
public function LogRequest(){
this.Sender = new URLLoader();
this.Sender.addEventListener(Event.COMPLETE, this.Dispose, false, 0, true);
this.Sender.addEventListener(IOErrorEvent.IO_ERROR, this.IOErrorHandler, false, 0, true);
this.Sender.addEventListener(HTTPStatusEvent.HTTP_STATUS, this.StatusChange, false, 0, true);
this.Sender.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.SecurityErrorHandler, false, 0, true);
this.Target = new URLRequest();
this.BaseUrl = ((("http://g" + Log.GUID) + ".api.playtomic.com/tracker/q.aspx?swfid=") + Log.SWFID);
}
public function Send():void{
this.Target.url = (((((((this.BaseUrl + "&q=") + this.Data) + "&url=") + Log.SourceUrl) + "&") + Math.random()) + "z");
this.Sender.load(this.Target);
}
private function SecurityErrorHandler(_arg1:SecurityErrorEvent):void{
}
private function IOErrorHandler(_arg1:IOErrorEvent):void{
Failed++;
}
public function Queue(_arg1:String):void{
if (Failed > 3){
return;
};
this.Data = (this.Data + (((this.Data == "")) ? "" : "~" + _arg1));
if (this.Data.length > 300){
this.Ready = true;
};
}
private function StatusChange(_arg1:HTTPStatusEvent):void{
}
public function MassQueue(_arg1:Array):void{
var _local3:LogRequest;
if (Failed > 3){
return;
};
var _local2:int = (_arg1.length - 1);
while (_local2 > -1) {
this.Data = (this.Data + (((this.Data == "")) ? "" : "~" + _arg1[_local2]));
_arg1.splice(_local2, 1);
if (this.Data.length > 300){
_local3 = Create();
_local3.MassQueue(_arg1);
this.Ready = true;
this.Send();
return;
};
_local2--;
};
Log.Request = this;
}
public function Dispose(_arg1:Event=null):void{
Pool.push(this);
}
public static function Create():LogRequest{
var _local1:LogRequest = ((Pool.length > 0)) ? (Pool.pop() as LogRequest) : new (LogRequest);
_local1.Data = "";
_local1.Ready = false;
return (_local1);
}
}
}//package Playtomic
Section 204
//FinalScreen (screens.FinalScreen)
package screens {
import flash.events.*;
import AKEngine.screens.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import managers.*;
import caurina.transitions.*;
import flash.text.*;
import flash.net.*;
public class FinalScreen extends AScreen {
private var container:Sprite;
private var selectLevel_bt:SimpleButton;
private var ok_bt:SimpleButton;
private var inner:Sprite;
private var submitScore_bt:SimpleButton;
private var window:Sprite;
private var intro:MovieClip;
private var score_tf:TextField;
public function FinalScreen():void{
}
private function introFinished():void{
SoundManager.instance.stopMusic();
stage.frameRate = 30;
GameData.instance.currentLevelNum = 0;
var _local1:GameScreen = new GameScreen();
changeScreen(_local1);
}
private function skipClickHandler(_arg1:MouseEvent):void{
endFinal();
}
override protected function init(_arg1:Event):void{
super.init(_arg1);
var _local2:Class = AssetsManager.instance.getAssetClass("FinalHolder");
window = new (_local2);
addChild(window);
container = (window.getChildByName("container") as Sprite);
inner = (window.getChildByName("inner") as Sprite);
submitScore_bt = (inner.getChildByName("submitScore_bt") as SimpleButton);
selectLevel_bt = (inner.getChildByName("selectLevel_bt") as SimpleButton);
score_tf = (inner.getChildByName("score_tf") as TextField);
ok_bt = (inner.getChildByName("ok_bt") as SimpleButton);
var _local3:Class = IntroAssetsManager.instance.getAssetClass("FinalAsset");
intro = new (_local3);
score_tf.text = getTotalScore().toString();
intro.x = 320;
intro.y = 240;
container.addChild(intro);
intro.addEventListener(Event.ENTER_FRAME, efHandler);
stage.frameRate = 25;
SoundManager.instance.playMusic("sndFinal", 0, false);
inner.visible = false;
selectLevel_bt.addEventListener(MouseEvent.CLICK, selectLevelClickHandler);
submitScore_bt.addEventListener(MouseEvent.CLICK, submitClickHandler);
ok_bt.addEventListener(MouseEvent.CLICK, okClickHandler);
}
private function submitClickHandler(_arg1:MouseEvent):void{
Sticks.topContainer.addChild(Preloader.agi);
Preloader.agi.showScoreboardSubmit(getTotalScore());
submitScore_bt.visible = false;
}
private function endFinal():void{
stage.frameRate = 30;
inner.visible = true;
inner.alpha = 0;
Tweener.addTween(inner, {alpha:1, time:0.5, transition:"linear"});
intro.stop();
intro.removeEventListener(Event.ENTER_FRAME, efHandler);
}
private function okClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("mailto:eugene.karataev@gmail.com"));
}
override protected function dispose(_arg1:Event):void{
selectLevel_bt.removeEventListener(MouseEvent.CLICK, selectLevelClickHandler);
submitScore_bt.removeEventListener(MouseEvent.CLICK, submitClickHandler);
}
private function getTotalScore():Number{
var _local3:LevelInfo;
var _local1:Number = 0;
var _local2:int;
while (_local2 < GameData.instance.levelInfos.length) {
_local3 = GameData.instance.levelInfos[_local2];
_local1 = (_local1 + _local3.bestScore);
_local2++;
};
return (_local1);
}
private function selectLevel():void{
SoundManager.instance.stopMusic();
var _local1:SelectLevelScreen = new SelectLevelScreen();
changeScreen(_local1);
}
private function efHandler(_arg1:Event):void{
if (intro.currentFrame == intro.totalFrames){
endFinal();
};
}
private function selectLevelClickHandler(_arg1:Event):void{
Fader.getInstance().fade(selectLevel);
}
}
}//package screens
Section 205
//GameScreen (screens.GameScreen)
package screens {
import flash.events.*;
import AKEngine.screens.*;
import AKEngine.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import managers.*;
import AKEngine.entity.box2d.*;
import entities.worlds.*;
import flash.filters.*;
public class GameScreen extends AScreen {
private var _hintsManager:HintsManager;
private var container:Sprite;
private var _factory:GameFactory;
private var topContainer:Sprite;
private var _uiBar:GameUIBar;
private var _world:GameWorld;
private var skin:Sprite;
private function levelLoadedHandler(_arg1:GameEvent):void{
_uiBar.initCoinIcons();
}
private function goFinalScreen():void{
SoundManager.instance.stopMusic();
var _local1:FinalScreen = new FinalScreen();
changeScreen(_local1);
}
override protected function dispose(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, update);
_world.dispose();
_world = null;
_factory.dispose();
_factory = null;
_hintsManager = null;
_uiBar.dispose();
_uiBar = null;
}
override protected function init(_arg1:Event):void{
super.init(_arg1);
var _local2:Class = AssetsManager.instance.getAssetClass("GameScreenAsset");
skin = new (_local2);
addChild(skin);
container = (skin.getChildByName("container") as Sprite);
topContainer = (skin.getChildByName("topContainer") as Sprite);
_factory = new GameFactory();
_world = new GameWorld(_factory, new Box2DWorldParams(), container);
_world.addEventListener(GameEvent.LEVEL_COMPLETE, levelCompleteHandler, false, 0, true);
_world.addEventListener(GameEvent.SELECT_LEVEL, selectLevelHandler, false, 0, true);
_world.addEventListener(GameEvent.UPDATE_UI, updateUIHandler, false, 0, true);
_hintsManager = new HintsManager(container);
_uiBar = new GameUIBar(_world, 0, 0);
_uiBar.addEventListener(GameEvent.SELECT_LEVEL, selectLevelHandler, false, 0, true);
addChild(_uiBar);
levelLoadedHandler(new GameEvent(GameEvent.LEVEL_LOADED));
addEventListener(Event.ENTER_FRAME, update, false, 0, true);
if (((SoundManager.instance.isMusicPlaying) && (SoundManager.instance.musicEnabled))){
SoundManager.instance.musicVolume = 1;
} else {
SoundManager.instance.playMusic("sndMusicLevel");
};
}
private function selectLevelHandler(_arg1:GameEvent):void{
SoundManager.instance.playSound("sndButtonPress");
Fader.getInstance().fade(selectLevel);
}
private function levelCompleteHandler(_arg1:GameEvent):void{
var _local3:LevelCompleteDialog;
_world.removeEventListener(GameEvent.LEVEL_COMPLETE, levelCompleteHandler);
_world.removeEventListener(GameEvent.SELECT_LEVEL, selectLevelHandler);
_uiBar.visible = false;
var _local2:BlurFilter = new BlurFilter(4, 4);
container.filters = [_local2];
if (GameData.instance.currentLevelNum == (GameData.instance.numLevels - 1)){
Fader.getInstance().fade(goFinalScreen);
} else {
_local3 = new LevelCompleteDialog();
_local3.addEventListener(GameEvent.SELECT_LEVEL, selectLevelHandler, false, 0, true);
_local3.addEventListener(GameEvent.NEXT_LEVEL, nextLevelHandler, false, 0, true);
topContainer.addChild(_local3);
};
}
private function selectLevel():void{
SoundManager.instance.stopMusic();
var _local1:SelectLevelScreen = new SelectLevelScreen();
changeScreen(_local1);
}
private function nextLevelHandler(_arg1:GameEvent):void{
GameData.instance.currentLevelNum++;
var _local2:GameScreen = new GameScreen();
changeScreen(_local2);
}
private function updateUIHandler(_arg1:GameEvent):void{
if (_uiBar){
_uiBar.updateState();
};
}
public function update(_arg1:Event):void{
_world.update(0);
_hintsManager.update();
_uiBar.update();
}
}
}//package screens
Section 206
//GameUIBar (screens.GameUIBar)
package screens {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import Box2D.Dynamics.Joints.*;
import entities.worlds.*;
import entities.*;
import toolbars.*;
import Playtomic.*;
public class GameUIBar extends AToolBar {
private var reset_bt:SimpleButton;
private var armorLogo_bt:SimpleButton;
private var hint_bt:SimpleButton;
private var _coinIcons:Array;
private var _currentLevelInfo:LevelInfo;
private var woodMeter:WoodMeter;
public function GameUIBar(_arg1:GameWorld, _arg2:Number=0, _arg3:Number=0){
super(_arg1, _arg2, _arg3);
_currentLevelInfo = (GameData.instance.levelInfos[GameData.instance.currentLevelNum] as LevelInfo);
var _local4:Class = AssetsManager.instance.getAssetClass("GameUIBarAsset");
_skin = (new (_local4) as MovieClip);
addChild(_skin);
reset_bt = (_skin.getChildByName("reset_bt") as SimpleButton);
hint_bt = (_skin.getChildByName("hint_bt") as SimpleButton);
armorLogo_bt = (_skin.getChildByName("armorLogo_bt") as SimpleButton);
(_skin["stopSimulationButton"] as SimpleButton).visible = false;
(_skin["stopSimulationButton"] as SimpleButton).addEventListener(MouseEvent.CLICK, stopSimulationClickHandler, false, 0, true);
(_skin["startSimulationButton"] as SimpleButton).addEventListener(MouseEvent.CLICK, startSimulationClickHandler, false, 0, true);
(_skin["selectLevelButton"] as SimpleButton).addEventListener(MouseEvent.CLICK, selectLevelClickHandler, false, 0, true);
woodMeter = new WoodMeter(_skin["woodBar"]);
reset_bt.addEventListener(MouseEvent.CLICK, resetClickHandler);
hint_bt.addEventListener(MouseEvent.CLICK, hintClickHandler);
armorLogo_bt.addEventListener(MouseEvent.CLICK, armorLogoClickHandler);
}
private function resetClickHandler(_arg1:MouseEvent):void{
var _local4:DynamicRect;
var _local2:Array = _world.getChildrenByType(DynamicRect);
var _local3:int = (_local2.length - 1);
while (_local3 >= 0) {
_local4 = _local2[_local3];
destroyRect(_local4);
_local3--;
};
if (_local2.length > 0){
SoundManager.instance.playSound("stickDeletedSound");
};
}
public function update():void{
var _local1:int = Math.floor((((_world as GameWorld).woodRemain / _currentLevelInfo.woodMax) * 100));
woodMeter.update(_local1);
}
override public function dispose():void{
(_skin["stopSimulationButton"] as SimpleButton).removeEventListener(MouseEvent.CLICK, stopSimulationClickHandler);
(_skin["startSimulationButton"] as SimpleButton).removeEventListener(MouseEvent.CLICK, startSimulationClickHandler);
(_skin["selectLevelButton"] as SimpleButton).removeEventListener(MouseEvent.CLICK, selectLevelClickHandler);
_coinIcons = null;
_currentLevelInfo = null;
super.dispose();
}
public function initCoinIcons():void{
var _local3:MovieClip;
var _local1:Class = AssetsManager.instance.getAssetClass("CoinAsset");
_coinIcons = [];
var _local2:int;
while (_local2 < _currentLevelInfo.coinsToWin) {
_local3 = (new (_local1) as MovieClip);
_local3.scaleX = (_local3.scaleY = 0.5);
_local3.y = _skin["coinIconsContainer"].y;
_local3.x = (_skin["coinIconsContainer"].x + (_local2 * 30));
addChild(_local3);
_coinIcons.push(_local3);
_local2++;
};
updateState();
}
private function hintClickHandler(_arg1:MouseEvent):void{
Link.Open(Sticks.WALKTHROUGH_URL, "Walkthrough", "Sponsor");
}
private function startSimulationClickHandler(_arg1:MouseEvent):void{
SoundManager.instance.playSound("sndButtonPress");
(_skin["startSimulationButton"] as SimpleButton).visible = false;
(_skin["stopSimulationButton"] as SimpleButton).visible = true;
reset_bt.visible = false;
(_world as GameWorld).startSimulation();
}
private function armorLogoClickHandler(_arg1:MouseEvent):void{
Link.Open(Sticks.SITE_URL, "GameplayLogo", "Sponsor");
}
public function updateState():void{
var _local1:int;
while (_local1 < _currentLevelInfo.coinsToWin) {
(_coinIcons[_local1] as MovieClip).alpha = 0.5;
_local1++;
};
_local1 = 0;
while (_local1 < (_world as GameWorld).collectedCoinsNum) {
(_coinIcons[_local1] as MovieClip).alpha = 1;
_local1++;
};
if ((_world as GameWorld).currentState == (_world as GameWorld).BUILDING_STATE){
(_skin["startSimulationButton"] as SimpleButton).visible = true;
(_skin["stopSimulationButton"] as SimpleButton).visible = false;
reset_bt.visible = true;
} else {
if ((_world as GameWorld).currentState == (_world as GameWorld).SIMULATING_STATE){
(_skin["startSimulationButton"] as SimpleButton).visible = false;
(_skin["stopSimulationButton"] as SimpleButton).visible = true;
reset_bt.visible = false;
};
};
}
private function stopSimulationClickHandler(_arg1:MouseEvent):void{
SoundManager.instance.playSound("sndButtonPress");
(_skin["stopSimulationButton"] as SimpleButton).visible = false;
(_skin["startSimulationButton"] as SimpleButton).visible = true;
reset_bt.visible = true;
(_world as GameWorld).stopSimulation();
}
private function selectLevelClickHandler(_arg1:MouseEvent):void{
dispatchEvent(new GameEvent(GameEvent.SELECT_LEVEL));
}
private function removeHinges(_arg1:DynamicRect):void{
var _local2:b2JointEdge = _arg1.body.GetJointList();
while (_local2) {
(_local2.joint.GetUserData() as DynamicHinge).isDead = true;
_local2 = _local2.next;
};
}
private function destroyRect(_arg1:DynamicRect):void{
_world.woodRemain = (_world.woodRemain + (_arg1.params as DynamicRectParams).width);
removeHinges(_arg1);
var _local2:StickRemoveEffect = new StickRemoveEffect(_world, _arg1.container);
_arg1.isCtrld = true;
_arg1.isDead = true;
}
}
}//package screens
Section 207
//IntroScreen (screens.IntroScreen)
package screens {
import flash.events.*;
import AKEngine.screens.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import managers.*;
public class IntroScreen extends AScreen {
private var container:Sprite;
private var intro:MovieClip;
private var window:Sprite;
private var skip_bt:SimpleButton;
public function IntroScreen():void{
}
private function skipClickHandler(_arg1:MouseEvent):void{
endIntro();
}
private function efHandler(_arg1:Event):void{
if (intro.currentFrame == intro.totalFrames){
endIntro();
};
}
private function endIntro():void{
intro.stop();
intro.removeEventListener(Event.ENTER_FRAME, efHandler);
Fader.getInstance().fade(introFinished, 0.8);
}
override protected function init(_arg1:Event):void{
super.init(_arg1);
var _local2:Class = AssetsManager.instance.getAssetClass("IntroHolder");
window = new (_local2);
addChild(window);
container = (window.getChildByName("container") as Sprite);
skip_bt = (window.getChildByName("skip_bt") as SimpleButton);
var _local3:Class = IntroAssetsManager.instance.getAssetClass("IntroAssets");
intro = new (_local3);
intro.x = 320;
intro.y = 240;
container.addChild(intro);
intro.addEventListener(Event.ENTER_FRAME, efHandler);
stage.frameRate = 25;
SoundManager.instance.playMusic("sndIntro", 0, false);
skip_bt.addEventListener(MouseEvent.CLICK, skipClickHandler);
}
private function introFinished():void{
SoundManager.instance.stopMusic();
stage.frameRate = 30;
GameData.instance.currentLevelNum = 0;
var _local1:GameScreen = new GameScreen();
changeScreen(_local1);
}
override protected function dispose(_arg1:Event):void{
skip_bt.removeEventListener(MouseEvent.CLICK, skipClickHandler);
}
}
}//package screens
Section 208
//LevelCompleteDialog (screens.LevelCompleteDialog)
package screens {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import flash.text.*;
public class LevelCompleteDialog extends MovieClip {
private var scoreAnim:MovieClip;
private var newHighscore:Sprite;
private var _skin:MovieClip;
private var score_tf:TextField;
public function LevelCompleteDialog(){
var _local1:Class = AssetsManager.instance.getAssetClass("LevelCompleteAsset");
_skin = (new (_local1) as MovieClip);
score_tf = (_skin.getChildByName("score_tf") as TextField);
newHighscore = (_skin.getChildByName("newHighscore") as Sprite);
scoreAnim = (newHighscore.getChildByName("scoreAnim") as MovieClip);
if (GameData.instance.currentLevelNum >= (GameData.instance.numLevels - 1)){
(_skin["nextLevelButton"] as SimpleButton).visible = false;
} else {
(_skin["nextLevelButton"] as SimpleButton).addEventListener(MouseEvent.CLICK, nextLevelClickHandler, false, 0, true);
};
(_skin["selectLevelButton"] as SimpleButton).addEventListener(MouseEvent.CLICK, selectLevelClickHandler, false, 0, true);
addChild(_skin);
var _local2:LevelInfo = (GameData.instance.levelInfos[GameData.instance.currentLevelNum] as LevelInfo);
score_tf.text = _local2.lastScore.toString();
if (_local2.lastScore == _local2.bestScore){
newHighscore.visible = true;
SoundManager.instance.playSound("sndCoinsFall");
scoreAnim.addEventListener(Event.ENTER_FRAME, scoreEfHandler);
} else {
newHighscore.visible = false;
};
SoundManager.instance.musicVolume = 0;
}
private function selectLevelClickHandler(_arg1:MouseEvent):void{
SoundManager.instance.stopMusic();
dispose();
parent.removeChild(this);
dispatchEvent(new GameEvent(GameEvent.SELECT_LEVEL));
}
public function dispose():void{
(_skin["nextLevelButton"] as SimpleButton).removeEventListener(MouseEvent.CLICK, nextLevelClickHandler);
(_skin["selectLevelButton"] as SimpleButton).removeEventListener(MouseEvent.CLICK, selectLevelClickHandler);
scoreAnim.removeEventListener(Event.ENTER_FRAME, scoreEfHandler);
}
private function nextLevel():void{
dispose();
parent.removeChild(this);
dispatchEvent(new GameEvent(GameEvent.NEXT_LEVEL));
}
private function nextLevelClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(nextLevel);
}
private function scoreEfHandler(_arg1:Event):void{
if (scoreAnim.currentFrame == scoreAnim.totalFrames){
scoreAnim.stop();
scoreAnim.removeEventListener(Event.ENTER_FRAME, scoreEfHandler);
};
}
}
}//package screens
Section 209
//LevelIcon (screens.LevelIcon)
package screens {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import flash.text.*;
public class LevelIcon extends Sprite {
public var number:Number;
private var _skin:MovieClip;
public function LevelIcon(_arg1:Number){
this.number = _arg1;
var _local2:Class = AssetsManager.instance.getAssetClass("LevelIconAsset");
_skin = (new (_local2) as MovieClip);
_skin.mouseChildren = false;
(_skin["scoreText"] as TextField).text = "";
var _local3:LevelInfo = (GameData.instance.levelInfos[_arg1] as LevelInfo);
if (_local3.isCompleted){
_skin.gotoAndStop(4);
_skin.buttonMode = true;
(_skin["scoreText"] as TextField).text = _local3.bestScore.toString();
} else {
if (_local3.isOpen){
_skin.gotoAndStop(1);
_skin.buttonMode = true;
} else {
_skin.gotoAndStop(3);
};
};
(_skin["numberText"] as TextField).mouseEnabled = false;
(_skin["numberText"] as TextField).text = (_arg1 + 1).toString();
addChild(_skin);
if (_local3.isOpen){
_skin.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
_skin.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
_skin.addEventListener(MouseEvent.CLICK, clickHandler);
};
}
private function mouseOutHandler(_arg1:MouseEvent):void{
var _local2:LevelInfo = (GameData.instance.levelInfos[number] as LevelInfo);
if (_local2.isCompleted){
_skin.gotoAndStop(4);
(_skin["scoreText"] as TextField).text = _local2.bestScore.toString();
} else {
_skin.gotoAndStop(1);
};
}
private function mouseOverHandler(_arg1:MouseEvent):void{
_skin.gotoAndStop(2);
dispatchEvent(new GameEvent(GameEvent.LEVEL_ICON_OVER, this));
}
private function clickHandler(_arg1:MouseEvent):void{
dispatchEvent(new GameEvent(GameEvent.LEVEL_ICON_CLICK, this));
}
}
}//package screens
Section 210
//LogoView (screens.LogoView)
package screens {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import Playtomic.*;
public class LogoView extends Sprite {
private var window:Sprite;
private var inner:MovieClip;
private var spash_bt:SimpleButton;
public static const COMPLETE:String = "complete";
public function LogoView():void{
init();
}
private function splashClickHandler(_arg1:MouseEvent):void{
Link.Open(Sticks.SITE_URL, "Splash", "Sponsor");
}
private function efHandler(_arg1:Event):void{
if (inner.currentFrame == inner.totalFrames){
finish();
};
}
private function destroy():void{
parent.removeChild(this);
}
private function init():void{
var _local1:Class = AssetsManager.instance.getAssetClass("LogoWindow");
window = new (_local1);
addChild(window);
inner = (window.getChildByName("ag") as MovieClip);
spash_bt = (window.getChildByName("splash_bt") as SimpleButton);
inner.addEventListener(Event.ENTER_FRAME, efHandler);
spash_bt.addEventListener(MouseEvent.CLICK, splashClickHandler);
}
private function finish():void{
inner.stop();
inner.removeEventListener(Event.ENTER_FRAME, efHandler);
Fader.getInstance().fade(reallyFinish);
}
private function reallyFinish():void{
dispatchEvent(new Event(COMPLETE));
destroy();
}
}
}//package screens
Section 211
//MainMenuScreen (screens.MainMenuScreen)
package screens {
import flash.events.*;
import AKEngine.screens.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import caurina.transitions.*;
import Playtomic.*;
import flash.net.*;
public class MainMenuScreen extends AScreen {
private var coins:Array;
private var moreGames_bt:SimpleButton;
private var artem_bt:SimpleButton;
private var debug:MovieClip;
private var inner:Sprite;
private var credits_bt:SimpleButton;
private var me_bt:SimpleButton;
private var _skin:MovieClip;
private var coinsContainer:Sprite;
private var andrey_bt:SimpleButton;
private var inner2:Sprite;
private var armorLogo_bt:SimpleButton;
private var back_bt:SimpleButton;
private var luke_bt:SimpleButton;
private var armorCredits_bt:SimpleButton;
private var play_bt:SimpleButton;
private function armorClickHandler(_arg1:MouseEvent):void{
Link.Open(Sticks.SITE_URL, "MainMenuLogo", "Sponsor");
}
override protected function init(_arg1:Event):void{
super.init(_arg1);
var _local2:Class = AssetsManager.instance.getAssetClass("MainMenuScreenAsset");
_skin = (new (_local2) as MovieClip);
addChild(_skin);
inner = (_skin.getChildByName("container") as Sprite);
inner2 = (inner.getChildByName("inner2") as Sprite);
debug = (_skin.getChildByName("debug") as MovieClip);
armorLogo_bt = (_skin.getChildByName("armorLogo_bt") as SimpleButton);
play_bt = (inner2.getChildByName("playButton") as SimpleButton);
moreGames_bt = (inner2.getChildByName("moreGames_bt") as SimpleButton);
credits_bt = (inner2.getChildByName("credits_bt") as SimpleButton);
back_bt = (inner2.getChildByName("back_bt") as SimpleButton);
me_bt = (inner2.getChildByName("me_bt") as SimpleButton);
artem_bt = (inner2.getChildByName("artem_bt") as SimpleButton);
andrey_bt = (inner2.getChildByName("andrey_bt") as SimpleButton);
luke_bt = (inner2.getChildByName("luke_bt") as SimpleButton);
armorCredits_bt = (inner2.getChildByName("armorCredits_bt") as SimpleButton);
coinsContainer = (inner.getChildByName("coinsContainer") as Sprite);
debug.visible = Preloader.DEBUG;
play_bt.addEventListener(MouseEvent.CLICK, playClickHandler, false, 0, true);
credits_bt.addEventListener(MouseEvent.CLICK, creditsClickHandler);
back_bt.addEventListener(MouseEvent.CLICK, backClickHandler);
armorLogo_bt.addEventListener(MouseEvent.CLICK, armorClickHandler);
moreGames_bt.addEventListener(MouseEvent.CLICK, moreGamesClickHandler);
if (!SoundManager.instance.isMusicPlaying){
SoundManager.instance.playMusic("sndMusicMenu");
};
artem_bt.visible = false;
andrey_bt.visible = false;
me_bt.addEventListener(MouseEvent.CLICK, meClickHandler);
luke_bt.addEventListener(MouseEvent.CLICK, lukeClickHandler);
armorCredits_bt.addEventListener(MouseEvent.CLICK, armorCreditsClickHandler);
createCoins();
}
override protected function dispose(_arg1:Event):void{
play_bt.removeEventListener(MouseEvent.CLICK, playClickHandler);
destroyCoins();
}
private function playClickHandler(_arg1:MouseEvent):void{
var _local3:int;
var _local4:LevelInfo;
if (((Preloader.DEBUG) && (InputManager.instance.isKeyPressed(InputManager.instance.SHIFT)))){
_local3 = 0;
while (_local3 < GameData.instance.numLevels) {
_local4 = GameData.instance.levelInfos[_local3];
_local4.isOpen = true;
_local3++;
};
};
Log.Play();
SoundManager.instance.playSound("sndButtonPress");
var _local2:Function = (isNewGame()) ? playIntro : selectLevel;
Fader.getInstance().fade(_local2);
}
private function meClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("mailto:eugene.karataev@gmail.com"));
}
private function moreGamesClickHandler(_arg1:MouseEvent):void{
Link.Open(Sticks.SITE_URL, "MainMenuMoreGames", "Sponsor");
}
private function armorCreditsClickHandler(_arg1:MouseEvent):void{
Link.Open(Sticks.SITE_URL, "MainMenuMoreGames", "Sponsor");
}
private function lukeClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://lukethomasmusic.wordpress.com/"));
}
private function isNewGame():Boolean{
var _local1:LevelInfo = GameData.instance.levelInfos[0];
return (!(_local1.isCompleted));
}
private function backClickHandler(_arg1:MouseEvent):void{
Tweener.addTween(inner2, {x:-320, time:0.5, trasition:"easeoutquad"});
}
private function createCoins():void{
var _local2:MenuCoinFall;
coins = [];
var _local1:int;
while (_local1 < 3) {
_local2 = new MenuCoinFall();
coinsContainer.addChild(_local2);
_local1++;
};
}
private function selectLevel():void{
var _local1:SelectLevelScreen = new SelectLevelScreen();
changeScreen(_local1);
}
private function playIntro():void{
SoundManager.instance.stopMusic();
var _local1:IntroScreen = new IntroScreen();
changeScreen(_local1);
}
private function creditsClickHandler(_arg1:MouseEvent):void{
Tweener.addTween(inner2, {x:-960, time:0.5, transition:"easeoutquad"});
}
private function destroyCoins():void{
var _local2:MenuCoinFall;
var _local1:int;
while (_local1 < coins.length) {
_local2 = coins[_local1];
_local2.destroy();
_local1++;
};
}
}
}//package screens
Section 212
//MenuCoinFall (screens.MenuCoinFall)
package screens {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
public class MenuCoinFall extends Sprite {
private var delay:Number;
private var skin:MovieClip;
private var time:int;
public function MenuCoinFall(){
init();
}
private function init():void{
var _local1:Class = AssetsManager.instance.getAssetClass("CoinFallAsset");
skin = new (_local1);
addChild(skin);
skin.stop();
skin.visible = false;
time = 0;
delay = Math.floor((Math.random() * 100));
addEventListener(Event.ENTER_FRAME, efHandler);
}
public function destroy():void{
skin.removeEventListener(Event.ENTER_FRAME, skinEfHandler);
removeEventListener(Event.ENTER_FRAME, efHandler);
}
private function efHandler(_arg1:Event):void{
time++;
if (time >= delay){
time = 0;
delay = (20 + Math.floor((Math.random() * 100)));
startCoin();
};
}
private function startCoin():void{
removeEventListener(Event.ENTER_FRAME, efHandler);
skin.visible = true;
skin.x = ((50 + Math.floor(((Math.random() * 640) - 100))) + 120);
skin.y = 240;
skin.scaleX = (skin.scaleY = (0.8 + (Math.random() * 0.5)));
skin.gotoAndPlay(1);
skin.addEventListener(Event.ENTER_FRAME, skinEfHandler);
}
private function skinEfHandler(_arg1:Event):void{
if (skin.currentFrame == skin.totalFrames){
skin.removeEventListener(Event.ENTER_FRAME, skinEfHandler);
skin.stop();
skin.visible = false;
addEventListener(Event.ENTER_FRAME, efHandler);
};
}
}
}//package screens
Section 213
//SelectLevelScreen (screens.SelectLevelScreen)
package screens {
import flash.events.*;
import AKEngine.screens.*;
import AKEngine.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import AKEngine.entity.box2d.*;
import flash.geom.*;
import entities.worlds.*;
public class SelectLevelScreen extends AScreen {
private var _previewWorld:PreviewWorld;
private var highscores_bt:SimpleButton;
private var no_bt:SimpleButton;
private var _previewBitmap:Bitmap;
private var clearProgress_bt:SimpleButton;
private var sureHolder:Sprite;
private var yes_bt:SimpleButton;
private var _skin:MovieClip;
private var _tmpSprite:Sprite;
private function noClickHandler(_arg1:MouseEvent):void{
sureHolder.visible = false;
clearProgress_bt.visible = true;
}
private function highscoresClickHandler(_arg1:MouseEvent):void{
Sticks.topContainer.addChild(Preloader.agi);
Preloader.agi.showScoreboardList();
}
override protected function init(_arg1:Event):void{
super.init(_arg1);
var _local2:Class = AssetsManager.instance.getAssetClass("SelectLevelScreenAsset");
_skin = (new (_local2) as MovieClip);
addChild(_skin);
createLevelIcons();
_previewBitmap = new Bitmap();
_previewBitmap.x = 307;
_previewBitmap.y = 110;
addChild(_previewBitmap);
clearProgress_bt = (_skin.getChildByName("clearProgress_bt") as SimpleButton);
sureHolder = (_skin.getChildByName("sureHolder") as Sprite);
yes_bt = (sureHolder.getChildByName("yes_bt") as SimpleButton);
no_bt = (sureHolder.getChildByName("no_bt") as SimpleButton);
highscores_bt = (_skin.getChildByName("highscores_bt") as SimpleButton);
clearProgress_bt.addEventListener(MouseEvent.CLICK, clearProgressClickHandler);
(_skin["menuButton"] as SimpleButton).addEventListener(MouseEvent.CLICK, menuClickHandler, false, 0, true);
if (!SoundManager.instance.isMusicPlaying){
SoundManager.instance.playMusic("sndMusicMenu");
if (SoundManager.instance.musicEnabled){
SoundManager.instance.musicVolume = 1;
};
};
sureHolder.visible = false;
yes_bt.addEventListener(MouseEvent.CLICK, yesClickHandler);
no_bt.addEventListener(MouseEvent.CLICK, noClickHandler);
highscores_bt.addEventListener(MouseEvent.CLICK, highscoresClickHandler);
}
private function createLevelIcons():void{
var _local2:LevelIcon;
var _local1:int;
while (_local1 < GameData.instance.numLevels) {
_local2 = new LevelIcon(_local1);
_local2.x = (56 + ((_local1 % 5) * 48));
_local2.y = (132 + (Math.floor((_local1 / 5)) * 48));
_local2.addEventListener(GameEvent.LEVEL_ICON_OVER, iconOverHandler, false, 0, true);
_local2.addEventListener(GameEvent.LEVEL_ICON_CLICK, iconClickHandler, false, 0, true);
addChild(_local2);
_local1++;
};
}
private function iconOverHandler(_arg1:GameEvent):void{
var _local2:LevelIcon = (_arg1.data as LevelIcon);
GameData.instance.currentLevelNum = _local2.number;
_tmpSprite = new Sprite();
_tmpSprite.visible = false;
addChild(_tmpSprite);
var _local3:GameFactory = new GameFactory();
_previewWorld = new PreviewWorld(_local3, new Box2DWorldParams(), _tmpSprite);
previewLoadedHandler(new Event(Event.COMPLETE));
}
override protected function dispose(_arg1:Event):void{
(_skin["menuButton"] as SimpleButton).removeEventListener(MouseEvent.CLICK, menuClickHandler);
clearProgress_bt.removeEventListener(MouseEvent.CLICK, clearProgressClickHandler);
}
private function gotoMenu():void{
var _local1:MainMenuScreen = new MainMenuScreen();
changeScreen(_local1);
}
private function clearProgressClickHandler(_arg1:MouseEvent):void{
sureHolder.visible = true;
clearProgress_bt.visible = false;
}
private function previewLoadedHandler(_arg1:Event):void{
var _local2:BitmapData = new BitmapData(320, 240, true, 0xFFFFFF);
var _local3:Matrix = new Matrix();
_local3.scale(0.5, 0.5);
_local2.draw(_tmpSprite, _local3);
_previewBitmap.bitmapData = _local2;
if (_tmpSprite.parent){
_tmpSprite.parent.removeChild(_tmpSprite);
};
}
private function menuClickHandler(_arg1:MouseEvent):void{
SoundManager.instance.playSound("sndButtonPress");
Fader.getInstance().fade(gotoMenu);
}
private function yesClickHandler(_arg1:MouseEvent):void{
GameData.instance.clearProgress();
SoundManager.instance.playSound("sndButtonPress");
Fader.getInstance().fade(gotoMenu);
}
private function closeHandler():void{
}
private function playLevel():void{
SoundManager.instance.stopMusic();
var _local1:GameScreen = new GameScreen();
changeScreen(_local1);
}
private function iconClickHandler(_arg1:GameEvent):void{
SoundManager.instance.playSound("sndButtonPress");
var _local2:LevelIcon = (_arg1.data as LevelIcon);
GameData.instance.currentLevelNum = _local2.number;
Fader.getInstance().fade(playLevel);
}
}
}//package screens
Section 214
//TopView (screens.TopView)
package screens {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
public class TopView extends Sprite {
private var window:Sprite;
private var music:MovieClip;
private var sound:MovieClip;
public function TopView():void{
init();
}
private function musicClickHandler(_arg1:MouseEvent):void{
var _local2:SoundManager = SoundManager.instance;
if (_local2.musicEnabled){
_local2.musicEnabled = false;
_local2.musicVolume = 0;
music.gotoAndStop(2);
} else {
_local2.musicEnabled = true;
_local2.musicVolume = 1;
music.gotoAndStop(1);
};
}
private function init():void{
var _local1:Class = AssetsManager.instance.getAssetClass("TopViewAsset");
window = new (_local1);
addChild(window);
music = (window.getChildByName("music") as MovieClip);
sound = (window.getChildByName("sound") as MovieClip);
music.stop();
music.buttonMode = true;
sound.visible = false;
sound.stop();
sound.buttonMode = true;
music.addEventListener(MouseEvent.CLICK, musicClickHandler);
}
}
}//package screens
Section 215
//WoodMeter (screens.WoodMeter)
package screens {
import flash.display.*;
public class WoodMeter {
private var skinMeterMask:Sprite;
private var barLength:Number;
private var skin:Sprite;
public function WoodMeter(_arg1:Sprite):void{
this.skin = _arg1;
init();
}
public function update(_arg1:Number):void{
skinMeterMask.width = ((_arg1 / 100) * barLength);
}
private function init():void{
skinMeterMask = (skin.getChildByName("meterMask") as Sprite);
barLength = skinMeterMask.width;
}
}
}//package screens
Section 216
//AToolBar (toolbars.AToolBar)
package toolbars {
import flash.events.*;
import flash.display.*;
import entities.worlds.*;
public class AToolBar extends Sprite {
protected var _world:GameWorld;
protected var _skin:MovieClip;
public function AToolBar(_arg1:GameWorld, _arg2:Number=0, _arg3:Number=0){
_world = _arg1;
this.x = _arg2;
this.y = _arg3;
}
protected function headMouseUpHandler(_arg1:MouseEvent):void{
stopDrag();
}
protected function headMouseDownHandler(_arg1:MouseEvent):void{
startDrag();
}
protected function initDrag():void{
if (_skin["head"]){
(_skin["head"] as MovieClip).addEventListener(MouseEvent.MOUSE_DOWN, headMouseDownHandler, false, 0, true);
(_skin["head"] as MovieClip).addEventListener(MouseEvent.MOUSE_UP, headMouseUpHandler, false, 0, true);
};
}
public function dispose():void{
if (_skin["head"]){
(_skin["head"] as MovieClip).removeEventListener(MouseEvent.MOUSE_DOWN, headMouseDownHandler);
(_skin["head"] as MovieClip).removeEventListener(MouseEvent.MOUSE_UP, headMouseUpHandler);
};
_world = null;
}
}
}//package toolbars
Section 217
//ATool (tools.ATool)
package tools {
import flash.events.*;
import entities.worlds.*;
public class ATool extends EventDispatcher {
protected var _world:GameWorld;
public function ATool(_arg1:GameWorld){
_world = _arg1;
}
protected function mouseDownHandler(_arg1:MouseEvent):void{
}
public function dispose():void{
_world.stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
_world = null;
}
}
}//package tools
Section 218
//DynamicRectTool (tools.DynamicRectTool)
package tools {
import flash.events.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import Box2D.Common.Math.*;
import AKEngine.entity.box2d.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import entities.worlds.*;
import entities.*;
import AKEngine.math.*;
import flash.ui.*;
public class DynamicRectTool extends ATool {
private var finalPos:b2Vec2;
private var skinData:BitmapData;
private var canvas:Sprite;
private var isMouseDown:Boolean;
private var initPos:b2Vec2;
private var drawSprite:Sprite;
private var rectHeight:Number;// = 12
private var tempWoodRemain:Number;
private var entity1:DynamicRect;// = null
private var isCollide:Boolean;// = false
private var isCtrl:Boolean;// = false
private var collisionPoint:b2Vec2;
public function DynamicRectTool(_arg1:GameWorld){
var _local3:ContextMenu;
super(_arg1);
var _local2:Class = AssetsManager.instance.getAssetClass("StickTextureAsset");
skinData = (new _local2(0, 0) as BitmapData);
canvas = _world.getLayer(_world.MAX_LAYERS);
_arg1.container.parent.doubleClickEnabled = true;
_arg1.container.parent.mouseChildren = false;
_arg1.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, false, 0, true);
_arg1.stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler, false, 0, true);
_arg1.container.parent.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 0, true);
_arg1.container.parent.addEventListener(MouseEvent.MOUSE_MOVE, globalMouseMoveHandler);
_arg1.container.parent.addEventListener(MouseEvent.DOUBLE_CLICK, doubleClickHandler);
_local3 = new ContextMenu();
_local3.hideBuiltInItems();
_local3.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelect, false, 0, true);
_world.container.parent.parent.contextMenu = _local3;
isMouseDown = false;
}
private function createHinges():void{
var _local6:b2Fixture;
var _local7:DynamicRectParams;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local14:b2Vec2;
var _local15:b2Vec2;
var _local16:b2Vec2;
var _local17:Number;
var _local18:DynamicHingeParams;
var _local19:DynamicHinge;
var _local1:b2Vec2 = new b2Vec2((initPos.x / _world.physScale), (initPos.y / _world.physScale));
var _local2:b2Vec2 = new b2Vec2((finalPos.x / _world.physScale), (finalPos.y / _world.physScale));
var _local3:Array = _world.physWorld.RayCastAll(_local1, _local2);
var _local4:Number = 1;
var _local5:int;
while (_local5 < _local3.length) {
_local6 = (_local3[_local5] as b2Fixture);
if (((((_local6) && (!((_local6.GetUserData() == entity1))))) && ((_local6.GetUserData() is DynamicRect)))){
_local7 = (_local6.GetUserData().params as DynamicRectParams);
_local8 = _local7.x;
_local9 = _local7.y;
_local10 = (_local7.width * Math.cos(_local7.rotation));
_local11 = (_local7.width * Math.sin(_local7.rotation));
_local12 = new b2Vec2((_local8 - (_local10 / 2)), (_local9 - (_local11 / 2)));
_local13 = new b2Vec2((_local8 + (_local10 / 2)), (_local9 + (_local11 / 2)));
_local14 = new b2Vec2(initPos.x, initPos.y);
_local15 = new b2Vec2(finalPos.x, finalPos.y);
_local16 = new b2Vec2();
_local17 = MathUtils.lineIntersection(_local14, _local15, _local12, _local13, _local16);
if (_local17 > 0){
_local18 = new DynamicHingeParams({x:_local16.x, y:_local16.y, uniqueNum1:(entity1.params as DynamicRectParams).uniqueID, uniqueNum2:_local7.uniqueID});
_world.entitiesParams.push(_local18);
_local19 = _world.factory.getEntity(_local18, _world);
};
};
_local5++;
};
}
private function mouseUpHandler(_arg1:MouseEvent):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:DynamicRectParams;
isMouseDown = false;
if (isCollide){
isCollide = false;
finalPos = collisionPoint.Copy();
} else {
finalPos = new b2Vec2(_arg1.stageX, _arg1.stageY);
};
if (((!((initPos.x == finalPos.x))) || (!((initPos.y == finalPos.y))))){
_local2 = (finalPos.x - initPos.x);
_local3 = (finalPos.y - initPos.y);
_local4 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
_local5 = new DynamicRectParams({x:(initPos.x + (_local2 / 2)), y:(initPos.y + (_local3 / 2)), width:_local4, height:rectHeight, rotation:((drawSprite.rotation * Math.PI) / 180), textureName:"StickTextureAsset", density:0.6, friction:0.4, restitution:0.4, isStatic:false});
_world.entitiesParams.push(_local5);
entity1 = (_world.factory.getEntity(_local5, _world) as DynamicRect);
_local5.uniqueID = entity1.uniqueID;
createHinges();
SoundManager.instance.playSound("stickCreatedSound");
};
canvas.removeChild(drawSprite);
drawSprite = null;
_world.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
_world.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function removeHinges(_arg1:DynamicRect):void{
var _local2:b2JointEdge = _arg1.body.GetJointList();
while (_local2) {
(_local2.joint.GetUserData() as DynamicHinge).isDead = true;
_local2 = _local2.next;
};
}
private function getBox2DEntitiesAtPoint(_arg1:Number, _arg2:Number):Array{
var _local6:Box2DEntity;
var _local3:Array = [];
var _local4:Array = _world.getChildrenByType(Box2DEntity);
var _local5:int;
while (_local5 < _local4.length) {
_local6 = _local4[_local5];
if (_local6.skin.hitTestPoint(_arg1, _arg2, true)){
_local3.push(_local6);
};
_local5++;
};
_local3.sortOn("uniqueID", Array.DESCENDING);
return (_local3);
}
private function keyUpHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == InputManager.instance.CONTROL){
isCtrl = false;
};
}
private function doubleClickHandler(_arg1:MouseEvent):void{
var _local3:StickRemoveEffect;
var _local2:DynamicRect = getTopDynamicRectAtPoint(initPos.x, initPos.y);
if (_local2){
_world.woodRemain = (_world.woodRemain + (_local2.params as DynamicRectParams).width);
removeHinges(_local2);
_local3 = new StickRemoveEffect(_world, _local2.container);
_local2.isCtrld = true;
_local2.isDead = true;
SoundManager.instance.playSound("stickDeletedSound");
isMouseDown = false;
return;
};
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
var _local14:b2RayCastInput;
var _local15:b2RayCastOutput;
var _local16:b2Vec2;
var _local18:Number;
var _local2:b2Vec2 = new b2Vec2(_arg1.stageX, _arg1.stageY);
var _local3:Graphics = drawSprite.graphics;
var _local4:Number = (_local2.x - initPos.x);
var _local5:Number = (_local2.y - initPos.y);
var _local6:Number = Math.atan2(_local5, _local4);
drawSprite.rotation = ((_local6 * 180) / Math.PI);
isCollide = false;
var _local7:b2Vec2 = new b2Vec2();
collisionPoint = null;
var _local8:b2Vec2 = b2Math.SubtractVV(_local2, initPos);
_local8.Normalize();
var _local9:b2Vec2 = new b2Vec2(-(_local8.y), _local8.x);
var _local10:b2Vec2 = new b2Vec2((initPos.x / _world.physScale), (initPos.y / _world.physScale));
var _local11:b2Vec2 = b2Math.AddVV(_local2, b2Math.MulFV((rectHeight / 2), _local8));
_local11.Multiply((1 / _world.physScale));
var _local12:b2Fixture = _world.RayCastClosest(_local10, _local11);
var _local13:Number = 1;
if (_local12){
_local14 = new b2RayCastInput(_local10, _local11);
_local15 = new b2RayCastOutput();
_local12.RayCast(_local15, _local14);
_local13 = _local15.fraction;
isCollide = true;
collisionPoint = new b2Vec2((((_local11.x * _local13) + ((1 - _local13) * _local10.x)) * _world.physScale), (((_local11.y * _local13) + ((1 - _local13) * _local10.y)) * _world.physScale));
collisionPoint.Subtract(b2Math.MulFV((rectHeight / 2), _local8));
};
_local10 = b2Math.AddVV(initPos, b2Math.MulFV((rectHeight / 2), _local9));
_local10.Multiply((1 / _world.physScale));
_local11 = b2Math.AddVV(_local2, b2Math.MulFV((rectHeight / 2), _local9));
_local11.Multiply((1 / _world.physScale));
_local12 = _world.RayCastClosest(_local10, _local11);
_local13 = 1;
if (_local12){
_local14 = new b2RayCastInput(_local10, _local11);
_local15 = new b2RayCastOutput();
_local12.RayCast(_local15, _local14);
_local13 = _local15.fraction;
_local7 = new b2Vec2((((_local11.x * _local13) + ((1 - _local13) * _local10.x)) * _world.physScale), (((_local11.y * _local13) + ((1 - _local13) * _local10.y)) * _world.physScale));
if (((!(isCollide)) || ((b2Math.DistanceSquared(initPos, _local7) < b2Math.DistanceSquared(initPos, collisionPoint))))){
isCollide = true;
collisionPoint = _local7.Copy();
collisionPoint.Subtract(b2Math.MulFV((rectHeight / 2), _local9));
};
};
_local10 = b2Math.AddVV(initPos, b2Math.MulFV((-(rectHeight) / 2), _local9));
_local10.Multiply((1 / _world.physScale));
_local11 = b2Math.AddVV(_local2, b2Math.MulFV((-(rectHeight) / 2), _local9));
_local11.Multiply((1 / _world.physScale));
_local12 = _world.RayCastClosest(_local10, _local11);
_local13 = 1;
if (_local12){
_local14 = new b2RayCastInput(_local10, _local11);
_local15 = new b2RayCastOutput();
_local12.RayCast(_local15, _local14);
_local13 = _local15.fraction;
_local7 = new b2Vec2((((_local11.x * _local13) + ((1 - _local13) * _local10.x)) * _world.physScale), (((_local11.y * _local13) + ((1 - _local13) * _local10.y)) * _world.physScale));
if (((!(isCollide)) || ((b2Math.DistanceSquared(initPos, _local7) < b2Math.DistanceSquared(initPos, collisionPoint))))){
isCollide = true;
collisionPoint = _local7.Copy();
collisionPoint.Subtract(b2Math.MulFV((-(rectHeight) / 2), _local9));
};
};
if (isCollide){
_local16 = b2Math.SubtractVV(collisionPoint, initPos);
} else {
_local16 = b2Math.SubtractVV(_local2, initPos);
};
var _local17:Number = _local16.Length();
if (_local17 > tempWoodRemain){
_local17 = tempWoodRemain;
_local7 = b2Math.AddVV(initPos, b2Math.MulFV((_local17 / _local16.Length()), _local16));
if (((!(isCollide)) || (((collisionPoint) && ((b2Math.DistanceSquared(initPos, _local7) < b2Math.DistanceSquared(initPos, collisionPoint))))))){
isCollide = true;
collisionPoint = _local7.Copy();
};
};
_world.woodRemain = (tempWoodRemain - _local17);
if (isCollide){
_local18 = b2Math.Distance(initPos, collisionPoint);
} else {
_local18 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
};
_local3.clear();
_local3.lineStyle(0, 0, 1);
var _local19:Matrix = new Matrix(1, 0, 0, 1, 0, -6);
_local3.beginBitmapFill(skinData, _local19, true, true);
_local3.moveTo(0, (-(rectHeight) / 2));
_local3.lineTo(_local18, (-(rectHeight) / 2));
_local3.curveTo((_local18 + rectHeight), 0, _local18, (rectHeight / 2));
_local3.lineTo(0, (rectHeight / 2));
_local3.curveTo(-(rectHeight), 0, 0, (-(rectHeight) / 2));
_local3.endFill();
}
private function globalMouseMoveHandler(_arg1:MouseEvent):void{
if (((isMouseDown) || ((_world.currentState == _world.SIMULATING_STATE)))){
return;
};
uncolorRects();
var _local2:b2Vec2 = new b2Vec2(_arg1.stageX, _arg1.stageY);
var _local3:DynamicRect = getTopDynamicRectAtPoint(_local2.x, _local2.y);
if (_local3){
_local3.underMouse();
};
}
private function getTopDynamicRectAtPoint(_arg1:Number, _arg2:Number):DynamicRect{
var _local4:DynamicRect;
var _local3:Number = 0;
var _local5:Array = _world.getChildrenByType(DynamicRect);
var _local6:int;
while (_local6 < _local5.length) {
if (_local5[_local6].skin.hitTestPoint(_arg1, _arg2, true)){
if (_local5[_local6].uniqueID > _local3){
_local3 = _local5[_local6].uniqueID;
_local4 = (_local5[_local6] as DynamicRect);
};
};
_local6++;
};
return (_local4);
}
override public function dispose():void{
uncolorRects();
_world.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
_world.stage.removeEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
_world.container.parent.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
_world.container.parent.removeEventListener(MouseEvent.MOUSE_MOVE, globalMouseMoveHandler);
_world.container.parent.removeEventListener(MouseEvent.DOUBLE_CLICK, doubleClickHandler);
canvas = null;
drawSprite = null;
super.dispose();
}
override protected function mouseDownHandler(_arg1:MouseEvent):void{
var _local3:Box2DEntity;
initPos = new b2Vec2(_arg1.stageX, _arg1.stageY);
var _local2:Array = getBox2DEntitiesAtPoint(initPos.x, initPos.y);
if (_local2.length == 0){
if (_world.woodRemain > 0){
isMouseDown = true;
drawSprite = new Sprite();
drawSprite.alpha = 0.7;
drawSprite.x = initPos.x;
drawSprite.y = initPos.y;
canvas.addChild(drawSprite);
tempWoodRemain = _world.woodRemain;
_world.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, false, 0, true);
_world.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 0, true);
};
} else {
_local3 = _local2[0];
if (!(_local3 is DynamicRect)){
SoundManager.instance.playSound("cantCreateStickSound");
};
};
}
private function uncolorRects():void{
var _local3:DynamicRect;
var _local1:Array = _world.getChildrenByType(DynamicRect);
var _local2:int;
while (_local2 < _local1.length) {
_local3 = _local1[_local2];
_local3.notUnderMouse();
_local2++;
};
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == InputManager.instance.CONTROL){
isCtrl = true;
};
}
private function menuSelect(_arg1:ContextMenuEvent):void{
if (drawSprite){
canvas.removeChild(drawSprite);
drawSprite = null;
_world.woodRemain = tempWoodRemain;
isCollide = false;
collisionPoint = null;
_world.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
_world.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
};
}
}
}//package tools
Section 219
//GameData (GameData)
package {
import helpers.*;
import flash.net.*;
public class GameData {
public var levelInfos:Array;
public var levels:Array;
public var numLevels:Number;
public var currentLevelNum:Number;
private static var _instance:GameData;
public function saveData():void{
var _local1:SharedObject = SharedObject.getLocal("sticks");
var _local2:Array = new Array(numLevels);
var _local3:Array = new Array(numLevels);
var _local4:Array = new Array(numLevels);
var _local5:int;
while (_local5 < numLevels) {
_local2[_local5] = (levelInfos[_local5] as LevelInfo).isOpen;
_local3[_local5] = (levelInfos[_local5] as LevelInfo).isCompleted;
_local4[_local5] = (levelInfos[_local5] as LevelInfo).bestScore;
_local5++;
};
_local1.data.levelsOpen = _local2;
_local1.data.levelsCompletion = _local3;
_local1.data.levelsScore = _local4;
}
public function updateLevelInfos(_arg1:Number):void{
var _local2:LevelInfo = (levelInfos[currentLevelNum] as LevelInfo);
_local2.isCompleted = true;
_local2.lastScore = _arg1;
if (_local2.lastScore > _local2.bestScore){
_local2.bestScore = _local2.lastScore;
};
var _local3:LevelInfo = (levelInfos[(currentLevelNum + 1)] as LevelInfo);
if (_local3){
_local3.isOpen = true;
};
}
public function initialize():void{
var _local2:XML;
var _local3:LevelInfo;
numLevels = 30;
currentLevelNum = 0;
levelInfos = [];
var _local1:int;
while (_local1 < numLevels) {
_local3 = new LevelInfo(_local1, "");
if (_local1 == 0){
_local3.isOpen = true;
};
levelInfos.push(_local3);
_local1++;
};
levels = [];
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="500" y="346" rotation="0"/>
<Poly forcedName="null" numVerts="5" v0x="-204.2629416598192" v0y="-17.68008764721992" v1x="226.7370583401808" v1y="-17.68008764721992" v2x="233.7370583401808" v2y="0.31991235278007935" v3x="-57.262941659819205" v3y="30.31991235278008" v4x="-219.2629416598192" v4y="-1.6800876472199209" textureName="BrickTextureAsset" layer="1" x="392.0129416598192" y="390.0300876472199" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-17.230197708097208" v0y="-28.91701297065856" v1x="-1.230197708097208" v1y="-26.91701297065856" v2x="23.769802291902792" v2y="14.08298702934144" v3x="-0.23019770809720796" v3y="28.08298702934144" v4x="-13.230197708097208" v4y="10.08298702934144" textureName="BrickTextureAsset" layer="1" x="61.23019770809721" y="240.91701297065856" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="124" y="134" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="2" woodMax="500"/>
<Hero forcedName="null" layer="2" x="341.90000000000003" y="378.1" rotation="0"/>
<Poly forcedName="null" numVerts="4" v0x="-29.61320030698397" v0y="-107.0386288053212" v1x="-7.61320030698397" v1y="-103.0386288053212" v2x="46.38679969301603" v2y="74.9613711946788" v3x="-19.61320030698397" v3y="73.9613711946788" textureName="BrickTextureAsset" layer="1" x="235.91320030698392" y="331.13862880532116" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-137.731901352426" v0y="-6.916033846821165" v1x="147.268098647574" v1y="-9.916033846821165" v2x="148.268098647574" v2y="3.083966153178835" v3x="-116.731901352426" v3y="13.083966153178835" textureName="BrickTextureAsset" layer="1" x="352.03190135242596" y="413.01603384682113" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-13.433143407838088" v0y="-73.76491337819385" v1x="19.566856592161912" v1y="-83.76491337819385" v2x="46.26685659216196" v2y="56.13508662180618" v3x="-52.73314340783804" v3y="56.13508662180618" textureName="BrickTextureAsset" layer="1" x="453.7331434078381" y="347.8649133781938" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-26.328405357594193" v0y="-15.043214556482354" v1x="14.671594642405807" v1y="-37.043214556482354" v2x="28.671594642405807" v2y="-14.043214556482354" v3x="2.6715946424058075" v3y="44.956785443517646" v4x="-26.328405357594193" v4y="10.956785443517646" textureName="BrickTextureAsset" layer="1" x="586.0284053575941" y="237.04321455648233" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="7" v0x="-25.842211210901183" v0y="-23.754258284298515" v1x="5.1577887890988166" v1y="-28.754258284298515" v2x="33.15778878909882" v2y="-13.754258284298515" v3x="38.15778878909882" v3y="12.245741715701485" v4x="15.157788789098817" v4y="29.245741715701485" v5x="-33.84221121090118" v5y="17.245741715701485" v6x="-37.84221121090118" v6y="-5.7542582842985155" textureName="BrickTextureAsset" layer="1" x="88.84221121090118" y="170.75425828429852" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="151.85" y="66.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="509.85" y="155.64999999999998" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="214.64999999999995" y="307.2" rotation="0"/>
<Coin forcedName="null" radius="20" layer="1" x="441.75" y="183.59999999999988" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-354.6547548339534" v0y="-108.47322261165704" v1x="-74.55475483395338" v1y="-110.42322261165702" v2x="360.4452451660466" v2y="-74.42322261165702" v3x="373.4452451660466" v3y="107.57677738834298" v4x="-353.5547548339534" v4y="90.57677738834298" textureName="BrickTextureAsset" layer="1" x="355.5547548339534" y="444.423222611657" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="120.89999999999998" y="369.6499999999999" rotation="0"/>
<Circle forcedName="null" radius="19.026297590440446" textureName="SteelTextureAsset" layer="1" x="394.9999999999999" y="414" rotation="0" density="7.8" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="395.94999999999993" y="415" motorSpeed="2" maxTorque="100" isReversed="false"/>
<Circle forcedName="null" radius="19.026297590440446" textureName="SteelTextureAsset" layer="1" x="534.9999999999999" y="414" rotation="0" density="7.8" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="535.9499999999999" y="415" motorSpeed="2" maxTorque="100" isReversed="false"/>
<Coin forcedName="null" radius="20" layer="1" x="224.8499999999999" y="380.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="8" v0x="-196.64206093799743" v0y="-13.973781246882597" v1x="-129.79206093799746" v1y="-41.423781246882584" v2x="18.207939062002534" v2y="-45.423781246882584" v3x="172.35793906200252" v3y="-36.973781246882595" v4x="200.20793906200257" v4y="-1.4237812468825837" v5x="171.20793906200254" v5y="36.576218753117416" v6x="-51.79206093799746" v6y="47.576218753117416" v7x="-205.79206093799743" v7y="23.576218753117416" textureName="BrickTextureAsset" layer="1" x="392.79206093799746" y="314.4237812468826" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="6" v0x="-121.34662948840906" v0y="-2.351405583252358" v1x="-109.34662948840906" v1y="-20.35140558325236" v2x="32.653370511590936" v2y="-21.35140558325236" v3x="144.00337051159096" v3y="-10.701405583252324" v4x="151.00337051159096" v4y="9.298594416747676" v5x="-111.34662948840906" v5y="26.64859441674764" textureName="BrickTextureAsset" layer="1" x="160.04662948840905" y="420.00140558325234" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="3" woodMax="500"/>
<Hero forcedName="null" layer="2" x="354.6" y="401.2" rotation="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="246" y="271" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="330" y="219" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="449" y="288" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="512" y="182" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="420" y="156" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="327" y="126" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="200" y="160" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="158" y="86" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="494" y="66" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="15" layer="1" x="238" y="77" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="15" layer="1" x="434" y="59" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="15" layer="1" x="551" y="93" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.110770276274835" textureName="BrickTextureAsset" layer="1" x="601" y="244" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-66.55272636285241" v0y="-43.23913043478257" v1x="63.44727363714759" v1y="-44.23913043478257" v2x="17.547273637147555" v2y="66.81086956521739" v3x="-13.452726362852445" v3y="65.81086956521739" textureName="BrickTextureAsset" layer="1" x="357.45272636285245" y="473.1891304347826" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="161.59999999999985" y="245.19999999999993" rotation="0"/>
<Circle forcedName="null" radius="17.08800749063506" textureName="BrickTextureAsset" layer="1" x="413" y="355" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="527" y="235.05" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="6" v0x="-36.292272294860766" v0y="-37.90267914426667" v1x="-4.292272294860766" v1y="-55.90267914426667" v2x="35.707727705139234" v2y="-33.90267914426667" v3x="52.707727705139234" v3y="40.09732085573333" v4x="-36.292272294860766" v4y="45.09732085573333" v5x="-48.292272294860766" v5y="-7.902679144266671" textureName="SteelTextureAsset" layer="1" x="296.04227229486077" y="233.00267914426664" rotation="0" density="7.8" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-78.88708220415532" v0y="11.523938572718976" v1x="-52.88708220415532" v1y="-15.476061427281024" v2x="57.11291779584468" v2y="-19.476061427281024" v3x="76.11291779584468" v3y="8.523938572718976" v4x="-12.88708220415532" v4y="20.523938572718976" textureName="BrickTextureAsset" layer="1" x="159.8370822041553" y="289.47606142728097" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="1000"/>
<Hero forcedName="null" layer="2" x="623.9" y="355.1" rotation="0"/>
<Rect forcedName="null" width="342.1" height="13.050000000000011" textureName="BrickTextureAsset" layer="1" x="164.8" y="412.025" rotation="0.09" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="342.1" height="13.050000000000011" textureName="BrickTextureAsset" layer="1" x="496.85" y="402.975" rotation="-0.14" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="161.60000000000002" y="382.1499999999999" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="267.6500000000001" y="392.0999999999999" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="39.55000000000004" y="372.0499999999999" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="117.65000000000003" y="310.0999999999999" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="3" woodMax="800"/>
<Hero forcedName="null" layer="2" x="570.15" y="420.7000000000001" rotation="0"/>
<Poly forcedName="null" numVerts="4" v0x="-359.7151979565772" v0y="-60.42273307790546" v1x="330.2848020434228" v1y="39.57726692209454" v2x="323.2848020434228" v2y="57.57726692209454" v3x="-365.7151979565772" v3y="-47.42273307790546" textureName="BrickTextureAsset" layer="1" x="348.01519795657714" y="118.02273307790546" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="15" textureName="SteelTextureAsset" layer="1" x="120" y="61" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="15" textureName="SteelTextureAsset" layer="1" x="179" y="70" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<DistanceJoint forcedName="null" layer="1" x="120" y="61" x2="180" y2="70" collideConnected="false"/>
<Coin forcedName="null" radius="20" layer="1" x="136.85000000000005" y="237.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="14" layer="1" x="120.5" y="201.20000000000005" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="14" layer="1" x="147.5" y="181.20000000000005" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-133.3251650862203" v0y="33.04090382749678" v1x="-104.3251650862203" v1y="-44.95909617250322" v2x="110.6748349137797" v2y="-50.95909617250322" v3x="103.6748349137797" v3y="58.04090382749678" textureName="BrickTextureAsset" layer="1" x="610.3251650862203" y="493.9590961725032" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="68" height="12" textureName="SteelTextureAsset" layer="1" x="145.05" y="147.00000000000003" rotation="0.15" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<DistanceJoint forcedName="null" layer="1" x="119" y="61" x2="121.05" y2="143" collideConnected="false"/>
<DistanceJoint forcedName="null" layer="1" x="180" y="71" x2="171.05" y2="151" collideConnected="false"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="572.6499999999999" y="385.2" rotation="0"/>
<Rect forcedName="null" width="186" height="10" textureName="SteelTextureAsset" layer="1" x="160.25" y="333.15" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="243.25" y="334.15" motorSpeed="-3.24" maxTorque="500" isReversed="true"/>
<Coin forcedName="null" radius="15" layer="1" x="179" y="313" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="15" textureName="BrickTextureAsset" layer="1" x="568" y="94.05" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="122" height="101" textureName="BrickTextureAsset" layer="1" x="572" y="463.5" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="549.6499999999999" y="254.2" rotation="0"/>
<Coin forcedName="null" radius="20" layer="1" x="393" y="136" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="121" height="14" textureName="BrickTextureAsset" layer="1" x="550.5" y="287" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="6" v0x="47.84041049876062" v0y="-33.79062709940466" v1x="46.84041049876062" v1y="-6.790627099404659" v2x="20.34041049876062" v2y="15.70937290059534" v3x="-62.65958950123938" v3y="33.70937290059534" v4x="-65.65958950123938" v4y="23.70937290059534" v5x="21.34041049876062" v5y="-34.29062709940466" textureName="BrickTextureAsset" layer="1" x="127.65958950123938" y="95.29062709940466" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-94.14232209737828" v0y="-5.767790262172468" v1x="75.85767790262173" v1y="-9.767790262172468" v2x="79.85767790262173" v2y="0.23220973782753165" v3x="73.85767790262173" v3y="10.232209737827532" v4x="-94.14232209737828" v4y="5.232209737827532" textureName="SteelTextureAsset" layer="1" x="269.04232209737825" y="239.01779026217247" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="180" y="239" motorSpeed="3.04" maxTorque="1000" isReversed="false"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="800"/>
<Hero forcedName="null" layer="2" x="305.64999999999986" y="348.2" rotation="0"/>
<Coin forcedName="null" radius="20" layer="1" x="401.0499999999999" y="160" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="13" textureName="BrickTextureAsset" layer="1" x="290.04999999999995" y="160" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-68.98718710299377" v0y="-75.19792075727213" v1x="65.01281289700626" v1y="-74.19792075727213" v2x="127.11281289700622" v2y="41.852079242727825" v3x="-18.887187102993774" v3y="76.85207924272783" v4x="-119.88718710299378" v4y="43.852079242727825" textureName="BrickTextureAsset" layer="1" x="307.8871871029938" y="451.1479207572722" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="584.1999999999997" y="364.1499999999999" rotation="0"/>
<Circle forcedName="null" radius="19.026297590440446" textureName="SteelTextureAsset" layer="1" x="-31" y="371" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="19.026297590440446" textureName="SteelTextureAsset" layer="1" x="297.94999999999993" y="370.95" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="376" y="239" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="115" height="15" textureName="BrickTextureAsset" layer="1" x="357.5" y="209.5" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="115" height="15" textureName="BrickTextureAsset" layer="1" x="356" y="267" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="19.026297590440446" textureName="SteelTextureAsset" layer="1" x="139.94999999999996" y="370.95" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="371" height="22" textureName="SteelTextureAsset" layer="1" x="132.4" y="362.95" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="-31.6" y="371.95" motorSpeed="2" maxTorque="100" isReversed="false"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="140.4" y="370.95" motorSpeed="2" maxTorque="100" isReversed="false"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="297.4" y="371.95" motorSpeed="2" maxTorque="100" isReversed="false"/>
<Rect forcedName="null" width="176.89999999999998" height="77.94999999999999" textureName="BrickTextureAsset" layer="1" x="593.45" y="429.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="545.9" height="109.05" textureName="BrickTextureAsset" layer="1" x="184.95" y="444.475" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="4" woodMax="1000"/>
<Hero forcedName="null" layer="2" x="87.15" y="402.1" rotation="0"/>
<Poly forcedName="null" numVerts="8" v0x="-67.97871918565227" v0y="-41.685460445758224" v1x="67.02128081434773" v1y="-39.685460445758224" v2x="77.02128081434773" v2y="-33.685460445758224" v3x="75.92128081434782" v3y="33.264539554241765" v4x="66.92128081434771" v4y="40.264539554241765" v5x="-56.97871918565227" v5y="42.314539554241776" v6x="-72.97871918565227" v6y="35.314539554241776" v7x="-77.97871918565227" v7y="-29.685460445758224" textureName="BrickTextureAsset" layer="1" x="539.9787191856523" y="259.6854604457582" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-47.48165137614683" v0y="-6.290519877675877" v1x="-2.4816513761468286" v1y="-15.290519877675877" v2x="48.51834862385317" v2y="-4.290519877675877" v3x="42.51834862385317" v3y="11.709480122324123" v4x="-41.48165137614683" v4y="10.709480122324123" textureName="BrickTextureAsset" layer="1" x="565.0316513761468" y="188.04051987767588" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="28" layer="1" x="392.9" y="249.40000000000003" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="323.85" y="161.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="262.9" y="306.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="15" layer="1" x="203.4" y="54.95000000000002" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-94.6928032598728" v0y="35.925189960621424" v1x="-72.79280325987278" v1y="-41.12481003937853" v2x="70.20719674012724" v2y="-41.12481003937853" v3x="95.3071967401272" v3y="38.925189960621424" textureName="BrickTextureAsset" layer="1" x="87.69280325987279" y="470.0748100393786" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="580.8" y="320.35" rotation="0"/>
<Poly forcedName="null" numVerts="4" v0x="-219.4734891073238" v0y="-12.67170204791961" v1x="166.5265108926762" v1y="-96.6717020479196" v2x="178.5265108926762" v2y="56.32829795208039" v3x="-212.4734891073238" v3y="63.32829795208039" textureName="BrickTextureAsset" layer="1" x="333.3734891073238" y="425.6217020479196" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="130.6" y="411.75" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="130.6" y="411.75" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="170.60000000000002" y="402.75" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="170.60000000000002" y="402.75" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="211.6" y="394.75" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="211.6" y="394.75" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="251.35" y="386.6" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="251.35" y="386.6" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="289.9" y="376.95" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="289.9" y="376.95" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="328.6000000000001" y="369.75" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="328.6" y="369.75" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="369.3500000000001" y="360.6" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="369.35" y="360.6" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="408.60000000000014" y="351.75" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="408.6" y="351.75" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="447.35000000000014" y="342.6" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="447.35" y="342.6" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Circle forcedName="null" radius="18.547573965346544" textureName="SteelTextureAsset" layer="1" x="486.9000000000001" y="333.95" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="486.9" y="333.95" motorSpeed="-2" maxTorque="100" isReversed="true"/>
<Coin forcedName="null" radius="28" layer="1" x="155" y="338" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="175.64999999999998" height="142.39999999999998" textureName="BrickTextureAsset" layer="1" x="588.175" y="419.8" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="398.1999999999998" y="315.1" rotation="0"/>
<Circle forcedName="null" radius="11.40175425099138" textureName="BrickTextureAsset" layer="1" x="43" y="261" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="15" layer="1" x="88.30000000000001" y="157.89999999999998" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="305" height="13" textureName="BrickTextureAsset" layer="1" x="438.5" y="348.5" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="6" v0x="-6.47912234966978" v0y="-65.95392509558567" v1x="1.5208776503302204" v1y="-72.95392509558567" v2x="6.52087765033022" v2y="-66.95392509558567" v3x="12.420877650330254" v3y="48.99607490441437" v4x="0.4208776503302545" v4y="61.99607490441437" v5x="-12.579122349669746" v5y="48.99607490441437" textureName="BrickTextureAsset" layer="1" x="167.47912234966978" y="236.95392509558567" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-36.44262939161507" v0y="-4.133576996607189" v1x="-23.44262939161507" v1y="-13.13357699660719" v2x="36.05737060838493" v2y="-4.633576996607189" v3x="35.45737060838496" v3y="9.816423003392856" v4x="-24.44262939161507" v4y="9.86642300339281" textureName="BrickTextureAsset" layer="1" x="305.44262939161507" y="347.1335769966072" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="1000"/>
<Hero forcedName="null" layer="2" x="493.74999999999994" y="399.4499999999999" rotation="0"/>
<Rect forcedName="null" width="126" height="144" textureName="BrickTextureAsset" layer="1" x="490.3" y="498.15" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="11.180339887498947" textureName="SteelTextureAsset" layer="1" x="184.9" y="263.95" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="136" height="11" textureName="SteelTextureAsset" layer="1" x="243" y="88.5" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="18" layer="1" x="182.65" y="406.95" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<DistanceJoint forcedName="null" layer="1" x="183.9" y="255.95" x2="185" y2="88.5" collideConnected="false"/>
<Motor forcedName="null" skinName="MotorAsset" layer="1" x="307" y="89.5" motorSpeed="-0.513" maxTorque="1000" isReversed="true"/>
<Poly forcedName="null" numVerts="5" v0x="-53.949696852839736" v0y="-88.40818818690144" v1x="-4.949696852839736" v1y="-133.40818818690144" v2x="51.050303147160264" v2y="-94.40818818690144" v3x="51.050303147160264" v3y="115.59181181309856" v4x="-47.949696852839736" v4y="115.59181181309856" textureName="BrickTextureAsset" layer="1" x="296.94969685283974" y="492.40818818690144" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="3" woodMax="800"/>
<Hero forcedName="null" layer="2" x="352.79999999999995" y="313.79999999999995" rotation="0"/>
<Coin forcedName="null" radius="22" layer="1" x="304.69999999999993" y="75.05000000000001" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="18" layer="1" x="118.09999999999992" y="236.15" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="361.8499999999999" y="75.60000000000002" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="12.041594578792296" textureName="BrickTextureAsset" layer="1" x="49.94999999999999" y="198.95" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="12.041594578792296" textureName="BrickTextureAsset" layer="1" x="108.95" y="198.95" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="7" v0x="-140.76275719259164" v0y="-90.14466176951834" v1x="132.33724280740836" v1y="-90.09466176951832" v2x="141.33724280740836" v2y="-76.09466176951832" v3x="129.33724280740836" v3y="59.905338230481675" v4x="23.33724280740836" v4y="123.90533823048168" v5x="-125.66275719259164" v5y="62.905338230481675" v6x="-148.66275719259164" v6y="-76.09466176951832" textureName="BrickTextureAsset" layer="1" x="354.66275719259164" y="432.0946617695183" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="3" v0x="0.96666666666664" v0y="-28.016666666666623" v1x="118.96666666666664" v1y="13.983333333333375" v2x="-119.93333333333334" v2y="14.033333333333388" textureName="BrickTextureAsset" layer="1" x="331.93333333333334" y="158.9666666666666" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="800"/>
<Hero forcedName="null" layer="2" x="549.6499999999999" y="236.2" rotation="0"/>
<Coin forcedName="null" radius="20" layer="1" x="250" y="235" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-12.969565676010603" v0y="-18.688750736179713" v1x="6.130434323989391" v1y="-25.638750736179706" v2x="14.130434323989393" v2y="-18.638750736179706" v3x="-1.9695656760106033" v3y="44.31124926382034" textureName="BrickTextureAsset" layer="1" x="167.8695656760106" y="304.6387507361797" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="3" v0x="-225.66666666666663" v0y="41.33333333333354" v1x="-27.66666666666663" v1y="-80.66666666666646" v2x="253.33333333333337" v2y="39.33333333333354" textureName="BrickTextureAsset" layer="1" x="366.66666666666663" y="501.66666666666646" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-65.884549931425" v0y="-13.030095379288523" v1x="-37.884549931425" v1y="-21.030095379288525" v2x="82.01545006857509" v2y="-20.080095379288537" v3x="45.01545006857498" v3y="19.919904620711463" v4x="-59.884549931425" v4y="24.969904620711475" textureName="BrickTextureAsset" layer="1" x="532.884549931425" y="284.0300953792885" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="2" woodMax="800"/>
<Hero forcedName="null" layer="2" x="336.94999999999993" y="377.2" rotation="0"/>
<Rect forcedName="null" width="678.1" height="27.05000000000001" textureName="BrickTextureAsset" layer="1" x="328.9" y="416.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Magnet forcedName="null" strength="2" maxDistance="200" layer="1" x="121.90000000000006" y="273.09999999999997" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="209.1" y="92.45" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="461.85" y="91.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="500"/>
<Hero forcedName="null" layer="2" x="143.49999999999983" y="374.95" rotation="0"/>
<Rect forcedName="null" width="228" height="12" textureName="SteelTextureAsset" layer="1" x="431.9" y="246" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Hinge forcedName="null" skinName="HingeAsset" layer="1" x="392.95" y="246.95"/>
<Rect forcedName="null" width="23" height="19" textureName="BrickTextureAsset" layer="1" x="535.9" y="262" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="525.8" y="218" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="634" height="15" textureName="BrickTextureAsset" layer="1" x="320.04999999999995" y="411" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="3" woodMax="1500"/>
<Hero forcedName="null" layer="2" x="120.8499999999998" y="418.1999999999999" rotation="0"/>
<Rect forcedName="null" width="297.1" height="124.05" textureName="BrickTextureAsset" layer="1" x="115.39999999999998" y="508.9749999999999" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="28" layer="1" x="487" y="79.45" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="507.9" y="221.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="63.89999999999998" height="16.899999999999977" textureName="BrickTextureAsset" layer="1" x="515.95" y="250.5" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="257.84999999999997" y="218.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="69.49999999999997" height="18.5" textureName="BrickTextureAsset" layer="1" x="276.65" y="250.2" rotation="0.07" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="161" height="22" textureName="BrickTextureAsset" layer="1" x="684.5" y="100" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="2" woodMax="1500"/>
<Hero forcedName="null" layer="2" x="337.79999999999995" y="451.0499999999999" rotation="0"/>
<Circle forcedName="null" radius="16.55294535724685" textureName="BrickTextureAsset" layer="1" x="203.9" y="237.95" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="16.55294535724685" textureName="BrickTextureAsset" layer="1" x="469" y="237" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="18" layer="1" x="76.75000000000003" y="226.55" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="18" layer="1" x="574.75" y="222.55" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="4" woodMax="500"/>
<Hero forcedName="null" layer="2" x="343.6999999999999" y="445.35" rotation="0"/>
<Rect forcedName="null" width="323" height="14" textureName="BrickTextureAsset" layer="1" x="556" y="138.00000000000003" rotation="-0.11100000000000024" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="323" height="14" textureName="BrickTextureAsset" layer="1" x="669.8000000000001" y="249.95" rotation="-0.2405000000000002" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="618.65" y="100.05" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="591.6999999999999" y="223.05" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="6" v0x="-16.177304964538735" v0y="-1.709219858155933" v1x="-10.177304964538736" v1y="-7.709219858155933" v2x="10.822695035461264" v2y="-7.709219858155933" v3x="16.822695035461265" v3y="-0.709219858155933" v4x="10.822695035461264" v4y="7.290780141844067" v5x="-11.177304964538736" v5y="8.290780141844067" textureName="BrickTextureAsset" layer="1" x="584.0273049645388" y="62.009219858155944" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="6" v0x="-17.303546099290486" v0y="-1.5252955082739277" v1x="-9.303546099290486" v1y="-6.525295508273928" v2x="9.696453900709514" v2y="-6.525295508273928" v3x="17.696453900709514" v3y="0.4747044917260723" v4x="5.696453900709514" v4y="7.474704491726072" v5x="-9.303546099290486" v5y="6.474704491726072" textureName="BrickTextureAsset" layer="1" x="584.0035460992905" y="14.025295508273928" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="6" v0x="-17.077994428969248" v0y="-0.27112349117936674" v1x="-8.077994428969248" v1y="-7.271123491179367" v2x="9.922005571030752" v2y="-6.271123491179367" v3x="17.922005571030752" v3y="0.7288765088206333" v4x="7.922005571030752" v4y="6.728876508820633" v5x="-10.077994428969248" v5y="6.728876508820633" textureName="BrickTextureAsset" layer="1" x="583.0279944289692" y="37.02112349117937" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="29.5296461204668" textureName="BrickTextureAsset" layer="1" x="575.9" y="429.95" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Circle forcedName="null" radius="29.5296461204668" textureName="BrickTextureAsset" layer="1" x="76.89999999999998" y="433.95" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="323" height="14" textureName="BrickTextureAsset" layer="1" x="85.1" y="137.00000000000003" rotation="0.2085" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="49.69999999999998" y="99.1" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="102.1" height="23.05000000000001" textureName="BrickTextureAsset" layer="1" x="343.9" y="481.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="292.1" height="13.050000000000011" textureName="BrickTextureAsset" layer="1" x="103.95" y="297.475" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="22" layer="1" x="70.6" y="270.05" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="1000"/>
<Hero forcedName="null" layer="2" x="65.19999999999995" y="389.14999999999986" rotation="0"/>
<Rect forcedName="null" width="297.1" height="124.05" textureName="BrickTextureAsset" layer="1" x="-43.40000000000001" y="476.125" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="596.9" y="198.6" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="3" v0x="-328.66666666666663" v0y="47" v1x="155.33333333333337" v1y="-172" v2x="173.33333333333337" v2y="125" textureName="BrickTextureAsset" layer="1" x="572.6666666666666" y="449" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-7.094162826420913" v0y="-53.379109062980035" v1x="4.905837173579087" v1y="-55.379109062980035" v2x="14.905837173579089" v2y="15.620890937019963" v3x="1.905837173579087" v3y="64.62089093701996" v4x="-15.094162826420911" v4y="7.620890937019965" textureName="SteelTextureAsset" layer="1" x="130.09416282642093" y="105.37910906298004" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-8.363313389916996" v0y="-41.91942395992774" v1x="4.736686610082998" v1y="-42.86942395992773" v2x="14.736686610082998" v2y="-2.8694239599277296" v3x="3.636686610083004" v3y="58.08057604007226" v4x="-15.263313389917002" v4y="2.1305760400722704" textureName="SteelTextureAsset" layer="1" x="122.263313389917" y="218.86942395992773" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-10.25996185887783" v0y="-62.42085717153458" v1x="3.74003814112217" v1y="-63.42085717153458" v2x="19.74003814112217" v2y="-15.420857171534578" v3x="-0.25996185887782985" v3y="95.57914282846542" v4x="-18.25996185887783" v4y="-20.42085717153458" textureName="SteelTextureAsset" layer="1" x="162.25996185887783" y="284.4208571715346" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-6.964603048593389" v0y="-47.3838669842105" v1x="6.135396951406605" v1y="-48.33386698421049" v2x="15.135396951406603" v2y="-4.333866984210488" v3x="-1.9646030485933892" v3y="69.6161330157895" v4x="-13.864603048593397" v4y="-6.333866984210488" textureName="SteelTextureAsset" layer="1" x="132.86460304859338" y="380.3338669842105" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-2.678960443340287" v0y="-67.8533027581372" v1x="17.321039556659713" v1y="-17.853302758137204" v2x="0.32103955665971284" v2y="86.1466972418628" v3x="-16.678960443340287" v3y="-18.853302758137204" textureName="SteelTextureAsset" layer="1" x="176.6789604433403" y="446.8533027581372" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-9.726453357368229" v0y="-26.00796154423918" v1x="4.273546642631771" v1y="-25.00796154423918" v2x="16.27354664263177" v2y="1.99203845576082" v3x="2.2735466426317714" v3y="32.99203845576082" v4x="-14.726453357368229" v4y="3.99203845576082" textureName="SteelTextureAsset" layer="1" x="198.72645335736823" y="190.0079615442392" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="5" v0x="-8.686884396060094" v0y="-41.78486262312079" v1x="8.313115603939906" v1y="-42.78486262312079" v2x="15.313115603939906" v2y="-11.784862623120787" v3x="-0.6868843960600941" v3y="68.21513737687921" v4x="-14.686884396060094" v4y="-8.784862623120787" textureName="SteelTextureAsset" layer="1" x="164.6868843960601" y="124.7848626231208" rotation="0" density="1" friction="0.74" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="1000"/>
<Hero forcedName="null" layer="2" x="66.04999999999995" y="348.9999999999999" rotation="0"/>
<Coin forcedName="null" radius="22" layer="1" x="530.55" y="340.05" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="295.1" height="95.05" textureName="BrickTextureAsset" layer="1" x="620.45" y="459.475" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="108.45" height="67.55000000000001" textureName="BrickTextureAsset" layer="1" x="419.225" y="479.225" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="297.1" height="124.05" textureName="BrickTextureAsset" layer="1" x="105.45" y="436.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="4" woodMax="1000"/>
<Hero forcedName="null" layer="2" x="326.79999999999995" y="387.5499999999999" rotation="0"/>
<Coin forcedName="null" radius="20" layer="1" x="399.75" y="214.5999999999999" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="217.8" y="213.74999999999991" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Magnet forcedName="null" strength="2" maxDistance="200" layer="1" x="190" y="119.45" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Magnet forcedName="null" strength="2" maxDistance="200" layer="1" x="433.7999999999999" y="121.3000000000001" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="554.85" y="209.64999999999992" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="86.75000000000003" y="210.5999999999999" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="663.1" height="76.05000000000001" textureName="BrickTextureAsset" layer="1" x="320.45" y="452.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="1500"/>
<Hero forcedName="null" layer="2" x="367.7999999999999" y="249.6" rotation="0"/>
<Coin forcedName="null" radius="22" layer="1" x="206.4" y="303.5" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="121.89999999999998" height="36.94999999999999" textureName="BrickTextureAsset" layer="1" x="366.9" y="294.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="4" woodMax="1200"/>
<Hero forcedName="null" layer="2" x="352.79999999999995" y="313.79999999999995" rotation="0"/>
<Coin forcedName="null" radius="22" layer="1" x="196.69999999999993" y="67.00000000000001" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="18" layer="1" x="145.0999999999999" y="166.15" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="323.89999999999986" y="78.60000000000002" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-47.48499608380643" v0y="-14.953811761634256" v1x="46.41500391619354" v1y="-15.30381176163428" v2x="18.06500391619352" v2y="20.546188238365744" v3x="-16.58499608380646" v3y="20.69618823836572" textureName="BrickTextureAsset" layer="1" x="354.58499608380646" y="357.3038117616343" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="18" layer="1" x="460.9999999999999" y="204.1" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="3" v0x="-24.666666666666544" v0y="4.666666666666728" v1x="12.333333333333456" v1y="-19.33333333333327" v2x="12.333333333333456" v2y="14.666666666666728" textureName="BrickTextureAsset" layer="1" x="207.66666666666657" y="100.33333333333329" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Poly forcedName="null" numVerts="4" v0x="-50.484388535618734" v0y="-13.444940558473789" v1x="66.41561146438124" v1y="-2.494940558473786" v2x="66.41561146438124" v2y="6.505059441526214" v3x="-47.484388535618734" v3y="10.555059441526211" textureName="BrickTextureAsset" layer="1" x="349.48438853561873" y="111.4449405584738" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="1500"/>
<Hero forcedName="null" layer="2" x="281.9" y="145.2000000000001" rotation="0"/>
<Coin forcedName="null" radius="20" layer="1" x="151.75" y="399.55" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="111.89999999999998" height="15.949999999999989" textureName="BrickTextureAsset" layer="1" x="280.95" y="179.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="337.1" height="26.05000000000001" textureName="BrickTextureAsset" layer="1" x="230.45" y="470.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
_local2 = <World>
<LevelSettings coinsToWin="1" woodMax="1000"/>
<Hero forcedName="null" layer="2" x="136.84999999999997" y="382.94999999999993" rotation="0"/>
<Magnet forcedName="null" strength="2" maxDistance="200" layer="1" x="381.5999999999999" y="168.65" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Magnet forcedName="null" strength="2" maxDistance="200" layer="1" x="377.8" y="249.39999999999992" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Coin forcedName="null" radius="20" layer="1" x="463.0499999999999" y="120.7" rotation="0" density="1" friction="0.2" restitution="0.2" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="false" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
<Rect forcedName="null" width="266.9" height="128.05" textureName="BrickTextureAsset" layer="1" x="121.45000000000002" y="473.975" rotation="0" density="5" friction="1" restitution="0.1" linearDamping="0" angularDamping="0" isFixedRotation="false" isStatic="true" isSensor="false" isBullet="false" categoryBits="1" maskBits="1" groupIndex="0"/>
</World>
;
levels.push(_local2);
}
public function loadData():void{
var _local5:int;
var _local1:SharedObject = SharedObject.getLocal("sticks");
var _local2:Array = new Array(numLevels);
var _local3:Array = new Array(numLevels);
var _local4:Array = new Array(numLevels);
_local2 = _local1.data.levelsOpen;
_local3 = _local1.data.levelsCompletion;
_local4 = _local1.data.levelsScore;
if (_local3){
_local5 = 0;
while (_local5 < numLevels) {
(levelInfos[_local5] as LevelInfo).isOpen = _local2[_local5];
(levelInfos[_local5] as LevelInfo).isCompleted = _local3[_local5];
(levelInfos[_local5] as LevelInfo).bestScore = _local4[_local5];
_local5++;
};
};
}
public function clearProgress():void{
var _local2:LevelInfo;
var _local1:int;
while (_local1 < levelInfos.length) {
_local2 = levelInfos[_local1];
_local2.clear();
if (_local1 == 0){
_local2.isOpen = true;
};
_local1++;
};
saveData();
}
public static function get instance():GameData{
if (!_instance){
_instance = new (GameData);
};
return (_instance);
}
}
}//package
Section 220
//GameEvent (GameEvent)
package {
import flash.events.*;
public class GameEvent extends Event {
public var data:Object;
public static const BOX2DOBJECT_SELECTED:String = "box2d object selected";
public static const LEVEL_LOADED:String = "level loaded";
public static const GOTO_EDITOR:String = "go to editor";
public static const SHOW_HIDE_COLLISION_BAR:String = "show hide collision bar";
public static const SHOW_HIDE_SAVE_BAR:String = "show hide save bar";
public static const UPDATE_UI:String = "update UI";
public static const NEXT_LEVEL:String = "next level";
public static const LEVEL_ICON_CLICK:String = "level icon click";
public static const SHOW_HIDE_COIN_BAR:String = "show hide coin bar";
public static const SELECT_LEVEL:String = "select level";
public static const MOTOR_SELECTED:String = "motor selected";
public static const SHOW_HIDE_COINS_EMITTER_BAR:String = "show hide coins emitter bar";
public static const SHOW_HIDE_MOTORS_BAR:String = "show hide motors bar";
public static const LEVEL_COMPLETE:String = "level complete";
public static const SHOW_HIDE_LOAD_BAR:String = "show hide load bar";
public static const SHOW_HIDE_MATERIAL_BAR:String = "show hide material bar";
public static const TEST_LEVEL:String = "test level";
public static const SHOW_HIDE_MAGNET_BAR:String = "show hide magnet bar";
public static const SHOW_HIDE_LEVEL_SETTINGS_BAR:String = "show hide level settings bar";
public static const LEVEL_ICON_OVER:String = "level icon over";
public function GameEvent(_arg1:String, _arg2:Object=null, _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.data = _arg2;
}
}
}//package
Section 221
//Preloader (Preloader)
package {
import flash.events.*;
import flash.display.*;
import Playtomic.*;
import flash.text.*;
import flash.net.*;
import flash.utils.*;
import flash.ui.*;
import flash.system.*;
public class Preloader extends MovieClip {
private var coins:Array;
private var prevProgress:Number;
private var WindowClass:Class;
private var loadingText:MovieClip;
private var devKey:String;// = "81e402f6d18cfd00bc230089f5128a2a"
private var gameKey:String;// = "sticks"
private var anim:MovieClip;
private var percentLoaded:Number;
private var percent_tf:TextField;
private var armorGames_bt:SimpleButton;
private var forbidden:Sprite;
private var loading:Sprite;
private var play_bt:SimpleButton;
public static var DOMAIN_LOCAL:Boolean = false;
public static var DEBUG:Boolean = false;
public static var DOMAIN_OLOLOGAMES:Boolean = false;
public static var agi;
public static var DOMAIN_ARMORGAMES:Boolean = false;
public function Preloader():void{
WindowClass = Preloader_WindowClass;
super();
init();
}
private function armorGamesClickHandler(_arg1:MouseEvent):void{
Link.Open("http://armorgames.com", "PreloaderLogo", "Sponsor");
}
private function createWindow():void{
var _local1:Sprite = new WindowClass();
addChild(_local1);
play_bt = (_local1.getChildByName("play_bt") as SimpleButton);
forbidden = (_local1.getChildByName("forbidden") as Sprite);
loading = (_local1.getChildByName("loading") as Sprite);
percent_tf = (loading.getChildByName("percent_tf") as TextField);
armorGames_bt = (_local1.getChildByName("armorGames_bt") as SimpleButton);
anim = (_local1.getChildByName("anim") as MovieClip);
loadingText = (anim.getChildByName("loadingText") as MovieClip);
}
private function updateProgress(_arg1:Number):void{
prevProgress = percentLoaded;
var _local2:int = (Math.round((percentLoaded * 22)) - coins.length);
var _local3:int;
while (_local3 < _local2) {
createCoin();
_local3++;
};
percent_tf.text = (Math.round((_arg1 * 100)).toString() + "%");
}
private function init():void{
var _local1:ContextMenu = new ContextMenu();
_local1.hideBuiltInItems();
contextMenu = _local1;
coins = [];
createWindow();
initArmorScores();
play_bt.addEventListener(MouseEvent.CLICK, playClickHandler);
armorGames_bt.addEventListener(MouseEvent.CLICK, armorGamesClickHandler);
forbidden.visible = false;
play_bt.visible = false;
anim.stop();
Log.View(1563, "0cc8b23a7b7c4f28", root.loaderInfo.loaderURL);
loading.visible = false;
checkDomain();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, onRootLoaderProgress);
loaderInfo.addEventListener(Event.COMPLETE, onRootLoaderComplete);
}
private function initArmorScores():void{
var _local1 = "http://agi.armorgames.com/assets/agi/AGI.swf";
Security.allowDomain(_local1);
var _local2:URLRequest = new URLRequest(_local1);
var _local3:Loader = new Loader();
_local3.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
_local3.load(_local2);
}
private function onRootLoaderProgress(_arg1:ProgressEvent):void{
var _local2:Number = _arg1.target.bytesLoaded;
var _local3:Number = _arg1.target.bytesTotal;
percentLoaded = (_local2 / _local3);
updateProgress(percentLoaded);
}
private function clickHandler(_arg1:MouseEvent):void{
createCoin();
}
private function createCoin():void{
var _local1:PreloaderCoin = new PreloaderCoin();
_local1.x = (16 + (coins.length * 12.3));
_local1.y = -25;
anim.addChild(_local1);
coins.push(_local1);
}
private function onRootLoaderComplete(_arg1:Event):void{
updateProgress(1);
loadingText.visible = false;
loading.visible = false;
play_bt.visible = true;
}
private function playClickHandler(_arg1:MouseEvent):void{
var _local3:Object;
loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onRootLoaderProgress);
loaderInfo.removeEventListener(Event.COMPLETE, onRootLoaderComplete);
nextFrame();
var _local2:Class = Class(getDefinitionByName("Sticks"));
if (_local2){
_local3 = new (_local2);
addChild((_local3 as DisplayObject));
};
}
private function checkDomain():void{
var _local1:String = stage.loaderInfo.url;
var _local2:Number = (_local1.indexOf("://") + 3);
var _local3:Number = _local1.indexOf("/", _local2);
var _local4:String = _local1.substring(_local2, _local3);
var _local5:Number = (_local4.lastIndexOf(".") - 1);
var _local6:Number = (_local4.lastIndexOf(".", _local5) + 1);
_local4 = _local4.substring(_local6, _local4.length);
if ((((_local4 == "")) || ((_local4 == "localhost")))){
DOMAIN_LOCAL = true;
};
if ((((_local4 == "isfland.com")) || ((_local4 == "olologames.com")))){
DOMAIN_OLOLOGAMES = true;
};
if (_local4 == "armorgames.com"){
DOMAIN_ARMORGAMES = true;
};
}
private function loadComplete(_arg1:Event):void{
agi = _arg1.currentTarget.content;
addChild(agi);
agi.init(devKey, gameKey, null, true);
}
}
}//package
Section 222
//Preloader_WindowClass (Preloader_WindowClass)
package {
import mx.core.*;
import flash.display.*;
public class Preloader_WindowClass extends SpriteAsset {
public var loadingText:DisplayObject;
public var percent_tf:DisplayObject;
public var armorGames_bt:DisplayObject;
public var anim:DisplayObject;
public var forbidden:DisplayObject;
public var loading:DisplayObject;
public var play_bt:DisplayObject;
}
}//package
Section 223
//PreloaderCoin (PreloaderCoin)
package {
import flash.events.*;
import flash.display.*;
public class PreloaderCoin extends Sprite {
private var CoinLoadClass:Class;
private var skin:MovieClip;
public function PreloaderCoin():void{
CoinLoadClass = PreloaderCoin_CoinLoadClass;
super();
init();
}
private function init():void{
skin = new CoinLoadClass();
addChild(skin);
skin.addEventListener(Event.ENTER_FRAME, efHandler);
}
private function efHandler(_arg1:Event):void{
if (skin.currentFrame == skin.totalFrames){
skin.stop();
skin.removeEventListener(Event.ENTER_FRAME, efHandler);
};
}
}
}//package
Section 224
//PreloaderCoin_CoinLoadClass (PreloaderCoin_CoinLoadClass)
package {
import mx.core.*;
import flash.display.*;
public class PreloaderCoin_CoinLoadClass extends MovieClipAsset {
public var loadingText:DisplayObject;
public var percent_tf:DisplayObject;
public var armorGames_bt:DisplayObject;
public var anim:DisplayObject;
public var forbidden:DisplayObject;
public var loading:DisplayObject;
public var play_bt:DisplayObject;
}
}//package
Section 225
//Sticks (Sticks)
package {
import flash.events.*;
import AKEngine.screens.*;
import flash.display.*;
import AKEngine.managers.*;
import helpers.*;
import managers.*;
import screens.*;
public class Sticks extends RootScreen {
public static const SITE_URL:String = "http://armorgames.com";
public static const WALKTHROUGH_URL:String = "http://armorgames.com/guide/Sticks-get-a-hint";
public static var container:Sprite;
public static var scoresConatiner:Sprite;
public static var faderContainer:Sprite;
public static var topContainer:Sprite;
override protected function postInit():void{
container = new Sprite();
stage.addChild(container);
container.addChild(this);
faderContainer = new Sprite();
stage.addChild(faderContainer);
scoresConatiner = new Sprite();
stage.addChild(scoresConatiner);
topContainer = new Sprite();
stage.addChild(topContainer);
var _local1:IntroAssetsManager = IntroAssetsManager.instance;
_local1.addEventListener(Event.INIT, introAssetsInitHandler);
_local1.initialize();
}
private function logoViewCompleteHandler(_arg1:Event):void{
var _local2:TopView = new TopView();
topContainer.addChild(_local2);
var _local3:MainMenuScreen = new MainMenuScreen();
changeScreen(_local3);
}
private function introAssetsInitHandler(_arg1:Event):void{
var _local2:HintsAssetsManager = HintsAssetsManager.instance;
_local2.addEventListener(Event.INIT, hintsAssetsInitHandler);
_local2.initialize();
}
private function initSounds():void{
var _local1:AssetsManager = AssetsManager.instance;
var _local2:SoundManager = SoundManager.instance;
var _local3:Class = _local1.getAssetClass("coinCollectedSound");
_local2.registerSound(new (_local3), "coinCollectedSound");
var _local4:Class = _local1.getAssetClass("levelCompleteSound");
_local2.registerSound(new (_local4), "levelCompleteSound");
var _local5:Class = _local1.getAssetClass("stickCreatedSound");
_local2.registerSound(new (_local5), "stickCreatedSound");
var _local6:Class = _local1.getAssetClass("cantCreateStickSound");
_local2.registerSound(new (_local6), "cantCreateStickSound");
var _local7:Class = _local1.getAssetClass("stickDeletedSound");
_local2.registerSound(new (_local7), "stickDeletedSound");
var _local8:Class = _local1.getAssetClass("SndWoodHitAsset");
_local2.registerSound(new (_local8), "sndWoodHit");
var _local9:Class = _local1.getAssetClass("SndCoinHitAsset");
_local2.registerSound(new (_local9), "sndCoinHit");
var _local10:Class = _local1.getAssetClass("SndButtonPress");
_local2.registerSound(new (_local10), "sndButtonPress");
var _local11:Class = _local1.getAssetClass("SndMusicMenu");
_local2.registerSound(new (_local11), "sndMusicMenu");
var _local12:Class = _local1.getAssetClass("SndMusicLevel");
_local2.registerSound(new (_local12), "sndMusicLevel");
var _local13:Class = _local1.getAssetClass("SndClothingRustle");
_local2.registerSound(new (_local13), "sndClothingRustle");
var _local14:Class = _local1.getAssetClass("SndIntro");
_local2.registerSound(new (_local14), "sndIntro");
var _local15:Class = _local1.getAssetClass("SndFinal");
_local2.registerSound(new (_local15), "sndFinal");
var _local16:Class = _local1.getAssetClass("SndCoinsFall");
_local2.registerSound(new (_local16), "sndCoinsFall");
}
private function hintsAssetsInitHandler(_arg1:Event):void{
var _local3:LogoView;
Fader.getInstance();
var _local2:GameData = GameData.instance;
_local2.initialize();
_local2.loadData();
initSounds();
SoundManager.instance.musicVolume = 1;
if (Preloader.DEBUG){
logoViewCompleteHandler(null);
} else {
_local3 = new LogoView();
_local3.addEventListener(LogoView.COMPLETE, logoViewCompleteHandler);
topContainer.addChild(_local3);
};
}
}
}//package