Section 1
//Converter (ascb.units.Converter)
package ascb.units {
import ascb.util.*;
public class Converter {
private var _uFrom:Unit;
private var _uTo:Unit;
public function Converter(_arg1:Unit, _arg2:Unit){
_uFrom = _arg1;
_uTo = _arg2;
}
public function convert(_arg1:Number, _arg2:Boolean=false):Number{
var _local3:Function = LookUpTable.getConversionFunction(((_uFrom.baseUnit.name + "TO") + _uTo.baseUnit.name));
var _local4:Number = NumberUtilities.round((_local3((_arg1 * _uFrom.multiplier)) / _uTo.multiplier), 1E-7);
if (_arg2){
trace(((((("converting " + _arg1) + " ") + _uFrom.name) + " to ") + _uTo.name));
trace(((((((("\t" + _uFrom.name) + ": 1 ") + _uFrom.baseUnit.name) + " = ") + _uFrom.multiplier) + " ") + _uFrom.name));
trace(((((((("\t" + _uTo.name) + ": 1 ") + _uTo.baseUnit.name) + " = ") + _uTo.multiplier) + " ") + _uTo.name));
trace(((("\tanswer: " + _local4) + " ") + ((_local4 == 1)) ? _uTo.label : _uTo.labelPlural));
};
return (_local4);
}
public function convertWithLabel(_arg1:Number):String{
var _local2:Number = convert(_arg1);
return (((_local2 + " ") + ((Math.abs((_local2 - 1)))<1E-15) ? _uTo.label : _uTo.labelPlural));
}
}
}//package ascb.units
class LookUpTable {
private function LookUpTable(){
}
public static function getConversionFunction(_arg1:String):Function{
var oFunctions:Object;
var sKey = _arg1;
oFunctions = new Object();
oFunctions.degreeTOradian = function (_arg1:Number):Number{
return (((_arg1 * Math.PI) / 180));
};
oFunctions.radianTOdegree = function (_arg1:Number):Number{
return (((_arg1 * 180) / Math.PI));
};
oFunctions.gradianTOdegree = function (_arg1:Number):Number{
return ((_arg1 * 0.9));
};
oFunctions.gradianTOradian = function (_arg1:Number):Number{
return (oFunctions.degreeTOradian((_arg1 * 0.9)));
};
oFunctions.degreeTOgradian = function (_arg1:Number):Number{
return ((_arg1 / 0.9));
};
oFunctions.radianTOgradian = function (_arg1:Number):Number{
return ((oFunctions.radianTOdegree(_arg1) / 0.9));
};
oFunctions.fahrenheitTOcelcius = function (_arg1:Number):Number{
return (((_arg1 - 32) * (5 / 9)));
};
oFunctions.celciusTOfahrenheit = function (_arg1:Number):Number{
return (((_arg1 * (9 / 5)) + 32));
};
oFunctions.fahrenheitTOkelvin = function (_arg1:Number):Number{
return ((oFunctions.fahrenheitTOcelcius(_arg1) + 273.15));
};
oFunctions.kelvinTOfahrenheit = function (_arg1:Number):Number{
return ((oFunctions.fahrenheitTOcelcius(_arg1) + 273.15));
};
oFunctions.celciusTOkelvin = function (_arg1:Number):Number{
return ((_arg1 + 273.15));
};
oFunctions.kelvinTOcelcius = function (_arg1:Number):Number{
return ((_arg1 - 273.15));
};
oFunctions.gramTOpound = function (_arg1:Number):Number{
return ((_arg1 * 0.0022));
};
oFunctions.poundTOgram = function (_arg1:Number):Number{
return ((_arg1 / 0.0022));
};
oFunctions.footTOmeter = function (_arg1:Number):Number{
return ((_arg1 / 3.2808399));
};
oFunctions.meterTOfoot = function (_arg1:Number):Number{
return ((_arg1 * 3.2808399));
};
oFunctions.gallonTOliter = function (_arg1:Number):Number{
return ((_arg1 * 3.7854));
};
oFunctions.literTOgallon = function (_arg1:Number):Number{
return ((_arg1 / 3.7854));
};
oFunctions.none = function (_arg1:Number):Number{
return (_arg1);
};
return (((oFunctions[sKey])==null) ? oFunctions.none : oFunctions[sKey]);
}
}
Section 2
//Unit (ascb.units.Unit)
package ascb.units {
public class Unit {
private var _sUnitName:String;
private var _sLabelPlural:String;
private var _uBaseUnit:Unit;
private var _nMultiplier:Number;
private var _sLabelSingular:String;
private var _sUnitCategory:String;
public function Unit(_arg1:String, _arg2:String, _arg3:Unit=null, _arg4:Number=1, _arg5:String=null, _arg6:String=null){
_sUnitName = _arg1;
_sUnitCategory = _arg2;
_uBaseUnit = ((_arg3)==null) ? this : _arg3;
_sLabelSingular = ((_arg5)==null) ? _arg1 : _arg5;
_sLabelPlural = ((_arg6)==null) ? (_sLabelSingular + "s") : _arg6;
_nMultiplier = _arg4;
}
public function get multiplier():Number{
return (_nMultiplier);
}
public function getConverterTo(_arg1:Unit):Converter{
if (_arg1.category != _sUnitCategory){
return (null);
};
return (new Converter(this, _arg1));
}
public function get name():String{
return (_sUnitName);
}
public function get label():String{
return (_sLabelSingular);
}
public function get baseUnit():Unit{
return (_uBaseUnit);
}
public function get labelPlural():String{
return (_sLabelPlural);
}
public function getConverterFrom(_arg1:Unit):Converter{
if (_arg1.category != _sUnitCategory){
return (null);
};
return (new Converter(_arg1, this));
}
public function get category():String{
return (_sUnitCategory);
}
public static function get GALLON():Unit{
return (new Unit("gallon", "volume"));
}
public static function get RADIAN():Unit{
return (new Unit("radian", "angle"));
}
public static function get MILLIGRAM():Unit{
return (new Unit("milligram", "weightmass", GRAM, 0.001));
}
public static function get GRADIAN():Unit{
return (new Unit("gradian", "angle"));
}
public static function get KELVIN():Unit{
return (new Unit("kelvin", "temperature", null, 1, "kelvin", "kelvin"));
}
public static function get OUNCE():Unit{
return (new Unit("ounce", "weightmass", POUND, (1 / 16)));
}
public static function get LITER():Unit{
return (new Unit("liter", "volume"));
}
public static function get POUND():Unit{
return (new Unit("pound", "weightmass"));
}
public static function get CELCIUS():Unit{
return (new Unit("celcius", "temperature", null, 1, "celcius", "celcius"));
}
public static function get CENTIMETER():Unit{
return (new Unit("centimeter", "distance", METER, 0.01));
}
public static function get METER():Unit{
return (new Unit("meter", "distance"));
}
public static function get INCH():Unit{
return (new Unit("inch", "distance", FOOT, (1 / 12), "inch", "inches"));
}
public static function getCategories():Array{
return (["angle", "temperature", "weightmass", "distance", "volume"]);
}
public static function get TON():Unit{
return (new Unit("ton", "weightmass", POUND, 2000));
}
public static function get FOOT():Unit{
return (new Unit("foot", "distance", null, 1, "foot", "feet"));
}
public static function get FAHRENHEIT():Unit{
return (new Unit("fahrenheit", "temperature", null, 1, "fahrenheit", "fahrenheit"));
}
public static function get GRAM():Unit{
return (new Unit("gram", "weightmass"));
}
public static function get KILOGRAM():Unit{
return (new Unit("kilogram", "weightmass", GRAM, 1000));
}
public static function getUnits(_arg1:String):Array{
var _local2:Array = ["DEGREE", "RADIAN", "GRADIAN"];
var _local3:Array = ["CELCIUS", "FAHRENHEIT", "KELVIN"];
var _local4:Array = ["OUNCE", "POUND", "TON", "MILLIGRAM", "GRAM", "KILOGRAM"];
var _local5:Array = ["CENTIMETER", "METER", "KILOMETER", "INCH", "FOOT", "MILE", "YARD"];
var _local6:Array = ["LITER", "GALLON"];
_local2.sort();
_local3.sort();
_local4.sort();
_local5.sort();
_local6.sort();
var _local7:Array = _local2.concat(_local3, _local4, _local5, _local6);
switch (_arg1){
case "angle":
return (_local2);
case "temperature":
return (_local3);
case "weightmass":
return (_local4);
case "distance":
return (_local5);
case "volume":
return (_local6);
default:
return (_local7);
};
}
public static function get YARD():Unit{
return (new Unit("yard", "distance", FOOT, 3));
}
public static function get DEGREE():Unit{
return (new Unit("degree", "angle"));
}
public static function get MILE():Unit{
return (new Unit("mile", "distance", FOOT, 5280));
}
public static function get KILOMETER():Unit{
return (new Unit("kilometer", "distance", METER, 1000));
}
}
}//package ascb.units
Section 3
//DateFormat (ascb.util.DateFormat)
package ascb.util {
public class DateFormat {
private var _sMask:String;
public static const DAYSINMONTH:Array = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
public static const MONTHS_ABBREVIATED:Array = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
public static const DAYS_ABBREVIATED:Array = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"];
public static const MONTHS:Array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
public static const DAYS:Array = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
public function DateFormat(_arg1:String){
_sMask = _arg1;
}
public function set mask(_arg1:String):void{
_sMask = _arg1;
}
private function getMaskElements(_arg1:Boolean=false):Array{
var _local4:Array;
var _local7:Number;
var _local2:Array = _sMask.split("'");
var _local3:Array = new Array();
var _local5:RegExp = new RegExp("[a-zA-Z]");
var _local6:Number = 0;
while (_local6 < _local2.length) {
if ((_local6 % 2) != 0){
_local3.push({type:"quoted", element:_local2[_local6]});
} else {
_local4 = _local2[_local6].split("");
_local7 = 0;
while (_local7 < _local4.length) {
if (((_local5.test(_local4[_local7])) && (_arg1))){
_local3.push({type:"regular", element:_local4[_local7]});
} else {
if (!_arg1){
_local3.push({type:"regular", element:_local4[_local7]});
};
};
_local7++;
};
};
_local6++;
};
return (_local3);
}
public function parse(_arg1:String):Date{
var _local3:Number;
var _local4:Number;
var _local8:String;
var _local9:String;
var _local10:String;
var _local11:Number;
var _local2:Array = getMaskElements(true);
_local4 = 0;
while (_local4 < _local2.length) {
_local3 = _arg1.indexOf(_local2[_local4].element);
if (_local2[_local4].type == "quoted"){
if (_local3 != -1){
_arg1 = ((_arg1.substring(0, _local3) + " ") + _arg1.substring((_local3 + _local2[_local4].element.length)));
_local2.splice(_local4, 1);
_local4--;
};
};
_local4++;
};
var _local5:RegExp = new RegExp("[^a-zA-Z0-9]+");
var _local6:Array = _arg1.split(_local5);
var _local7:Date = new Date(0, 0, 0, 0, 0, 0, 0);
_local4 = 0;
while (_local4 < _local2.length) {
_local9 = String(_local6.shift());
switch (_local2[_local4].element){
case "a":
case "A":
_local8 = _local9.toLowerCase();
break;
case "d":
_local7.setDate(parseInt(_local9));
break;
case "F":
_local10 = _local6.shift().toLowerCase();
_local11 = 0;
while (_local11 < DateFormat.MONTHS.length) {
if (_local10 == DateFormat.MONTHS[_local11].toLowerCase()){
_local7.setMonth(_local11);
break;
};
_local11++;
};
break;
case "g":
case "G":
case "h":
case "H":
_local7.setHours(parseInt(_local9));
break;
case "i":
_local7.setMinutes(parseInt(_local9));
break;
case "j":
_local7.setDate(parseInt(_local9));
break;
case "m":
case "n":
_local7.setMonth((parseInt(_local9) - 1));
break;
case "M":
_local10 = _local9.toLowerCase();
_local11 = 0;
while (_local11 < DateFormat.MONTHS_ABBREVIATED.length) {
if (DateFormat.MONTHS_ABBREVIATED[_local11].toLowerCase() == _local10){
_local7.setMonth(_local11);
break;
};
_local11++;
};
break;
case "s":
_local7.setSeconds(parseInt(_local9));
break;
case "y":
_local7.setFullYear((2000 + parseInt(_local9)));
break;
case "Y":
_local7.setFullYear(parseInt(_local9));
break;
};
_local4++;
};
if (_local8 == "pm"){
if (_local7.getHours() < 12){
_local7.setHours((_local7.getHours() + 12));
};
} else {
if (_local8 == "am"){
if (_local7.getHours() == 12){
_local7.setHours(0);
};
};
};
return (_local7);
}
public function get mask():String{
return (_sMask);
}
public function format(_arg1:Date):String{
var _local2:NumberFormat;
var _local5:Number;
var _local3:Array = getMaskElements();
var _local4:Array = new Array();
var _local6:Number = 0;
while (_local6 < _local3.length) {
switch (_local3[_local6].element){
case "a":
if (_arg1.getHours() < 12){
_local4.push("am");
} else {
_local4.push("pm");
};
break;
case "A":
if (_arg1.getHours() < 12){
_local4.push("AM");
} else {
_local4.push("PM");
};
break;
case "d":
_local4.push(_arg1.getDate());
break;
case "D":
_local4.push(DateFormat.DAYS_ABBREVIATED[_arg1.getDay()]);
break;
case "F":
_local4.push(DateFormat.MONTHS[_arg1.getMonth()]);
break;
case "g":
_local5 = _arg1.getHours();
if (_local5 == 12){
_local4.push(12);
} else {
if (_local5 <= 12){
_local4.push(_local5);
} else {
_local4.push((_local5 - 12));
};
};
break;
case "G":
_local4.push(_arg1.getHours());
break;
case "h":
_local2 = new NumberFormat("00");
_local5 = _arg1.getHours();
if (_local5 == 12){
_local4.push(12);
} else {
if (_local5 <= 12){
_local4.push(_local2.format(_local5));
} else {
_local4.push(_local2.format((_local5 - 12)));
};
};
break;
case "H":
_local2 = new NumberFormat("00");
_local4.push(_local2.format(_arg1.getHours()));
break;
case "i":
_local2 = new NumberFormat("00");
_local4.push(_local2.format(_arg1.getMinutes()));
break;
case "j":
_local4.push(_arg1.getDate());
break;
case "l":
_local4.push(DateFormat.DAYS[_arg1.getDay()]);
break;
case "m":
_local2 = new NumberFormat("00");
_local4.push(_local2.format((_arg1.getMonth() + 1)));
break;
case "M":
_local4.push(DateFormat.MONTHS_ABBREVIATED[_arg1.getMonth()]);
break;
case "n":
_local4.push((_arg1.getMonth() + 1));
break;
case "s":
_local2 = new NumberFormat("00");
_local4.push(_local2.format(_arg1.getSeconds()));
break;
case "t":
_local4.push(DateFormat.DAYSINMONTH[_arg1.getMonth()]);
break;
case "w":
_local4.push(_arg1.getDay());
break;
case "y":
_local4.push(String(_arg1.getFullYear()).substring(2));
break;
case "Y":
_local4.push(_arg1.getFullYear());
break;
case "\\":
_local4.push((_local3[_local6].element + ((_local3[(_local6 + 1)].element)==undefined) ? "" : _local3[(_local6 + 1)].element));
_local6++;
break;
default:
_local4.push(_local3[_local6].element);
};
_local6++;
};
return (_local4.join(""));
}
public static function formatSeconds(_arg1:Number):String{
var _local2:NumberFormat = new NumberFormat("00");
var _local3:String = _local2.format(Math.floor((_arg1 / 60)));
var _local4:String = _local2.format(Math.round((_arg1 - (parseInt(_local3) * 60))));
return (((_local3 + ":") + _local4));
}
public static function formatMilliseconds(_arg1:Number):String{
var _local2:Number = (_arg1 / 1000);
return (formatSeconds(_local2));
}
public static function formatMMSSMM(_arg1:Number):String{
var _local2:NumberFormat = new NumberFormat("00");
var _local3:Number = (_arg1 / 1000);
var _local4:String = _local2.format(Math.floor(((_arg1 - (_local3 * 1000)) / 10)));
return (((formatSeconds(_local3) + ":") + _local4));
}
}
}//package ascb.util
Section 4
//Locale (ascb.util.Locale)
package ascb.util {
import flash.system.*;
public class Locale {
private var _sVariant:String;
private var _sLanguage:String;
public static const GERMAN:String = "de";
public static const CHINESE:String = "zh";
public static const ENGLISH:String = "en";
public static const SPANISH:String = "es";
public static const UK:String = "UK";
public static const US:String = "US";
public static const FRENCH:String = "fr";
public static const JAPANESE:String = "jp";
private static var __sLanguage:String;
private static var __sVariant:String;
public function Locale(_arg1:String=null, _arg2:String=null){
_sLanguage = _arg1;
_sVariant = _arg2;
}
public function set language(_arg1:String):void{
_sLanguage = _arg1;
}
public function get variant():String{
if (_sVariant == null){
if (Locale.svariant == null){
if (Capabilities.language.length > 2){
_sVariant = Capabilities.language.substr(3);
} else {
if (language == ENGLISH){
if (new Date().getTimezoneOffset() > 120){
_sVariant = US;
} else {
_sVariant = UK;
};
} else {
if (language == SPANISH){
if (new Date().getTimezoneOffset() > 120){
_sVariant = "MX";
} else {
_sVariant = "ES";
};
};
};
};
} else {
_sVariant = Locale.svariant;
};
};
return (_sVariant);
}
public function reset():void{
_sLanguage = null;
_sVariant = null;
}
public function set languageVariant(_arg1:String):void{
var _local2:Array = _arg1.split("-");
_sLanguage = _local2[0];
_sVariant = _local2[1];
}
public function set variant(_arg1:String):void{
_sVariant = _arg1;
}
public function get languageVariant():String{
var _local1:String = language;
if (variant != null){
_local1 = (_local1 + ("-" + variant));
};
return (_local1);
}
public function get language():String{
if (_sLanguage == null){
if (Locale.slanguage == null){
_sLanguage = Capabilities.language.substr(0, 2);
} else {
_sLanguage = Locale.slanguage;
};
};
return (_sLanguage);
}
public static function sreset():void{
__sLanguage = null;
__sVariant = null;
}
public static function get slanguage():String{
return (__sLanguage);
}
public static function set slanguage(_arg1:String):void{
__sLanguage = _arg1;
}
public static function set svariant(_arg1:String):void{
__sVariant = _arg1;
}
public static function get svariant():String{
return (__sVariant);
}
public static function get slanguageVariant():String{
var _local1:String = slanguage;
if (svariant != null){
_local1 = (_local1 + ("-" + svariant));
};
return (_local1);
}
public static function set slanguageVariant(_arg1:String):void{
var _local2:Array = _arg1.split("-");
__sLanguage = _local2[0];
__sVariant = _local2[1];
}
}
}//package ascb.util
Section 5
//NumberFormat (ascb.util.NumberFormat)
package ascb.util {
public class NumberFormat {
private var _sMask:String;
public function NumberFormat(_arg1:String=null){
_sMask = _arg1;
}
public function parse(_arg1:String, _arg2:Number, _arg3:Boolean, _arg4:Locale):Number{
if (_arg4 == null){
_arg4 = new Locale();
};
var _local5:Object = getSymbols(_arg3, _arg4);
var _local6:Array = _arg1.split("");
if (isNaN(_arg2)){
if (_local6[0] == "O"){
if (_local6[1] == "x"){
_arg2 = 16;
} else {
_arg2 = 8;
};
} else {
if (_local6[0] == "#"){
_arg2 = 16;
} else {
_arg2 = (isNaN(_arg2)) ? 10 : _arg2;
};
};
};
var _local7:Number = 0;
while (_local7 < _local6.length) {
switch (_local6[_local7]){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
break;
case _local5.decimal:
_local6[_local7] = ".";
break;
default:
if (_arg2 > 10){
if ((((((_local6[_local7].charCodeAt(0) > 64)) && ((_local6[_local7].charCodeAt(0) < 91)))) || ((((_local6[_local7].charCodeAt(0) > 96)) && ((_local6[_local7].charCodeAt(0) < 123)))))){
break;
};
};
_local6.splice(_local7, 1);
_local7--;
};
_local7++;
};
if (_arg2 == 10){
return (Number(_local6.join("")));
};
return (parseInt(_local6.join(""), _arg2));
}
private function getSymbols(_arg1:Boolean, _arg2:Locale):Object{
var _local3:Object = new Object();
switch (_arg2.languageVariant){
case "en-US":
_local3.currency = "$";
_local3.group = ",";
_local3.decimal = ".";
_local3.before = true;
break;
case "en-UK":
_local3.currency = "£";
_local3.group = ",";
_local3.decimal = ".";
_local3.before = true;
break;
case "es-MX":
_local3.currency = "$";
_local3.group = ",";
_local3.decimal = ".";
_local3.before = true;
break;
case "es-ES":
_local3.currency = "€";
_local3.group = ".";
_local3.decimal = ",";
_local3.before = false;
break;
case "fr":
_local3.currency = "€";
_local3.group = ".";
_local3.decimal = ",";
_local3.before = false;
break;
case "sv":
_local3.currency = "kr";
_local3.group = (_arg1) ? "," : " ";
_local3.decimal = ".";
_local3.before = false;
break;
case "jp":
_local3.currency = " 5";
_local3.group = ",";
_local3.decimal = ".";
_local3.before = true;
break;
case "nl":
_local3.currency = "€";
_local3.group = ".";
_local3.decimal = ",";
_local3.before = true;
break;
default:
_local3.currency = "€";
_local3.group = ".";
_local3.decimal = ",";
_local3.before = true;
break;
};
return (_local3);
}
public function format(_arg1:Number, _arg2:Object=null, _arg3:Object=null):String{
var _local4:String;
var _local10:Number;
var _local11:Number;
var _local12:String;
var _local13:Object;
var _local14:Locale;
var _local15:Locale;
var _local16:Number;
var _local17:Array;
var _local18:Array;
var _local19:Array;
var _local20:Number;
var _local21:Number;
var _local22:Boolean;
var _local23:Array;
var _local24:Number;
if (typeof(_arg2) == "number"){
_local11 = Number(_arg2);
_local4 = _arg1.toString(_local11);
_local12 = "";
if (_local11 == 16){
_local12 = "0x";
};
if (_local11 == 8){
_local12 = "0";
};
if (_arg3 != null){
_local12 = String(_arg3);
};
return ((_local12 + _local4.toUpperCase()));
};
var _local5 = ",";
var _local6 = ".";
if (((!((_arg2 == null))) && (_arg2.hasOwnProperty("group")))){
_local13 = _arg2;
} else {
_local14 = Locale(_arg2);
if (_local14 == null){
_local14 = new Locale();
};
_local15 = Locale(_local14);
_local13 = getSymbols(false, _local15);
};
_local5 = _local13.decimal;
_local6 = _local13.group;
var _local7:Array = String(_arg1).split(".");
var _local8:Array = _local7[0].split("");
var _local9:Array = ((_local7.length)>1) ? _local7[1].split("") : new Array();
if (_sMask == null){
_local16 = 1;
_local8.reverse();
_local10 = 0;
while (_local10 < _local8.length) {
if (_local16 > 3){
_local16 = 0;
_local8.splice(_local10, 0, _local6);
};
_local16++;
_local10++;
};
_local8.reverse();
_local4 = _local8.join("");
if (_local7[1] != null){
_local4 = (_local4 + (_local5 + _local7[1]));
};
} else {
_local17 = _sMask.split("");
_local10 = 0;
while (_local10 < _local17.length) {
if (((((!((_local17[_local10] == "0"))) && (!((_local17[_local10] == "#"))))) && (!((_local17[_local10] == "."))))){
_local17.splice(_local10, 1);
_local10--;
};
_local10++;
};
_local17 = _local17.join("").split(".");
_local18 = _local17[0].split("");
_local19 = ((_local17.length)>1) ? _local17[1].split("") : new Array();
_local16 = _local18.length;
_local20 = 0;
_local21 = 0;
_local4 = "";
if (_local16 < _local8.length){
_local10 = 0;
while (_local10 < (_local8.length - _local16)) {
_local4 = (_local4 + _local8[_local10]);
_local20++;
_local10++;
};
} else {
if (_local16 > _local8.length){
_local10 = 0;
while (_local10 < (_local16 - _local8.length)) {
if (_local18[_local10] == "0"){
_local4 = (_local4 + "0");
} else {
if (_local18[_local10] == "#"){
_local4 = (_local4 + " ");
};
};
_local21++;
_local10++;
};
};
};
_local22 = false;
_local10 = _local21;
while (_local10 < _local18.length) {
if ((((_local18[_local10] == "0")) || ((_local18[_local10] == "#")))){
_local4 = (_local4 + ((_local8[_local20])==undefined) ? "" : _local8[_local20]);
_local20++;
};
_local10++;
};
_local17 = _sMask.split(".");
_local17 = _local17[0].split("");
_local23 = _local4.split("");
_local22 = false;
_local10 = 0;
while (_local10 < _local17.length) {
if (((((!((_local17[_local10] == "0"))) && (!((_local17[_local10] == "#"))))) && (!((_local17[_local10] == "."))))){
if (_local22){
_local23.splice(_local10, 0, _local6);
} else {
_local23.splice(_local10, 0, " ");
};
};
if (((!((_local23[_local10] == " "))) && (!((_local23[_local10] == "0"))))){
_local22 = true;
};
_local10++;
};
_local4 = _local23.join("");
if (_local19.length > 0){
_local4 = (_local4 + _local5);
};
_local10 = 0;
while (_local10 < _local19.length) {
if (_local9[_local10] == null){
if (_local19[_local10] == "0"){
_local4 = (_local4 + "0");
} else {
if (_local19[_local10] == "#"){
_local4 = (_local4 + " ");
};
};
} else {
_local24 = Number(((_local9[_local10] + "") + _local9[(_local10 + 1)]));
if ((((_local10 == (_local19.length - 1))) && (!(isNaN(_local24))))){
_local4 = (_local4 + String(Math.round((_local24 / 10))));
} else {
_local4 = (_local4 + _local9[_local10]);
};
};
_local10++;
};
};
return (_local4);
}
public function set mask(_arg1:String):void{
_sMask = _arg1;
}
public function currencyFormat(_arg1:Number, _arg2:Object=null):String{
var _local5:Object;
var _local16:Number;
var _local4:Locale = ((arguments[1] is Locale)) ? arguments[1] : new Locale();
if (((!((_arg2 == null))) && (_arg2.hasOwnProperty("group")))){
_local5 = _arg2;
} else {
_local5 = getSymbols(true, _local4);
};
var _local6:String = _local5.currency;
var _local7:String = _local5.group;
var _local8:String = _local5.decimal;
var _local9:String = _sMask;
_sMask = null;
var _local10:Locale = new Locale();
_local10.language = "en";
_local10.variant = "US";
var _local11:String = format(_arg1, _local10);
_sMask = _local9;
var _local12:Array = _local11.split(".");
if (_local12[1] == undefined){
_local12[1] = "00";
} else {
_local12[1] = Number(_local12[1]);
_local16 = String(_local12[1]).length;
if (_local16 > 2){
_local12[1] = (_local12[1] / Math.pow(10, (_local16 - 2)));
_local12[1] = Math.round(_local12[1]);
};
};
_local11 = _local12.join(".");
var _local13:Array = _local11.split("");
var _local14:Number = 0;
while (_local14 < _local13.length) {
if (_local13[_local14] == ","){
_local13[_local14] = _local7;
} else {
if (_local13[_local14] == "."){
_local13[_local14] = _local8;
};
};
_local14++;
};
var _local15:String = (((_local5.before) ? _local6 : "" + _local13.join("")) + (_local5.before) ? "" : _local6);
return (_local15);
}
public function get mask():String{
return (_sMask);
}
}
}//package ascb.util
Section 6
//NumberUtilities (ascb.util.NumberUtilities)
package ascb.util {
public class NumberUtilities {
private static var _aUniqueIDs:Array;
public static function random(_arg1:Number, _arg2:Number=0, _arg3:Number=1):Number{
var _local6:Number;
if (_arg1 > _arg2){
_local6 = _arg1;
_arg1 = _arg2;
_arg2 = _local6;
};
var _local4:Number = ((_arg2 - _arg1) + (1 * _arg3));
var _local5:Number = (Math.random() * _local4);
_local5 = (_local5 + _arg1);
return (floor(_local5, _arg3));
}
public static function ceil(_arg1:Number, _arg2:Number=1):Number{
return ((Math.ceil((_arg1 / _arg2)) * _arg2));
}
public static function getUnique():Number{
if (_aUniqueIDs == null){
_aUniqueIDs = new Array();
};
var _local1:Date = new Date();
var _local2:Number = _local1.getTime();
while (!(isUnique(_local2))) {
_local2 = (_local2 + NumberUtilities.random(_local1.getTime(), (2 * _local1.getTime())));
};
_aUniqueIDs.push(_local2);
return (_local2);
}
private static function isUnique(_arg1:Number):Boolean{
var _local2:Number = 0;
while (_local2 < _aUniqueIDs.length) {
if (_aUniqueIDs[_local2] == _arg1){
return (false);
};
_local2++;
};
return (true);
}
public static function floor(_arg1:Number, _arg2:Number=1):Number{
return ((Math.floor((_arg1 / _arg2)) * _arg2));
}
public static function round(_arg1:Number, _arg2:Number=1):Number{
return ((Math.round((_arg1 / _arg2)) * _arg2));
}
}
}//package ascb.util
Section 7
//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 8
//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 9
//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 10
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 11
//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 12
//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 13
//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 14
//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 15
//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 16
//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 17
//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 18
//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 19
//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 20
//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 21
//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 22
//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 23
//b2DynamicTreePair (Box2D.Collision.b2DynamicTreePair)
package Box2D.Collision {
public class b2DynamicTreePair {
public var proxyA:b2DynamicTreeNode;
public var proxyB:b2DynamicTreeNode;
}
}//package Box2D.Collision
Section 24
//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 25
//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 26
//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 27
//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 28
//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 29
//b2SeparationFunction (Box2D.Collision.b2SeparationFunction)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
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 30
//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 31
//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 32
//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 33
//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 34
//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 35
//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 36
//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 37
//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 38
//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 39
//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 40
//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 41
//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 42
//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 43
//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 44
//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 45
//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 46
//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 47
//b2internal (Box2D.Common.b2internal)
package Box2D.Common {
public namespace b2internal = "http://www.box2d.org/ns/b2internal";
}//package Box2D.Common
Section 48
//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 49
//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 50
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 51
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 52
//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 53
//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 54
//b2ContactFactory (Box2D.Dynamics.Contacts.b2ContactFactory)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 55
//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 56
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 57
//b2EdgeAndCircleContact (Box2D.Dynamics.Contacts.b2EdgeAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 58
//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 59
//b2PolyAndEdgeContact (Box2D.Dynamics.Contacts.b2PolyAndEdgeContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 60
//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 61
//b2PositionSolverManifold (Box2D.Dynamics.Contacts.b2PositionSolverManifold)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 62
//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 63
//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 64
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 65
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 66
//b2FrictionJoint (Box2D.Dynamics.Joints.b2FrictionJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 67
//b2FrictionJointDef (Box2D.Dynamics.Joints.b2FrictionJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 68
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 69
//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 70
//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 71
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 72
//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 73
//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 74
//b2LineJoint (Box2D.Dynamics.Joints.b2LineJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 75
//b2LineJointDef (Box2D.Dynamics.Joints.b2LineJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 76
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 77
//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 78
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 79
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 80
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 81
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 82
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 83
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 84
//b2WeldJoint (Box2D.Dynamics.Joints.b2WeldJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 85
//b2WeldJointDef (Box2D.Dynamics.Joints.b2WeldJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
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 86
//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 87
//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 88
//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 89
//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 90
//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 91
//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 92
//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 93
//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 94
//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 95
//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 96
//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 97
//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 98
//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 99
//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 100
//FRateLimiter (Box2D.General.FRateLimiter)
package Box2D.General {
import flash.utils.*;
public class FRateLimiter {
private static var newT:uint = oldT;
private static var oldT:uint = getTimer();
public static function limitFrame(_arg1:uint):void{
var _local2:uint = (1000 / _arg1);
while (Math.abs((newT - oldT)) < _local2) {
newT = getTimer();
};
oldT = getTimer();
}
}
}//package Box2D.General
Section 101
//Input (Box2D.General.Input)
package Box2D.General {
import flash.events.*;
import flash.display.*;
public class Input {
public static var mouseOffsetX:Number = 0;
private static var keyArr:Array;
public static var mouseDragX:Number = 0;
public static var mouseDragY:Number = 0;
public static var mouseOffsetY:Number = 0;
public static var ascii:Array;
public static var mouseX:Number = 0;
public static var mouseY:Number = 0;
public static var mouseOver:Boolean = false;
private static var bufferSize:int;
public static var mouse:Sprite = new Sprite();
public static var mouseDown:Boolean = false;
public static var mouseReleased:Boolean = false;
public static var lastKey:int = 0;
public static var m_stageMc:Sprite;
private static var keyState:Array;
public static var timeSinceLastKey:Number = 0;
public static var mousePressed:Boolean = false;
private static var keyBuffer:Array;
public function Input(_arg1:Sprite){
m_stageMc = _arg1;
ascii = new Array(222);
fillAscii();
keyState = new Array(222);
keyArr = new Array();
var _local2:int;
while (_local2 < 222) {
keyState[_local2] = new int(0);
if (ascii[_local2] != undefined){
keyArr.push(_local2);
};
_local2++;
};
bufferSize = 5;
keyBuffer = new Array(bufferSize);
var _local3:int;
while (_local3 < bufferSize) {
keyBuffer[_local3] = new Array(0, 0);
_local3++;
};
_arg1.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPress, false, 0, true);
_arg1.stage.addEventListener(KeyboardEvent.KEY_UP, keyRelease, false, 0, true);
_arg1.stage.addEventListener(MouseEvent.MOUSE_DOWN, mousePress, false, 0, true);
_arg1.stage.addEventListener(MouseEvent.CLICK, mouseRelease, false, 0, true);
_arg1.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove, false, 0, true);
_arg1.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeave, false, 0, true);
mouse.graphics.lineStyle(0.1, 0, 100);
mouse.graphics.moveTo(0, 0);
mouse.graphics.lineTo(0, 0.1);
}
public function mouseLeave(_arg1:Event):void{
mouseReleased = mouseDown;
mouseDown = false;
}
public function keyPress(_arg1:KeyboardEvent):void{
keyState[_arg1.keyCode] = Math.max(keyState[_arg1.keyCode], 1);
lastKey = _arg1.keyCode;
}
private function fillAscii():void{
ascii[65] = "A";
ascii[66] = "B";
ascii[67] = "C";
ascii[68] = "D";
ascii[69] = "E";
ascii[70] = "F";
ascii[71] = "G";
ascii[72] = "H";
ascii[73] = "I";
ascii[74] = "J";
ascii[75] = "K";
ascii[76] = "L";
ascii[77] = "M";
ascii[78] = "N";
ascii[79] = "O";
ascii[80] = "P";
ascii[81] = "Q";
ascii[82] = "R";
ascii[83] = "S";
ascii[84] = "T";
ascii[85] = "U";
ascii[86] = "V";
ascii[87] = "W";
ascii[88] = "X";
ascii[89] = "Y";
ascii[90] = "Z";
ascii[48] = "0";
ascii[49] = "1";
ascii[50] = "2";
ascii[51] = "3";
ascii[52] = "4";
ascii[53] = "5";
ascii[54] = "6";
ascii[55] = "7";
ascii[56] = "8";
ascii[57] = "9";
ascii[32] = "Spacebar";
ascii[17] = "Ctrl";
ascii[16] = "Shift";
ascii[192] = "~";
ascii[38] = "up";
ascii[40] = "down";
ascii[37] = "left";
ascii[39] = "right";
ascii[96] = "Numpad 0";
ascii[97] = "Numpad 1";
ascii[98] = "Numpad 2";
ascii[99] = "Numpad 3";
ascii[100] = "Numpad 4";
ascii[101] = "Numpad 5";
ascii[102] = "Numpad 6";
ascii[103] = "Numpad 7";
ascii[104] = "Numpad 8";
ascii[105] = "Numpad 9";
ascii[111] = "Numpad /";
ascii[106] = "Numpad *";
ascii[109] = "Numpad -";
ascii[107] = "Numpad +";
ascii[110] = "Numpad .";
ascii[45] = "Insert";
ascii[46] = "Delete";
ascii[33] = "Page Up";
ascii[34] = "Page Down";
ascii[35] = "End";
ascii[36] = "Home";
ascii[112] = "F1";
ascii[113] = "F2";
ascii[114] = "F3";
ascii[115] = "F4";
ascii[116] = "F5";
ascii[117] = "F6";
ascii[118] = "F7";
ascii[119] = "F8";
ascii[188] = ",";
ascii[190] = ".";
ascii[186] = ";";
ascii[222] = "'";
ascii[219] = "[";
ascii[221] = "]";
ascii[189] = "-";
ascii[187] = "+";
ascii[220] = "\\";
ascii[191] = "/";
ascii[9] = "TAB";
ascii[8] = "Backspace";
}
public function mouseMove(_arg1:MouseEvent):void{
if (mouseDown != _arg1.buttonDown){
mouseDown = _arg1.buttonDown;
mouseReleased = !(_arg1.buttonDown);
mousePressed = _arg1.buttonDown;
mouseDragX = 0;
mouseDragY = 0;
};
mouseX = (_arg1.stageX - m_stageMc.x);
mouseY = (_arg1.stageY - m_stageMc.y);
mouseOffsetX = (mouseX - mouse.x);
mouseOffsetY = (mouseY - mouse.y);
if (mouseDown){
mouseDragX = (mouseDragX + mouseOffsetX);
mouseDragY = (mouseDragY + mouseOffsetY);
};
mouse.x = mouseX;
mouse.y = mouseY;
}
public function keyRelease(_arg1:KeyboardEvent):void{
keyState[_arg1.keyCode] = -1;
var _local2:int = (bufferSize - 1);
while (_local2 > 0) {
keyBuffer[_local2] = keyBuffer[(_local2 - 1)];
_local2--;
};
keyBuffer[0] = [_arg1.keyCode, 0];
}
public function mouseRelease(_arg1:MouseEvent):void{
mouseDown = false;
mouseReleased = true;
}
public function mousePress(_arg1:MouseEvent):void{
mousePressed = true;
mouseDown = true;
mouseDragX = 0;
mouseDragY = 0;
}
public static function getKeyHold(_arg1:int):int{
return (Math.max(0, keyState[_arg1]));
}
public static function update():void{
var _local1:int;
while (_local1 < keyArr.length) {
if (keyState[keyArr[_local1]] != 0){
var _local3 = keyState;
var _local4 = keyArr[_local1];
var _local5 = (_local3[_local4] + 1);
_local3[_local4] = _local5;
};
_local1++;
};
var _local2:int;
while (_local2 < bufferSize) {
_local3 = keyBuffer[_local2];
_local4 = 1;
_local5 = (_local3[_local4] + 1);
_local3[_local4] = _local5;
_local2++;
};
mouseReleased = false;
mousePressed = false;
mouseOver = false;
}
public static function isKeyPressed(_arg1:int):Boolean{
timeSinceLastKey = 0;
return ((keyState[_arg1] == 1));
}
public static function isKeyDown(_arg1:int):Boolean{
return ((keyState[_arg1] > 0));
}
public static function getKeyString(_arg1:uint):String{
return (ascii[_arg1]);
}
public static function isKeyReleased(_arg1:int):Boolean{
return ((keyState[_arg1] == -1));
}
public static function isKeyInBuffer(_arg1:int, _arg2:int, _arg3:int):Boolean{
return ((((keyBuffer[_arg2][0] == _arg1)) && ((keyBuffer[_arg2][1] <= _arg3))));
}
}
}//package Box2D.General
Section 102
//GrahamScan (couk.psyked.box2d.utils.GrahamScan)
package couk.psyked.box2d.utils {
import flash.geom.*;
public class GrahamScan {
public function convexHull(_arg1:Array):Array{
return (findHull(order(_arg1)));
}
public function findHull(_arg1:Array):Array{
var _local2:int = _arg1.length;
var _local3:Array = new Array();
_local3.push(_arg1[0]);
_local3.push(_arg1[1]);
var _local4 = 2;
while (_local4 < _local2) {
while (direction(_local3[(_local3.length - 2)], _local3[(_local3.length - 1)], _arg1[_local4]) > 0) {
_local3.pop();
};
_local3.push(_arg1[_local4]);
_local4++;
};
return (_local3);
}
public function order(_arg1:Array):Array{
var _local4:int;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local2:Point = _arg1[0];
var _local3:int = _arg1.length;
_local4 = 0;
while (_local4 < _local3) {
if (_arg1[_local4].y < _local2.y){
_local2 = _arg1[_local4];
} else {
if ((((_arg1[_local4].y == _local2.y)) && ((_arg1[_local4].x < _local2.x)))){
_local2 = _arg1[_local4];
};
};
_local4++;
};
var _local5:Array = new Array();
var _local6:Array = new Array();
var _local7:Array = new Array();
_local4 = 0;
while (_local4 < _local3) {
_local9 = (_arg1[_local4].x - _local2.x);
_local10 = (_arg1[_local4].y - _local2.y);
_local11 = (_local10 / _local9);
if (_local11 < 0){
_local7.push({point:_arg1[_local4], cotangent:_local11});
} else {
_local6.push({point:_arg1[_local4], cotangent:_local11});
};
_local4++;
};
_local6.sortOn("cotangent", (Array.NUMERIC | Array.DESCENDING));
_local7.sortOn("cotangent", (Array.NUMERIC | Array.DESCENDING));
_local5 = _local7.concat(_local6);
var _local8:Array = new Array();
_local8.push(_local2);
_local4 = 0;
while (_local4 < _local3) {
if (_local2 == _local5[_local4].point){
} else {
_local8.push(_local5[_local4].point);
};
_local4++;
};
return (_local8);
}
private function direction(_arg1:Point, _arg2:Point, _arg3:Point):Number{
return ((((_arg2.x - _arg1.x) * (_arg3.y - _arg1.y)) - ((_arg2.y - _arg1.y) * (_arg3.x - _arg1.x))));
}
}
}//package couk.psyked.box2d.utils
Section 103
//PolygonTool (couk.psyked.box2d.utils.PolygonTool)
package couk.psyked.box2d.utils {
public class PolygonTool {
public static function getConvexPoly(_arg1:Array):Array{
var _local2:GrahamScan = new GrahamScan();
return (_local2.convexHull(_arg1.slice(0)));
}
public static function isPolyClockwise(_arg1:Array):Boolean{
var _local2:int;
var _local3:int;
var _local4:int;
var _local6:Number;
var _local5:int;
if (_arg1.length < 3){
return (false);
};
_local2 = 0;
while (_local2 < _arg1.length) {
_local3 = ((_local2 + 1) % _arg1.length);
_local4 = ((_local2 + 2) % _arg1.length);
_local6 = ((_arg1[_local3].x - _arg1[_local2].x) * (_arg1[_local4].y - _arg1[_local3].y));
_local6 = (_local6 - ((_arg1[_local3].y - _arg1[_local2].y) * (_arg1[_local4].x - _arg1[_local3].x)));
if (_local6 < 0){
_local5--;
} else {
if (_local6 > 0){
_local5++;
};
};
_local2++;
};
if (_local5 > 0){
return (false);
};
if (_local5 < 0){
return (true);
};
return (false);
}
public static function isPolyConvex(_arg1:Array):Boolean{
var _local2:int;
var _local3:int;
var _local4:int;
var _local6:Number;
var _local5:int;
var _local7:int = _arg1.length;
if (_local7 < 3){
return (false);
};
_local2 = 0;
while (_local2 < _local7) {
_local3 = ((_local2 + 1) % _local7);
_local4 = ((_local2 + 2) % _local7);
_local6 = ((_arg1[_local3].x - _arg1[_local2].x) * (_arg1[_local4].y - _arg1[_local3].y));
_local6 = (_local6 - ((_arg1[_local3].y - _arg1[_local2].y) * (_arg1[_local4].x - _arg1[_local3].x)));
if (_local6 < 0){
_local5 = (_local5 | 1);
} else {
if (_local6 > 0){
_local5 = (_local5 | 2);
};
};
if (_local5 == 3){
return (false);
};
_local2++;
};
if (_local5 != 0){
return (true);
};
return (false);
}
public static function getTriangulatedPoly(_arg1:Array):Array{
var _local2:Triangulate = new Triangulate();
return (_local2.process(_arg1.slice(0)));
}
}
}//package couk.psyked.box2d.utils
Section 104
//Triangulate (couk.psyked.box2d.utils.Triangulate)
package couk.psyked.box2d.utils {
public class Triangulate {
private static var EPSILON:Number = 1E-10;
private function snip(_arg1:Array, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:Array):Boolean{
var _local7:int;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
_local8 = _arg1[_arg6[_arg2]].x;
_local9 = _arg1[_arg6[_arg2]].y;
_local10 = _arg1[_arg6[_arg3]].x;
_local11 = _arg1[_arg6[_arg3]].y;
_local12 = _arg1[_arg6[_arg4]].x;
_local13 = _arg1[_arg6[_arg4]].y;
if (EPSILON > (((_local10 - _local8) * (_local13 - _local9)) - ((_local11 - _local9) * (_local12 - _local8)))){
return (false);
};
_local7 = 0;
while (_local7 < _arg5) {
if ((((((_local7 == _arg2)) || ((_local7 == _arg3)))) || ((_local7 == _arg4)))){
} else {
_local14 = _arg1[_arg6[_local7]].x;
_local15 = _arg1[_arg6[_local7]].y;
if (insideTriangle(_local8, _local9, _local10, _local11, _local12, _local13, _local14, _local15)){
return (false);
};
};
_local7++;
};
return (true);
}
public function insideTriangle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number):Boolean{
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;
_local9 = (_arg5 - _arg3);
_local10 = (_arg6 - _arg4);
_local11 = (_arg1 - _arg5);
_local12 = (_arg2 - _arg6);
_local13 = (_arg3 - _arg1);
_local14 = (_arg4 - _arg2);
_local15 = (_arg7 - _arg1);
_local16 = (_arg8 - _arg2);
_local17 = (_arg7 - _arg3);
_local18 = (_arg8 - _arg4);
_local19 = (_arg7 - _arg5);
_local20 = (_arg8 - _arg6);
_local23 = ((_local9 * _local18) - (_local10 * _local17));
_local21 = ((_local13 * _local16) - (_local14 * _local15));
_local22 = ((_local11 * _local20) - (_local12 * _local19));
return ((((((_local23 >= 0)) && ((_local22 >= 0)))) && ((_local21 >= 0))));
}
public function area(_arg1:Array):Number{
var _local2:int = _arg1.length;
var _local3:Number = 0;
var _local4:int = (_local2 - 1);
var _local5:int;
while (_local5 < _local2) {
_local3 = (_local3 + ((_arg1[_local4].x * _arg1[_local5].y) - (_arg1[_local5].x * _arg1[_local4].y)));
var _temp1 = _local5;
_local5 = (_local5 + 1);
_local4 = _temp1;
};
return ((_local3 * 0.5));
}
public function process(_arg1:Array):Array{
var _local5:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:int;
var _local2:Array = new Array();
var _local3:int = _arg1.length;
if (_local3 < 3){
return (null);
};
var _local4:Array = new Array();
if (0 < area(_arg1)){
_local5 = 0;
while (_local5 < _local3) {
_local4[_local5] = _local5;
_local5++;
};
} else {
_local5 = 0;
while (_local5 < _local3) {
_local4[_local5] = ((_local3 - 1) - _local5);
_local5++;
};
};
var _local6:int = _local3;
var _local7:int = (2 * _local6);
_local8 = 0;
_local5 = (_local6 - 1);
while (_local6 > 2) {
var _temp1 = _local7;
_local7 = (_local7 - 1);
if (0 >= _temp1){
return (null);
};
_local9 = _local5;
if (_local6 <= _local9){
_local9 = 0;
};
_local5 = (_local9 + 1);
if (_local6 <= _local5){
_local5 = 0;
};
_local10 = (_local5 + 1);
if (_local6 <= _local10){
_local10 = 0;
};
if (snip(_arg1, _local9, _local5, _local10, _local6, _local4)){
_local11 = _local4[_local9];
_local12 = _local4[_local5];
_local13 = _local4[_local10];
_local2.push(_arg1[_local11]);
_local2.push(_arg1[_local12]);
_local2.push(_arg1[_local13]);
_local8++;
_local14 = _local5;
_local15 = (_local5 + 1);
while (_local15 < _local6) {
_local4[_local14] = _local4[_local15];
_local14++;
_local15++;
};
_local6--;
_local7 = (2 * _local6);
};
};
return (_local2);
}
}
}//package couk.psyked.box2d.utils
Section 105
//CMyContactListner (lib.Collision.CMyContactListner)
package lib.Collision {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import lib.*;
public class CMyContactListner extends b2ContactListener {
private var isContactWheel2:Boolean;// = true
private var isContactCart:Boolean;// = false
private var isContactWheel1:Boolean;// = true
private var isStar:Object;
private var isCrash:Boolean;// = false
public function CMyContactListner(){
isStar = {bool:false, num:-1};
super();
}
public function get isShapesCollied():Boolean{
return (isCrash);
}
override public function PreSolve(_arg1:b2Contact, _arg2:b2Manifold):void{
var _local3:b2Fixture = _arg1.GetFixtureA();
var _local4:b2Fixture = _arg1.GetFixtureB();
if (_local3.GetBody().GetUserData() == CGlobal.STAR){
isStar.bool = true;
isStar.num = parseInt(_local3.GetUserData());
_arg1.SetEnabled(false);
};
if (_local4.GetBody().GetUserData() == CGlobal.STAR){
isStar.bool = true;
isStar.num = parseInt(_local4.GetUserData());
_arg1.SetEnabled(false);
};
}
override public function EndContact(_arg1:b2Contact):void{
var _local2:b2Fixture = _arg1.GetFixtureA();
var _local3:b2Fixture = _arg1.GetFixtureB();
if ((((((_local3.GetUserData() == (CGlobal.WHEEL + "1"))) && ((_local2.GetBody().GetUserData() == CGlobal.GROUND)))) && (!((_local2.GetFilterData().groupIndex == _local3.GetFilterData().groupIndex))))){
isContactWheel1 = false;
};
if ((((((_local3.GetUserData() == (CGlobal.WHEEL + "2"))) || ((_local2.GetBody().GetUserData() == CGlobal.GROUND)))) && (!((_local2.GetFilterData().groupIndex == _local3.GetFilterData().groupIndex))))){
isContactWheel2 = false;
};
}
public function get isStarBring():Object{
return (isStar);
}
public function get ContactWheel1():Boolean{
return (isContactWheel1);
}
override public function BeginContact(_arg1:b2Contact):void{
var _local2:b2Fixture = _arg1.GetFixtureA();
var _local3:b2Fixture = _arg1.GetFixtureB();
if ((((((((((_local2.GetUserData() == CGlobal.BIKER)) || ((_local3.GetUserData() == CGlobal.BIKER)))) && (!((_local2.GetFilterData().groupIndex == _local3.GetFilterData().groupIndex))))) && (!((_local2.GetFilterData().groupIndex == -5))))) && (!((_local3.GetFilterData().groupIndex == -5))))){
isCrash = true;
};
if ((((((_local3.GetUserData() == (CGlobal.WHEEL + "1"))) && ((_local2.GetBody().GetUserData() == CGlobal.GROUND)))) && (!((_local2.GetFilterData().groupIndex == _local3.GetFilterData().groupIndex))))){
isContactWheel1 = true;
};
if ((((((_local3.GetUserData() == (CGlobal.WHEEL + "2"))) && ((_local2.GetBody().GetUserData() == CGlobal.GROUND)))) && (!((_local2.GetFilterData().groupIndex == _local3.GetFilterData().groupIndex))))){
isContactWheel2 = true;
};
}
public function get ContactWheel2():Boolean{
return (isContactWheel2);
}
}
}//package lib.Collision
Section 106
//CGroundBody (lib.GameObjects.CGroundBody)
package lib.GameObjects {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import lib.*;
import couk.psyked.box2d.utils.*;
import wumedia.vector.*;
public class CGroundBody {
private var body3:b2Body;
private var body:b2Body;
private var world:b2World;
public function CGroundBody(_arg1:b2World){
world = _arg1;
}
public function createComplexPolygon(_arg1:Number, _arg2:Number, _arg3:Array, _arg4:int=0):void{
if (_arg3.length < 3){
throw (new Error("Complex Polygons must have at least 3 points."));
};
if (CGlobal.numLevel == 0){
};
var _local5:b2BodyDef = new b2BodyDef();
_local5.position.Set(_arg1, _arg2);
_local5.linearDamping = 0;
_local5.angularDamping = 0.1;
body3 = world.CreateBody(_local5);
body3.SetAngle(((_arg4 % 360) * (Math.PI / 180)));
body3.SetUserData(CGlobal.GROUND);
makeComplexBody(body3, _arg3);
}
public function createPolyFromLibraryShape(_arg1:int, _arg2:int, _arg3:String, _arg4:int=0):void{
var _local6:Array;
var _local7:int;
var _local8:Number;
var _local9:Number;
VectorShapes.extractFromLibrary(new UrbanStunts.Resources(), [_arg3]);
var _local5:Array = VectorShapes.getPoints(_arg3, 1);
if (_local5){
_local6 = PolygonTool.getTriangulatedPoly(_local5);
if (_local6 == null){
_local6 = PolygonTool.getConvexPoly(_local5);
};
_local7 = 0;
while (_local7 < _local6.length) {
_local8 = (int((_local6[_local7].x * 1000)) / 1000);
_local9 = (int((_local6[_local7].y * 1000)) / 1000);
trace((((((("\t\t<Item Id=\"" + String((_local7 + 1))) + "\" x=\"") + _local8) + "\" y=\"") + _local9) + "\"/>"));
_local7++;
};
};
}
function makeComplexBody(_arg1:b2Body, _arg2:Array):void{
var _local5:int;
var _local6:Array;
var _local7:b2PolygonShape;
var _local8:b2FixtureDef;
var _local3:int = int((_arg2.length / 3));
var _local4:int;
while (_local4 < _local3) {
_local5 = (_local4 * 3);
_local6 = new Array();
_local6[0] = new b2Vec2((_arg2[_local5].x / CGame.DRAW_SCALE), (_arg2[_local5].y / CGame.DRAW_SCALE));
_local6[1] = new b2Vec2((_arg2[(_local5 + 1)].x / CGame.DRAW_SCALE), (_arg2[(_local5 + 1)].y / CGame.DRAW_SCALE));
_local6[2] = new b2Vec2((_arg2[(_local5 + 2)].x / CGame.DRAW_SCALE), (_arg2[(_local5 + 2)].y / CGame.DRAW_SCALE));
_local7 = new b2PolygonShape();
_local7.SetAsArray(_local6, 3);
_local8 = new b2FixtureDef();
_local8.shape = _local7;
_local8.density = 1;
_local8.friction = 1;
_local8.filter.groupIndex = -2;
_arg1.CreateFixture(_local8);
_local4++;
};
_arg1.CreateFixture(_local8);
}
}
}//package lib.GameObjects
Section 107
//CStars (lib.GameObjects.CStars)
package lib.GameObjects {
import flash.display.*;
import VX.UI.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import lib.*;
public class CStars extends CModule {
private const numKillFrame:int = 70;
private const star_offset_x:int = 23;
private const star_offset_y:int = 25;
private const starSrc:String = "BonusStar";
private const levelId:int;
private var bodies:Array;
private var bikeX:Number;
private var world:b2World;
private var scr:Object;
private var Level:Object;
public static var visibleAll:Boolean = true;
public function CStars(_arg1:b2World, _arg2, _arg3, _arg4){
levelId = CGlobal.numLevel;
Level = CGlobal.LevelsParam[levelId];
bodies = new Array();
super();
world = _arg1;
scr = {x:_arg2, y:_arg3};
bikeX = _arg4;
}
public function RemoveStar(_arg1:int):void{
CStars.visibleAll = false;
if (((bodies[_arg1]) && (bodies[_arg1].mc))){
Level.Stars[_arg1].isShow = false;
CGlobal.numPickStars++;
bodies[_arg1].mc.gotoAndStop(numKillFrame);
bodies[_arg1].mc.play();
if (bodies[_arg1].body){
world.DestroyBody(bodies[_arg1].body);
bodies[_arg1].body = null;
};
};
}
private function RestartVisibleStars():void{
CGlobal.numPickStars = 0;
var _local1:int;
while (_local1 < Level.Stars.length) {
Level.Stars[_local1].isShow = true;
_local1++;
};
}
override public function Update():void{
var _local1:int;
if (bodies){
_local1 = 0;
while (_local1 < bodies.length) {
if (((bodies[_local1]) && (bodies[_local1].mc))){
if (bodies[_local1].mc.currentFrame == bodies[_local1].mc.totalFrames){
bodies[_local1].mc.stop();
removeChild(bodies[_local1].mc);
bodies[_local1].mc = null;
} else {
if (bodies[_local1].mc.currentFrame == (numKillFrame - 1)){
bodies[_local1].mc.gotoAndStop(1);
bodies[_local1].mc.play();
};
};
};
_local1++;
};
};
}
private function VerifyCheckpoints():void{
CGlobal.numPickStars = 0;
var _local1:int;
while (_local1 < Level.Stars.length) {
if (Level.Stars[_local1].x > bikeX){
Level.Stars[_local1].isShow = true;
CGlobal.numPickStars++;
};
_local1++;
};
}
override public function Init():void{
var _local1:b2PolygonShape;
var _local5:b2Body;
_local1 = new b2PolygonShape();
var _local2:b2BodyDef = new b2BodyDef();
var _local3:b2FixtureDef = new b2FixtureDef();
if (CStars.visibleAll){
RestartVisibleStars();
} else {
VerifyCheckpoints();
};
var _local4:int;
while (_local4 < Level.Stars.length) {
if (Level.Stars[_local4].isShow){
_local2.position.Set(Level.Stars[_local4].x, Level.Stars[_local4].y);
_local2.userData = (new (CGlobal.Classes.GetClass(starSrc)) as MovieClip);
_local2.userData.name = String((CGlobal.STAR + _local4));
_local2.userData.x = ((scr.x + (_local2.position.x * CGame.DRAW_SCALE)) - star_offset_x);
_local2.userData.y = ((scr.y + (_local2.position.y * CGame.DRAW_SCALE)) - star_offset_y);
_local2.userData.play();
_local2.type = b2Body.b2_staticBody;
addChildAt(_local2.userData, 0);
_local1.SetAsBox(0.4, 0.4);
_local3.shape = _local1;
_local3.density = 0.01;
_local3.filter.groupIndex = -5;
_local3.userData = String(_local4);
_local5 = world.CreateBody(_local2);
_local5.CreateFixture(_local3);
_local5.SetUserData(CGlobal.STAR);
bodies[_local4] = new Object();
bodies[_local4].body = _local5;
bodies[_local4].mc = _local2.userData;
bodies[_local4].x = Number(_local2.position.x);
bodies[_local4].y = Number(_local2.position.y);
};
_local4++;
};
}
public function UpdateStars(_arg1:Object):void{
var _local2:int;
while (_local2 < bodies.length) {
if (((bodies[_local2]) && (bodies[_local2].mc))){
bodies[_local2].mc.x = (((bodies[_local2].x * CGame.DRAW_SCALE) + _arg1.x) - star_offset_x);
bodies[_local2].mc.y = (((bodies[_local2].y * CGame.DRAW_SCALE) + _arg1.y) - star_offset_y);
};
_local2++;
};
}
override public function Remove():void{
var _local1:int;
while (_local1 < bodies.length) {
if (bodies[_local1]){
if (bodies[_local1].mc){
removeChild(bodies[_local1].mc);
bodies[_local1].mc = null;
};
if (bodies[_local1].body){
world.DestroyBody(bodies[_local1].body);
bodies[_local1].body = null;
};
bodies[_local1] = null;
};
_local1++;
};
bodies = null;
}
}
}//package lib.GameObjects
Section 108
//CBikeProgress (lib.Hud.CBikeProgress)
package lib.Hud {
import flash.display.*;
import flash.utils.*;
import VX.UI.*;
public class CBikeProgress extends CModule {
public var MaxPos:int;
public function CBikeProgress(_arg1:MovieClip){
Ani = _arg1;
super();
}
override public function Init():void{
MaxPos = Ani.totalFrames;
}
override public function ProcessMessage(_arg1:int, _arg2:Object):int{
return (0);
}
public function RestoreProgress():void{
Ani.progress.gotoAndStop(MaxPos);
}
public function InitLevelValue(_arg1:Number, _arg2:Number):void{
var _local3:int = ((MaxPos * _arg1) / _arg2);
ChangeValueProgress(_local3);
}
public function ChangeValueProgress(_arg1:int):void{
Ani.gotoAndStop(_arg1);
}
}
}//package lib.Hud
Section 109
//CHud (lib.Hud.CHud)
package lib.Hud {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import VX.UI.*;
import ascb.util.*;
import lib.*;
import lib.GameObjects.*;
public class CHud extends CModule {
private const dotBarSrc:String = "checkPoint";
private const OverTurnSrc:String = "CheckOverTurn";
private const TryAgainSrc:String = "TryAgain";
private const timeDelay:int = 1000;
private const CheckPointSrc:String = "SavedCheckPoint";
private const levelId:int;
private const SEC_IN_MIN:int = 60;
private const srcHud:String = "Hud";
private var lastTime:int;// = 0
private var TryAgain:Sprite;
private var CheckPoint:Sprite;
private var Overturn:Sprite;
private var checkPoints:Array;
private var isShowCheckPoint:Boolean;// = false
private var isShowTryAgain:Boolean;// = false
private var Progress:CBikeProgress;
private var isShowOverTurn:Boolean;// = false
private var Level:Object;
private var levelTime:int;
private var playTimer:Timer;
private var numStars:int;
public static var length:Number;
public function CHud(){
checkPoints = new Array();
levelId = CGlobal.numLevel;
Level = CGlobal.LevelsParam[levelId];
playTimer = new Timer(1000);
super();
}
public function SetVisibleStars():void{
numStars = GetNumVisibleStars();
Ani.stars.text = String(numStars);
}
private function onBackMainWindow(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.SHOW_MAIN_WINDOW, {isGame:true});
}
private function onPlayTime(_arg1:TimerEvent):void{
CMain.levelTime = (CMain.levelTime - 1000);
if (CMain.levelTime >= 0){
Ani.times.text = DateFormat.formatMilliseconds(CMain.levelTime);
};
if (CMain.levelTime == 0){
playTimer.stop();
playTimer.removeEventListener(TimerEvent.TIMER, onPlayTime);
};
}
public function ShowTryAgain():void{
if (!isShowTryAgain){
if (((isShowCheckPoint) && (CheckPoint))){
CheckPoint.visible = false;
};
if (((isShowOverTurn) && (Overturn))){
Overturn.visible = false;
};
isShowTryAgain = true;
TryAgain = new (CGlobal.Classes.GetClass(TryAgainSrc));
Ani.addChild(TryAgain);
};
}
override public function Remove():void{
if (playTimer){
playTimer.stop();
playTimer.removeEventListener(TimerEvent.TIMER, onPlayTime);
};
CSounds.SoundManager.Reset();
Ani.volume.removeEventListener(MouseEvent.CLICK, onChangeVolume);
Ani.tryAgain.removeEventListener(MouseEvent.CLICK, onTryAgain);
Ani.back.removeEventListener(MouseEvent.CLICK, onBackMainWindow);
removeChild(Ani);
}
private function GetNumVisibleStars():int{
var _local1:int;
var _local2:int;
while (_local2 < Level.Stars.length) {
_local1 = (_local1 + (((Level.Stars[_local2].isShow) || (CStars.visibleAll))) ? 1 : 0);
_local2++;
};
return (_local1);
}
public function ShowOverTurn():void{
if (!isShowOverTurn){
isShowOverTurn = true;
Overturn = new (CGlobal.Classes.GetClass(OverTurnSrc));
Ani.addChild(Overturn);
};
}
override public function Init():void{
length = (Math.abs(Level.Bike.startX) + Math.abs(Level.Bike.finishX));
Ani = new (CGlobal.Classes.GetClass(srcHud));
Ani.volume.buttonMode = true;
Ani.volume.addEventListener(MouseEvent.CLICK, onChangeVolume, false, 0, true);
if (((CSounds.SoundManager.Mute) && (CSounds.MusicManager.Mute))){
Ani.volume.gotoAndStop(2);
} else {
Ani.volume.gotoAndStop(1);
};
Ani.levelName.text = ("Level " + String((levelId + 1)));
Ani.progress.gotoAndStop(1);
Progress = new CBikeProgress(Ani.progress);
Add(Progress);
InitCheckPoints();
Ani.times.text = DateFormat.formatMilliseconds(CMain.levelTime);
SetVisibleStars();
if ((CMain.levelTime - CGlobal.oneSec) > 0){
playTimer.addEventListener(TimerEvent.TIMER, onPlayTime, false, 0, true);
playTimer.start();
};
Ani.tryAgain.addEventListener(MouseEvent.CLICK, onTryAgain, false, 0, true);
Ani.back.addEventListener(MouseEvent.CLICK, onBackMainWindow, false, 0, true);
addChild(Ani);
}
public function InitCheckPoint(_arg1:Number):void{
if (CheckPoints(_arg1)){
if (((!(isShowCheckPoint)) && (!(isShowTryAgain)))){
isShowCheckPoint = true;
CheckPoint = new (CGlobal.Classes.GetClass(CheckPointSrc));
Ani.addChild(CheckPoint);
};
};
Progress.InitLevelValue((_arg1 - Level.Bike.startX), length);
}
public function InitCheckPoints():void{
var _local2:Sprite;
var _local3:Number;
var _local4:Number;
var _local1:int;
while (_local1 < Level.Checkpoints.length) {
_local2 = new (CGlobal.Classes.GetClass(dotBarSrc));
_local2.scaleX = (_local2.scaleY = 0.7);
_local3 = (Level.Checkpoints[_local1].x - Level.Bike.startX);
_local4 = ((Ani.progress.width * _local3) / length);
_local2.x = (Ani.progress.x + _local4);
_local2.y = (Ani.progress.y - 2);
Ani.addChild(_local2);
_local1++;
};
}
private function onChangeVolume(_arg1:MouseEvent):void{
if (CSounds.SoundManager.Mute){
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = false);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = false);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = false);
Ani.volume.gotoAndStop(1);
} else {
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = true);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = true);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = true);
Ani.volume.gotoAndStop(2);
};
}
private function onTryAgain(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.START_GAME, {isTry:true, isMusReset:false});
}
override public function Update():void{
if (isShowCheckPoint){
if (lastTime == 0){
lastTime = getTimer();
};
if ((getTimer() - lastTime) > timeDelay){
if (CheckPoint){
Ani.removeChild(CheckPoint);
CheckPoint = null;
isShowCheckPoint = false;
};
lastTime = 0;
};
};
if (isShowTryAgain){
if (lastTime == 0){
lastTime = getTimer();
};
if ((getTimer() - lastTime) > timeDelay){
if (TryAgain){
Ani.removeChild(TryAgain);
TryAgain = null;
isShowTryAgain = false;
};
lastTime = 0;
};
};
if (isShowOverTurn){
if (lastTime == 0){
lastTime = getTimer();
};
if ((getTimer() - lastTime) > (timeDelay / 2)){
if (Overturn){
Ani.removeChild(Overturn);
Overturn = null;
isShowOverTurn = false;
};
lastTime = 0;
};
};
}
private function CheckPoints(_arg1:Number):Boolean{
var _local2:int;
while (_local2 < Level.Checkpoints.length) {
if ((((_arg1 > Level.Checkpoints[_local2].x)) && ((CGlobal.numCheckPoint < _local2)))){
CGlobal.numCheckPoint = _local2;
return (true);
};
_local2++;
};
return (false);
}
}
}//package lib.Hud
Section 110
//CGameKeyboard (lib.Keyboard.CGameKeyboard)
package lib.Keyboard {
import VX.Input.*;
import flash.ui.*;
public class CGameKeyboard extends CKeyboard {
public var View:Boolean;
public var Jump:Boolean;
public var Restart:Boolean;
public var Pos:Boolean;
public var Nitro:Boolean;
public var Exit:Boolean;
override public function SetKey(_arg1:uint, _arg2:Boolean):Boolean{
var _local3:Boolean = super.SetKey(_arg1, _arg2);
if (!_local3){
switch (_arg1){
case 67:
if (View != _arg2){
View = _arg2;
return (true);
};
break;
case 68:
if (Jump != _arg2){
Jump = _arg2;
return (true);
};
break;
case 65:
if (Nitro != _arg2){
Nitro = _arg2;
return (true);
};
break;
case 82:
if (Restart != _arg2){
Restart = _arg2;
return (true);
};
break;
case 80:
if (Pos != _arg2){
Pos = _arg2;
return (true);
};
break;
case Keyboard.ESCAPE:
if (Exit != _arg2){
Exit = _arg2;
return (true);
};
break;
default:
break;
};
};
return (_local3);
}
override public function Reset():void{
super.Reset();
Nitro = false;
Jump = false;
Restart = false;
View = false;
Exit = false;
Pos = false;
}
override public function Read(_arg1:Object):void{
super.Read(_arg1);
Nitro = _arg1.Nitro;
Jump = _arg1.Jump;
Restart = _arg1.Restart;
View = _arg1.View;
Exit = _arg1.Exit;
Pos = _arg1.Pos;
}
override public function Write(_arg1:Object):void{
super.Write(_arg1);
_arg1.Nitro = Nitro;
_arg1.Jump = Jump;
_arg1.Restart = Restart;
_arg1.View = View;
_arg1.Exit = Exit;
_arg1.Pos = Pos;
}
}
}//package lib.Keyboard
Section 111
//CChooseBike (lib.Menu.CChooseBike)
package lib.Menu {
import flash.events.*;
import VX.UI.*;
import lib.*;
import flash.filters.*;
public class CChooseBike extends CModule {
private const srcBike:String = "ChooseBike";
private const sumBikes:int;
private const saturateMatrix:Array;
public function CChooseBike(){
sumBikes = CGlobal.Bikes.length;
saturateMatrix = [0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0, 0, 0, 1, 0];
super();
}
override public function Remove():void{
Ani.volume.removeEventListener(MouseEvent.CLICK, onChangeVolume);
Ani.StartGame.removeEventListener(MouseEvent.CLICK, onStartGame);
Ani.Back.removeEventListener(MouseEvent.CLICK, onBackMenu);
var _local1 = 1;
while (_local1 <= sumBikes) {
Ani[("bike_" + _local1)].removeEventListener(MouseEvent.CLICK, onChooseBike);
_local1++;
};
removeChild(Ani);
}
private function onChangeVolume(_arg1:MouseEvent):void{
if (CSounds.SoundManager.Mute){
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = false);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = false);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = false);
Ani.volume.gotoAndStop(1);
} else {
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = true);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = true);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = true);
Ani.volume.gotoAndStop(2);
};
}
private function onBackMenu(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.SHOW_MAIN_WINDOW, {isGame:false});
}
private function onStartGame(_arg1:MouseEvent):void{
if (CGlobal.ChoosedBike != -1){
doHide();
SendMessageExclude(CMessages.CHOOSE_LEVEL, null);
};
}
private function ShowStartBtn():void{
var _local1:Array = Ani.StartGame.filters;
Ani.StartGame.enabled = true;
_local1.pop();
Ani.StartGame.filters = _local1;
Ani.StartGame.addEventListener(MouseEvent.CLICK, onStartGame, false, 0, true);
}
private function CheckChooseBikes(_arg1:int):void{
if (_arg1 == 1){
Ani["bike_1"].gotoAndStop(2);
Ani["bike_2"].gotoAndStop(1);
} else {
Ani["bike_1"].gotoAndStop(1);
Ani["bike_2"].gotoAndStop(2);
};
}
private function HideStartBtn():void{
var _local1:ColorMatrixFilter = new ColorMatrixFilter(saturateMatrix);
Ani.StartGame.enabled = false;
var _local2:Array = Ani.StartGame.filters;
_local2.push(_local1);
Ani.StartGame.filters = _local2;
}
private function onChooseBike(_arg1:MouseEvent):void{
var _local2:String = _arg1.currentTarget.name;
var _local3:int = int(_local2.substr((_local2.length - 1), 1));
CheckChooseBikes(_local3);
CGlobal.ChoosedBike = (_local3 - 1);
ShowStartBtn();
}
override public function Init():void{
CGlobal.ChoosedBike = -1;
Ani = new (CGlobal.Classes.GetClass(srcBike));
Ani.volume.buttonMode = true;
Ani.volume.addEventListener(MouseEvent.CLICK, onChangeVolume, false, 0, true);
if (((CSounds.SoundManager.Mute) && (CSounds.MusicManager.Mute))){
Ani.volume.gotoAndStop(2);
} else {
Ani.volume.gotoAndStop(1);
};
Ani.Back.addEventListener(MouseEvent.CLICK, onBackMenu, false, 0, true);
var _local1 = 1;
while (_local1 <= sumBikes) {
Ani[("bike_" + _local1)].buttonMode = true;
Ani[("bike_" + _local1)].gotoAndStop(1);
Ani[("bike_" + _local1)].addEventListener(MouseEvent.CLICK, onChooseBike, false, 0, true);
_local1++;
};
HideStartBtn();
addChild(Ani);
}
}
}//package lib.Menu
Section 112
//CChooseLevel (lib.Menu.CChooseLevel)
package lib.Menu {
import flash.events.*;
import VX.UI.*;
import lib.*;
import VX.Utils.*;
import flash.filters.*;
public class CChooseLevel extends CModule {
private const levelName:String = "Level";
private const saturateMatrix:Array;
private const ChooseLevelSrc:String = "ChooseLevel";
private var Levels:Object;
public function CChooseLevel(){
Levels = new Object();
saturateMatrix = [0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0, 0, 0, 1, 0];
super();
}
private function CheckLockedLevels():void{
var _local1:int;
while (_local1 < CGlobal.LevelsParam.length) {
Ani[(levelName + _local1)].stop();
Ani[(levelName + _local1)].enabled = true;
Ani[(levelName + _local1)].buttonMode = false;
Ani[(levelName + _local1)].ellement.visible = false;
if (_local1 < (CGlobal.openLevel - 1)){
Ani[(levelName + _local1)].gotoAndStop(4);
Ani[(levelName + _local1)].enabled = false;
Ani[(levelName + _local1)].levelName.text = (_local1 + 1).toString();
} else {
if ((_local1 + 1) == CGlobal.openLevel){
Ani[(levelName + _local1)].gotoAndStop(2);
Ani[(levelName + _local1)].buttonMode = true;
Ani[(levelName + _local1)].ellement.visible = true;
Ani[(levelName + _local1)].ellement.addEventListener(MouseEvent.CLICK, onChooseLevel, false, 0, true);
} else {
Ani[(levelName + _local1)].gotoAndStop(3);
Ani[(levelName + _local1)].ellement.removeEventListener(MouseEvent.CLICK, onChooseLevel);
};
};
_local1++;
};
}
private function SetChoiseBorderPos(_arg1:int):void{
Ani.levelChoise.x = (Ani[(levelName + _arg1)].x - ((Ani.levelChoise.width - Ani[(levelName + _arg1)].width) / 2));
Ani.levelChoise.y = (Ani[(levelName + _arg1)].y - ((Ani.levelChoise.height - Ani[(levelName + _arg1)].height) / 2));
}
private function ShowStartBtn():void{
var _local1:Array = Ani.StartGame.filters;
Ani.StartGame.enabled = true;
_local1.pop();
Ani.StartGame.filters = _local1;
Ani.StartGame.addEventListener(MouseEvent.CLICK, onStartGame, false, 0, true);
}
private function onChangeVolume(_arg1:MouseEvent):void{
if (CSounds.SoundManager.Mute){
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = false);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = false);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = false);
Ani.volume.gotoAndStop(1);
} else {
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = true);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = true);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = true);
Ani.volume.gotoAndStop(2);
};
}
override public function Remove():void{
Ani.volume.removeEventListener(MouseEvent.CLICK, onChangeVolume);
Ani.StartGame.removeEventListener(MouseEvent.CLICK, onStartGame);
Ani.Back.removeEventListener(MouseEvent.CLICK, onBackMenu);
var _local1:int;
while (_local1 < CGlobal.LevelsParam.length) {
Ani[(levelName + _local1)].removeEventListener(MouseEvent.CLICK, onChooseLevel);
_local1++;
};
removeChild(Ani);
while (Ani.numChildren > 0) {
Ani.removeChildAt(0);
};
}
private function onBackMenu(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.SHOW_MAIN_WINDOW, {isGame:false});
}
private function onStartGame(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.START_GAME, {isTry:false, isMusReset:true});
}
override public function Init():void{
Ani = new (CGlobal.Classes.GetClass(ChooseLevelSrc));
Ani.volume.buttonMode = true;
Ani.volume.addEventListener(MouseEvent.CLICK, onChangeVolume, false, 0, true);
if (((CSounds.SoundManager.Mute) && (CSounds.MusicManager.Mute))){
Ani.volume.gotoAndStop(2);
} else {
Ani.volume.gotoAndStop(1);
};
Ani.Back.addEventListener(MouseEvent.CLICK, onBackMenu, false, 0, true);
HideStartBtn();
SetChoiseBorderPos(0);
CheckLockedLevels();
addChild(Ani);
}
private function HideStartBtn():void{
Ani.levelChoise.visible = false;
var _local1:ColorMatrixFilter = new ColorMatrixFilter(saturateMatrix);
Ani.StartGame.enabled = false;
var _local2:Array = Ani.StartGame.filters;
_local2.push(_local1);
Ani.StartGame.filters = _local2;
}
private function onChooseLevel(_arg1:MouseEvent):void{
var _local2:String = _arg1.target.parent.name;
var _local3:int = (CGlobal.numLevel = parseInt(CUtil.getNumber2(_local2, levelName)));
SetChoiseBorderPos(_local3);
if (!Ani.StartGame.enabled){
ShowStartBtn();
Ani.levelChoise.visible = true;
};
}
}
}//package lib.Menu
Section 113
//CCompleteLevel (lib.Menu.CCompleteLevel)
package lib.Menu {
import flash.events.*;
import VX.UI.*;
import ascb.util.*;
import lib.*;
import mochi.as3.*;
import flash.net.*;
public class CCompleteLevel extends CModule {
private const src:String = "CompleteLevel";
private const bikeId:int;
private const levelId:int;
private var Bike:Object;
private var Level:Object;
public function CCompleteLevel(){
levelId = CGlobal.numLevel;
Level = CGlobal.LevelsParam[levelId];
bikeId = CGlobal.ChoosedBike;
Bike = CGlobal.Bikes[bikeId];
super();
}
private function onBackMenu(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.SHOW_MAIN_WINDOW, {isGame:true});
}
override public function Remove():void{
Ani.volume.removeEventListener(MouseEvent.CLICK, onChangeVolume);
if (CGlobal.numLevel < (CGlobal.LevelsParam.length - 1)){
Ani.NextLevel.removeEventListener(MouseEvent.CLICK, onNextLevel);
} else {
Ani.BackMenu.removeEventListener(MouseEvent.CLICK, onBackMenu);
Ani.HighScores.removeEventListener(MouseEvent.CLICK, onHighScores);
Ani.MoreGames.removeEventListener(MouseEvent.CLICK, onMoreGames);
};
removeChild(Ani);
}
private function GetLostTime():int{
return (Math.floor((CMain.levelTime / CGlobal.oneSec)));
}
private function onHighScores(_arg1:MouseEvent):void{
var o:Object;
var boardID:String;
var e = _arg1;
if (CGlobal.score > 0){
o = {n:[6, 13, 13, 11, 6, 7, 6, 5, 6, 13, 15, 3, 10, 9, 0, 14], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:CGlobal.score});
};
CGlobal.score = 0;
}
private function onMoreGames(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(CGlobal.moreGames_link), "_blank");
}
override public function Init():void{
Ani = new (CGlobal.Classes.GetClass(src));
Ani.finish.gotoAndStop((CGlobal.ChoosedBike + 1));
var _local1:int = (CGlobal.numPickStars * CGlobal.scoreByStar);
Ani.starsScore.text = ((((CGlobal.numPickStars + " X ") + CGlobal.scoreByStar) + " = ") + _local1);
var _local2:int = (CGlobal.scoreByOverturn * CGlobal.numTurns);
Ani.numOverturns.text = ((((String(CGlobal.numTurns) + " X ") + CGlobal.scoreByOverturn) + " = ") + _local2);
var _local3:int = ((Level.Time[CGlobal.ChoosedBike] * CGlobal.oneSec) - CMain.levelTime);
Ani.levelTime.text = DateFormat.formatMilliseconds(_local3);
var _local4:int = GetLostTime();
var _local5:int = (_local4 * CGlobal.timeBonusOneSec);
Ani.bonusTime.text = ((((_local4 + "s X ") + CGlobal.timeBonusOneSec) + " = ") + _local5);
Ani.levelScoreName.text = (Bike.scoreText + ":");
var _local6:int = (((_local1 + _local5) + _local2) * Bike.scoreKoef);
Ani.levelScore.text = _local6.toString();
CGlobal.score = (CGlobal.score + _local6);
Ani.totalScore.text = CGlobal.score;
Ani.banner.addEventListener(MouseEvent.CLICK, onBanner, false, 0, true);
if (CGlobal.numLevel < (CGlobal.LevelsParam.length - 1)){
Ani.NextLevel.addEventListener(MouseEvent.CLICK, onNextLevel, false, 0, true);
Ani.BackMenu.visible = false;
Ani.BackMenu.enabled = false;
Ani.HighScores.visible = false;
Ani.HighScores.enabled = false;
Ani.MoreGames.visible = false;
Ani.MoreGames.enabled = false;
} else {
Ani.NextLevel.visible = false;
Ani.NextLevel.enabled = false;
Ani.BackMenu.addEventListener(MouseEvent.CLICK, onBackMenu, false, 0, true);
Ani.HighScores.addEventListener(MouseEvent.CLICK, onHighScores, false, 0, true);
Ani.MoreGames.addEventListener(MouseEvent.CLICK, onMoreGames, false, 0, true);
};
Ani.volume.buttonMode = true;
Ani.volume.addEventListener(MouseEvent.CLICK, onChangeVolume, false, 0, true);
if (((CSounds.SoundManager.Mute) && (CSounds.MusicManager.Mute))){
Ani.volume.gotoAndStop(2);
} else {
Ani.volume.gotoAndStop(1);
};
addChild(Ani);
}
private function onNextLevel(_arg1:MouseEvent):void{
doHide();
CGlobal.numLevel++;
SendMessageExclude(CMessages.START_GAME, {isTry:false, isMusReset:false});
}
private function onChangeVolume(_arg1:MouseEvent):void{
if (CSounds.SoundManager.Mute){
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = false);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = false);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = false);
Ani.volume.gotoAndStop(1);
} else {
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = true);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = true);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = true);
Ani.volume.gotoAndStop(2);
};
}
private function onBanner(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(CGlobal.stuntsGames_link), "_blank");
}
}
}//package lib.Menu
Section 114
//CGameOver (lib.Menu.CGameOver)
package lib.Menu {
import flash.events.*;
import VX.UI.*;
import lib.*;
public class CGameOver extends CModule {
private const src:String = "GameOver";
override public function Init():void{
Ani = new (CGlobal.Classes.GetClass(src));
Ani.tryAgain.addEventListener(MouseEvent.CLICK, onTryAgain, false, 0, true);
Ani.restart.addEventListener(MouseEvent.CLICK, onRestartGame, false, 0, true);
addChild(Ani);
}
private function onRestartGame(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.CHOOSE_BIKE, null);
}
private function onTryAgain(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.START_GAME, {isTry:true, isMusReset:true});
}
override public function Remove():void{
Ani.restart.removeEventListener(MouseEvent.CLICK, onRestartGame);
removeChild(Ani);
}
override public function ProcessMessage(_arg1:int, _arg2:Object):int{
return (0);
}
}
}//package lib.Menu
Section 115
//CIntstructions (lib.Menu.CIntstructions)
package lib.Menu {
import flash.events.*;
import VX.UI.*;
import lib.*;
public class CIntstructions extends CModule {
private const src:String = "Inctructions";
override public function Init():void{
Ani = new (CGlobal.Classes.GetClass(src));
Ani.volume.buttonMode = true;
Ani.volume.addEventListener(MouseEvent.CLICK, onChangeVolume, false, 0, true);
if (((CSounds.SoundManager.Mute) && (CSounds.MusicManager.Mute))){
Ani.volume.gotoAndStop(2);
} else {
Ani.volume.gotoAndStop(1);
};
Ani.StartGame.addEventListener(MouseEvent.CLICK, onStartGame, false, 0, true);
Ani.Back.addEventListener(MouseEvent.CLICK, onBack, false, 0, true);
addChild(Ani);
}
private function onStartGame(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.CHOOSE_BIKE, null);
RemoveSelf();
}
private function onBack(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.SHOW_MAIN_WINDOW, {isGame:false});
RemoveSelf();
}
private function onChangeVolume(_arg1:MouseEvent):void{
if (CSounds.SoundManager.Mute){
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = false);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = false);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = false);
Ani.volume.gotoAndStop(1);
} else {
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = true);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = true);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = true);
Ani.volume.gotoAndStop(2);
};
}
override public function Remove():void{
Ani.volume.removeEventListener(MouseEvent.CLICK, onChangeVolume);
Ani.StartGame.removeEventListener(MouseEvent.CLICK, onStartGame);
Ani.Back.removeEventListener(MouseEvent.CLICK, onBack);
removeChild(Ani);
}
}
}//package lib.Menu
Section 116
//CMainWindow (lib.Menu.CMainWindow)
package lib.Menu {
import flash.events.*;
import VX.UI.*;
import lib.*;
import mochi.as3.*;
import flash.net.*;
public class CMainWindow extends CModule {
private const src:String = "MainWindow";
private function onHighScores(_arg1:MouseEvent):void{
var e = _arg1;
var o:Object = {n:[6, 13, 13, 11, 6, 7, 6, 5, 6, 13, 15, 3, 10, 9, 0, 14], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
var boardID:String = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:CGlobal.score});
CGlobal.score = 0;
}
override public function Remove():void{
Ani.volume.removeEventListener(MouseEvent.CLICK, onChangeVolume);
Ani.StartGame.removeEventListener(MouseEvent.CLICK, onStartGame);
Ani.Instructions.removeEventListener(MouseEvent.CLICK, onInstructions);
Ani.HighScores.removeEventListener(MouseEvent.CLICK, onHighScores);
Ani.MoreGames.removeEventListener(MouseEvent.CLICK, onMoreGames);
Ani.banner.removeEventListener(MouseEvent.CLICK, onBanner);
removeChild(Ani);
}
private function onChangeVolume(_arg1:MouseEvent):void{
if (CSounds.SoundManager.Mute){
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = false);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = false);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = false);
Ani.volume.gotoAndStop(1);
} else {
CSounds.SoundManager.Paused = (CSounds.SoundManager.Mute = true);
CSounds.SoundManager2.Paused = (CSounds.SoundManager2.Mute = true);
CSounds.MusicManager.Paused = (CSounds.MusicManager.Mute = true);
Ani.volume.gotoAndStop(2);
};
}
private function onBanner(_arg1:MouseEvent):void{
var e = _arg1;
try {
navigateToURL(new URLRequest(CGlobal.games_link), "_blank");
} catch(e:Event) {
};
}
private function onMoreGames(_arg1:MouseEvent):void{
var e = _arg1;
try {
navigateToURL(new URLRequest(CGlobal.moreGames_link), "_blank");
} catch(e:Event) {
};
}
override public function doShow():void{
super.doShow();
if (((CSounds.SoundManager.Mute) && (CSounds.MusicManager.Mute))){
Ani.volume.gotoAndStop(2);
} else {
Ani.volume.gotoAndStop(1);
};
}
override public function Init():void{
Ani = new (CGlobal.Classes.GetClass(src));
Ani.volume.buttonMode = true;
Ani.volume.addEventListener(MouseEvent.CLICK, onChangeVolume, false, 0, true);
Ani.StartGame.addEventListener(MouseEvent.CLICK, onStartGame, false, 0, true);
Ani.Instructions.addEventListener(MouseEvent.CLICK, onInstructions, false, 0, true);
Ani.HighScores.addEventListener(MouseEvent.CLICK, onHighScores, false, 0, true);
Ani.MoreGames.addEventListener(MouseEvent.CLICK, onMoreGames, false, 0, true);
Ani.banner.addEventListener(MouseEvent.CLICK, onBanner, false, 0, true);
addChild(Ani);
doShow();
}
private function onStartGame(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.CHOOSE_BIKE, null);
}
override public function ProcessMessage(_arg1:int, _arg2:Object):int{
return (0);
}
private function onInstructions(_arg1:MouseEvent):void{
doHide();
SendMessageExclude(CMessages.SHOW_INSTR, null);
}
}
}//package lib.Menu
Section 117
//CGetDataXml (lib.Params.CGetDataXml)
package lib.Params {
import flash.geom.*;
import flash.xml.*;
import lib.*;
public class CGetDataXml {
public static function GetShapes(_arg1:XMLDocument):void{
var _local2:XMLNode;
var _local3:XMLNode;
var _local4:XMLNode;
var _local5:XMLNode;
var _local6:XMLNode;
var _local7:int;
var _local8:Object;
var _local9:int;
var _local10:Number;
var _local11:Number;
_local2 = _arg1.firstChild;
while (_local2) {
if (_local2.nodeName == "Levels"){
CGlobal.Shapes = new Array();
_local3 = _local2.firstChild;
while (_local3) {
if (_local3.nodeName == "Level"){
_local7 = int(_local3.attributes.Id);
_local8 = new Object();
_local8.x = Number(_local3.attributes.x);
_local8.y = Number(_local3.attributes.y);
_local8.rotation = Number(_local3.attributes.rotation);
_local8.Points = new Array();
_local4 = _local3.firstChild;
while (_local4) {
if (_local4.nodeName == "Item"){
_local9 = (int(_local4.attributes.Id) - 1);
_local10 = Number(_local4.attributes.x);
_local11 = Number(_local4.attributes.y);
_local8.Points[_local9] = new Point(_local10, _local11);
};
_local4 = _local4.nextSibling;
};
CGlobal.Shapes[_local7] = _local8;
};
_local3 = _local3.nextSibling;
};
};
_local2 = _local2.nextSibling;
};
}
public static function GetBikesOptions(_arg1:XMLDocument):void{
var _local2:XMLNode;
var _local3:XMLNode;
var _local4:XMLNode;
var _local5:XMLNode;
var _local6:XMLNode;
var _local7:int;
var _local8:Number;
_local2 = _arg1.firstChild;
while (_local2) {
if (_local2.nodeName == "Bikes"){
_local3 = _local2.firstChild;
while (_local3) {
if (_local3.nodeName == "Item"){
_local7 = (int(_local3.attributes.Id) - 1);
CGlobal.Bikes[_local7].speed = Number(_local3.attributes.speed);
_local8 = Number(_local3.attributes.massKoef);
CGlobal.Bikes[_local7].Body.density = (CGlobal.Bikes[_local7].Body.density * _local8);
CGlobal.Bikes[_local7].Engine.density = (CGlobal.Bikes[_local7].Engine.density * _local8);
CGlobal.Bikes[_local7].Head.density = (CGlobal.Bikes[_local7].Head.density * _local8);
CGlobal.Bikes[_local7].Axles[0].density = (CGlobal.Bikes[_local7].Axles[0].density * _local8);
CGlobal.Bikes[_local7].Axles[1].density = (CGlobal.Bikes[_local7].Axles[1].density * _local8);
CGlobal.Bikes[_local7].Wheels[0].density = (CGlobal.Bikes[_local7].Wheels[0].density * _local8);
CGlobal.Bikes[_local7].Wheels[1].density = (CGlobal.Bikes[_local7].Wheels[1].density * _local8);
};
_local3 = _local3.nextSibling;
};
_local2 = _local2.nextSibling;
};
};
}
public static function GetGameOptions(_arg1:XMLDocument):void{
var _local2:XMLNode;
var _local3:XMLNode;
var _local4:XMLNode;
var _local5:XMLNode;
var _local6:XMLNode;
var _local7:int;
var _local8:Object;
var _local9:int;
var _local10:Object;
var _local11:int;
var _local12:Object;
var _local13:int;
var _local14:int;
var _local15:Object;
var _local16:int;
var _local17:Object;
_local2 = _arg1.firstChild;
while (_local2) {
if (_local2.nodeName == "UrbanStunts"){
CGlobal.alpha = Number(_local2.attributes.alpha);
_local3 = _local2.firstChild;
while (_local3) {
if (_local3.nodeName == "Debug"){
CGlobal.Debug = ((_local3.attributes.value)=="true") ? true : false;
CGlobal.bikeVisible = ((_local3.attributes.bikeVisible)=="true") ? true : false;
CGlobal.ChoosedBike = (int(_local3.attributes.bikeId) - 1);
CGlobal.numLevel = int(_local3.attributes.levelId);
CGlobal.isCreatePolygon = ((_local3.attributes.isCreatePolygon)=="true") ? true : false;
} else {
if (_local3.nodeName == "Game"){
CGlobal.finishPause = int(_local3.attributes.finishPause);
CGlobal.crashPause = int(_local3.attributes.crashPause);
} else {
if (_local3.nodeName == "Bikes"){
CGlobal.FreeFallKoef = Number(_local3.attributes.freeFallKoef);
CGlobal.TimeStamp = int(_local3.attributes.timeStamp);
CGlobal.DrawScale = int(_local3.attributes.drawScale);
CGlobal.Iterations = int(_local3.attributes.iterations);
_local4 = _local3.firstChild;
while (_local4) {
if (_local4.nodeName == "Bike"){
_local7 = (int(_local4.attributes.Id) - 1);
_local8 = new Object();
_local8.speed = Number(_local4.attributes.speed);
_local8.control = Number(_local4.attributes.control);
_local8.breakStep = Number(_local4.attributes.breakStep);
_local8.scoreKoef = Number(_local4.attributes.scoreKoef);
_local8.scoreText = _local4.attributes.scoreText;
_local5 = _local4.firstChild;
while (_local5) {
if (_local5.nodeName == "Body"){
_local8.Body = new Object();
_local8.Body.density = Number(_local5.attributes.weight);
_local8.Body.friction = Number(_local5.attributes.friction);
_local8.Body.restitution = Number(_local5.attributes.restitution);
} else {
if (_local5.nodeName == "Axles"){
_local8.Axles = new Array();
_local6 = _local5.firstChild;
while (_local6) {
if (_local6.nodeName == "Axle"){
_local9 = (int(_local6.attributes.Id) - 1);
_local10 = new Object();
_local10.x = Number(_local6.attributes.x);
_local10.density = Number(_local6.attributes.weight);
_local8.Axles[_local9] = _local10;
};
_local6 = _local6.nextSibling;
};
} else {
if (_local5.nodeName == "Wheels"){
_local8.Wheels = new Array();
_local6 = _local5.firstChild;
while (_local6) {
if (_local6.nodeName == "Wheel"){
_local11 = (int(_local6.attributes.Id) - 1);
_local12 = new Object();
_local12.radius = Number(_local6.attributes.radius);
_local12.density = Number(_local6.attributes.weight);
_local12.friction = Number(_local6.attributes.friction);
_local12.restitution = Number(_local6.attributes.restitution);
_local12.scale = Number(_local6.attributes.scale);
_local8.Wheels[_local11] = _local12;
};
_local6 = _local6.nextSibling;
};
} else {
if (_local5.nodeName == "Biker"){
_local8.Head = new Object();
_local8.Head.density = Number(_local5.attributes.weight);
_local8.Head.width = Number(_local5.attributes.width);
_local8.Head.height = Number(_local5.attributes.height);
_local8.Head.x = Number(_local5.attributes.x);
_local8.Head.y = Number(_local5.attributes.y);
} else {
if (_local5.nodeName == "Engine"){
_local8.Engine = new Object();
_local8.Engine.density = Number(_local5.attributes.weight);
_local8.Engine.width = Number(_local5.attributes.width);
_local8.Engine.height = Number(_local5.attributes.height);
_local8.Engine.x = Number(_local5.attributes.x);
_local8.Engine.y = Number(_local5.attributes.y);
};
};
};
};
};
_local5 = _local5.nextSibling;
};
CGlobal.Bikes[_local7] = _local8;
};
_local4 = _local4.nextSibling;
};
} else {
if (_local3.nodeName == "Scores"){
CGlobal.timeBonusOneSec = int(_local3.attributes.bonusByOneSec);
CGlobal.scoreByStar = int(_local3.attributes.byStar);
CGlobal.scoreByOverturn = int(_local3.attributes.byOverturn);
} else {
if (_local3.nodeName == "Levels"){
CGlobal.LevelsParam = new Array();
_local4 = _local3.firstChild;
while (_local4) {
if (_local4.nodeName == "Level"){
_local13 = int(_local4.attributes.Id);
CGlobal.LevelsParam[_local13] = new Object();
_local5 = _local4.firstChild;
while (_local5) {
if (_local5.nodeName == "Time"){
_local6 = _local5.firstChild;
CGlobal.LevelsParam[_local13].Time = new Array();
while (_local6) {
if (_local6.nodeName == "Item"){
_local7 = (int(_local6.attributes.bikeId) - 1);
CGlobal.LevelsParam[_local13].Time[_local7] = int(_local6.attributes.value);
};
_local6 = _local6.nextSibling;
};
} else {
if (_local5.nodeName == "Checkpoints"){
_local6 = _local5.firstChild;
CGlobal.LevelsParam[_local13].Checkpoints = new Array();
while (_local6) {
if (_local6.nodeName == "Item"){
_local14 = (int(_local6.attributes.Id) - 1);
_local15 = new Object();
_local15.x = Number(_local6.attributes.posX);
_local15.y = Number(_local6.attributes.posY);
CGlobal.LevelsParam[_local13].Checkpoints[_local14] = _local15;
};
_local6 = _local6.nextSibling;
};
} else {
if (_local5.nodeName == "Bike"){
CGlobal.LevelsParam[_local13].Bike = new Object();
CGlobal.LevelsParam[_local13].Bike.startX = Number(_local5.attributes.startX);
CGlobal.LevelsParam[_local13].Bike.startY = Number(_local5.attributes.startY);
CGlobal.LevelsParam[_local13].Bike.finishX = Number(_local5.attributes.finishX);
CGlobal.LevelsParam[_local13].Bike.finishY = Number(_local5.attributes.finishY);
CGlobal.LevelsParam[_local13].Bike.checkId = int(_local5.attributes.checkId);
} else {
if (_local5.nodeName == "Stars"){
CGlobal.LevelsParam[_local13].Stars = new Array();
_local6 = _local5.firstChild;
while (_local6) {
if (_local6.nodeName == "Item"){
_local16 = (int(_local6.attributes.Id) - 1);
_local17 = new Object();
_local17.x = Number(_local6.attributes.posX);
_local17.y = Number(_local6.attributes.posY);
_local17.isShow = true;
CGlobal.LevelsParam[_local13].Stars[_local16] = _local17;
};
_local6 = _local6.nextSibling;
};
};
};
};
};
_local5 = _local5.nextSibling;
};
};
_local4 = _local4.nextSibling;
};
};
};
};
};
};
_local3 = _local3.nextSibling;
};
};
_local2 = _local2.nextSibling;
};
}
}
}//package lib.Params
Section 118
//CGame (lib.CGame)
package lib {
import flash.display.*;
import flash.utils.*;
import VX.UI.*;
import Box2D.Dynamics.*;
import lib.Keyboard.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import ascb.units.*;
import lib.GameObjects.*;
import Box2D.General.*;
import lib.Hud.*;
import lib.Collision.*;
public class CGame extends CModule {
public const SCREEN_WIDTH:int = 600;
public const ITERATIONS:int;
public const SCREEN_HEIGHT:int = 400;
private const half_circle:int = 180;
private const levelId:int;
private const bikeId:int;
public const TIME_STEP:Number;
private var Bike:Object;
private var cart:b2Body;
private var isGameOver:Boolean;// = false
private var wheel2:b2Body;
private var levelMc:MovieClip;
public var fixtureDef:b2FixtureDef;
private var wheel1:b2Body;
private var axle1:b2Body;
private var Stars:CStars;
private var axle2:b2Body;
var isBikeImpulse:Boolean;// = false
private var wheelPos1:b2Vec2;
private var wheelPos2:b2Vec2;
private var motor2:b2RevoluteJoint;
private var motor1:b2RevoluteJoint;
private var Level:Object;
private var breakStep:Number;
private var screen:Sprite;
private var isFinish:Boolean;// = false
private var lastTime:int;// = 0
private var ground:CGroundBody;
public var world:b2World;
private var bikeKoefY:Number;
private var mc:MovieClip;
private var bikeKoefX:Number;
var isBikeBreak:Boolean;// = false
private var body:b2Body;
private var isMoveSndPlay:Boolean;// = false
private var isOverturn:Boolean;// = false
var isBikeNitro:Boolean;// = false
private var spring1:b2PrismaticJoint;
private var spring2:b2PrismaticJoint;
private var maze:Array;
private var input:Input;
private var fon:MovieClip;
private var body2:b2Body;
private var Hud:CHud;
private var head:b2PolygonShape;
private var keyboard:CGameKeyboard;
private var isNormalPos:Boolean;// = true
private var isGasSndPlay:Boolean;// = false
private var contactListner:CMyContactListner;
public static const DRAW_SCALE:Number = CGlobal.DrawScale;
public function CGame(_arg1:CGameKeyboard){
ITERATIONS = CGlobal.Iterations;
TIME_STEP = (1 / CGlobal.TimeStamp);
bikeId = CGlobal.ChoosedBike;
Bike = CGlobal.Bikes[bikeId];
levelId = CGlobal.numLevel;
Level = CGlobal.LevelsParam[levelId];
maze = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]];
contactListner = new CMyContactListner();
fixtureDef = new b2FixtureDef();
breakStep = Bike.breakStep;
super();
keyboard = _arg1;
}
private function InitGasSound(_arg1:Boolean):void{
CSounds.SoundManager.Reset();
if (_arg1){
isMoveSndPlay = !(_arg1);
isGasSndPlay = _arg1;
CSounds.SoundManager.Play(CSounds.BikeGasSound, false, UrbanStunts.SFX_VOLUME2);
CSounds.SoundManager.AddOnEndFunc(onEndGas);
} else {
isGasSndPlay = _arg1;
InitMoveSound();
};
}
private function SetGroundPos():void{
screen.x = (((SCREEN_WIDTH / 2) - (DRAW_SCALE * cart.GetWorldCenter().x)) - (cart.GetLinearVelocity().x * 3));
screen.y = ((((2 * SCREEN_HEIGHT) / 3) - (DRAW_SCALE * cart.GetWorldCenter().y)) - (cart.GetLinearVelocity().y * 2));
if (Stars){
Stars.UpdateStars({x:screen.x, y:screen.y});
};
levelMc.x = ((screen.x - (600 * 2)) + 80);
levelMc.y = (screen.y - 410);
}
override public function Init():void{
screen = new Sprite();
screen.y = SCREEN_HEIGHT;
addChild(screen);
stage.focus = this;
CSounds.SoundManager.Reset();
InitGame();
}
private function InitGame():void{
var _local1:int;
var _local2:b2BodyDef;
var _local3:b2PolygonShape;
var _local4:b2CircleShape;
var _local5:b2RevoluteJointDef;
var _local6:b2PrismaticJointDef;
var _local7:Number;
var _local8:Number;
var _local9:Object;
world = new b2World(new b2Vec2(0, 10), true);
world.SetContactListener(contactListner);
debug_draw();
_local2 = new b2BodyDef();
ground = new CGroundBody(world);
if (CGlobal.isCreatePolygon){
trace(((("\n\t\t" + CGlobal.LEVEL) + " №") + CGlobal.numLevel.toString()));
ground.createPolyFromLibraryShape(0, 0, ((CGlobal.LEVEL + levelId) + CGlobal.SHAPE), 0);
} else {
_local9 = CGlobal.Shapes[levelId];
ground.createComplexPolygon(_local9.x, _local9.y, _local9.Points, _local9.rotation);
};
fon = new (CGlobal.Classes.GetClass((CGlobal.BG + (((levelId % 2))==0) ? 1 : 2)));
fon.y = -100;
fon.alpha = CGlobal.alpha;
addChild(fon);
levelMc = new (CGlobal.Classes.GetClass((CGlobal.LEVEL + CGlobal.numLevel.toString())));
levelMc.alpha = CGlobal.alpha;
addChild(levelMc);
CGlobal.numCheckPoint = ((CGlobal.numCheckPoint)<(Level.Bike.checkId - 1)) ? (Level.Bike.checkId - 1) : CGlobal.numCheckPoint;
if ((((CGlobal.numCheckPoint >= 0)) && ((CGlobal.numCheckPoint < Level.Checkpoints.length)))){
_local7 = Level.Checkpoints[CGlobal.numCheckPoint].x;
_local8 = Level.Checkpoints[CGlobal.numCheckPoint].y;
} else {
if (CGlobal.numCheckPoint == -1){
_local7 = Level.Bike.startX;
_local8 = Level.Bike.startY;
} else {
_local7 = Level.Bike.finishX;
_local8 = Level.Bike.finishY;
};
};
_local2.position.Set(_local7, _local8);
_local2.type = b2Body.b2_dynamicBody;
_local2.userData = new (CGlobal.Classes.GetClass((CGlobal.BIKE + String((CGlobal.ChoosedBike + 1)))));
_local2.userData.rotation = Math.PI;
_local2.linearDamping = 0.25;
_local2.angularDamping = 0.25;
_local2.userData.biker.gotoAndStop(3);
_local2.userData.alpha = CGlobal.alpha;
cart = world.CreateBody(_local2);
cart.SetType(b2Body.b2_dynamicBody);
SetGroundPos();
_local3 = new b2PolygonShape();
_local3.SetAsBox(0.6, 0.2);
fixtureDef.shape = _local3;
fixtureDef.density = Bike.Body.density;
fixtureDef.friction = Bike.Body.friction;
fixtureDef.restitution = Bike.Body.restitution;
fixtureDef.filter.groupIndex = -1;
cart.CreateFixture(fixtureDef);
_local3.SetAsOrientedBox(0.25, 0.15, new b2Vec2(-(Bike.Axles[1].x), 0.15), (-(Math.PI) / 3));
fixtureDef.shape = _local3;
fixtureDef.density = 0.5;
cart.CreateFixture(fixtureDef);
_local3.SetAsOrientedBox(0.25, 0.15, new b2Vec2(Bike.Axles[0].x, 0.15), (Math.PI / 3));
fixtureDef.shape = _local3;
cart.CreateFixture(fixtureDef);
_local3.SetAsOrientedBox(Bike.Engine.width, Bike.Engine.height, new b2Vec2(Bike.Engine.x, Bike.Engine.y), 0);
fixtureDef.shape = _local3;
fixtureDef.density = Bike.Engine.density;
cart.CreateFixture(fixtureDef);
head = new b2PolygonShape();
head.SetAsOrientedBox(Bike.Head.width, Bike.Head.height, new b2Vec2(Bike.Head.x, Bike.Head.y));
fixtureDef.shape = head;
fixtureDef.density = Bike.Head.density;
fixtureDef.friction = Bike.Head.friction;
fixtureDef.filter.groupIndex = -1;
fixtureDef.userData = CGlobal.BIKER;
cart.CreateFixture(fixtureDef);
_local3.SetAsOrientedBox(0.3, 0.1, new b2Vec2((-(Bike.Axles[1].x) - (0.6 * Math.cos((Math.PI / 3)))), (0.15 - (0.6 * Math.sin((-(Math.PI) / 3))))), (-(Math.PI) / 3));
fixtureDef.userData = "";
fixtureDef.shape = _local3;
fixtureDef.density = Bike.Axles[1].density;
axle1 = world.CreateBody(_local2);
axle1.CreateFixture(fixtureDef);
_local6 = new b2PrismaticJointDef();
_local6.Initialize(cart, axle1, axle1.GetWorldCenter(), new b2Vec2(Math.cos((Math.PI / 3)), Math.sin((Math.PI / 3))));
_local6.lowerTranslation = 0;
_local6.upperTranslation = 0;
_local6.enableLimit = true;
_local6.enableMotor = true;
spring1 = (world.CreateJoint(_local6) as b2PrismaticJoint);
_local3.SetAsOrientedBox(0.3, 0.1, new b2Vec2((Bike.Axles[0].x + (0.6 * Math.cos((-(Math.PI) / 3)))), (0.15 + (0.6 * Math.sin((Math.PI / 3))))), (Math.PI / 3));
fixtureDef.shape = _local3;
fixtureDef.density = Bike.Axles[0].density;
axle2 = world.CreateBody(_local2);
axle2.CreateFixture(fixtureDef);
_local6.Initialize(cart, axle2, axle2.GetWorldCenter(), new b2Vec2(-(Math.cos((Math.PI / 3))), Math.sin((Math.PI / 3))));
spring2 = (world.CreateJoint(_local6) as b2PrismaticJoint);
_local1 = 0;
while (_local1 < 2) {
fixtureDef.density = Bike.Wheels[_local1].density;
fixtureDef.friction = Bike.Wheels[_local1].friction;
fixtureDef.restitution = Bike.Wheels[_local1].restitution;
fixtureDef.filter.groupIndex = -1;
fixtureDef.shape = new b2CircleShape(Bike.Wheels[_local1].radius);
fixtureDef.userData = (CGlobal.WHEEL + String((_local1 + 1)));
if (_local1 == 0){
_local2.position.Set((axle1.GetWorldCenter().x - (0.3 * Math.cos((Math.PI / 3)))), (axle1.GetWorldCenter().y - (0.3 * Math.sin((-(Math.PI) / 3)))));
wheel1 = world.CreateBody(_local2);
wheel1.CreateFixture(fixtureDef);
} else {
_local2.position.Set((axle2.GetWorldCenter().x + (0.3 * Math.cos((-(Math.PI) / 3)))), (axle2.GetWorldCenter().y + (0.3 * Math.sin((Math.PI / 3)))));
wheel2 = world.CreateBody(_local2);
wheel2.CreateFixture(fixtureDef);
};
_local1++;
};
addChild(cart.GetUserData());
_local5 = new b2RevoluteJointDef();
_local5.enableMotor = true;
_local5.Initialize(axle1, wheel1, wheel1.GetWorldCenter());
motor1 = (world.CreateJoint(_local5) as b2RevoluteJoint);
_local5.Initialize(axle2, wheel2, wheel2.GetWorldCenter());
motor2 = (world.CreateJoint(_local5) as b2RevoluteJoint);
Stars = new CStars(world, screen.x, screen.y, _local7);
Add(Stars);
Hud = new CHud();
Add(Hud);
InitMoveSound();
}
private function InitMoveSound():void{
isMoveSndPlay = true;
isGasSndPlay = false;
CSounds.SoundManager.Reset();
CSounds.SoundManager.Play(CSounds.BikeMoveSound, true, UrbanStunts.SFX_VOLUME2);
}
public function RestartGame():void{
RemoveSelf();
SendMessageExclude(CMessages.START_GAME, {isTry:false, isMusReset:true});
}
public function ChangeView():void{
var _local1:Number = 0.3;
levelMc.alpha = ((levelMc.alpha)<1) ? 1 : _local1;
fon.alpha = ((fon.alpha)<1) ? 1 : _local1;
cart.GetUserData().alpha = ((cart.GetUserData().alpha)<1) ? 1 : _local1;
wheel1.GetUserData().alpha = ((wheel1.GetUserData().alpha)<1) ? 1 : _local1;
wheel2.GetUserData().alpha = ((wheel2.GetUserData().alpha)<1) ? 1 : _local1;
}
public function GameTryAgain():void{
RemoveSelf();
SendMessageExclude(CMessages.START_GAME, {isTry:true, isMusReset:false});
}
override public function Remove():void{
Hud.RemoveSelf();
Hud = null;
Stars.RemoveSelf();
Stars = null;
while (numChildren > 0) {
removeChildAt(0);
};
world.DestroyBody(axle2);
world.DestroyBody(axle1);
world.DestroyBody(wheel2);
world.DestroyBody(wheel1);
world.DestroyBody(cart);
world = null;
}
private function CheckBikerAngle(_arg1:b2Body):void{
var _local2:Number;
if (((_arg1.GetUserData().biker) && (!(isGameOver)))){
_local2 = (cart.GetLinearVelocity().x * 3);
if ((((_local2 > 2)) && ((_local2 < 4)))){
_arg1.GetUserData().biker.gotoAndStop(2);
} else {
if (_local2 > 4){
_arg1.GetUserData().biker.gotoAndStop(1);
} else {
_arg1.GetUserData().biker.gotoAndStop(3);
};
};
};
}
private function debug_draw():void{
var _local1:b2DebugDraw = new b2DebugDraw();
_local1.SetSprite(screen);
_local1.SetDrawScale(DRAW_SCALE);
_local1.SetFillAlpha(0.1);
_local1.SetLineThickness(2);
_local1.SetFlags(1);
world.SetDebugDraw(_local1);
}
private function onEndGas():void{
isGasSndPlay = false;
}
public function TraceBikePos():void{
trace((((("Bike pos: (" + cart.GetPosition().x) + ", ") + cart.GetPosition().y) + ")"));
}
override public function Update():void{
var _local1:Converter;
var _local6:Number;
var _local7:Sprite;
if (((isOverturn) && (((contactListner.ContactWheel1) || (contactListner.ContactWheel2))))){
isOverturn = false;
};
if (contactListner.isStarBring.bool){
CSounds.SoundManager2.Play(CSounds.StarPickSound, false, UrbanStunts.SFX_VOLUME);
Stars.RemoveStar(contactListner.isStarBring.num);
Hud.SetVisibleStars();
contactListner.isStarBring.bool = false;
};
if (contactListner.isShapesCollied){
isGameOver = true;
if (lastTime == 0){
CSounds.SoundManager.Reset();
CSounds.SoundManager.Play(CSounds.BikeFallSound, false, UrbanStunts.SFX_VOLUME);
lastTime = getTimer();
Hud.ShowTryAgain();
cart.GetLinearVelocity().x = 0;
};
if ((getTimer() - lastTime) > CGlobal.crashPause){
CGlobal.numTurns = 0;
CGlobal.numFalls++;
GameTryAgain();
};
return;
};
if (cart.GetPosition().x > Level.Bike.finishX){
if (!isFinish){
CSounds.SoundManager.Reset();
CSounds.SoundManager2.Play(CSounds.WinSound, false, UrbanStunts.SFX_VOLUME);
if (cart.GetLinearVelocity().x > 0){
cart.GetLinearVelocity().x = 0;
SendMessageExclude(CMessages.REMOVE_KEYBOARD, null);
} else {
lastTime = getTimer();
isFinish = true;
};
};
if (((isFinish) && (((getTimer() - lastTime) > CGlobal.finishPause)))){
RemoveSelf();
SendMessageExclude(CMessages.NEXT_LEVEL, null);
};
return;
};
if (((isBikeBreak) && (((contactListner.ContactWheel1) || (contactListner.ContactWheel2))))){
_local6 = cart.GetLinearVelocity().x;
if ((((_local6 > 0)) && (((_local6 - breakStep) > 0)))){
cart.GetLinearVelocity().x = (cart.GetLinearVelocity().x - breakStep);
} else {
if ((((_local6 < 0)) && (((_local6 + breakStep) < 0)))){
cart.GetLinearVelocity().x = (cart.GetLinearVelocity().x + breakStep);
} else {
cart.GetLinearVelocity().x = 0;
isBikeBreak = false;
};
};
};
_local1 = Unit.RADIAN.getConverterTo(Unit.DEGREE);
var _local2:b2Body = world.GetBodyList();
while (_local2) {
if (((!((_local2.GetUserData() == null))) && ((_local2.GetUserData() is Sprite)))){
_local7 = _local2.GetUserData();
_local7.x = (screen.x + (DRAW_SCALE * _local2.GetWorldCenter().x));
_local7.y = (screen.y + (DRAW_SCALE * _local2.GetWorldCenter().y));
_local7.rotation = (_local1.convert(_local2.GetAngle()) % (2 * half_circle));
CheckBikerAngle(_local2);
};
_local2 = _local2.GetNext();
};
_local1 = Unit.RADIAN.getConverterTo(Unit.DEGREE);
var _local3:int = (Math.round(((_local1.convert(cart.GetAngle()) % 360) / 10)) * 10);
if ((((((((_local3 == -(half_circle))) && (isNormalPos))) && (!(contactListner.ContactWheel1)))) && (!(contactListner.ContactWheel2)))){
if (!isOverturn){
isOverturn = true;
};
isNormalPos = false;
CGlobal.numTurns++;
} else {
if ((((_local3 == 0)) && (!(isNormalPos)))){
isNormalPos = !(isNormalPos);
};
};
if (((cart.GetUserData().w1) && (cart.GetUserData().w2))){
cart.GetUserData().w2.rotation = (_local1.convert(wheel1.GetAngle()) % (2 * half_circle));
cart.GetUserData().w1.rotation = (_local1.convert(wheel2.GetAngle()) % (2 * half_circle));
};
if (((!(isGameOver)) && (!((world == null))))){
world.Step(TIME_STEP, ITERATIONS, ITERATIONS);
world.ClearForces();
world.DrawDebugData();
};
if (!isGasSndPlay){
if (((keyboard.Up) || (keyboard.Down))){
InitGasSound(true);
} else {
if (!isMoveSndPlay){
InitMoveSound();
};
};
} else {
if (((!(keyboard.Up)) && (!(keyboard.Down)))){
InitGasSound(false);
};
};
motor1.SetMotorSpeed(((15 * Math.PI) * (keyboard.Up) ? 1 : (keyboard.Down) ? -1 : 0));
motor1.SetMaxMotorTorque((((keyboard.Up) || (keyboard.Down))) ? (12 * Bike.speed) : (0.5 * Bike.speed));
var _local4:Number = Bike.control;
var _local5:Number = (ITERATIONS * (keyboard.Right) ? (1 * _local4) : (keyboard.Left) ? (-1 * _local4) : 0);
cart.ApplyTorque(_local5);
Hud.InitCheckPoint(cart.GetWorldCenter().x);
SetGroundPos();
FRateLimiter.limitFrame(60);
}
}
}//package lib
Section 119
//CGlobal (lib.CGlobal)
package lib {
public class CGlobal {
public static const GROUND:String = "ground";
public static const SHAPE:String = "Shape";
public static const oneSec:int = 1000;
public static const BIKER:String = "biker";
public static const games_link:String = "http://www.flashracingonline.com/games-your-site.html";
public static const BG:String = "bg";
public static const WHEEL:String = "wheel";
public static const gameId:String = "2dbf452df11a435c";
public static const STAR:String = "star";
public static const stuntsGames_link:String = "http://x.mochiads.com/link/f7d72ece14df8c52";
public static const BIKE:String = "bike";
public static const LEVEL:String = "level";
public static const leaderBoard:String = "6ddb67656df3a90e";
public static const moreGames_link:String = "http://x.mochiads.com/link/a683034b91396c95";
public static var Classes:Object;
public static var ChoosedBike:int = -1;
public static var crashPause:int;
public static var score:int = 0;
public static var isCreatePolygon:Boolean = false;
public static var numCheckPoint:int = -1;
public static var Bikes:Array = new Array();
public static var Shapes:Array;
public static var isQuatro:Boolean = true;
public static var finishPause:int;
public static var numLevel:int = 0;
public static var numTurns:int = 0;
public static var Debug:Boolean = false;
public static var LevelsParam:Array;
public static var DrawScale:int;
public static var FreeFallKoef:Number;
public static var bikeVisible:Boolean = true;
public static var TimeStamp:int;
public static var openLevel:int = 1;
public static var Iterations:int;
public static var alpha:Number;
public static var numPickStars:int = 0;
public static var numFalls:int = 0;
public static var scoreByOverturn:int = 0;
public static var scoreByStar:int = 0;
public static var timeBonusOneSec:int = 0;
}
}//package lib
Section 120
//CLogo (lib.CLogo)
package lib {
import flash.events.*;
import VX.UI.*;
import flash.net.*;
public class CLogo extends CModule {
private const srcLogo:String = "Logo";
override public function Init():void{
Ani = new (CGlobal.Classes.GetClass(srcLogo));
Ani.x = 290;
Ani.y = 210;
Ani.gotoAndStop(1);
Ani.buttonMode = true;
Ani.addEventListener(MouseEvent.CLICK, onMoreGames);
addChild(Ani);
}
override public function Remove():void{
Ani.removeEventListener(MouseEvent.CLICK, onMoreGames);
Ani.gotoAndStop(1);
removeChild(Ani);
}
override public function Update():void{
if (Ani.currentFrame >= (Ani.totalFrames - 1)){
Ani.stop();
SendMessageExclude(CMessages.START_MAIN, null);
} else {
if ((((Ani.currentFrame == 70)) && (Ani.carkoleso))){
Ani.carkoleso.gotoAndStop(4);
};
};
Ani.gotoAndStop((Ani.currentFrame + 1));
if (Ani.carkoleso){
if (Ani.carkoleso.currentFrame == 3){
Ani.carkoleso.gotoAndStop(1);
} else {
if (Ani.carkoleso.currentFrame == 4){
Ani.carkoleso.stop();
};
};
};
}
public function EndClip():void{
Ani.play();
}
private function onMoreGames(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(CGlobal.moreGames_link), "_blank");
}
}
}//package lib
Section 121
//CMain (lib.CMain)
package lib {
import flash.events.*;
import flash.utils.*;
import VX.UI.*;
import lib.Keyboard.*;
import lib.Menu.*;
import lib.GameObjects.*;
public class CMain extends CModule {
private var Instructions:CIntstructions;
private var GameOver:CGameOver;
private var ChooseLevel:CChooseLevel;
private var Game:CGame;
private var GameKeyboard:CGameKeyboard;
private var MainWindow:CMainWindow;
private var CompleteLevel:CCompleteLevel;
private var LoadClip:CLogo;
private var ChooseBike:CChooseBike;
public static var levelTime:int;
private function InitGame():void{
DestroyGame();
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true);
Game = new CGame(GameKeyboard);
Add(Game);
}
private function DestroyGame():void{
if (Game){
RemoveKeyboradListeners();
Game.RemoveSelf();
Game = null;
};
}
private function onKeyDown(_arg1:KeyboardEvent):void{
GameKeyboard.SetKey(_arg1.keyCode, true);
if (((Game) && (Game.world))){
if (GameKeyboard.Restart){
Game.GameTryAgain();
} else {
if (GameKeyboard.Space){
Game.isBikeBreak = true;
};
};
};
}
private function InitMenuMusic():void{
CSounds.MusicManager.Reset();
CSounds.MusicManager.Play(CSounds.MenuMusic, true, UrbanStunts.START_VOLUME);
}
private function GameInit():void{
var _local1:int;
GameKeyboard = new CGameKeyboard();
if (CGlobal.Debug){
_local1 = CGlobal.numLevel;
levelTime = (CGlobal.LevelsParam[_local1].Time[CGlobal.ChoosedBike] * CGlobal.oneSec);
InitGame();
} else {
CGlobal.openLevel = 1;
MainWindow = new CMainWindow();
Add(MainWindow);
InitMenuMusic();
};
}
private function InitCompleteLevel():void{
if (CompleteLevel){
CompleteLevel.RemoveSelf();
CompleteLevel = null;
};
CompleteLevel = new CCompleteLevel();
Add(CompleteLevel);
}
private function InitChooseLevel():void{
if (ChooseLevel){
ChooseLevel.RemoveSelf();
ChooseLevel = null;
};
ChooseLevel = new CChooseLevel();
Add(ChooseLevel);
}
private function InitChooseBike():void{
if (ChooseBike){
ChooseBike.RemoveSelf();
ChooseBike = null;
};
ChooseBike = new CChooseBike();
Add(ChooseBike);
}
private function RemoveKeyboradListeners():void{
GameKeyboard.Reset();
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
override public function Init():void{
if (CGlobal.Debug){
GameInit();
} else {
LoadClip = new CLogo();
Add(LoadClip);
};
}
private function onKeyUp(_arg1:KeyboardEvent):void{
GameKeyboard.SetKey(_arg1.keyCode, false);
}
override public function Remove():void{
}
private function InitGameOver():void{
if (GameOver){
GameOver.RemoveSelf();
GameOver = null;
};
GameOver = new CGameOver();
Add(GameOver);
}
override public function ProcessMessage(_arg1:int, _arg2:Object):int{
var _local3:int;
switch (_arg1){
case CMessages.START_MAIN:
if (LoadClip){
LoadClip.RemoveSelf();
LoadClip = null;
GameInit();
};
break;
case CMessages.SHOW_INSTR:
if (MainWindow){
MainWindow.doHide();
};
Instructions = new CIntstructions();
Add(Instructions);
break;
case CMessages.CHOOSE_BIKE:
DestroyGame();
InitChooseBike();
break;
case CMessages.CHOOSE_LEVEL:
DestroyGame();
InitChooseLevel();
break;
case CMessages.START_GAME:
if (!_arg2.isTry){
CGlobal.numCheckPoint = -1;
_local3 = CGlobal.numLevel;
levelTime = (CGlobal.LevelsParam[_local3].Time[CGlobal.ChoosedBike] * CGlobal.oneSec);
CStars.visibleAll = true;
CGlobal.numPickStars = 0;
CGlobal.numFalls = 0;
CGlobal.numTurns = 0;
CSounds.MusicManager.Reset();
CSounds.MusicManager.Play(CSounds.LevelMusic, true, UrbanStunts.START_VOLUME);
};
if (_arg2.isMusReset){
CSounds.MusicManager.Reset();
CSounds.MusicManager.Play(CSounds.LevelMusic, true, UrbanStunts.START_VOLUME);
};
InitGame();
break;
case CMessages.RESTART_GAME:
InitGameOver();
break;
case CMessages.NEXT_LEVEL:
if ((((CGlobal.openLevel < CGlobal.LevelsParam.length)) && ((CGlobal.openLevel == (CGlobal.numLevel + 1))))){
CGlobal.openLevel++;
};
InitCompleteLevel();
break;
case CMessages.SHOW_MAIN_WINDOW:
DestroyGame();
if (CGlobal.Debug){
InitChooseBike();
} else {
MainWindow.doShow();
if (_arg2.isGame){
InitMenuMusic();
};
};
break;
case CMessages.REMOVE_KEYBOARD:
RemoveKeyboradListeners();
break;
};
return (0);
}
}
}//package lib
Section 122
//CMessages (lib.CMessages)
package lib {
import VX.Data.*;
public class CMessages {
public static const CHOOSE_BIKE:int = CFunctions.GetUId();
public static const SHOW_INSTR:int = CFunctions.GetUId();
public static const START_GAME:int = CFunctions.GetUId();
public static const RESTART_GAME:int = CFunctions.GetUId();
public static const SHOW_MAIN_WINDOW:int = CFunctions.GetUId();
public static const START_MAIN:int = CFunctions.GetUId();
public static const NEXT_LEVEL:int = CFunctions.GetUId();
public static const REMOVE_KEYBOARD:int = CFunctions.GetUId();
public static const CHOOSE_LEVEL:int = CFunctions.GetUId();
}
}//package lib
Section 123
//CSounds (lib.CSounds)
package lib {
import VX.Sound.*;
public class CSounds {
public static var LevelMusic:CSound;
public static var StarPickSound:CSound;
public static var MenuMusic:CSound;
public static var WinSound:CSound;
public static var MusicManager:CSoundManager;
public static var BikeFallSound:CSound;
public static var SoundManager2:CSoundManager;
public static var Inited:Boolean = Init();
public static var BikeGasSound:CSound;
public static var BikeMoveSound:CSound;
public static var SoundManager:CSoundManager;
private static function Init():void{
SoundManager = new CSoundManager();
SoundManager2 = new CSoundManager();
MusicManager = new CSoundManager();
MenuMusic = CSound.CreateInitSound(new (CGlobal.Classes.GetClass("Menu.wav")));
LevelMusic = CSound.CreateInitSound(new (CGlobal.Classes.GetClass("Gameplay.wav")));
BikeFallSound = CSound.CreateInitSound(new (CGlobal.Classes.GetClass("fall.mp3")));
BikeGasSound = CSound.CreateInitSound(new (CGlobal.Classes.GetClass("gas.mp3")));
BikeMoveSound = CSound.CreateInitSound(new (CGlobal.Classes.GetClass("move.mp3")));
StarPickSound = CSound.CreateInitSound(new (CGlobal.Classes.GetClass("Stars_pick.mp3")));
WinSound = CSound.CreateInitSound(new (CGlobal.Classes.GetClass("flag_won.wav")));
}
}
}//package lib
Section 124
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function get value():Number{
return (Number(this.toString()));
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 125
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var n:Number;
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local2:Object = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi.as3
Section 126
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__ms_";
private static var _servicesURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
public static var netup:Boolean = true;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().getTime()));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
var _local2:Rectangle = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.0");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
public static function get id():String{
return (_id);
}
private static function urlOptions(_arg1:Object):Object{
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
var _local3:String = _arg1.loaderInfo.parameters.mochiad_options;
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((((_container is Sprite)) && (_clip))){
Sprite(_container).addChild(_clip);
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_listenChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = this.client._callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
trace("connected!");
_connecting = false;
_connected = true;
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var id = _arg1;
var clip = _arg2;
var clipname:String = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(clip).servicesURL != undefined){
_servicesURL = urlOptions(clip).servicesURL;
};
MochiServices.allowDomains(_servicesURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
var f:Function = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().getTime()) + "_") + Math.floor((Math.random() * 99999))));
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
var req:URLRequest = new URLRequest(_servicesURL);
var vars:URLVariables = new URLVariables();
vars.listenLC = _listenChannelName;
vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options;
if (widget){
vars.widget = true;
};
req.data = vars;
listen();
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function get clip():Object{
return (_container);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
var mc:MovieClip = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
}
}//package mochi.as3
Section 127
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.5.0.12683";
}
}//package mx.core
Section 128
//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.5.0.12683";
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 129
//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.5.0.12683";
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 130
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 131
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 132
//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 133
//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 134
//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.5.0.12683";
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 135
//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 136
//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.5.0.12683";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var result:String;
var o:DisplayObject;
var s:String;
var indices:Array;
var displayObject = _arg1;
try {
o = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
} catch(e:SecurityError) {
};
return (result);
}
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 137
//Color (wumedia.parsers.swf.Color)
package wumedia.parsers.swf {
public class Color {
public var a:uint;
public var b:uint;
public var g:uint;
public var r:uint;
public function Color(_arg1:Data, _arg2:Boolean){
r = _arg1.readUnsignedByte();
g = _arg1.readUnsignedByte();
b = _arg1.readUnsignedByte();
if (_arg2){
a = _arg1.readUnsignedByte();
} else {
a = 0xFF;
};
}
public function get color():uint{
return ((((r << 16) | (g << 8)) | b));
}
public function toString():String{
return (value.toString(16));
}
public function get value():uint{
return (((((a << 24) | (r << 16)) | (g << 8)) | b));
}
public function get alpha():Number{
return ((a / 0xFF));
}
}
}//package wumedia.parsers.swf
Section 138
//Data (wumedia.parsers.swf.Data)
package wumedia.parsers.swf {
import flash.geom.*;
import flash.utils.*;
public class Data implements IDataInput {
protected var _data:ByteArray;
protected var _bitPos:int;
protected var _bitBuff:int;
public function Data(_arg1:ByteArray){
_data = _arg1;
_data.endian = Endian.LITTLE_ENDIAN;
synchBits();
}
public function readInt():int{
synchBits();
return (_data.readInt());
}
public function readBytes(_arg1:ByteArray, _arg2:uint=0, _arg3:uint=0):void{
synchBits();
_data.readBytes(_arg1, _arg2, _arg3);
}
public function readShort():int{
synchBits();
return (_data.readShort());
}
public function readDouble():Number{
var _local1:ByteArray = new ByteArray();
var _local2:ByteArray = new ByteArray();
_data.readBytes(_local1, 0, 8);
_local2.length = 8;
_local2[0] = _local1[3];
_local2[1] = _local1[2];
_local2[2] = _local1[1];
_local2[3] = _local1[0];
_local2[4] = _local1[7];
_local2[5] = _local1[6];
_local2[6] = _local1[5];
_local2[7] = _local1[4];
_local2.position = 0;
return (_local2.readDouble());
}
public function readUnsignedShort():uint{
synchBits();
return (_data.readUnsignedShort());
}
public function readRect():Rectangle{
var _local1:uint = readUBits(5);
var _local2:Number = (readSBits(_local1) * 0.05);
var _local3:Number = (readSBits(_local1) * 0.05);
var _local4:Number = (readSBits(_local1) * 0.05);
var _local5:Number = (readSBits(_local1) * 0.05);
synchBits();
return (new Rectangle(_local2, _local4, (_local3 - _local2), (_local5 - _local4)));
}
public function get endian():String{
return (_data.endian);
}
public function get bytesAvailable():uint{
return (_data.bytesAvailable);
}
public function readSBits(_arg1:uint):int{
var _local2:int = readUBits(_arg1);
if ((_local2 & (1 << (_arg1 - 1))) != 0){
_local2 = (_local2 | (-1 << _arg1));
};
return (_local2);
}
public function readUBits(_arg1:uint):uint{
var _local4:int;
if (_arg1 == 0){
return (0);
};
var _local2:int = _arg1;
var _local3:int;
if (_bitPos == 0){
_bitBuff = _data.readUnsignedByte();
_bitPos = 8;
};
while (true) {
_local4 = (_local2 - _bitPos);
if (_local4 > 0){
_local3 = (_local3 | (_bitBuff << _local4));
_local2 = (_local2 - _bitPos);
_bitBuff = _data.readUnsignedByte();
_bitPos = 8;
} else {
_local3 = (_local3 | (_bitBuff >> -(_local4)));
_bitPos = (_bitPos - _local2);
_bitBuff = (_bitBuff & (0xFF >> (8 - _bitPos)));
break;
};
};
return (_local3);
}
public function get position():int{
return (_data.position);
}
public function get data():ByteArray{
return (_data);
}
public function readUTF():String{
synchBits();
return (_data.readUTF());
}
public function readBoolean():Boolean{
synchBits();
return (_data.readBoolean());
}
public function set endian(_arg1:String):void{
_data.endian = _arg1;
}
public function readByte():int{
synchBits();
return (readByte());
}
public function readUnsignedInt():uint{
synchBits();
return (_data.readUnsignedInt());
}
public function readString():String{
var _local2:uint;
var _local1 = "";
while ((_local2 = readUnsignedByte()) != 0) {
_local1 = (_local1 + String.fromCharCode(_local2));
};
return (_local1);
}
public function readUTFBytes(_arg1:uint):String{
synchBits();
return (_data.readUTFBytes(_arg1));
}
public function get objectEncoding():uint{
return (_data.objectEncoding);
}
public function set position(_arg1:int):void{
_data.position = _arg1;
}
public function synchBits():void{
_bitBuff = 0;
_bitPos = 0;
}
public function set data(_arg1:ByteArray):void{
_data = _arg1;
synchBits();
}
public function readUnsignedByte():uint{
synchBits();
return (_data.readUnsignedByte());
}
public function set objectEncoding(_arg1:uint):void{
_data.objectEncoding = _arg1;
}
public function readMultiByte(_arg1:uint, _arg2:String):String{
synchBits();
return (_data.readMultiByte(_arg1, _arg2));
}
public function readFloat():Number{
synchBits();
return (_data.readFloat());
}
public function readObject(){
synchBits();
return (_data.readObject());
}
public function readMatrix():Matrix{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:uint;
synchBits();
if (readUBits(1) == 1){
_local7 = readUBits(5);
_local1 = (readSBits(_local7) / 65536);
_local2 = (readSBits(_local7) / 65536);
} else {
_local1 = 1;
_local2 = 1;
};
if (readUBits(1) == 1){
_local7 = readUBits(5);
_local3 = (readSBits(_local7) / 65536);
_local4 = (readSBits(_local7) / 65536);
} else {
_local3 = 0;
_local4 = 0;
};
_local7 = readUBits(5);
_local5 = (readSBits(_local7) * 0.05);
_local6 = (readSBits(_local7) * 0.05);
return (new Matrix(_local1, _local3, _local4, _local2, _local5, _local6));
}
public function get length():uint{
return (_data.length);
}
}
}//package wumedia.parsers.swf
Section 139
//Edge (wumedia.parsers.swf.Edge)
package wumedia.parsers.swf {
public class Edge {
public var sx:int;
public var sy:int;
public var cx:int;
public var cy:int;
public var x:int;
public var y:int;
public var type:uint;
public static const LINE:uint = 1;
public static const CURVE:uint = 0;
public function Edge(_arg1:uint, _arg2:Data, _arg3:int=0, _arg4:int=0){
this.type = _arg1;
if (_arg2){
sx = _arg3;
sy = _arg4;
if (_arg1 == CURVE){
parseCurve(_arg2);
} else {
parseLine(_arg2);
};
};
}
public function reverse():Edge{
var _local1:Edge = new Edge(type, null);
_local1.x = sx;
_local1.y = sy;
_local1.cx = cx;
_local1.cy = cy;
_local1.sx = x;
_local1.sy = y;
return (_local1);
}
private function parseLine(_arg1:Data):void{
var _local4:Boolean;
var _local2:uint = (_arg1.readUBits(4) + 2);
var _local3 = (_arg1.readUBits(1) == 1);
if (_local3){
x = (_arg1.readSBits(_local2) + sx);
y = (_arg1.readSBits(_local2) + sy);
} else {
_local4 = (_arg1.readUBits(1) == 1);
if (_local4){
x = sx;
y = (_arg1.readSBits(_local2) + sy);
} else {
x = (_arg1.readSBits(_local2) + sx);
y = sy;
};
};
}
public function apply(_arg1, _arg2:Number=1, _arg3:Number=0, _arg4:Number=0):void{
if (type == CURVE){
var _local5 = _arg1;
_local5["curveTo"](((cx * _arg2) + _arg3), ((cy * _arg2) + _arg4), ((x * _arg2) + _arg3), ((y * _arg2) + _arg4));
} else {
_local5 = _arg1;
_local5["lineTo"](((x * _arg2) + _arg3), ((y * _arg2) + _arg4));
};
}
private function parseCurve(_arg1:Data):void{
var _local2:uint = (_arg1.readUBits(4) + 2);
cx = (_arg1.readSBits(_local2) + sx);
cy = (_arg1.readSBits(_local2) + sy);
x = (_arg1.readSBits(_local2) + cx);
y = (_arg1.readSBits(_local2) + cy);
}
}
}//package wumedia.parsers.swf
Section 140
//FillStyle (wumedia.parsers.swf.FillStyle)
package wumedia.parsers.swf {
import flash.display.*;
import flash.geom.*;
public class FillStyle {
private var _method:String;
private var _fillMatrix:Matrix;
private var _solidColor:Color;
public var type:String;
private var _arguments:Array;
public function FillStyle(_arg1:Data, _arg2:Boolean){
var _local3:int;
var _local5:int;
var _local6:Array;
var _local7:Array;
var _local8:uint;
super();
var _local4:int = _arg1.readUnsignedByte();
if (_local4 == 0){
_solidColor = new Color(_arg1, _arg2);
_method = "beginFill";
_arguments = [_solidColor.color, _solidColor.alpha];
type = "FS";
} else {
if ((((((_local4 == 16)) || ((_local4 == 18)))) || ((_local4 == 19)))){
_fillMatrix = _arg1.readMatrix();
_local5 = _arg1.readUnsignedByte();
_local6 = new Array(_local5);
_local7 = new Array(_local5);
_local3 = 0;
while (_local3 < _local5) {
_local6[_local3] = _arg1.readUnsignedByte();
_local7[_local3] = new Color(_arg1, _arg2);
_local3++;
};
if (_local4 == 16){
_arguments = [GradientType.LINEAR];
} else {
if (_local4 == 18){
_arguments = [GradientType.RADIAL];
} else {
_arguments = [GradientType.RADIAL];
};
};
_arguments = _arguments.concat([_local7.map(mapColors), _local7.map(mapAlphas), _local6]);
_method = "beginGradientFill";
type = "FG";
} else {
if ((((((((_local4 == 64)) || ((_local4 == 65)))) || ((_local4 == 66)))) || ((_local4 == 67)))){
_local8 = _arg1.readUnsignedShort();
_fillMatrix = _arg1.readMatrix();
_method = "beginBitmapFill";
type = "FB";
} else {
type = "FS";
_method = "beginFill";
_arguments = [0xFFFFFF];
};
};
};
}
public function get method(){
return (_method);
}
private function mapColors(_arg1:Color, ... _args):uint{
return (_arg1.color);
}
private function mapAlphas(_arg1:Color, ... _args):uint{
return (_arg1.alpha);
}
public function apply(_arg1, _arg2:Number=1, _arg3:Number=0, _arg4:Number=0):void{
var mat:Matrix;
var graphics = _arg1;
var scale = _arg2;
var offsetX = _arg3;
var offsetY = _arg4;
if (graphics["hasOwnProperty"](_method)){
if (type == "FS"){
graphics[_method].apply(null, _arguments);
} else {
mat = _fillMatrix.clone();
mat.scale(scale, scale);
mat.translate(offsetX, offsetY);
graphics[_method].apply(null, _arguments.concat(mat));
};
} else {
if (graphics["hasOwnProperty"]("beginFill")){
if (type == "FG"){
try {
var _local6 = graphics;
_local6["beginFill"](_arguments[1][0]);
} catch(err:Error) {
var _local7 = graphics;
_local7["beginFill"](0);
};
} else {
_local6 = graphics;
_local6["beginFill"](0);
};
};
};
}
}
}//package wumedia.parsers.swf
Section 141
//LineStyle (wumedia.parsers.swf.LineStyle)
package wumedia.parsers.swf {
import flash.display.*;
public class LineStyle {
public var type:uint;
public var jointStyle:String;
private var _flags:uint;
public var width:Number;
public var endCaps:String;
public var color:Color;
public var startCaps:String;
public var miterLimit:Number;
public var noClose:Boolean;
public static const TYPE_1:uint = 0;
public static const TYPE_2:uint = 1;
public function LineStyle(_arg1:uint, _arg2:Data, _arg3:Boolean=true){
this.type = _arg1;
if (_arg2){
if (_arg1 == TYPE_1){
parseStyle1(_arg2, _arg3);
} else {
parseStyle2(_arg2, _arg3);
};
};
}
public function get noVScale():Boolean{
return (!(((_flags & 2) == 0)));
}
public function get pixelHinting():Boolean{
return (!(((_flags & 1) == 0)));
}
public function apply(_arg1):void{
if (_arg1["hasOwnProperty"]("lineStyle")){
if (color){
var _local2 = _arg1;
_local2["lineStyle"](width, color.color, color.alpha);
} else {
_local2 = _arg1;
_local2["lineStyle"]();
};
};
}
public function get noHScale():Boolean{
return (!(((_flags & 4) == 0)));
}
private function parseStyle1(_arg1:Data, _arg2:Boolean=true):void{
width = (_arg1.readUnsignedShort() * 0.05);
color = new Color(_arg1, _arg2);
}
private function parseStyle2(_arg1:Data, _arg2:Boolean=true):void{
var _local3:uint;
width = (_arg1.readUnsignedShort() * 0.05);
_local3 = _arg1.readUBits(2);
if (_local3 == 0){
startCaps = CapsStyle.ROUND;
} else {
if (_local3 == 1){
startCaps = CapsStyle.NONE;
} else {
startCaps = CapsStyle.SQUARE;
};
};
_local3 = _arg1.readUBits(2);
if (_local3 == 0){
jointStyle = JointStyle.ROUND;
} else {
if (_local3 == 1){
jointStyle = JointStyle.BEVEL;
} else {
jointStyle = JointStyle.MITER;
};
};
_flags = _arg1.readUBits(4);
_arg1.readUBits(5);
noClose = (_arg1.readUBits(1) == 1);
_local3 = _arg1.readUBits(2);
if (_local3 == 0){
endCaps = CapsStyle.ROUND;
} else {
if (_local3 == 1){
endCaps = CapsStyle.NONE;
} else {
endCaps = CapsStyle.SQUARE;
};
};
if (jointStyle == JointStyle.MITER){
miterLimit = (_arg1.readUnsignedShort() * 0.05);
};
if (hasFill){
} else {
color = new Color(_arg1, _arg2);
};
}
public function get hasFill():Boolean{
return (!(((_flags & 8) == 0)));
}
}
}//package wumedia.parsers.swf
Section 142
//ShapeRecord (wumedia.parsers.swf.ShapeRecord)
package wumedia.parsers.swf {
import flash.display.*;
import flash.geom.*;
public class ShapeRecord {
private var _hasAlpha:Boolean;
private var _hasStateNewStyle:Boolean;
private var _fillBits:uint;
private var _fill1Index:uint;
private var _fill0:Array;
private var _fill1:Array;
private var _fills:Array;
private var _bounds:Rectangle;
private var _elements:Array;
private var _hasExtendedFill:Boolean;
private var _hasStyle:Boolean;
private var _fill0Index:uint;
private var _tagType:uint;
private var _lineBits:uint;
private static var _shape:Shape = new Shape();
public function ShapeRecord(_arg1:Data, _arg2:uint){
_tagType = _arg2;
_hasStyle = (((((((_tagType == TagTypes.DEFINE_SHAPE)) || ((_tagType == TagTypes.DEFINE_SHAPE2)))) || ((_tagType == TagTypes.DEFINE_SHAPE3)))) || ((_tagType == TagTypes.DEFINE_SHAPE4)));
_hasAlpha = (((_tagType == TagTypes.DEFINE_SHAPE3)) || ((_tagType == TagTypes.DEFINE_SHAPE4)));
_hasExtendedFill = (((((_tagType == TagTypes.DEFINE_SHAPE2)) || ((_tagType == TagTypes.DEFINE_SHAPE3)))) || ((_tagType == TagTypes.DEFINE_SHAPE4)));
_hasStateNewStyle = (((((_tagType == TagTypes.DEFINE_SHAPE2)) || ((_tagType == TagTypes.DEFINE_SHAPE3)))) || ((_tagType == TagTypes.DEFINE_SHAPE4)));
parse(_arg1);
if (_elements.length > 0){
calculateBounds();
} else {
_bounds = new Rectangle(0, 0, 0, 0);
};
}
private function calculateBounds():void{
var _local1:Graphics = _shape.graphics;
_local1.clear();
_local1.beginFill(0);
drawShape(_local1, this);
_local1.endFill();
_bounds = _shape.getRect(_shape);
}
public function get bounds():Rectangle{
return (_bounds);
}
private function queueEdges():void{
if (_fill0){
_fills[_fill0Index] = _fills[_fill0Index].concat(_fill0);
};
if (_fill1){
_fills[_fill1Index] = _fills[_fill1Index].concat(_fill1);
};
}
private function sortEdges(_arg1:Array):Array{
var _local2:int;
var _local3:int;
var _local5:Edge;
var _local4:Array = [_arg1.shift()];
while (_arg1.length > 0) {
_local5 = _arg1.pop();
_local4.push(_local5);
_local3 = _arg1.length;
while (--_local3 > -1) {
_local2 = _arg1.length;
while (--_local2 > -1) {
if ((((_local5.x == _arg1[_local2].sx)) && ((_local5.y == _arg1[_local2].sy)))){
_local5 = _arg1.splice(_local2, 1)[0];
_local4.push(_local5);
continue;
};
};
};
};
return (_local4);
}
private function saveEdges():void{
var _local1:int;
var _local2:int;
queueEdges();
_local2 = _fills.length;
_local1 = -1;
while (++_local1 < _local2) {
_fills[_local1] = sortEdges(_fills[_local1]);
_elements = _elements.concat(_fills[_local1]);
};
_fills = new Array();
}
public function get elements():Array{
return (_elements);
}
private function parse(_arg1:Data):void{
var _local2:Boolean;
var _local3:Boolean;
var _local4:Boolean;
var _local5:Boolean;
var _local6:Boolean;
var _local7:uint;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:uint;
var _local14:Edge;
var _local15:uint;
var _local12:int;
var _local13:int;
_elements = new Array();
_fills = new Array();
_arg1.synchBits();
if (_hasStyle){
parseStyles(_arg1);
_arg1.synchBits();
} else {
_fills = [[]];
_fill0 = [];
_fill0Index = 0;
};
_fillBits = _arg1.readUBits(4);
_lineBits = _arg1.readUBits(4);
while (true) {
_local15 = _arg1.readUBits(1);
if (_local15 == 1){
_local14 = new Edge(((_arg1.readUBits(1) == 0)) ? Edge.CURVE : Edge.LINE, _arg1, _local12, _local13);
if (_fill0){
_fill0.push(_local14.reverse());
};
if (_fill1){
_fill1.push(_local14);
};
_local12 = _local14.x;
_local13 = _local14.y;
} else {
_local11 = _arg1.readUBits(5);
if (_local11 == 0){
break;
};
_local2 = !(((_local11 & 1) == 0));
_local3 = !(((_local11 & 2) == 0));
_local4 = !(((_local11 & 4) == 0));
_local5 = !(((_local11 & 8) == 0));
_local6 = !(((_local11 & 16) == 0));
if (_local2){
_local7 = _arg1.readUBits(5);
_local12 = _arg1.readSBits(_local7);
_local13 = _arg1.readSBits(_local7);
};
if (_local3){
_local8 = _arg1.readUBits(_fillBits);
};
if (_local4){
_local9 = _arg1.readUBits(_fillBits);
};
if (_local5){
_local10 = _arg1.readUBits(_lineBits);
};
if (_hasStyle){
queueEdges();
_fill0Index = (_local8 - 1);
if ((((_local8 > 0)) && (_fills[_fill0Index]))){
_fill0 = [];
} else {
_fill0 = null;
};
_fill1Index = (_local9 - 1);
if ((((_local9 > 0)) && (_fills[_fill1Index]))){
_fill1 = [];
} else {
_fill1 = null;
};
};
if (((_hasStateNewStyle) && (_local6))){
parseStyles(_arg1);
_fillBits = _arg1.readUBits(4);
_lineBits = _arg1.readUBits(4);
};
};
};
saveEdges();
}
private function parseStyles(_arg1:Data):void{
var _local2:int;
var _local3:int;
saveEdges();
_local3 = _arg1.readUnsignedByte();
if (((_hasExtendedFill) && ((_local3 == 0xFF)))){
_local3 = _arg1.readUnsignedShort();
};
_local2 = 0;
while (_local2 < _local3) {
_fills.push([new FillStyle(_arg1, _hasAlpha)]);
_local2++;
};
_local3 = _arg1.readUnsignedByte();
if (_local3 == 0xFF){
_local3 = _arg1.readUnsignedShort();
};
_local2 = 0;
while (_local2 < _local3) {
new LineStyle(((_tagType == TagTypes.DEFINE_SHAPE4)) ? LineStyle.TYPE_2 : LineStyle.TYPE_1, _arg1, _hasAlpha);
_local2++;
};
}
public static function getPoints(_arg1:ShapeRecord, _arg2:Number=1):Array{
var _local9:Edge;
var _local3:Array = new Array();
var _local4:Array = _arg1._elements;
var _local5 = -1;
var _local6:int = _local4.length;
var _local7:int;
var _local8:int;
_arg2 = (_arg2 * 0.05);
while (++_local5 < _local6) {
if ((_local4[_local5] is Edge)){
_local9 = _local4[_local5];
_local3.push(new Point((_local9.x * _arg2), (_local9.y * _arg2)));
_local7 = _local9.x;
_local8 = _local9.y;
};
};
return (_local3);
}
public static function drawShape(_arg1, _arg2:ShapeRecord, _arg3:Number=1, _arg4:Number=0, _arg5:Number=0):void{
var _local11:Edge;
var _local6:Array = _arg2._elements;
var _local7 = -1;
var _local8:int = _local6.length;
var _local9:int;
var _local10:int;
_arg3 = (_arg3 * 0.05);
while (++_local7 < _local8) {
if ((_local6[_local7] is Edge)){
_local11 = _local6[_local7];
if (((!((_local9 == _local11.sx))) || (!((_local10 == _local11.sy))))){
var _local12 = _arg1;
_local12["moveTo"]((_arg4 + (_local11.sx * _arg3)), (_arg5 + (_local11.sy * _arg3)));
};
_local11.apply(_arg1, _arg3, _arg4, _arg5);
_local9 = _local11.x;
_local10 = _local11.y;
} else {
if ((_local6[_local7] is FillStyle)){
(_local6[_local7] as FillStyle).apply(_arg1, _arg3, _arg4, _arg5);
};
};
};
}
}
}//package wumedia.parsers.swf
Section 143
//SWFParser (wumedia.parsers.swf.SWFParser)
package wumedia.parsers.swf {
import flash.geom.*;
import flash.utils.*;
public class SWFParser {
protected var _size:uint;
protected var _rect:Rectangle;
protected var _frames:uint;
protected var _version:uint;
protected var _data:Data;
protected var _frameRate:uint;
public function SWFParser(_arg1:ByteArray){
var _local2:String;
var _local3:ByteArray;
super();
if (_arg1){
_arg1.position = 0;
_local2 = _arg1.readUTFBytes(3);
_version = _arg1.readUnsignedByte();
_size = _arg1.readUnsignedInt();
_data = new Data(_arg1);
if (_local2 == "CWS"){
_local3 = new ByteArray();
_data.readBytes(_local3);
_local3.position = 0;
_local3.uncompress();
_local3.position = 0;
_data = new Data(_local3);
};
_rect = _data.readRect();
_frameRate = (_data.readUnsignedShort() >> 8);
_frames = _data.readShort();
};
}
public function get size():uint{
return (_size);
}
public function get rect():Rectangle{
return (_rect);
}
public function parseTags(_arg1, _arg2:Boolean, _arg3:uint=0, _arg4:Data=null):Array{
var _local6:uint;
var _local7:uint;
var _local10:Tag;
var _local11:ByteArray;
if (_arg4 == null){
_arg4 = _data;
};
var _local5 = -1;
var _local8:uint = _arg4.position;
var _local9:Array = [];
while (((_arg4.bytesAvailable) && (!((_local5 == _arg3))))) {
_local5 = _arg4.readUnsignedShort();
_local6 = (_local5 & 63);
if (_local6 == 63){
_local6 = _arg4.readUnsignedInt();
};
_local5 = (_local5 >> 6);
_local7 = _arg4.position;
if ((((_local5 == _arg1)) || (((_arg1 is Array)) ? !(((_arg1 as Array).indexOf(_local5) == -1)) : false))){
_local10 = new Tag(_local5, _arg4.position, _local6);
if (_arg2){
_local11 = new ByteArray();
_arg4.readBytes(_local11, 0, _local10.length);
_local11.position = 0;
_local10.data = new Data(_local11);
};
_local9.push(_local10);
};
if (_arg4.position == _local7){
_arg4.position = (_arg4.position + _local6);
};
};
_arg4.position = _local8;
return (_local9);
}
public function get frameRate():uint{
return (_frameRate);
}
public function get data():Data{
return (_data);
}
public function get frames():uint{
return (_frames);
}
public function get ver():uint{
return (_version);
}
}
}//package wumedia.parsers.swf
Section 144
//Tag (wumedia.parsers.swf.Tag)
package wumedia.parsers.swf {
public class Tag {
public var data:Data;
public var length:uint;
public var position:uint;
public var type:int;
public function Tag(_arg1:uint=0, _arg2:uint=0, _arg3:uint=0){
this.type = _arg1;
this.position = _arg2;
this.length = _arg3;
}
}
}//package wumedia.parsers.swf
Section 145
//TagTypes (wumedia.parsers.swf.TagTypes)
package wumedia.parsers.swf {
public class TagTypes {
public static const SYMBOL_CLASS:uint = 76;
public static const DEFINE_BITS:uint = 6;
public static const SCRIPT_LIMITS:uint = 65;
public static const CSM_TEXT_SETTINGS:uint = 74;
public static const DEFINE_FONT_INFO:uint = 13;
public static const DEFINE_MORPH_SHAPE2:uint = 84;
public static const JPEG_TABLES:uint = 8;
public static const DEFINE_TEXT2:uint = 33;
public static const SOUND_STREAM_HEAD2:uint = 45;
public static const METADATA:uint = 77;
public static const DEFINE_TEXT:uint = 11;
public static const DEFINE_BUTTON:uint = 7;
public static const REMNOVE_OBJECT2:uint = 28;
public static const DEFINE_FONT2:uint = 48;
public static const DEFINE_FONT3:uint = 75;
public static const DEFINE_FONT4:uint = 91;
public static const DEFINE_BUTTON_CX_FORM:uint = 23;
public static const SOUND_STREAM_BLOCK:uint = 19;
public static const SET_BACKGROUND_COLOR:uint = 9;
public static const DEFINE_FONT:uint = 10;
public static const DEFINE_BITS_JPEG2:uint = 21;
public static const DEFINE_BITS_JPEG4:uint = 90;
public static const DEFINE_FONT_INFO2:uint = 62;
public static const REMOVE_OBJECT:uint = 5;
public static const DEFINE_BITS_JPEG3:uint = 35;
public static const DEFINE_FONT_ALIGN_ZONES:uint = 73;
public static const FRAME_LABEL:uint = 43;
public static const DO_ACTION:uint = 12;
public static const DEFINE_SOUND:uint = 14;
public static const EXPORT_ASSETS:uint = 56;
public static const ENABLE_DEBUGGER2:uint = 64;
public static const PLACE_OBJECT2:uint = 26;
public static const ENABLE_DEBUGGER:uint = 58;
public static const DEFINE_BITS_LOSSLESS2:uint = 36;
public static const IMPORT_ASSETS2:uint = 71;
public static const SHOW_FRAME:uint = 1;
public static const DO_ABC:uint = 82;
public static const DO_INIT_ACTION:uint = 59;
public static const PLACE_OBJECT3:uint = 70;
public static const PLACE_OBJECT:uint = 4;
public static const DEFINE_BINARY_DATA:uint = 87;
public static const SET_TAB_INDEX:uint = 66;
public static const DEFINE_BUTTON_SOUND:uint = 17;
public static const PROTECT:uint = 24;
public static const START_SOUND:uint = 15;
public static const END:uint = 0;
public static const DEFINE_BUTTON2:uint = 34;
public static const DEFINE_EDIT_TEXT:uint = 37;
public static const START_SOUND2:uint = 89;
public static const DEFINE_SCALIGN_GRID:uint = 78;
public static const DEFINE_SPRITE:uint = 39;
public static const IMOPRT_ASSETS:uint = 57;
public static const DEFINE_BITS_LOSSLESS:uint = 20;
public static const DEFINE_SHAPE2:uint = 22;
public static const DEFINE_SHAPE4:uint = 83;
public static const DEFINE_SHAPE3:uint = 32;
public static const VIDEO_STREAM:uint = 61;
public static const DEFINE_MORPH_SHAPE:uint = 46;
public static const DEFINE_VIDEO_STREAM:uint = 60;
public static const DEFINE_SCENE_AND_FRAME_LABEL_DATA:uint = 86;
public static const SOUND_STREAM_HEAD:uint = 18;
public static const DEFINE_FONT_NAME:uint = 88;
public static const FILE_ATTRIBUTES:uint = 69;
public static const DEFINE_SHAPE:uint = 2;
}
}//package wumedia.parsers.swf
Section 146
//VectorShapes (wumedia.vector.VectorShapes)
package wumedia.vector {
import flash.geom.*;
import flash.utils.*;
import wumedia.parsers.swf.*;
public class VectorShapes {
private static var _library:Object = new Object();
public function VectorShapes(){
throw (new Error((getQualifiedClassName(this) + " can not be instantiated")));
}
public static function draw(_arg1, _arg2:String, _arg3:Number=1, _arg4:Number=0, _arg5:Number=0):void{
if (_library[_arg2]){
ShapeRecord.drawShape(_arg1, _library[_arg2], _arg3, _arg4, _arg5);
} else {
trace((("ERROR: missing " + _arg2) + " vector"));
};
}
private static function getShapeFromPlaceTags(_arg1:SWFParser, _arg2:Array):Tag{
var swf = _arg1;
var placeTags = _arg2;
var lib:Array = swf.parseTags([TagTypes.DEFINE_SHAPE, TagTypes.DEFINE_SHAPE2, TagTypes.DEFINE_SHAPE3, TagTypes.DEFINE_SHAPE4], true).filter(function (_arg1:Tag, ... _args):Boolean{
var _local3:* = _arg1.data.readUnsignedShort();
_arg1.data.position = 0;
return (!((placeTags.indexOf(_local3) == -1)));
});
return (lib[0]);
}
private static function parsePlacetags(_arg1:Array):Array{
var _local5:uint;
var _local6:Matrix;
var _local7:Data;
var _local8:uint;
var _local9:uint;
var _local2:Array = [];
var _local3 = -1;
var _local4:int = _arg1.length;
while (++_local3 < _local4) {
_local7 = _arg1[_local3].data;
_local8 = _arg1[_local3].type;
if (_local8 == TagTypes.PLACE_OBJECT){
_local5 = _local7.readUnsignedShort();
_local7.readUnsignedShort();
_local6 = _local7.readMatrix();
} else {
if (_local8 == TagTypes.PLACE_OBJECT2){
_local7.readUBits(8);
_local7.readUnsignedShort();
_local5 = _local7.readUnsignedShort();
_local6 = _local7.readMatrix();
} else {
if (_local8 == TagTypes.PLACE_OBJECT3){
_local9 = _local7.readUBits(16);
_local7.readUnsignedShort();
if (((((!(((_local9 & 8) == 0))) || (!(((_local9 & 16) == 0))))) || (!(((_local9 & 0x0200) == 0))))){
_local7.readString();
};
_local5 = _local7.readUnsignedShort();
_local6 = _local7.readMatrix();
} else {
_local5 = 0;
};
};
};
if (_local5 != 0){
_local2.push(_local5);
_local2.push(_local6);
};
};
return (_local2);
}
private static function parseClassIdTable(_arg1:SWFParser):Object{
var _local7:uint;
var _local8:String;
var _local2:Object = {};
var _local3:Array = _arg1.parseTags(TagTypes.SYMBOL_CLASS, true);
if (_local3.length != 1){
return (_local2);
};
var _local4:Data = _local3[0].data;
var _local5:uint = _local4.readUnsignedShort();
var _local6 = -1;
while (++_local6 < _local5) {
_local7 = _local4.readUnsignedShort();
_local8 = _local4.readString();
_local2[_local7] = _local8;
};
return (_local2);
}
private static function shiftDataPosToShapeRecord(_arg1:Data, _arg2:uint):void{
_arg1.readUnsignedShort();
_arg1.readRect();
if (_arg2 == TagTypes.DEFINE_SHAPE4){
_arg1.readRect();
_arg1.readUBits(5);
_arg1.readUBits(1);
_arg1.readUBits(1);
_arg1.readUBits(1);
};
}
public static function extractFromLibrary(_arg1:ByteArray, _arg2:Array):void{
var swf:SWFParser;
var classes:Object;
var sprites:Array;
var i:int;
var l:int;
var placeTags:Array;
var defineShape:Tag;
var spriteId:uint;
var bytes = _arg1;
var ids = _arg2;
try {
swf = new SWFParser(bytes);
classes = parseClassIdTable(swf);
sprites = swf.parseTags([TagTypes.DEFINE_SPRITE], true).filter(function (_arg1:Tag, ... _args):Boolean{
var _local3:* = _arg1.data.readUnsignedShort();
_arg1.data.position = (_arg1.data.position - 2);
return (!((ids.indexOf(classes[_local3]) == -1)));
});
i = -1;
l = sprites.length;
while ((i = (i + 1)), (i + 1) < l) {
sprites[i].data.readUnsignedInt();
placeTags = parsePlacetags(swf.parseTags([TagTypes.PLACE_OBJECT, TagTypes.PLACE_OBJECT2, TagTypes.PLACE_OBJECT3], true, 1, sprites[i].data));
defineShape = getShapeFromPlaceTags(swf, placeTags);
if (defineShape){
sprites[i].data.position = 0;
spriteId = sprites[i].data.readUnsignedShort();
defineShape.data.position = 0;
shiftDataPosToShapeRecord(defineShape.data, defineShape.type);
if (!_library[classes[spriteId]]){
_library[classes[spriteId]] = new ShapeRecord(defineShape.data, defineShape.type);
} else {
trace((("WARNING: vector shape with id " + classes[spriteId]) + " already exists. skipping."));
};
};
};
} catch(err:Error) {
trace("**************************************************");
trace("** Error: unable to extract vectors from swf bytes");
trace(err.getStackTrace());
trace("**************************************************");
};
}
public static function extractFromStage(_arg1:ByteArray, _arg2:String):void{
var swf:SWFParser;
var placeTags:Array;
var defineShape:Tag;
var bytes = _arg1;
var id = _arg2;
try {
swf = new SWFParser(bytes);
placeTags = parsePlacetags(swf.parseTags([TagTypes.PLACE_OBJECT, TagTypes.PLACE_OBJECT2, TagTypes.PLACE_OBJECT3], true, 1));
defineShape = getShapeFromPlaceTags(swf, placeTags);
if (defineShape){
defineShape.data.position = 0;
shiftDataPosToShapeRecord(defineShape.data, defineShape.type);
if (!_library[id]){
_library[id] = new ShapeRecord(defineShape.data, defineShape.type);
} else {
trace((("WARNING: vector shape with id " + id) + " already exists, skipping."));
};
} else {
throw (new Error("no shapes found"));
};
} catch(err:Error) {
trace("**************************************************");
trace("** Error: unable to extract vectors from swf bytes");
trace(err.getStackTrace());
trace("**************************************************");
};
}
public static function getPoints(_arg1:String, _arg2:Number=1):Array{
if (_library[_arg1]){
return (ShapeRecord.getPoints(_library[_arg1], _arg2));
};
trace((("ERROR: missing " + _arg1) + " vector"));
return (null);
}
public static function get library():Object{
return (_library);
}
}
}//package wumedia.vector
Section 147
//CBinDataClassLoader (VX.Data.CBinDataClassLoader)
package VX.Data {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class CBinDataClassLoader {
private var ClassLoader:Loader;
private var OnCompleteProcessingFunc:Function;
public function CBinDataClassLoader(_arg1:ByteArray, _arg2:Function){
OnCompleteProcessingFunc = _arg2;
ClassLoader = new Loader();
ClassLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, OnComplete, false, 0, true);
ClassLoader.loadBytes(_arg1);
}
public function GetClass(_arg1:String):Class{
return ((ClassLoader.contentLoaderInfo.applicationDomain.getDefinition(_arg1) as Class));
}
private function OnComplete(_arg1:Event):void{
ClassLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, OnComplete);
OnCompleteProcessingFunc();
}
}
}//package VX.Data
Section 148
//CBinLoader (VX.Data.CBinLoader)
package VX.Data {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class CBinLoader {
private var Ldr:URLLoader;
private var FuncLoad:Function;
private var file:String;
private var FuncComplete:Function;
public function CBinLoader(_arg1:String, _arg2:Function, _arg3:Function=null){
var _local4:URLRequest;
super();
if (((_arg1) && (!((_arg2 == null))))){
file = _arg1;
FuncComplete = _arg2;
FuncLoad = _arg3;
_local4 = new URLRequest(_arg1);
Ldr = new URLLoader(_local4);
Ldr.dataFormat = URLLoaderDataFormat.BINARY;
Ldr.addEventListener(Event.COMPLETE, OnComplete, false, 0, true);
if (FuncLoad != null){
Ldr.addEventListener(ProgressEvent.PROGRESS, OnLoad);
};
};
}
private function OnLoad(_arg1:ProgressEvent):void{
FuncLoad(_arg1.bytesLoaded, _arg1.bytesTotal);
}
private function OnComplete(_arg1:Event):void{
Ldr.removeEventListener(Event.COMPLETE, OnComplete);
if (FuncLoad != null){
Ldr.removeEventListener(ProgressEvent.PROGRESS, OnLoad);
};
FuncComplete((Ldr.data as ByteArray));
}
}
}//package VX.Data
Section 149
//CFunctions (VX.Data.CFunctions)
package VX.Data {
public class CFunctions {
private static var UId:int = 0;
public static function FSqr010(_arg1:Number):Number{
_arg1 = Math.min(Math.max(0, _arg1), 1);
_arg1 = ((2 * _arg1) - 1);
return ((1 - (_arg1 * _arg1)));
}
public static function FSqr01(_arg1:Number):Number{
_arg1 = Math.min(Math.max(0, _arg1), 1);
if (_arg1 < 0.5){
return (((2 * _arg1) * _arg1));
};
return ((1 - ((2 * (1 - _arg1)) * (1 - _arg1))));
}
public static function FExp01(_arg1:Number):Number{
return ((1 - (Math.cos((((5 * Math.PI) * _arg1) * _arg1)) * Math.exp((-7 * _arg1)))));
}
public static function GetUId():int{
return (UId++);
}
public static function FExp01_Once(_arg1:Number):Number{
return ((1 - (Math.cos((Math.PI * _arg1)) * Math.exp((-3 * _arg1)))));
}
}
}//package VX.Data
Section 150
//CXmlData (VX.Data.CXmlData)
package VX.Data {
import flash.xml.*;
import flash.utils.*;
public class CXmlData {
private var FuncLoad:Function;
private var Data:XML;
private var FuncComplete:Function;
private var DataLoader:CBinLoader;
public function CXmlData(_arg1:String, _arg2:Function, _arg3:Function=null){
if (((_arg1) && (!((_arg2 == null))))){
DataLoader = new CBinLoader(_arg1, OnComplete, OnLoad);
FuncComplete = _arg2;
FuncLoad = _arg3;
};
}
public function getData():XML{
return (Data);
}
private function OnLoad(_arg1:uint, _arg2:uint):void{
if (FuncLoad != null){
FuncLoad(_arg1, _arg2);
};
}
private function OnComplete(_arg1:ByteArray):void{
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
var _local3:XML = XML(_arg1);
Data = _local3;
_local2.parseXML(_local3.toXMLString());
FuncComplete(_local2);
}
public static function LoadBinXmlData(_arg1:ByteArray, _arg2:Function):void{
var _local3:XMLDocument = new XMLDocument();
_local3.ignoreWhite = true;
var _local4:XML = XML(_arg1);
_local3.parseXML(_local4.toXMLString());
_arg2(_local3);
}
}
}//package VX.Data
Section 151
//CList (VX.DataStruct.CList)
package VX.DataStruct {
public class CList {
private var Head:CListItem;
private var Tail:CListItem;
public function CList(){
Head = null;
Tail = null;
}
public function Add(_arg1:Object):CListItem{
var _local2:CListItem = new CListItem();
_local2.Prev = Tail;
_local2.Next = null;
_local2.Item = _arg1;
if (Tail == null){
Head = _local2;
Tail = _local2;
} else {
Tail.Next = _local2;
Tail = _local2;
};
return (_local2);
}
public function AddListItem(_arg1:CListItem):void{
_arg1.Prev = Tail;
_arg1.Next = null;
if (Tail == null){
Head = _arg1;
Tail = _arg1;
} else {
Tail.Next = _arg1;
Tail = _arg1;
};
}
public function Remove(_arg1:Object):void{
var _local2:CListItem = Head;
while (_local2 != null) {
if (_local2.Item == _arg1){
RemoveListItem(_local2);
return;
};
_local2 = _local2.Next;
};
}
public function GetByIndex(_arg1:int):CListItem{
var _local2:CListItem = Head;
while (((_local2) && ((_arg1 >= 0)))) {
if (_arg1 == 0){
return (_local2);
};
_arg1--;
_local2 = _local2.Next;
};
return (null);
}
public function GetHead():CListItem{
return (Head);
}
public function RemoveListItem(_arg1:CListItem):void{
if (_arg1){
if (_arg1.Prev != null){
_arg1.Prev.Next = _arg1.Next;
} else {
Head = _arg1.Next;
};
if (_arg1.Next != null){
_arg1.Next.Prev = _arg1.Prev;
} else {
Tail = _arg1.Prev;
};
};
}
public function Reset():void{
Head = null;
Tail = null;
}
}
}//package VX.DataStruct
Section 152
//CListItem (VX.DataStruct.CListItem)
package VX.DataStruct {
public class CListItem {
public var Prev:CListItem;
public var Item:Object;
public var Next:CListItem;
}
}//package VX.DataStruct
Section 153
//CKeyboard (VX.Input.CKeyboard)
package VX.Input {
import flash.ui.*;
public class CKeyboard {
public var Plus:Boolean;
public var Down:Boolean;
public var Space:Boolean;
public var Left:Boolean;
public var Time:Number;
public var Minus:Boolean;
public var Up:Boolean;
public var Right:Boolean;
public function CKeyboard(){
Reset();
}
public function Reset():void{
Left = false;
Right = false;
Up = false;
Down = false;
Space = false;
Plus = false;
Minus = false;
}
public function SetKey(_arg1:uint, _arg2:Boolean):Boolean{
switch (_arg1){
case Keyboard.LEFT:
if (Left != _arg2){
Left = _arg2;
return (true);
};
break;
case Keyboard.UP:
if (Up != _arg2){
Up = _arg2;
return (true);
};
break;
case Keyboard.RIGHT:
if (Right != _arg2){
Right = _arg2;
return (true);
};
break;
case Keyboard.DOWN:
if (Down != _arg2){
Down = _arg2;
return (true);
};
break;
case Keyboard.SPACE:
if (Space != _arg2){
Space = _arg2;
return (true);
};
break;
case Keyboard.NUMPAD_ADD:
if (Plus != _arg2){
Plus = _arg2;
return (true);
};
break;
case Keyboard.NUMPAD_DECIMAL:
if (Minus != _arg2){
Minus = _arg2;
return (true);
};
break;
default:
break;
};
return (false);
}
public function Read(_arg1:Object):void{
Left = _arg1.Left;
Right = _arg1.Right;
Up = _arg1.Up;
Down = _arg1.Down;
Space = _arg1.Space;
Time = _arg1.Time;
Plus = _arg1.Plus;
Minus = _arg1.Minus;
}
public function Write(_arg1:Object):void{
_arg1.Left = Left;
_arg1.Right = Right;
_arg1.Up = Up;
_arg1.Down = Down;
_arg1.Space = Space;
_arg1.Time = Time;
_arg1.Plus = Plus;
_arg1.Minus = Minus;
}
}
}//package VX.Input
Section 154
//CSound (VX.Sound.CSound)
package VX.Sound {
import flash.events.*;
import VX.DataStruct.*;
import flash.media.*;
import flash.net.*;
public class CSound {
private var Loaded:Boolean;
private var OnLoadedFuncs:CList;
private var SndProp:Sound;
public function CSound(){
OnLoadedFuncs = new CList();
}
public function RemoveOnLoadFuncItem(_arg1:CListItem):void{
OnLoadedFuncs.RemoveListItem(_arg1);
}
public function get Snd():Sound{
if (Loaded){
return (SndProp);
};
return (null);
}
public function AddOnLoadFunc(_arg1:Function):CListItem{
if (Loaded){
_arg1();
return (null);
};
return (OnLoadedFuncs.Add(_arg1));
}
public function InitPath(_arg1:String):void{
SndProp = new Sound(new URLRequest(_arg1));
SndProp.addEventListener(Event.COMPLETE, OnSoundLoaded, false, 0, true);
Loaded = false;
}
private function OnSoundLoaded(_arg1:Event):void{
SndProp.removeEventListener(Event.COMPLETE, OnSoundLoaded);
Loaded = true;
var _local2:CListItem = OnLoadedFuncs.GetHead();
while (_local2) {
(_local2.Item as Function)();
_local2 = _local2.Next;
};
OnLoadedFuncs.Reset();
}
public function InitSound(_arg1:Sound):void{
SndProp = _arg1;
Loaded = true;
}
public static function CreateInitPath(_arg1:String):CSound{
var _local2:CSound;
_local2 = new (CSound);
_local2.InitPath(_arg1);
return (_local2);
}
public static function CreateInitSound(_arg1:Sound):CSound{
var _local2:CSound;
_local2 = new (CSound);
_local2.InitSound(_arg1);
return (_local2);
}
public static function CreateInitSound2(_arg1:String, _arg2:Object):CSound{
var _local3:CSound;
_local3 = new (CSound);
var _local4:Sound = new (_arg2.GetClass(_arg1));
_local3.InitSound(_local4);
return (_local3);
}
}
}//package VX.Sound
Section 155
//CSoundChannel (VX.Sound.CSoundChannel)
package VX.Sound {
import flash.events.*;
import flash.utils.*;
import VX.DataStruct.*;
import flash.media.*;
public class CSoundChannel implements ISoundChannel {
private var SndChannel:SoundChannel;
private var Snd:CSound;
private var OnStopFuncs:CList;
private var PausedProp:Boolean;
private var ExternalPauseProp:Boolean;
private var TimeStamp:Number;
private var ChannelItem:CListItem;
private var Looped:Boolean;
private var SndTransform:SoundTransform;
private var Channels:CList;
private var VolumeMul:Number;
private var Pos:Number;
private var VolumeProp:Number;
private var OnLoadFuncItem:CListItem;
public function CSoundChannel(_arg1:CList, _arg2:Boolean, _arg3:CSound, _arg4:Number, _arg5:Number, _arg6:Boolean){
TimeStamp = getTimer();
Pos = 0;
Channels = _arg1;
Looped = _arg2;
Snd = _arg3;
VolumeProp = _arg4;
VolumeMul = _arg5;
ExternalPause = _arg6;
PausedProp = false;
SndChannel = null;
OnStopFuncs = new CList();
SndTransform = new SoundTransform((VolumeProp * VolumeMul));
OnLoadFuncItem = null;
ChannelItem = Channels.Add(this);
if (Snd.Snd){
UpdatePauseState();
} else {
OnLoadFuncItem = Snd.AddOnLoadFunc(OnSndLoad);
};
}
public function set Volume(_arg1:Number):void{
if (VolumeProp != _arg1){
VolumeProp = _arg1;
Update(VolumeMul);
};
}
private function UpdatePauseState():void{
var _local1:Number = getTimer();
var _local2:Number = (_local1 - TimeStamp);
TimeStamp = _local1;
if (((!(PausedProp)) && (!(ExternalPauseProp)))){
if (!Snd.Snd){
Pos = (Pos + _local2);
} else {
Play();
};
} else {
Pause();
};
}
public function get ExternalPause():Boolean{
return (ExternalPauseProp);
}
private function OnComplete(_arg1:Event):void{
if (Looped){
SndChannel.removeEventListener(Event.SOUND_COMPLETE, OnComplete);
SndChannel = null;
Pos = 0;
Play();
} else {
Stop();
};
}
private function Play():void{
if (Snd.Snd){
if ((((Pos < Snd.Snd.length)) || (Looped))){
if (((!(PausedProp)) && (!(ExternalPauseProp)))){
Pos = (Pos - (Math.floor((Pos / Snd.Snd.length)) * Snd.Snd.length));
SndChannel = Snd.Snd.play(Pos, 0, SndTransform);
if (SndChannel){
SndChannel.addEventListener(Event.SOUND_COMPLETE, OnComplete, false, 0, true);
} else {
Stop();
};
};
} else {
Stop();
};
};
}
public function AddOnEndFunc(_arg1:Function):void{
OnStopFuncs.Add(_arg1);
}
private function Pause():void{
if (SndChannel){
Pos = SndChannel.position;
SndChannel.stop();
SndChannel.removeEventListener(Event.SOUND_COMPLETE, OnComplete);
SndChannel = null;
};
}
public function get Paused():Boolean{
return (PausedProp);
}
public function get Volume():Number{
return (VolumeProp);
}
public function Stop():void{
if (OnLoadFuncItem){
Snd.RemoveOnLoadFuncItem(OnLoadFuncItem);
OnLoadFuncItem = null;
};
if (SndChannel){
SndChannel.stop();
SndChannel.removeEventListener(Event.SOUND_COMPLETE, OnComplete);
SndChannel = null;
};
var _local1:CListItem = OnStopFuncs.GetHead();
while (_local1) {
(_local1.Item as Function)();
_local1 = _local1.Next;
};
OnStopFuncs.Reset();
Channels.RemoveListItem(ChannelItem);
ChannelItem = null;
}
public function Update(_arg1:Number):void{
VolumeMul = _arg1;
SndTransform.volume = (VolumeProp * VolumeMul);
if (SndChannel){
SndChannel.soundTransform = SndTransform;
};
}
private function OnSndLoad():void{
OnLoadFuncItem = null;
UpdatePauseState();
}
public function set ExternalPause(_arg1:Boolean):void{
if (ExternalPauseProp != _arg1){
ExternalPauseProp = _arg1;
UpdatePauseState();
};
}
public function set Paused(_arg1:Boolean):void{
if (PausedProp != _arg1){
PausedProp = _arg1;
UpdatePauseState();
};
}
}
}//package VX.Sound
Section 156
//CSoundManager (VX.Sound.CSoundManager)
package VX.Sound {
import VX.DataStruct.*;
public class CSoundManager {
private var OnEndFunc:Function;
private var Channels:CList;
private var PausedProp:Boolean;
private var SoundChannel:CSoundChannel;
private var MuteProp:Boolean;
private var VolumeProp:Number;
public function CSoundManager(){
Channels = new CList();
super();
VolumeProp = 1;
MuteProp = false;
PausedProp = false;
}
public function get Volume():Number{
return (VolumeProp);
}
public function Play(_arg1:CSound, _arg2:Boolean, _arg3:Number):ISoundChannel{
var _local4:Number = VolumeProp;
if (MuteProp){
_local4 = 0;
};
SoundChannel = new CSoundChannel(Channels, _arg2, _arg1, _arg3, _local4, PausedProp);
return (SoundChannel);
}
private function Update():void{
var _local1:Number = VolumeProp;
if (MuteProp){
_local1 = 0;
};
var _local2:CListItem = Channels.GetHead();
while (_local2 != null) {
(_local2.Item as CSoundChannel).Update(_local1);
(_local2.Item as CSoundChannel).ExternalPause = PausedProp;
_local2 = _local2.Next;
};
}
public function set Paused(_arg1:Boolean):void{
if (PausedProp != _arg1){
PausedProp = _arg1;
Update();
};
}
public function get Paused():Boolean{
return (PausedProp);
}
public function set Mute(_arg1:Boolean):void{
if (MuteProp != _arg1){
MuteProp = _arg1;
Update();
};
}
public function Reset():void{
var _local2:CListItem;
var _local1:CListItem = Channels.GetHead();
while (_local1 != null) {
_local2 = _local1.Next;
(_local1.Item as CSoundChannel).Stop();
_local1 = _local2;
};
Channels.Reset();
}
public function get Mute():Boolean{
return (MuteProp);
}
public function set Volume(_arg1:Number):void{
if (VolumeProp != _arg1){
VolumeProp = _arg1;
};
Update();
}
public function AddOnEndFunc(_arg1:Function):void{
SoundChannel.AddOnEndFunc(_arg1);
}
}
}//package VX.Sound
Section 157
//ISoundChannel (VX.Sound.ISoundChannel)
package VX.Sound {
public interface ISoundChannel {
function Stop():void;
function set Volume(_arg1:Number):void;
function get Volume():Number;
function set Paused(_arg1:Boolean):void;
function get Paused():Boolean;
function AddOnEndFunc(_arg1:Function):void;
}
}//package VX.Sound
Section 158
//CModule (VX.UI.CModule)
package VX.UI {
import flash.display.*;
import VX.DataStruct.*;
import VX.Data.*;
public class CModule extends Sprite {
public var ModuleManager:CModuleManager;
public var PauseCounter:int;
public var ManagerItem:CListItem;
public var IsLive:Boolean;
public var PauseOther:Boolean;
public var IsAdd:Boolean;
public var Ani:MovieClip;
public static const DESTROY:int = CFunctions.GetUId();
public function Add(_arg1:CModule, _arg2:Boolean=false, _arg3:int=-1):void{
ModuleManager.Add(_arg1, _arg2, _arg3);
}
public function RemoveSelf():void{
ModuleManager.Remove(this);
}
public function UpdateInterpolated(_arg1:Number):void{
}
public function SendMessageExclude(_arg1:int, _arg2:Object):int{
return (ModuleManager.SendMessage(_arg1, _arg2, this));
}
public function Pause(_arg1:Boolean):void{
}
public function Behind(_arg1:CModule):void{
ModuleManager.Behind(this, _arg1);
}
public function Remove():void{
}
public function doShow():void{
Ani.visible = true;
}
public function Update():void{
}
public function doHide():void{
Ani.visible = false;
}
public function Init():void{
}
public function get ChildIndex():int{
return (ModuleManager.GetChildIndex(this));
}
public function ToTop():void{
ModuleManager.ToTop(this);
}
public function ProcessMessage(_arg1:int, _arg2:Object):int{
return (0);
}
}
}//package VX.UI
Section 159
//CModuleManager (VX.UI.CModuleManager)
package VX.UI {
import flash.display.*;
import flash.utils.*;
import VX.DataStruct.*;
public class CModuleManager extends Sprite {
private var LastTime:Number;
private var Modules:CList;
private var UpdateTime:Number;
private var FirstUpdate:Boolean;// = true
private var NeedUpdate:Number;
private static var CurrentFPSProp:Number = 0;
private static var UpSProp:Number;
public function CModuleManager(_arg1:Number){
Modules = new CList();
super();
UpSProp = _arg1;
UpdateTime = (1 / UpSProp);
}
public function Add(_arg1:CModule, _arg2:Boolean, _arg3:int=-1):void{
var _local4:CListItem;
if (_arg2){
_local4 = Modules.GetHead();
while (_local4 != null) {
_local4.Item.PauseCounter++;
if (_local4.Item.PauseCounter == 1){
_local4.Item.Pause(true);
};
_local4 = _local4.Next;
};
_arg1.PauseOther = true;
} else {
_arg1.PauseOther = false;
};
_arg1.ManagerItem = Modules.Add(_arg1);
_arg1.PauseCounter = 0;
_arg1.ModuleManager = this;
_arg1.IsLive = true;
if (_arg3 < 0){
addChild(_arg1);
} else {
addChildAt(_arg1, _arg3);
};
_arg1.Init();
}
public function Remove(_arg1:CModule):void{
var _local2:CListItem;
if (_arg1.IsLive){
_arg1.IsLive = false;
Modules.RemoveListItem(_arg1.ManagerItem);
_arg1.Remove();
removeChild(_arg1);
if (_arg1.PauseOther){
_local2 = Modules.GetHead();
while (_local2 != null) {
if (_local2.Item.PauseCounter > 0){
_local2.Item.PauseCounter--;
if (_local2.Item.PauseCounter == 0){
_local2.Item.Pause(false);
};
};
_local2 = _local2.Next;
};
};
};
}
public function Update():void{
var _local3:CListItem;
var _local5:Number;
var _local1:Number = (getTimer() / 1000);
var _local2:Number = (_local1 - LastTime);
if (((((FirstUpdate) || ((_local2 < 0)))) || ((_local2 > 1)))){
LastTime = _local1;
NeedUpdate = 0;
_local2 = (_local1 - LastTime);
};
if (_local2 > 0){
_local5 = (1 / _local2);
CurrentFPSProp = (((_local5 - CurrentFPSProp) * 0.03) + CurrentFPSProp);
};
NeedUpdate = (NeedUpdate + _local2);
while (NeedUpdate > 0) {
_local3 = Modules.GetHead();
while (_local3 != null) {
_local3.Item.Update();
_local3 = _local3.Next;
};
NeedUpdate = (NeedUpdate - UpdateTime);
};
var _local4:Number = (1 + (NeedUpdate / UpdateTime));
_local3 = Modules.GetHead();
while (_local3 != null) {
_local3.Item.UpdateInterpolated(_local4);
_local3 = _local3.Next;
};
LastTime = _local1;
FirstUpdate = false;
}
public function SendMessage(_arg1:int, _arg2:Object, _arg3:CModule):int{
var _local4:CListItem;
var _local5:int;
_local4 = Modules.GetHead();
while (_local4 != null) {
if (_arg3 != _local4.Item){
_local5 = (_local5 | _local4.Item.ProcessMessage(_arg1, _arg2));
};
_local4 = _local4.Next;
};
return (_local5);
}
public function ToTop(_arg1:CModule):void{
var _local2:int = getChildIndex(_arg1);
if (_local2 != -1){
removeChild(_arg1);
addChild(_arg1);
};
}
public function GetChildIndex(_arg1:CModule):int{
return (getChildIndex(_arg1));
}
public function Behind(_arg1:CModule, _arg2:CModule):void{
var _local3:int = getChildIndex(_arg1);
var _local4:int = getChildIndex(_arg2);
if (((!((_local3 == -1))) && (!((_local4 == -1))))){
removeChild(_arg2);
addChildAt(_arg2, _local3);
};
}
public static function get CurrentFPS():Number{
return (CurrentFPSProp);
}
public static function get UPS():Number{
return (UpSProp);
}
}
}//package VX.UI
Section 160
//CUtil (VX.Utils.CUtil)
package VX.Utils {
import flash.geom.*;
import flash.utils.*;
public class CUtil {
public static function getFirstSymbols(_arg1:String, _arg2:int):String{
return (_arg1.substr(0, _arg2));
}
public static function random(_arg1:Number, _arg2:Number=0, _arg3:Number=1):Number{
var _local6:Number;
if (_arg1 > _arg2){
_local6 = _arg1;
_arg1 = _arg2;
_arg2 = _local6;
};
var _local4:Number = ((_arg2 - _arg1) + (1 * _arg3));
var _local5:Number = (Math.random() * _local4);
_local5 = (_local5 + _arg1);
return (floor(_local5, _arg3));
}
public static function isInBar(_arg1:Rectangle, _arg2:Number, _arg3:Number, _arg4:Number=0):Boolean{
if ((((((((_arg2 >= (_arg1.x + _arg4))) && ((_arg3 >= (_arg1.y + _arg4))))) && ((_arg2 <= ((_arg1.x + _arg1.width) - _arg4))))) && ((_arg3 <= ((_arg1.y + _arg1.height) - _arg4))))){
return (true);
};
return (false);
}
public static function getAboveOne(_arg1:String):String{
return (_arg1.substr(1, (_arg1.length - 1)));
}
public static function GetIndexDataByName(_arg1:Array, _arg2:String):int{
var _local4:String;
var _local3:int;
while (_local3 < _arg1.length) {
_local4 = _arg1[_local3].Name.substr(0, _arg2.length);
if (_local4 == _arg2){
return (_local3);
};
_local3++;
};
return (-1);
}
public static function CheckCloneArray(_arg1:Array):Array{
if (((!((_arg1 == null))) && ((_arg1.length > 0)))){
return (clone(_arg1));
};
return (new Array());
}
public static function floor(_arg1:Number, _arg2:Number=1):Number{
return ((Math.floor((_arg1 / _arg2)) * _arg2));
}
public static function CheckDataForMaxRow(_arg1:Array, _arg2:int):void{
var _local3:int = (_arg1.length - _arg2);
if (_local3 > 0){
_arg1.splice(_arg2, _local3);
};
}
public static function getFirstSymbol(_arg1:String):String{
return (_arg1.substr((_arg1.length - 1), 1));
}
public static function IsNotInArr(_arg1:Array, _arg2:int):Boolean{
var _local3:int;
while (_local3 < _arg1.length) {
if (_arg2 == _arg1[_local3]){
return (false);
};
_local3++;
};
return (true);
}
public static function getStr_1(_arg1:String):String{
return (_arg1.substr(0, (_arg1.length - 1)));
}
public static function GetIndexDataById(_arg1:Array, _arg2:uint):int{
var _local3:int;
while (_local3 < _arg1.length) {
if (_arg1[_local3].uid == _arg2){
return (_local3);
};
_local3++;
};
return (-1);
}
public static function getNumber2(_arg1:String, _arg2:String):String{
return (_arg1.substr(_arg2.length, (_arg1.length - _arg2.length)));
}
public static function getLastSymbol(_arg1:String):String{
return (_arg1.substr((_arg1.length - 1), 1));
}
public static function clone(_arg1:Object){
var _local2:ByteArray = new ByteArray();
_local2.writeObject(_arg1);
_local2.position = 0;
return (_local2.readObject());
}
public static function GetQuotesString(_arg1:String):String{
return ((("\"" + _arg1) + "\""));
}
public static function getNumber(_arg1:String):String{
return (_arg1.substr((_arg1.length - 1), 1));
}
}
}//package VX.Utils
Section 161
//CPreloader (CPreloader)
package {
import flash.events.*;
import flash.display.*;
import lib.*;
import flash.net.*;
import flash.ui.*;
public dynamic class CPreloader extends MovieClip {
private var percent:int;
public var ProgressBar:MovieClip;
private var isFirst:Boolean;// = true
public var Inited:Boolean;// = false
private var isFull:Boolean;// = false
public var Ani:MovieClip;
public static var PreloaderClass:Class = CPreloader_PreloaderClass;
public static var MAIN_CLASS:String = "UrbanStunts";
public function CPreloader(){
Ani = new PreloaderClass();
Ani.gotoAndStop(1);
ProgressBar = (Ani.getChildByName("progressBar") as MovieClip);
if (ProgressBar){
ProgressBar.gotoAndStop(1);
};
addChild(Ani);
InitContextMenu();
addEventListener(Event.ENTER_FRAME, Update, false, 0, true);
}
public function Update(_arg1:Event):void{
var _local4:UrbanStunts;
if (((!(Inited)) && (stage))){
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.frameRate = 15;
Inited = true;
};
var _local2:int = loaderInfo.bytesLoaded;
var _local3:int = loaderInfo.bytesTotal;
percent = int(((_local2 * 100) / _local3));
if (percent > ProgressBar.currentFrame){
ProgressBar.nextFrame();
} else {
_local4 = new UrbanStunts();
addChild((_local4 as DisplayObject));
Ani.gotoAndStop(2);
removeEventListener(Event.ENTER_FRAME, Update);
removeChild(Ani);
};
}
private function playMore(_arg1:ContextMenuEvent):void{
navigateToURL(new URLRequest(CGlobal.moreGames_link), "_blank");
}
public function InitContextMenu():void{
var _local1:ContextMenu = new ContextMenu();
_local1.hideBuiltInItems();
var _local2:ContextMenuItem = new ContextMenuItem("Play More Games");
_local2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, playMore);
_local1.customItems.push(_local2);
this.contextMenu = _local1;
}
}
}//package
Section 162
//CPreloader_PreloaderClass (CPreloader_PreloaderClass)
package {
import mx.core.*;
import flash.display.*;
public class CPreloader_PreloaderClass extends MovieClipAsset {
public var progressBar:DisplayObject;
}
}//package
Section 163
//UrbanStunts (UrbanStunts)
package {
import flash.events.*;
import flash.display.*;
import flash.xml.*;
import VX.UI.*;
import lib.*;
import VX.Data.*;
import lib.Params.*;
import mochi.as3.*;
public dynamic class UrbanStunts extends Sprite {
public var bikesPathXml:String;// = "bikes.xml"
private var ModuleManager:CModuleManager;
public var OptionXml:Class;
public var BikesXml:Class;
public var ShapesXml:Class;
private var OptionXmlData:CXmlData;
public var shapesPathXml:String;// = "shapes.xml"
public var optionPathXml:String;// = "options.xml"
public static const SFX_VOLUME:Number = 0.2;
public static const START_VOLUME:Number = 0.4;
public static const SFX_VOLUME2:Number = 1;
public static var Resources:Class = UrbanStunts_Resources;
private static var UPS:int;
public function UrbanStunts(){
OptionXml = UrbanStunts_OptionXml;
BikesXml = UrbanStunts_BikesXml;
ShapesXml = UrbanStunts_ShapesXml;
super();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
}
private function onOptionXmlLoaded(_arg1:XMLDocument):void{
CGetDataXml.GetGameOptions(_arg1);
CXmlData.LoadBinXmlData(new BikesXml(), onBikesXmlLoaded);
}
private function OnClassesLoaded():void{
if (!CGlobal.Debug){
MochiServices.connect("2dbf452df11a435c", root);
};
addEventListener(Event.ENTER_FRAME, Update, false, 0, true);
ModuleManager = new CModuleManager(UPS);
addChild(ModuleManager);
ModuleManager.Add(new CMain(), false);
}
private function onBikesXmlLoaded(_arg1:XMLDocument):void{
CGetDataXml.GetBikesOptions(_arg1);
CXmlData.LoadBinXmlData(new ShapesXml(), onShapesXmlLoaded);
}
private function onShapesXmlLoaded(_arg1:XMLDocument):void{
CGetDataXml.GetShapes(_arg1);
CGlobal.Classes = new CBinDataClassLoader(new Resources(), OnClassesLoaded);
}
public function Update(_arg1:Event):void{
ModuleManager.Update();
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.frameRate = (UPS = 50);
CXmlData.LoadBinXmlData(new OptionXml(), onOptionXmlLoaded);
}
}
}//package
Section 164
//UrbanStunts_BikesXml (UrbanStunts_BikesXml)
package {
import mx.core.*;
public class UrbanStunts_BikesXml extends ByteArrayAsset {
}
}//package
Section 165
//UrbanStunts_OptionXml (UrbanStunts_OptionXml)
package {
import mx.core.*;
public class UrbanStunts_OptionXml extends ByteArrayAsset {
}
}//package
Section 166
//UrbanStunts_Resources (UrbanStunts_Resources)
package {
import mx.core.*;
public class UrbanStunts_Resources extends ByteArrayAsset {
}
}//package
Section 167
//UrbanStunts_ShapesXml (UrbanStunts_ShapesXml)
package {
import mx.core.*;
public class UrbanStunts_ShapesXml extends ByteArrayAsset {
}
}//package