Section 1
//height_meter_48 (achieveGame_fla.height_meter_48)
package achieveGame_fla {
import flash.display.*;
public dynamic class height_meter_48 extends MovieClip {
public var HEIGHT_METER_BUBBLES:MovieClip;
}
}//package achieveGame_fla
Section 2
//loaderingbar2copy_2 (achieveGame_fla.loaderingbar2copy_2)
package achieveGame_fla {
import flash.display.*;
public dynamic class loaderingbar2copy_2 extends MovieClip {
public var mainLoadingBar_mc:MovieClip;
public function loaderingbar2copy_2(){
addFrameScript(11, frame12);
}
function frame12(){
gotoAndPlay(1);
}
}
}//package achieveGame_fla
Section 3
//loading_5 (achieveGame_fla.loading_5)
package achieveGame_fla {
import flash.display.*;
public dynamic class loading_5 extends MovieClip {
public function loading_5(){
addFrameScript(29, frame30);
}
function frame30(){
gotoAndPlay(1);
}
}
}//package achieveGame_fla
Section 4
//preloader_1 (achieveGame_fla.preloader_1)
package achieveGame_fla {
import flash.display.*;
import flash.text.*;
public dynamic class preloader_1 extends MovieClip {
public var done_txt:TextField;
public var parentLoader_mc:MovieClip;
public function preloader_1(){
addFrameScript(1, frame2);
}
function frame2(){
stop();
}
}
}//package achieveGame_fla
Section 5
//scorePopUpTweenContainer_37 (achieveGame_fla.scorePopUpTweenContainer_37)
package achieveGame_fla {
import flash.display.*;
import flash.text.*;
public dynamic class scorePopUpTweenContainer_37 extends MovieClip {
public var _msg:TextField;
}
}//package achieveGame_fla
Section 6
//sfx_preloader_7 (achieveGame_fla.sfx_preloader_7)
package achieveGame_fla {
import flash.display.*;
public dynamic class sfx_preloader_7 extends MovieClip {
public function sfx_preloader_7(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package achieveGame_fla
Section 7
//AnimationEvent (base.animation.AnimationEvent)
package base.animation {
import flash.display.*;
import flash.events.*;
public class AnimationEvent extends Event {
private var _mc:MovieClip;
public static const COMPLETE:String = "complete";
public function AnimationEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:MovieClip=null){
super(_arg1, _arg2, _arg3);
_mc = _arg4;
}
public function getMovieClip():MovieClip{
return (_mc);
}
}
}//package base.animation
Section 8
//SpriteAnimator (base.animation.SpriteAnimator)
package base.animation {
import flash.display.*;
import flash.events.*;
public class SpriteAnimator extends EventDispatcher {
public var _loopAnim:Boolean;
public var _startFrame:int;
public var _isPlayingBackwards:Boolean;
public var _animateTimer:Number;
public var _framerate:Number;
var _gameContext:GameEntry;
public var _c:int;
public var _animate:Boolean;
public var _endFrame:int;
var _mc:MovieClip;
public var _lastFrame:int;
public function SpriteAnimator(_arg1:GameEntry, _arg2:MovieClip){
_gameContext = _arg1;
_mc = _arg2;
_animateTimer = 0;
}
public function reverseAnimation():void{
var _local1:*;
var _local2:*;
_local1 = _endFrame;
_local2 = _startFrame;
_startFrame = _local1;
_endFrame = _local2;
_isPlayingBackwards = ((_startFrame)>_endFrame) ? true : false;
}
public function getCurrentFrame():int{
return (_mc.currentFrame);
}
public function doneAnimating():void{
if (_animate == false){
return;
};
_animate = false;
if (hasEventListener(AnimationEvent.COMPLETE)){
dispatchEvent(new AnimationEvent(AnimationEvent.COMPLETE, false, false, _mc));
};
}
public function getEndFrame():Number{
return (_endFrame);
}
public function setFramerate(_arg1:int):void{
_framerate = (1 / _arg1);
}
public function isAnimating():Boolean{
return (_animate);
}
public function moveToFrame(_arg1:int):void{
_mc.gotoAndStop(_arg1);
_lastFrame = _arg1;
}
public function getFramerate():Number{
return (_framerate);
}
public function startAnimating(_arg1:int, _arg2:int, _arg3:Boolean=false, _arg4:int=-1, _arg5:Number=32){
_c = ((_arg4)>-1) ? _arg4 : _arg1;
_startFrame = _arg1;
_endFrame = _arg2;
moveToFrame(_arg1);
_framerate = (1 / _arg5);
_loopAnim = _arg3;
_animate = true;
_animateTimer = _framerate;
_isPlayingBackwards = ((_startFrame)>_endFrame) ? true : false;
}
public function isLooping():Boolean{
return (_loopAnim);
}
public function getStartFrame():Number{
return (_startFrame);
}
public function animateSprite():int{
if (_animate == false){
return (1);
};
_animateTimer = (_animateTimer - _gameContext.getDT());
if (_animateTimer <= 0){
_animateTimer = _framerate;
if (_startFrame <= _endFrame){
_c++;
if (_c > _endFrame){
if (_loopAnim){
_c = _startFrame;
} else {
doneAnimating();
_c = _endFrame;
return (1);
};
};
} else {
_c--;
if (_c < _endFrame){
if (_loopAnim){
_c = _startFrame;
} else {
doneAnimating();
_c = _endFrame;
return (1);
};
};
};
moveToFrame(_c);
};
return (0);
}
}
}//package base.animation
Section 9
//SpriteEntityAnimator (base.animation.SpriteEntityAnimator)
package base.animation {
import base.display.*;
public class SpriteEntityAnimator {
var toAnimate:Array;
var toAdd:Array;
var toRemove:Array;
public function SpriteEntityAnimator(){
toAdd = new Array();
toAnimate = new Array();
toRemove = new Array();
}
public function addSpriteToAnimate(_arg1:SpriteEntity, _arg2:Object=null, _arg3:Function=null, _arg4:Array=null):void{
toAdd.push(new Array(_arg1, _arg2, _arg3, _arg4));
}
public function Update():void{
var _local1:int;
var _local2:SpriteEntity;
var _local3:int;
var _local4:Object;
var _local5:Function;
var _local6:Array;
if (toAdd.length > 0){
toAnimate = toAnimate.concat(toAdd);
toAdd = [];
};
_local1 = toAnimate.length;
if (_local1 < 1){
return;
};
_local2 = null;
toRemove = [];
while (_local1--) {
_local2 = (toAnimate[_local1][0] as SpriteEntity);
_local3 = _local2.animateSprite();
if (_local3 == 1){
_local4 = toAnimate[_local1][1];
if (_local4 != null){
_local5 = toAnimate[_local1][2];
_local6 = toAnimate[_local1][3];
_local5.apply(_local4, _local6);
};
toAnimate.splice(_local1, 1);
};
};
}
}
}//package base.animation
Section 10
//DisplayObjectFactory (base.display.DisplayObjectFactory)
package base.display {
import flash.display.*;
import flash.utils.*;
public class DisplayObjectFactory {
var _objectsIdle:Array;
var _objectsAll:Array;
var ClassReference:Class;
var _objectsActive:Array;
public function DisplayObjectFactory(){
_objectsAll = new Array();
_objectsIdle = new Array();
_objectsActive = new Array();
}
public function traceAllInventory():void{
var _local1:String;
var _local2:int;
_local1 = "All[";
_local2 = _objectsAll.length;
while (_local2--) {
_local1 = (_local1 + (_objectsAll[_local2] + ","));
};
_local1 = (_local1 + "]");
trace(_local1);
}
public function deleteInstance(_arg1:DisplayObject):void{
var _local2:int;
_local2 = -1;
_local2 = _objectsAll.indexOf(_arg1);
if (_local2 == -1){
return;
};
_objectsAll.splice(_local2, 1);
_local2 = _objectsIdle.indexOf(_arg1);
if (_local2 == -1){
return;
};
_objectsIdle.splice(_local2, 1);
_local2 = _objectsActive.indexOf(_arg1);
if (_local2 == -1){
return;
};
_objectsActive.splice(_local2, 1);
}
public function traceIdleInventory():void{
var _local1:String;
var _local2:int;
_local1 = "Idle[";
_local2 = _objectsIdle.length;
while (_local2--) {
_local1 = (_local1 + (_objectsIdle[_local2] + ","));
};
_local1 = (_local1 + "]");
trace(_local1);
}
public function returnInstance(_arg1:DisplayObject):void{
var _local2:int;
_local2 = _objectsActive.indexOf(_arg1);
if (_local2 == -1){
trace(("Error returning object " + _arg1));
return;
};
_objectsActive.splice(_local2, 1);
_objectsIdle.push(_arg1);
}
public function get objectsIdle():Array{
return (_objectsIdle);
}
public function get objectsAll():Array{
return (_objectsAll);
}
public function getSpriteInstance(_arg1:String):Sprite{
var _local2:Sprite;
var _local3:int;
var _local4:Class;
_local3 = _objectsIdle.length;
while (_local3--) {
_local2 = (_objectsIdle[_local3] as Sprite);
if (getQualifiedClassName(_local2) == _arg1){
_objectsIdle.splice(_local3, 1);
_objectsActive.push(_local2);
return (_local2);
};
};
_local4 = (getDefinitionByName(_arg1) as Class);
_local2 = (new (_local4) as Sprite);
_objectsAll.push(_local2);
_objectsActive.push(_local2);
return (_local2);
}
public function get objectsActive():Array{
return (_objectsActive);
}
public function getMovieClipInstance(_arg1:String):MovieClip{
var _local2:MovieClip;
var _local3:int;
var _local4:Class;
_local3 = _objectsIdle.length;
while (_local3--) {
_local2 = (_objectsIdle[_local3] as MovieClip);
if (getQualifiedClassName(_local2) == _arg1){
_objectsIdle.splice(_local3, 1);
_objectsActive.push(_local2);
return (_local2);
};
};
_local4 = (getDefinitionByName(_arg1) as Class);
_local2 = (new (_local4) as MovieClip);
_objectsAll.push(_local2);
_objectsActive.push(_local2);
return (_local2);
}
}
}//package base.display
Section 11
//GameCamera (base.display.GameCamera)
package base.display {
import flash.display.*;
import flash.geom.*;
public class GameCamera {
var startCamY:Number;
var shakeCounter:Number;// = 4
var scrollingFlats:Array;
var camera:Rectangle;
var truckSpeedX;// = 1
var truckSpeedY;// = 1
var YMIN:Number;
private var _isOnTargetX:Boolean;// = false
private var _isOnTargetY:Boolean;// = false
var numScrollingFlats:int;
var staticFlats:Array;
var YMAX:Number;
var gameContext:GameEntry;
var targOffsetX:Number;
var targOffsetY:Number;
var dobjFactory:DisplayObjectFactory;
var cameraShakeX:Number;// = 0
var cameraShakeY:Number;// = 0
var cameraWidth:Number;
var shakeDir:Number;// = -1
var cameraHeight:Number;
public var scrollFlatsWithCamera:Boolean;// = false
var isShaking:Boolean;
public var currCamX:Number;
public var currCamY:Number;
var targetToFollow:Object;
var mainStage:DisplayObject;
var shakeIntensity:Number;
var XMIN:Number;
var targCamX:Number;
public var XMAX:Number;
var startCamX:Number;
var shakeTime:Number;// = 4
public var shouldFollowTarget:Boolean;
var sceneOffsetX:Number;
var sceneOffsetY:Number;
var targCamY:Number;
public function GameCamera(_arg1:GameEntry, _arg2:DisplayObject, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number=0, _arg8:Number=0, _arg9:Number=0, _arg10:Number=0, _arg11:Number=0, _arg12:Number=0, _arg13:Boolean=false, _arg14:Object=null, _arg15:Number=0, _arg16:Number=0){
truckSpeedX = 1;
truckSpeedY = 1;
scrollFlatsWithCamera = false;
_isOnTargetX = false;
_isOnTargetY = false;
shakeTime = 4;
shakeCounter = 4;
shakeDir = -1;
cameraShakeY = 0;
cameraShakeX = 0;
super();
this.gameContext = _arg1;
dobjFactory = _arg1.getDisplayObjectFactory();
mainStage = _arg2;
sceneOffsetX = _arg11;
sceneOffsetY = _arg12;
currCamX = (startCamX = _arg3);
currCamY = (startCamY = _arg4);
camera = new Rectangle(_arg3, _arg4, _arg5, _arg6);
this.cameraWidth = _arg5;
this.cameraHeight = _arg6;
mainStage.scrollRect = camera;
this.shouldFollowTarget = _arg13;
this.targetToFollow = _arg14;
this.targOffsetX = _arg15;
this.targOffsetY = _arg16;
XMIN = _arg7;
XMAX = _arg8;
YMIN = _arg9;
YMAX = _arg10;
staticFlats = new Array();
scrollingFlats = new Array();
}
public function setTargetOffsetX(_arg1:Number):void{
targOffsetX = _arg1;
}
public function setTargetOffsetY(_arg1:Number):void{
targOffsetY = _arg1;
}
public function setCamToTarget(_arg1:Point):void{
var _local2:*;
var _local3:*;
camera.x = (camera.x - 6000);
currCamX = (currCamX - 6000);
targCamY = (targetToFollow.y + targOffsetY);
_local2 = (targCamY - currCamY);
_local3 = (currCamY + _local2);
currCamY = (_local3 + _arg1.y);
camera.y = (currCamY + sceneOffsetY);
mainStage.scrollRect = camera;
}
public function getTop():Number{
return (camera.top);
}
public function getBottom():Number{
return (camera.bottom);
}
public function setMinPosX(_arg1:Number):void{
XMIN = _arg1;
}
public function setMinPosY(_arg1:Number):void{
YMIN = _arg1;
}
public function setMaxPosX(_arg1:Number):void{
XMAX = _arg1;
}
public function setMaxPosY(_arg1:Number):void{
YMAX = _arg1;
}
public function reset():void{
currCamX = startCamX;
currCamY = startCamY;
Update();
}
public function updateScrollingFlats(_arg1:Number, _arg2:Number):void{
var _local3:int;
var _local4:Object;
var _local5:Number;
var _local6:Number;
_local3 = scrollingFlats.length;
while (_local3--) {
_local4 = scrollingFlats[_local3];
_arg1 = (_arg1 + _local4.camRect.x);
_local5 = ((_arg1 + _local4.offsetX) * _local4.camTruckX);
_local4.camRect.x = ((_local5)>=743) ? 0 : _local5;
_local6 = ((_arg2 + _local4.offsetY) * _local4.camTruckY);
_local4.camRect.y = ((_local6)<0) ? _local6 : 0;
_local4.flat.scrollRect = _local4.camRect;
};
}
public function getRight():Number{
return (camera.right);
}
public function setTruckSpeedX(_arg1:Number):void{
truckSpeedX = _arg1;
}
public function setTruckSpeedY(_arg1:Number):void{
truckSpeedY = _arg1;
}
public function getDistanceToTarget():Point{
var _local1:Point;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = new Point();
_local2 = (targetToFollow.x + targOffsetX);
_local3 = (targetToFollow.y + targOffsetY);
_local4 = (_local2 - currCamX);
_local5 = (_local3 - currCamY);
_local1.x = _local4;
_local1.y = _local5;
return (_local1);
}
public function getLeft():Number{
return (camera.left);
}
public function setTargetOffsetXY(_arg1:Number, _arg2:Number):void{
targOffsetX = _arg1;
targOffsetY = _arg2;
}
public function handleCameraShake():void{
var _local1:Number;
if (isShaking == false){
return;
};
shakeCounter++;
_local1 = 0;
if (shakeCounter < shakeTime){
_local1 = ((Math.random() * 2) + 2);
shakeDir = (shakeDir * -1);
cameraShakeY = (_local1 * shakeDir);
} else {
cameraShakeY = 0;
cameraShakeX = 0;
isShaking = false;
};
}
public function removeAllFlats():void{
var _local1:int;
var _local2:Object;
var _local3:Sprite;
var _local4:int;
var _local5:Sprite;
_local1 = scrollingFlats.length;
while (_local1--) {
_local2 = scrollingFlats[_local1];
_local3 = (_local2.flat as Sprite);
_local4 = 0;
while (_local4 < _local3.numChildren) {
_local5 = (_local3.getChildAt(_local4) as Sprite);
dobjFactory.returnInstance(_local5);
_local4++;
};
if (_local2.parent.contains(_local3)){
_local2.parent.removeChild(_local3);
};
};
scrollingFlats = [];
}
public function getCameraY():Number{
return (camera.y);
}
public function getCameraX():Number{
return (camera.x);
}
public function setTargetToFollow(_arg1:Object, _arg2:Number, _arg3:Number):void{
targetToFollow = _arg1;
targOffsetX = _arg2;
targOffsetY = _arg3;
shouldFollowTarget = true;
}
public function shakeCamera(_arg1:Number):void{
shakeIntensity = _arg1;
isShaking = true;
shakeTime = ((_arg1)==1) ? 10 : 20;
shakeCounter = 0;
}
public function snapToTarget():void{
}
public function Update():void{
var _local1:*;
var _local2:*;
var _local3:Number;
var _local4:*;
var _local5:Number;
var _local6:*;
if (shouldFollowTarget){
targCamX = (targetToFollow.x + targOffsetX);
targCamY = (targetToFollow.y + targOffsetY);
};
_local1 = (targCamX - currCamX);
_local2 = (targCamY - currCamY);
if (targCamX != currCamX){
_isOnTargetX = false;
if (_local1 <= truckSpeedX){
_local3 = _local1;
} else {
_local3 = (_local1 * truckSpeedX);
};
_local4 = (currCamX + _local3);
if (_local4 >= XMAX){
currCamX = XMAX;
} else {
if (_local4 <= XMIN){
currCamX = XMIN;
} else {
currCamX = _local4;
};
};
} else {
_isOnTargetX = true;
};
if (targCamY != currCamY){
_isOnTargetY = false;
if (Math.abs(_local2) <= truckSpeedY){
_local5 = _local2;
} else {
_local5 = (_local2 * truckSpeedY);
};
_local6 = (currCamY + _local5);
if (_local6 >= YMAX){
currCamY = YMAX;
} else {
if (_local6 <= YMIN){
currCamY = YMIN;
} else {
currCamY = _local6;
};
};
} else {
_isOnTargetY = true;
};
handleCameraShake();
camera.x = (currCamX + sceneOffsetX);
camera.y = ((currCamY + sceneOffsetY) + cameraShakeY);
mainStage.scrollRect = camera;
}
public function addScrollingFlat(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:DisplayObjectContainer, _arg7:Number, _arg8:Number, _arg9:Number=0, _arg10:Number=0, _arg11:Number=1, _arg12:Number=1):int{
var _local13:int;
var _local14:Rectangle;
var _local15:Sprite;
var _local16:int;
var _local17:*;
var _local18:Sprite;
_local13 = scrollingFlats.length;
_local14 = new Rectangle(0, 0, cameraWidth, cameraHeight);
_local15 = new Sprite();
_local15.x = 0;
_local15.y = 0;
_arg6.addChild(_local15);
_local16 = Math.ceil((_arg7 / _arg2));
_local17 = 0;
while (_local17 < _local16) {
_local18 = dobjFactory.getSpriteInstance(_arg1);
_local18.x = (_local17 * _arg2);
_local18.y = _arg5;
_local15.addChild(_local18);
_local17++;
};
scrollingFlats.push({id:_local13, camRect:_local14, parent:_arg6, flat:_local15, offsetX:_arg9, offsetY:_arg10, camTruckX:_arg11, camTruckY:_arg12});
numScrollingFlats = scrollingFlats.length;
return (_local13);
}
public function removeScrollingFlat(_arg1:int):void{
numScrollingFlats = scrollingFlats.length;
}
public function get isOnTargetX():Boolean{
return (_isOnTargetX);
}
public function get isOnTargetY():Boolean{
return (_isOnTargetY);
}
}
}//package base.display
Section 12
//SpriteEntity (base.display.SpriteEntity)
package base.display {
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
public class SpriteEntity {
private var _selectableChildren:Array;
public var _lastFrame:int;
private var _mouseRollOff:Boolean;
public var _loopAnim:Boolean;
public var _mc:MovieClip;
public var _clipHeight:Number;
private var _isSelectable:Boolean;
public var _flipped:Boolean;
public var _isPlayingBackwards:Boolean;
private var _returnVal:int;
public var _framerate:Number;
private var _children:Array;
var mouseWasOverLastFrame:Boolean;// = false
public var _targetAnimationDelta:Number;
private var _mouseIsOver:Boolean;
public var _curFrame:int;
private var _startingPositionX:Number;
private var _startingPositionY:Number;
private var _moveSpeed:Number;
public var _centerPoint:Number;
private var _mouseRollOn:Boolean;
private var _gameContext:GameEntry;
public var _animate:Boolean;
private var _destPosX:Number;
private var _destPosY:Number;
public var _spName:String;
public var _faceDir:Number;
public var _endFrame:int;
public var _startFrame:int;
public var _clipWidth:Number;
public function SpriteEntity(_arg1:GameEntry, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Number=0, _arg5:Number=0, _arg6:Boolean=false, _arg7:int=-1, _arg8:int=-1){
var _local9:*;
var _local10:Class;
mouseWasOverLastFrame = false;
super();
_gameContext = _arg1;
_local9 = _arg3.getChildByName(_arg2);
if (_arg6){
_local9 = null;
};
if (_local9){
_mc = _local9;
} else {
_local10 = (getDefinitionByName(_arg2) as Class);
_mc = new (_local10);
_mc.name = _arg2;
_mc.x = _arg4;
_mc.y = _arg5;
if (_arg7 < 0){
_arg3.addChild(_mc);
} else {
_arg3.addChildAt(_mc, _arg7);
};
};
_spName = _arg2;
_mc.visible = true;
_mc.gotoAndStop(1);
_flipped = false;
_curFrame = 1;
_startFrame = 0;
_endFrame = 0;
_lastFrame = 0;
_framerate = 32;
_targetAnimationDelta = 0;
_animate = false;
_loopAnim = false;
_isPlayingBackwards = false;
_returnVal = _arg8;
_mc.mouseEnabled = false;
_isSelectable = false;
if (_returnVal > -1){
setSelectable(_arg8);
};
_mouseIsOver = false;
_mouseRollOn = false;
_mouseRollOff = false;
_children = [];
_selectableChildren = [];
}
public function setRotation(_arg1:Number){
_mc.rotation = _arg1;
}
public function setDestPosX(_arg1:Number){
_destPosX = _arg1;
}
public function getArea():Number{
return ((_mc.width * _mc.height));
}
public function animateSprite():int{
var _local1:Number;
_local1 = _gameContext.getDT();
_targetAnimationDelta = (_targetAnimationDelta - _local1);
if (_targetAnimationDelta <= 0){
_targetAnimationDelta = _framerate;
if (_startFrame <= _endFrame){
_curFrame++;
if (_curFrame > _endFrame){
if (_loopAnim){
_curFrame = _startFrame;
} else {
doneAnimating();
_curFrame = _endFrame;
return (1);
};
};
} else {
_curFrame--;
if (_curFrame < _endFrame){
if (_loopAnim){
_curFrame = _startFrame;
} else {
doneAnimating();
_curFrame = _endFrame;
return (1);
};
};
};
moveToFrame(_curFrame);
};
return (0);
}
public function getVisibility():Boolean{
return (_mc.visible);
}
public function addNestedChild(_arg1:String, _arg2:int=-1):SpriteEntity{
var _local3:SpriteEntity;
_local3 = new SpriteEntity(_gameContext, _arg1, _mc);
if (_arg2 > -1){
_local3.setSelectable(_arg2);
_selectableChildren.push(_local3);
} else {
_children.push(_local3);
};
return (_local3);
}
public function setPositionX(_arg1:Number){
_mc.x = _arg1;
}
public function setPositionY(_arg1:Number){
_mc.y = _arg1;
}
public function getWidth():Number{
return (_mc.width);
}
public function isMouseOver():Boolean{
var _local1:Rectangle;
if (_mc.visible == false){
return (false);
};
_mouseRollOn = false;
_mouseRollOff = false;
_local1 = _mc.getBounds(_gameContext.getStageSprite());
if ((((((((_gameContext.getPadManager().getMousePosX() < _local1.left)) || ((_gameContext.getPadManager().getMousePosX() > _local1.right)))) || ((_gameContext.getPadManager().getMousePosY() < _local1.top)))) || ((_gameContext.getPadManager().getMousePosY() > _local1.bottom)))){
if (mouseWasOverLastFrame){
_mouseRollOff = true;
};
mouseWasOverLastFrame = false;
_mouseIsOver = false;
return (false);
};
if (_mouseIsOver){
mouseWasOverLastFrame = true;
} else {
_mouseRollOn = true;
mouseWasOverLastFrame = true;
};
_mouseIsOver = true;
return (true);
}
public function getFramerate():Number{
return (_framerate);
}
public function setVisibility(_arg1:Boolean){
_mc.visible = _arg1;
}
public function startAnimating(_arg1:int, _arg2:int, _arg3:Boolean=false, _arg4:Number=32){
_curFrame = _arg1;
_startFrame = _arg1;
_endFrame = _arg2;
moveToFrame(_arg1);
_framerate = (1 / _arg4);
_loopAnim = _arg3;
_animate = true;
_targetAnimationDelta = _framerate;
_isPlayingBackwards = ((_startFrame)>_endFrame) ? true : false;
}
public function getHeight():Number{
return (_mc.height);
}
public function getStartFrame():Number{
return (_startFrame);
}
public function getReturnVal():int{
return (_returnVal);
}
public function addNewChild(_arg1:String, _arg2:int, _arg3:int, _arg4:Boolean=false, _arg5:int=-1):SpriteEntity{
var _local6:SpriteEntity;
_local6 = new SpriteEntity(_gameContext, _arg1, _mc, _arg2, _arg3, _arg4);
if (_arg5 > -1){
_local6.setSelectable(_arg5);
_selectableChildren.push(_local6);
} else {
_children.push(_local6);
};
return (_local6);
}
public function setFaceDir(_arg1:Number):void{
_faceDir = _arg1;
}
public function setStartingPositionToPosition():void{
_startingPositionX = getPositionX();
_startingPositionY = getPositionY();
}
public function getSelectableChild(_arg1:int):SpriteEntity{
return (_selectableChildren[_arg1]);
}
public function getStartingPositionX():Number{
return (_startingPositionX);
}
public function getStartingPositionY():Number{
return (_startingPositionY);
}
public function isLooping():Boolean{
return (_loopAnim);
}
public function getMoveSpeed():Number{
return (_moveSpeed);
}
public function getScaleY():Number{
return (_mc.scaleY);
}
public function setScaleX(_arg1:Number):void{
_mc.scaleX = _arg1;
}
public function setScaleY(_arg1:Number):void{
_mc.scaleY = _arg1;
}
public function getScaleX():Number{
return (_mc.scaleX);
}
public function isAnimating():Boolean{
return (_animate);
}
public function getSelectable():Boolean{
return (_isSelectable);
}
public function getChild(_arg1:int):SpriteEntity{
return (_selectableChildren[_arg1]);
}
public function setSelectable(_arg1:int):void{
_isSelectable = true;
_returnVal = _arg1;
_mc.mouseEnabled = true;
_mc.buttonMode = true;
_mc.useHandCursor = true;
}
public function removeSprite():void{
var _local1:int;
_local1 = 0;
_local1 = _children.length;
if (_local1 > 0){
while (_local1--) {
_children[_local1] = null;
};
_children = [];
};
_local1 = _selectableChildren.length;
if (_local1 > 0){
while (_local1--) {
_selectableChildren[_local1] = null;
};
_selectableChildren = [];
};
_mc.parent.removeChild(_mc);
_mc = null;
}
public function getNumChildren():Number{
return (_children.length);
}
public function getSelectableChildren():Array{
return (_selectableChildren);
}
public function getChildren():Array{
return (_children);
}
public function setFramerate(_arg1:int):void{
_framerate = (1 / _arg1);
}
public function isMouseRollOff():Boolean{
return (_mouseRollOff);
}
public function getPositionX():Number{
return (_mc.x);
}
public function getPositionY():Number{
return (_mc.y);
}
public function moveToFrame(_arg1:int):void{
_mc.gotoAndStop(_arg1);
_lastFrame = _arg1;
}
public function setPosition(_arg1:Number, _arg2:Number){
_mc.x = _arg1;
_mc.y = _arg2;
}
public function scaleSprite(_arg1:Number):void{
_mc.scaleX = (_mc.scaleX * _arg1);
_mc.scaleY = (_mc.scaleY * _arg1);
}
public function setMoveSpeed(_arg1:Number){
_moveSpeed = _arg1;
}
public function playFlipped(){
if (_flipped){
return;
};
_flipped = true;
_mc.scaleX = (_mc.scaleX * -1);
}
public function isMouseRollOn():Boolean{
return (_mouseRollOn);
}
public function getFaceDir():Number{
return (_faceDir);
}
public function getDestPosY():Number{
return (_destPosY);
}
public function setFlipped():void{
_flipped = (_flipped) ? false : true;
_mc.scaleX = (_mc.scaleX * -1);
}
public function reverseAnimation():void{
var _local1:*;
var _local2:*;
_local1 = _endFrame;
_local2 = _startFrame;
_startFrame = _local1;
_endFrame = _local2;
_isPlayingBackwards = ((_startFrame)>_endFrame) ? true : false;
}
public function getDestPosX():Number{
return (_destPosX);
}
public function getEndFrame():Number{
return (_endFrame);
}
public function setDestPosY(_arg1:Number){
_destPosY = _arg1;
}
public function isAtDestination():Boolean{
return (((((_mc.x == _destPosX)) && ((_mc.y == _destPosY)))) ? true : false);
}
public function getSelectableChildMouseIsOver():SpriteEntity{
var _local1:int;
_local1 = _selectableChildren.length;
while (_local1--) {
if (_selectableChildren[_local1].isMouseOver()){
return (_selectableChildren[_local1]);
};
};
return (null);
}
public function getNumSelectableChildren():Number{
return (_selectableChildren.length);
}
public function isVisible():Boolean{
return (_mc.visible);
}
public function getCurrentFrame():int{
return (_mc.currentFrame);
}
public function getMovieClip():MovieClip{
return (_mc);
}
public function playUnflipped(){
if (_flipped){
_mc.scaleX = (_mc.scaleX * -1);
};
_flipped = false;
}
public function doneAnimating():void{
_animate = false;
}
public function isFlipped():Boolean{
return (_flipped);
}
}
}//package base.display
Section 13
//PadManager (base.pad.PadManager)
package base.pad {
import flash.events.*;
import flash.utils.*;
public class PadManager {
private var _tapBufferMax:Number;
private var _handleMouseRelease:Boolean;
private var _keysDown:Object;
private var _lastKeyPressed:Number;
private var _padData:Array;
private var _gameContext:GameEntry;
private var _handleMousePress:Boolean;
private var _keyTarget:Object;
private var keyStage;
var _keyPressed:Boolean;
private var _lastKeyReleaseTime:Number;
private var _tapBufferMin:Number;
private var _mouseData:Object;
private var _keyTargeting:Boolean;
public function PadManager(_arg1:GameEntry){
trace("|----@ PAD MANAGER @----|");
_gameContext = _arg1;
keyStage = _gameContext.getStageSprite();
_keysDown = new Object();
_padData = new Array();
_lastKeyPressed = 0;
_lastKeyReleaseTime = 0;
_keyTargeting = false;
_keyPressed = false;
_mouseData = new Object();
_mouseData.mouseJustPressed = false;
_mouseData.mouseStillPressed = false;
_mouseData.mouseReleased = false;
_mouseData.mouseTimePressed = 0;
_mouseData.mousePressedPosX = 0;
_mouseData.mousePressedPosY = 0;
_mouseData.mousePosX = 0;
_mouseData.mousePosY = 0;
_handleMousePress = false;
_handleMouseRelease = false;
Init();
}
public function getKeyDoubleTapped(_arg1):Boolean{
var _local2:*;
_local2 = 0;
while (_local2 < _padData.length) {
if ((((_padData[_local2].keyAction == _arg1)) && (_padData[_local2].doubleTapped))){
return (true);
};
_local2++;
};
return (false);
}
public function getMouseStillPressed():Boolean{
return (_mouseData.mouseStillPressed);
}
private function mouseUpHandler(_arg1:MouseEvent):void{
_handleMouseRelease = true;
}
private function doubleClickHandler(_arg1:MouseEvent):void{
}
public function getKeyActionHeld(_arg1):Boolean{
var _local2:*;
_local2 = 0;
while (_local2 < _padData.length) {
if ((((_padData[_local2].keyAction == _arg1)) && (_padData[_local2].keyStillPressed))){
return (true);
};
_local2++;
};
return (false);
}
public function Update():void{
var _local1:int;
var _local2:Number;
if (_gameContext.stage.focus == null){
clearKeys();
};
if (_mouseData.mouseReleased){
_mouseData.mouseReleased = false;
};
if (_handleMouseRelease){
_handleMouseRelease = false;
_mouseData.mouseJustPressed = false;
_mouseData.mouseStillPressed = false;
_mouseData.mouseReleased = true;
} else {
if (_mouseData.mouseJustPressed){
_mouseData.mouseJustPressed = false;
_mouseData.mouseReleased = false;
_mouseData.mouseStillPressed = true;
};
if (_mouseData.mouseStillPressed){
_mouseData.mouseTimePressed = (_mouseData.mouseTimePressed + _gameContext.getDT());
};
};
if (_handleMousePress){
_handleMousePress = false;
_mouseData.mouseJustPressed = true;
_mouseData.mousePressedPosX = keyStage.mouseX;
_mouseData.mousePressedPosY = keyStage.mouseY;
_mouseData.mouseReleased = false;
_mouseData.mouseStillPressed = false;
_mouseData.mouseTimePressed = 0;
};
_mouseData.mousePosX = keyStage.mouseX;
_mouseData.mousePosY = keyStage.mouseY;
_local1 = 0;
while (_local1 < _padData.length) {
if (isDown(_padData[_local1].keyID)){
if (((!(_padData[_local1].keyPressed)) && (!(_padData[_local1].keyStillPressed)))){
if (_padData[_local1].keyID == _lastKeyPressed){
_local2 = (getTimer() - _lastKeyReleaseTime);
if (_local2 < 0.18){
_padData[_local1].doubleTapped = true;
};
};
_padData[_local1].keyPressed = true;
_padData[_local1].keyStillPressed = false;
_padData[_local1].keyReleased = false;
_padData[_local1].timePressed = 0;
} else {
if (((_padData[_local1].keyPressed) || (_padData[_local1].keyStillPressed))){
_padData[_local1].keyPressed = false;
_padData[_local1].keyStillPressed = true;
_padData[_local1].keyReleased = false;
_padData[_local1].timePressed = (_padData[_local1].timePressed + _gameContext.getDT());
};
};
} else {
if (((_padData[_local1].keyStillPressed) || (_padData[_local1].keyPressed))){
_padData[_local1].keyPressed = false;
_padData[_local1].keyStillPressed = false;
_padData[_local1].keyReleased = true;
_padData[_local1].doubleTapped = false;
_lastKeyPressed = _padData[_local1].keyID;
_lastKeyReleaseTime = getTimer();
};
};
_local1++;
};
}
public function getAnyKeyPressed():Boolean{
if (_keyPressed){
return (true);
};
return (false);
}
public function getMousePosX():Number{
return (_mouseData.mousePosX);
}
public function getMousePosY():Number{
return (_mouseData.mousePosY);
}
private function mouseOutHandler(_arg1:MouseEvent):void{
}
private function clickHandler(_arg1:MouseEvent):void{
}
public function resetListener():void{
keyStage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
keyStage.removeEventListener(KeyboardEvent.KEY_UP, keyReleased);
keyStage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
keyStage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
}
public function getMouseTimePressed():Number{
return (_mouseData.mouseTimePressed);
}
public function getPadData():Array{
return (_padData);
}
public function getKeyJustPressed(_arg1:Number){
return (_padData[_arg1].keyPressed);
}
public function getMouseJustPressed():Boolean{
return (_mouseData.mouseJustPressed);
}
public function getKeyStillPressed(_arg1:Number){
return (_padData[_arg1].keyStillPressed);
}
public function getCurrentKeyActionUp():String{
var _local1:*;
_local1 = 0;
while (_local1 < _padData.length) {
if (_padData[_local1].keyReleased){
return (_padData[_local1].keyAction);
};
_local1++;
};
return ("");
}
public function Init():void{
keyStage.addEventListener(MouseEvent.CLICK, clickHandler);
keyStage.addEventListener(MouseEvent.DOUBLE_CLICK, doubleClickHandler);
keyStage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
keyStage.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
keyStage.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
keyStage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
keyStage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler);
keyStage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
keyStage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
}
private function mouseWheelHandler(_arg1:MouseEvent):void{
}
private function keyReleased(_arg1:KeyboardEvent):void{
_keyPressed = false;
delete _keysDown[_arg1.keyCode];
}
public function getCurrentKeyActionHeld():String{
var _local1:*;
_local1 = 0;
while (_local1 < _padData.length) {
if (_padData[_local1].keyStillPressed){
return (_padData[_local1].keyAction);
};
_local1++;
};
return ("");
}
private function keyPressed(_arg1:KeyboardEvent):void{
_keyPressed = true;
_keysDown[_arg1.keyCode] = true;
}
public function getMouseReleased():Boolean{
return (_mouseData.mouseReleased);
}
public function getTimeKeyActionHeld():Number{
var _local1:*;
_local1 = 0;
while (_local1 < _padData.length) {
if (_padData[_local1].keyStillPressed){
return (_padData[_local1].timePressed);
};
_local1++;
};
return (0);
}
public function getMousePressedPosX():Number{
return (_mouseData.mousePressedPosX);
}
public function getMousePressedPosY():Number{
return (_mouseData.mousePressedPosY);
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
}
function clearKeys():void{
var _local1:int;
var _local2:*;
_local1 = _padData.length;
while (_local1--) {
_padData[_local1].keyPressed = false;
_padData[_local1].keyStillPressed = false;
_padData[_local1].keyReleased = false;
_padData[_local1].timePressed = 0;
};
for (_local2 in _keysDown) {
_keysDown[_local2] = null;
};
_lastKeyPressed = 0;
}
private function mouseDownHandler(_arg1:MouseEvent):void{
_handleMousePress = true;
_gameContext.stage.focus = _gameContext.stage;
}
private function isDown(_arg1:uint):Boolean{
return (Boolean(_keysDown[_arg1]));
}
public function getPadDataLength():Number{
return (_padData.length);
}
public function getCurrentKeyAction():String{
var _local1:*;
_local1 = 0;
while (_local1 < _padData.length) {
if (_padData[_local1].keyPressed){
return (_padData[_local1].keyAction);
};
_local1++;
};
return ("");
}
public function setKeyControls(_arg1:Array):void{
var _local2:Number;
_local2 = 0;
while (_local2 < _arg1.length) {
_padData.push({keyID:_arg1[_local2].keyID, keyAction:_arg1[_local2].keyAction, keyPressed:false, keyReleased:false, keyStillPressed:false, timePressed:0, doubleTapped:false});
_local2++;
};
}
public function deconstruct():void{
_keysDown = new Object();
_mouseData = new Object();
keyStage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
keyStage.removeEventListener(KeyboardEvent.KEY_UP, keyReleased);
keyStage.removeEventListener(MouseEvent.CLICK, clickHandler);
keyStage.removeEventListener(MouseEvent.DOUBLE_CLICK, doubleClickHandler);
keyStage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
keyStage.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
keyStage.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
keyStage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
keyStage.removeEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler);
}
private function mouseOverHandler(_arg1:MouseEvent):void{
}
public function toString():String{
return ("PadManager()");
}
}
}//package base.pad
Section 14
//SoundModule (base.sound.SoundModule)
package base.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import base.utils.*;
import game.*;
public class SoundModule {
private const soundVolDefault:Number = 1;
private const musicVolDefault:Number = 1;
private var fadeInChannel:SoundChannel;
private var hash:Object;
private var currMusic:String;// = null
private var fadeOutStep:Number;
private var fadeOutStr:String;
private var musicVolTarget:Number;// = 1
private var fadeInStr:String;
private var fadeInSoundInterval:uint;
private var fadeInStep:Number;
private var fadeInMusicInterval:uint;
private var musicMute:Boolean;
public var _soundData:SoundData;
private var mutedVolume:Number;// = 1
private var fadeOutSoundInterval:uint;
private var activeSounds:Array;
private var currMusicChannel:SoundChannel;// = null
private var fadeOutChannel:SoundChannel;
private var fadeOutMusicInterval:uint;
private static var MAX_SOUNDS:Number = 30;
public function SoundModule(){
musicVolTarget = 1;
currMusic = null;
currMusicChannel = null;
mutedVolume = 1;
super();
hash = new Object();
activeSounds = new Array();
_soundData = new SoundData();
}
public function getCurrentMusicChannel():SoundChannel{
return (currMusicChannel);
}
public function updateFadeOutChannel(_arg1:Timer, _arg2:SoundChannel, _arg3:Number, ... _args):void{
var _local5:Number;
var _local6:SoundTransform;
_local5 = (_arg2.soundTransform.volume - _arg3);
_local6 = new SoundTransform(_local5, 0);
if (_local5 <= 0){
_arg1.stop();
_arg1.removeEventListener(TimerEvent.TIMER, this.updateFadeOutChannel);
_arg1 = null;
_arg2.stop();
deactivateChannel(_arg2);
_arg2 = null;
} else {
_arg2.soundTransform = _local6;
};
}
public function setMusicMute(_arg1:Boolean):void{
var _local2:SoundTransform;
if (currMusicChannel == null){
musicMute = _arg1;
return;
};
if (fadeInSoundInterval > 0){
clearInterval(fadeInSoundInterval);
fadeInSoundInterval = 0;
};
switch (_arg1){
case true:
_local2 = new SoundTransform(0, 0);
currMusicChannel.soundTransform = _local2;
musicMute = true;
break;
case false:
_local2 = new SoundTransform(mutedVolume, 0);
currMusicChannel.soundTransform = _local2;
musicMute = false;
break;
};
}
public function getMusicMute():Boolean{
return (musicMute);
}
public function crossFadeMusic(_arg1:SoundChannel, _arg2:SoundChannel, _arg3:Number):void{
if (_arg1 != null){
addChannelToFadeOut(_arg1, _arg3);
};
if (_arg2 != null){
addChannelToFadeIn(_arg2, _arg3);
};
}
public function stopSound(_arg1:SoundChannel):void{
var _local2:Number;
_local2 = activeSounds.length;
while (_local2--) {
if (activeSounds[_local2][1] == _arg1){
_arg1.stop();
_arg1 = null;
activeSounds.splice(_local2, 1);
break;
};
};
}
public function addChannelToFadeOut(_arg1:SoundChannel, _arg2:Number):void{
var _local3:SoundTransform;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Timer;
_local3 = _arg1.soundTransform;
_local4 = (_local3.volume * 100);
_local5 = (_local4 / _arg2);
_local6 = (_arg2 / _local4);
_local7 = (_arg2 / _local6);
if (_local5 < 0.02){
_local5 = 0.02;
};
_local8 = new Timer(_local7, _local6);
_local8.addEventListener(TimerEvent.TIMER, FuncProxy.create(this, updateFadeOutChannel, _local8, _arg1, _local5));
_local8.start();
}
public function updateFadeInChannel(_arg1:Timer, _arg2:SoundChannel, _arg3:Number, ... _args):void{
var _local5:Number;
var _local6:SoundTransform;
_local5 = (_arg2.soundTransform.volume + _arg3);
_local6 = new SoundTransform(_local5, 0);
if (_local5 >= musicVolTarget){
_arg1.stop();
_arg1.removeEventListener(TimerEvent.TIMER, this.updateFadeOutChannel);
_arg1 = null;
} else {
_arg2.soundTransform = _local6;
};
}
public function playSound(_arg1:String, _arg2:Number=1, _arg3:Number=0, _arg4:Number=0, _arg5:int=0, _arg6:Boolean=false):SoundChannel{
var _local7:Number;
var _local8:Sound;
var _local9:SoundTransform;
var _local10:SoundChannel;
if (_arg2 > 1){
_arg2 = 1;
};
if ((((_arg3 < -1)) || ((_arg3 > 1)))){
_arg3 = 0;
};
if ((((hash[_arg1] == undefined)) || ((hash[_arg1] == null)))){
loadSound(_arg1);
} else {
if (!_arg6){
_local7 = activeSounds.length;
if (_local7 > 0){
while (_local7--) {
if (activeSounds[_local7][0] == _arg1){
return (null);
};
};
};
};
};
if (activeSounds.length < MAX_SOUNDS){
_local8 = hash[_arg1];
_local9 = new SoundTransform(_arg2, _arg3);
_local10 = _local8.play(_arg4, _arg5, _local9);
if (_local10 == null){
trace("Sound Failed to Play");
return (null);
};
activeSounds.push([_arg1, _local10]);
_local10.addEventListener(Event.SOUND_COMPLETE, FuncProxy.create(this, soundCompleteHandler, _arg1, _local10));
return (_local10);
} else {
trace("Active Sounds exceeds Maximum Allowed");
};
return (null);
}
public function startLoopFade(_arg1:String, _arg2:Number, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:int=9999, _arg7:Boolean=false):SoundChannel{
var _local8:Number;
var _local9:Sound;
var _local10:SoundTransform;
var _local11:SoundChannel;
if ((((hash[_arg1] == undefined)) || ((hash[_arg1] == null)))){
loadSound(_arg1);
} else {
if (!_arg7){
_local8 = activeSounds.length;
if (_local8 > 0){
while (_local8--) {
if (activeSounds[_local8][0] == _arg1){
trace(("Sound Already Playing:" + _arg1), _local8);
return (null);
};
};
};
};
};
if (activeSounds.length < MAX_SOUNDS){
_local9 = hash[_arg1];
_local10 = new SoundTransform(0, _arg4);
_local11 = _local9.play(_arg5, _arg6, _local10);
if (_local11 == null){
trace("Loop Sound Failed to Play");
return (null);
};
activeSounds.push([_arg1, _local11]);
addChannelToFadeIn(_local11, _arg2);
return (_local11);
} else {
trace("Active Sounds exceeds Maximum Allowed");
};
return (null);
}
public function playSoundByEvent(_arg1:Object):SoundChannel{
var _local2:Number;
var _local3:SoundChannel;
_local2 = ((_arg1.loop)==true) ? 9999 : 0;
_local3 = playSound(_arg1.linkage, _arg1.vol, _arg1.pan, _arg1.offset, _local2, _arg1.force);
return (_local3);
}
public function traceActiveSounds():void{
var _local1:Number;
trace("");
_local1 = activeSounds.length;
while (_local1--) {
trace((("[" + activeSounds[_local1][0]) + "]"));
};
trace("");
}
public function loadSound(_arg1:String):void{
var _local2:Class;
var _local3:Sound;
_local2 = (getDefinitionByName(_arg1) as Class);
_local3 = (new (_local2) as Sound);
hash[_arg1] = _local3;
}
public function soundCompleteHandler(_arg1:String, _arg2:SoundChannel):void{
deactivateChannel(_arg2);
_arg2.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
_arg2 = null;
}
public function stopMusic():void{
if (currMusicChannel == null){
return;
};
addChannelToFadeOut(currMusicChannel, 1000);
currMusicChannel = null;
}
public function soundIsPlaying(_arg1:Object):Boolean{
var _local2:*;
for (_local2 in activeSounds) {
if (activeSounds[_local2][0] == _arg1.linkage){
return (true);
};
};
return (false);
}
public function playMusic(_arg1:String, _arg2:Number=0, _arg3:Number=1):SoundChannel{
var _local4:Sound;
var _local5:SoundChannel;
var _local6:SoundTransform;
if (currMusicChannel != null){
_local5 = currMusicChannel;
};
currMusicChannel = null;
if ((((hash[_arg1] == undefined)) || ((hash[_arg1] == null)))){
loadSound(_arg1);
};
_local4 = hash[_arg1];
mutedVolume = _arg3;
musicVolTarget = (musicMute) ? 0 : _arg3;
_local6 = new SoundTransform(_arg2, 0);
currMusicChannel = _local4.play(0, 9999, _local6);
if (_arg2 != musicVolTarget){
crossFadeMusic(_local5, currMusicChannel, 1000);
} else {
if (_local5 != null){
addChannelToFadeOut(_local5, 1000);
};
};
return (currMusicChannel);
}
public function stopAllSounds():void{
var _local1:Number;
var _local2:SoundChannel;
_local1 = activeSounds.length;
while (_local1--) {
_local2 = activeSounds[_local1][1];
_local2.stop();
_local2 = null;
};
activeSounds = new Array();
}
public function unMuteSound(_arg1:SoundChannel, _arg2:Number=1):void{
var _local3:SoundTransform;
_local3 = new SoundTransform(_arg2, 0);
_arg1.soundTransform = _local3;
}
public function deactivateChannel(_arg1:SoundChannel):void{
var _local2:int;
_local2 = activeSounds.length;
while (_local2--) {
if (activeSounds[_local2][1] == _arg1){
activeSounds.splice(_local2, 1);
_arg1 = null;
return;
};
};
}
public function addChannelToFadeIn(_arg1:SoundChannel, _arg2:Number):void{
var _local3:SoundTransform;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Timer;
_local3 = _arg1.soundTransform;
_local4 = (musicVolTarget * 100);
_local5 = (_local4 / _arg2);
_local6 = (_arg2 / _local4);
_local7 = (_arg2 / _local6);
if (_local5 < 0.02){
_local5 = 0.02;
};
_local8 = new Timer(_local7, _local6);
_local8.addEventListener(TimerEvent.TIMER, FuncProxy.create(this, updateFadeInChannel, _local8, _arg1, _local5));
_local8.start();
}
public function muteSound(_arg1:SoundChannel):void{
var _local2:SoundTransform;
_local2 = new SoundTransform(0, 0);
_arg1.soundTransform = _local2;
}
}
}//package base.sound
Section 15
//GameTrack_AS3 (base.tracker.GameTrack_AS3)
package base.tracker {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class GameTrack_AS3 {
var container:DisplayObjectContainer;
var trkLoader:Loader;
var tracker;
public function GameTrack_AS3(_arg1:DisplayObjectContainer){
container = _arg1;
}
public function sendEventPlaySaved(){
trackNewEvent("play_saved");
}
private function trackNewEvent(_arg1:String){
if (this.tracker != null){
this.tracker.sendTracking(_arg1);
trace("Event Sent to Omniture Component");
};
}
public function sendEventPlay(){
trackNewEvent("play");
}
public function sendEventWin(){
trackNewEvent("win");
}
private function trkLoadComplete(_arg1:Event):void{
this.tracker = _arg1.target.content;
trace(("LoadComplete(): " + this.tracker));
}
public function sendEventLose(){
trackNewEvent("lose");
}
public function sendEventReplay(){
trackNewEvent("replay");
}
public function loadTracker():void{
}
private function configureListeners(_arg1:IEventDispatcher):void{
_arg1.addEventListener(Event.COMPLETE, trkLoadComplete, false, 0, true);
}
public function sendEventCustom(_arg1:String){
trackNewEvent(("cust_" + _arg1));
}
}
}//package base.tracker
Section 16
//Input (base.ui.Input)
package base.ui {
import flash.display.*;
import flash.events.*;
public class Input {
public static var mouseOffsetX:Number = 0;
public static var mouseOffsetY:Number = 0;
private static var keyArr:Array;
public static var mouseDragX:Number = 0;
public static var mouseReleased:Boolean = false;
public static var mouseDragY: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;
public static var m_stageMc:Sprite;
private static var bufferSize:int;
public static var mouse:Sprite = new Sprite();
public static var mouseDown:Boolean = false;
public static var lastKey:int = 0;
private static var keyState:Array;
public static var timeSinceLastKey = 0;
public static var mousePressed:Boolean = false;
private static var keyBuffer:Array;
public function Input(_arg1:Sprite){
var _local2:int;
var _local3:int;
super();
m_stageMc = _arg1;
ascii = new Array(222);
fillAscii();
keyState = new Array(222);
keyArr = new Array();
_local2 = 0;
while (_local2 < 222) {
keyState[_local2] = new int(0);
if (ascii[_local2] != undefined){
keyArr.push(_local2);
};
_local2++;
};
bufferSize = 5;
keyBuffer = new Array(bufferSize);
_local3 = 0;
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.MOUSE_UP, 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 mouseRelease(_arg1:MouseEvent){
mouseDown = false;
mouseReleased = true;
}
public function keyPress(_arg1:KeyboardEvent){
keyState[_arg1.keyCode] = Math.max(keyState[_arg1.keyCode], 1);
lastKey = _arg1.keyCode;
}
private function fillAscii(){
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){
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){
var _local2:int;
keyState[_arg1.keyCode] = -1;
_local2 = (bufferSize - 1);
while (_local2 > 0) {
keyBuffer[_local2] = keyBuffer[(_local2 - 1)];
_local2--;
};
keyBuffer[0] = [_arg1.keyCode, 0];
}
public function mouseLeave(_arg1:Event){
mouseReleased = mouseDown;
mouseDown = false;
}
public function mousePress(_arg1:MouseEvent){
mousePressed = true;
mouseDown = true;
mouseDragX = 0;
mouseDragY = 0;
}
public static function getKeyHold(_arg1:int):int{
return (Math.max(0, keyState[_arg1]));
}
public static function isKeyPressed(_arg1:int):Boolean{
timeSinceLastKey = 0;
return ((keyState[_arg1] == 1));
}
public static function update(){
var _local1:int;
var _local2:int;
_local1 = 0;
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++;
};
_local2 = 0;
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 isKeyDown(_arg1:int):Boolean{
return ((keyState[_arg1] > 0));
}
public static function isKeyReleased(_arg1:int):Boolean{
return ((keyState[_arg1] == -1));
}
public static function getKeyString(_arg1:uint):String{
return (ascii[_arg1]);
}
public static function isKeyInBuffer(_arg1:int, _arg2:int, _arg3:int){
return ((((keyBuffer[_arg2][0] == _arg1)) && ((keyBuffer[_arg2][1] <= _arg3))));
}
}
}//package base.ui
Section 17
//UIButton (base.ui.UIButton)
package base.ui {
import flash.display.*;
import base.display.*;
public class UIButton extends SpriteEntity {
public var normFrame:int;// = 1
public var sfxUp:Object;// = null
public var animOutEnd:int;// = 1
public var animOverEnd:int;// = 2
public var sfxOver:Object;// = null
public var animGreyEnd:int;// = 1
public var selectOnDown:Boolean;// = false
public var animUpStart:int;// = 3
public var rollOn:Boolean;
public var animDownEnd:int;// = 3
public var sfxOut:Object;// = null
public var hasSound:Boolean;// = false
public var unselectOthers:Boolean;// = false
public var iName:String;// = ""
public var animGreyStart:int;// = 1
public var animUpEnd:int;// = 3
public var rollOff:Boolean;
public var isDisabled:Boolean;// = false
public var sfxDown:Object;// = null
public var greyFrame:int;// = 4
public var animOverStart:int;// = 2
public var animDownStart:int;// = 3
public var downFrame:int;// = 3
public var isSelected:Boolean;// = false
public var isAnimated:Boolean;// = false
public var animOutStart:int;// = 1
public var overFrame:int;// = 2
public static const STATE_OUT:int = 1;
public static const STATE_UP:int = 4;
public static const STATE_OVER:int = 2;
public static const STATE_DOWN:int = 3;
public static const STATE_DISABLED:int = 5;
public function UIButton(_arg1:GameEntry, _arg2:String, _arg3:DisplayObjectContainer, _arg4:int, _arg5:Boolean=false, _arg6:Boolean=false, _arg7:Boolean=false){
iName = "";
isAnimated = false;
hasSound = false;
isSelected = false;
isDisabled = false;
selectOnDown = false;
unselectOthers = false;
normFrame = 1;
overFrame = 2;
downFrame = 3;
greyFrame = 4;
animOutStart = 1;
animOutEnd = 1;
animOverStart = 2;
animOverEnd = 2;
animDownStart = 3;
animDownEnd = 3;
animUpStart = 3;
animUpEnd = 3;
animGreyStart = 1;
animGreyEnd = 1;
sfxOut = null;
sfxOver = null;
sfxDown = null;
sfxUp = null;
super(_arg1, _arg2, _arg3);
iName = _arg2;
setSelectable(_arg4);
this.isAnimated = _arg5;
this.selectOnDown = _arg6;
this.unselectOthers = _arg7;
}
public function setSelected(_arg1:Boolean):void{
var _local2:int;
isSelected = _arg1;
_local2 = ((isSelected)==false) ? normFrame : downFrame;
moveToFrame(_local2);
}
public function mouseRollOn():void{
rollOn = true;
rollOff = false;
}
public function mouseRollOff():void{
rollOn = false;
rollOff = true;
}
public function addButtonSounds(_arg1:int, _arg2:Object):void{
hasSound = true;
switch (_arg1){
case STATE_OUT:
sfxOut = _arg2;
break;
case STATE_OVER:
sfxOver = _arg2;
break;
case STATE_DOWN:
sfxDown = _arg2;
break;
case STATE_UP:
sfxUp = _arg2;
break;
};
}
public function toString():String{
return (iName);
}
public function addButtonAnimation(_arg1:int, _arg2:int, _arg3:int):void{
isAnimated = true;
switch (_arg1){
case STATE_OUT:
animOutStart = _arg2;
animOutEnd = _arg3;
break;
case STATE_OVER:
animOverStart = _arg2;
animOverEnd = _arg3;
break;
case STATE_DOWN:
animDownStart = _arg2;
animDownEnd = _arg3;
break;
case STATE_UP:
animUpStart = _arg2;
animUpEnd = _arg3;
break;
};
}
public function setDisabled(_arg1:Boolean):void{
var _local2:int;
isDisabled = _arg1;
_local2 = ((isDisabled)==false) ? normFrame : greyFrame;
moveToFrame(_local2);
}
}
}//package base.ui
Section 18
//UIManager (base.ui.UIManager)
package base.ui {
import flash.display.*;
import base.display.*;
import base.pad.*;
public class UIManager {
private var _screens:Array;
private var _screen:SpriteEntity;
private var bArray:Array;
private var _gameContext:GameEntry;
private var _isButtonPressed:Boolean;
private var b:UIButton;
private var _padMgr:PadManager;
private var _uiReturnVal:int;
private var bSelected:Array;
private var n:int;
public var _runUpdate:Boolean;
public function UIManager(_arg1:GameEntry){
trace("|----@ UI MANAGER @----|");
_gameContext = _arg1;
_padMgr = _arg1.getPadManager();
_screen = null;
_screens = new Array();
_runUpdate = true;
_isButtonPressed = false;
n = 0;
b = null;
bArray = [];
bSelected = [];
}
public function addButton(_arg1:DisplayObjectContainer, _arg2:String, _arg3:int, _arg4:Boolean=false, _arg5:Boolean=false, _arg6:Boolean=false):UIButton{
var _local7:UIButton;
_local7 = new UIButton(_gameContext, _arg2, _arg1, _arg3, _arg4, _arg6);
bArray.push(_local7);
return (_local7);
}
public function showScreen(_arg1:String, _arg2:DisplayObjectContainer, _arg3:int=0, _arg4:int=0, _arg5:int=-1, _arg6:Boolean=true):SpriteEntity{
var _local7:SpriteEntity;
if (_arg6){
removeScreen();
_screen = new SpriteEntity(_gameContext, _arg1, _arg2, _arg3, _arg4, true, _arg5);
return (_screen);
};
_local7 = new SpriteEntity(_gameContext, _arg1, _arg2, _arg3, _arg4, true, _arg5);
_screens.push(_local7);
return (_local7);
}
public function getScreens():Array{
return (_screens);
}
public function getScreen():SpriteEntity{
return (_screen);
}
public function clearSelected():void{
var _local1:int;
var _local2:UIButton;
_local1 = bSelected.length;
while (_local1--) {
_local2 = bSelected[_local1];
trace(("button:" + _local2));
if (_local2 != null){
_local2.setSelected(false);
};
};
bSelected.splice(0);
}
public function removeScreen():void{
n = bArray.length;
while (n--) {
b = bArray[n];
b.removeSprite();
b = null;
};
bArray = [];
if (_screen != null){
_screen.removeSprite();
_screen = null;
};
}
public function Update():void{
if (!_runUpdate){
return;
};
_uiReturnVal = -1;
if (_screen != null){
n = bArray.length;
while (n--) {
b = bArray[n];
if ((((b == null)) || (b.isDisabled))){
} else {
if (b.isMouseOver()){
if (_padMgr.getMouseJustPressed()){
b.startAnimating(b.animDownStart, b.animDownEnd);
_isButtonPressed = true;
if (b.selectOnDown){
_uiReturnVal = b.getReturnVal();
if (b.isSelected){
return;
};
clearSelected();
b.setSelected(true);
bSelected.push(b);
if (b.sfxDown != null){
_gameContext.getSoundModule().playSoundByEvent(b.sfxDown);
};
return;
};
};
if (((_padMgr.getMouseReleased()) && ((b.selectOnDown == false)))){
b.startAnimating(b.animOutStart, b.animOutEnd);
b.animateSprite();
_uiReturnVal = b.getReturnVal();
return;
};
};
if (b.isSelected){
_uiReturnVal = b.getReturnVal();
} else {
if (b.isMouseRollOff()){
b.mouseRollOff();
b.startAnimating(b.animOutStart, b.animOutEnd);
if (b.sfxOut != null){
_gameContext.getSoundModule().playSoundByEvent(b.sfxOut);
};
};
if (b.isMouseRollOn()){
b.mouseRollOn();
b.startAnimating(b.animOverStart, b.animOverEnd);
if (b.sfxOver != null){
_gameContext.getSoundModule().playSoundByEvent(b.sfxOver);
};
};
if (b.isAnimating()){
b.animateSprite();
};
};
};
};
_isButtonPressed = false;
};
}
public function addScreen(_arg1:String, _arg2:DisplayObjectContainer, _arg3:int=0, _arg4:int=0, _arg5:int=-1, _arg6:Boolean=true):void{
}
public function getIsButtomPressed():Boolean{
return (_isButtonPressed);
}
public function getUIReturnVal():int{
return (_uiReturnVal);
}
public function promoteScreenToFocus():void{
}
public function setUIReturnVal(_arg1:int):void{
_uiReturnVal = _arg1;
}
public function setSelected(_arg1:UIButton):void{
_arg1.setSelected(true);
bSelected.push(_arg1);
}
}
}//package base.ui
Section 19
//FuncProxy (base.utils.FuncProxy)
package base.utils {
public dynamic class FuncProxy {
public static function create(_arg1:Object, _arg2:Function, ... _args):Function{
var aParameters:Array;
var i:Number;
var fProxy:Function;
var oTarget = _arg1;
var fFunction = _arg2;
var rest = _args;
aParameters = new Array();
i = 2;
while (i < rest.length) {
aParameters[(i - 2)] = rest[i];
i = (i + 1);
};
fProxy = function ():void{
var _local1:Array;
_local1 = rest.concat(aParameters);
fFunction.apply(oTarget, _local1);
};
return (fProxy);
}
}
}//package base.utils
Section 20
//Profile (base.utils.Profile)
package base.utils {
import base.*;
import flash.utils.*;
public class Profile {
private var _profiles:Array;
private var _gameContext:GameEntry;
public function Profile(_arg1:GameEntry){
_gameContext = _arg1;
_profiles = [];
}
public function StartProfile(_arg1:String):void{
var _local2:int;
var _local3:int;
_local2 = getTimer();
_local3 = 0;
while (_local3 < _profiles.length) {
if (_profiles[_local3].name == _arg1){
_profiles[_local3].startTime = _local2;
_profiles[_local3].endTime = 0;
};
_local3++;
};
}
public function EndProfile(_arg1:String):void{
var _local2:int;
var _local3:int;
_local2 = getTimer();
_local3 = 0;
while (_local3 < _profiles.length) {
if (_profiles[_local3].name == _arg1){
_profiles[_local3].endTime = _local2;
};
_local3++;
};
}
public function RegisterProfile(_arg1:String):void{
var _local2:Number;
trace(("**** registering profile ****" + _arg1));
_profiles.push(new Object());
_local2 = (_profiles.length - 1);
_profiles[_local2].name = _arg1;
_profiles[_local2].startTime = 0;
_profiles[_local2].endTime = 0;
}
public function ReportProfile():void{
var _local1:int;
var _local2:int;
trace("*********************************");
trace(("Reporting Profile " + _profiles.length));
trace(("frameRate: " + _gameContext.getTimeManager().getFramerate()));
_local1 = 0;
while (_local1 < _profiles.length) {
_local2 = (_profiles[_local1].endTime - _profiles[_local1].startTime);
trace(((("Profile " + _profiles[_local1].name) + ": ") + _local2));
_local1++;
};
trace("*********************************");
}
}
}//package base.utils
Section 21
//RandomNumber (base.utils.RandomNumber)
package base.utils {
public class RandomNumber {
public static var seed:uint = 1;
public static function nextDoubleRange(_arg1:Number, _arg2:Number):Number{
return ((_arg1 + ((_arg2 - _arg1) * nextDouble())));
}
public static function nextIntRange(_arg1:Number, _arg2:Number):uint{
_arg1 = (_arg1 - 0.4999);
_arg2 = (_arg2 + 0.4999);
return (Math.round((_arg1 + ((_arg2 - _arg1) * nextDouble()))));
}
public static function nextDouble():Number{
return ((gen() / 2147483647));
}
public static function gen():uint{
return ((seed = ((seed * 16807) % 2147483647)));
}
public static function nextInt():uint{
return (gen());
}
}
}//package base.utils
Section 22
//Time (base.utils.Time)
package base.utils {
import flash.utils.*;
public class Time {
private var _averageTime:Array;
var time:int;// = 0
private var _startTime;
private var _timeLastTick;
var frTimeMS:int;// = 0
private var _currentTime;
var fps:int;// = 0
var prevTime:int;// = 0
private var _currentPlaceInAvgArray:int;
static const FRAME_SAMPLES:int = 15;
public function Time(){
time = 0;
frTimeMS = 0;
prevTime = 0;
fps = 0;
super();
_startTime = getTimer();
_averageTime = [];
_currentPlaceInAvgArray = 0;
}
public function getAverageDeltaMilliseconds():Number{
var _local1:*;
var _local2:int;
_local1 = 0;
if (_averageTime.length < FRAME_SAMPLES){
return (0);
};
_local2 = FRAME_SAMPLES;
while (_local2--) {
_local1 = (_local1 + _averageTime[_local2]);
};
_local1 = (_local1 / FRAME_SAMPLES);
return (_local1);
}
public function getFrameDeltaSeconds():Number{
return ((frTimeMS / 1000));
}
public function getFramerate():Number{
var _local1:*;
_local1 = Math.floor((1000 / getAverageDeltaMilliseconds()));
return (_local1);
}
public function getTotalMillisecondsElapsed():Number{
var _local1:int;
_local1 = getTimer();
return ((_local1 - _startTime));
}
public function markTimeThisTick(){
var _local1:int;
_local1 = getTimer();
frTimeMS = (_local1 - prevTime);
prevTime = _local1;
var _local2 = _currentPlaceInAvgArray++;
_averageTime[_local2] = frTimeMS;
if (_currentPlaceInAvgArray >= FRAME_SAMPLES){
_currentPlaceInAvgArray = 0;
};
}
public function getFrameDeltaMilliseconds():Number{
return (frTimeMS);
}
}
}//package base.utils
Section 23
//TwoDMath (base.utils.TwoDMath)
package base.utils {
public class TwoDMath {
private static var _ptX:Number;
private static var _ptY:Number;
public function TwoDMath(){
_ptX = 0;
_ptY = 0;
}
public static function degreesInRadians(_arg1:Number):Number{
return (((_arg1 * Math.PI) / 180));
}
public static function dot(_arg1:Object, _arg2:Object):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function getIntersectPtX():Number{
return (_ptX);
}
public static function getIntersectPtY():Number{
return (_ptY);
}
public static function inSegment(_arg1:Object, _arg2:Object, _arg3:Object){
if (_arg2.x != _arg3.x){
if ((((_arg2.x <= _arg1.x)) && ((_arg1.x <= _arg3.x)))){
return (1);
};
if ((((_arg2.x >= _arg1.x)) && ((_arg1.x >= _arg3.x)))){
return (1);
};
} else {
if ((((_arg2.y <= _arg1.y)) && ((_arg1.y <= _arg3.y)))){
return (1);
};
if ((((_arg2.y >= _arg1.y)) && ((_arg1.y >= _arg3.y)))){
return (1);
};
};
return (0);
}
public static function radiansInDegrees(_arg1:Number):Number{
return (((_arg1 * 180) / Math.PI));
}
public static function intersect2D(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number):Number{
var _local9:*;
var _local10:Object;
var _local11:Object;
var _local12:Object;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Object;
var _local17:Number;
var _local18:Number;
var _local19:Object;
var _local20:Number;
var _local21:Number;
var _local22:Number;
_local9 = 1E-8;
_local10 = new Object();
_local11 = new Object();
_local12 = new Object();
_local10.x = (_arg3 - _arg1);
_local10.y = (_arg4 - _arg2);
_local11.x = (_arg7 - _arg5);
_local11.y = (_arg8 - _arg6);
_local12.x = (_arg1 - _arg5);
_local12.y = (_arg2 - _arg6);
_local13 = perp(_local10, _local11);
if (Math.abs(_local13) < _local9){
if (((!((perp(_local10, _local12) == 0))) || (!((perp(_local11, _local12) == 0))))){
return (0);
};
_local17 = dot(_local10, _local10);
_local18 = dot(_local11, _local11);
if ((((_local17 == 0)) && ((_local18 == 0)))){
if (((!((_arg1 == _arg5))) || (!((_arg2 == _arg6))))){
return (0);
};
_ptX = _arg1;
_ptY = _arg2;
return (1);
};
_local19 = new Object();
_local19.x = (_arg3 - _arg5);
_local19.y = (_arg4 - _arg6);
if (_local11.x != 0){
_local20 = (_local12.x / _local11.x);
_local21 = (_local19.x / _local11.x);
} else {
_local20 = (_local12.y / _local11.y);
_local21 = (_local19.y / _local11.y);
};
if (_local20 > _local21){
_local22 = _local20;
_local20 = _local21;
_local21 = _local22;
};
if ((((_local20 > 1)) || ((_local21 < 0)))){
return (0);
};
_local20 = ((_local20)<0) ? 0 : _local20;
_local21 = ((_local21)>1) ? 1 : _local21;
if (_local20 == _local21){
return (1);
};
};
_local14 = (perp(_local11, _local12) / _local13);
if ((((_local14 < 0)) || ((_local14 > 1)))){
return (0);
};
_local15 = (perp(_local10, _local12) / _local13);
if ((((_local15 < 0)) || ((_local15 > 1)))){
return (0);
};
_local16 = new Object();
_local16.x = (_arg1 + (_local14 * _local10.x));
_local16.y = (_arg2 + (_local14 * _local10.y));
_ptX = _local16.x;
_ptY = _local16.y;
return (1);
}
public static function perp(_arg1:Object, _arg2:Object):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
public static function getVector(_arg1:Object, _arg2:Object):Object{
var _local3:Object;
_local3 = new Object();
_local3.x = (_arg2.x - _arg1.x);
_local3.y = (_arg2.y - _arg1.y);
return (_local3);
}
public static function getAngle(_arg1:Object, _arg2:Object):Number{
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
_local3 = Math.sqrt(((_arg1.x * _arg1.x) + (_arg1.y * _arg1.y)));
_local4 = Math.sqrt(((_arg2.x * _arg2.x) + (_arg2.y * _arg2.y)));
_local5 = dot(_arg1, _arg2);
if (_local5 < 0){
};
_local6 = (_local5 / (_local3 * _local4));
_local7 = (Math.acos(_local6) * (180 / Math.PI));
return (_local7);
}
}
}//package base.utils
Section 24
//GameManager (base.GameManager)
package base {
import game.states.*;
public class GameManager {
private var _currentGameState;
private var _followingGameState;
private var _nextGameState;
private var _gameContext:GameEntry;
public function GameManager(_arg1:GameEntry, _arg2=null){
trace("|----@ GAME MANAGER @----|");
_gameContext = _arg1;
_currentGameState = null;
if (_arg2 != null){
setNextState(_arg2);
};
}
public function setNextState(_arg1){
_nextGameState = new _arg1(_gameContext, this);
}
public function getFollowingGameState(){
return (_followingGameState);
}
public function getCurrentGameState():GameState{
return (_currentGameState);
}
public function setFollowingGameState(_arg1){
_followingGameState = _arg1;
}
public function Update(){
if (_currentGameState != _nextGameState){
_currentGameState = _nextGameState;
_currentGameState.Entry();
} else {
if (_currentGameState == _nextGameState){
_currentGameState.Update();
if (_currentGameState != _nextGameState){
_currentGameState.Exit();
_currentGameState = null;
};
};
};
}
}
}//package base
Section 25
//GameState (base.GameState)
package base {
import base.ui.*;
import base.pad.*;
import game.*;
import base.sound.*;
public class GameState {
protected var snd:SoundModule;
protected var pad:PadManager;
protected var ui:UIManager;
protected var gameManager:GameManager;
protected var gameData:GameData;
protected var gameContext:GameEntry;
public function GameState(_arg1:GameEntry, _arg2:GameManager){
if (_arg1 != null){
this.gameContext = _arg1;
this.gameManager = _arg2;
gameData = _arg1.getGameData();
pad = _arg1.getPadManager();
snd = _arg1.getSoundModule();
ui = _arg1.getUIManager();
};
}
public function Update():void{
}
public function Entry():void{
}
public function Exit():void{
}
}
}//package base
Section 26
//b2CircleDef (Box2D.Collision.Shapes.b2CircleDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2CircleDef extends b2ShapeDef {
public var localPosition:b2Vec2;
public var radius:Number;
public function b2CircleDef(){
localPosition = new b2Vec2(0, 0);
super();
type = b2Shape.e_circleShape;
radius = 1;
}
}
}//package Box2D.Collision.Shapes
Section 27
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.*;
public class b2CircleShape extends b2Shape {
b2internal var m_localPosition:b2Vec2;
b2internal var m_radius:Number;
public function b2CircleShape(_arg1:b2ShapeDef){
var _local2:b2CircleDef;
m_localPosition = new b2Vec2();
super(_arg1);
_local2 = (_arg1 as b2CircleDef);
m_type = e_circleShape;
m_localPosition.SetV(_local2.localPosition);
m_radius = _local2.radius;
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2XForm, _arg4:b2Vec2):Number{
var _local5:b2Vec2;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
_local5 = b2Math.b2MulX(_arg3, m_localPosition);
_local6 = -((b2Math.b2Dot(_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));
};
_local7 = (m_radius * m_radius);
_local8 = (_local6 * _local6);
_local9 = ((_local7 * (Math.asin((_local6 / m_radius)) + (Math.PI / 2))) + (_local6 * Math.sqrt((_local7 - _local8))));
_local10 = (((-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 ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.R;
_local4 = (_arg2.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y)));
_local5 = (_arg2.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y)));
_arg1.lowerBound.Set((_local4 - m_radius), (_local5 - m_radius));
_arg1.upperBound.Set((_local4 + m_radius), (_local5 + m_radius));
}
override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = _arg2.R;
_local5 = (_arg2.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y)));
_local6 = (_arg2.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y)));
_local4 = _arg3.R;
_local7 = (_arg3.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y)));
_local8 = (_arg3.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y)));
_arg1.lowerBound.Set((((_local5 < _local7)) ? _local5 : _local7 - m_radius), (((_local6 < _local8)) ? _local6 : _local8 - m_radius));
_arg1.upperBound.Set((((_local5 > _local7)) ? _local5 : _local7 + m_radius), (((_local6 > _local8)) ? _local6 : _local8 + m_radius));
}
public function GetLocalPosition():b2Vec2{
return (m_localPosition);
}
override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{
var _local6:b2Mat22;
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;
_local6 = _arg1.R;
_local7 = (_arg1.position.x + ((_local6.col1.x * m_localPosition.x) + (_local6.col2.x * m_localPosition.y)));
_local8 = (_arg1.position.y + ((_local6.col1.y * m_localPosition.x) + (_local6.col2.y * m_localPosition.y)));
_local9 = (_arg4.p1.x - _local7);
_local10 = (_arg4.p1.y - _local8);
_local11 = (((_local9 * _local9) + (_local10 * _local10)) - (m_radius * m_radius));
if (_local11 < 0){
_arg2[0] = 0;
return (e_startsInsideCollide);
};
_local12 = (_arg4.p2.x - _arg4.p1.x);
_local13 = (_arg4.p2.y - _arg4.p1.y);
_local14 = ((_local9 * _local12) + (_local10 * _local13));
_local15 = ((_local12 * _local12) + (_local13 * _local13));
_local16 = ((_local14 * _local14) - (_local15 * _local11));
if ((((_local16 < 0)) || ((_local15 < Number.MIN_VALUE)))){
return (e_missCollide);
};
_local17 = -((_local14 + Math.sqrt(_local16)));
if ((((0 <= _local17)) && ((_local17 <= (_arg5 * _local15))))){
_local17 = (_local17 / _local15);
_arg2[0] = _local17;
_arg3.x = (_local9 + (_local17 * _local12));
_arg3.y = (_local10 + (_local17 * _local13));
_arg3.Normalize();
return (e_hitCollide);
};
return (e_missCollide);
}
public function GetRadius():Number{
return (m_radius);
}
override public function ComputeMass(_arg1:b2MassData):void{
_arg1.mass = (((m_density * b2Settings.b2_pi) * m_radius) * m_radius);
_arg1.center.SetV(m_localPosition);
_arg1.I = (_arg1.mass * (((0.5 * m_radius) * m_radius) + ((m_localPosition.x * m_localPosition.x) + (m_localPosition.y * m_localPosition.y))));
}
override b2internal function UpdateSweepRadius(_arg1:b2Vec2):void{
var _local2:Number;
var _local3:Number;
_local2 = (m_localPosition.x - _arg1.x);
_local3 = (m_localPosition.y - _arg1.y);
_local2 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
m_sweepRadius = ((_local2 + m_radius) - b2Settings.b2_toiSlop);
}
override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
_local3 = _arg1.R;
_local4 = (_arg1.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y)));
_local5 = (_arg1.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y)));
_local4 = (_arg2.x - _local4);
_local5 = (_arg2.y - _local5);
return ((((_local4 * _local4) + (_local5 * _local5)) <= (m_radius * m_radius)));
}
}
}//package Box2D.Collision.Shapes
Section 28
//b2EdgeChainDef (Box2D.Collision.Shapes.b2EdgeChainDef)
package Box2D.Collision.Shapes {
public class b2EdgeChainDef extends b2ShapeDef {
public var isALoop:Boolean;
public var vertexCount:int;
public var vertices:Array;
public function b2EdgeChainDef(){
type = b2Shape.e_edgeShape;
vertexCount = 0;
isALoop = true;
vertices = [];
}
}
}//package Box2D.Collision.Shapes
Section 29
//b2EdgeShape (Box2D.Collision.Shapes.b2EdgeShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.*;
public class b2EdgeShape extends b2Shape {
b2internal var m_v2:b2Vec2;
b2internal var m_v1:b2Vec2;
b2internal var m_coreV1:b2Vec2;
private var s_supportVec:b2Vec2;
b2internal var m_coreV2:b2Vec2;
b2internal var m_length:Number;
b2internal var m_cornerConvex1:Boolean;
b2internal var m_cornerConvex2:Boolean;
b2internal var m_direction:b2Vec2;
b2internal var m_cornerDir1:b2Vec2;
b2internal var m_cornerDir2:b2Vec2;
b2internal var m_nextEdge:b2EdgeShape;
b2internal var m_prevEdge:b2EdgeShape;
b2internal var m_normal:b2Vec2;
public function b2EdgeShape(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2ShapeDef){
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(_arg3);
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));
}
public function GetVertex1():b2Vec2{
return (m_v1);
}
override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
return (false);
}
public function GetCorner2Vector():b2Vec2{
return (m_cornerDir2);
}
public function GetDirectionVector():b2Vec2{
return (m_direction);
}
override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{
var _local6:b2Mat22;
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;
_local7 = (_arg4.p2.x - _arg4.p1.x);
_local8 = (_arg4.p2.y - _arg4.p1.y);
_local6 = _arg1.R;
_local9 = (_arg1.position.x + ((_local6.col1.x * m_v1.x) + (_local6.col2.x * m_v1.y)));
_local10 = (_arg1.position.y + ((_local6.col1.y * m_v1.x) + (_local6.col2.y * m_v1.y)));
_local11 = ((_arg1.position.y + ((_local6.col1.y * m_v2.x) + (_local6.col2.y * m_v2.y))) - _local10);
_local12 = -(((_arg1.position.x + ((_local6.col1.x * m_v2.x) + (_local6.col2.x * m_v2.y))) - _local9));
_local13 = (100 * Number.MIN_VALUE);
_local14 = -(((_local7 * _local11) + (_local8 * _local12)));
if (_local14 > _local13){
_local15 = (_arg4.p1.x - _local9);
_local16 = (_arg4.p1.y - _local10);
_local17 = ((_local15 * _local11) + (_local16 * _local12));
if ((((0 <= _local17)) && ((_local17 <= (_arg5 * _local14))))){
_local18 = ((-(_local7) * _local16) + (_local8 * _local15));
if (((((-(_local13) * _local14) <= _local18)) && ((_local18 <= (_local14 * (1 + _local13)))))){
_local17 = (_local17 / _local14);
_arg2[0] = _local17;
_local19 = Math.sqrt(((_local11 * _local11) + (_local12 * _local12)));
_arg3.x = (_local11 / _local19);
_arg3.y = (_local12 / _local19);
return (e_hitCollide);
};
};
};
return (e_missCollide);
}
public function GetNextEdge():b2EdgeShape{
return (m_nextEdge);
}
override public function ComputeMass(_arg1:b2MassData):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:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = _arg1.R;
_local5 = (_arg1.position.x + ((_local4.col1.x * m_coreV1.x) + (_local4.col2.x * m_coreV1.y)));
_local6 = (_arg1.position.y + ((_local4.col1.y * m_coreV1.x) + (_local4.col2.y * m_coreV1.y)));
_local7 = (_arg1.position.x + ((_local4.col1.x * m_coreV2.x) + (_local4.col2.x * m_coreV2.y)));
_local8 = (_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 GetLength():Number{
return (m_length);
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2XForm, _arg4:b2Vec2):Number{
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Number;
_local5 = new b2Vec2((_arg1.x * _arg2), (_arg1.y * _arg2));
_local6 = b2Math.b2MulX(_arg3, m_v1);
_local7 = b2Math.b2MulX(_arg3, m_v2);
_local8 = (b2Math.b2Dot(_arg1, _local6) - _arg2);
_local9 = (b2Math.b2Dot(_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 ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
_local4 = _arg2.R;
_local5 = (_arg2.position.x + ((_local4.col1.x * m_v1.x) + (_local4.col2.x * m_v1.y)));
_local6 = (_arg2.position.y + ((_local4.col1.y * m_v1.x) + (_local4.col2.y * m_v1.y)));
_local7 = (_arg2.position.x + ((_local4.col1.x * m_v2.x) + (_local4.col2.x * m_v2.y)));
_local8 = (_arg2.position.y + ((_local4.col1.y * m_v2.x) + (_local4.col2.y * m_v2.y)));
_local4 = _arg3.R;
_local9 = (_arg3.position.x + ((_local4.col1.x * m_v1.x) + (_local4.col2.x * m_v1.y)));
_local10 = (_arg3.position.y + ((_local4.col1.y * m_v1.x) + (_local4.col2.y * m_v1.y)));
_local11 = (_arg3.position.x + ((_local4.col1.x * m_v2.x) + (_local4.col2.x * m_v2.y)));
_local12 = (_arg3.position.y + ((_local4.col1.y * m_v2.x) + (_local4.col2.y * m_v2.y)));
_arg1.lowerBound.x = ((((((_local5 < _local7)) ? _local5 : _local7 < _local9)) ? ((_local5 < _local7)) ? _local5 : _local7 : _local9 < _local11)) ? ((((_local5 < _local7)) ? _local5 : _local7 < _local9)) ? ((_local5 < _local7)) ? _local5 : _local7 : _local9 : _local11;
_arg1.lowerBound.y = ((((((_local6 < _local8)) ? _local6 : _local8 < _local10)) ? ((_local6 < _local8)) ? _local6 : _local8 : _local10 < _local12)) ? ((((_local6 < _local8)) ? _local6 : _local8 < _local10)) ? ((_local6 < _local8)) ? _local6 : _local8 : _local10 : _local12;
_arg1.upperBound.x = ((((((_local5 > _local7)) ? _local5 : _local7 > _local9)) ? ((_local5 > _local7)) ? _local5 : _local7 : _local9 > _local11)) ? ((((_local5 > _local7)) ? _local5 : _local7 > _local9)) ? ((_local5 > _local7)) ? _local5 : _local7 : _local9 : _local11;
_arg1.upperBound.y = ((((((_local6 > _local8)) ? _local6 : _local8 > _local10)) ? ((_local6 > _local8)) ? _local6 : _local8 : _local10 > _local12)) ? ((((_local6 > _local8)) ? _local6 : _local8 > _local10)) ? ((_local6 > _local8)) ? _local6 : _local8 : _local10 : _local12;
}
public function GetCoreVertex1():b2Vec2{
return (m_coreV1);
}
public function GetCoreVertex2():b2Vec2{
return (m_coreV2);
}
public function GetFirstVertex(_arg1:b2XForm):b2Vec2{
var _local2:b2Mat22;
_local2 = _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 GetCorner1Vector():b2Vec2{
return (m_cornerDir1);
}
public function GetPrevEdge():b2EdgeShape{
return (m_prevEdge);
}
b2internal function SetPrevEdge(_arg1:b2EdgeShape, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Boolean):void{
m_prevEdge = _arg1;
m_coreV1 = _arg2;
m_cornerDir1 = _arg3;
m_cornerConvex1 = _arg4;
}
override b2internal function UpdateSweepRadius(_arg1:b2Vec2):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = (m_coreV1.x - _arg1.x);
_local3 = (m_coreV1.y - _arg1.y);
_local4 = ((_local2 * _local2) + (_local3 * _local3));
_local2 = (m_coreV2.x - _arg1.x);
_local3 = (m_coreV2.y - _arg1.y);
_local5 = ((_local2 * _local2) + (_local3 * _local3));
m_sweepRadius = Math.sqrt(((_local4 > _local5)) ? _local4 : _local5);
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local3 = _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 GetVertex2():b2Vec2{
return (m_v2);
}
}
}//package Box2D.Collision.Shapes
Section 30
//b2FilterData (Box2D.Collision.Shapes.b2FilterData)
package Box2D.Collision.Shapes {
public class b2FilterData {
public var maskBits:uint;// = 0xFFFF
public var groupIndex:int;// = 0
public var categoryBits:uint;// = 1
public function b2FilterData(){
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
super();
}
public function Copy():b2FilterData{
var _local1:b2FilterData;
_local1 = new b2FilterData();
_local1.categoryBits = categoryBits;
_local1.maskBits = maskBits;
_local1.groupIndex = groupIndex;
return (_local1);
}
}
}//package Box2D.Collision.Shapes
Section 31
//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(){
mass = 0;
center = new b2Vec2(0, 0);
I = 0;
super();
}
}
}//package Box2D.Collision.Shapes
Section 32
//b2PolygonDef (Box2D.Collision.Shapes.b2PolygonDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PolygonDef extends b2ShapeDef {
public var vertexCount:int;
public var vertices:Array;
private static var s_mat:b2Mat22 = new b2Mat22();
public function b2PolygonDef(){
var _local1:int;
vertices = new Array(b2Settings.b2_maxPolygonVertices);
super();
type = b2Shape.e_polygonShape;
vertexCount = 0;
_local1 = 0;
while (_local1 < b2Settings.b2_maxPolygonVertices) {
vertices[_local1] = new b2Vec2();
_local1++;
};
}
public function SetAsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):void{
var _local5:b2Vec2;
var _local6:b2Mat22;
var _local7:int;
vertexCount = 4;
vertices[0].Set(-(_arg1), -(_arg2));
vertices[1].Set(_arg1, -(_arg2));
vertices[2].Set(_arg1, _arg2);
vertices[3].Set(-(_arg1), _arg2);
if (_arg3){
_local5 = _arg3;
_local6 = s_mat;
_local6.Set(_arg4);
_local7 = 0;
while (_local7 < vertexCount) {
_arg3 = vertices[_local7];
_arg1 = (_local5.x + ((_local6.col1.x * _arg3.x) + (_local6.col2.x * _arg3.y)));
_arg3.y = (_local5.y + ((_local6.col1.y * _arg3.x) + (_local6.col2.y * _arg3.y)));
_arg3.x = _arg1;
_local7++;
};
};
}
public function SetAsBox(_arg1:Number, _arg2:Number):void{
vertexCount = 4;
vertices[0].Set(-(_arg1), -(_arg2));
vertices[1].Set(_arg1, -(_arg2));
vertices[2].Set(_arg1, _arg2);
vertices[3].Set(-(_arg1), _arg2);
}
}
}//package Box2D.Collision.Shapes
Section 33
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2PolygonShape extends b2Shape {
b2internal var m_vertices:Array;
private var s_supportVec:b2Vec2;
b2internal var m_normals:Array;
private var m_obb:b2OBB;
private var m_coreVertices:Array;
b2internal var m_centroid:b2Vec2;
b2internal var m_vertexCount:int;
private static var s_computeMat:b2Mat22 = new b2Mat22();
private static var s_sweptAABB1:b2AABB = new b2AABB();
private static var s_sweptAABB2:b2AABB = new b2AABB();
public function b2PolygonShape(_arg1:b2ShapeDef){
var _local2:b2PolygonDef;
var _local3:int;
var _local4:int;
var _local5:int;
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;
s_supportVec = new b2Vec2();
m_obb = new b2OBB();
m_vertices = new Array(b2Settings.b2_maxPolygonVertices);
m_normals = new Array(b2Settings.b2_maxPolygonVertices);
m_coreVertices = new Array(b2Settings.b2_maxPolygonVertices);
super(_arg1);
m_type = e_polygonShape;
_local2 = (_arg1 as b2PolygonDef);
m_vertexCount = _local2.vertexCount;
_local4 = _local3;
_local5 = _local3;
_local3 = 0;
while (_local3 < m_vertexCount) {
m_vertices[_local3] = _local2.vertices[_local3].Copy();
_local3++;
};
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = _local3;
_local5 = (((_local3 + 1) < m_vertexCount)) ? (_local3 + 1) : 0;
_local6 = (m_vertices[_local5].x - m_vertices[_local4].x);
_local7 = (m_vertices[_local5].y - m_vertices[_local4].y);
_local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
m_normals[_local3] = new b2Vec2((_local7 / _local8), (-(_local6) / _local8));
_local3++;
};
m_centroid = ComputeCentroid(_local2.vertices, _local2.vertexCount);
ComputeOBB(m_obb, m_vertices, m_vertexCount);
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = (((_local3 - 1) >= 0)) ? (_local3 - 1) : (m_vertexCount - 1);
_local5 = _local3;
_local9 = m_normals[_local4].x;
_local10 = m_normals[_local4].y;
_local11 = m_normals[_local5].x;
_local12 = m_normals[_local5].y;
_local13 = (m_vertices[_local3].x - m_centroid.x);
_local14 = (m_vertices[_local3].y - m_centroid.y);
_local15 = (((_local9 * _local13) + (_local10 * _local14)) - b2Settings.b2_toiSlop);
_local16 = (((_local11 * _local13) + (_local12 * _local14)) - b2Settings.b2_toiSlop);
_local17 = (1 / ((_local9 * _local12) - (_local10 * _local11)));
m_coreVertices[_local3] = new b2Vec2(((_local17 * ((_local12 * _local15) - (_local10 * _local16))) + m_centroid.x), ((_local17 * ((_local9 * _local16) - (_local11 * _local15))) + m_centroid.y));
_local3++;
};
}
override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
var _local3:b2Vec2;
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local10:Number;
_local4 = _arg1.R;
_local5 = (_arg2.x - _arg1.position.x);
_local6 = (_arg2.y - _arg1.position.y);
_local7 = ((_local5 * _local4.col1.x) + (_local6 * _local4.col1.y));
_local8 = ((_local5 * _local4.col2.x) + (_local6 * _local4.col2.y));
_local9 = 0;
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);
}
public function GetCoreVertices():Array{
return (m_coreVertices);
}
public function GetCentroid():b2Vec2{
return (m_centroid);
}
override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{
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 _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:Number;
var _local21:Number;
_local6 = 0;
_local7 = _arg5;
_local8 = (_arg4.p1.x - _arg1.position.x);
_local9 = (_arg4.p1.y - _arg1.position.y);
_local10 = _arg1.R;
_local12 = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y));
_local13 = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y));
_local8 = (_arg4.p2.x - _arg1.position.x);
_local9 = (_arg4.p2.y - _arg1.position.y);
_local10 = _arg1.R;
_local14 = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y));
_local15 = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y));
_local16 = (_local14 - _local12);
_local17 = (_local15 - _local13);
_local18 = -1;
_local19 = 0;
while (_local19 < m_vertexCount) {
_local11 = m_vertices[_local19];
_local8 = (_local11.x - _local12);
_local9 = (_local11.y - _local13);
_local11 = m_normals[_local19];
_local20 = ((_local11.x * _local8) + (_local11.y * _local9));
_local21 = ((_local11.x * _local16) + (_local11.y * _local17));
if (_local21 == 0){
if (_local20 < 0){
return (e_missCollide);
};
} else {
if ((((_local21 < 0)) && ((_local20 < (_local6 * _local21))))){
_local6 = (_local20 / _local21);
_local18 = _local19;
} else {
if ((((_local21 > 0)) && ((_local20 < (_local7 * _local21))))){
_local7 = (_local20 / _local21);
};
};
};
if (_local7 < _local6){
return (e_missCollide);
};
_local19++;
};
if (_local18 >= 0){
_arg2[0] = _local6;
_local10 = _arg1.R;
_local11 = m_normals[_local18];
_arg3.x = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_arg3.y = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
return (e_hitCollide);
};
_arg2[0] = 0;
return (e_startsInsideCollide);
}
override public function ComputeMass(_arg1:b2MassData):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local10:b2Vec2;
var _local11:b2Vec2;
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;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = 0;
_local6 = 0;
_local7 = 0;
_local8 = (1 / 3);
_local9 = 0;
while (_local9 < m_vertexCount) {
_local10 = m_vertices[_local9];
_local11 = (((_local9 + 1) < m_vertexCount)) ? m_vertices[int((_local9 + 1))] : m_vertices[0];
_local12 = (_local10.x - _local6);
_local13 = (_local10.y - _local7);
_local14 = (_local11.x - _local6);
_local15 = (_local11.y - _local7);
_local16 = ((_local12 * _local15) - (_local13 * _local14));
_local17 = (0.5 * _local16);
_local4 = (_local4 + _local17);
_local2 = (_local2 + ((_local17 * _local8) * ((_local6 + _local10.x) + _local11.x)));
_local3 = (_local3 + ((_local17 * _local8) * ((_local7 + _local10.y) + _local11.y)));
_local18 = _local6;
_local19 = _local7;
_local20 = _local12;
_local21 = _local13;
_local22 = _local14;
_local23 = _local15;
_local24 = ((_local8 * ((0.25 * (((_local20 * _local20) + (_local22 * _local20)) + (_local22 * _local22))) + ((_local18 * _local20) + (_local18 * _local22)))) + ((0.5 * _local18) * _local18));
_local25 = ((_local8 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19));
_local5 = (_local5 + (_local16 * (_local24 + _local25)));
_local9++;
};
_arg1.mass = (m_density * _local4);
_local2 = (_local2 * (1 / _local4));
_local3 = (_local3 * (1 / _local4));
_arg1.center.Set(_local2, _local3);
_arg1.I = (m_density * _local5);
}
public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:b2Vec2;
var _local5:b2Mat22;
var _local6:Number;
var _local7:Number;
var _local8:int;
var _local9:Number;
var _local10:int;
var _local11:Number;
_local5 = _arg1.R;
_local6 = ((_arg2 * _local5.col1.x) + (_arg3 * _local5.col1.y));
_local7 = ((_arg2 * _local5.col2.x) + (_arg3 * _local5.col2.y));
_local8 = 0;
_local4 = m_coreVertices[0];
_local9 = ((_local4.x * _local6) + (_local4.y * _local7));
_local10 = 1;
while (_local10 < m_vertexCount) {
_local4 = m_coreVertices[_local10];
_local11 = ((_local4.x * _local6) + (_local4.y * _local7));
if (_local11 > _local9){
_local8 = _local10;
_local9 = _local11;
};
_local10++;
};
_local5 = _arg1.R;
_local4 = m_coreVertices[_local8];
s_supportVec.x = (_arg1.position.x + ((_local5.col1.x * _local4.x) + (_local5.col2.x * _local4.y)));
s_supportVec.y = (_arg1.position.y + ((_local5.col1.y * _local4.x) + (_local5.col2.y * _local4.y)));
return (s_supportVec);
}
public function GetVertexCount():int{
return (m_vertexCount);
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2XForm, _arg4:b2Vec2):Number{
var _local5:b2Vec2;
var _local6:Number;
var _local7:Array;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:Boolean;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:Number;
var _local16:Number;
var _local17:b2Vec2;
var _local18:b2Vec2;
var _local19:Number;
var _local20:b2Vec2;
var _local21:b2Vec2;
var _local22:b2Vec2;
var _local23:Boolean;
var _local24:b2MassData;
var _local25:Number;
_local5 = b2Math.b2MulTMV(_arg3.R, _arg1);
_local6 = (_arg2 - b2Math.b2Dot(_arg1, _arg3.position));
_local7 = new Array();
_local8 = 0;
_local9 = -1;
_local10 = -1;
_local11 = false;
_local12 = 0;
while (_local12 < m_vertexCount) {
_local7[_local12] = (b2Math.b2Dot(_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);
_arg4.SetV(b2Math.b2MulX(_arg3, _local24.center));
return ((_local24.mass / m_density));
};
return (0);
case 1:
if (_local9 == -1){
_local9 = (m_vertexCount - 1);
} else {
_local10 = (m_vertexCount - 1);
};
break;
};
_local13 = ((_local9 + 1) % m_vertexCount);
_local14 = ((_local10 + 1) % m_vertexCount);
_local15 = ((0 - _local7[_local9]) / (_local7[_local13] - _local7[_local9]));
_local16 = ((0 - _local7[_local10]) / (_local7[_local14] - _local7[_local10]));
_local17 = new b2Vec2(((m_vertices[_local9].x * (1 - _local15)) + (m_vertices[_local13].x * _local15)), ((m_vertices[_local9].y * (1 - _local15)) + (m_vertices[_local13].y * _local15)));
_local18 = new b2Vec2(((m_vertices[_local10].x * (1 - _local16)) + (m_vertices[_local14].x * _local16)), ((m_vertices[_local10].y * (1 - _local16)) + (m_vertices[_local14].y * _local16)));
_local19 = 0;
_local20 = new b2Vec2();
_local21 = 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.b2MulX(_arg3, _local20));
return (_local19);
}
override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
var _local4:b2AABB;
var _local5:b2AABB;
_local4 = s_sweptAABB1;
_local5 = s_sweptAABB2;
ComputeAABB(_local4, _arg2);
ComputeAABB(_local5, _arg3);
_arg1.lowerBound.Set(((_local4.lowerBound.x < _local5.lowerBound.x)) ? _local4.lowerBound.x : _local5.lowerBound.x, ((_local4.lowerBound.y < _local5.lowerBound.y)) ? _local4.lowerBound.y : _local5.lowerBound.y);
_arg1.upperBound.Set(((_local4.upperBound.x > _local5.upperBound.x)) ? _local4.upperBound.x : _local5.upperBound.x, ((_local4.upperBound.y > _local5.upperBound.y)) ? _local4.upperBound.y : _local5.upperBound.y);
}
public function GetVertices():Array{
return (m_vertices);
}
public function GetNormals():Array{
return (m_normals);
}
public function GetOBB():b2OBB{
return (m_obb);
}
public function GetFirstVertex(_arg1:b2XForm):b2Vec2{
return (b2Math.b2MulX(_arg1, m_coreVertices[0]));
}
public function Centroid(_arg1:b2XForm):b2Vec2{
return (b2Math.b2MulX(_arg1, m_centroid));
}
override b2internal function UpdateSweepRadius(_arg1:b2Vec2):void{
var _local2:b2Vec2;
var _local3:int;
var _local4:Number;
var _local5:Number;
m_sweepRadius = 0;
_local3 = 0;
while (_local3 < m_vertexCount) {
_local2 = m_coreVertices[_local3];
_local4 = (_local2.x - _arg1.x);
_local5 = (_local2.y - _arg1.y);
_local4 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
if (_local4 > m_sweepRadius){
m_sweepRadius = _local4;
};
_local3++;
};
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:b2Mat22;
var _local6:b2Mat22;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
_local5 = s_computeMat;
_local3 = _arg2.R;
_local4 = m_obb.R.col1;
_local5.col1.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local5.col1.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local4 = m_obb.R.col2;
_local5.col2.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local5.col2.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local5.Abs();
_local6 = _local5;
_local4 = m_obb.extents;
_local7 = ((_local6.col1.x * _local4.x) + (_local6.col2.x * _local4.y));
_local8 = ((_local6.col1.y * _local4.x) + (_local6.col2.y * _local4.y));
_local3 = _arg2.R;
_local4 = m_obb.center;
_local9 = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)));
_local10 = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)));
_arg1.lowerBound.Set((_local9 - _local7), (_local10 - _local8));
_arg1.upperBound.Set((_local9 + _local7), (_local10 + _local8));
}
public static function ComputeCentroid(_arg1:Array, _arg2:int):b2Vec2{
var _local3:b2Vec2;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:int;
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();
_local4 = 0;
_local5 = 0;
_local6 = 0;
_local7 = (1 / 3);
_local8 = 0;
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);
}
b2internal static function ComputeOBB(_arg1:b2OBB, _arg2:Array, _arg3:int):void{
var _local4:int;
var _local5:Array;
var _local6:Number;
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;
_local5 = new Array((b2Settings.b2_maxPolygonVertices + 1));
_local4 = 0;
while (_local4 < _arg3) {
_local5[_local4] = _arg2[_local4];
_local4++;
};
_local5[_arg3] = _local5[0];
_local6 = 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++;
};
}
}
}//package Box2D.Collision.Shapes
Section 34
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2Shape {
b2internal var m_type:int;
b2internal var m_sweepRadius:Number;
private var m_proxy:b2Proxy;
private var m_filter:b2FilterData;
b2internal var m_friction:Number;
b2internal var m_next:b2Shape;
b2internal var m_restitution:Number;
private var m_userData;
b2internal var m_density:Number;
private var m_isSensor:Boolean;
b2internal var m_body:b2Body;
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_unknownShape:int = -1;
b2internal static const e_circleShape:int = 0;
b2internal static const e_shapeTypeCount:int = 3;
public static const e_startsInsideCollide:int = -1;
private static var s_resetAABB:b2AABB = new b2AABB();
private static var s_syncAABB:b2AABB = new b2AABB();
private static var s_proxyAABB:b2AABB = new b2AABB();
public function b2Shape(_arg1:b2ShapeDef){
m_userData = _arg1.userData;
m_friction = _arg1.friction;
m_restitution = _arg1.restitution;
m_density = _arg1.density;
m_body = null;
m_sweepRadius = 0;
m_next = null;
m_proxy = null;
m_filter = _arg1.filter.Copy();
m_isSensor = _arg1.isSensor;
}
public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2XForm, _arg4:b2Vec2):Number{
return (0);
}
public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
return (false);
}
public function GetSweepRadius():Number{
return (m_sweepRadius);
}
public function GetNext():b2Shape{
return (m_next);
}
public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
}
public function SetRestitution(_arg1:Number):void{
m_restitution = _arg1;
}
public function GetType():int{
return (m_type);
}
public function GetRestitution():Number{
return (m_restitution);
}
public function GetFriction():Number{
return (m_friction);
}
public function GetFilterData():b2FilterData{
return (m_filter.Copy());
}
public function SetFriction(_arg1:Number):void{
m_friction = _arg1;
}
public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{
return (e_missCollide);
}
public function SetSensor(_arg1:Boolean):void{
m_isSensor = _arg1;
}
public function IsSensor():Boolean{
return (m_isSensor);
}
b2internal function RefilterProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{
var _local3:b2AABB;
var _local4:Boolean;
if (m_proxy == null){
return;
};
_arg1.DestroyProxy(m_proxy);
_local3 = s_resetAABB;
ComputeAABB(_local3, _arg2);
_local4 = _arg1.InRange(_local3);
if (_local4){
m_proxy = _arg1.CreateProxy(_local3, this);
} else {
m_proxy = null;
};
}
public function GetUserData(){
return (m_userData);
}
b2internal function Synchronize(_arg1:b2BroadPhase, _arg2:b2XForm, _arg3:b2XForm):Boolean{
var _local4:b2AABB;
if (m_proxy == null){
return (false);
};
_local4 = s_syncAABB;
ComputeSweptAABB(_local4, _arg2, _arg3);
if (_arg1.InRange(_local4)){
_arg1.MoveProxy(m_proxy, _local4);
return (true);
};
return (false);
}
public function ComputeMass(_arg1:b2MassData):void{
}
public function SetFilterData(_arg1:b2FilterData):void{
m_filter = _arg1.Copy();
}
b2internal function DestroyProxy(_arg1:b2BroadPhase):void{
if (m_proxy){
_arg1.DestroyProxy(m_proxy);
m_proxy = null;
};
}
b2internal function UpdateSweepRadius(_arg1:b2Vec2):void{
}
public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
}
public function GetBody():b2Body{
return (m_body);
}
b2internal function CreateProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{
var _local3:b2AABB;
var _local4:Boolean;
_local3 = s_proxyAABB;
ComputeAABB(_local3, _arg2);
_local4 = _arg1.InRange(_local3);
if (_local4){
m_proxy = _arg1.CreateProxy(_local3, this);
} else {
m_proxy = null;
};
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
b2internal static function Destroy(_arg1:b2Shape, _arg2):void{
var _local3:b2EdgeShape;
switch (_arg1.m_type){
case e_edgeShape:
_local3 = (_arg1 as b2EdgeShape);
if (_local3.m_nextEdge != null){
_local3.m_nextEdge.m_prevEdge = null;
};
if (_local3.m_prevEdge != null){
_local3.m_prevEdge.m_nextEdge = null;
};
break;
};
}
b2internal static function Create(_arg1:b2ShapeDef, _arg2):b2Shape{
switch (_arg1.type){
case e_circleShape:
return (new b2CircleShape(_arg1));
case e_polygonShape:
return (new b2PolygonShape(_arg1));
default:
return (null);
};
}
}
}//package Box2D.Collision.Shapes
Section 35
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef)
package Box2D.Collision.Shapes {
public class b2ShapeDef {
public var isSensor:Boolean;// = false
public var density:Number;// = 0
public var type:int;// = -1
public var restitution:Number;// = 0
public var userData;// = null
public var filter:b2FilterData;
public var friction:Number;// = 0.2
public function b2ShapeDef(){
type = b2Shape.e_unknownShape;
userData = null;
friction = 0.2;
restitution = 0;
density = 0;
isSensor = false;
filter = new b2FilterData();
super();
}
}
}//package Box2D.Collision.Shapes
Section 36
//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 RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput):void{
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:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local3 = Number.MIN_VALUE;
_local4 = Number.MAX_VALUE;
_arg1.hit = false;
_local5 = _arg2.p1.x;
_local6 = _arg2.p1.y;
_local7 = (_arg2.p2.x - _arg2.p1.x);
_local8 = (_arg2.p2.y - _arg2.p1.y);
_local9 = Math.abs(_local7);
_local10 = Math.abs(_local8);
_local11 = _arg1.normal;
if (_local9 < Number.MIN_VALUE){
if ((((_local5 < lowerBound.x)) || ((upperBound.x < _local5)))){
return;
};
} 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;
};
};
if (_local10 < Number.MIN_VALUE){
if ((((_local6 < lowerBound.y)) || ((upperBound.y < _local6)))){
return;
};
} 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;
};
};
}
public function GetCenter():b2Vec2{
return (new b2Vec2(((lowerBound.x + upperBound.x) / 2), ((lowerBound.y + upperBound.y) / 2)));
}
public function IsValid():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:Boolean;
_local1 = (upperBound.x - lowerBound.x);
_local2 = (upperBound.y - lowerBound.y);
_local3 = (((_local1 >= 0)) && ((_local2 >= 0)));
_local3 = ((((_local3) && (lowerBound.IsValid()))) && (upperBound.IsValid()));
return (_local3);
}
public function GetExtents():b2Vec2{
return (new b2Vec2(((upperBound.x - lowerBound.x) / 2), ((upperBound.y - lowerBound.y) / 2)));
}
public function Contains(_arg1:b2AABB):Boolean{
var _local2:Boolean;
_local2 = true;
_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 static function Combine(_arg1:b2AABB, _arg2:b2AABB):b2AABB{
var _local3:b2AABB;
_local3 = new (b2AABB);
_local3.lowerBound.x = Math.min(_arg1.lowerBound.x, _arg2.lowerBound.x);
_local3.lowerBound.y = Math.min(_arg1.lowerBound.y, _arg2.lowerBound.y);
_local3.upperBound.x = Math.max(_arg1.upperBound.x, _arg2.upperBound.x);
_local3.upperBound.y = Math.max(_arg1.upperBound.y, _arg2.upperBound.y);
return (_local3);
}
}
}//package Box2D.Collision
Section 37
//b2Bound (Box2D.Collision.b2Bound)
package Box2D.Collision {
public class b2Bound {
public var stabbingCount:uint;
public var proxy:b2Proxy;
public var value:uint;
public function Swap(_arg1:b2Bound):void{
var _local2:uint;
var _local3:b2Proxy;
var _local4:uint;
_local2 = value;
_local3 = proxy;
_local4 = stabbingCount;
value = _arg1.value;
proxy = _arg1.proxy;
stabbingCount = _arg1.stabbingCount;
_arg1.value = _local2;
_arg1.proxy = _local3;
_arg1.stabbingCount = _local4;
}
public function IsLower():Boolean{
return (((value & 1) == 0));
}
public function IsUpper():Boolean{
return (((value & 1) == 1));
}
}
}//package Box2D.Collision
Section 38
//b2BoundValues (Box2D.Collision.b2BoundValues)
package Box2D.Collision {
public class b2BoundValues {
public var lowerValues:Array;
public var upperValues:Array;
public function b2BoundValues(){
lowerValues = [0, 0];
upperValues = [0, 0];
super();
}
}
}//package Box2D.Collision
Section 39
//b2BroadPhase (Box2D.Collision.b2BroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2BroadPhase {
b2internal var m_quantizationFactor:b2Vec2;
b2internal var m_worldAABB:b2AABB;
b2internal var m_bounds:Array;
private var m_freeProxy:b2Proxy;
b2internal var m_proxyCount:int;
b2internal var m_proxyPool:Array;
private var m_querySortKeys:Array;
b2internal var m_pairManager:b2PairManager;
private var m_queryResultCount:int;
private var m_timeStamp:uint;
private var m_queryResults:Array;
public static const b2_nullEdge:uint = b2Settings.USHRT_MAX;
public static const b2_invalid:uint = b2Settings.USHRT_MAX;
public static var s_validate:Boolean = false;
public function b2BroadPhase(_arg1:b2AABB, _arg2:b2PairCallback){
var _local3:int;
var _local4:Number;
var _local5:Number;
m_pairManager = new b2PairManager();
m_proxyPool = new Array();
m_bounds = new Array();
m_querySortKeys = new Array();
m_queryResults = new Array();
m_quantizationFactor = new b2Vec2();
super();
m_pairManager.Initialize(this, _arg2);
m_worldAABB = _arg1;
m_proxyCount = 0;
m_bounds = new Array(2);
_local3 = 0;
while (_local3 < 2) {
m_bounds[_local3] = new Array();
_local3++;
};
_local4 = (_arg1.upperBound.x - _arg1.lowerBound.x);
_local5 = (_arg1.upperBound.y - _arg1.lowerBound.y);
m_quantizationFactor.x = (b2Settings.USHRT_MAX / _local4);
m_quantizationFactor.y = (b2Settings.USHRT_MAX / _local5);
m_timeStamp = 1;
m_queryResultCount = 0;
}
public function QueryAABB(_arg1:b2AABB, _arg2, _arg3:int):int{
var _local4:Array;
var _local5:Array;
var _local6:uint;
var _local7:uint;
var _local8:Array;
var _local9:Array;
var _local10:int;
var _local11:int;
var _local12:b2Proxy;
_local4 = new Array();
_local5 = new Array();
ComputeBounds(_local4, _local5, _arg1);
_local8 = [_local6];
_local9 = [_local7];
Query(_local8, _local9, _local4[0], _local5[0], m_bounds[0], (2 * m_proxyCount), 0);
Query(_local8, _local9, _local4[1], _local5[1], m_bounds[1], (2 * m_proxyCount), 1);
_local10 = 0;
_local11 = 0;
while ((((_local11 < m_queryResultCount)) && ((_local10 < _arg3)))) {
_local12 = m_queryResults[_local11];
_arg2[_local11] = _local12.userData;
_local11++;
_local10++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local10);
}
public function Commit():void{
m_pairManager.Commit();
}
private function IncrementTimeStamp():void{
var _local1:uint;
if (m_timeStamp == b2Settings.USHRT_MAX){
_local1 = 0;
while (_local1 < m_proxyPool.length) {
(m_proxyPool[_local1] as b2Proxy).timeStamp = 0;
_local1++;
};
m_timeStamp = 1;
} else {
m_timeStamp++;
};
}
private function Query(_arg1:Array, _arg2:Array, _arg3:uint, _arg4:uint, _arg5:Array, _arg6:uint, _arg7:int):void{
var _local8:uint;
var _local9:uint;
var _local10:b2Bound;
var _local11:uint;
var _local12:int;
var _local13:int;
var _local14:b2Proxy;
_local8 = BinarySearch(_arg5, _arg6, _arg3);
_local9 = BinarySearch(_arg5, _arg6, _arg4);
_local11 = _local8;
while (_local11 < _local9) {
_local10 = _arg5[_local11];
if (_local10.IsLower()){
IncrementOverlapCount(_local10.proxy);
};
_local11++;
};
if (_local8 > 0){
_local12 = (_local8 - 1);
_local10 = _arg5[_local12];
_local13 = _local10.stabbingCount;
while (_local13) {
_local10 = _arg5[_local12];
if (_local10.IsLower()){
_local14 = _local10.proxy;
if (_local8 <= _local14.upperBounds[_arg7]){
IncrementOverlapCount(_local10.proxy);
_local13--;
};
};
_local12--;
};
};
_arg1[0] = _local8;
_arg2[0] = _local9;
}
private function AddProxyResult(_arg1:b2Proxy, _arg2:Number, _arg3:Function):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:b2Proxy;
var _local8:Number;
var _local9:b2Proxy;
_local4 = _arg3(_arg1.userData);
if (_local4 < 0){
return;
};
_local5 = 0;
while ((((_local5 < m_queryResultCount)) && ((m_querySortKeys[_local5] < _local4)))) {
_local5++;
};
_local6 = _local4;
_local7 = _arg1;
m_queryResultCount = (m_queryResultCount + 1);
if (m_queryResultCount > _arg2){
m_queryResultCount = _arg2;
};
while (_local5 < m_queryResultCount) {
_local8 = m_querySortKeys[_local5];
_local9 = m_queryResults[_local5];
m_querySortKeys[_local5] = _local6;
m_queryResults[_local5] = _local7;
_local6 = _local8;
_local7 = _local9;
_local5++;
};
}
public function QuerySegment(_arg1:b2Segment, _arg2, _arg3:int, _arg4:Function):int{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:int;
var _local9:int;
var _local10:Number;
var _local11:Number;
var _local12:Array;
var _local13:Array;
var _local14:Array;
var _local15:int;
var _local16:int;
var _local17:b2Proxy;
var _local18:uint;
var _local19:uint;
var _local20:Array;
var _local21:Array;
var _local22:int;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:b2Proxy;
var _local27:Number;
var _local28:Number;
_local5 = 1;
_local6 = ((_arg1.p2.x - _arg1.p1.x) * m_quantizationFactor.x);
_local7 = ((_arg1.p2.y - _arg1.p1.y) * m_quantizationFactor.y);
_local8 = ((_local6 < -(Number.MIN_VALUE))) ? -1 : ((_local6 > Number.MIN_VALUE)) ? 1 : 0;
_local9 = ((_local7 < -(Number.MIN_VALUE))) ? -1 : ((_local7 > Number.MIN_VALUE)) ? 1 : 0;
_local10 = (m_quantizationFactor.x * (_arg1.p1.x - m_worldAABB.lowerBound.x));
_local11 = (m_quantizationFactor.y * (_arg1.p1.y - m_worldAABB.lowerBound.y));
_local12 = new Array();
_local13 = new Array();
_local12[0] = (uint(_local10) & (b2Settings.USHRT_MAX - 1));
_local12[1] = (uint(_local11) & (b2Settings.USHRT_MAX - 1));
_local13[0] = (_local12[0] + 1);
_local13[1] = (_local12[1] + 1);
_local14 = new Array();
_local20 = [_local18];
_local21 = [_local19];
Query(_local20, _local21, _local12[0], _local13[0], m_bounds[0], (2 * m_proxyCount), 0);
if (_local8 >= 0){
_local15 = (_local21[0] - 1);
} else {
_local15 = _local20[0];
};
Query(_local20, _local21, _local12[1], _local13[1], m_bounds[1], (2 * m_proxyCount), 1);
if (_local9 >= 0){
_local16 = (_local21[0] - 1);
} else {
_local16 = _local20[0];
};
if (_arg4 != null){
_local23 = 0;
while (_local23 < m_queryResultCount) {
m_querySortKeys[_local23] = _arg4(m_queryResults[_local23].userData);
_local23++;
};
_local23 = 0;
while (_local23 < (m_queryResultCount - 1)) {
_local24 = m_querySortKeys[_local23];
_local25 = m_querySortKeys[(_local23 + 1)];
if (((_local24)<0) ? (_local25 >= 0) : (((_local24 > _local25)) && ((_local25 >= 0)))){
m_querySortKeys[(_local23 + 1)] = _local24;
m_querySortKeys[_local23] = _local25;
_local26 = m_queryResults[(_local23 + 1)];
m_queryResults[(_local23 + 1)] = m_queryResults[_local23];
m_queryResults[_local23] = _local26;
--_local23;
if (_local23 == -1){
_local23 = 1;
};
} else {
_local23++;
};
};
while ((((m_queryResultCount > 0)) && ((m_querySortKeys[(m_queryResultCount - 1)] < 0)))) {
m_queryResultCount--;
};
};
while (true) {
_local27 = 0;
_local28 = 0;
_local15 = (_local15 + ((_local8 >= 0)) ? 1 : -1);
if ((((_local15 < 0)) || ((_local15 >= (m_proxyCount * 2))))){
break;
};
if (_local8 != 0){
_local27 = ((m_bounds[0][_local15].value - _local10) / _local6);
};
_local16 = (_local16 + ((_local9 >= 0)) ? 1 : -1);
if ((((_local16 < 0)) || ((_local16 >= (m_proxyCount * 2))))){
break;
};
if (_local9 != 0){
_local28 = ((m_bounds[1][_local16].value - _local11) / _local7);
};
while (true) {
if ((((_local9 == 0)) || (((!((_local8 == 0))) && ((_local27 < _local28)))))){
if (_local27 > _local5){
break;
};
if (((_local8 > 0)) ? m_bounds[0][_local15].IsLower() : m_bounds[0][_local15].IsUpper()){
_local17 = m_bounds[0][_local15].proxy;
if (_local9 >= 0){
if ((((_local17.lowerBounds[1] <= (_local16 - 1))) && ((_local17.upperBounds[1] >= _local16)))){
if (_arg4 != null){
AddProxyResult(_local17, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
} else {
if ((((_local17.lowerBounds[1] <= _local16)) && ((_local17.upperBounds[1] >= (_local16 + 1))))){
if (_arg4 != null){
AddProxyResult(_local17, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
};
};
if (((((((!((_arg4 == null))) && ((m_queryResultCount == _arg3)))) && ((m_queryResultCount > 0)))) && ((_local27 > m_querySortKeys[(m_queryResultCount - 1)])))){
break;
};
if (_local8 > 0){
_local15++;
if (_local15 == (m_proxyCount * 2)){
break;
};
} else {
--_local15;
if (_local15 < 0){
break;
};
};
_local27 = ((m_bounds[0][_local15].value - _local10) / _local6);
} else {
if (_local28 > _local5){
break;
};
if (((_local9 > 0)) ? m_bounds[1][_local16].IsLower() : m_bounds[1][_local16].IsUpper()){
_local17 = m_bounds[1][_local16].proxy;
if (_local8 >= 0){
if ((((_local17.lowerBounds[0] <= (_local15 - 1))) && ((_local17.upperBounds[0] >= _local15)))){
if (_arg4 != null){
AddProxyResult(_local17, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
} else {
if ((((_local17.lowerBounds[0] <= _local15)) && ((_local17.upperBounds[0] >= (_local15 + 1))))){
if (_arg4 != null){
AddProxyResult(_local17, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
};
};
if (((((((!((_arg4 == null))) && ((m_queryResultCount == _arg3)))) && ((m_queryResultCount > 0)))) && ((_local28 > m_querySortKeys[(m_queryResultCount - 1)])))){
break;
};
if (_local9 > 0){
_local16++;
if (_local16 == (m_proxyCount * 2)){
break;
};
} else {
--_local16;
if (_local16 < 0){
break;
};
};
_local28 = ((m_bounds[1][_local16].value - _local11) / _local7);
};
};
break;
};
_local22 = 0;
_local23 = 0;
while ((((_local23 < m_queryResultCount)) && ((_local22 < _arg3)))) {
_local17 = m_queryResults[_local23];
_arg2[_local23] = _local17.userData;
_local23++;
_local22++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local22);
}
private function ComputeBounds(_arg1:Array, _arg2:Array, _arg3:b2AABB):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local4 = _arg3.lowerBound.x;
_local5 = _arg3.lowerBound.y;
_local4 = b2Math.b2Min(_local4, m_worldAABB.upperBound.x);
_local5 = b2Math.b2Min(_local5, m_worldAABB.upperBound.y);
_local4 = b2Math.b2Max(_local4, m_worldAABB.lowerBound.x);
_local5 = b2Math.b2Max(_local5, m_worldAABB.lowerBound.y);
_local6 = _arg3.upperBound.x;
_local7 = _arg3.upperBound.y;
_local6 = b2Math.b2Min(_local6, m_worldAABB.upperBound.x);
_local7 = b2Math.b2Min(_local7, m_worldAABB.upperBound.y);
_local6 = b2Math.b2Max(_local6, m_worldAABB.lowerBound.x);
_local7 = b2Math.b2Max(_local7, m_worldAABB.lowerBound.y);
_arg1[0] = (uint((m_quantizationFactor.x * (_local4 - m_worldAABB.lowerBound.x))) & (b2Settings.USHRT_MAX - 1));
_arg2[0] = ((uint((m_quantizationFactor.x * (_local6 - m_worldAABB.lowerBound.x))) & 0xFFFF) | 1);
_arg1[1] = (uint((m_quantizationFactor.y * (_local5 - m_worldAABB.lowerBound.y))) & (b2Settings.USHRT_MAX - 1));
_arg2[1] = ((uint((m_quantizationFactor.y * (_local7 - m_worldAABB.lowerBound.y))) & 0xFFFF) | 1);
}
public function CreateProxy(_arg1:b2AABB, _arg2):b2Proxy{
var _local3:uint;
var _local4:b2Proxy;
var _local5:int;
var _local6:int;
var _local7:uint;
var _local8:Array;
var _local9:Array;
var _local10:int;
var _local11:Array;
var _local12:uint;
var _local13:uint;
var _local14:Array;
var _local15:Array;
var _local16:b2Bound;
var _local17:b2Bound;
var _local18:b2Bound;
var _local19:b2Proxy;
if (!m_freeProxy){
m_freeProxy = (m_proxyPool[m_proxyCount] = new b2Proxy());
m_freeProxy.next = null;
m_freeProxy.timeStamp = 0;
m_freeProxy.overlapCount = b2_invalid;
m_freeProxy.userData = null;
_local5 = 0;
while (_local5 < 2) {
_local6 = (m_proxyCount * 2);
var _temp1 = _local6;
_local6 = (_local6 + 1);
var _local20 = _temp1;
m_bounds[_local5][_local20] = new b2Bound();
m_bounds[_local5][_local6] = new b2Bound();
_local5++;
};
};
_local4 = m_freeProxy;
m_freeProxy = _local4.next;
_local4.overlapCount = 0;
_local4.userData = _arg2;
_local7 = (2 * m_proxyCount);
_local8 = new Array();
_local9 = new Array();
ComputeBounds(_local8, _local9, _arg1);
_local10 = 0;
while (_local10 < 2) {
_local11 = m_bounds[_local10];
_local14 = [_local12];
_local15 = [_local13];
Query(_local14, _local15, _local8[_local10], _local9[_local10], _local11, _local7, _local10);
_local12 = _local14[0];
_local13 = _local15[0];
_local11.splice(_local13, 0, _local11[(_local11.length - 1)]);
_local11.length--;
_local11.splice(_local12, 0, _local11[(_local11.length - 1)]);
_local11.length--;
_local13++;
_local16 = _local11[_local12];
_local17 = _local11[_local13];
_local16.value = _local8[_local10];
_local16.proxy = _local4;
_local17.value = _local9[_local10];
_local17.proxy = _local4;
_local18 = _local11[int((_local12 - 1))];
_local16.stabbingCount = ((_local12 == 0)) ? 0 : _local18.stabbingCount;
_local18 = _local11[int((_local13 - 1))];
_local17.stabbingCount = _local18.stabbingCount;
_local3 = _local12;
while (_local3 < _local13) {
_local18 = _local11[_local3];
_local18.stabbingCount++;
_local3++;
};
_local3 = _local12;
while (_local3 < (_local7 + 2)) {
_local16 = _local11[_local3];
_local19 = _local16.proxy;
if (_local16.IsLower()){
_local19.lowerBounds[_local10] = _local3;
} else {
_local19.upperBounds[_local10] = _local3;
};
_local3++;
};
_local10++;
};
m_proxyCount++;
_local5 = 0;
while (_local5 < m_queryResultCount) {
m_pairManager.AddBufferedPair(_local4, m_queryResults[_local5]);
_local5++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local4);
}
public function DestroyProxy(_arg1:b2Proxy):void{
var _local2:b2Bound;
var _local3:b2Bound;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Array;
var _local8:uint;
var _local9:uint;
var _local10:uint;
var _local11:uint;
var _local12:int;
var _local13:uint;
var _local14:int;
var _local15:b2Proxy;
_local4 = (2 * m_proxyCount);
_local5 = 0;
while (_local5 < 2) {
_local7 = m_bounds[_local5];
_local8 = _arg1.lowerBounds[_local5];
_local9 = _arg1.upperBounds[_local5];
_local2 = _local7[_local8];
_local10 = _local2.value;
_local3 = _local7[_local9];
_local11 = _local3.value;
_local7.splice(_local9, 1);
_local7.splice(_local8, 1);
_local7.push(_local2);
_local7.push(_local3);
_local12 = (_local4 - 2);
_local13 = _local8;
while (_local13 < _local12) {
_local2 = _local7[_local13];
_local15 = _local2.proxy;
if (_local2.IsLower()){
_local15.lowerBounds[_local5] = _local13;
} else {
_local15.upperBounds[_local5] = _local13;
};
_local13++;
};
_local12 = (_local9 - 1);
_local14 = _local8;
while (_local14 < _local12) {
_local2 = _local7[_local14];
_local2.stabbingCount--;
_local14++;
};
Query([0], [0], _local10, _local11, _local7, (_local4 - 2), _local5);
_local5++;
};
_local6 = 0;
while (_local6 < m_queryResultCount) {
m_pairManager.RemoveBufferedPair(_arg1, m_queryResults[_local6]);
_local6++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
_arg1.userData = null;
_arg1.overlapCount = b2_invalid;
_arg1.lowerBounds[0] = b2_invalid;
_arg1.lowerBounds[1] = b2_invalid;
_arg1.upperBounds[0] = b2_invalid;
_arg1.upperBounds[1] = b2_invalid;
_arg1.next = m_freeProxy;
m_freeProxy = _arg1;
m_proxyCount--;
}
public function TestOverlap(_arg1:b2BoundValues, _arg2:b2Proxy):Boolean{
var _local3:int;
var _local4:Array;
var _local5:b2Bound;
_local3 = 0;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
_local5 = _local4[_arg2.upperBounds[_local3]];
if (_arg1.lowerValues[_local3] > _local5.value){
return (false);
};
_local5 = _local4[_arg2.lowerBounds[_local3]];
if (_arg1.upperValues[_local3] < _local5.value){
return (false);
};
_local3++;
};
return (true);
}
public function Validate():void{
var _local1:b2Pair;
var _local2:b2Proxy;
var _local3:b2Proxy;
var _local4:Boolean;
var _local5:int;
var _local6:b2Bound;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:b2Bound;
_local5 = 0;
while (_local5 < 2) {
_local6 = m_bounds[_local5];
_local7 = (2 * m_proxyCount);
_local8 = 0;
_local9 = 0;
while (_local9 < _local7) {
_local10 = _local6[_local9];
if (_local10.IsLower() == true){
_local8++;
} else {
_local8--;
};
_local9++;
};
_local5++;
};
}
private function IncrementOverlapCount(_arg1:b2Proxy):void{
if (_arg1.timeStamp < m_timeStamp){
_arg1.timeStamp = m_timeStamp;
_arg1.overlapCount = 1;
} else {
_arg1.overlapCount = 2;
m_queryResults[m_queryResultCount] = _arg1;
m_queryResultCount++;
};
}
public function InRange(_arg1:b2AABB):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = _arg1.lowerBound.x;
_local3 = _arg1.lowerBound.y;
_local2 = (_local2 - m_worldAABB.upperBound.x);
_local3 = (_local3 - m_worldAABB.upperBound.y);
_local4 = m_worldAABB.lowerBound.x;
_local5 = m_worldAABB.lowerBound.y;
_local4 = (_local4 - _arg1.upperBound.x);
_local5 = (_local5 - _arg1.upperBound.y);
_local2 = b2Math.b2Max(_local2, _local4);
_local3 = b2Math.b2Max(_local3, _local5);
return ((b2Math.b2Max(_local2, _local3) < 0));
}
private function TestOverlapValidate(_arg1:b2Proxy, _arg2:b2Proxy):Boolean{
var _local3:int;
var _local4:Array;
var _local5:b2Bound;
var _local6:b2Bound;
_local3 = 0;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
_local5 = _local4[_arg1.lowerBounds[_local3]];
_local6 = _local4[_arg2.upperBounds[_local3]];
if (_local5.value > _local6.value){
return (false);
};
_local5 = _local4[_arg1.upperBounds[_local3]];
_local6 = _local4[_arg2.lowerBounds[_local3]];
if (_local5.value < _local6.value){
return (false);
};
_local3++;
};
return (true);
}
public function MoveProxy(_arg1:b2Proxy, _arg2:b2AABB):void{
var _local3:Array;
var _local4:int;
var _local5:uint;
var _local6:uint;
var _local7:b2Bound;
var _local8:b2Bound;
var _local9:b2Bound;
var _local10:uint;
var _local11:b2Proxy;
var _local12:uint;
var _local13:b2BoundValues;
var _local14:b2BoundValues;
var _local15:Array;
var _local16:uint;
var _local17:uint;
var _local18:uint;
var _local19:uint;
var _local20:int;
var _local21:int;
var _local22:b2Proxy;
if (_arg1 == null){
return;
};
if (_arg2.IsValid() == false){
return;
};
_local12 = (2 * m_proxyCount);
_local13 = new b2BoundValues();
ComputeBounds(_local13.lowerValues, _local13.upperValues, _arg2);
_local14 = new b2BoundValues();
_local5 = 0;
while (_local5 < 2) {
_local7 = m_bounds[_local5][_arg1.lowerBounds[_local5]];
_local14.lowerValues[_local5] = _local7.value;
_local7 = m_bounds[_local5][_arg1.upperBounds[_local5]];
_local14.upperValues[_local5] = _local7.value;
_local5++;
};
_local5 = 0;
while (_local5 < 2) {
_local15 = m_bounds[_local5];
_local16 = _arg1.lowerBounds[_local5];
_local17 = _arg1.upperBounds[_local5];
_local18 = _local13.lowerValues[_local5];
_local19 = _local13.upperValues[_local5];
_local7 = _local15[_local16];
_local20 = (_local18 - _local7.value);
_local7.value = _local18;
_local7 = _local15[_local17];
_local21 = (_local19 - _local7.value);
_local7.value = _local19;
if (_local20 < 0){
_local6 = _local16;
while ((((_local6 > 0)) && ((_local18 < (_local15[int((_local6 - 1))] as b2Bound).value)))) {
_local7 = _local15[_local6];
_local8 = _local15[int((_local6 - 1))];
_local22 = _local8.proxy;
_local8.stabbingCount++;
if (_local8.IsUpper() == true){
if (TestOverlap(_local13, _local22)){
m_pairManager.AddBufferedPair(_arg1, _local22);
};
_local3 = _local22.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount++;
} else {
_local3 = _local22.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount--;
};
_local3 = _arg1.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.Swap(_local8);
_local6--;
};
};
if (_local21 > 0){
_local6 = _local17;
while ((((_local6 < (_local12 - 1))) && (((_local15[int((_local6 + 1))] as b2Bound).value <= _local19)))) {
_local7 = _local15[_local6];
_local9 = _local15[int((_local6 + 1))];
_local11 = _local9.proxy;
_local9.stabbingCount++;
if (_local9.IsLower() == true){
if (TestOverlap(_local13, _local11)){
m_pairManager.AddBufferedPair(_arg1, _local11);
};
_local3 = _local11.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount++;
} else {
_local3 = _local11.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount--;
};
_local3 = _arg1.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.Swap(_local9);
_local6++;
};
};
if (_local20 > 0){
_local6 = _local16;
while ((((_local6 < (_local12 - 1))) && (((_local15[int((_local6 + 1))] as b2Bound).value <= _local18)))) {
_local7 = _local15[_local6];
_local9 = _local15[int((_local6 + 1))];
_local11 = _local9.proxy;
_local9.stabbingCount--;
if (_local9.IsUpper()){
if (TestOverlap(_local14, _local11)){
m_pairManager.RemoveBufferedPair(_arg1, _local11);
};
_local3 = _local11.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount--;
} else {
_local3 = _local11.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount++;
};
_local3 = _arg1.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.Swap(_local9);
_local6++;
};
};
if (_local21 < 0){
_local6 = _local17;
while ((((_local6 > 0)) && ((_local19 < (_local15[int((_local6 - 1))] as b2Bound).value)))) {
_local7 = _local15[_local6];
_local8 = _local15[int((_local6 - 1))];
_local22 = _local8.proxy;
_local8.stabbingCount--;
if (_local8.IsLower() == true){
if (TestOverlap(_local14, _local22)){
m_pairManager.RemoveBufferedPair(_arg1, _local22);
};
_local3 = _local22.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount--;
} else {
_local3 = _local22.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount++;
};
_local3 = _arg1.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.Swap(_local8);
_local6--;
};
};
_local5++;
};
}
public static function BinarySearch(_arg1:Array, _arg2:int, _arg3:uint):uint{
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:b2Bound;
_local4 = 0;
_local5 = (_arg2 - 1);
while (_local4 <= _local5) {
_local6 = ((_local4 + _local5) / 2);
_local7 = _arg1[_local6];
if (_local7.value > _arg3){
_local5 = (_local6 - 1);
} else {
if (_local7.value < _arg3){
_local4 = (_local6 + 1);
} else {
return (uint(_local6));
};
};
};
return (uint(_local4));
}
}
}//package Box2D.Collision
Section 40
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
public static function EdgeSeparation(_arg1:b2PolygonShape, _arg2:b2XForm, _arg3:int, _arg4:b2PolygonShape, _arg5:b2XForm):Number{
var _local6:int;
var _local7:Array;
var _local8:Array;
var _local9:int;
var _local10:Array;
var _local11:b2Mat22;
var _local12:b2Vec2;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:int;
var _local18:Number;
var _local19:int;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
_local6 = _arg1.m_vertexCount;
_local7 = _arg1.m_vertices;
_local8 = _arg1.m_normals;
_local9 = _arg4.m_vertexCount;
_local10 = _arg4.m_vertices;
_local11 = _arg2.R;
_local12 = _local8[_arg3];
_local13 = ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y));
_local14 = ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y));
_local11 = _arg5.R;
_local15 = ((_local11.col1.x * _local13) + (_local11.col1.y * _local14));
_local16 = ((_local11.col2.x * _local13) + (_local11.col2.y * _local14));
_local17 = 0;
_local18 = Number.MAX_VALUE;
_local19 = 0;
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;
_local20 = (_arg2.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
_local21 = (_arg2.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local12 = _local10[_local17];
_local11 = _arg5.R;
_local22 = (_arg5.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
_local23 = (_arg5.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local22 = (_local22 - _local20);
_local23 = (_local23 - _local21);
_local24 = ((_local22 * _local13) + (_local23 * _local14));
return (_local24);
}
public static function b2TestOverlap(_arg1:b2AABB, _arg2:b2AABB):Boolean{
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local3 = _arg2.lowerBound;
_local4 = _arg1.upperBound;
_local5 = (_local3.x - _local4.x);
_local6 = (_local3.y - _local4.y);
_local3 = _arg1.lowerBound;
_local4 = _arg2.upperBound;
_local7 = (_local3.x - _local4.x);
_local8 = (_local3.y - _local4.y);
if ((((_local5 > 0)) || ((_local6 > 0)))){
return (false);
};
if ((((_local7 > 0)) || ((_local8 > 0)))){
return (false);
};
return (true);
}
public static function FindIncidentEdge(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:int, _arg5:b2PolygonShape, _arg6:b2XForm):void{
var _local7:int;
var _local8:Array;
var _local9:int;
var _local10:Array;
var _local11:Array;
var _local12:b2Mat22;
var _local13:b2Vec2;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:int;
var _local18:Number;
var _local19:int;
var _local20:ClipVertex;
var _local21:int;
var _local22:int;
var _local23:Number;
_local7 = _arg2.m_vertexCount;
_local8 = _arg2.m_normals;
_local9 = _arg5.m_vertexCount;
_local10 = _arg5.m_vertices;
_local11 = _arg5.m_normals;
_local12 = _arg3.R;
_local13 = _local8[_arg4];
_local14 = ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y));
_local15 = ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y));
_local12 = _arg6.R;
_local16 = ((_local12.col1.x * _local14) + (_local12.col1.y * _local15));
_local15 = ((_local12.col2.x * _local14) + (_local12.col2.y * _local15));
_local14 = _local16;
_local17 = 0;
_local18 = Number.MAX_VALUE;
_local19 = 0;
while (_local19 < _local9) {
_local13 = _local11[_local19];
_local23 = ((_local14 * _local13.x) + (_local15 * _local13.y));
if (_local23 < _local18){
_local18 = _local23;
_local17 = _local19;
};
_local19++;
};
_local21 = _local17;
_local22 = (((_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 b2CollidePolygons(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):void{
var _local6:ClipVertex;
var _local7:int;
var _local8:Array;
var _local9:Number;
var _local10:int;
var _local11:Array;
var _local12:Number;
var _local13:b2PolygonShape;
var _local14:b2PolygonShape;
var _local15:b2XForm;
var _local16:b2XForm;
var _local17:int;
var _local18:uint;
var _local19:Number;
var _local20:Number;
var _local21:Array;
var _local22:int;
var _local23:Array;
var _local24:b2Vec2;
var _local25:b2Vec2;
var _local26:b2Vec2;
var _local27:b2Vec2;
var _local28:b2Vec2;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Array;
var _local33:Array;
var _local34:int;
var _local35:int;
var _local36:int;
var _local37:b2Vec2;
var _local38:Number;
var _local39:b2ManifoldPoint;
_arg1.pointCount = 0;
_local7 = 0;
_local8 = [_local7];
_local9 = FindMaxSeparation(_local8, _arg2, _arg3, _arg4, _arg5);
_local7 = _local8[0];
if (_local9 > 0){
return;
};
_local10 = 0;
_local11 = [_local10];
_local12 = FindMaxSeparation(_local11, _arg4, _arg5, _arg2, _arg3);
_local10 = _local11[0];
if (_local12 > 0){
return;
};
_local15 = new b2XForm();
_local16 = new b2XForm();
_local19 = 0.98;
_local20 = 0.001;
if (_local12 > ((_local19 * _local9) + _local20)){
_local13 = _arg4;
_local14 = _arg2;
_local15.Set(_arg5);
_local16.Set(_arg3);
_local17 = _local10;
_local18 = 1;
} else {
_local13 = _arg2;
_local14 = _arg4;
_local15.Set(_arg3);
_local16.Set(_arg5);
_local17 = _local7;
_local18 = 0;
};
_local21 = [new ClipVertex(), new ClipVertex()];
FindIncidentEdge(_local21, _local13, _local15, _local17, _local14, _local16);
_local22 = _local13.m_vertexCount;
_local23 = _local13.m_vertices;
_local24 = _local23[_local17];
_local25 = _local24.Copy();
if ((_local17 + 1) < _local22){
_local24 = _local23[int((_local17 + 1))];
_local37 = _local24.Copy();
} else {
_local24 = _local23[0];
_local37 = _local24.Copy();
};
_local26 = b2Math.SubtractVV(_local37, _local25);
_local27 = b2Math.b2MulMV(_local15.R, b2Math.SubtractVV(_local37, _local25));
_local27.Normalize();
_local28 = b2Math.b2CrossVF(_local27, 1);
_local25 = b2Math.b2MulX(_local15, _local25);
_local37 = b2Math.b2MulX(_local15, _local37);
_local29 = b2Math.b2Dot(_local28, _local25);
_local30 = -(b2Math.b2Dot(_local27, _local25));
_local31 = b2Math.b2Dot(_local27, _local37);
_local32 = [new ClipVertex(), new ClipVertex()];
_local33 = [new ClipVertex(), new ClipVertex()];
_local34 = ClipSegmentToLine(_local32, _local21, _local27.Negative(), _local30);
if (_local34 < 2){
return;
};
_local34 = ClipSegmentToLine(_local33, _local32, _local27, _local31);
if (_local34 < 2){
return;
};
_arg1.normal = (_local18) ? _local28.Negative() : _local28.Copy();
_local35 = 0;
_local36 = 0;
while (_local36 < b2Settings.b2_maxManifoldPoints) {
_local6 = _local33[_local36];
_local38 = (((_local28.x * _local6.v.x) + (_local28.y * _local6.v.y)) - _local29);
if (_local38 <= 0){
_local39 = _arg1.points[_local35];
_local39.separation = _local38;
_local39.localPoint1 = b2Math.b2MulXT(_arg3, _local6.v);
_local39.localPoint2 = b2Math.b2MulXT(_arg5, _local6.v);
_local39.id.key = _local6.id._key;
_local39.id.features.flip = _local18;
_local35++;
};
_local36++;
};
_arg1.pointCount = _local35;
}
public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):Number{
var _local6:int;
var _local7:Array;
var _local8:b2Vec2;
var _local9:b2Mat22;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local15:Number;
var _local16:int;
var _local17:Number;
var _local18:int;
var _local19:Number;
var _local20:int;
var _local21:Number;
var _local22:int;
var _local23:Number;
var _local24:int;
var _local25:Number;
_local6 = _arg2.m_vertexCount;
_local7 = _arg2.m_normals;
_local9 = _arg5.R;
_local8 = _arg4.m_centroid;
_local10 = (_arg5.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y)));
_local11 = (_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))));
_local12 = ((_local10 * _arg3.R.col1.x) + (_local11 * _arg3.R.col1.y));
_local13 = ((_local10 * _arg3.R.col2.x) + (_local11 * _arg3.R.col2.y));
_local14 = 0;
_local15 = -(Number.MAX_VALUE);
_local16 = 0;
while (_local16 < _local6) {
_local8 = _local7[_local16];
_local25 = ((_local8.x * _local12) + (_local8.y * _local13));
if (_local25 > _local15){
_local15 = _local25;
_local14 = _local16;
};
_local16++;
};
_local17 = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
if (_local17 > 0){
return (_local17);
};
_local18 = (((_local14 - 1) >= 0)) ? (_local14 - 1) : (_local6 - 1);
_local19 = EdgeSeparation(_arg2, _arg3, _local18, _arg4, _arg5);
if (_local19 > 0){
return (_local19);
};
_local20 = (((_local14 + 1) < _local6)) ? (_local14 + 1) : 0;
_local21 = EdgeSeparation(_arg2, _arg3, _local20, _arg4, _arg5);
if (_local21 > 0){
return (_local21);
};
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 > 0){
return (_local17);
};
if (_local17 > _local23){
_local22 = _local14;
_local23 = _local17;
} else {
break;
};
};
_arg1[0] = _local22;
return (_local23);
}
public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{
var _local5:ClipVertex;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local13:ClipVertex;
_local6 = 0;
_local5 = _arg2[0];
_local7 = _local5.v;
_local5 = _arg2[1];
_local8 = _local5.v;
_local9 = (b2Math.b2Dot(_arg3, _local7) - _arg4);
_local10 = (b2Math.b2Dot(_arg3, _local8) - _arg4);
if (_local9 <= 0){
var _temp1 = _local6;
_local6 = (_local6 + 1);
var _local14 = _temp1;
_arg1[_local14] = _arg2[0];
};
if (_local10 <= 0){
var _temp2 = _local6;
_local6 = (_local6 + 1);
_local14 = _temp2;
_arg1[_local14] = _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);
}
public static function b2CollideCircles(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{
var _local6:b2Mat22;
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:Number;
var _local18:Number;
var _local19:b2ManifoldPoint;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
_arg1.pointCount = 0;
_local6 = _arg3.R;
_local7 = _arg2.m_localPosition;
_local8 = (_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
_local9 = (_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local6 = _arg5.R;
_local7 = _arg4.m_localPosition;
_local10 = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
_local11 = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local12 = (_local10 - _local8);
_local13 = (_local11 - _local9);
_local14 = ((_local12 * _local12) + (_local13 * _local13));
_local15 = _arg2.m_radius;
_local16 = _arg4.m_radius;
_local17 = (_local15 + _local16);
if (_local14 > (_local17 * _local17)){
return;
};
if (_local14 < Number.MIN_VALUE){
_local18 = -(_local17);
_arg1.normal.Set(0, 1);
} else {
_local24 = Math.sqrt(_local14);
_local18 = (_local24 - _local17);
_local25 = (1 / _local24);
_arg1.normal.x = (_local25 * _local12);
_arg1.normal.y = (_local25 * _local13);
};
_arg1.pointCount = 1;
_local19 = _arg1.points[0];
_local19.id.key = 0;
_local19.separation = _local18;
_local8 = (_local8 + (_local15 * _arg1.normal.x));
_local9 = (_local9 + (_local15 * _arg1.normal.y));
_local10 = (_local10 - (_local16 * _arg1.normal.x));
_local11 = (_local11 - (_local16 * _arg1.normal.y));
_local20 = (0.5 * (_local8 + _local10));
_local21 = (0.5 * (_local9 + _local11));
_local22 = (_local20 - _arg3.position.x);
_local23 = (_local21 - _arg3.position.y);
_local19.localPoint1.x = ((_local22 * _arg3.R.col1.x) + (_local23 * _arg3.R.col1.y));
_local19.localPoint1.y = ((_local22 * _arg3.R.col2.x) + (_local23 * _arg3.R.col2.y));
_local22 = (_local20 - _arg5.position.x);
_local23 = (_local21 - _arg5.position.y);
_local19.localPoint2.x = ((_local22 * _arg5.R.col1.x) + (_local23 * _arg5.R.col1.y));
_local19.localPoint2.y = ((_local22 * _arg5.R.col2.x) + (_local23 * _arg5.R.col2.y));
}
public static function b2CollidePolygonAndCircle(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{
var _local6:b2ManifoldPoint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:b2Mat22;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:Number;
var _local20:Number;
var _local21:int;
var _local22:Array;
var _local23:Array;
var _local24:int;
var _local25:int;
var _local26:int;
var _local27:b2Vec2;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_arg1.pointCount = 0;
_local12 = _arg5.R;
_local11 = _arg4.m_localPosition;
_local13 = (_arg5.position.x + ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y)));
_local14 = (_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;
_local15 = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local16 = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local18 = 0;
_local19 = -(Number.MAX_VALUE);
_local20 = _arg4.m_radius;
_local21 = _arg2.m_vertexCount;
_local22 = _arg2.m_vertices;
_local23 = _arg2.m_normals;
_local24 = 0;
while (_local24 < _local21) {
_local11 = _local22[_local24];
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
_local11 = _local23[_local24];
_local34 = ((_local11.x * _local7) + (_local11.y * _local8));
if (_local34 > _local20){
return;
};
if (_local34 > _local19){
_local19 = _local34;
_local18 = _local24;
};
_local24++;
};
if (_local19 < Number.MIN_VALUE){
_arg1.pointCount = 1;
_local11 = _local23[_local18];
_local12 = _arg3.R;
_arg1.normal.x = ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y));
_arg1.normal.y = ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y));
_local6 = _arg1.points[0];
_local6.id.features.incidentEdge = _local18;
_local6.id.features.incidentVertex = b2_nullFeature;
_local6.id.features.referenceEdge = 0;
_local6.id.features.flip = 0;
_local9 = (_local13 - (_local20 * _arg1.normal.x));
_local10 = (_local14 - (_local20 * _arg1.normal.y));
_local7 = (_local9 - _arg3.position.x);
_local8 = (_local10 - _arg3.position.y);
_local12 = _arg3.R;
_local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local7 = (_local9 - _arg5.position.x);
_local8 = (_local10 - _arg5.position.y);
_local12 = _arg5.R;
_local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local6.separation = (_local19 - _local20);
return;
};
_local25 = _local18;
_local26 = (((_local25 + 1) < _local21)) ? (_local25 + 1) : 0;
_local11 = _local22[_local25];
_local27 = _local22[_local26];
_local28 = (_local27.x - _local11.x);
_local29 = (_local27.y - _local11.y);
_local30 = Math.sqrt(((_local28 * _local28) + (_local29 * _local29)));
_local28 = (_local28 / _local30);
_local29 = (_local29 / _local30);
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
_local31 = ((_local7 * _local28) + (_local8 * _local29));
_local6 = _arg1.points[0];
if (_local31 <= 0){
_local32 = _local11.x;
_local33 = _local11.y;
_local6.id.features.incidentEdge = b2_nullFeature;
_local6.id.features.incidentVertex = _local25;
} else {
if (_local31 >= _local30){
_local32 = _local27.x;
_local33 = _local27.y;
_local6.id.features.incidentEdge = b2_nullFeature;
_local6.id.features.incidentVertex = _local26;
} else {
_local32 = ((_local28 * _local31) + _local11.x);
_local33 = ((_local29 * _local31) + _local11.y);
_local6.id.features.incidentEdge = _local18;
_local6.id.features.incidentVertex = b2_nullFeature;
};
};
_local7 = (_local15 - _local32);
_local8 = (_local16 - _local33);
_local17 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_local7 = (_local7 / _local17);
_local8 = (_local8 / _local17);
if (_local17 > _local20){
return;
};
_arg1.pointCount = 1;
_local12 = _arg3.R;
_arg1.normal.x = ((_local12.col1.x * _local7) + (_local12.col2.x * _local8));
_arg1.normal.y = ((_local12.col1.y * _local7) + (_local12.col2.y * _local8));
_local9 = (_local13 - (_local20 * _arg1.normal.x));
_local10 = (_local14 - (_local20 * _arg1.normal.y));
_local7 = (_local9 - _arg3.position.x);
_local8 = (_local10 - _arg3.position.y);
_local12 = _arg3.R;
_local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local7 = (_local9 - _arg5.position.x);
_local8 = (_local10 - _arg5.position.y);
_local12 = _arg5.R;
_local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local6.separation = (_local17 - _local20);
_local6.id.features.referenceEdge = 0;
_local6.id.features.flip = 0;
}
}
}//package Box2D.Collision
Section 41
//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;
_local1 = new b2ContactID();
_local1.key = key;
return (_local1);
}
public function get key():uint{
return (_key);
}
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);
}
}
}//package Box2D.Collision
Section 42
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
public class b2ContactPoint {
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 friction:Number;
public var velocity:b2Vec2;
public function b2ContactPoint(){
position = new b2Vec2();
velocity = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 43
//b2Distance (Box2D.Collision.b2Distance)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
public class b2Distance {
private static var s_p2s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_p1s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_points:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var gPoint:b2Point = new b2Point();
public static var g_GJK_Iterations:int = 0;
public static function InPoints(_arg1:b2Vec2, _arg2:Array, _arg3:int):Boolean{
var _local4:Number;
var _local5:int;
var _local6:b2Vec2;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
_local4 = (100 * Number.MIN_VALUE);
_local5 = 0;
while (_local5 < _arg3) {
_local6 = _arg2[_local5];
_local7 = (((_arg1.x - _local6.x) < 0)) ? -((_arg1.x - _local6.x)) : (_arg1.x - _local6.x);
_local8 = (((_arg1.y - _local6.y) < 0)) ? -((_arg1.y - _local6.y)) : (_arg1.y - _local6.y);
_local9 = ((_arg1.x < 0)) ? -(_arg1.x) : (((_arg1.x > _local6.x) < 0)) ? -(_local6.x) : (_local6.x) ? ((_arg1.x < 0)) ? -(_arg1.x) : _arg1.x : ((_local6.x < 0)) ? -(_local6.x) : _local6.x;
_local10 = ((_arg1.x < 0)) ? -(_arg1.y) : (((_arg1.y > _local6.y) < 0)) ? -(_local6.y) : (_local6.y) ? ((_arg1.y < 0)) ? -(_arg1.y) : _arg1.y : ((_local6.y < 0)) ? -(_local6.y) : _local6.y;
if ((((_local7 < (_local4 * (_local9 + 1)))) && ((_local8 < (_local4 * (_local10 + 1)))))){
return (true);
};
_local5++;
};
return (false);
}
public static function DistanceGeneric(_arg1:b2Vec2, _arg2:b2Vec2, _arg3, _arg4:b2XForm, _arg5, _arg6:b2XForm):Number{
var _local7:b2Vec2;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:int;
var _local12:Number;
var _local13:int;
var _local14:int;
var _local15:Number;
var _local16:Number;
var _local17:b2Vec2;
var _local18:b2Vec2;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:int;
_local8 = s_p1s;
_local9 = s_p2s;
_local10 = s_points;
_local11 = 0;
_arg1.SetV(_arg3.GetFirstVertex(_arg4));
_arg2.SetV(_arg5.GetFirstVertex(_arg6));
_local12 = 0;
_local13 = 20;
_local14 = 0;
while (_local14 < _local13) {
_local15 = (_arg2.x - _arg1.x);
_local16 = (_arg2.y - _arg1.y);
_local17 = _arg3.Support(_arg4, _local15, _local16);
_local18 = _arg5.Support(_arg6, -(_local15), -(_local16));
_local12 = ((_local15 * _local15) + (_local16 * _local16));
_local19 = (_local18.x - _local17.x);
_local20 = (_local18.y - _local17.y);
_local21 = ((_local15 * _local19) + (_local16 * _local20));
if ((_local12 - _local21) <= (0.01 * _local12)){
if (_local11 == 0){
_arg1.SetV(_local17);
_arg2.SetV(_local18);
};
g_GJK_Iterations = _local14;
return (Math.sqrt(_local12));
};
switch (_local11){
case 0:
_local7 = _local8[0];
_local7.SetV(_local17);
_local7 = _local9[0];
_local7.SetV(_local18);
_local7 = _local10[0];
_local7.x = _local19;
_local7.y = _local20;
_arg1.SetV(_local8[0]);
_arg2.SetV(_local9[0]);
_local11++;
break;
case 1:
_local7 = _local8[1];
_local7.SetV(_local17);
_local7 = _local9[1];
_local7.SetV(_local18);
_local7 = _local10[1];
_local7.x = _local19;
_local7.y = _local20;
_local11 = ProcessTwo(_arg1, _arg2, _local8, _local9, _local10);
break;
case 2:
_local7 = _local8[2];
_local7.SetV(_local17);
_local7 = _local9[2];
_local7.SetV(_local18);
_local7 = _local10[2];
_local7.x = _local19;
_local7.y = _local20;
_local11 = ProcessThree(_arg1, _arg2, _local8, _local9, _local10);
break;
};
if (_local11 == 3){
g_GJK_Iterations = _local14;
return (0);
};
_local22 = -(Number.MAX_VALUE);
_local23 = 0;
while (_local23 < _local11) {
_local7 = _local10[_local23];
_local22 = b2Math.b2Max(_local22, ((_local7.x * _local7.x) + (_local7.y * _local7.y)));
_local23++;
};
_local15 = (_arg2.x - _arg1.x);
_local16 = (_arg2.y - _arg1.y);
_local12 = ((_local15 * _local15) + (_local16 * _local16));
if (_local12 <= ((100 * Number.MIN_VALUE) * _local22)){
g_GJK_Iterations = _local14;
return (Math.sqrt(_local12));
};
_local14++;
};
g_GJK_Iterations = _local13;
return (Math.sqrt(_local12));
}
public static function DistanceEdgeCircle(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2EdgeShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{
var _local7:b2Vec2;
var _local8:Number;
var _local9:b2Mat22;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
_local8 = (_arg5.m_radius - b2Settings.b2_toiSlop);
_local9 = _arg6.R;
_local10 = _arg5.m_localPosition;
_local11 = (_arg6.position.x + ((_local9.col1.x * _local10.x) + (_local9.col2.x * _local10.y)));
_local12 = (_arg6.position.y + ((_local9.col1.y * _local10.x) + (_local9.col2.y * _local10.y)));
_local9 = _arg4.R;
_local13 = (_local11 - _arg4.position.x);
_local14 = (_local12 - _arg4.position.y);
_local15 = ((_local13 * _local9.col1.x) + (_local14 * _local9.col1.y));
_local16 = ((_local13 * _local9.col2.x) + (_local14 * _local9.col2.y));
_local17 = (((_local15 - _arg3.m_coreV1.x) * _arg3.m_direction.x) + ((_local16 - _arg3.m_coreV1.y) * _arg3.m_direction.y));
if (_local17 <= 0){
_local9 = _arg4.R;
_local10 = _arg3.m_coreV1;
_arg1.x = (_arg4.position.x + ((_local9.col1.x * _local10.x) + (_local9.col2.x * _local10.y)));
_arg1.y = (_arg4.position.y + ((_local9.col1.y * _local10.x) + (_local9.col2.y * _local10.y)));
} else {
if (_local17 >= _arg3.m_length){
_local9 = _arg4.R;
_local10 = _arg3.m_coreV2;
_arg1.x = (_arg4.position.x + ((_local9.col1.x * _local10.x) + (_local9.col2.x * _local10.y)));
_arg1.y = (_arg4.position.y + ((_local9.col1.y * _local10.x) + (_local9.col2.y * _local10.y)));
} else {
_local9 = _arg4.R;
_local13 = (_arg3.m_coreV1.x + (_local17 * _arg3.m_direction.x));
_local14 = (_arg3.m_coreV1.y + (_local17 * _arg3.m_direction.y));
_arg1.x = (_arg4.position.x + ((_local9.col1.x * _local13) + (_local9.col2.x * _local14)));
_arg1.y = (_arg4.position.y + ((_local9.col1.y * _local13) + (_local9.col2.y * _local14)));
_local17 = (((_local15 - _arg3.m_coreV1.x) * _arg3.m_normal.x) + ((_local16 - _arg3.m_coreV1.y) * _arg3.m_normal.y));
if (_local17 < 0){
if (_local17 < -(_local8)){
_local9 = _arg4.R;
_local13 = (_local15 + (_local8 * _arg3.m_normal.x));
_local14 = (_local16 + (_local8 * _arg3.m_normal.y));
_arg2.x = (_arg4.position.x + ((_local9.col1.x * _local13) + (_local9.col2.x * _local14)));
_arg2.y = (_arg4.position.y + ((_local9.col1.y * _local13) + (_local9.col2.y * _local14)));
return ((-(_local17) - _local8));
};
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
} else {
if (_local17 > _local8){
_local9 = _arg4.R;
_local13 = (_local15 - (_local8 * _arg3.m_normal.x));
_local14 = (_local16 - (_local8 * _arg3.m_normal.y));
_arg2.x = (_arg4.position.x + ((_local9.col1.x * _local13) + (_local9.col2.x * _local14)));
_arg2.y = (_arg4.position.y + ((_local9.col1.y * _local13) + (_local9.col2.y * _local14)));
return ((_local17 - _local8));
};
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
};
};
};
_local13 = (_local11 - _arg1.x);
_local14 = (_local12 - _arg1.y);
_local17 = ((_local13 * _local13) + (_local14 * _local14));
if (_local17 > (_local8 * _local8)){
_local17 = Math.sqrt(_local17);
_arg2.x = (_local11 - ((_local8 * _local13) / _local17));
_arg2.y = (_local12 - ((_local8 * _local14) / _local17));
return ((_local17 - _local8));
};
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
}
public static function DistanceCC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2CircleShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{
var _local7:b2Mat22;
var _local8:b2Vec2;
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;
_local7 = _arg4.R;
_local8 = _arg3.m_localPosition;
_local9 = (_arg4.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
_local10 = (_arg4.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
_local7 = _arg6.R;
_local8 = _arg5.m_localPosition;
_local11 = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
_local12 = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
_local13 = (_local11 - _local9);
_local14 = (_local12 - _local10);
_local15 = ((_local13 * _local13) + (_local14 * _local14));
_local16 = (_arg3.m_radius - b2Settings.b2_toiSlop);
_local17 = (_arg5.m_radius - b2Settings.b2_toiSlop);
_local18 = (_local16 + _local17);
if (_local15 > (_local18 * _local18)){
_local19 = Math.sqrt(_local15);
_local13 = (_local13 / _local19);
_local14 = (_local14 / _local19);
_local20 = (_local19 - _local18);
_arg1.x = (_local9 + (_local16 * _local13));
_arg1.y = (_local10 + (_local16 * _local14));
_arg2.x = (_local11 - (_local17 * _local13));
_arg2.y = (_local12 - (_local17 * _local14));
return (_local20);
};
if (_local15 > (Number.MIN_VALUE * Number.MIN_VALUE)){
_local19 = Math.sqrt(_local15);
_local13 = (_local13 / _local19);
_local14 = (_local14 / _local19);
_arg1.x = (_local9 + (_local16 * _local13));
_arg1.y = (_local10 + (_local16 * _local14));
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
};
_arg1.x = _local9;
_arg1.y = _local10;
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
}
public static function ProcessThree(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:b2Vec2;
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 _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
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;
_local6 = _arg5[0];
_local7 = _arg5[1];
_local8 = _arg5[2];
_local9 = _arg3[0];
_local10 = _arg3[1];
_local11 = _arg3[2];
_local12 = _arg4[0];
_local13 = _arg4[1];
_local14 = _arg4[2];
_local15 = _local6.x;
_local16 = _local6.y;
_local17 = _local7.x;
_local18 = _local7.y;
_local19 = _local8.x;
_local20 = _local8.y;
_local21 = (_local17 - _local15);
_local22 = (_local18 - _local16);
_local23 = (_local19 - _local15);
_local24 = (_local20 - _local16);
_local25 = (_local19 - _local17);
_local26 = (_local20 - _local18);
_local27 = -(((_local15 * _local21) + (_local16 * _local22)));
_local28 = ((_local17 * _local21) + (_local18 * _local22));
_local29 = -(((_local15 * _local23) + (_local16 * _local24)));
_local30 = ((_local19 * _local23) + (_local20 * _local24));
_local31 = -(((_local17 * _local25) + (_local18 * _local26)));
_local32 = ((_local19 * _local25) + (_local20 * _local26));
if ((((_local30 <= 0)) && ((_local32 <= 0)))){
_arg1.SetV(_local11);
_arg2.SetV(_local14);
_local9.SetV(_local11);
_local12.SetV(_local14);
_local6.SetV(_local8);
return (1);
};
_local33 = ((_local21 * _local24) - (_local22 * _local23));
_local34 = (_local33 * ((_local15 * _local18) - (_local16 * _local17)));
_local36 = (_local33 * ((_local17 * _local20) - (_local18 * _local19)));
if ((((((((_local36 <= 0)) && ((_local31 >= 0)))) && ((_local32 >= 0)))) && (((_local31 + _local32) > 0)))){
_local35 = (_local31 / (_local31 + _local32));
_arg1.x = (_local10.x + (_local35 * (_local11.x - _local10.x)));
_arg1.y = (_local10.y + (_local35 * (_local11.y - _local10.y)));
_arg2.x = (_local13.x + (_local35 * (_local14.x - _local13.x)));
_arg2.y = (_local13.y + (_local35 * (_local14.y - _local13.y)));
_local9.SetV(_local11);
_local12.SetV(_local14);
_local6.SetV(_local8);
return (2);
};
_local37 = (_local33 * ((_local19 * _local16) - (_local20 * _local15)));
if ((((((((_local37 <= 0)) && ((_local29 >= 0)))) && ((_local30 >= 0)))) && (((_local29 + _local30) > 0)))){
_local35 = (_local29 / (_local29 + _local30));
_arg1.x = (_local9.x + (_local35 * (_local11.x - _local9.x)));
_arg1.y = (_local9.y + (_local35 * (_local11.y - _local9.y)));
_arg2.x = (_local12.x + (_local35 * (_local14.x - _local12.x)));
_arg2.y = (_local12.y + (_local35 * (_local14.y - _local12.y)));
_local10.SetV(_local11);
_local13.SetV(_local14);
_local7.SetV(_local8);
return (2);
};
_local38 = ((_local36 + _local37) + _local34);
_local38 = (1 / _local38);
_local39 = (_local36 * _local38);
_local40 = (_local37 * _local38);
_local41 = ((1 - _local39) - _local40);
_arg1.x = (((_local39 * _local9.x) + (_local40 * _local10.x)) + (_local41 * _local11.x));
_arg1.y = (((_local39 * _local9.y) + (_local40 * _local10.y)) + (_local41 * _local11.y));
_arg2.x = (((_local39 * _local12.x) + (_local40 * _local13.x)) + (_local41 * _local14.x));
_arg2.y = (((_local39 * _local12.y) + (_local40 * _local13.y)) + (_local41 * _local14.y));
return (3);
}
public static function DistancePC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2PolygonShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{
var _local7:b2Mat22;
var _local8:b2Vec2;
var _local9:b2Point;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local9 = gPoint;
_local8 = _arg5.m_localPosition;
_local7 = _arg6.R;
_local9.p.x = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
_local9.p.y = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
_local10 = DistanceGeneric(_arg1, _arg2, _arg3, _arg4, _local9, b2Math.b2XForm_identity);
_local11 = (_arg5.m_radius - b2Settings.b2_toiSlop);
if (_local10 > _local11){
_local10 = (_local10 - _local11);
_local12 = (_arg2.x - _arg1.x);
_local13 = (_arg2.y - _arg1.y);
_local14 = Math.sqrt(((_local12 * _local12) + (_local13 * _local13)));
_local12 = (_local12 / _local14);
_local13 = (_local13 / _local14);
_arg2.x = (_arg2.x - (_local11 * _local12));
_arg2.y = (_arg2.y - (_local11 * _local13));
} else {
_local10 = 0;
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
};
return (_local10);
}
public static function Distance(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Shape, _arg4:b2XForm, _arg5:b2Shape, _arg6:b2XForm):Number{
var _local7:int;
var _local8:int;
_local7 = _arg3.m_type;
_local8 = _arg5.m_type;
if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_circleShape)))){
return (DistanceCC(_arg1, _arg2, (_arg3 as b2CircleShape), _arg4, (_arg5 as b2CircleShape), _arg6));
};
if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_circleShape)))){
return (DistancePC(_arg1, _arg2, (_arg3 as b2PolygonShape), _arg4, (_arg5 as b2CircleShape), _arg6));
};
if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_polygonShape)))){
return (DistancePC(_arg2, _arg1, (_arg5 as b2PolygonShape), _arg6, (_arg3 as b2CircleShape), _arg4));
};
if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_polygonShape)))){
return (DistanceGeneric(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6));
};
if ((((_local7 == b2Shape.e_edgeShape)) && ((_local8 == b2Shape.e_circleShape)))){
return (DistanceEdgeCircle(_arg1, _arg2, (_arg3 as b2EdgeShape), _arg4, (_arg5 as b2CircleShape), _arg6));
};
if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_edgeShape)))){
return (DistanceEdgeCircle(_arg2, _arg1, (_arg5 as b2EdgeShape), _arg6, (_arg3 as b2CircleShape), _arg4));
};
if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_edgeShape)))){
return (DistanceGeneric(_arg2, _arg1, _arg5, _arg6, _arg3, _arg4));
};
if ((((_local7 == b2Shape.e_edgeShape)) && ((_local8 == b2Shape.e_polygonShape)))){
return (DistanceGeneric(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6));
};
return (0);
}
public static function ProcessTwo(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
_local6 = _arg5[0];
_local7 = _arg5[1];
_local8 = _arg3[0];
_local9 = _arg3[1];
_local10 = _arg4[0];
_local11 = _arg4[1];
_local12 = -(_local7.x);
_local13 = -(_local7.y);
_local14 = (_local6.x - _local7.x);
_local15 = (_local6.y - _local7.y);
_local16 = Math.sqrt(((_local14 * _local14) + (_local15 * _local15)));
_local14 = (_local14 / _local16);
_local15 = (_local15 / _local16);
_local17 = ((_local12 * _local14) + (_local13 * _local15));
if ((((_local17 <= 0)) || ((_local16 < Number.MIN_VALUE)))){
_arg1.SetV(_local9);
_arg2.SetV(_local11);
_local8.SetV(_local9);
_local10.SetV(_local11);
_local6.SetV(_local7);
return (1);
};
_local17 = (_local17 / _local16);
_arg1.x = (_local9.x + (_local17 * (_local8.x - _local9.x)));
_arg1.y = (_local9.y + (_local17 * (_local8.y - _local9.y)));
_arg2.x = (_local11.x + (_local17 * (_local10.x - _local11.x)));
_arg2.y = (_local11.y + (_local17 * (_local10.y - _local11.y)));
return (2);
}
}
}//package Box2D.Collision
Section 44
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var points:Array;
public var pointCount:int;// = 0
public var normal:b2Vec2;
public function b2Manifold(){
var _local1:int;
pointCount = 0;
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
_local1 = 0;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ManifoldPoint();
_local1++;
};
normal = new b2Vec2();
}
public function Set(_arg1:b2Manifold):void{
var _local2:int;
pointCount = _arg1.pointCount;
_local2 = 0;
while (_local2 < b2Settings.b2_maxManifoldPoints) {
(points[_local2] as b2ManifoldPoint).Set(_arg1.points[_local2]);
_local2++;
};
normal.SetV(_arg1.normal);
}
public function Reset():void{
var _local1:int;
_local1 = 0;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
(points[_local1] as b2ManifoldPoint).Reset();
_local1++;
};
normal.SetZero();
pointCount = 0;
}
}
}//package Box2D.Collision
Section 45
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ManifoldPoint {
public var separation:Number;
public var localPoint2:b2Vec2;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var localPoint1:b2Vec2;
public var id:b2ContactID;
public function b2ManifoldPoint(){
localPoint1 = new b2Vec2();
localPoint2 = new b2Vec2();
id = new b2ContactID();
super();
}
public function Set(_arg1:b2ManifoldPoint):void{
localPoint1.SetV(_arg1.localPoint1);
localPoint2.SetV(_arg1.localPoint2);
separation = _arg1.separation;
normalImpulse = _arg1.normalImpulse;
tangentImpulse = _arg1.tangentImpulse;
id.key = _arg1.id.key;
}
public function Reset():void{
localPoint1.SetZero();
localPoint2.SetZero();
separation = 0;
normalImpulse = 0;
tangentImpulse = 0;
id.key = 0;
}
}
}//package Box2D.Collision
Section 46
//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 47
//b2Pair (Box2D.Collision.b2Pair)
package Box2D.Collision {
import Box2D.Common.*;
public class b2Pair {
public var proxy1:b2Proxy;
public var proxy2:b2Proxy;
public var status:uint;
public var userData;// = null
public var next:b2Pair;
public static var e_pairBuffered:uint = 1;
public static var b2_nullProxy:uint = b2Settings.USHRT_MAX;
public static var e_pairFinal:uint = 4;
public static var e_pairRemoved:uint = 2;
public function b2Pair(){
userData = null;
super();
}
public function SetBuffered():void{
status = (status | e_pairBuffered);
}
public function IsBuffered():Boolean{
return (((status & e_pairBuffered) == e_pairBuffered));
}
public function IsFinal():Boolean{
return (((status & e_pairFinal) == e_pairFinal));
}
public function ClearRemoved():void{
status = (status & ~(e_pairRemoved));
}
public function SetFinal():void{
status = (status | e_pairFinal);
}
public function IsRemoved():Boolean{
return (((status & e_pairRemoved) == e_pairRemoved));
}
public function ClearBuffered():void{
status = (status & ~(e_pairBuffered));
}
public function SetRemoved():void{
status = (status | e_pairRemoved);
}
}
}//package Box2D.Collision
Section 48
//b2PairCallback (Box2D.Collision.b2PairCallback)
package Box2D.Collision {
public class b2PairCallback {
public function PairRemoved(_arg1, _arg2, _arg3):void{
}
public function PairAdded(_arg1, _arg2){
return (null);
}
}
}//package Box2D.Collision
Section 49
//b2PairManager (Box2D.Collision.b2PairManager)
package Box2D.Collision {
import Box2D.Common.*;
public class b2PairManager {
b2internal var m_pairCount:int;
private var m_pairBuffer:Array;
private var m_callback:b2PairCallback;
b2internal var m_pairs:Array;
private var m_pairBufferCount:int;
private var m_broadPhase:b2BroadPhase;
private var m_freePair:b2Pair;
public function b2PairManager(){
m_pairs = new Array();
m_pairBuffer = new Array();
m_pairCount = 0;
m_pairBufferCount = 0;
m_freePair = null;
}
private function Find(_arg1:b2Proxy, _arg2:b2Proxy):b2Pair{
return (_arg1.pairs[_arg2]);
}
private function ValidateBuffer():void{
}
public function Commit():void{
var _local1:int;
var _local2:int;
var _local3:b2Pair;
var _local4:b2Proxy;
var _local5:b2Proxy;
_local2 = 0;
_local1 = 0;
while (_local1 < m_pairBufferCount) {
_local3 = m_pairBuffer[_local1];
_local3.ClearBuffered();
_local4 = _local3.proxy1;
_local5 = _local3.proxy2;
if (_local3.IsRemoved()){
if (_local3.IsFinal() == true){
m_callback.PairRemoved(_local4.userData, _local5.userData, _local3.userData);
};
m_pairBuffer[_local2] = _local3;
_local2++;
} else {
if (_local3.IsFinal() == false){
_local3.userData = m_callback.PairAdded(_local4.userData, _local5.userData);
_local3.SetFinal();
};
};
_local1++;
};
_local1 = 0;
while (_local1 < _local2) {
_local3 = m_pairBuffer[_local1];
RemovePair(_local3.proxy1, _local3.proxy2);
_local1++;
};
m_pairBufferCount = 0;
if (b2BroadPhase.s_validate){
ValidateTable();
};
}
public function RemoveBufferedPair(_arg1:b2Proxy, _arg2:b2Proxy):void{
var _local3:b2Pair;
_local3 = Find(_arg1, _arg2);
if (_local3 == null){
return;
};
if (_local3.IsBuffered() == false){
_local3.SetBuffered();
m_pairBuffer[m_pairBufferCount] = _local3;
m_pairBufferCount++;
};
_local3.SetRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function RemovePair(_arg1:b2Proxy, _arg2:b2Proxy){
var _local3:b2Pair;
var _local4:*;
_local3 = _arg1.pairs[_arg2];
if (_local3 == null){
return (null);
};
_local4 = _local3.userData;
delete _arg1.pairs[_arg2];
delete _arg2.pairs[_arg1];
_local3.next = m_freePair;
_local3.proxy1 = null;
_local3.proxy2 = null;
_local3.userData = null;
_local3.status = 0;
m_freePair = _local3;
m_pairCount--;
return (_local4);
}
public function Initialize(_arg1:b2BroadPhase, _arg2:b2PairCallback):void{
m_broadPhase = _arg1;
m_callback = _arg2;
}
public function AddBufferedPair(_arg1:b2Proxy, _arg2:b2Proxy):void{
var _local3:b2Pair;
_local3 = AddPair(_arg1, _arg2);
if (_local3.IsBuffered() == false){
_local3.SetBuffered();
m_pairBuffer[m_pairBufferCount] = _local3;
m_pairBufferCount++;
};
_local3.ClearRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function AddPair(_arg1:b2Proxy, _arg2:b2Proxy):b2Pair{
var _local3:b2Pair;
_local3 = _arg1.pairs[_arg2];
if (_local3 != null){
return (_local3);
};
if (m_freePair == null){
m_freePair = new b2Pair();
m_pairs.push(m_freePair);
};
_local3 = m_freePair;
m_freePair = _local3.next;
_local3.proxy1 = _arg1;
_local3.proxy2 = _arg2;
_local3.status = 0;
_local3.userData = null;
_local3.next = null;
_arg1.pairs[_arg2] = _local3;
_arg2.pairs[_arg1] = _local3;
m_pairCount++;
return (_local3);
}
private function ValidateTable():void{
}
}
}//package Box2D.Collision
Section 50
//b2Point (Box2D.Collision.b2Point)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2Point {
public var p:b2Vec2;
public function b2Point(){
p = new b2Vec2();
super();
}
public function GetFirstVertex(_arg1:b2XForm):b2Vec2{
return (p);
}
public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{
return (p);
}
}
}//package Box2D.Collision
Section 51
//b2Proxy (Box2D.Collision.b2Proxy)
package Box2D.Collision {
import flash.utils.*;
public class b2Proxy {
public var overlapCount:uint;
public var userData;// = null
public var lowerBounds:Array;
public var upperBounds:Array;
public var pairs:Dictionary;
public var next:b2Proxy;
public var timeStamp:uint;
public function b2Proxy(){
lowerBounds = [uint(0), uint(0)];
upperBounds = [uint(0), uint(0)];
pairs = new Dictionary();
userData = null;
super();
}
public function IsValid():Boolean{
return (!((overlapCount == b2BroadPhase.b2_invalid)));
}
}
}//package Box2D.Collision
Section 52
//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;
}
}//package Box2D.Collision
Section 53
//b2RayCastOutput (Box2D.Collision.b2RayCastOutput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2RayCastOutput {
public var fraction:Number;
public var hit:Boolean;
public var normal:b2Vec2;
}
}//package Box2D.Collision
Section 54
//b2Segment (Box2D.Collision.b2Segment)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2Segment {
public var p1:b2Vec2;
public var p2:b2Vec2;
public function b2Segment(){
p1 = new b2Vec2();
p2 = new b2Vec2();
super();
}
public function TestSegment(_arg1:Array, _arg2:b2Vec2, _arg3:b2Segment, _arg4:Number):Boolean{
var _local5:b2Vec2;
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;
_local5 = _arg3.p1;
_local6 = (_arg3.p2.x - _local5.x);
_local7 = (_arg3.p2.y - _local5.y);
_local8 = (p2.x - p1.x);
_local9 = (p2.y - p1.y);
_local10 = _local9;
_local11 = -(_local8);
_local12 = (100 * Number.MIN_VALUE);
_local13 = -(((_local6 * _local10) + (_local7 * _local11)));
if (_local13 > _local12){
_local14 = (_local5.x - p1.x);
_local15 = (_local5.y - p1.y);
_local16 = ((_local14 * _local10) + (_local15 * _local11));
if ((((0 <= _local16)) && ((_local16 <= (_arg4 * _local13))))){
_local17 = ((-(_local6) * _local15) + (_local7 * _local14));
if (((((-(_local12) * _local13) <= _local17)) && ((_local17 <= (_local13 * (1 + _local12)))))){
_local16 = (_local16 / _local13);
_local18 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
_local10 = (_local10 / _local18);
_local11 = (_local11 / _local18);
_arg1[0] = _local16;
_arg2.Set(_local10, _local11);
return (true);
};
};
};
return (false);
}
public function ExtendForward(_arg1:b2AABB):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (p2.x - p1.x);
_local3 = (p2.y - p1.y);
_local4 = Math.min(((_local2 > 0)) ? ((_arg1.upperBound.x - p1.x) / _local2) : ((_local2 < 0)) ? ((_arg1.lowerBound.x - p1.x) / _local2) : Number.POSITIVE_INFINITY, ((_local3 > 0)) ? ((_arg1.upperBound.y - p1.y) / _local3) : ((_local3 < 0)) ? ((_arg1.lowerBound.y - p1.y) / _local3) : Number.POSITIVE_INFINITY);
p2.x = (p1.x + (_local2 * _local4));
p2.y = (p1.y + (_local3 * _local4));
}
public function Extend(_arg1:b2AABB):void{
ExtendForward(_arg1);
ExtendBackward(_arg1);
}
public function ExtendBackward(_arg1:b2AABB):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (-(p2.x) + p1.x);
_local3 = (-(p2.y) + p1.y);
_local4 = Math.min(((_local2 > 0)) ? ((_arg1.upperBound.x - p2.x) / _local2) : ((_local2 < 0)) ? ((_arg1.lowerBound.x - p2.x) / _local2) : Number.POSITIVE_INFINITY, ((_local3 > 0)) ? ((_arg1.upperBound.y - p2.y) / _local3) : ((_local3 < 0)) ? ((_arg1.lowerBound.y - p2.y) / _local3) : Number.POSITIVE_INFINITY);
p1.x = (p2.x + (_local2 * _local4));
p1.y = (p2.y + (_local3 * _local4));
}
}
}//package Box2D.Collision
Section 55
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
public class b2TimeOfImpact {
private static var b2_maxToiRootIters:int = 0;
private static var b2_maxToiIters:int = 0;
public static var s_p1:b2Vec2 = new b2Vec2();
public static var s_p2:b2Vec2 = new b2Vec2();
public static var s_xf1:b2XForm = new b2XForm();
public static var s_xf2:b2XForm = new b2XForm();
public static function TimeOfImpact(_arg1:b2Shape, _arg2:b2Sweep, _arg3:b2Shape, _arg4:b2Sweep):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:b2Vec2;
var _local18:b2Vec2;
var _local19:int;
var _local20:int;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:b2XForm;
var _local27:b2XForm;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
_local7 = _arg1.m_sweepRadius;
_local8 = _arg3.m_sweepRadius;
_local9 = _arg2.t0;
_local10 = (_arg2.c.x - _arg2.c0.x);
_local11 = (_arg2.c.y - _arg2.c0.y);
_local12 = (_arg4.c.x - _arg4.c0.x);
_local13 = (_arg4.c.y - _arg4.c0.y);
_local14 = (_arg2.a - _arg2.a0);
_local15 = (_arg4.a - _arg4.a0);
_local16 = 0;
_local17 = s_p1;
_local18 = s_p2;
_local19 = 20;
_local20 = 0;
_local21 = 0;
_local22 = 0;
_local23 = 0;
_local24 = 0;
while (true) {
_local25 = (((1 - _local16) * _local9) + _local16);
_local26 = s_xf1;
_local27 = s_xf2;
_arg2.GetXForm(_local26, _local25);
_arg4.GetXForm(_local27, _local25);
_local23 = b2Distance.Distance(_local17, _local18, _arg1, _local26, _arg3, _local27);
if (_local20 == 0){
if (_local23 > (2 * b2Settings.b2_toiSlop)){
_local24 = (1.5 * b2Settings.b2_toiSlop);
} else {
_local5 = (0.05 * b2Settings.b2_toiSlop);
_local6 = (_local23 - (0.5 * b2Settings.b2_toiSlop));
_local24 = ((_local5 > _local6)) ? _local5 : _local6;
};
};
if (((((_local23 - _local24) < (0.05 * b2Settings.b2_toiSlop))) || ((_local20 == _local19)))){
break;
};
_local21 = (_local18.x - _local17.x);
_local22 = (_local18.y - _local17.y);
_local28 = Math.sqrt(((_local21 * _local21) + (_local22 * _local22)));
_local21 = (_local21 / _local28);
_local22 = (_local22 / _local28);
_local29 = ((((_local21 * (_local10 - _local12)) + (_local22 * (_local11 - _local13))) + (((_local14 < 0)) ? -(_local14) : _local14 * _local7)) + (((_local15 < 0)) ? -(_local15) : _local15 * _local8));
if (_local29 == 0){
_local16 = 1;
break;
};
_local30 = ((_local23 - _local24) / _local29);
_local31 = (_local16 + _local30);
if ((((_local31 < 0)) || ((1 < _local31)))){
_local16 = 1;
break;
};
if (_local31 < ((1 + (100 * Number.MIN_VALUE)) * _local16)){
break;
};
_local16 = _local31;
_local20++;
};
b2_maxToiIters = b2Math.b2Max(_local20, b2_maxToiIters);
return (_local16);
}
}
}//package Box2D.Collision
Section 56
//ClipVertex (Box2D.Collision.ClipVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class ClipVertex {
public var v:b2Vec2;
public var id:b2ContactID;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 57
//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 58
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(_arg1:Number=0, _arg2:b2Vec2=null, _arg3:b2Vec2=null){
var _local4:Number;
var _local5:Number;
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
if (((!((_arg2 == null))) && (!((_arg3 == null))))){
col1.SetV(_arg2);
col2.SetV(_arg3);
} else {
_local4 = Math.cos(_arg1);
_local5 = Math.sin(_arg1);
col1.x = _local4;
col2.x = -(_local5);
col1.y = _local5;
col2.y = _local4;
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function Set(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
col1.x = _local2;
col2.x = -(_local3);
col1.y = _local3;
col2.y = _local2;
}
public function SetVV(_arg1:b2Vec2, _arg2:b2Vec2):void{
col1.SetV(_arg1);
col2.SetV(_arg2);
}
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{
return (new b2Mat22(0, col1, col2));
}
public function GetInverse(_arg1:b2Mat22):b2Mat22{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local2 = col1.x;
_local3 = col2.x;
_local4 = col1.y;
_local5 = col2.y;
_local6 = ((_local2 * _local5) - (_local3 * _local4));
_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;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = col1.x;
_local5 = col2.x;
_local6 = col1.y;
_local7 = col2.y;
_local8 = ((_local4 * _local7) - (_local5 * _local6));
_local8 = (1 / _local8);
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
}
}//package Box2D.Common.Math
Section 59
//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 Solve33(_arg1:b2Vec3, _arg2:Number, _arg3:Number, _arg4:Number):b2Vec3{
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;
_local5 = col1.x;
_local6 = col1.y;
_local7 = col1.z;
_local8 = col2.x;
_local9 = col2.y;
_local10 = col2.z;
_local11 = col3.x;
_local12 = col3.y;
_local13 = col3.z;
_local14 = (((_local5 * ((_local9 * _local13) - (_local10 * _local12))) + (_local6 * ((_local10 * _local11) - (_local8 * _local13)))) + (_local7 * ((_local8 * _local12) - (_local9 * _local11))));
_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);
}
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 Solve22(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = col1.x;
_local5 = col2.x;
_local6 = col1.y;
_local7 = col2.y;
_local8 = ((_local4 * _local7) - (_local5 * _local6));
_local8 = (1 / _local8);
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
}
}//package Box2D.Common.Math
Section 60
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public static const b2Mat22_identity:b2Mat22 = new b2Mat22(0, new b2Vec2(1, 0), new b2Vec2(0, 1));
public static const b2XForm_identity:b2XForm = new b2XForm(b2Vec2_zero, b2Mat22_identity);
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0, 0);
public static function b2CrossVF(_arg1:b2Vec2, _arg2:Number):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg2 * _arg1.y), (-(_arg2) * _arg1.x));
return (_local3);
}
public static function AddVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg1.x + _arg2.x), (_arg1.y + _arg2.y));
return (_local3);
}
public static function b2IsValid(_arg1:Number):Boolean{
return (isFinite(_arg1));
}
public static function b2MinV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(b2Min(_arg1.x, _arg2.x), b2Min(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2MulX(_arg1:b2XForm, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = b2MulMV(_arg1.R, _arg2);
_local3.x = (_local3.x + _arg1.position.x);
_local3.y = (_local3.y + _arg1.position.y);
return (_local3);
}
public static function b2DistanceSquared(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number;
var _local4:Number;
_local3 = (_arg1.x - _arg2.x);
_local4 = (_arg1.y - _arg2.y);
return (((_local3 * _local3) + (_local4 * _local4)));
}
public static function b2Swap(_arg1:Array, _arg2:Array):void{
var _local3:*;
_local3 = _arg1[0];
_arg1[0] = _arg2[0];
_arg2[0] = _local3;
}
public static function b2AbsM(_arg1:b2Mat22):b2Mat22{
var _local2:b2Mat22;
_local2 = new b2Mat22(0, b2AbsV(_arg1.col1), b2AbsV(_arg1.col2));
return (_local2);
}
public static function SubtractVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg1.x - _arg2.x), (_arg1.y - _arg2.y));
return (_local3);
}
public static function b2MulXT(_arg1:b2XForm, _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 b2Abs(_arg1:Number):Number{
return (((_arg1 > 0)) ? _arg1 : -(_arg1));
}
public static function b2Clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (b2Max(_arg2, b2Min(_arg1, _arg3)));
}
public static function b2AbsV(_arg1:b2Vec2):b2Vec2{
var _local2:b2Vec2;
_local2 = new b2Vec2(b2Abs(_arg1.x), b2Abs(_arg1.y));
return (_local2);
}
public static function MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y));
return (_local3);
}
public static function b2CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
public static function b2Dot(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function b2CrossFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((-(_arg1) * _arg2.y), (_arg1 * _arg2.x));
return (_local3);
}
public static function AddMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22;
_local3 = new b2Mat22(0, AddVV(_arg1.col1, _arg2.col1), AddVV(_arg1.col2, _arg2.col2));
return (_local3);
}
public static function b2Distance(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number;
var _local4:Number;
_local3 = (_arg1.x - _arg2.x);
_local4 = (_arg1.y - _arg2.y);
return (Math.sqrt(((_local3 * _local3) + (_local4 * _local4))));
}
public static function b2MulTMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2Mat22;
_local3 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col1), b2Dot(_arg1.col2, _arg2.col1));
_local4 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col2), b2Dot(_arg1.col2, _arg2.col2));
_local5 = new b2Mat22(0, _local3, _local4);
return (_local5);
}
public static function b2MaxV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(b2Max(_arg1.x, _arg2.x), b2Max(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2IsPowerOfTwo(_arg1:uint):Boolean{
var _local2:Boolean;
_local2 = (((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)));
return (_local2);
}
public static function b2ClampV(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):b2Vec2{
return (b2MaxV(_arg2, b2MinV(_arg1, _arg3)));
}
public static function b2RandomRange(_arg1:Number, _arg2:Number):Number{
var _local3:Number;
_local3 = Math.random();
_local3 = (((_arg2 - _arg1) * _local3) + _arg1);
return (_local3);
}
public static function b2MulTMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(b2Dot(_arg2, _arg1.col1), b2Dot(_arg2, _arg1.col2));
return (_local3);
}
public static function b2Min(_arg1:Number, _arg2:Number):Number{
return (((_arg1 < _arg2)) ? _arg1 : _arg2);
}
public static function b2Random():Number{
return (((Math.random() * 2) - 1));
}
public static function b2MulMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22;
_local3 = new b2Mat22(0, b2MulMV(_arg1, _arg2.col1), b2MulMV(_arg1, _arg2.col2));
return (_local3);
}
public static function b2NextPowerOfTwo(_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 b2Max(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function b2MulMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(((_arg1.col1.x * _arg2.x) + (_arg1.col2.x * _arg2.y)), ((_arg1.col1.y * _arg2.x) + (_arg1.col2.y * _arg2.y)));
return (_local3);
}
}
}//package Box2D.Common.Math
Section 61
//b2Sweep (Box2D.Common.Math.b2Sweep)
package Box2D.Common.Math {
public class b2Sweep {
public var localCenter:b2Vec2;
public var c:b2Vec2;
public var a:Number;
public var c0:b2Vec2;
public var t0:Number;
public var a0: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 GetXForm2(_arg1:b2XForm, _arg2:Number):void{
var _local3:b2Mat22;
var _local4:Number;
if ((1 - t0) > Number.MIN_VALUE){
_arg1.position.x = (((1 - _arg2) * c0.x) + (_arg2 * c.x));
_arg1.position.y = (((1 - _arg2) * c0.y) + (_arg2 * c.y));
_local4 = (((1 - _arg2) * a0) + (_arg2 * a));
_arg1.R.Set(_local4);
} else {
_arg1.position.SetV(c);
_arg1.R.Set(a);
};
_local3 = _arg1.R;
_arg1.position.x = (_arg1.position.x - ((_local3.col1.x * localCenter.x) + (_local3.col2.x * localCenter.y)));
_arg1.position.y = (_arg1.position.y - ((_local3.col1.y * localCenter.x) + (_local3.col2.y * localCenter.y)));
}
public function GetXForm(_arg1:b2XForm, _arg2:Number):void{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
if ((1 - t0) > Number.MIN_VALUE){
_local4 = ((_arg2 - t0) / (1 - t0));
_arg1.position.x = (((1 - _local4) * c0.x) + (_local4 * c.x));
_arg1.position.y = (((1 - _local4) * c0.y) + (_local4 * c.y));
_local5 = (((1 - _local4) * a0) + (_local4 * a));
_arg1.R.Set(_local5);
} else {
_arg1.position.SetV(c);
_arg1.R.Set(a);
};
_local3 = _arg1.R;
_arg1.position.x = (_arg1.position.x - ((_local3.col1.x * localCenter.x) + (_local3.col2.x * localCenter.y)));
_arg1.position.y = (_arg1.position.y - ((_local3.col1.y * localCenter.x) + (_local3.col2.y * localCenter.y)));
}
}
}//package Box2D.Common.Math
Section 62
//b2Vec2 (Box2D.Common.Math.b2Vec2)
package Box2D.Common.Math {
public class b2Vec2 {
public var x:Number;
public var y:Number;
public function b2Vec2(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function Set(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
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 LengthSquared():Number{
return (((x * x) + (y * y)));
}
public function SetZero():void{
x = 0;
y = 0;
}
public function Add(_arg1:b2Vec2):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
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 Negative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function CrossVF(_arg1:Number):void{
var _local2:Number;
_local2 = x;
x = (_arg1 * y);
y = (-(_arg1) * _local2);
}
public function Abs():void{
if (x < 0){
x = -(x);
};
if (y < 0){
y = -(y);
};
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function MulTM(_arg1:b2Mat22):void{
var _local2:Number;
_local2 = b2Math.b2Dot(this, _arg1.col1);
y = b2Math.b2Dot(this, _arg1.col2);
x = _local2;
}
public function IsValid():Boolean{
return (((b2Math.b2IsValid(x)) && (b2Math.b2IsValid(y))));
}
public function MinV(_arg1:b2Vec2):void{
x = ((x < _arg1.x)) ? x : _arg1.x;
y = ((y < _arg1.y)) ? y : _arg1.y;
}
public function MulM(_arg1:b2Mat22):void{
var _local2:Number;
_local2 = x;
x = ((_arg1.col1.x * _local2) + (_arg1.col2.x * y));
y = ((_arg1.col1.y * _local2) + (_arg1.col2.y * y));
}
public function Normalize():Number{
var _local1:Number;
var _local2:Number;
_local1 = Math.sqrt(((x * x) + (y * y)));
if (_local1 < Number.MIN_VALUE){
return (0);
};
_local2 = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
return (_local1);
}
public function Subtract(_arg1:b2Vec2):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function CrossFV(_arg1:Number):void{
var _local2:Number;
_local2 = x;
x = (-(_arg1) * y);
y = (_arg1 * _local2);
}
public static function Make(_arg1:Number, _arg2:Number):b2Vec2{
return (new b2Vec2(_arg1, _arg2));
}
}
}//package Box2D.Common.Math
Section 63
//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 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 SetV(_arg1:b2Vec3):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
public function Negative():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);
}
public function Copy():b2Vec3{
return (new b2Vec3(x, y, z));
}
}
}//package Box2D.Common.Math
Section 64
//b2XForm (Box2D.Common.Math.b2XForm)
package Box2D.Common.Math {
public class b2XForm {
public var R:b2Mat22;
public var position:b2Vec2;
public function b2XForm(_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:b2XForm):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 65
//b2Color (Box2D.Common.b2Color)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Color {
private var _g:uint;// = 0
private var _b:uint;// = 0
private var _r:uint;// = 0
public function b2Color(_arg1:Number, _arg2:Number, _arg3:Number){
_r = 0;
_g = 0;
_b = 0;
super();
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1)));
}
public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1)));
}
public function get color():uint{
return ((((_r << 16) | (_g << 8)) | _b));
}
public function set r(_arg1:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
public function set b(_arg1:Number):void{
_b = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
public function set g(_arg1:Number):void{
_g = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
}
}//package Box2D.Common
Section 66
//b2internal (Box2D.Common.b2internal)
package Box2D.Common {
public namespace b2internal = "http://www.box2d.org/ns/b2internal";
}//package Box2D.Common
Section 67
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Settings {
public static const b2_fatAABBFactor:Number = 1.5;
public static const b2_maxTranslation:Number = 2;
public static const b2_pi:Number = 3.14159265358979;
public static const b2_angularSleepTolerance:Number = 0.0349065850398866;
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_maxTOIJointsPerIsland:int = 32;
public static const b2_maxPolygonVertices:int = 8;
public static const b2_velocityThreshold:Number = 1;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxTOIContactsPerIsland:int = 32;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const USHRT_MAX:int = 0xFFFF;
public static const VERSION:String = "2.0.2";
public static const b2_toiSlop:Number = 0.04;
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{
var _local2:b2Vec2;
if (!_arg1){
_local2.x++;
};
}
}
}//package Box2D.Common
Section 68
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2CircleContact extends b2Contact {
private var m_manifolds:Array;
private var m0:b2Manifold;
private var m_manifold:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2CircleContact(_arg1:b2Shape, _arg2:b2Shape){
var _local3:b2ManifoldPoint;
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
_local3 = m_manifold.points[0];
_local3.normalImpulse = 0;
_local3.tangentImpulse = 0;
}
override public function GetManifolds():Array{
return (m_manifolds);
}
override b2internal function Evaluate(_arg1:b2ContactListener):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2ManifoldPoint;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactPoint;
var _local8:b2ManifoldPoint;
_local5 = m_shape1.m_body;
_local6 = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollideCircles(m_manifold, (m_shape1 as b2CircleShape), _local5.m_xf, (m_shape2 as b2CircleShape), _local6.m_xf);
_local7 = s_evalCP;
_local7.shape1 = m_shape1;
_local7.shape2 = m_shape2;
_local7.friction = b2Settings.b2MixFriction(m_shape1.GetFriction(), m_shape2.GetFriction());
_local7.restitution = b2Settings.b2MixRestitution(m_shape1.GetRestitution(), m_shape2.GetRestitution());
if (m_manifold.pointCount > 0){
m_manifoldCount = 1;
_local8 = m_manifold.points[0];
if (m0.pointCount == 0){
_local8.normalImpulse = 0;
_local8.tangentImpulse = 0;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Add(_local7);
};
} else {
_local4 = m0.points[0];
_local8.normalImpulse = _local4.normalImpulse;
_local8.tangentImpulse = _local4.tangentImpulse;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Persist(_local7);
};
};
} else {
m_manifoldCount = 0;
if ((((m0.pointCount > 0)) && (_arg1))){
_local4 = m0.points[0];
_local7.position = _local5.GetWorldPoint(_local4.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m0.normal);
_local7.separation = _local4.separation;
_local7.id.key = _local4.id._key;
_arg1.Remove(_local7);
};
};
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2CircleContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 69
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2Contact {
b2internal var m_shape1:b2Shape;
b2internal var m_shape2:b2Shape;
b2internal var m_prev:b2Contact;
b2internal var m_toi:Number;
b2internal var m_next:b2Contact;
b2internal var m_manifoldCount:int;
b2internal var m_node1:b2ContactEdge;
b2internal var m_node2:b2ContactEdge;
b2internal var m_flags:uint;
b2internal static var e_toiFlag:uint = 8;
b2internal static var e_nonSolidFlag:uint = 1;
b2internal static var e_slowFlag:uint = 2;
b2internal static var e_islandFlag:uint = 4;
b2internal static var s_registers:Array;
b2internal static var s_initialized:Boolean = false;
public function b2Contact(_arg1:b2Shape=null, _arg2:b2Shape=null){
m_node1 = new b2ContactEdge();
m_node2 = new b2ContactEdge();
super();
m_flags = 0;
if (((!(_arg1)) || (!(_arg2)))){
m_shape1 = null;
m_shape2 = null;
return;
};
if (((_arg1.IsSensor()) || (_arg2.IsSensor()))){
m_flags = (m_flags | e_nonSolidFlag);
};
m_shape1 = _arg1;
m_shape2 = _arg2;
m_manifoldCount = 0;
m_prev = null;
m_next = null;
m_node1.contact = null;
m_node1.prev = null;
m_node1.next = null;
m_node1.other = null;
m_node2.contact = null;
m_node2.prev = null;
m_node2.next = null;
m_node2.other = null;
}
public function GetShape1():b2Shape{
return (m_shape1);
}
public function IsSolid():Boolean{
return (((m_flags & e_nonSolidFlag) == 0));
}
public function GetNext():b2Contact{
return (m_next);
}
public function GetManifolds():Array{
return (null);
}
public function GetShape2():b2Shape{
return (m_shape2);
}
public function GetManifoldCount():int{
return (m_manifoldCount);
}
b2internal function Update(_arg1:b2ContactListener):void{
var _local2:int;
var _local3:int;
var _local4:b2Body;
var _local5:b2Body;
_local2 = m_manifoldCount;
Evaluate(_arg1);
_local3 = m_manifoldCount;
_local4 = m_shape1.m_body;
_local5 = m_shape2.m_body;
if ((((_local3 == 0)) && ((_local2 > 0)))){
_local4.WakeUp();
_local5.WakeUp();
};
if (((((((_local4.IsStatic()) || (_local4.IsBullet()))) || (_local5.IsStatic()))) || (_local5.IsBullet()))){
m_flags = (m_flags & ~(e_slowFlag));
} else {
m_flags = (m_flags | e_slowFlag);
};
}
b2internal function Evaluate(_arg1:b2ContactListener):void{
}
b2internal static function InitializeRegisters():void{
var _local1:int;
var _local2:int;
s_registers = new Array(b2Shape.e_shapeTypeCount);
_local1 = 0;
while (_local1 < b2Shape.e_shapeTypeCount) {
s_registers[_local1] = new Array(b2Shape.e_shapeTypeCount);
_local2 = 0;
while (_local2 < b2Shape.e_shapeTypeCount) {
s_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);
}
b2internal static function Destroy(_arg1:b2Contact, _arg2):void{
var _local3:int;
var _local4:int;
var _local5:b2ContactRegister;
var _local6:Function;
if (_arg1.m_manifoldCount > 0){
_arg1.m_shape1.m_body.WakeUp();
_arg1.m_shape2.m_body.WakeUp();
};
_local3 = _arg1.m_shape1.m_type;
_local4 = _arg1.m_shape2.m_type;
_local5 = s_registers[_local3][_local4];
_local6 = _local5.destroyFcn;
_local6(_arg1, _arg2);
}
b2internal static function AddType(_arg1:Function, _arg2:Function, _arg3:int, _arg4:int):void{
s_registers[_arg3][_arg4].createFcn = _arg1;
s_registers[_arg3][_arg4].destroyFcn = _arg2;
s_registers[_arg3][_arg4].primary = true;
if (_arg3 != _arg4){
s_registers[_arg4][_arg3].createFcn = _arg1;
s_registers[_arg4][_arg3].destroyFcn = _arg2;
s_registers[_arg4][_arg3].primary = false;
};
}
b2internal static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
var _local4:int;
var _local5:int;
var _local6:b2ContactRegister;
var _local7:Function;
var _local8:b2Contact;
var _local9:int;
var _local10:b2Manifold;
if (s_initialized == false){
InitializeRegisters();
s_initialized = true;
};
_local4 = _arg1.m_type;
_local5 = _arg2.m_type;
_local6 = s_registers[_local4][_local5];
_local7 = _local6.createFcn;
if (_local7 != null){
if (_local6.primary){
return (_local7(_arg1, _arg2, _arg3));
};
_local8 = _local7(_arg2, _arg1, _arg3);
_local9 = 0;
while (_local9 < _local8.m_manifoldCount) {
_local10 = _local8.GetManifolds()[_local9];
_local8.GetManifolds()[_local9].normal = _local10.normal.Negative();
_local9++;
};
return (_local8);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 70
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2ContactConstraint {
public var pointCount:int;
public var points:Array;
public var restitution:Number;
public var K:b2Mat22;
public var manifold:b2Manifold;
public var body2:b2Body;
public var friction:Number;
public var normalMass:b2Mat22;
public var body1:b2Body;
public var normal:b2Vec2;
public function b2ContactConstraint(){
var _local1:int;
normal = new b2Vec2();
normalMass = new b2Mat22();
K = new b2Mat22();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
_local1 = 0;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactConstraintPoint();
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 71
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var r2:b2Vec2;
public var separation:Number;
public var normalImpulse:Number;
public var equalizedMass:Number;
public var tangentMass:Number;
public var tangentImpulse:Number;
public var localAnchor1:b2Vec2;
public var velocityBias:Number;
public var localAnchor2:b2Vec2;
public var normalMass:Number;
public var r1:b2Vec2;
public function b2ContactConstraintPoint(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
r1 = new b2Vec2();
r2 = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 72
//b2ContactEdge (Box2D.Dynamics.Contacts.b2ContactEdge)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactEdge {
public var next:b2ContactEdge;
public var other:b2Body;
public var contact:b2Contact;
public var prev:b2ContactEdge;
}
}//package Box2D.Dynamics.Contacts
Section 73
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var createFcn:Function;
public var destroyFcn:Function;
}
}//package Box2D.Dynamics.Contacts
Section 74
//b2ContactResult (Box2D.Dynamics.Contacts.b2ContactResult)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Collision.*;
public class b2ContactResult {
public var normal:b2Vec2;
public var position:b2Vec2;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var id:b2ContactID;
public function b2ContactResult(){
position = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 75
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2ContactSolver {
private var m_constraintCount:int;
b2internal var m_constraints:Array;
private var m_allocator;
private var m_step:b2TimeStep;
public function b2ContactSolver(_arg1:b2TimeStep, _arg2:Array, _arg3:int, _arg4){
var _local5:b2Contact;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Mat22;
var _local9:int;
var _local10:b2Shape;
var _local11:b2Shape;
var _local12:b2Body;
var _local13:b2Body;
var _local14:int;
var _local15:Array;
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:int;
var _local25:b2Manifold;
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 = new b2TimeStep();
m_constraints = new Array();
super();
m_step.dt = _arg1.dt;
m_step.inv_dt = _arg1.inv_dt;
m_step.positionIterations = _arg1.positionIterations;
m_step.velocityIterations = _arg1.velocityIterations;
m_allocator = _arg4;
m_constraintCount = 0;
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
m_constraintCount = (m_constraintCount + _local5.m_manifoldCount);
_local6++;
};
_local6 = 0;
while (_local6 < m_constraintCount) {
m_constraints[_local6] = new b2ContactConstraint();
_local6++;
};
_local9 = 0;
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
_local10 = _local5.m_shape1;
_local11 = _local5.m_shape2;
_local12 = _local10.m_body;
_local13 = _local11.m_body;
_local14 = _local5.m_manifoldCount;
_local15 = _local5.GetManifolds();
_local16 = b2Settings.b2MixFriction(_local10.GetFriction(), _local11.GetFriction());
_local17 = b2Settings.b2MixRestitution(_local10.GetRestitution(), _local11.GetRestitution());
_local18 = _local12.m_linearVelocity.x;
_local19 = _local12.m_linearVelocity.y;
_local20 = _local13.m_linearVelocity.x;
_local21 = _local13.m_linearVelocity.y;
_local22 = _local12.m_angularVelocity;
_local23 = _local13.m_angularVelocity;
_local24 = 0;
while (_local24 < _local14) {
_local25 = _local15[_local24];
_local26 = _local25.normal.x;
_local27 = _local25.normal.y;
_local28 = m_constraints[_local9];
_local28.body1 = _local12;
_local28.body2 = _local13;
_local28.manifold = _local25;
_local28.normal.x = _local26;
_local28.normal.y = _local27;
_local28.pointCount = _local25.pointCount;
_local28.friction = _local16;
_local28.restitution = _local17;
_local29 = 0;
while (_local29 < _local28.pointCount) {
_local30 = _local25.points[_local29];
_local31 = _local28.points[_local29];
_local31.normalImpulse = _local30.normalImpulse;
_local31.tangentImpulse = _local30.tangentImpulse;
_local31.separation = _local30.separation;
_local31.localAnchor1.SetV(_local30.localPoint1);
_local31.localAnchor2.SetV(_local30.localPoint2);
_local8 = _local12.m_xf.R;
_local34 = (_local30.localPoint1.x - _local12.m_sweep.localCenter.x);
_local35 = (_local30.localPoint1.y - _local12.m_sweep.localCenter.y);
_local32 = ((_local8.col1.x * _local34) + (_local8.col2.x * _local35));
_local35 = ((_local8.col1.y * _local34) + (_local8.col2.y * _local35));
_local34 = _local32;
_local31.r1.Set(_local34, _local35);
_local8 = _local13.m_xf.R;
_local36 = (_local30.localPoint2.x - _local13.m_sweep.localCenter.x);
_local37 = (_local30.localPoint2.y - _local13.m_sweep.localCenter.y);
_local32 = ((_local8.col1.x * _local36) + (_local8.col2.x * _local37));
_local37 = ((_local8.col1.y * _local36) + (_local8.col2.y * _local37));
_local36 = _local32;
_local31.r2.Set(_local36, _local37);
_local38 = ((_local34 * _local27) - (_local35 * _local26));
_local39 = ((_local36 * _local27) - (_local37 * _local26));
_local38 = (_local38 * _local38);
_local39 = (_local39 * _local39);
_local40 = (((_local12.m_invMass + _local13.m_invMass) + (_local12.m_invI * _local38)) + (_local13.m_invI * _local39));
_local31.normalMass = (1 / _local40);
_local41 = ((_local12.m_mass * _local12.m_invMass) + (_local13.m_mass * _local13.m_invMass));
_local41 = (_local41 + (((_local12.m_mass * _local12.m_invI) * _local38) + ((_local13.m_mass * _local13.m_invI) * _local39)));
_local31.equalizedMass = (1 / _local41);
_local42 = _local27;
_local43 = -(_local26);
_local44 = ((_local34 * _local43) - (_local35 * _local42));
_local45 = ((_local36 * _local43) - (_local37 * _local42));
_local44 = (_local44 * _local44);
_local45 = (_local45 * _local45);
_local46 = (((_local12.m_invMass + _local13.m_invMass) + (_local12.m_invI * _local44)) + (_local13.m_invI * _local45));
_local31.tangentMass = (1 / _local46);
_local31.velocityBias = 0;
if (_local31.separation > 0){
_local31.velocityBias = (-60 * _local31.separation);
} else {
_local32 = (((_local20 + (-(_local23) * _local37)) - _local18) - (-(_local22) * _local35));
_local33 = (((_local21 + (_local23 * _local36)) - _local19) - (_local22 * _local34));
_local47 = ((_local28.normal.x * _local32) + (_local28.normal.y * _local33));
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 = _local12.m_invMass;
_local51 = _local12.m_invI;
_local52 = _local13.m_invMass;
_local53 = _local13.m_invI;
_local54 = ((_local48.r1.x * _local27) - (_local48.r1.y * _local26));
_local55 = ((_local48.r2.x * _local27) - (_local48.r2.y * _local26));
_local56 = ((_local49.r1.x * _local27) - (_local49.r1.y * _local26));
_local57 = ((_local49.r2.x * _local27) - (_local49.r2.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;
};
};
_local9++;
_local24++;
};
_local6++;
};
}
public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2Mat22;
var _local5:int;
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;
_local5 = 0;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_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.r1.x * _local22) - (_local20.r1.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.r2.x * _local22) - (_local20.r2.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 _local2:Number;
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:int;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
var _local9:b2Vec2;
var _local10:Number;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:int;
var _local20:int;
var _local21:b2ContactConstraintPoint;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
_local2 = 0;
_local5 = 0;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_local9 = _local7.m_sweep.c;
_local10 = _local7.m_sweep.a;
_local11 = _local8.m_sweep.c;
_local12 = _local8.m_sweep.a;
_local13 = (_local7.m_mass * _local7.m_invMass);
_local14 = (_local7.m_mass * _local7.m_invI);
_local15 = (_local8.m_mass * _local8.m_invMass);
_local16 = (_local8.m_mass * _local8.m_invI);
_local17 = _local6.normal.x;
_local18 = _local6.normal.y;
_local19 = _local6.pointCount;
_local20 = 0;
while (_local20 < _local19) {
_local21 = _local6.points[_local20];
_local3 = _local7.m_xf.R;
_local4 = _local7.m_sweep.localCenter;
_local22 = (_local21.localAnchor1.x - _local4.x);
_local23 = (_local21.localAnchor1.y - _local4.y);
_local26 = ((_local3.col1.x * _local22) + (_local3.col2.x * _local23));
_local23 = ((_local3.col1.y * _local22) + (_local3.col2.y * _local23));
_local22 = _local26;
_local3 = _local8.m_xf.R;
_local4 = _local8.m_sweep.localCenter;
_local24 = (_local21.localAnchor2.x - _local4.x);
_local25 = (_local21.localAnchor2.y - _local4.y);
_local26 = ((_local3.col1.x * _local24) + (_local3.col2.x * _local25));
_local25 = ((_local3.col1.y * _local24) + (_local3.col2.y * _local25));
_local24 = _local26;
_local27 = (_local9.x + _local22);
_local28 = (_local9.y + _local23);
_local29 = (_local11.x + _local24);
_local30 = (_local11.y + _local25);
_local31 = (_local29 - _local27);
_local32 = (_local30 - _local28);
_local33 = (((_local31 * _local17) + (_local32 * _local18)) + _local21.separation);
_local2 = b2Math.b2Min(_local2, _local33);
_local34 = (_arg1 * b2Math.b2Clamp((_local33 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0));
_local35 = (-(_local21.equalizedMass) * _local34);
_local36 = (_local35 * _local17);
_local37 = (_local35 * _local18);
_local9.x = (_local9.x - (_local13 * _local36));
_local9.y = (_local9.y - (_local13 * _local37));
_local10 = (_local10 - (_local14 * ((_local22 * _local37) - (_local23 * _local36))));
_local7.m_sweep.a = _local10;
_local7.SynchronizeTransform();
_local11.x = (_local11.x + (_local15 * _local36));
_local11.y = (_local11.y + (_local15 * _local37));
_local12 = (_local12 + (_local16 * ((_local24 * _local37) - (_local25 * _local36))));
_local8.m_sweep.a = _local12;
_local8.SynchronizeTransform();
_local20++;
};
_local5++;
};
return ((_local2 >= (-1.5 * b2Settings.b2_linearSlop)));
}
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:Number;
var _local23:b2Mat22;
var _local24:b2Vec2;
var _local25:int;
var _local26:b2ContactConstraint;
var _local27:b2Body;
var _local28:b2Body;
var _local29:Number;
var _local30:Number;
var _local31:b2Vec2;
var _local32:b2Vec2;
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:int;
var _local44:Number;
var _local45:b2ContactConstraintPoint;
var _local46:b2ContactConstraintPoint;
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 _local58:Number;
var _local59:Number;
_local25 = 0;
while (_local25 < m_constraintCount) {
_local26 = m_constraints[_local25];
_local27 = _local26.body1;
_local28 = _local26.body2;
_local29 = _local27.m_angularVelocity;
_local30 = _local28.m_angularVelocity;
_local31 = _local27.m_linearVelocity;
_local32 = _local28.m_linearVelocity;
_local33 = _local27.m_invMass;
_local34 = _local27.m_invI;
_local35 = _local28.m_invMass;
_local36 = _local28.m_invI;
_local37 = _local26.normal.x;
_local38 = _local26.normal.y;
_local39 = _local38;
_local40 = -(_local37);
_local41 = _local26.friction;
_local43 = _local26.pointCount;
if (_local26.pointCount == 1){
_local2 = _local26.points[0];
_local7 = (((_local32.x + (-(_local30) * _local2.r2.y)) - _local31.x) - (-(_local29) * _local2.r1.y));
_local8 = (((_local32.y + (_local30 * _local2.r2.x)) - _local31.y) - (_local29 * _local2.r1.x));
_local9 = ((_local7 * _local37) + (_local8 * _local38));
_local11 = (-(_local2.normalMass) * (_local9 - _local2.velocityBias));
_local10 = ((_local7 * _local39) + (_local8 * _local40));
_local12 = (_local2.tangentMass * -(_local10));
_local13 = b2Math.b2Max((_local2.normalImpulse + _local11), 0);
_local11 = (_local13 - _local2.normalImpulse);
_local44 = (_local41 * _local2.normalImpulse);
_local14 = b2Math.b2Clamp((_local2.tangentImpulse + _local12), -(_local44), _local44);
_local12 = (_local14 - _local2.tangentImpulse);
_local15 = ((_local11 * _local37) + (_local12 * _local39));
_local16 = ((_local11 * _local38) + (_local12 * _local40));
_local31.x = (_local31.x - (_local33 * _local15));
_local31.y = (_local31.y - (_local33 * _local16));
_local29 = (_local29 - (_local34 * ((_local2.r1.x * _local16) - (_local2.r1.y * _local15))));
_local32.x = (_local32.x + (_local35 * _local15));
_local32.y = (_local32.y + (_local35 * _local16));
_local30 = (_local30 + (_local36 * ((_local2.r2.x * _local16) - (_local2.r2.y * _local15))));
_local2.normalImpulse = _local13;
_local2.tangentImpulse = _local14;
} else {
_local45 = _local26.points[0];
_local46 = _local26.points[1];
_local47 = _local45.normalImpulse;
_local48 = _local46.normalImpulse;
_local49 = (((_local32.x - (_local30 * _local45.r2.y)) - _local31.x) + (_local29 * _local45.r1.y));
_local50 = (((_local32.y + (_local30 * _local45.r2.x)) - _local31.y) - (_local29 * _local45.r1.x));
_local51 = (((_local32.x - (_local30 * _local46.r2.y)) - _local31.x) + (_local29 * _local46.r1.y));
_local52 = (((_local32.y + (_local30 * _local46.r2.x)) - _local31.y) - (_local29 * _local46.r1.x));
_local53 = ((_local49 * _local37) + (_local50 * _local38));
_local54 = ((_local51 * _local37) + (_local52 * _local38));
_local55 = (_local53 - _local45.velocityBias);
_local56 = (_local54 - _local46.velocityBias);
_local23 = _local26.K;
_local55 = (_local55 - ((_local23.col1.x * _local47) + (_local23.col2.x * _local48)));
_local56 = (_local56 - ((_local23.col1.y * _local47) + (_local23.col2.y * _local48)));
_local57 = 0.001;
while (true) {
_local23 = _local26.normalMass;
_local58 = -(((_local23.col1.x * _local55) + (_local23.col2.x * _local56)));
_local59 = -(((_local23.col1.y * _local55) + (_local23.col2.y * _local56)));
if ((((_local58 >= 0)) && ((_local59 >= 0)))){
_local17 = (_local58 - _local47);
_local18 = (_local59 - _local48);
_local19 = (_local17 * _local37);
_local20 = (_local17 * _local38);
_local21 = (_local18 * _local37);
_local22 = (_local18 * _local38);
_local31.x = (_local31.x - (_local33 * (_local19 + _local21)));
_local31.y = (_local31.y - (_local33 * (_local20 + _local22)));
_local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21))));
_local32.x = (_local32.x + (_local35 * (_local19 + _local21)));
_local32.y = (_local32.y + (_local35 * (_local20 + _local22)));
_local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21))));
_local45.normalImpulse = _local58;
_local46.normalImpulse = _local59;
break;
};
_local58 = (-(_local45.normalMass) * _local55);
_local59 = 0;
_local53 = 0;
_local54 = ((_local26.K.col1.y * _local58) + _local56);
if ((((_local58 >= 0)) && ((_local54 >= 0)))){
_local17 = (_local58 - _local47);
_local18 = (_local59 - _local48);
_local19 = (_local17 * _local37);
_local20 = (_local17 * _local38);
_local21 = (_local18 * _local37);
_local22 = (_local18 * _local38);
_local31.x = (_local31.x - (_local33 * (_local19 + _local21)));
_local31.y = (_local31.y - (_local33 * (_local20 + _local22)));
_local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21))));
_local32.x = (_local32.x + (_local35 * (_local19 + _local21)));
_local32.y = (_local32.y + (_local35 * (_local20 + _local22)));
_local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21))));
_local45.normalImpulse = _local58;
_local46.normalImpulse = _local59;
break;
};
_local58 = 0;
_local59 = (-(_local46.normalMass) * _local56);
_local53 = ((_local26.K.col2.x * _local59) + _local55);
_local54 = 0;
if ((((_local59 >= 0)) && ((_local53 >= 0)))){
_local17 = (_local58 - _local47);
_local18 = (_local59 - _local48);
_local19 = (_local17 * _local37);
_local20 = (_local17 * _local38);
_local21 = (_local18 * _local37);
_local22 = (_local18 * _local38);
_local31.x = (_local31.x - (_local33 * (_local19 + _local21)));
_local31.y = (_local31.y - (_local33 * (_local20 + _local22)));
_local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21))));
_local32.x = (_local32.x + (_local35 * (_local19 + _local21)));
_local32.y = (_local32.y + (_local35 * (_local20 + _local22)));
_local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21))));
_local45.normalImpulse = _local58;
_local46.normalImpulse = _local59;
break;
};
_local58 = 0;
_local59 = 0;
_local53 = _local55;
_local54 = _local56;
if ((((_local53 >= 0)) && ((_local54 >= 0)))){
_local17 = (_local58 - _local47);
_local18 = (_local59 - _local48);
_local19 = (_local17 * _local37);
_local20 = (_local17 * _local38);
_local21 = (_local18 * _local37);
_local22 = (_local18 * _local38);
_local31.x = (_local31.x - (_local33 * (_local19 + _local21)));
_local31.y = (_local31.y - (_local33 * (_local20 + _local22)));
_local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21))));
_local32.x = (_local32.x + (_local35 * (_local19 + _local21)));
_local32.y = (_local32.y + (_local35 * (_local20 + _local22)));
_local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21))));
_local45.normalImpulse = _local58;
_local46.normalImpulse = _local59;
break;
};
break;
};
_local1 = 0;
while (_local1 < _local26.pointCount) {
_local2 = _local26.points[_local1];
_local7 = (((_local32.x - (_local30 * _local2.r2.y)) - _local31.x) + (_local29 * _local2.r1.y));
_local8 = (((_local32.y + (_local30 * _local2.r2.x)) - _local31.y) - (_local29 * _local2.r1.x));
_local10 = ((_local7 * _local39) + (_local8 * _local40));
_local12 = (_local2.tangentMass * -(_local10));
_local44 = (_local41 * _local2.normalImpulse);
_local14 = b2Math.b2Clamp((_local2.tangentImpulse + _local12), -(_local44), _local44);
_local12 = (_local14 - _local2.tangentImpulse);
_local15 = (_local12 * _local39);
_local16 = (_local12 * _local40);
_local31.x = (_local31.x - (_local33 * _local15));
_local31.y = (_local31.y - (_local33 * _local16));
_local29 = (_local29 - (_local34 * ((_local2.r1.x * _local16) - (_local2.r1.y * _local15))));
_local32.x = (_local32.x + (_local35 * _local15));
_local32.y = (_local32.y + (_local35 * _local16));
_local30 = (_local30 + (_local36 * ((_local2.r2.x * _local16) - (_local2.r2.y * _local15))));
_local2.tangentImpulse = _local14;
_local1++;
};
};
_local27.m_angularVelocity = _local29;
_local28.m_angularVelocity = _local30;
_local25++;
};
}
public function FinalizeVelocityConstraints():void{
var _local1:int;
var _local2:b2ContactConstraint;
var _local3:b2Manifold;
var _local4:int;
var _local5:b2ManifoldPoint;
var _local6:b2ContactConstraintPoint;
_local1 = 0;
while (_local1 < m_constraintCount) {
_local2 = m_constraints[_local1];
_local3 = _local2.manifold;
_local4 = 0;
while (_local4 < _local2.pointCount) {
_local5 = _local3.points[_local4];
_local6 = _local2.points[_local4];
_local5.normalImpulse = _local6.normalImpulse;
_local5.tangentImpulse = _local6.tangentImpulse;
_local4++;
};
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 76
//b2EdgeAndCircleContact (Box2D.Dynamics.Contacts.b2EdgeAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2EdgeAndCircleContact extends b2Contact {
private var m_manifolds:Array;
private var m_manifold:b2Manifold;
private var m0:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2EdgeAndCircleContact(_arg1:b2Shape, _arg2:b2Shape){
var _local3:b2ManifoldPoint;
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
_local3 = m_manifold.points[0];
_local3.normalImpulse = 0;
_local3.tangentImpulse = 0;
}
override public function GetManifolds():Array{
return (m_manifolds);
}
private function b2CollideEdgeAndCircle(_arg1:b2Manifold, _arg2:b2EdgeShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{
var _local6:b2Mat22;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:b2ManifoldPoint;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:b2Vec2;
var _local18:b2Vec2;
var _local19:b2Vec2;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Boolean;
var _local24:Number;
_arg1.pointCount = 0;
_local6 = _arg5.R;
_local7 = _arg4.m_localPosition;
_local13 = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
_local14 = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local6 = _arg3.R;
_local10 = (_local13 - _arg3.position.x);
_local11 = (_local14 - _arg3.position.y);
_local15 = ((_local10 * _local6.col1.x) + (_local11 * _local6.col1.y));
_local16 = ((_local10 * _local6.col2.x) + (_local11 * _local6.col2.y));
_local17 = _arg2.m_normal;
_local18 = _arg2.m_v1;
_local19 = _arg2.m_v2;
_local20 = _arg4.m_radius;
_local22 = (((_local15 - _local18.x) * _arg2.m_direction.x) + ((_local16 - _local18.y) * _arg2.m_direction.y));
_local23 = false;
if (_local22 <= 0){
_local8 = (_local15 - _local18.x);
_local9 = (_local16 - _local18.y);
if (((_local8 * _arg2.m_cornerDir1.x) + (_local9 * _arg2.m_cornerDir1.y)) < 0){
return;
};
_local8 = (_local13 - (_arg3.position.x + ((_local6.col1.x * _local18.x) + (_local6.col2.x * _local18.y))));
_local9 = (_local14 - (_arg3.position.y + ((_local6.col1.y * _local18.x) + (_local6.col2.y * _local18.y))));
} else {
if (_local22 >= _arg2.m_length){
_local8 = (_local15 - _local19.x);
_local9 = (_local16 - _local19.y);
if (((_local8 * _arg2.m_cornerDir2.x) + (_local9 * _arg2.m_cornerDir2.y)) > 0){
return;
};
_local8 = (_local13 - (_arg3.position.x + ((_local6.col1.x * _local19.x) + (_local6.col2.x * _local19.y))));
_local9 = (_local14 - (_arg3.position.y + ((_local6.col1.y * _local19.x) + (_local6.col2.y * _local19.y))));
} else {
_local21 = (((_local15 - _local18.x) * _local17.x) + ((_local16 - _local18.y) * _local17.y));
if ((((_local21 > _local20)) || ((_local21 < -(_local20))))){
return;
};
_local21 = (_local21 - _local20);
_local6 = _arg3.R;
_arg1.normal.x = ((_local6.col1.x * _local17.x) + (_local6.col2.x * _local17.y));
_arg1.normal.y = ((_local6.col1.y * _local17.x) + (_local6.col2.y * _local17.y));
_local23 = true;
};
};
if (!_local23){
_local24 = ((_local8 * _local8) + (_local9 * _local9));
if (_local24 > (_local20 * _local20)){
return;
};
if (_local24 < Number.MIN_VALUE){
_local21 = -(_local20);
_arg1.normal.x = ((_local6.col1.x * _local17.x) + (_local6.col2.x * _local17.y));
_arg1.normal.y = ((_local6.col1.y * _local17.x) + (_local6.col2.y * _local17.y));
} else {
_local24 = Math.sqrt(_local24);
_local8 = (_local8 / _local24);
_local9 = (_local9 / _local24);
_local21 = (_local24 - _local20);
_arg1.normal.x = _local8;
_arg1.normal.y = _local9;
};
};
_local12 = _arg1.points[0];
_arg1.pointCount = 1;
_local12.id.key = 0;
_local12.separation = _local21;
_local13 = (_local13 - (_local20 * _arg1.normal.x));
_local14 = (_local14 - (_local20 * _arg1.normal.y));
_local10 = (_local13 - _arg3.position.x);
_local11 = (_local14 - _arg3.position.y);
_local12.localPoint1.x = ((_local10 * _local6.col1.x) + (_local11 * _local6.col1.y));
_local12.localPoint1.y = ((_local10 * _local6.col2.x) + (_local11 * _local6.col2.y));
_local6 = _arg5.R;
_local10 = (_local13 - _arg5.position.x);
_local11 = (_local14 - _arg5.position.y);
_local12.localPoint2.x = ((_local10 * _local6.col1.x) + (_local11 * _local6.col1.y));
_local12.localPoint2.y = ((_local10 * _local6.col2.x) + (_local11 * _local6.col2.y));
}
override b2internal function Evaluate(_arg1:b2ContactListener):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2ManifoldPoint;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactPoint;
var _local8:b2ManifoldPoint;
_local5 = m_shape1.m_body;
_local6 = m_shape2.m_body;
m0.Set(m_manifold);
b2CollideEdgeAndCircle(m_manifold, (m_shape1 as b2EdgeShape), _local5.m_xf, (m_shape2 as b2CircleShape), _local6.m_xf);
_local7 = s_evalCP;
_local7.shape1 = m_shape1;
_local7.shape2 = m_shape2;
_local7.friction = b2Settings.b2MixFriction(m_shape1.GetFriction(), m_shape2.GetFriction());
_local7.restitution = b2Settings.b2MixRestitution(m_shape1.GetRestitution(), m_shape2.GetRestitution());
if (m_manifold.pointCount > 0){
m_manifoldCount = 1;
_local8 = m_manifold.points[0];
if (m0.pointCount == 0){
_local8.normalImpulse = 0;
_local8.tangentImpulse = 0;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Add(_local7);
};
} else {
_local4 = m0.points[0];
_local8.normalImpulse = _local4.normalImpulse;
_local8.tangentImpulse = _local4.tangentImpulse;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Persist(_local7);
};
};
} else {
m_manifoldCount = 0;
if ((((m0.pointCount > 0)) && (_arg1))){
_local4 = m0.points[0];
_local7.position = _local5.GetWorldPoint(_local4.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m0.normal);
_local7.separation = _local4.separation;
_local7.id.key = _local4.id._key;
_arg1.Remove(_local7);
};
};
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2EdgeAndCircleContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 77
//b2NullContact (Box2D.Dynamics.Contacts.b2NullContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2NullContact extends b2Contact {
override public function GetManifolds():Array{
return (null);
}
override b2internal function Evaluate(_arg1:b2ContactListener):void{
}
}
}//package Box2D.Dynamics.Contacts
Section 78
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2PolyAndCircleContact extends b2Contact {
private var m_manifolds:Array;
private var m0:b2Manifold;
private var m_manifold:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolyAndCircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polygonShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_circleShape));
m_manifold.pointCount = 0;
}
override public function GetManifolds():Array{
return (m_manifolds);
}
override b2internal function Evaluate(_arg1:b2ContactListener):void{
var _local2:int;
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2ManifoldPoint;
var _local6:b2Body;
var _local7:b2Body;
var _local8:Array;
var _local9:b2ContactPoint;
var _local10:b2ManifoldPoint;
var _local11:Boolean;
var _local12:uint;
var _local13:int;
_local6 = m_shape1.m_body;
_local7 = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygonAndCircle(m_manifold, (m_shape1 as b2PolygonShape), _local6.m_xf, (m_shape2 as b2CircleShape), _local7.m_xf);
_local8 = [false, false];
_local9 = s_evalCP;
_local9.shape1 = m_shape1;
_local9.shape2 = m_shape2;
_local9.friction = b2Settings.b2MixFriction(m_shape1.GetFriction(), m_shape2.GetFriction());
_local9.restitution = b2Settings.b2MixRestitution(m_shape1.GetRestitution(), m_shape2.GetRestitution());
if (m_manifold.pointCount > 0){
_local2 = 0;
while (_local2 < m_manifold.pointCount) {
_local10 = m_manifold.points[_local2];
_local10.normalImpulse = 0;
_local10.tangentImpulse = 0;
_local11 = false;
_local12 = _local10.id._key;
_local13 = 0;
while (_local13 < m0.pointCount) {
if (_local8[_local13] == true){
} else {
_local5 = m0.points[_local13];
if (_local5.id._key == _local12){
_local8[_local13] = true;
_local10.normalImpulse = _local5.normalImpulse;
_local10.tangentImpulse = _local5.tangentImpulse;
_local11 = true;
if (_arg1 != null){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Persist(_local9);
};
break;
};
};
_local13++;
};
if ((((_local11 == false)) && (!((_arg1 == null))))){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Add(_local9);
};
_local2++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (_arg1 == null){
return;
};
_local2 = 0;
while (_local2 < m0.pointCount) {
if (_local8[_local2]){
} else {
_local5 = m0.points[_local2];
_local9.position = _local6.GetWorldPoint(_local5.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local5.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local5.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m0.normal);
_local9.separation = _local5.separation;
_local9.id.key = _local5.id._key;
_arg1.Remove(_local9);
};
_local2++;
};
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolyAndCircleContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 79
//b2PolyAndEdgeContact (Box2D.Dynamics.Contacts.b2PolyAndEdgeContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2PolyAndEdgeContact extends b2Contact {
private var m_manifolds:Array;
private var m0:b2Manifold;
private var m_manifold:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolyAndEdgeContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polygonShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_edgeShape));
m_manifold.pointCount = 0;
}
override public function GetManifolds():Array{
return (m_manifolds);
}
private function b2CollidePolyAndEdge(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2EdgeShape, _arg5:b2XForm):void{
var _local6:b2Mat22;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:Number;
var _local10:Number;
var _local11:b2ManifoldPoint;
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:int;
var _local27:Number;
var _local28:Number;
var _local29:int;
var _local30:Number;
var _local31:Number;
var _local32:Boolean;
var _local33:int;
var _local34:int;
var _local35:Array;
var _local36:Array;
var _local37:int;
var _local38:int;
var _local39:int;
var _local40:int;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:int;
var _local47:Number;
var _local48:Number;
_arg1.pointCount = 0;
_local6 = _arg5.R;
_local7 = _arg4.m_v1;
_local13 = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
_local14 = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local7 = _arg4.m_v2;
_local15 = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
_local16 = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local7 = _arg4.m_normal;
_local17 = ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y));
_local18 = ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y));
_local6 = _arg3.R;
_local9 = (_local13 - _arg3.position.x);
_local10 = (_local14 - _arg3.position.y);
_local19 = ((_local9 * _local6.col1.x) + (_local10 * _local6.col1.y));
_local20 = ((_local9 * _local6.col2.x) + (_local10 * _local6.col2.y));
_local9 = (_local15 - _arg3.position.x);
_local10 = (_local16 - _arg3.position.y);
_local21 = ((_local9 * _local6.col1.x) + (_local10 * _local6.col1.y));
_local22 = ((_local9 * _local6.col2.x) + (_local10 * _local6.col2.y));
_local23 = ((_local17 * _local6.col1.x) + (_local18 * _local6.col1.y));
_local24 = ((_local17 * _local6.col2.x) + (_local18 * _local6.col2.y));
_local26 = -1;
_local27 = -(Number.MAX_VALUE);
_local29 = -1;
_local30 = -(Number.MAX_VALUE);
_local31 = -(Number.MAX_VALUE);
_local32 = false;
_local33 = -1;
_local34 = _arg2.m_vertexCount;
_local35 = _arg2.m_vertices;
_local36 = _arg2.m_normals;
_local37 = -1;
_local38 = -1;
_local39 = -1;
_local40 = -1;
_local41 = 0;
_local42 = 0;
_local43 = 0;
_local44 = 0;
_local45 = Number.MAX_VALUE;
_local7 = _local35[(_local34 - 1)];
_local41 = (((_local7.x - _local19) * _local23) + ((_local7.y - _local20) * _local24));
_local46 = 0;
while (_local46 < _local34) {
_local7 = _local35[_local46];
_local8 = _local36[_local46];
_local25 = (((_local19 - _local7.x) * _local8.x) + ((_local20 - _local7.y) * _local8.y));
_local28 = (((_local21 - _local7.x) * _local8.x) + ((_local22 - _local7.y) * _local8.y));
if (_local28 < _local25){
if (_local28 > _local31){
_local31 = _local28;
_local32 = false;
_local33 = _local46;
};
} else {
if (_local25 > _local31){
_local31 = _local25;
_local32 = true;
_local33 = _local46;
};
};
if (_local25 > _local27){
_local27 = _local25;
_local26 = _local46;
};
if (_local28 > _local30){
_local30 = _local28;
_local29 = _local46;
};
_local42 = (((_local7.x - _local19) * _local23) + ((_local7.y - _local20) * _local24));
if ((((_local42 >= 0)) && ((_local41 < 0)))){
_local39 = ((_local46)==0) ? (_local34 - 1) : (_local46 - 1);
_local40 = _local46;
_local44 = _local41;
} else {
if ((((_local42 < 0)) && ((_local41 >= 0)))){
_local37 = ((_local46)==0) ? (_local34 - 1) : (_local46 - 1);
_local38 = _local46;
_local43 = _local42;
};
};
if (_local42 < _local45){
_local45 = _local42;
};
_local41 = _local42;
_local46++;
};
if (_local37 == -1){
return;
};
if (_local31 > 0){
return;
};
if (((((_local32) && (_arg4.m_cornerConvex1))) || (((!(_local32)) && (_arg4.m_cornerConvex2))))){
if (_local31 > (_local45 + b2Settings.b2_linearSlop)){
if (_local32){
_local6 = _arg5.R;
_local7 = _arg4.m_cornerDir1;
_local9 = ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y));
_local10 = ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y));
_local6 = _arg3.R;
_local13 = ((_local6.col1.x * _local9) + (_local6.col2.x * _local10));
_local14 = ((_local6.col1.y * _local9) + (_local6.col2.y * _local10));
_local8 = _local36[_local26];
if (((_local8.x * _local13) + (_local8.y * _local14)) >= 0){
return;
};
} else {
_local6 = _arg5.R;
_local7 = _arg4.m_cornerDir2;
_local9 = ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y));
_local10 = ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y));
_local6 = _arg3.R;
_local13 = ((_local6.col1.x * _local9) + (_local6.col2.x * _local10));
_local14 = ((_local6.col1.y * _local9) + (_local6.col2.y * _local10));
_local8 = _local36[_local29];
if (((_local8.x * _local13) + (_local8.y * _local14)) <= 0){
return;
};
};
_local11 = _arg1.points[0];
_arg1.pointCount = 1;
_local6 = _arg3.R;
_local8 = _local36[_local33];
_arg1.normal.x = ((_local6.col1.x * _local8.x) + (_local6.col2.x * _local8.y));
_arg1.normal.y = ((_local6.col1.y * _local8.x) + (_local6.col2.y * _local8.y));
_local11.separation = _local31;
_local11.id.features.incidentEdge = _local33;
_local11.id.features.incidentVertex = b2Collision.b2_nullFeature;
_local11.id.features.referenceEdge = 0;
_local11.id.features.flip = 0;
if (_local32){
_local11.localPoint1.x = _local19;
_local11.localPoint1.y = _local20;
_local11.localPoint2.x = _arg4.m_v1.x;
_local11.localPoint2.y = _arg4.m_v1.y;
} else {
_local11.localPoint1.x = _local21;
_local11.localPoint1.y = _local22;
_local11.localPoint2.x = _arg4.m_v2.x;
_local11.localPoint2.y = _arg4.m_v2.y;
};
return;
};
};
_arg1.normal.x = -(_local17);
_arg1.normal.y = -(_local18);
if (_local38 == _local39){
_local11 = _arg1.points[0];
_arg1.pointCount = 1;
_local11.id.features.incidentEdge = _local38;
_local11.id.features.incidentVertex = b2Collision.b2_nullFeature;
_local11.id.features.referenceEdge = 0;
_local11.id.features.flip = 0;
_local7 = _local35[_local38];
_local11.localPoint1.x = _local7.x;
_local11.localPoint1.y = _local7.y;
_local6 = _arg3.R;
_local9 = ((_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y))) - _arg5.position.x);
_local10 = ((_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y))) - _arg5.position.y);
_local6 = _arg5.R;
_local11.localPoint2.x = ((_local9 * _local6.col1.x) + (_local10 * _local6.col1.y));
_local11.localPoint2.y = ((_local9 * _local6.col2.x) + (_local10 * _local6.col2.y));
_local11.separation = _local43;
return;
};
_arg1.pointCount = 2;
_local9 = -(_local24);
_local10 = _local23;
_local7 = _local35[_local38];
_local47 = ((_local9 * (_local7.x - _local19)) + (_local10 * (_local7.y - _local20)));
_local40 = ((_local38)==(_local34 - 1)) ? 0 : (_local38 + 1);
_local7 = _local35[_local39];
if (_local40 != _local39){
_local39 = _local40;
_local44 = ((_local23 * (_local7.x - _local19)) + (_local24 * (_local7.y - _local20)));
};
_local48 = ((_local9 * (_local7.x - _local19)) + (_local10 * (_local7.y - _local20)));
_local11 = _arg1.points[0];
_local11.id.features.incidentEdge = _local38;
_local11.id.features.incidentVertex = b2Collision.b2_nullFeature;
_local11.id.features.referenceEdge = 0;
_local11.id.features.flip = 0;
if (_local47 > _arg4.m_length){
_local11.localPoint1.x = _local21;
_local11.localPoint1.y = _local22;
_local11.localPoint2.x = _arg4.m_v2.x;
_local11.localPoint2.y = _arg4.m_v2.y;
_local12 = ((_arg4.m_length - _local48) / (_local47 - _local48));
if ((((_local12 > (100 * Number.MIN_VALUE))) && ((_local12 < 1)))){
_local11.separation = ((_local44 * (1 - _local12)) + (_local43 * _local12));
} else {
_local11.separation = _local43;
};
} else {
_local7 = _local35[_local38];
_local11.localPoint1.x = _local7.x;
_local11.localPoint1.y = _local7.y;
_local6 = _arg3.R;
_local9 = ((_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y))) - _arg5.position.x);
_local10 = ((_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y))) - _arg5.position.y);
_local6 = _arg5.R;
_local11.localPoint2.x = ((_local9 * _local6.col1.x) + (_local10 * _local6.col1.y));
_local11.localPoint2.y = ((_local9 * _local6.col2.x) + (_local10 * _local6.col2.y));
_local11.separation = _local43;
};
_local11 = _arg1.points[1];
_local11.id.features.incidentEdge = _local39;
_local11.id.features.incidentVertex = b2Collision.b2_nullFeature;
_local11.id.features.referenceEdge = 0;
_local11.id.features.flip = 0;
if (_local48 < 0){
_local11.localPoint1.x = _local19;
_local11.localPoint1.y = _local20;
_local11.localPoint2.x = _arg4.m_v1.x;
_local11.localPoint2.y = _arg4.m_v1.y;
_local12 = (-(_local47) / (_local48 - _local47));
if ((((_local12 > (100 * Number.MIN_VALUE))) && ((_local12 < 1)))){
_local11.separation = ((_local43 * (1 - _local12)) + (_local44 * _local12));
} else {
_local11.separation = _local44;
};
} else {
_local7 = _local35[_local39];
_local11.localPoint1.x = _local7.x;
_local11.localPoint1.y = _local7.y;
_local6 = _arg3.R;
_local9 = ((_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y))) - _arg5.position.x);
_local10 = ((_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y))) - _arg5.position.y);
_local6 = _arg5.R;
_local11.localPoint2.x = ((_local9 * _local6.col1.x) + (_local10 * _local6.col1.y));
_local11.localPoint2.y = ((_local9 * _local6.col2.x) + (_local10 * _local6.col2.y));
_local11.separation = _local44;
};
}
override b2internal function Evaluate(_arg1:b2ContactListener):void{
var _local2:int;
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2ManifoldPoint;
var _local6:b2Body;
var _local7:b2Body;
var _local8:Array;
var _local9:b2ContactPoint;
var _local10:b2ManifoldPoint;
var _local11:Boolean;
var _local12:uint;
var _local13:int;
_local6 = m_shape1.m_body;
_local7 = m_shape2.m_body;
m0.Set(m_manifold);
b2CollidePolyAndEdge(m_manifold, (m_shape1 as b2PolygonShape), _local6.m_xf, (m_shape2 as b2EdgeShape), _local7.m_xf);
_local8 = [false, false];
_local9 = s_evalCP;
_local9.shape1 = m_shape1;
_local9.shape2 = m_shape2;
_local9.friction = b2Settings.b2MixFriction(m_shape1.GetFriction(), m_shape2.GetFriction());
_local9.restitution = b2Settings.b2MixRestitution(m_shape1.GetRestitution(), m_shape2.GetRestitution());
if (m_manifold.pointCount > 0){
_local2 = 0;
while (_local2 < m_manifold.pointCount) {
_local10 = m_manifold.points[_local2];
_local10.normalImpulse = 0;
_local10.tangentImpulse = 0;
_local11 = false;
_local12 = _local10.id._key;
_local13 = 0;
while (_local13 < m0.pointCount) {
if (_local8[_local13] == true){
} else {
_local5 = m0.points[_local13];
if (_local5.id._key == _local12){
_local8[_local13] = true;
_local10.normalImpulse = _local5.normalImpulse;
_local10.tangentImpulse = _local5.tangentImpulse;
_local11 = true;
if (_arg1 != null){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Persist(_local9);
};
break;
};
};
_local13++;
};
if ((((_local11 == false)) && (!((_arg1 == null))))){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Add(_local9);
};
_local2++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (_arg1 == null){
return;
};
_local2 = 0;
while (_local2 < m0.pointCount) {
if (_local8[_local2]){
} else {
_local5 = m0.points[_local2];
_local9.position = _local6.GetWorldPoint(_local5.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local5.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local5.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m0.normal);
_local9.separation = _local5.separation;
_local9.id.key = _local5.id._key;
_arg1.Remove(_local9);
};
_local2++;
};
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolyAndEdgeContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 80
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2PolygonContact extends b2Contact {
private var m_manifolds:Array;
private var m0:b2Manifold;
private var m_manifold:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolygonContact(_arg1:b2Shape, _arg2:b2Shape):void{
m0 = new b2Manifold();
m_manifolds = [new b2Manifold()];
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
}
override public function GetManifolds():Array{
return (m_manifolds);
}
override b2internal function Evaluate(_arg1:b2ContactListener):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2ManifoldPoint;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactPoint;
var _local8:int;
var _local9:Array;
var _local10:b2ManifoldPoint;
var _local11:Boolean;
var _local12:uint;
var _local13:int;
_local5 = m_shape1.m_body;
_local6 = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygons(m_manifold, (m_shape1 as b2PolygonShape), _local5.m_xf, (m_shape2 as b2PolygonShape), _local6.m_xf);
_local9 = [false, false];
_local7 = s_evalCP;
_local7.shape1 = m_shape1;
_local7.shape2 = m_shape2;
_local7.friction = b2Settings.b2MixFriction(m_shape1.GetFriction(), m_shape2.GetFriction());
_local7.restitution = b2Settings.b2MixRestitution(m_shape1.GetRestitution(), m_shape2.GetRestitution());
if (m_manifold.pointCount > 0){
_local8 = 0;
while (_local8 < m_manifold.pointCount) {
_local10 = m_manifold.points[_local8];
_local10.normalImpulse = 0;
_local10.tangentImpulse = 0;
_local11 = false;
_local12 = _local10.id._key;
_local13 = 0;
while (_local13 < m0.pointCount) {
if (_local9[_local13] == true){
} else {
_local4 = m0.points[_local13];
if (_local4.id._key == _local12){
_local9[_local13] = true;
_local10.normalImpulse = _local4.normalImpulse;
_local10.tangentImpulse = _local4.tangentImpulse;
_local11 = true;
if (_arg1 != null){
_local7.position = _local5.GetWorldPoint(_local10.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local10.separation;
_local7.id.key = _local12;
_arg1.Persist(_local7);
};
break;
};
};
_local13++;
};
if ((((_local11 == false)) && (!((_arg1 == null))))){
_local7.position = _local5.GetWorldPoint(_local10.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local10.separation;
_local7.id.key = _local12;
_arg1.Add(_local7);
};
_local8++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (_arg1 == null){
return;
};
_local8 = 0;
while (_local8 < m0.pointCount) {
if (_local9[_local8]){
} else {
_local4 = m0.points[_local8];
_local7.position = _local5.GetWorldPoint(_local4.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m0.normal);
_local7.separation = _local4.separation;
_local7.id.key = _local4.id._key;
_arg1.Remove(_local7);
};
_local8++;
};
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolygonContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 81
//b2Controller (Box2D.Dynamics.Controllers.b2Controller)
package Box2D.Dynamics.Controllers {
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2Controller {
b2internal var m_world:b2World;
b2internal var m_next:b2Controller;
protected var m_bodyList:b2ControllerEdge;
b2internal var m_prev:b2Controller;
protected var m_bodyCount:int;
public function AddBody(_arg1:b2Body):void{
var _local2:b2ControllerEdge;
_local2 = 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;
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 Step(_arg1:b2TimeStep):void{
}
public function Clear():void{
while (m_bodyList) {
RemoveBody(m_bodyList.body);
};
}
public function GetBodyList():b2ControllerEdge{
return (m_bodyList);
}
public function GetWorld():b2World{
return (m_world);
}
}
}//package Box2D.Dynamics.Controllers
Section 82
//b2ControllerEdge (Box2D.Dynamics.Controllers.b2ControllerEdge)
package Box2D.Dynamics.Controllers {
import Box2D.Dynamics.*;
public class b2ControllerEdge {
public var body:b2Body;
public var nextController:b2ControllerEdge;
public var nextBody:b2ControllerEdge;
public var prevController:b2ControllerEdge;
public var prevBody:b2ControllerEdge;
public var controller:b2Controller;
}
}//package Box2D.Dynamics.Controllers
Section 83
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2DistanceJoint extends b2Joint {
private var m_mass:Number;
private var m_u:b2Vec2;
private var m_impulse:Number;
private var m_dampingRatio:Number;
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_bias:Number;
private var m_frequencyHz:Number;
private var m_gamma:Number;
private var m_length: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.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_length = _arg1.length;
m_frequencyHz = _arg1.frequencyHz;
m_dampingRatio = _arg1.dampingRatio;
m_impulse = 0;
m_gamma = 0;
m_bias = 0;
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
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;
var _local3:b2Body;
var _local4:b2Body;
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;
if (m_frequencyHz > 0){
return (true);
};
_local3 = m_body1;
_local4 = m_body2;
_local2 = _local3.m_xf.R;
_local5 = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
_local6 = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
_local8 = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
_local9 = (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;
_local10 = (((_local4.m_sweep.c.x + _local8) - _local3.m_sweep.c.x) - _local5);
_local11 = (((_local4.m_sweep.c.y + _local9) - _local3.m_sweep.c.y) - _local6);
_local12 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
_local10 = (_local10 / _local12);
_local11 = (_local11 / _local12);
_local13 = (_local12 - m_length);
_local13 = b2Math.b2Clamp(_local13, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local14 = (-(m_mass) * _local13);
m_u.Set(_local10, _local11);
_local15 = (_local14 * m_u.x);
_local16 = (_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.b2Abs(_local13) < b2Settings.b2_linearSlop));
}
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;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
_local4 = m_body1;
_local5 = m_body2;
_local2 = _local4.m_xf.R;
_local6 = (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;
_local8 = (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);
_local10 = 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();
};
_local11 = ((_local6 * m_u.y) - (_local7 * m_u.x));
_local12 = ((_local8 * m_u.y) - (_local9 * m_u.x));
_local13 = (((_local4.m_invMass + ((_local4.m_invI * _local11) * _local11)) + _local5.m_invMass) + ((_local5.m_invI * _local12) * _local12));
m_mass = (1 / _local13);
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 = (1 / (_arg1.dt * (_local16 + (_arg1.dt * _local17))));
m_bias = (((_local14 * _arg1.dt) * _local17) * m_gamma);
m_mass = (1 / (_local13 + m_gamma));
};
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;
};
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:b2Body;
var _local4:b2Body;
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;
_local3 = m_body1;
_local4 = m_body2;
_local2 = _local3.m_xf.R;
_local5 = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
_local6 = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
_local8 = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
_local9 = (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;
_local10 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local6));
_local11 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local5));
_local12 = (_local4.m_linearVelocity.x + (-(_local4.m_angularVelocity) * _local9));
_local13 = (_local4.m_linearVelocity.y + (_local4.m_angularVelocity * _local8));
_local14 = ((m_u.x * (_local12 - _local10)) + (m_u.y * (_local13 - _local11)));
_local15 = (-(m_mass) * ((_local14 + m_bias) + (m_gamma * m_impulse)));
m_impulse = (m_impulse + _local15);
_local16 = (_local15 * m_u.x);
_local17 = (_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))));
}
}
}//package Box2D.Dynamics.Joints
Section 84
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2DistanceJointDef extends b2JointDef {
public var length:Number;
public var dampingRatio:Number;
public var frequencyHz:Number;
public var localAnchor2:b2Vec2;
public var localAnchor1:b2Vec2;
public function b2DistanceJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = 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{
var _local5:Number;
var _local6:Number;
body1 = _arg1;
body2 = _arg2;
localAnchor1.SetV(body1.GetLocalPoint(_arg3));
localAnchor2.SetV(body2.GetLocalPoint(_arg4));
_local5 = (_arg4.x - _arg3.x);
_local6 = (_arg4.y - _arg3.y);
length = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
frequencyHz = 0;
dampingRatio = 0;
}
}
}//package Box2D.Dynamics.Joints
Section 85
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2GearJoint extends b2Joint {
private var m_ratio:Number;
private var m_mass:Number;
private var m_impulse:Number;
private var m_prismatic1:b2PrismaticJoint;
private var m_prismatic2:b2PrismaticJoint;
private var m_ground1:b2Body;
private var m_constant:Number;
private var m_ground2:b2Body;
private var m_groundAnchor2:b2Vec2;
private var m_groundAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_revolute1:b2RevoluteJoint;
private var m_revolute2:b2RevoluteJoint;
private var m_localAnchor1:b2Vec2;
private var m_J:b2Jacobian;
public function b2GearJoint(_arg1:b2GearJointDef){
var _local2:int;
var _local3:int;
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);
_local2 = _arg1.joint1.m_type;
_local3 = _arg1.joint2.m_type;
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = _arg1.joint1.m_body1;
m_body1 = _arg1.joint1.m_body2;
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.m_body1;
m_body2 = _arg1.joint2.m_body2;
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 public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2(((_arg1 * m_impulse) * m_J.linear2.x), ((_arg1 * m_impulse) * m_J.linear2.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:b2Body;
var _local4:b2Body;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local2 = 0;
_local3 = m_body1;
_local4 = m_body2;
if (m_revolute1){
_local5 = m_revolute1.GetJointAngle();
} else {
_local5 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
_local6 = m_revolute2.GetJointAngle();
} else {
_local6 = m_prismatic2.GetJointTranslation();
};
_local7 = (m_constant - (_local5 + (m_ratio * _local6)));
_local8 = (-(m_mass) * _local7);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local3.m_invMass * _local8) * m_J.linear1.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local3.m_invMass * _local8) * m_J.linear1.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local3.m_invI * _local8) * m_J.angular1));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local4.m_invMass * _local8) * m_J.linear2.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local4.m_invMass * _local8) * m_J.linear2.y));
_local4.m_sweep.a = (_local4.m_sweep.a + ((_local4.m_invI * _local8) * m_J.angular2));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
return ((_local2 < b2Settings.b2_linearSlop));
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Body;
var _local5: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 _local14:Number;
_local2 = m_ground1;
_local3 = m_ground2;
_local4 = m_body1;
_local5 = m_body2;
_local14 = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angular1 = -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.linear1.Set(-(_local6), -(_local7));
m_J.angular1 = -(_local12);
_local14 = (_local14 + (_local4.m_invMass + ((_local4.m_invI * _local12) * _local12)));
};
if (m_revolute2){
m_J.angular2 = -(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.linear2.Set((-(m_ratio) * _local6), (-(m_ratio) * _local7));
m_J.angular2 = (-(m_ratio) * _local12);
_local14 = (_local14 + ((m_ratio * m_ratio) * (_local5.m_invMass + ((_local5.m_invI * _local12) * _local12))));
};
m_mass = (1 / _local14);
if (_arg1.warmStarting){
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * m_impulse) * m_J.linear1.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * m_impulse) * m_J.linear1.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * m_impulse) * m_J.angular1));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + ((_local5.m_invMass * m_impulse) * m_J.linear2.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + ((_local5.m_invMass * m_impulse) * m_J.linear2.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + ((_local5.m_invI * m_impulse) * m_J.angular2));
} else {
m_impulse = 0;
};
}
override public function GetReactionTorque(_arg1:Number):Number{
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local2 = m_body2.m_xf.R;
_local3 = (m_localAnchor1.x - m_body2.m_sweep.localCenter.x);
_local4 = (m_localAnchor1.y - m_body2.m_sweep.localCenter.y);
_local5 = ((_local2.col1.x * _local3) + (_local2.col2.x * _local4));
_local4 = ((_local2.col1.y * _local3) + (_local2.col2.y * _local4));
_local3 = _local5;
_local6 = (m_impulse * m_J.linear2.x);
_local7 = (m_impulse * m_J.linear2.y);
return ((_arg1 * (((m_impulse * m_J.angular2) - (_local3 * _local7)) + (_local4 * _local6))));
}
public function GetRatio():Number{
return (m_ratio);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:Number;
var _local5:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = m_J.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local5 = (-(m_mass) * _local4);
m_impulse = (m_impulse + _local5);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local2.m_invMass * _local5) * m_J.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local2.m_invMass * _local5) * m_J.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local2.m_invI * _local5) * m_J.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * _local5) * m_J.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * _local5) * m_J.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _local5) * m_J.angular2));
}
}
}//package Box2D.Dynamics.Joints
Section 86
//b2GearJointDef (Box2D.Dynamics.Joints.b2GearJointDef)
package Box2D.Dynamics.Joints {
public class b2GearJointDef extends b2JointDef {
public var joint2:b2Joint;
public var joint1:b2Joint;
public var ratio:Number;
public function b2GearJointDef(){
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Box2D.Dynamics.Joints
Section 87
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var linear1:b2Vec2;
public var linear2:b2Vec2;
public var angular2:Number;
public var angular1:Number;
public function b2Jacobian(){
linear1 = new b2Vec2();
linear2 = new b2Vec2();
super();
}
public function Set(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):void{
linear1.SetV(_arg1);
angular1 = _arg2;
linear2.SetV(_arg3);
angular2 = _arg4;
}
public function SetZero():void{
linear1.SetZero();
angular1 = 0;
linear2.SetZero();
angular2 = 0;
}
public function Compute(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{
return ((((((linear1.x * _arg1.x) + (linear1.y * _arg1.y)) + (angular1 * _arg2)) + ((linear2.x * _arg3.x) + (linear2.y * _arg3.y))) + (angular2 * _arg4)));
}
}
}//package Box2D.Dynamics.Joints
Section 88
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2Joint {
b2internal var m_islandFlag:Boolean;
b2internal var m_collideConnected:Boolean;
b2internal var m_prev:b2Joint;
b2internal var m_type:int;
b2internal var m_next:b2Joint;
b2internal var m_node1:b2JointEdge;
b2internal var m_node2:b2JointEdge;
b2internal var m_localCenter1:b2Vec2;
b2internal var m_localCenter2:b2Vec2;
b2internal var m_invMass1:Number;
b2internal var m_invI2:Number;
b2internal var m_invMass2:Number;
private var m_userData;
b2internal var m_body1:b2Body;
b2internal var m_body2:b2Body;
b2internal var m_invI1:Number;
b2internal static const e_prismaticJoint:int = 2;
b2internal static const e_equalLimits:int = 3;
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_node1 = new b2JointEdge();
m_node2 = new b2JointEdge();
m_localCenter1 = new b2Vec2();
m_localCenter2 = new b2Vec2();
super();
m_type = _arg1.type;
m_prev = null;
m_next = null;
m_body1 = _arg1.body1;
m_body2 = _arg1.body2;
m_collideConnected = _arg1.collideConnected;
m_islandFlag = false;
m_userData = _arg1.userData;
}
b2internal function ComputeXForm(_arg1:b2XForm, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):void{
_arg1.R.Set(_arg4);
_arg1.position.SetV(b2Math.SubtractVV(_arg2, b2Math.b2MulMV(_arg1.R, _arg3)));
}
public function GetAnchor1():b2Vec2{
return (null);
}
public function GetAnchor2():b2Vec2{
return (null);
}
b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
}
public function GetType():int{
return (m_type);
}
public function GetBody2():b2Body{
return (m_body2);
}
public function GetNext():b2Joint{
return (m_next);
}
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 SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetBody1():b2Body{
return (m_body1);
}
b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
}
b2internal static function Destroy(_arg1:b2Joint, _arg2):void{
}
b2internal static function Create(_arg1:b2JointDef, _arg2):b2Joint{
var _local3:b2Joint;
_local3 = null;
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;
default:
break;
};
return (_local3);
}
}
}//package Box2D.Dynamics.Joints
Section 89
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var collideConnected:Boolean;
public var body1:b2Body;
public var body2:b2Body;
public var userData;
public var type:int;
public function b2JointDef(){
type = b2Joint.e_unknownJoint;
userData = null;
body1 = null;
body2 = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 90
//b2JointEdge (Box2D.Dynamics.Joints.b2JointEdge)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointEdge {
public var joint:b2Joint;
public var other:b2Body;
public var next:b2JointEdge;
public var prev:b2JointEdge;
}
}//package Box2D.Dynamics.Joints
Section 91
//b2LineJoint (Box2D.Dynamics.Joints.b2LineJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2LineJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_enableLimit:Boolean;
private var m_impulse:b2Vec2;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_s1:Number;
private var m_axis:b2Vec2;
private var m_motorImpulse:Number;
private var m_upperTranslation:Number;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_perp:b2Vec2;
private var m_maxMotorForce:Number;
private var m_motorMass:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_enableMotor:Boolean;
private var m_motorSpeed:Number;
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.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_localXAxis1.SetV(_arg1.localAxis1);
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 public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetJointTranslation():Number{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local6:Number;
var _local7:Number;
var _local8:b2Vec2;
var _local9:Number;
_local1 = m_body1;
_local2 = m_body2;
_local4 = _local1.GetWorldPoint(m_localAnchor1);
_local5 = _local2.GetWorldPoint(m_localAnchor2);
_local6 = (_local5.x - _local4.x);
_local7 = (_local5.y - _local4.y);
_local8 = _local1.GetWorldVector(m_localXAxis1);
_local9 = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
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);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Vec2;
var _local5:Number;
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;
var _local17:Number;
var _local18:b2Vec2;
var _local19:b2Vec2;
var _local20:Number;
var _local21:Number;
var _local22:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_linearVelocity;
_local5 = _local2.m_angularVelocity;
_local6 = _local3.m_linearVelocity;
_local7 = _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.b2Clamp((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_invMass1 * _local8));
_local4.y = (_local4.y - (m_invMass1 * _local9));
_local5 = (_local5 - (m_invI1 * _local10));
_local6.x = (_local6.x + (m_invMass2 * _local8));
_local6.y = (_local6.y + (m_invMass2 * _local9));
_local7 = (_local7 + (m_invI2 * _local11));
};
_local12 = ((((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.b2Max(m_impulse.y, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.y = b2Math.b2Min(m_impulse.y, 0);
};
};
_local20 = (-(_local12) - ((m_impulse.y - _local18.y) * m_K.col2.x));
_local21 = ((_local20 / m_K.col1.x) + _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_invMass1 * _local8));
_local4.y = (_local4.y - (m_invMass1 * _local9));
_local5 = (_local5 - (m_invI1 * _local10));
_local6.x = (_local6.x + (m_invMass2 * _local8));
_local6.y = (_local6.y + (m_invMass2 * _local9));
_local7 = (_local7 + (m_invI2 * _local11));
} else {
_local22 = (-(_local12) / m_K.col1.x);
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_invMass1 * _local8));
_local4.y = (_local4.y - (m_invMass1 * _local9));
_local5 = (_local5 - (m_invI1 * _local10));
_local6.x = (_local6.x + (m_invMass2 * _local8));
_local6.y = (_local6.y + (m_invMass2 * _local9));
_local7 = (_local7 + (m_invI2 * _local11));
};
_local2.m_linearVelocity.SetV(_local4);
_local2.m_angularVelocity = _local5;
_local3.m_linearVelocity.SetV(_local6);
_local3.m_angularVelocity = _local7;
}
public function EnableMotor(_arg1:Boolean):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_enableMotor = _arg1;
}
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 _local4:b2Body;
var _local5:b2Body;
var _local6:b2Vec2;
var _local7:Number;
var _local8:b2Vec2;
var _local9:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Boolean;
var _local19:Number;
var _local20:b2Mat22;
var _local21:b2Mat22;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:b2Vec2;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
_local4 = m_body1;
_local5 = m_body2;
_local6 = _local4.m_sweep.c;
_local7 = _local4.m_sweep.a;
_local8 = _local5.m_sweep.c;
_local9 = _local5.m_sweep.a;
_local16 = 0;
_local17 = 0;
_local18 = false;
_local19 = 0;
_local20 = new b2Mat22(_local7);
_local21 = new b2Mat22(_local9);
_local10 = _local20;
_local22 = (m_localAnchor1.x - m_localCenter1.x);
_local23 = (m_localAnchor1.y - m_localCenter1.y);
_local11 = ((_local10.col1.x * _local22) + (_local10.col2.x * _local23));
_local23 = ((_local10.col1.y * _local22) + (_local10.col2.y * _local23));
_local22 = _local11;
_local10 = _local21;
_local24 = (m_localAnchor2.x - m_localCenter2.x);
_local25 = (m_localAnchor2.y - m_localCenter2.y);
_local11 = ((_local10.col1.x * _local24) + (_local10.col2.x * _local25));
_local25 = ((_local10.col1.y * _local24) + (_local10.col2.y * _local25));
_local24 = _local11;
_local26 = (((_local8.x + _local24) - _local6.x) - _local22);
_local27 = (((_local8.y + _local25) - _local6.y) - _local23);
if (m_enableLimit){
m_axis = b2Math.b2MulMV(_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.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
_local19 = b2Math.b2Clamp(_local34, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local16 = b2Math.b2Abs(_local34);
_local18 = true;
} else {
if (_local34 <= m_lowerTranslation){
_local19 = b2Math.b2Clamp(((_local34 - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local16 = (m_lowerTranslation - _local34);
_local18 = true;
} else {
if (_local34 >= m_upperTranslation){
_local19 = b2Math.b2Clamp(((_local34 - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local16 = (_local34 - m_upperTranslation);
_local18 = true;
};
};
};
};
m_perp = b2Math.b2MulMV(_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));
_local28 = new b2Vec2();
_local29 = ((m_perp.x * _local26) + (m_perp.y * _local27));
_local16 = b2Math.b2Max(_local16, b2Math.b2Abs(_local29));
_local17 = 0;
if (_local18){
_local12 = m_invMass1;
_local13 = m_invMass2;
_local14 = m_invI1;
_local15 = m_invI2;
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_invMass1;
_local13 = m_invMass2;
_local14 = m_invI1;
_local15 = m_invI2;
_local35 = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
_local36 = (-(_local29) / _local35);
_local28.x = _local36;
_local28.y = 0;
};
_local30 = ((_local28.x * m_perp.x) + (_local28.y * m_axis.x));
_local31 = ((_local28.x * m_perp.y) + (_local28.y * m_axis.y));
_local32 = ((_local28.x * m_s1) + (_local28.y * m_a1));
_local33 = ((_local28.x * m_s2) + (_local28.y * m_a2));
_local6.x = (_local6.x - (m_invMass1 * _local30));
_local6.y = (_local6.y - (m_invMass1 * _local31));
_local7 = (_local7 - (m_invI1 * _local32));
_local8.x = (_local8.x + (m_invMass2 * _local30));
_local8.y = (_local8.y + (m_invMass2 * _local31));
_local9 = (_local9 + (m_invI2 * _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 GetJointSpeed():Number{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
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:b2Vec2;
var _local16:b2Vec2;
var _local17:b2Vec2;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_xf.R;
_local4 = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
_local5 = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
_local7 = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
_local8 = (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;
_local9 = (_local1.m_sweep.c.x + _local4);
_local10 = (_local1.m_sweep.c.y + _local5);
_local11 = (_local2.m_sweep.c.x + _local7);
_local12 = (_local2.m_sweep.c.y + _local8);
_local13 = (_local11 - _local9);
_local14 = (_local12 - _local10);
_local15 = _local1.GetWorldVector(m_localXAxis1);
_local16 = _local1.m_linearVelocity;
_local17 = _local2.m_linearVelocity;
_local18 = _local1.m_angularVelocity;
_local19 = _local2.m_angularVelocity;
_local20 = (((_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);
}
public function SetMotorSpeed(_arg1:Number):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_motorSpeed = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local6:b2XForm;
var _local7:b2XForm;
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:Number;
_local2 = m_body1;
_local3 = m_body2;
m_localCenter1.SetV(_local2.GetLocalCenter());
m_localCenter2.SetV(_local3.GetLocalCenter());
_local6 = _local2.GetXForm();
_local7 = _local3.GetXForm();
_local4 = _local2.m_xf.R;
_local8 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local2.m_sweep.localCenter.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;
_local10 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
_local12 = (((_local3.m_sweep.c.x + _local10) - _local2.m_sweep.c.x) - _local8);
_local13 = (((_local3.m_sweep.c.y + _local11) - _local2.m_sweep.c.y) - _local9);
m_invMass1 = _local2.m_invMass;
m_invMass2 = _local3.m_invMass;
m_invI1 = _local2.m_invI;
m_invI2 = _local3.m_invI;
m_axis.SetV(b2Math.b2MulMV(_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_invMass1 + m_invMass2) + ((m_invI1 * m_a1) * m_a1)) + ((m_invI2 * m_a2) * m_a2));
m_motorMass = (1 / m_motorMass);
m_perp.SetV(b2Math.b2MulMV(_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));
_local14 = m_invMass1;
_local15 = m_invMass2;
_local16 = m_invI1;
_local17 = m_invI2;
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.b2Abs((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_invMass1 * _local19));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (m_invMass1 * _local20));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (m_invI1 * _local21));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (m_invMass2 * _local19));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (m_invMass2 * _local20));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (m_invI2 * _local22));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function EnableLimit(_arg1:Boolean):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_enableLimit = _arg1;
}
public function SetMaxMotorForce(_arg1:Number):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_maxMotorForce = _arg1;
}
}
}//package Box2D.Dynamics.Joints
Section 92
//b2LineJointDef (Box2D.Dynamics.Joints.b2LineJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2LineJointDef extends b2JointDef {
public var localAxis1:b2Vec2;
public var maxMotorForce:Number;
public var motorSpeed:Number;
public var upperTranslation:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var lowerTranslation:Number;
public function b2LineJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
localAxis1 = new b2Vec2();
super();
type = b2Joint.e_lineJoint;
localAxis1.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{
body1 = _arg1;
body2 = _arg2;
localAnchor1 = body1.GetLocalPoint(_arg3);
localAnchor2 = body2.GetLocalPoint(_arg3);
localAxis1 = body1.GetLocalVector(_arg4);
}
}
}//package Box2D.Dynamics.Joints
Section 93
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2MouseJoint extends b2Joint {
private var m_beta:Number;
private var m_mass:b2Mat22;
private var m_target:b2Vec2;
private var m_impulse:b2Vec2;
private var m_localAnchor:b2Vec2;
private var m_dampingRatio:Number;
private var K2:b2Mat22;
private var K:b2Mat22;
private var K1:b2Mat22;
private var m_frequencyHz:Number;
private var m_gamma:Number;
private var m_C:b2Vec2;
private var m_maxForce:Number;
public function b2MouseJoint(_arg1:b2MouseJointDef){
var _local2:Number;
var _local3: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_body2.m_xf.position.x);
_local3 = (m_target.y - m_body2.m_xf.position.y);
_local4 = m_body2.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;
}
override public function GetAnchor1():b2Vec2{
return (m_target);
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor));
}
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 InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:b2Mat22;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
_local2 = m_body2;
_local3 = _local2.GetMass();
_local4 = ((2 * Math.PI) * m_frequencyHz);
_local5 = (((2 * _local3) * m_dampingRatio) * _local4);
_local6 = ((_local3 * _local4) * _local4);
m_gamma = (1 / (_arg1.dt * (_local5 + (_arg1.dt * _local6))));
m_beta = ((_arg1.dt * _local6) * m_gamma);
_local7 = _local2.m_xf.R;
_local8 = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
_local9 = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
_local10 = ((_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 GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function SetTarget(_arg1:b2Vec2):void{
if (m_body2.IsSleeping()){
m_body2.WakeUp();
};
m_target = _arg1;
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Mat22;
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;
_local2 = m_body2;
_local3 = _local2.m_xf.R;
_local6 = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
_local7 = (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;
_local8 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local7));
_local9 = (_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));
_local10 = -(((_local3.col1.x * _local4) + (_local3.col2.x * _local5)));
_local11 = -(((_local3.col1.y * _local4) + (_local3.col2.y * _local5)));
_local12 = m_impulse.x;
_local13 = m_impulse.y;
m_impulse.x = (m_impulse.x + _local10);
m_impulse.y = (m_impulse.y + _local11);
_local14 = (_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))));
}
}
}//package Box2D.Dynamics.Joints
Section 94
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var frequencyHz:Number;
public var dampingRatio:Number;
public var maxForce:Number;
public var target:b2Vec2;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
}
}
}//package Box2D.Dynamics.Joints
Section 95
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2PrismaticJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_enableLimit:Boolean;
private var m_impulse:b2Vec3;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_s1:Number;
private var m_axis:b2Vec2;
private var m_motorImpulse:Number;
private var m_upperTranslation:Number;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_perp:b2Vec2;
private var m_refAngle:Number;
private var m_maxMotorForce:Number;
private var m_motorMass:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_enableMotor:Boolean;
private var m_motorSpeed:Number;
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.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_localXAxis1.SetV(_arg1.localAxis1);
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 public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetJointTranslation():Number{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local6:Number;
var _local7:Number;
var _local8:b2Vec2;
var _local9:Number;
_local1 = m_body1;
_local2 = m_body2;
_local4 = _local1.GetWorldPoint(m_localAnchor1);
_local5 = _local2.GetWorldPoint(m_localAnchor2);
_local6 = (_local5.x - _local4.x);
_local7 = (_local5.y - _local4.y);
_local8 = _local1.GetWorldVector(m_localXAxis1);
_local9 = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
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);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Vec2;
var _local5:Number;
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;
var _local17:Number;
var _local18:Number;
var _local19:b2Vec3;
var _local20:b2Vec3;
var _local21:Number;
var _local22:Number;
var _local23:b2Vec2;
var _local24:b2Vec2;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_linearVelocity;
_local5 = _local2.m_angularVelocity;
_local6 = _local3.m_linearVelocity;
_local7 = _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.b2Clamp((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_invMass1 * _local8));
_local4.y = (_local4.y - (m_invMass1 * _local9));
_local5 = (_local5 - (m_invI1 * _local10));
_local6.x = (_local6.x + (m_invMass2 * _local8));
_local6.y = (_local6.y + (m_invMass2 * _local9));
_local7 = (_local7 + (m_invI2 * _local11));
};
_local12 = ((((m_perp.x * (_local6.x - _local4.x)) + (m_perp.y * (_local6.y - _local4.y))) + (m_s2 * _local7)) - (m_s1 * _local5));
_local13 = (_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.b2Max(m_impulse.z, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.z = b2Math.b2Min(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_invMass1 * _local8));
_local4.y = (_local4.y - (m_invMass1 * _local9));
_local5 = (_local5 - (m_invI1 * _local10));
_local6.x = (_local6.x + (m_invMass2 * _local8));
_local6.y = (_local6.y + (m_invMass2 * _local9));
_local7 = (_local7 + (m_invI2 * _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_invMass1 * _local8));
_local4.y = (_local4.y - (m_invMass1 * _local9));
_local5 = (_local5 - (m_invI1 * _local10));
_local6.x = (_local6.x + (m_invMass2 * _local8));
_local6.y = (_local6.y + (m_invMass2 * _local9));
_local7 = (_local7 + (m_invI2 * _local11));
};
_local2.m_linearVelocity.SetV(_local4);
_local2.m_angularVelocity = _local5;
_local3.m_linearVelocity.SetV(_local6);
_local3.m_angularVelocity = _local7;
}
public function EnableMotor(_arg1:Boolean):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_enableMotor = _arg1;
}
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 _local4:b2Body;
var _local5:b2Body;
var _local6:b2Vec2;
var _local7:Number;
var _local8:b2Vec2;
var _local9:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Boolean;
var _local19:Number;
var _local20:b2Mat22;
var _local21:b2Mat22;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:b2Vec3;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:b2Vec2;
_local4 = m_body1;
_local5 = m_body2;
_local6 = _local4.m_sweep.c;
_local7 = _local4.m_sweep.a;
_local8 = _local5.m_sweep.c;
_local9 = _local5.m_sweep.a;
_local16 = 0;
_local17 = 0;
_local18 = false;
_local19 = 0;
_local20 = new b2Mat22(_local7);
_local21 = new b2Mat22(_local9);
_local10 = _local20;
_local22 = (m_localAnchor1.x - m_localCenter1.x);
_local23 = (m_localAnchor1.y - m_localCenter1.y);
_local11 = ((_local10.col1.x * _local22) + (_local10.col2.x * _local23));
_local23 = ((_local10.col1.y * _local22) + (_local10.col2.y * _local23));
_local22 = _local11;
_local10 = _local21;
_local24 = (m_localAnchor2.x - m_localCenter2.x);
_local25 = (m_localAnchor2.y - m_localCenter2.y);
_local11 = ((_local10.col1.x * _local24) + (_local10.col2.x * _local25));
_local25 = ((_local10.col1.y * _local24) + (_local10.col2.y * _local25));
_local24 = _local11;
_local26 = (((_local8.x + _local24) - _local6.x) - _local22);
_local27 = (((_local8.y + _local25) - _local6.y) - _local23);
if (m_enableLimit){
m_axis = b2Math.b2MulMV(_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.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
_local19 = b2Math.b2Clamp(_local35, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local16 = b2Math.b2Abs(_local35);
_local18 = true;
} else {
if (_local35 <= m_lowerTranslation){
_local19 = b2Math.b2Clamp(((_local35 - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local16 = (m_lowerTranslation - _local35);
_local18 = true;
} else {
if (_local35 >= m_upperTranslation){
_local19 = b2Math.b2Clamp(((_local35 - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local16 = (_local35 - m_upperTranslation);
_local18 = true;
};
};
};
};
m_perp = b2Math.b2MulMV(_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));
_local28 = new b2Vec3();
_local29 = ((m_perp.x * _local26) + (m_perp.y * _local27));
_local30 = ((_local9 - _local7) - m_refAngle);
_local16 = b2Math.b2Max(_local16, b2Math.b2Abs(_local29));
_local17 = b2Math.b2Abs(_local30);
if (_local18){
_local12 = m_invMass1;
_local13 = m_invMass2;
_local14 = m_invI1;
_local15 = m_invI2;
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_invMass1;
_local13 = m_invMass2;
_local14 = m_invI1;
_local15 = m_invI2;
_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;
};
_local31 = ((_local28.x * m_perp.x) + (_local28.z * m_axis.x));
_local32 = ((_local28.x * m_perp.y) + (_local28.z * m_axis.y));
_local33 = (((_local28.x * m_s1) + _local28.y) + (_local28.z * m_a1));
_local34 = (((_local28.x * m_s2) + _local28.y) + (_local28.z * m_a2));
_local6.x = (_local6.x - (m_invMass1 * _local31));
_local6.y = (_local6.y - (m_invMass1 * _local32));
_local7 = (_local7 - (m_invI1 * _local33));
_local8.x = (_local8.x + (m_invMass2 * _local31));
_local8.y = (_local8.y + (m_invMass2 * _local32));
_local9 = (_local9 + (m_invI2 * _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 GetJointSpeed():Number{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
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:b2Vec2;
var _local16:b2Vec2;
var _local17:b2Vec2;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_xf.R;
_local4 = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
_local5 = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
_local7 = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
_local8 = (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;
_local9 = (_local1.m_sweep.c.x + _local4);
_local10 = (_local1.m_sweep.c.y + _local5);
_local11 = (_local2.m_sweep.c.x + _local7);
_local12 = (_local2.m_sweep.c.y + _local8);
_local13 = (_local11 - _local9);
_local14 = (_local12 - _local10);
_local15 = _local1.GetWorldVector(m_localXAxis1);
_local16 = _local1.m_linearVelocity;
_local17 = _local2.m_linearVelocity;
_local18 = _local1.m_angularVelocity;
_local19 = _local2.m_angularVelocity;
_local20 = (((_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);
}
public function SetMotorSpeed(_arg1:Number):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_motorSpeed = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local6:b2XForm;
var _local7:b2XForm;
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:Number;
_local2 = m_body1;
_local3 = m_body2;
m_localCenter1.SetV(_local2.GetLocalCenter());
m_localCenter2.SetV(_local3.GetLocalCenter());
_local6 = _local2.GetXForm();
_local7 = _local3.GetXForm();
_local4 = _local2.m_xf.R;
_local8 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local2.m_sweep.localCenter.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;
_local10 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
_local12 = (((_local3.m_sweep.c.x + _local10) - _local2.m_sweep.c.x) - _local8);
_local13 = (((_local3.m_sweep.c.y + _local11) - _local2.m_sweep.c.y) - _local9);
m_invMass1 = _local2.m_invMass;
m_invMass2 = _local3.m_invMass;
m_invI1 = _local2.m_invI;
m_invI2 = _local3.m_invI;
m_axis.SetV(b2Math.b2MulMV(_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_invMass1 + m_invMass2) + ((m_invI1 * m_a1) * m_a1)) + ((m_invI2 * m_a2) * m_a2));
m_motorMass = (1 / m_motorMass);
m_perp.SetV(b2Math.b2MulMV(_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));
_local14 = m_invMass1;
_local15 = m_invMass2;
_local16 = m_invI1;
_local17 = m_invI2;
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.b2Abs((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_invMass1 * _local19));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (m_invMass1 * _local20));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (m_invI1 * _local21));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (m_invMass2 * _local19));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (m_invMass2 * _local20));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (m_invI2 * _local22));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function EnableLimit(_arg1:Boolean):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_enableLimit = _arg1;
}
public function SetMaxMotorForce(_arg1:Number):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_maxMotorForce = _arg1;
}
}
}//package Box2D.Dynamics.Joints
Section 96
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PrismaticJointDef extends b2JointDef {
public var localAxis1:b2Vec2;
public var referenceAngle:Number;
public var maxMotorForce:Number;
public var motorSpeed:Number;
public var upperTranslation:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var lowerTranslation:Number;
public function b2PrismaticJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
localAxis1 = new b2Vec2();
super();
type = b2Joint.e_prismaticJoint;
localAxis1.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{
body1 = _arg1;
body2 = _arg2;
localAnchor1 = body1.GetLocalPoint(_arg3);
localAnchor2 = body2.GetLocalPoint(_arg3);
localAxis1 = body1.GetLocalVector(_arg4);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 97
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2PulleyJoint extends b2Joint {
private var m_ground:b2Body;
private var m_maxLength2:Number;
private var m_maxLength1:Number;
private var m_limitState1:int;
private var m_limitState2:int;
private var m_pulleyMass:Number;
private var m_constant:Number;
private var m_impulse:Number;
private var m_state:int;
private var m_ratio:Number;
private var m_groundAnchor2:b2Vec2;
private var m_groundAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_localAnchor1:b2Vec2;
private var m_limitMass2:Number;
private var m_limitMass1:Number;
private var m_limitImpulse2:Number;
private var m_u1:b2Vec2;
private var m_u2:b2Vec2;
private var m_limitImpulse1:Number;
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_body1.m_world.m_groundBody;
m_groundAnchor1.x = (_arg1.groundAnchor1.x - m_ground.m_xf.position.x);
m_groundAnchor1.y = (_arg1.groundAnchor1.y - m_ground.m_xf.position.y);
m_groundAnchor2.x = (_arg1.groundAnchor2.x - m_ground.m_xf.position.x);
m_groundAnchor2.y = (_arg1.groundAnchor2.y - m_ground.m_xf.position.y);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_ratio = _arg1.ratio;
m_constant = (_arg1.length1 + (m_ratio * _arg1.length2));
m_maxLength1 = b2Math.b2Min(_arg1.maxLength1, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.b2Min(_arg1.maxLength2, ((m_constant - b2_minPulleyLength) / m_ratio));
m_impulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
}
public function GetGroundAnchor2():b2Vec2{
var _local1:b2Vec2;
_local1 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor2);
return (_local1);
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetRatio():Number{
return (m_ratio);
}
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 _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
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:Number;
var _local23:Number;
var _local24:Number;
_local2 = m_body1;
_local3 = m_body2;
_local5 = (m_ground.m_xf.position.x + m_groundAnchor1.x);
_local6 = (m_ground.m_xf.position.y + m_groundAnchor1.y);
_local7 = (m_ground.m_xf.position.x + m_groundAnchor2.x);
_local8 = (m_ground.m_xf.position.y + m_groundAnchor2.y);
_local24 = 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.b2Max(_local24, -(_local19));
_local19 = b2Math.b2Clamp((_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.b2Max(_local24, -(_local19));
_local19 = b2Math.b2Clamp((_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.b2Max(_local24, -(_local19));
_local19 = b2Math.b2Clamp((_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 _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:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_xf.R;
_local5 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local6 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
_local8 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local9 = (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;
_local10 = (_local2.m_sweep.c.x + _local5);
_local11 = (_local2.m_sweep.c.y + _local6);
_local12 = (_local3.m_sweep.c.x + _local8);
_local13 = (_local3.m_sweep.c.y + _local9);
_local14 = (m_ground.m_xf.position.x + m_groundAnchor1.x);
_local15 = (m_ground.m_xf.position.y + m_groundAnchor1.y);
_local16 = (m_ground.m_xf.position.x + m_groundAnchor2.x);
_local17 = (m_ground.m_xf.position.y + m_groundAnchor2.y);
m_u1.Set((_local10 - _local14), (_local11 - _local15));
m_u2.Set((_local12 - _local16), (_local13 - _local17));
_local18 = m_u1.Length();
_local19 = 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();
};
_local20 = ((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;
};
_local21 = ((_local5 * m_u1.y) - (_local6 * m_u1.x));
_local22 = ((_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 GetLength1():Number{
var _local1:b2Vec2;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = m_body1.GetWorldPoint(m_localAnchor1);
_local2 = (m_ground.m_xf.position.x + m_groundAnchor1.x);
_local3 = (m_ground.m_xf.position.y + m_groundAnchor1.y);
_local4 = (_local1.x - _local2);
_local5 = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
public function GetLength2():Number{
var _local1:b2Vec2;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = m_body2.GetWorldPoint(m_localAnchor2);
_local2 = (m_ground.m_xf.position.x + m_groundAnchor2.x);
_local3 = (m_ground.m_xf.position.y + m_groundAnchor2.y);
_local4 = (_local1.x - _local2);
_local5 = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
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;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_xf.R;
_local5 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local6 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
_local8 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local9 = (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.b2Max(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.b2Max(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.b2Max(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 GetGroundAnchor1():b2Vec2{
var _local1:b2Vec2;
_local1 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor1);
return (_local1);
}
}
}//package Box2D.Dynamics.Joints
Section 98
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PulleyJointDef extends b2JointDef {
public var maxLength2:Number;
public var length1:Number;
public var length2:Number;
public var maxLength1:Number;
public var ratio:Number;
public var groundAnchor1:b2Vec2;
public var groundAnchor2:b2Vec2;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public function b2PulleyJointDef(){
groundAnchor1 = new b2Vec2();
groundAnchor2 = new b2Vec2();
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundAnchor1.Set(-1, 1);
groundAnchor2.Set(1, 1);
localAnchor1.Set(-1, 0);
localAnchor2.Set(1, 0);
length1 = 0;
maxLength1 = 0;
length2 = 0;
maxLength2 = 0;
ratio = 1;
collideConnected = true;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2, _arg6:b2Vec2, _arg7:Number):void{
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
body1 = _arg1;
body2 = _arg2;
groundAnchor1.SetV(_arg3);
groundAnchor2.SetV(_arg4);
localAnchor1 = body1.GetLocalPoint(_arg5);
localAnchor2 = body2.GetLocalPoint(_arg6);
_local8 = (_arg5.x - _arg3.x);
_local9 = (_arg5.y - _arg3.y);
length1 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
_local10 = (_arg6.x - _arg4.x);
_local11 = (_arg6.y - _arg4.y);
length2 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
ratio = _arg7;
_local12 = (length1 + (ratio * length2));
maxLength1 = (_local12 - (ratio * b2PulleyJoint.b2_minPulleyLength));
maxLength2 = ((_local12 - b2PulleyJoint.b2_minPulleyLength) / ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 99
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.*;
public class b2RevoluteJoint extends b2Joint {
private var m_referenceAngle:Number;
private var m_enableLimit:Boolean;
private var m_impulse:b2Vec3;
private var m_limitState:int;
private var m_motorMass:Number;
b2internal var m_localAnchor2:b2Vec2;
private var K2:b2Mat22;
b2internal var m_localAnchor1:b2Vec2;
private var K1:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
private var m_motorImpulse:Number;
private var m_mass:b2Mat33;
private var m_enableMotor:Boolean;
private var m_upperAngle:Number;
private var m_motorSpeed:Number;
private var m_maxMotorTorque:Number;
private var m_lowerAngle: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();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_impulse = new b2Vec3();
m_mass = new b2Mat33();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
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 public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetUpperLimit():Number{
return (m_upperAngle);
}
public function GetLowerLimit():Number{
return (m_lowerAngle);
}
public function EnableMotor(_arg1:Boolean):void{
m_enableMotor = _arg1;
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_lowerAngle = _arg1;
m_upperAngle = _arg2;
}
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 _local5:b2Body;
var _local6:b2Body;
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:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
_local5 = m_body1;
_local6 = m_body2;
_local7 = 0;
_local8 = 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.b2Clamp((_local25 - m_lowerAngle), -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local3);
_local7 = b2Math.b2Abs(_local3);
} else {
if (m_limitState == e_atLowerLimit){
_local3 = (_local25 - m_lowerAngle);
_local7 = -(_local3);
_local3 = b2Math.b2Clamp((_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.b2Clamp((_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;
_local12 = (m_localAnchor1.x - _local5.m_sweep.localCenter.x);
_local13 = (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;
_local14 = (m_localAnchor2.x - _local6.m_sweep.localCenter.x);
_local15 = (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;
_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);
_local18 = ((_local16 * _local16) + (_local17 * _local17));
_local19 = Math.sqrt(_local18);
_local8 = _local19;
_local20 = _local5.m_invMass;
_local21 = _local6.m_invMass;
_local22 = _local5.m_invI;
_local23 = _local6.m_invI;
_local24 = (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 GetJointSpeed():Number{
return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity));
}
public function SetMotorSpeed(_arg1:Number):void{
m_body1.WakeUp();
m_body2.WakeUp();
m_motorSpeed = _arg1;
}
public function EnableLimit(_arg1:Boolean):void{
m_enableLimit = _arg1;
}
public function SetMaxMotorTorque(_arg1:Number):void{
m_maxMotorTorque = _arg1;
}
public function GetJointAngle():Number{
return (((m_body2.m_sweep.a - m_body1.m_sweep.a) - m_referenceAngle));
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
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;
_local2 = m_body1;
_local3 = m_body2;
if (((m_enableMotor) || (m_enableLimit))){
};
_local4 = _local2.m_xf.R;
_local6 = (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;
_local8 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local9 = (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;
_local10 = _local2.m_invMass;
_local11 = _local3.m_invMass;
_local12 = _local2.m_invI;
_local13 = _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.b2Abs((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 GetMotorTorque():Number{
return (m_maxMotorTorque);
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.z));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
m_body1.WakeUp();
m_body2.WakeUp();
return (m_enableMotor);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local13:Number;
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 _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:b2Vec3;
var _local28:Number;
var _local29:Number;
var _local30:b2Vec2;
_local2 = m_body1;
_local3 = m_body2;
_local12 = _local2.m_linearVelocity;
_local13 = _local2.m_angularVelocity;
_local14 = _local3.m_linearVelocity;
_local15 = _local3.m_angularVelocity;
_local16 = _local2.m_invMass;
_local17 = _local3.m_invMass;
_local18 = _local2.m_invI;
_local19 = _local3.m_invI;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local20 = ((_local15 - _local13) - m_motorSpeed);
_local21 = (m_motorMass * -(_local20));
_local22 = m_motorImpulse;
_local23 = (_arg1.dt * m_maxMotorTorque);
m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + _local21), -(_local23), _local23);
_local21 = (m_motorImpulse - _local22);
_local13 = (_local13 - (_local18 * _local21));
_local15 = (_local15 + (_local19 * _local21));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local4 = _local2.m_xf.R;
_local8 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local2.m_sweep.localCenter.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;
_local10 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
_local24 = (((_local14.x + (-(_local15) * _local11)) - _local12.x) - (-(_local13) * _local9));
_local25 = (((_local14.y + (_local15 * _local10)) - _local12.y) - (_local13 * _local8));
_local26 = (_local15 - _local13);
_local27 = m_mass.Solve33(new b2Vec3(), -(_local24), -(_local25), -(_local26));
if (m_limitState == e_equalLimits){
m_impulse.Add(_local27);
} else {
if (m_limitState == e_atLowerLimit){
_local6 = (m_impulse.z + _local27.z);
if (_local6 < 0){
_local7 = m_mass.Solve22(new b2Vec2(), -(_local24), -(_local25));
_local27.x = _local7.x;
_local27.y = _local7.y;
_local27.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + _local7.x);
m_impulse.y = (m_impulse.y + _local7.y);
m_impulse.z = 0;
};
} else {
if (m_limitState == e_atUpperLimit){
_local6 = (m_impulse.z + _local27.z);
if (_local6 > 0){
_local7 = m_mass.Solve22(new b2Vec2(), -(_local24), -(_local25));
_local27.x = _local7.x;
_local27.y = _local7.y;
_local27.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + _local7.x);
m_impulse.y = (m_impulse.y + _local7.y);
m_impulse.z = 0;
};
};
};
};
_local12.x = (_local12.x - (_local16 * _local27.x));
_local12.y = (_local12.y - (_local16 * _local27.y));
_local13 = (_local13 - (_local18 * (((_local8 * _local27.y) - (_local9 * _local27.x)) + _local27.z)));
_local14.x = (_local14.x + (_local17 * _local27.x));
_local14.y = (_local14.y + (_local17 * _local27.y));
_local15 = (_local15 + (_local19 * (((_local10 * _local27.y) - (_local11 * _local27.x)) + _local27.z)));
} else {
_local4 = _local2.m_xf.R;
_local8 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local2.m_sweep.localCenter.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;
_local10 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
_local28 = (((_local14.x + (-(_local15) * _local11)) - _local12.x) - (-(_local13) * _local9));
_local29 = (((_local14.y + (_local15 * _local10)) - _local12.y) - (_local13 * _local8));
_local30 = m_mass.Solve22(new b2Vec2(), -(_local28), -(_local29));
m_impulse.x = (m_impulse.x + _local30.x);
m_impulse.y = (m_impulse.y + _local30.y);
_local12.x = (_local12.x - (_local16 * _local30.x));
_local12.y = (_local12.y - (_local16 * _local30.y));
_local13 = (_local13 - (_local18 * ((_local8 * _local30.y) - (_local9 * _local30.x))));
_local14.x = (_local14.x + (_local17 * _local30.x));
_local14.y = (_local14.y + (_local17 * _local30.y));
_local15 = (_local15 + (_local19 * ((_local10 * _local30.y) - (_local11 * _local30.x))));
};
_local2.m_linearVelocity.SetV(_local12);
_local2.m_angularVelocity = _local13;
_local3.m_linearVelocity.SetV(_local14);
_local3.m_angularVelocity = _local15;
}
}
}//package Box2D.Dynamics.Joints
Section 100
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2RevoluteJointDef extends b2JointDef {
public var referenceAngle:Number;
public var upperAngle:Number;
public var lowerAngle:Number;
public var motorSpeed:Number;
public var maxMotorTorque:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public function b2RevoluteJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_revoluteJoint;
localAnchor1.Set(0, 0);
localAnchor2.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{
body1 = _arg1;
body2 = _arg2;
localAnchor1 = body1.GetLocalPoint(_arg3);
localAnchor2 = body2.GetLocalPoint(_arg3);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 101
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Dynamics.Contacts.*;
public class b2Body {
b2internal var m_controllerCount:int;
b2internal var m_contactList:b2ContactEdge;
b2internal var m_angularVelocity:Number;
b2internal var m_invI:Number;
b2internal var m_shapeCount:int;
b2internal var m_torque:Number;
b2internal var m_flags:uint;
b2internal var m_linearVelocity:b2Vec2;
b2internal var m_world:b2World;
b2internal var m_xf:b2XForm;
b2internal var m_controllerList:b2ControllerEdge;
b2internal var m_next:b2Body;
b2internal var m_mass:Number;
b2internal var m_shapeList:b2Shape;
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;
private var m_type:int;
b2internal var m_angularDamping:Number;
b2internal var m_islandIndex:int;
b2internal var m_sleepTime:Number;
b2internal var m_jointList:b2JointEdge;
b2internal var m_I:Number;
b2internal static var e_fixedRotationFlag:uint = 64;
b2internal static var e_frozenFlag:uint = 2;
b2internal static var e_maxTypes:uint = 3;
b2internal static var e_sleepFlag:uint = 8;
private static var s_massData:b2MassData = new b2MassData();
b2internal static var e_bulletFlag:uint = 32;
b2internal static var e_staticType:uint = 1;
b2internal static var e_islandFlag:uint = 4;
b2internal static var e_allowSleepFlag:uint = 16;
private static var s_xf1:b2XForm = new b2XForm();
b2internal static var e_dynamicType:uint = 2;
public function b2Body(_arg1:b2BodyDef, _arg2:b2World){
var _local3:b2Mat22;
var _local4:b2Vec2;
m_xf = new b2XForm();
m_sweep = new b2Sweep();
m_linearVelocity = new b2Vec2();
m_force = new b2Vec2();
super();
m_flags = 0;
if (_arg1.isBullet){
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.isSleeping){
m_flags = (m_flags | e_sleepFlag);
};
m_world = _arg2;
m_xf.position.SetV(_arg1.position);
m_xf.R.Set(_arg1.angle);
m_sweep.localCenter.SetV(_arg1.massData.center);
m_sweep.t0 = 1;
m_sweep.a0 = (m_sweep.a = _arg1.angle);
_local3 = m_xf.R;
_local4 = 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_linearDamping = _arg1.linearDamping;
m_angularDamping = _arg1.angularDamping;
m_force.Set(0, 0);
m_torque = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_sleepTime = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.massData.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
if ((m_flags & b2Body.e_fixedRotationFlag) == 0){
m_I = _arg1.massData.I;
};
if (m_I > 0){
m_invI = (1 / m_I);
};
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
m_userData = _arg1.userData;
m_shapeList = null;
m_shapeCount = 0;
}
public function SetLinearVelocity(_arg1:b2Vec2):void{
m_linearVelocity.SetV(_arg1);
}
public function GetMassData():b2MassData{
var _local1:b2MassData;
_local1 = new b2MassData();
_local1.mass = m_mass;
_local1.I = m_I;
_local1.center = GetWorldCenter();
return (_local1);
}
public function IsSleeping():Boolean{
return (((m_flags & e_sleepFlag) == e_sleepFlag));
}
b2internal function SynchronizeTransform():void{
var _local1:b2Mat22;
var _local2:b2Vec2;
m_xf.R.Set(m_sweep.a);
_local1 = m_xf.R;
_local2 = 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 SetLinearDamping(_arg1:Number):void{
m_linearDamping = _arg1;
}
public function PutToSleep():void{
m_flags = (m_flags | e_sleepFlag);
m_sleepTime = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_force.SetZero();
m_torque = 0;
}
public function GetControllerList():b2ControllerEdge{
return (m_controllerList);
}
public function SetMassFromShapes():void{
var _local1:b2Shape;
var _local2:Number;
var _local3:Number;
var _local4:b2MassData;
var _local5:b2Mat22;
var _local6:b2Vec2;
var _local7:int;
if (m_world.m_lock == true){
return;
};
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
_local2 = 0;
_local3 = 0;
_local4 = s_massData;
_local1 = m_shapeList;
while (_local1) {
_local1.ComputeMass(_local4);
m_mass = (m_mass + _local4.mass);
_local2 = (_local2 + (_local4.mass * _local4.center.x));
_local3 = (_local3 + (_local4.mass * _local4.center.y));
m_I = (m_I + _local4.I);
_local1 = _local1.m_next;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
_local2 = (_local2 * m_invMass);
_local3 = (_local3 * m_invMass);
};
if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (m_I - (m_mass * ((_local2 * _local2) + (_local3 * _local3))));
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
m_sweep.localCenter.Set(_local2, _local3);
_local5 = m_xf.R;
_local6 = m_sweep.localCenter;
m_sweep.c.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y));
m_sweep.c.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.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);
_local1 = m_shapeList;
while (_local1) {
_local1.UpdateSweepRadius(m_sweep.localCenter);
_local1 = _local1.m_next;
};
_local7 = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (_local7 != m_type){
_local1 = m_shapeList;
while (_local1) {
_local1.RefilterProxy(m_world.m_broadPhase, m_xf);
_local1 = _local1.m_next;
};
};
}
public function SetXForm(_arg1:b2XForm):Boolean{
return (SetPositionAndAngle(_arg1.position, _arg1.GetAngle()));
}
public function SetAngularVelocity(_arg1:Number):void{
m_angularVelocity = _arg1;
}
b2internal function SynchronizeShapes():Boolean{
var _local1:b2XForm;
var _local2:b2Mat22;
var _local3:b2Vec2;
var _local4:b2Shape;
var _local5:Boolean;
_local1 = s_xf1;
_local1.R.Set(m_sweep.a0);
_local2 = _local1.R;
_local3 = 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)));
_local5 = true;
_local4 = m_shapeList;
while (_local4) {
_local5 = _local4.Synchronize(m_world.m_broadPhase, _local1, m_xf);
if (_local5 == false){
break;
};
_local4 = _local4.m_next;
};
if (_local5 == false){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
_local4 = m_shapeList;
while (_local4) {
_local4.DestroyProxy(m_world.m_broadPhase);
_local4 = _local4.m_next;
};
return (false);
};
return (true);
}
public function GetAngle():Number{
return (m_sweep.a);
}
public function GetLinearVelocityFromLocalPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22;
var _local3:b2Vec2;
_local2 = m_xf.R;
_local3 = 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 GetShapeList():b2Shape{
return (m_shapeList);
}
public function GetMass():Number{
return (m_mass);
}
public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
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 SetStatic():void{
var _local1:b2Shape;
if (m_type == e_staticType){
return;
};
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_type = e_staticType;
_local1 = m_shapeList;
while (_local1) {
_local1.RefilterProxy(m_world.m_broadPhase, m_xf);
_local1 = _local1.m_next;
};
}
public function SetMass(_arg1:b2MassData):void{
var _local2:b2Shape;
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:int;
if (m_world.m_lock == true){
return;
};
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
m_I = _arg1.I;
if ((((m_I > 0)) && (((m_flags & b2Body.e_fixedRotationFlag) == 0)))){
m_invI = (1 / m_I);
};
m_sweep.localCenter.SetV(_arg1.center);
_local3 = m_xf.R;
_local4 = 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);
_local2 = m_shapeList;
while (_local2) {
_local2.UpdateSweepRadius(m_sweep.localCenter);
_local2 = _local2.m_next;
};
_local5 = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (_local5 != m_type){
_local2 = m_shapeList;
while (_local2) {
_local2.RefilterProxy(m_world.m_broadPhase, m_xf);
_local2 = _local2.m_next;
};
};
}
public function IsStatic():Boolean{
return ((m_type == e_staticType));
}
public function GetWorldVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulMV(m_xf.R, _arg1));
}
public function GetNext():b2Body{
return (m_next);
}
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 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.b2MulTMV(m_xf.R, _arg1));
}
public function WakeUp():void{
m_flags = (m_flags & ~(e_sleepFlag));
m_sleepTime = 0;
}
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 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;
var _local5:Number;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:Boolean;
_local4 = Math.atan2(_arg2.GetDirectionVector().y, _arg2.GetDirectionVector().x);
_local5 = Math.tan(((_local4 - _arg3) * 0.5));
_local6 = b2Math.MulFV(_local5, _arg2.GetDirectionVector());
_local6 = b2Math.SubtractVV(_local6, _arg2.GetNormalVector());
_local6 = b2Math.MulFV(b2Settings.b2_toiSlop, _local6);
_local6 = b2Math.AddVV(_local6, _arg2.GetVertex1());
_local7 = b2Math.AddVV(_arg1.GetDirectionVector(), _arg2.GetDirectionVector());
_local7.Normalize();
_local8 = (b2Math.b2Dot(_arg1.GetDirectionVector(), _arg2.GetNormalVector()) > 0);
_arg1.SetNextEdge(_arg2, _local6, _local7, _local8);
_arg2.SetPrevEdge(_arg1, _local6, _local7, _local8);
return (_local4);
}
public function GetPosition():b2Vec2{
return (m_xf.position);
}
public function IsFrozen():Boolean{
return (((m_flags & e_frozenFlag) == e_frozenFlag));
}
public function IsDynamic():Boolean{
return ((m_type == e_dynamicType));
}
public function GetAngularDamping():Number{
return (m_angularDamping);
}
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.b2MulXT(m_xf, _arg1));
}
public function GetXForm():b2XForm{
return (m_xf);
}
public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
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 GetAngularVelocity():Number{
return (m_angularVelocity);
}
b2internal function IsConnected(_arg1:b2Body):Boolean{
var _local2:b2JointEdge;
_local2 = m_jointList;
while (_local2) {
if (_local2.other == _arg1){
return ((_local2.joint.m_collideConnected == false));
};
_local2 = _local2.next;
};
return (false);
}
public function SetBullet(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_bulletFlag);
} else {
m_flags = (m_flags & ~(e_bulletFlag));
};
}
public function CreateShape(_arg1:b2ShapeDef):b2Shape{
var _local2:b2Shape;
var _local3:b2EdgeChainDef;
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local6:int;
var _local7:b2EdgeShape;
var _local8:b2EdgeShape;
var _local9:b2EdgeShape;
var _local10:Number;
if (m_world.m_lock == true){
return (null);
};
if (_arg1.type == b2Shape.e_edgeShape){
_local3 = (_arg1 as b2EdgeChainDef);
if (_local3.isALoop){
_local4 = _local3.vertices[(_local3.vertexCount - 1)];
_local6 = 0;
} else {
_local4 = _local3.vertices[0];
_local6 = 1;
};
_local7 = null;
_local8 = null;
_local9 = null;
_local10 = 0;
while (_local6 < _local3.vertexCount) {
_local5 = _local3.vertices[_local6];
_local9 = new b2EdgeShape(_local4, _local5, _arg1);
_local9.m_next = m_shapeList;
m_shapeList = _local9;
m_shapeCount++;
_local9.m_body = this;
_local9.CreateProxy(m_world.m_broadPhase, m_xf);
_local9.UpdateSweepRadius(m_sweep.localCenter);
if (_local8 == null){
_local7 = _local9;
_local10 = Math.atan2(_local9.GetDirectionVector().y, _local9.GetDirectionVector().x);
} else {
_local10 = connectEdges(_local8, _local9, _local10);
};
_local8 = _local9;
_local4 = _local5;
_local6++;
};
if (_local3.isALoop){
connectEdges(_local8, _local7, _local10);
};
return (_local7);
};
_local2 = b2Shape.Create(_arg1, m_world.m_blockAllocator);
_local2.m_next = m_shapeList;
m_shapeList = _local2;
m_shapeCount++;
_local2.m_body = this;
_local2.CreateProxy(m_world.m_broadPhase, m_xf);
_local2.UpdateSweepRadius(m_sweep.localCenter);
return (_local2);
}
public function DestroyShape(_arg1:b2Shape):void{
var _local2:b2Shape;
var _local3:b2Shape;
var _local4:Boolean;
if (m_world.m_lock == true){
return;
};
_arg1.DestroyProxy(m_world.m_broadPhase);
_local2 = m_shapeList;
_local3 = null;
_local4 = false;
while (_local2 != null) {
if (_local2 == _arg1){
if (_local3){
_local3.m_next = _arg1.m_next;
} else {
m_shapeList = _arg1.m_next;
};
_local4 = true;
break;
};
_local3 = _local2;
_local2 = _local2.m_next;
};
_arg1.m_body = null;
_arg1.m_next = null;
m_shapeCount--;
b2Shape.Destroy(_arg1, m_world.m_blockAllocator);
}
public function IsFixedRotation():Boolean{
return (((m_flags & e_fixedRotationFlag) == e_fixedRotationFlag));
}
public function IsAllowSleeping():Boolean{
return (((m_flags & e_allowSleepFlag) == e_allowSleepFlag));
}
public function SetPositionAndAngle(_arg1:b2Vec2, _arg2:Number):Boolean{
var _local3:b2Shape;
var _local4:b2Mat22;
var _local5:b2Vec2;
var _local6:Boolean;
var _local7:Boolean;
if (m_world.m_lock == true){
return (true);
};
if (IsFrozen()){
return (false);
};
m_xf.R.Set(_arg2);
m_xf.position.SetV(_arg1);
_local4 = m_xf.R;
_local5 = 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);
_local6 = false;
_local3 = m_shapeList;
while (_local3) {
_local7 = _local3.Synchronize(m_world.m_broadPhase, m_xf, m_xf);
if (_local7 == false){
_local6 = true;
break;
};
_local3 = _local3.m_next;
};
if (_local6 == true){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
_local3 = m_shapeList;
while (_local3) {
_local3.DestroyProxy(m_world.m_broadPhase);
_local3 = _local3.m_next;
};
return (false);
};
m_world.m_broadPhase.Commit();
return (true);
}
public function SetFixedRotation(_arg1:Boolean):void{
if (_arg1){
m_angularVelocity = 0;
m_invI = 0;
m_flags = (m_flags | e_fixedRotationFlag);
} else {
if (m_I > 0){
m_invI = (1 / m_I);
m_flags = (m_flags & e_fixedRotationFlag);
};
};
}
public function IsBullet():Boolean{
return (((m_flags & e_bulletFlag) == e_bulletFlag));
}
public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22;
var _local3:b2Vec2;
_local2 = m_xf.R;
_local3 = 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 GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function AllowSleeping(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
WakeUp();
};
}
public function GetWorld():b2World{
return (m_world);
}
public function ApplyTorque(_arg1:Number):void{
if (IsSleeping()){
WakeUp();
};
m_torque = (m_torque + _arg1);
}
}
}//package Box2D.Dynamics
Section 102
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
public class b2BodyDef {
public var massData:b2MassData;
public var isBullet:Boolean;
public var allowSleep:Boolean;
public var angle:Number;
public var userData;
public var angularDamping:Number;
public var fixedRotation:Boolean;
public var linearDamping:Number;
public var angularVelocity:Number;
public var linearVelocity:b2Vec2;
public var position:b2Vec2;
public var isSleeping:Boolean;
public function b2BodyDef(){
massData = new b2MassData();
position = new b2Vec2();
linearVelocity = new b2Vec2();
super();
massData.center.SetZero();
massData.mass = 0;
massData.I = 0;
userData = null;
position.Set(0, 0);
angle = 0;
linearVelocity.Set(0, 0);
angularVelocity = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
isSleeping = false;
fixedRotation = false;
isBullet = false;
}
}
}//package Box2D.Dynamics
Section 103
//b2BoundaryListener (Box2D.Dynamics.b2BoundaryListener)
package Box2D.Dynamics {
public class b2BoundaryListener {
public function Violation(_arg1:b2Body):void{
}
}
}//package Box2D.Dynamics
Section 104
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter)
package Box2D.Dynamics {
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
public class b2ContactFilter {
b2internal static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter);
;
public function RayCollide(_arg1, _arg2:b2Shape):Boolean{
if (!_arg1){
return (true);
};
return (ShouldCollide((_arg1 as b2Shape), _arg2));
}
public function ShouldCollide(_arg1:b2Shape, _arg2:b2Shape):Boolean{
var _local3:b2FilterData;
var _local4:b2FilterData;
var _local5:Boolean;
_local3 = _arg1.GetFilterData();
_local4 = _arg2.GetFilterData();
if ((((_local3.groupIndex == _local4.groupIndex)) && (!((_local3.groupIndex == 0))))){
return ((_local3.groupIndex > 0));
};
_local5 = ((!(((_local3.maskBits & _local4.categoryBits) == 0))) && (!(((_local3.categoryBits & _local4.maskBits) == 0))));
return (_local5);
}
}
}//package Box2D.Dynamics
Section 105
//b2ContactListener (Box2D.Dynamics.b2ContactListener)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactListener {
public function Add(_arg1:b2ContactPoint):void{
}
public function Remove(_arg1:b2ContactPoint):void{
}
public function Persist(_arg1:b2ContactPoint):void{
}
public function Result(_arg1:b2ContactResult):void{
}
}
}//package Box2D.Dynamics
Section 106
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactManager extends b2PairCallback {
b2internal var m_world:b2World;
private var m_destroyImmediate:Boolean;
private var m_nullContact:b2NullContact;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2ContactManager(){
m_nullContact = new b2NullContact();
super();
m_world = null;
m_destroyImmediate = false;
}
override public function PairAdded(_arg1, _arg2){
var _local3:b2Shape;
var _local4:b2Shape;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2Contact;
_local3 = (_arg1 as b2Shape);
_local4 = (_arg2 as b2Shape);
_local5 = _local3.m_body;
_local6 = _local4.m_body;
if (((_local5.IsStatic()) && (_local6.IsStatic()))){
return (m_nullContact);
};
if (_local3.m_body == _local4.m_body){
return (m_nullContact);
};
if (_local6.IsConnected(_local5)){
return (m_nullContact);
};
if (((!((m_world.m_contactFilter == null))) && ((m_world.m_contactFilter.ShouldCollide(_local3, _local4) == false)))){
return (m_nullContact);
};
_local7 = b2Contact.Create(_local3, _local4, m_world.m_blockAllocator);
if (_local7 == null){
return (m_nullContact);
};
_local3 = _local7.m_shape1;
_local4 = _local7.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local7.m_prev = null;
_local7.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = _local7;
};
m_world.m_contactList = _local7;
_local7.m_node1.contact = _local7;
_local7.m_node1.other = _local6;
_local7.m_node1.prev = null;
_local7.m_node1.next = _local5.m_contactList;
if (_local5.m_contactList != null){
_local5.m_contactList.prev = _local7.m_node1;
};
_local5.m_contactList = _local7.m_node1;
_local7.m_node2.contact = _local7;
_local7.m_node2.other = _local5;
_local7.m_node2.prev = null;
_local7.m_node2.next = _local6.m_contactList;
if (_local6.m_contactList != null){
_local6.m_contactList.prev = _local7.m_node2;
};
_local6.m_contactList = _local7.m_node2;
m_world.m_contactCount++;
return (_local7);
}
override public function PairRemoved(_arg1, _arg2, _arg3):void{
var _local4:b2Contact;
if (_arg3 == null){
return;
};
_local4 = (_arg3 as b2Contact);
if (_local4 == m_nullContact){
return;
};
Destroy(_local4);
}
public function Destroy(_arg1:b2Contact):void{
var _local2:b2Shape;
var _local3:b2Shape;
var _local4:b2Body;
var _local5:b2Body;
var _local6:b2ContactPoint;
var _local7:int;
var _local8:Array;
var _local9:int;
var _local10:b2Manifold;
var _local11:int;
var _local12:b2ManifoldPoint;
var _local13:b2Vec2;
var _local14:b2Vec2;
_local2 = _arg1.m_shape1;
_local3 = _arg1.m_shape2;
_local4 = _local2.m_body;
_local5 = _local3.m_body;
_local6 = s_evalCP;
_local6.shape1 = _arg1.m_shape1;
_local6.shape2 = _arg1.m_shape2;
_local6.friction = b2Settings.b2MixFriction(_local2.GetFriction(), _local3.GetFriction());
_local6.restitution = b2Settings.b2MixRestitution(_local2.GetRestitution(), _local3.GetRestitution());
_local7 = _arg1.m_manifoldCount;
if ((((_local7 > 0)) && (m_world.m_contactListener))){
_local8 = _arg1.GetManifolds();
_local9 = 0;
while (_local9 < _local7) {
_local10 = _local8[_local9];
_local6.normal.SetV(_local10.normal);
_local11 = 0;
while (_local11 < _local10.pointCount) {
_local12 = _local10.points[_local11];
_local6.position = _local4.GetWorldPoint(_local12.localPoint1);
_local13 = _local4.GetLinearVelocityFromLocalPoint(_local12.localPoint1);
_local14 = _local5.GetLinearVelocityFromLocalPoint(_local12.localPoint2);
_local6.velocity.Set((_local14.x - _local13.x), (_local14.y - _local13.y));
_local6.separation = _local12.separation;
_local6.id.key = _local12.id._key;
m_world.m_contactListener.Remove(_local6);
_local11++;
};
_local9++;
};
};
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_node1.prev){
_arg1.m_node1.prev.next = _arg1.m_node1.next;
};
if (_arg1.m_node1.next){
_arg1.m_node1.next.prev = _arg1.m_node1.prev;
};
if (_arg1.m_node1 == _local4.m_contactList){
_local4.m_contactList = _arg1.m_node1.next;
};
if (_arg1.m_node2.prev){
_arg1.m_node2.prev.next = _arg1.m_node2.next;
};
if (_arg1.m_node2.next){
_arg1.m_node2.next.prev = _arg1.m_node2.prev;
};
if (_arg1.m_node2 == _local5.m_contactList){
_local5.m_contactList = _arg1.m_node2.next;
};
b2Contact.Destroy(_arg1, m_world.m_blockAllocator);
m_world.m_contactCount--;
}
public function Collide():void{
var _local1:b2Contact;
var _local2:b2Body;
var _local3:b2Body;
_local1 = m_world.m_contactList;
while (_local1) {
_local2 = _local1.m_shape1.m_body;
_local3 = _local1.m_shape2.m_body;
if (((_local2.IsSleeping()) && (_local3.IsSleeping()))){
} else {
_local1.Update(m_world.m_contactListener);
};
_local1 = _local1.m_next;
};
}
}
}//package Box2D.Dynamics
Section 107
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw)
package Box2D.Dynamics {
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
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_coreShapeBit:uint = 4;
public static var e_shapeBit:uint = 1;
public static var e_centerOfMassBit:uint = 64;
public static var e_aabbBit:uint = 8;
public static var e_controllerBit:uint = 128;
public static var e_obbBit:uint = 16;
public static var e_pairBit:uint = 32;
public static var e_jointBit:uint = 2;
public function b2DebugDraw(){
m_drawScale = 1;
m_lineThickness = 1;
m_alpha = 1;
m_fillAlpha = 1;
m_xformScale = 1;
super();
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{
var _local4:int;
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);
_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 DrawXForm(_arg1:b2XForm):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 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 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{
var _local4:int;
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
_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 108
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Joints.*;
public class b2DestructionListener {
public function SayGoodbyeJoint(_arg1:b2Joint):void{
}
public function SayGoodbyeShape(_arg1:b2Shape):void{
}
}
}//package Box2D.Dynamics
Section 109
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class b2Island {
b2internal var m_joints:Array;
private var m_listener:b2ContactListener;
private var m_bodyCapacity:int;
b2internal var m_bodies:Array;
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_bodyCount:int;
private static var s_reportCR:b2ContactResult = new b2ContactResult();
public function b2Island(_arg1:int, _arg2:int, _arg3:int, _arg4, _arg5:b2ContactListener){
var _local6:int;
super();
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_bodies = new Array(_arg1);
_local6 = 0;
while (_local6 < _arg1) {
m_bodies[_local6] = null;
_local6++;
};
m_contacts = new Array(_arg2);
_local6 = 0;
while (_local6 < _arg2) {
m_contacts[_local6] = null;
_local6++;
};
m_joints = new Array(_arg3);
_local6 = 0;
while (_local6 < _arg3) {
m_joints[_local6] = null;
_local6++;
};
}
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 _local2:b2Mat22;
var _local3:b2Vec2;
var _local4:int;
var _local5:b2Contact;
var _local6:b2ContactConstraint;
var _local7:b2ContactResult;
var _local8:b2Body;
var _local9:int;
var _local10:Array;
var _local11:int;
var _local12:b2Manifold;
var _local13:int;
var _local14:b2ManifoldPoint;
var _local15:b2ContactConstraintPoint;
if (m_listener == null){
return;
};
_local4 = 0;
while (_local4 < m_contactCount) {
_local5 = m_contacts[_local4];
_local6 = _arg1[_local4];
_local7 = s_reportCR;
_local7.shape1 = _local5.m_shape1;
_local7.shape2 = _local5.m_shape2;
_local8 = _local7.shape1.m_body;
_local9 = _local5.m_manifoldCount;
_local10 = _local5.GetManifolds();
_local11 = 0;
while (_local11 < _local9) {
_local12 = _local10[_local11];
_local7.normal.SetV(_local12.normal);
_local13 = 0;
while (_local13 < _local12.pointCount) {
_local14 = _local12.points[_local13];
_local15 = _local6.points[_local13];
_local7.position = _local8.GetWorldPoint(_local14.localPoint1);
_local7.normalImpulse = _local15.normalImpulse;
_local7.tangentImpulse = _local15.tangentImpulse;
_local7.id.key = _local14.id.key;
m_listener.Result(_local7);
_local13++;
};
_local11++;
};
_local4++;
};
}
public function Solve(_arg1:b2TimeStep, _arg2:b2Vec2, _arg3:Boolean):void{
var _local4:int;
var _local5:int;
var _local6:b2Body;
var _local7:b2Joint;
var _local8:b2ContactSolver;
var _local9:b2Vec2;
var _local10:Number;
var _local11:Boolean;
var _local12:Boolean;
var _local13:Boolean;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.IsStatic()){
} 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_force.SetZero();
_local6.m_torque = 0;
_local6.m_linearVelocity.Multiply(b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_linearDamping)), 0, 1));
_local6.m_angularVelocity = (_local6.m_angularVelocity * b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_angularDamping)), 0, 1));
};
_local4++;
};
_local8 = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator);
_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++;
};
_local8.FinalizeVelocityConstraints();
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.IsStatic()){
} else {
_local9 = b2Math.MulFV(_arg1.dt, _local6.m_linearVelocity);
if (_local9.LengthSquared() > 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));
};
_local10 = (_arg1.dt * _local6.m_angularVelocity);
if (((_arg1.dt * _local6.m_angularVelocity) * _local10) > 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) {
_local11 = _local8.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local12 = true;
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local13 = _local7.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local12 = ((_local12) && (_local13));
_local5++;
};
if (((_local11) && (_local12))){
break;
};
_local4++;
};
Report(_local8.m_constraints);
if (_arg3){
_local14 = Number.MAX_VALUE;
_local15 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
_local16 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.m_invMass == 0){
} else {
if ((_local6.m_flags & b2Body.e_allowSleepFlag) == 0){
_local6.m_sleepTime = 0;
_local14 = 0;
};
if (((((((_local6.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local6.m_angularVelocity * _local6.m_angularVelocity) > _local16)))) || ((b2Math.b2Dot(_local6.m_linearVelocity, _local6.m_linearVelocity) > _local15)))){
_local6.m_sleepTime = 0;
_local14 = 0;
} else {
_local6.m_sleepTime = (_local6.m_sleepTime + _arg1.dt);
_local14 = b2Math.b2Min(_local14, _local6.m_sleepTime);
};
};
_local4++;
};
if (_local14 >= b2Settings.b2_timeToSleep){
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
m_bodies[_local4].m_flags = (_local6.m_flags | b2Body.e_sleepFlag);
_local6.m_linearVelocity.SetZero();
_local6.m_angularVelocity = 0;
_local4++;
};
};
};
}
public function AddContact(_arg1:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = _arg1;
}
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 _local4:b2ContactSolver;
var _local5:Number;
var _local6:b2Body;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Boolean;
var _local10:Boolean;
var _local11:Boolean;
_local4 = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator);
_arg1.warmStarting = true;
_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].InitVelocityConstraints(_arg1);
_local3++;
};
_local2++;
};
_local2 = 0;
while (_local2 < m_bodyCount) {
_local6 = m_bodies[_local2];
if (_local6.IsStatic()){
} else {
_local7 = b2Math.MulFV(_arg1.dt, _local6.m_linearVelocity);
if (_local7.LengthSquared() > 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));
};
_local8 = (_arg1.dt * _local6.m_angularVelocity);
if (((_arg1.dt * _local6.m_angularVelocity) * _local8) > 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++;
};
_local5 = 0.75;
_local2 = 0;
while (_local2 < _arg1.positionIterations) {
_local9 = _local4.SolvePositionConstraints(_local5);
_local10 = true;
_local3 = 0;
while (_local3 < m_jointCount) {
_local11 = m_joints[_local3].SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local10 = ((_local10) && (_local11));
_local3++;
};
if (((_local9) && (_local10))){
break;
};
_local2++;
};
Report(_local4.m_constraints);
}
}
}//package Box2D.Dynamics
Section 110
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var warmStarting:Boolean;
public var dt:Number;
public var velocityIterations:int;
public var dtRatio:Number;
public var inv_dt:Number;
public var positionIterations:int;
}
}//package Box2D.Dynamics
Section 111
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Common.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class b2World {
private var m_inv_dt0:Number;
private var m_boundaryListener:b2BoundaryListener;
private var m_controllerList:b2Controller;
private var m_controllerCount:int;
b2internal var m_contactList:b2Contact;
b2internal var m_blockAllocator;
b2internal var m_contactListener:b2ContactListener;
b2internal var m_raycastSegment:b2Segment;
b2internal var m_broadPhase:b2BroadPhase;
private var m_jointCount:int;
private var m_bodyCount:int;
private var m_destructionListener:b2DestructionListener;
b2internal var m_lock:Boolean;
b2internal var m_raycastUserData;
private var m_allowSleep:Boolean;
b2internal var m_groundBody:b2Body;
b2internal var m_contactCount:int;
b2internal var m_raycastNormal:b2Vec2;
b2internal var m_contactFilter:b2ContactFilter;
b2internal var m_bodyList:b2Body;
private var m_debugDraw:b2DebugDraw;
b2internal var m_stackAllocator;
private var m_jointList:b2Joint;
private var m_gravity:b2Vec2;
private var m_contactManager:b2ContactManager;
private static var s_xf:b2XForm = new b2XForm();
private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8);
private static var m_continuousPhysics:Boolean;
private static var m_warmStarting:Boolean;
private static var s_coreColor:b2Color = new b2Color(0.9, 0.6, 0.6);
public function b2World(_arg1:b2AABB, _arg2:b2Vec2, _arg3:Boolean){
var _local4:b2BodyDef;
m_raycastNormal = new b2Vec2();
m_contactManager = new b2ContactManager();
super();
m_destructionListener = null;
m_boundaryListener = null;
m_contactFilter = b2ContactFilter.b2_defaultFilter;
m_contactListener = 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 = _arg3;
m_gravity = _arg2;
m_lock = false;
m_inv_dt0 = 0;
m_contactManager.m_world = this;
m_broadPhase = new b2BroadPhase(_arg1, m_contactManager);
_local4 = new b2BodyDef();
m_groundBody = CreateBody(_local4);
}
b2internal function DrawJoint(_arg1:b2Joint):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2XForm;
var _local5:b2XForm;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Color;
var _local11:b2PulleyJoint;
var _local12:b2Vec2;
var _local13:b2Vec2;
_local2 = _arg1.m_body1;
_local3 = _arg1.m_body2;
_local4 = _local2.m_xf;
_local5 = _local3.m_xf;
_local6 = _local4.position;
_local7 = _local5.position;
_local8 = _arg1.GetAnchor1();
_local9 = _arg1.GetAnchor2();
_local10 = 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.GetGroundAnchor1();
_local13 = _local11.GetGroundAnchor2();
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 Refilter(_arg1:b2Shape):void{
_arg1.RefilterProxy(m_broadPhase, _arg1.m_body.m_xf);
}
public function SetDebugDraw(_arg1:b2DebugDraw):void{
m_debugDraw = _arg1;
}
public function SetContinuousPhysics(_arg1:Boolean):void{
m_continuousPhysics = _arg1;
}
public function GetProxyCount():int{
return (m_broadPhase.m_proxyCount);
}
b2internal function DrawDebugData():void{
var _local1:uint;
var _local2:int;
var _local3:b2Body;
var _local4:b2Shape;
var _local5:b2Joint;
var _local6:b2BroadPhase;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Color;
var _local11:b2XForm;
var _local12:b2AABB;
var _local13:b2AABB;
var _local14:Array;
var _local15:Boolean;
var _local16:b2Controller;
var _local17:b2Pair;
var _local18:b2Proxy;
var _local19:b2Proxy;
var _local20:b2Vec2;
var _local21:b2Vec2;
var _local22:b2Proxy;
var _local23:b2PolygonShape;
var _local24:b2OBB;
var _local25:b2Vec2;
var _local26:b2Mat22;
var _local27:b2Vec2;
var _local28:Number;
if (m_debugDraw == null){
return;
};
m_debugDraw.m_sprite.graphics.clear();
_local1 = m_debugDraw.GetFlags();
_local7 = new b2Vec2();
_local8 = new b2Vec2();
_local9 = new b2Vec2();
_local10 = new b2Color(0, 0, 0);
_local12 = new b2AABB();
_local13 = new b2AABB();
_local14 = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
if ((_local1 & b2DebugDraw.e_shapeBit)){
_local15 = ((_local1 & b2DebugDraw.e_coreShapeBit) == b2DebugDraw.e_coreShapeBit);
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetShapeList();
while (_local4) {
if (_local3.IsStatic()){
DrawShape(_local4, _local11, new b2Color(0.5, 0.9, 0.5), _local15);
} else {
if (_local3.IsSleeping()){
DrawShape(_local4, _local11, new b2Color(0.5, 0.5, 0.9), _local15);
} else {
DrawShape(_local4, _local11, new b2Color(0.9, 0.9, 0.9), _local15);
};
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
if ((_local1 & b2DebugDraw.e_jointBit)){
_local5 = m_jointList;
while (_local5) {
DrawJoint(_local5);
_local5 = _local5.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)){
_local6 = m_broadPhase;
_local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y));
_local10.Set(0.9, 0.9, 0.3);
for each (_local17 in _local6.m_pairManager.m_pairs) {
_local18 = _local17.proxy1;
_local19 = _local17.proxy2;
if (((!(_local18)) || (!(_local19)))){
} else {
_local12.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.lowerBounds[0]].value));
_local12.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.lowerBounds[1]].value));
_local12.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.upperBounds[0]].value));
_local12.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.upperBounds[1]].value));
_local13.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.lowerBounds[0]].value));
_local13.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.lowerBounds[1]].value));
_local13.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.upperBounds[0]].value));
_local13.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.upperBounds[1]].value));
_local8.x = (0.5 * (_local12.lowerBound.x + _local12.upperBound.x));
_local8.y = (0.5 * (_local12.lowerBound.y + _local12.upperBound.y));
_local9.x = (0.5 * (_local13.lowerBound.x + _local13.upperBound.x));
_local9.y = (0.5 * (_local13.lowerBound.y + _local13.upperBound.y));
m_debugDraw.DrawSegment(_local8, _local9, _local10);
};
};
};
if ((_local1 & b2DebugDraw.e_aabbBit)){
_local6 = m_broadPhase;
_local20 = _local6.m_worldAABB.lowerBound;
_local21 = _local6.m_worldAABB.upperBound;
_local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y));
_local10.Set(0.9, 0.3, 0.9);
_local2 = 0;
while (_local2 < _local6.m_proxyPool.length) {
_local22 = _local6.m_proxyPool[_local2];
if (_local22.IsValid() == false){
} else {
_local12.lowerBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.lowerBounds[0]].value));
_local12.lowerBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.lowerBounds[1]].value));
_local12.upperBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.upperBounds[0]].value));
_local12.upperBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.upperBounds[1]].value));
_local14[0].Set(_local12.lowerBound.x, _local12.lowerBound.y);
_local14[1].Set(_local12.upperBound.x, _local12.lowerBound.y);
_local14[2].Set(_local12.upperBound.x, _local12.upperBound.y);
_local14[3].Set(_local12.lowerBound.x, _local12.upperBound.y);
m_debugDraw.DrawPolygon(_local14, 4, _local10);
};
_local2++;
};
_local14[0].Set(_local20.x, _local20.y);
_local14[1].Set(_local21.x, _local20.y);
_local14[2].Set(_local21.x, _local21.y);
_local14[3].Set(_local20.x, _local21.y);
m_debugDraw.DrawPolygon(_local14, 4, new b2Color(0.3, 0.9, 0.9));
};
if ((_local1 & b2DebugDraw.e_obbBit)){
_local10.Set(0.5, 0.3, 0.5);
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetShapeList();
while (_local4) {
if (_local4.m_type != b2Shape.e_polygonShape){
} else {
_local23 = (_local4 as b2PolygonShape);
_local24 = _local23.GetOBB();
_local25 = _local24.extents;
_local14[0].Set(-(_local25.x), -(_local25.y));
_local14[1].Set(_local25.x, -(_local25.y));
_local14[2].Set(_local25.x, _local25.y);
_local14[3].Set(-(_local25.x), _local25.y);
_local2 = 0;
while (_local2 < 4) {
_local26 = _local24.R;
_local27 = _local14[_local2];
_local28 = (_local24.center.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y)));
_local14[_local2].y = (_local24.center.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y)));
_local14[_local2].x = _local28;
_local26 = _local11.R;
_local28 = (_local11.position.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y)));
_local14[_local2].y = (_local11.position.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y)));
_local14[_local2].x = _local28;
_local2++;
};
m_debugDraw.DrawPolygon(_local14, 4, _local10);
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
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.DrawXForm(_local11);
_local3 = _local3.m_next;
};
};
}
public function DestroyBody(_arg1:b2Body):void{
var _local2:b2JointEdge;
var _local3:b2ControllerEdge;
var _local4:b2Shape;
var _local5:b2JointEdge;
var _local6:b2ControllerEdge;
var _local7:b2Shape;
if (m_lock == true){
return;
};
_local2 = _arg1.m_jointList;
while (_local2) {
_local5 = _local2;
_local2 = _local2.next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeJoint(_local5.joint);
};
DestroyJoint(_local5.joint);
};
_local3 = _arg1.m_controllerList;
while (_local3) {
_local6 = _local3;
_local3 = _local3.nextController;
_local6.controller.RemoveBody(_arg1);
};
_local4 = _arg1.m_shapeList;
while (_local4) {
_local7 = _local4;
_local4 = _local4.m_next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeShape(_local7);
};
_local7.DestroyProxy(m_broadPhase);
b2Shape.Destroy(_local7, m_blockAllocator);
};
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:b2XForm, _arg3:b2Color, _arg4:Boolean):void{
var _local5:b2Color;
var _local6:b2CircleShape;
var _local7:b2Vec2;
var _local8:Number;
var _local9:b2Vec2;
var _local10:int;
var _local11:b2PolygonShape;
var _local12:int;
var _local13:Array;
var _local14:Array;
var _local15:Array;
var _local16:b2EdgeShape;
_local5 = s_coreColor;
switch (_arg1.m_type){
case b2Shape.e_circleShape:
_local6 = (_arg1 as b2CircleShape);
_local7 = b2Math.b2MulX(_arg2, _local6.m_localPosition);
_local8 = _local6.m_radius;
_local9 = _arg2.R.col1;
m_debugDraw.DrawSolidCircle(_local7, _local8, _local9, _arg3);
if (_arg4){
m_debugDraw.DrawCircle(_local7, (_local8 - b2Settings.b2_toiSlop), _local5);
};
break;
case b2Shape.e_polygonShape:
_local11 = (_arg1 as b2PolygonShape);
_local12 = _local11.GetVertexCount();
_local13 = _local11.GetVertices();
_local14 = new Array(b2Settings.b2_maxPolygonVertices);
_local10 = 0;
while (_local10 < _local12) {
_local14[_local10] = b2Math.b2MulX(_arg2, _local13[_local10]);
_local10++;
};
m_debugDraw.DrawSolidPolygon(_local14, _local12, _arg3);
if (_arg4){
_local15 = _local11.GetCoreVertices();
_local10 = 0;
while (_local10 < _local12) {
_local14[_local10] = b2Math.b2MulX(_arg2, _local15[_local10]);
_local10++;
};
m_debugDraw.DrawPolygon(_local14, _local12, _local5);
};
break;
case b2Shape.e_edgeShape:
_local16 = (_arg1 as b2EdgeShape);
m_debugDraw.DrawSegment(b2Math.b2MulX(_arg2, _local16.GetVertex1()), b2Math.b2MulX(_arg2, _local16.GetVertex2()), _arg3);
if (_arg4){
m_debugDraw.DrawSegment(b2Math.b2MulX(_arg2, _local16.GetCoreVertex1()), b2Math.b2MulX(_arg2, _local16.GetCoreVertex2()), _local5);
};
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 _local3:b2Controller;
var _local4:b2Island;
var _local5:b2Contact;
var _local6:b2Joint;
var _local7:int;
var _local8:Array;
var _local9:b2Body;
var _local10:int;
var _local11:int;
var _local12:b2Body;
var _local13:b2ContactEdge;
var _local14:b2JointEdge;
var _local15:Boolean;
_local3 = m_controllerList;
while (_local3) {
_local3.Step(_arg1);
_local3 = _local3.m_next;
};
_local4 = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator, m_contactListener);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2 = _local2.m_next;
};
_local5 = m_contactList;
while (_local5) {
_local5.m_flags = (_local5.m_flags & ~(b2Contact.e_islandFlag));
_local5 = _local5.m_next;
};
_local6 = m_jointList;
while (_local6) {
_local6.m_islandFlag = false;
_local6 = _local6.m_next;
};
_local7 = m_bodyCount;
_local8 = new Array(_local7);
_local9 = m_bodyList;
while (_local9) {
if ((_local9.m_flags & ((b2Body.e_islandFlag | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){
} else {
if (_local9.IsStatic()){
} else {
_local4.Clear();
_local10 = 0;
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local16 = _temp1;
_local8[_local16] = _local9;
_local9.m_flags = (_local9.m_flags | b2Body.e_islandFlag);
while (_local10 > 0) {
--_local10;
_local2 = _local8[_local10];
_local4.AddBody(_local2);
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag));
if (_local2.IsStatic()){
} else {
_local13 = _local2.m_contactList;
while (_local13) {
if ((_local13.contact.m_flags & (b2Contact.e_islandFlag | b2Contact.e_nonSolidFlag))){
} else {
if (_local13.contact.m_manifoldCount == 0){
} 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 _local17 = _temp2;
_local8[_local17] = _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 {
_local4.AddJoint(_local14.joint);
_local14.joint.m_islandFlag = true;
_local12 = _local14.other;
if ((_local12.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = _local10;
_local10 = (_local10 + 1);
_local17 = _temp3;
_local8[_local17] = _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.IsStatic()){
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
};
_local11++;
};
};
};
_local9 = _local9.m_next;
};
_local2 = m_bodyList;
while (_local2) {
if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (_local2.IsStatic()){
} else {
_local15 = _local2.SynchronizeShapes();
if ((((_local15 == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(_local2);
};
};
};
_local2 = _local2.m_next;
};
m_broadPhase.Commit();
}
public function Query(_arg1:b2AABB, _arg2:Array, _arg3:int):int{
var _local4:Array;
var _local5:int;
var _local6:int;
_local4 = new Array(_arg3);
_local5 = m_broadPhase.QueryAABB(_arg1, _local4, _arg3);
_local6 = 0;
while (_local6 < _local5) {
_arg2[_local6] = _local4[_local6];
_local6++;
};
return (_local5);
}
public function SetGravity(_arg1:b2Vec2):void{
m_gravity = _arg1;
}
public function SetContactFilter(_arg1:b2ContactFilter):void{
m_contactFilter = _arg1;
}
b2internal function SolveTOI(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Shape;
var _local4:b2Shape;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactEdge;
var _local8:b2Joint;
var _local9:b2Island;
var _local10:int;
var _local11:Array;
var _local12:b2Contact;
var _local13:b2Contact;
var _local14:Number;
var _local15:b2Body;
var _local16:int;
var _local17:int;
var _local18:b2JointEdge;
var _local19:b2TimeStep;
var _local20:int;
var _local21:Number;
var _local22:Number;
var _local23:b2Body;
var _local24:Boolean;
_local9 = new b2Island(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, m_stackAllocator, m_contactListener);
_local10 = m_bodyCount;
_local11 = new Array(_local10);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2.m_sweep.t0 = 0;
_local2 = _local2.m_next;
};
_local12 = m_contactList;
while (_local12) {
_local12.m_flags = (_local12.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local12 = _local12.m_next;
};
_local8 = m_jointList;
while (_local8) {
_local8.m_islandFlag = false;
_local8 = _local8.m_next;
};
while (true) {
_local13 = null;
_local14 = 1;
_local12 = m_contactList;
for (;_local12;(_local12 = _local12.m_next)) {
if ((_local12.m_flags & (b2Contact.e_slowFlag | b2Contact.e_nonSolidFlag))){
} else {
_local21 = 1;
if ((_local12.m_flags & b2Contact.e_toiFlag)){
_local21 = _local12.m_toi;
} else {
_local3 = _local12.m_shape1;
_local4 = _local12.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
if (((((_local5.IsStatic()) || (_local5.IsSleeping()))) && (((_local6.IsStatic()) || (_local6.IsSleeping()))))){
continue;
};
_local22 = _local5.m_sweep.t0;
if (_local5.m_sweep.t0 < _local6.m_sweep.t0){
_local22 = _local6.m_sweep.t0;
_local5.m_sweep.Advance(_local22);
} else {
if (_local6.m_sweep.t0 < _local5.m_sweep.t0){
_local22 = _local5.m_sweep.t0;
_local6.m_sweep.Advance(_local22);
};
};
_local21 = b2TimeOfImpact.TimeOfImpact(_local12.m_shape1, _local5.m_sweep, _local12.m_shape2, _local6.m_sweep);
if ((((_local21 > 0)) && ((_local21 < 1)))){
_local21 = (((1 - _local21) * _local22) + _local21);
if (_local21 > 1){
_local21 = 1;
};
};
_local12.m_toi = _local21;
_local12.m_flags = (_local12.m_flags | b2Contact.e_toiFlag);
};
if ((((Number.MIN_VALUE < _local21)) && ((_local21 < _local14)))){
_local13 = _local12;
_local14 = _local21;
};
};
};
if ((((_local13 == null)) || (((1 - (100 * Number.MIN_VALUE)) < _local14)))){
break;
};
_local3 = _local13.m_shape1;
_local4 = _local13.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local5.Advance(_local14);
_local6.Advance(_local14);
_local13.Update(m_contactListener);
_local13.m_flags = (_local13.m_flags & ~(b2Contact.e_toiFlag));
if (_local13.m_manifoldCount == 0){
} else {
_local15 = _local5;
if (_local15.IsStatic()){
_local15 = _local6;
};
_local9.Clear();
_local16 = 0;
_local17 = 0;
var _temp1 = _local17;
_local17 = (_local17 + 1);
_local11[(_local16 + _temp1)] = _local15;
_local15.m_flags = (_local15.m_flags | b2Body.e_islandFlag);
while (_local17 > 0) {
var _temp2 = _local16;
_local16 = (_local16 + 1);
_local2 = _local11[_temp2];
_local17--;
_local9.AddBody(_local2);
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag));
if (_local2.IsStatic()){
} else {
_local7 = _local2.m_contactList;
while (_local7) {
if (_local9.m_contactCount == _local9.m_contactCapacity){
} else {
if ((_local7.contact.m_flags & ((b2Contact.e_islandFlag | b2Contact.e_slowFlag) | b2Contact.e_nonSolidFlag))){
} else {
if (_local7.contact.m_manifoldCount == 0){
} else {
_local9.AddContact(_local7.contact);
_local7.contact.m_flags = (_local7.contact.m_flags | b2Contact.e_islandFlag);
_local23 = _local7.other;
if ((_local23.m_flags & b2Body.e_islandFlag)){
} else {
if (_local23.IsStatic() == false){
_local23.Advance(_local14);
_local23.WakeUp();
};
_local11[(_local16 + _local17)] = _local23;
_local17++;
_local23.m_flags = (_local23.m_flags | b2Body.e_islandFlag);
};
};
};
};
_local7 = _local7.next;
};
};
};
_local18 = _local2.m_jointList;
while (_local18) {
if (_local9.m_jointCount == _local9.m_jointCapacity){
} else {
if (_local18.joint.m_islandFlag == true){
} else {
_local9.AddJoint(_local18.joint);
_local18.joint.m_islandFlag = true;
_local23 = _local18.other;
if ((_local23.m_flags & b2Body.e_islandFlag)){
} else {
if (!_local23.IsStatic()){
_local23.Advance(_local14);
_local23.WakeUp();
};
_local11[(_local16 + _local17)] = _local23;
_local17++;
_local23.m_flags = (_local23.m_flags | b2Body.e_islandFlag);
};
};
};
_local18 = _local18.next;
};
_local19 = new b2TimeStep();
_local19.warmStarting = false;
_local19.dt = ((1 - _local14) * _arg1.dt);
_local19.inv_dt = (1 / _local19.dt);
_local19.dtRatio = 0;
_local19.velocityIterations = _arg1.velocityIterations;
_local19.positionIterations = _arg1.positionIterations;
_local9.SolveTOI(_local19);
_local20 = 0;
while (_local20 < _local9.m_bodyCount) {
_local2 = _local9.m_bodies[_local20];
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (_local2.IsStatic()){
} else {
_local24 = _local2.SynchronizeShapes();
if ((((_local24 == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(_local2);
};
_local7 = _local2.m_contactList;
while (_local7) {
_local7.contact.m_flags = (_local7.contact.m_flags & ~(b2Contact.e_toiFlag));
_local7 = _local7.next;
};
};
};
_local20++;
};
_local20 = 0;
while (_local20 < _local9.m_contactCount) {
_local12 = _local9.m_contacts[_local20];
_local9.m_contacts[_local20].m_flags = (_local12.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local20++;
};
_local20 = 0;
while (_local20 < _local9.m_jointCount) {
_local8 = _local9.m_joints[_local20];
_local8.m_islandFlag = false;
_local20++;
};
m_broadPhase.Commit();
};
};
}
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 Validate():void{
m_broadPhase.Validate();
}
public function GetPairCount():int{
return (m_broadPhase.m_pairManager.m_pairCount);
}
public function SetWarmStarting(_arg1:Boolean):void{
m_warmStarting = _arg1;
}
public function Raycast(_arg1:b2Segment, _arg2:Array, _arg3:int, _arg4:Boolean, _arg5):int{
var _local6:Array;
var _local7:int;
var _local8:int;
_local6 = new Array(_arg3);
m_raycastSegment = _arg1;
m_raycastUserData = _arg5;
if (_arg4){
_local7 = m_broadPhase.QuerySegment(_arg1, _local6, _arg3, RaycastSortKey);
} else {
_local7 = m_broadPhase.QuerySegment(_arg1, _local6, _arg3, RaycastSortKey2);
};
_local8 = 0;
while (_local8 < _local7) {
_arg2[_local8] = _local6[_local8];
_local8++;
};
return (_local7);
}
public function CreateJoint(_arg1:b2JointDef):b2Joint{
var _local2:b2Joint;
var _local3:b2Body;
var _local4:b2Shape;
_local2 = b2Joint.Create(_arg1, m_blockAllocator);
_local2.m_prev = null;
_local2.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = _local2;
};
m_jointList = _local2;
m_jointCount++;
_local2.m_node1.joint = _local2;
_local2.m_node1.other = _local2.m_body2;
_local2.m_node1.prev = null;
_local2.m_node1.next = _local2.m_body1.m_jointList;
if (_local2.m_body1.m_jointList){
_local2.m_body1.m_jointList.prev = _local2.m_node1;
};
_local2.m_body1.m_jointList = _local2.m_node1;
_local2.m_node2.joint = _local2;
_local2.m_node2.other = _local2.m_body1;
_local2.m_node2.prev = null;
_local2.m_node2.next = _local2.m_body2.m_jointList;
if (_local2.m_body2.m_jointList){
_local2.m_body2.m_jointList.prev = _local2.m_node2;
};
_local2.m_body2.m_jointList = _local2.m_node2;
if (_arg1.collideConnected == false){
_local3 = ((_arg1.body1.m_shapeCount < _arg1.body2.m_shapeCount)) ? _arg1.body1 : _arg1.body2;
_local4 = _local3.m_shapeList;
while (_local4) {
_local4.RefilterProxy(m_broadPhase, _local3.m_xf);
_local4 = _local4.m_next;
};
};
return (_local2);
}
public function DestroyJoint(_arg1:b2Joint):void{
var _local2:Boolean;
var _local3:b2Body;
var _local4:b2Body;
var _local5:b2Body;
var _local6:b2Shape;
_local2 = _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;
};
_local3 = _arg1.m_body1;
_local4 = _arg1.m_body2;
_local3.WakeUp();
_local4.WakeUp();
if (_arg1.m_node1.prev){
_arg1.m_node1.prev.next = _arg1.m_node1.next;
};
if (_arg1.m_node1.next){
_arg1.m_node1.next.prev = _arg1.m_node1.prev;
};
if (_arg1.m_node1 == _local3.m_jointList){
_local3.m_jointList = _arg1.m_node1.next;
};
_arg1.m_node1.prev = null;
_arg1.m_node1.next = null;
if (_arg1.m_node2.prev){
_arg1.m_node2.prev.next = _arg1.m_node2.next;
};
if (_arg1.m_node2.next){
_arg1.m_node2.next.prev = _arg1.m_node2.prev;
};
if (_arg1.m_node2 == _local4.m_jointList){
_local4.m_jointList = _arg1.m_node2.next;
};
_arg1.m_node2.prev = null;
_arg1.m_node2.next = null;
b2Joint.Destroy(_arg1, m_blockAllocator);
m_jointCount--;
if (_local2 == false){
_local5 = ((_local3.m_shapeCount < _local4.m_shapeCount)) ? _local3 : _local4;
_local6 = _local5.m_shapeList;
while (_local6) {
_local6.RefilterProxy(m_broadPhase, _local5.m_xf);
_local6 = _local6.m_next;
};
};
}
public function SetContactListener(_arg1:b2ContactListener):void{
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);
}
b2internal function RaycastSortKey2(_arg1:b2Shape):Number{
var _local2:b2Body;
var _local3:b2XForm;
var _local4:Array;
if (((m_contactFilter) && (!(m_contactFilter.RayCollide(m_raycastUserData, _arg1))))){
return (-1);
};
_local2 = _arg1.GetBody();
_local3 = _local2.GetXForm();
_local4 = [0];
if (_arg1.TestSegment(_local3, _local4, m_raycastNormal, m_raycastSegment, 1) != b2Shape.e_hitCollide){
return (-1);
};
return (_local4[0]);
}
public function RaycastOne(_arg1:b2Segment, _arg2:Array, _arg3:b2Vec2, _arg4:Boolean, _arg5):b2Shape{
var _local6:Array;
var _local7:Number;
var _local8:b2Shape;
var _local9:b2XForm;
_local6 = new Array(1);
_local7 = Raycast(_arg1, _local6, 1, _arg4, _arg5);
if (_local7 == 0){
return (null);
};
if (_local7 > 1){
trace(_local7);
};
_local8 = _local6[0];
_local9 = _local8.GetBody().GetXForm();
_local8.TestSegment(_local9, _arg2, _arg3, _arg1, 1);
return (_local8);
}
public function CreateBody(_arg1:b2BodyDef):b2Body{
var _local2:b2Body;
if (m_lock == true){
return (null);
};
_local2 = 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);
}
b2internal function RaycastSortKey(_arg1:b2Shape):Number{
var _local2:b2Body;
var _local3:b2XForm;
var _local4:Array;
if (((m_contactFilter) && (!(m_contactFilter.RayCollide(m_raycastUserData, _arg1))))){
return (-1);
};
_local2 = _arg1.GetBody();
_local3 = _local2.GetXForm();
_local4 = [0];
if (_arg1.TestSegment(_local3, _local4, m_raycastNormal, m_raycastSegment, 1) == b2Shape.e_missCollide){
return (-1);
};
return (_local4[0]);
}
public function SetBoundaryListener(_arg1:b2BoundaryListener):void{
m_boundaryListener = _arg1;
}
public function SetDestructionListener(_arg1:b2DestructionListener):void{
m_destructionListener = _arg1;
}
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 Step(_arg1:Number, _arg2:int, _arg3:int):void{
var _local4:b2TimeStep;
m_lock = true;
_local4 = new b2TimeStep();
_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);
};
DrawDebugData();
m_inv_dt0 = _local4.inv_dt;
m_lock = false;
}
public function GetBodyCount():int{
return (m_bodyCount);
}
public function InRange(_arg1:b2AABB):Boolean{
return (m_broadPhase.InRange(_arg1));
}
public function GetJointCount():int{
return (m_jointCount);
}
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 112
//AchievementAS3 (com.cartoonnetwork.AchievementSystem.AchievementAS3)
package com.cartoonnetwork.AchievementSystem {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import com.cartoonnetwork.connect.*;
import flash.net.*;
public class AchievementAS3 {
private var _displayConnection:Connection;
private var _moduleConnection:Connection;
public var _status:int;
private var _connectTimer:Timer;
public var _containerLoaded;// = false
private var _connectedToModule:Boolean;
private var _mc:MovieClip;
private var _swfLoader:Loader;
public var _xmlLoaded:Boolean;// = false
public static var STATUS_CONNECTING:int = 0;
public static var STATUS_READY:int = 2;
public static var STATUS_SHOWING_ACHIEVEMENT:int = 1;
public static var _uniqueVal:int = -1;
public static var _achievementNotificationFinished:Boolean;
public function AchievementAS3(_arg1:MovieClip){
_swfLoader = new Loader();
_xmlLoaded = false;
_containerLoaded = false;
_mc = new MovieClip();
super();
_mc = _arg1;
_mc.x = 0;
_mc.y = 0;
_moduleConnection = new Connection("fromAchieveModule", "toAchieveModule", this, true);
}
public function xmlLoaded(){
_xmlLoaded = true;
trace("xmlLoaded()");
_swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
_swfLoader.load(new URLRequest("AchieveDisplay.swf"));
_swfLoader.x = 175;
_swfLoader.y = 400;
_mc.addChild(_swfLoader);
}
public function achievementEarned(_arg1:Array){
showAchievement(_arg1[0], _arg1[1]);
}
public function achievementNotificationFinished(){
AchievementAS3._achievementNotificationFinished = true;
trace("<< Notification Finished");
}
public function achievementNotificationGameStarted(){
_moduleConnection.send("achievementNotificationGameStarted");
}
public function isAchievmentNotificationFinished(){
var _local1:*;
_local1 = _achievementNotificationFinished;
_achievementNotificationFinished = false;
return (_local1);
}
public function achievementNotificationGameEnded(){
_moduleConnection.send("achievementNotificationGameEnded");
}
private function onCompleteHandler(_arg1:Event){
_containerLoaded = true;
trace("container added");
_displayConnection = new Connection("fromDisplayModule", "toDisplayModule", this, false);
}
public function achievementNotificationGameLoaded(){
_moduleConnection.send("achievementNotificationGameLoaded");
}
public function showAchievement(_arg1:String, _arg2:String){
if (!_containerLoaded){
trace("<< container not loaded");
return;
};
_displayConnection.send("displayAchievement", _arg1, _arg2);
}
public function toString():String{
return ("<< AchievementAS3 >>");
}
public function sendStat(_arg1:String, _arg2:int){
_moduleConnection.send("updateStat", _arg1, _arg2);
}
}
}//package com.cartoonnetwork.AchievementSystem
Section 113
//Connection (com.cartoonnetwork.connect.Connection)
package com.cartoonnetwork.connect {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class Connection {
private var _master:Boolean;
public var _connected:Boolean;
private var _connectTimer:Timer;
private var _uniqueClient;
public var _rLC:LocalConnection;
public var _sLC:LocalConnection;
private var _unique;
public var _rConnection:String;
public var _sConnection:String;
public function Connection(_arg1:String, _arg2:String, _arg3, _arg4:Boolean){
_rLC = new LocalConnection();
_sLC = new LocalConnection();
super();
_rConnection = _arg1;
_sConnection = _arg2;
_uniqueClient = _arg3;
_master = _arg4;
if (_master){
_unique = Math.floor((Math.random() * 10000));
_rConnection = (_rConnection + _unique);
initConnection();
_rLC.connect(_rConnection);
_rLC.client = this;
} else {
_rLC.connect(_rConnection);
_rLC.client = this;
};
}
public function slaveReceivedUnique(){
trace(("<< game slave received unique: " + _unique));
_sLC.removeEventListener(StatusEvent.STATUS, onConnectionStatus);
_sLC.addEventListener(StatusEvent.STATUS, onStatus);
_connected = true;
_sConnection = (_sConnection + _unique);
_connectTimer.stop();
_connectTimer.removeEventListener("timer", AttemptConnection);
_rLC.close();
_rLC.connect(_rConnection);
_rLC.client = _uniqueClient;
}
public function initConnection(){
_connectTimer = new Timer(2000);
_connectTimer.addEventListener("timer", AttemptConnection);
_sLC.addEventListener(StatusEvent.STATUS, onConnectionStatus);
AttemptConnection(null);
_connectTimer.start();
}
public function setUnique(_arg1:int){
_unique = _arg1;
_rConnection = (_rConnection + _unique);
_sConnection = (_sConnection + _unique);
trace(("<< sending message to : " + _sConnection));
_sLC.send(_sConnection, "slaveReceivedUnique");
_sLC.addEventListener(StatusEvent.STATUS, onStatus);
_rLC.close();
_rLC.connect(_rConnection);
_rLC.client = _uniqueClient;
_connected = true;
}
public function send(_arg1:String, ... _args){
if (_args.length > 0){
_sLC.send(_sConnection, _arg1, _args);
} else {
_sLC.send(_sConnection, _arg1);
};
}
private function onConnectionStatus(_arg1:StatusEvent){
switch (_arg1.level){
case "status":
trace("LocalConnection connected successfully.");
slaveReceivedUnique();
break;
case "error":
trace("LocalConnection encountered an error.");
break;
default:
trace("default");
break;
};
}
public function AttemptConnection(_arg1:TimerEvent){
trace(((("sending unique to " + _sConnection) + " unique val: ") + _unique));
_sLC.send(_sConnection, "setUnique", _unique);
}
private function onStatus(_arg1:StatusEvent){
switch (_arg1.level){
case "status":
trace("LocalConnection sent successfully.");
break;
case "error":
trace("LocalConnection encountered an error.");
break;
default:
trace("default");
break;
};
}
}
}//package com.cartoonnetwork.connect
Section 114
//SubmitScore (com.cartoonnetwork.highscores.SubmitScore)
package com.cartoonnetwork.highscores {
import flash.events.*;
import flash.external.*;
public class SubmitScore extends EventDispatcher {
protected static var e_instance:SubmitScore = new (SubmitScore);
;
public function submitScore(_arg1:Number):void{
trace("Supposed to submit score");
if (ExternalInterface.available){
ExternalInterface.call("TopScoresModuleComm.onScore", _arg1);
};
}
public static function getInstance():SubmitScore{
return (SubmitScore.e_instance);
}
}
}//package com.cartoonnetwork.highscores
Section 115
//CollisionEvent (game.collision.CollisionEvent)
package game.collision {
import flash.events.*;
import Box2D.Collision.Shapes.*;
import Box2D.Collision.*;
public class CollisionEvent extends Event {
private var _otherShape:b2Shape;
private var _collidingPoint:b2ContactPoint;
public static const COLLIDE:String = "collide";
public static const FIRST_COLLIDE:String = "firstCollide";
public function CollisionEvent(_arg1:String, _arg2:b2Shape, _arg3:b2ContactPoint, _arg4:Boolean=false, _arg5:Boolean=false){
super(_arg1, _arg4, _arg5);
_otherShape = _arg2;
_collidingPoint = _arg3;
}
public function get collidingPoint():b2ContactPoint{
return (_collidingPoint);
}
public function get otherShape():b2Shape{
return (_otherShape);
}
}
}//package game.collision
Section 116
//CollisionHandler (game.collision.CollisionHandler)
package game.collision {
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class CollisionHandler extends b2ContactListener {
var collisionListeners:Array;
var contactListeners:Array;
public function CollisionHandler(){
contactListeners = new Array();
collisionListeners = new Array();
super();
}
public function addContactListener(_arg1:ContactListener):void{
contactListeners.push(_arg1);
}
override public function Remove(_arg1:b2ContactPoint):void{
var _local2:int;
var _local3:CollisionListener;
var _local4:b2Shape;
_local2 = collisionListeners.length;
while (_local2--) {
_local3 = collisionListeners[_local2];
_local4 = _local3.shapeToWatch;
if ((((_arg1.shape1 == _local4)) || ((_arg1.shape2 == _local4)))){
_local3.removeCollision(_arg1);
};
};
}
public function addCollisionListener(_arg1:CollisionListener):void{
collisionListeners.push(_arg1);
}
override public function Add(_arg1:b2ContactPoint):void{
var _local2:b2Shape;
var _local3:int;
var _local4:ContactListener;
var _local5:CollisionListener;
_local3 = contactListeners.length;
while (_local3--) {
_local4 = contactListeners[_local3];
_local2 = _local4.shapeToWatch;
if ((((_arg1.shape1 == _local2)) || ((_arg1.shape2 == _local2)))){
_local4.addContact(_arg1);
};
};
_local3 = collisionListeners.length;
while (_local3--) {
_local5 = collisionListeners[_local3];
_local2 = _local5.shapeToWatch;
if ((((_arg1.shape1 == _local2)) || ((_arg1.shape2 == _local2)))){
_local5.addCollision(_arg1);
};
};
}
override public function Persist(_arg1:b2ContactPoint):void{
var _local2:int;
var _local3:ContactListener;
var _local4:b2Shape;
_local2 = contactListeners.length;
while (_local2--) {
_local3 = contactListeners[_local2];
_local4 = _local3.shapeToWatch;
if ((((_arg1.shape1 == _local4)) || ((_arg1.shape2 == _local4)))){
_local3.addContact(_arg1);
};
};
}
}
}//package game.collision
Section 117
//CollisionListener (game.collision.CollisionListener)
package game.collision {
import flash.events.*;
import Box2D.Collision.Shapes.*;
import Box2D.Collision.*;
public class CollisionListener extends EventDispatcher {
private var _shapeToWatch:b2Shape;
private var _collisionStack:Array;
public function CollisionListener(_arg1:b2Shape){
_collisionStack = new Array();
super();
_shapeToWatch = _arg1;
}
public function addCollision(_arg1:b2ContactPoint):void{
var _local2:b2Shape;
var _local3:int;
var _local4:CollisionEvent;
var _local5:CollisionEvent;
_local2 = ((_shapeToWatch)==_arg1.shape1) ? _arg1.shape2 : _arg1.shape1;
_local3 = _collisionStack.indexOf(_local2);
if (_local3 < 0){
_collisionStack.push(_local2);
if (hasEventListener(CollisionEvent.FIRST_COLLIDE)){
_local4 = new CollisionEvent(CollisionEvent.FIRST_COLLIDE, _local2, _arg1);
dispatchEvent(_local4);
};
return;
};
if (hasEventListener(CollisionEvent.COLLIDE)){
_local5 = new CollisionEvent(CollisionEvent.COLLIDE, _local2, _arg1);
dispatchEvent(_local5);
};
}
public function get shapeToWatch():b2Shape{
return (_shapeToWatch);
}
public function removeCollision(_arg1:b2ContactPoint):void{
var _local2:b2Shape;
var _local3:int;
_local2 = ((_shapeToWatch)==_arg1.shape1) ? _arg1.shape2 : _arg1.shape1;
_local3 = _collisionStack.indexOf(_local2);
if (_local3 >= 0){
_collisionStack.splice(_local3, 0);
};
}
}
}//package game.collision
Section 118
//Contact (game.collision.Contact)
package game.collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
public class Contact {
public var _separation:Number;
public var _body:b2Body;
public var _shape2:b2Shape;
public var _pos:b2Vec2;
public var _shape1:b2Shape;
public function Contact(_arg1:b2Shape, _arg2:b2Shape, _arg3:b2Vec2, _arg4:Number){
_shape1 = _arg1;
_shape2 = _arg2;
_pos = _arg3;
_separation = _arg4;
}
}
}//package game.collision
Section 119
//ContactListener (game.collision.ContactListener)
package game.collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Collision.*;
public class ContactListener {
private var curContact:Contact;// = null
private var contactStack:Array;
private var _shapeToWatch:b2Shape;
public function ContactListener(_arg1:b2Shape){
curContact = null;
contactStack = new Array();
super();
_shapeToWatch = _arg1;
}
public function processContacts():Contact{
curContact = null;
while (contactStack[0]) {
curContact = contactStack.pop();
};
return (curContact);
}
public function getNumContacts():int{
return (contactStack.length);
}
public function getStack():Array{
return (contactStack);
}
public function get shapeToWatch():b2Shape{
return (_shapeToWatch);
}
public function addContact(_arg1:b2ContactPoint):void{
var _local2:Number;
var _local3:b2Vec2;
var _local4:b2Shape;
var _local5:b2Shape;
_local2 = _arg1.separation;
_local3 = _arg1.position.Copy();
_local4 = ((_arg1.shape1)==_shapeToWatch) ? _arg1.shape1 : _arg1.shape2;
_local5 = ((_arg1.shape1)==_shapeToWatch) ? _arg1.shape2 : _arg1.shape1;
contactStack.push(new Contact(_local4, _local5, _local3, _local2));
}
}
}//package game.collision
Section 120
//Obstacle (game.objects.Obstacle)
package game.objects {
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.*;
public class Obstacle {
private const ANCHOFFSET:Number = 8;
private const GRNDHGT:Number = 1;
private const ALPHA:Number = 1;
private var crate:b2CircleDef;
private var joint:b2Joint;
private var world:b2World;
private var apos:b2Vec2;
private var oBodyDef:b2BodyDef;
private var aBody:b2Body;
private var board:DisplayObjectContainer;
private var oBody:b2Body;
private var bpos:b2Vec2;
private var oShapeDef:b2PolygonDef;
private var type:int;
public static const GENERIC:int = 0;
public function Obstacle(_arg1:int, _arg2:int, _arg3:int, _arg4:b2World, _arg5:DisplayObjectContainer){
this.world = _arg4;
this.board = _arg5;
this.type = _arg1;
apos = new b2Vec2((_arg2 / 30), (_arg3 / 30));
bpos = new b2Vec2(apos.x, (apos.y - ANCHOFFSET));
initObstacle();
}
public function moveTo(_arg1:Number, _arg2:Number):void{
apos = new b2Vec2(_arg1, _arg2);
bpos = new b2Vec2(_arg1, (_arg2 - ANCHOFFSET));
aBody.SetXForm(new b2XForm(bpos, new b2Mat22(aBody.GetAngle())));
oBody.SetXForm(new b2XForm(apos, new b2Mat22(oBody.GetAngle())));
oBody.GetUserData().x = (oBody.GetPosition().x * 30);
oBody.GetUserData().y = (oBody.GetPosition().y * 30);
}
public function cleanup():void{
var _local1:DisplayObject;
var _local2:DisplayObject;
_local1 = (oBody.GetUserData() as DisplayObject);
if (board.contains(_local1)){
_local2 = board.removeChild(_local1);
};
world.DestroyBody(oBody);
world.DestroyBody(aBody);
}
public function get pos():b2Vec2{
return (apos);
}
public function updateSprite():void{
oBody.GetUserData().x = (oBody.GetPosition().x * 30);
oBody.GetUserData().y = (oBody.GetPosition().y * 30);
oBody.GetUserData().rotation = (oBody.GetAngle() * (180 / Math.PI));
}
function initObstacle():void{
var _local1:b2CircleDef;
var _local2:b2BodyDef;
var _local3:b2RevoluteJointDef;
switch (type){
case GENERIC:
_local1 = new b2CircleDef();
_local1.radius = 1;
_local2 = new b2BodyDef();
_local2.position.Set(bpos.x, bpos.y);
aBody = world.CreateBody(_local2);
aBody.CreateShape(_local1);
oBodyDef = new b2BodyDef();
oBodyDef.position.Set(apos.x, apos.y);
oBodyDef.userData = new obs_Generic();
oBodyDef.userData.x = (oBodyDef.position.x * 30);
oBodyDef.userData.y = (oBodyDef.position.y * 30);
oBodyDef.userData.alpha = ALPHA;
board.addChildAt(oBodyDef.userData, 0);
crate = new b2CircleDef();
crate.radius = 2;
crate.userData = "airobstacle";
crate.isSensor = true;
crate.density = 1;
crate.restitution = 1;
crate.friction = 0;
crate.localPosition.Set(-1, 0);
oBody = world.CreateBody(oBodyDef);
oBody.CreateShape(crate);
oBody.SetMassFromShapes();
_local3 = new b2RevoluteJointDef();
_local3.Initialize(aBody, oBody, aBody.GetWorldCenter());
joint = world.CreateJoint(_local3);
break;
};
}
}
}//package game.objects
Section 121
//Tile (game.objects.Tile)
package game.objects {
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
public class Tile {
const GRNDHGT:Number = 1;
const ALPHA:Number = 1;
private var tShape:b2Shape;
private var world:b2World;
private var _pos:b2Vec2;
private var _type:int;
private var board:DisplayObjectContainer;
private var tBodyDef:b2BodyDef;
private var tBody:b2Body;
private var tFlatDef:b2PolygonDef;
public static const FLATLAND_OBSTACLE_WARNING:int = 14;
public static const JUMP_LARGE:int = 8;
public static const FLATLAND_OBSTACLE:int = 12;
public static const GAP_LARGE:int = 11;
public static const MOGUL_LARGE:int = 3;
public static const GAP_SMALL:int = 9;
public static const FLATLAND_GAP_WARNING:int = 13;
public static const HILL_DOWN:int = 5;
public static const HILL_IN:int = 4;
public static const MOGUL_SMALL:int = 2;
public static const HILL_DOWN_EXT:int = 6;
public static const GAP_MED:int = 10;
public static const FLATLAND:int = 0;
public static const HILL_OUT:int = 7;
public static const MOGUL_SET:int = 1;
public function Tile(_arg1:int, _arg2:int, _arg3:int, _arg4:b2World, _arg5:DisplayObjectContainer){
this.world = _arg4;
this.board = _arg5;
_type = _arg1;
_pos = new b2Vec2((_arg2 / 30), (_arg3 / 30));
initTile();
}
function getTileSprite(_arg1:int):MovieClip{
var _local2:MovieClip;
switch (_arg1){
case FLATLAND:
_local2 = new t_Flatland();
break;
case FLATLAND_OBSTACLE:
_local2 = new t_Flatland_Obstacle();
break;
case FLATLAND_GAP_WARNING:
_local2 = new t_Flatland_GapWarning();
break;
case FLATLAND_OBSTACLE_WARNING:
_local2 = new t_Flatland_ObstacleWarning();
break;
};
return (_local2);
}
public function get pos():b2Vec2{
return (_pos);
}
public function get shape():b2Shape{
return (tShape);
}
function initTile():void{
var _local1:b2XForm;
var _local2:b2PolygonDef;
var _local3:b2XForm;
var _local4:b2PolygonDef;
var _local5:b2CircleDef;
var _local6:b2XForm;
var _local7:b2PolygonDef;
var _local8:b2CircleDef;
var _local9:b2XForm;
var _local10:b2PolygonDef;
var _local11:b2XForm;
var _local12:b2PolygonDef;
var _local13:b2CircleDef;
var _local14:b2CircleDef;
var _local15:b2PolygonDef;
var _local16:b2PolygonDef;
var _local17:b2PolygonDef;
var _local18:b2PolygonDef;
var _local19:b2PolygonDef;
var _local20:b2PolygonDef;
var _local21:b2CircleDef;
var _local22:b2PolygonDef;
var _local23:b2PolygonDef;
var _local24:b2PolygonDef;
var _local25:b2PolygonDef;
var _local26:b2PolygonDef;
var _local27:b2PolygonDef;
var _local28:b2PolygonDef;
switch (_type){
case FLATLAND:
case FLATLAND_OBSTACLE:
case FLATLAND_GAP_WARNING:
case FLATLAND_OBSTACLE_WARNING:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = getTileSprite(_type);
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "flatground";
tFlatDef.SetAsBox(10, 0.25);
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
break;
case MOGUL_SET:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Mogul_Set();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "flatground";
tFlatDef.SetAsBox(10, 0.25);
_local1 = new b2XForm();
_local2 = new b2PolygonDef();
_local2.userData = "mogulramp";
_local2.vertexCount = 4;
_local2.vertices[0] = b2Math.b2MulX(_local1, new b2Vec2(-8.8, 0));
_local2.vertices[1] = b2Math.b2MulX(_local1, new b2Vec2(-6.2, -1.5));
_local2.vertices[2] = b2Math.b2MulX(_local1, new b2Vec2(-5.5, -1.5));
_local2.vertices[3] = b2Math.b2MulX(_local1, new b2Vec2(-3.5, 0));
_local3 = new b2XForm();
_local4 = new b2PolygonDef();
_local4.userData = "mogulramp";
_local4.vertexCount = 4;
_local4.vertices[0] = b2Math.b2MulX(_local3, new b2Vec2(-3, 0));
_local4.vertices[1] = b2Math.b2MulX(_local3, new b2Vec2(-1, -0.9));
_local4.vertices[2] = b2Math.b2MulX(_local3, new b2Vec2(1, -0.9));
_local4.vertices[3] = b2Math.b2MulX(_local3, new b2Vec2(3, 0));
_local5 = new b2CircleDef();
_local5.userData = "mogultop";
_local5.localPosition.Set(0, 0.8);
_local5.radius = 2;
_local6 = new b2XForm();
_local7 = new b2PolygonDef();
_local7.userData = "mogulramp";
_local7.vertexCount = 4;
_local7.vertices[0] = b2Math.b2MulX(_local6, new b2Vec2(3.5, 0));
_local7.vertices[1] = b2Math.b2MulX(_local6, new b2Vec2(5.5, -0.9));
_local7.vertices[2] = b2Math.b2MulX(_local6, new b2Vec2(7.5, -0.9));
_local7.vertices[3] = b2Math.b2MulX(_local6, new b2Vec2(9.5, 0));
_local8 = new b2CircleDef();
_local8.userData = "mogultop";
_local8.localPosition.Set(6.5, 0.8);
_local8.radius = 2;
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
tBody.CreateShape(_local2);
tBody.CreateShape(_local4);
tBody.CreateShape(_local5);
tBody.CreateShape(_local7);
tBody.CreateShape(_local8);
break;
case MOGUL_SMALL:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Mogul_Small();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "flatground";
tFlatDef.SetAsBox(10, 0.25);
_local9 = new b2XForm();
_local10 = new b2PolygonDef();
_local10.userData = "mogulramp";
_local10.vertexCount = 4;
_local10.vertices[0] = b2Math.b2MulX(_local9, new b2Vec2(-4.25, 0));
_local10.vertices[1] = b2Math.b2MulX(_local9, new b2Vec2(-0.2, -1.8));
_local10.vertices[2] = b2Math.b2MulX(_local9, new b2Vec2(0.8, -1.8));
_local10.vertices[3] = b2Math.b2MulX(_local9, new b2Vec2(4.25, 0));
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
tBody.CreateShape(_local10);
break;
case MOGUL_LARGE:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Mogul_Large();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "flatground";
tFlatDef.SetAsBox(10, 0.25);
_local11 = new b2XForm();
_local12 = new b2PolygonDef();
_local12.userData = "mogulramp";
_local12.vertexCount = 4;
_local12.vertices[0] = b2Math.b2MulX(_local11, new b2Vec2(-6.25, 0));
_local12.vertices[1] = b2Math.b2MulX(_local11, new b2Vec2(-1.8, -3.1));
_local12.vertices[2] = b2Math.b2MulX(_local11, new b2Vec2(1.8, -3.1));
_local12.vertices[3] = b2Math.b2MulX(_local11, new b2Vec2(6.25, 0));
_local13 = new b2CircleDef();
_local13.userData = "mogultop";
_local13.localPosition.Set(0, 0.6);
_local13.radius = 4;
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
tBody.CreateShape(_local12);
tBody.CreateShape(_local13);
break;
case HILL_IN:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Hill_In();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "hillapproach";
tFlatDef.SetAsOrientedBox(9.25, 0.25, new b2Vec2(-0.75, 0));
_local14 = new b2CircleDef();
_local14.userData = "hilltop";
_local14.localPosition.Set(8.75, 1.5);
_local14.radius = 1.75;
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
tBody.CreateShape(_local14);
break;
case HILL_DOWN:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Hill_Down();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "hilldown";
tFlatDef.SetAsOrientedBox(8, 1, new b2Vec2(-5.2, -6), 0.86);
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
break;
case HILL_DOWN_EXT:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Hill_Down();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "hilldown";
tFlatDef.SetAsOrientedBox(8, 1, new b2Vec2(-5.2, -6), 0.86);
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
break;
case HILL_OUT:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Hill_Out();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "flatground";
tFlatDef.SetAsOrientedBox(10, 0.25);
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
break;
case JUMP_LARGE:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Jump();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
tFlatDef = new b2PolygonDef();
tFlatDef.userData = "flatground";
tFlatDef.SetAsBox(10, 0.25);
_local15 = new b2PolygonDef();
_local15.userData = "jump";
_local15.SetAsOrientedBox(4, 0.25, new b2Vec2(0, -0.4), 3);
_local16 = new b2PolygonDef();
_local16.userData = "jump";
_local16.SetAsOrientedBox(2, 0.25, new b2Vec2(2.9, -1.1), 2.8);
_local17 = new b2PolygonDef();
_local17.userData = "jump";
_local17.SetAsOrientedBox(2, 0.25, new b2Vec2(5.9, -2.6), 2.6);
_local18 = new b2PolygonDef();
_local18.userData = "jump";
_local18.SetAsOrientedBox(2, 0.25, new b2Vec2(7.8, -4), 2.3);
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(tFlatDef);
tBody.CreateShape(_local15);
tBody.CreateShape(_local16);
tBody.CreateShape(_local17);
tBody.CreateShape(_local18);
break;
case GAP_SMALL:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Gap_Small();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
_local19 = new b2PolygonDef();
_local19.userData = "flatground";
_local19.SetAsOrientedBox(4.5, 0.25, new b2Vec2(-6, 0));
_local20 = new b2PolygonDef();
_local20.userData = "flatground";
_local20.SetAsOrientedBox(4, 0.25, new b2Vec2(7, 0));
_local21 = new b2CircleDef();
_local21.userData = "endGap";
_local21.radius = 0.7;
_local21.localPosition.Set(3.3, 0.45);
_local22 = new b2PolygonDef();
_local22.userData = "gap";
_local22.SetAsOrientedBox(5, 4, new b2Vec2(0.6, 4.5));
_local22.isSensor = true;
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(_local19);
tBody.CreateShape(_local20);
tBody.CreateShape(_local22);
break;
case GAP_MED:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Gap_Med();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
_local23 = new b2PolygonDef();
_local23.userData = "flatground";
_local23.SetAsOrientedBox(2.5, 0.25, new b2Vec2(-7.5, 0));
_local24 = new b2PolygonDef();
_local24.userData = "flatground";
_local24.SetAsOrientedBox(2.5, 0.25, new b2Vec2(7.5, 0));
_local25 = new b2PolygonDef();
_local25.userData = "gap";
_local25.SetAsOrientedBox(10, 4, new b2Vec2(0, 4.8));
_local25.isSensor = true;
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(_local23);
tBody.CreateShape(_local24);
tBody.CreateShape(_local25);
break;
case GAP_LARGE:
tBodyDef = new b2BodyDef();
tBodyDef.position.Set(pos.x, pos.y);
tBodyDef.userData = new t_Gap_Large();
tBodyDef.userData.x = (tBodyDef.position.x * 30);
tBodyDef.userData.y = (tBodyDef.position.y * 30);
tBodyDef.userData.alpha = ALPHA;
board.addChildAt(tBodyDef.userData, 0);
_local26 = new b2PolygonDef();
_local26.userData = "flatground";
_local26.SetAsOrientedBox(0.25, 0.25, new b2Vec2(-9.75, 0));
_local27 = new b2PolygonDef();
_local27.userData = "flatground";
_local27.SetAsOrientedBox(0.25, 0.25, new b2Vec2(9.75, 0));
_local28 = new b2PolygonDef();
_local28.userData = "gap";
_local28.SetAsOrientedBox(14, 4, new b2Vec2(0, 5));
_local28.isSensor = true;
tBody = world.CreateBody(tBodyDef);
tShape = tBody.CreateShape(_local26);
tBody.CreateShape(_local27);
tBody.CreateShape(_local28);
break;
};
}
public function cleanup():void{
var _local1:DisplayObject;
var _local2:DisplayObject;
_local1 = (tBody.GetUserData() as DisplayObject);
if (board.contains(_local1)){
_local2 = board.removeChild(_local1);
};
world.DestroyBody(tBody);
}
public function get type():int{
return (_type);
}
public function moveTo(_arg1:Number, _arg2:Number):void{
_pos = new b2Vec2(_arg1, _arg2);
tBody.SetXForm(new b2XForm(_pos, new b2Mat22(tBody.GetAngle())));
tBody.GetUserData().x = (tBody.GetPosition().x * 30);
tBody.GetUserData().y = (tBody.GetPosition().y * 30);
}
}
}//package game.objects
Section 122
//BlastSnow (game.particles.BlastSnow)
package game.particles {
import flash.geom.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.actions.*;
public class BlastSnow extends Emitter2D {
public function BlastSnow(){
counter = new Blast(50);
addInitializer(new ImageClass(SnowBoardParticle));
addInitializer(new Lifetime(1));
addInitializer(new ScaleImageInit(0.3, 0.4));
addInitializer(new Velocity(new DiscSectorZone(new Point(0, 6), 40, 10, -(Math.PI), 0)));
addInitializer(new Position(new DiscZone(new Point(0, 6), 20)));
addAction(new Age());
addAction(new Move());
addAction(new Fade(1, 0));
addAction(new ScaleImage(0.4, 1));
}
}
}//package game.particles
Section 123
//RiderSnow (game.particles.RiderSnow)
package game.particles {
import flash.geom.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.actions.*;
public class RiderSnow extends Emitter2D {
public function RiderSnow(){
counter = new Steady(30);
addInitializer(new ImageClass(SnowBoardParticle));
addInitializer(new Lifetime(0.3));
addInitializer(new Position(new LineZone(new Point(-50, 10), new Point(-15, 10))));
addInitializer(new ScaleImageInit(0.2, 0.3));
addAction(new Age());
addAction(new Move());
addAction(new Fade(1, 0));
addAction(new ScaleImage(0.3, 1));
}
}
}//package game.particles
Section 124
//SnowBoardParticle (game.particles.SnowBoardParticle)
package game.particles {
import flash.display.*;
import flash.filters.*;
public class SnowBoardParticle extends Sprite {
public function SnowBoardParticle(){
var _local1:MovieClip;
var _local2:BlurFilter;
var _local3:Array;
super();
_local1 = new snowParticle();
_local2 = new BlurFilter(1.5, 1.5, 1);
_local3 = [_local2];
_local1.filters = _local3;
addChild(_local1);
}
}
}//package game.particles
Section 125
//SnowFlake (game.particles.SnowFlake)
package game.particles {
import flash.display.*;
import base.utils.*;
public class SnowFlake extends Sprite {
public function SnowFlake(){
var _local1:Array;
var _local2:MovieClip;
super();
_local1 = [new snowflake_mc1(), new snowflake_mc2(), new snowflake_mc3(), new snowflake_mc4(), new snowflake_mc5(), new snowflake_mc6()];
_local2 = (_local1[RandomNumber.nextIntRange(0, (_local1.length - 1))] as MovieClip);
addChild(_local2);
}
}
}//package game.particles
Section 126
//TumbleSnow (game.particles.TumbleSnow)
package game.particles {
import flash.geom.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.actions.*;
public class TumbleSnow extends Emitter2D {
public function TumbleSnow(){
counter = new Steady(50);
addInitializer(new ImageClass(SnowBoardParticle));
addInitializer(new Lifetime(1));
addInitializer(new ScaleImageInit(0.3, 0.4));
addInitializer(new Velocity(new DiscSectorZone(new Point(0, 6), 40, 10, -(Math.PI), 0)));
addInitializer(new Position(new DiscZone(new Point(0, 6), 10)));
addAction(new Age());
addAction(new Move());
addAction(new Fade(1, 0));
addAction(new ScaleImage(0.4, 1));
}
}
}//package game.particles
Section 127
//WorldSnow (game.particles.WorldSnow)
package game.particles {
import flash.geom.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.actions.*;
public class WorldSnow extends Emitter2D {
public var velSetter:TargetVelocity;
public function WorldSnow(){
var _local1:MultiZone;
super();
counter = new Steady(50);
addInitializer(new ImageClass(SnowFlake));
_local1 = new MultiZone();
_local1.addZone(new LineZone(new Point(-250, -10), new Point(600, -10)));
_local1.addZone(new LineZone(new Point(610, 100), new Point(610, 300)));
addInitializer(new Position(_local1));
addInitializer(new ScaleImageInit(0.25, 1));
addAction(new Move());
addAction(new DeathZone(new RectangleZone(0, -10, 1000, 400), true));
}
}
}//package game.particles
Section 128
//GameOver (game.states.GameOver)
package game.states {
import flash.display.*;
import base.display.*;
import base.*;
import flash.events.*;
import flash.utils.*;
import base.animation.*;
import game.*;
import flash.text.*;
public class GameOver extends GameState {
var scr_GameOver:MovieClip;
var btn_PlayAgain:SimpleButton;
var txt_FinalScore:TextField;
var playAgain:Boolean;
var transition:SpriteEntity;
var anim_Transition:SpriteAnimator;
var step:Function;
var pauseTimer:Timer;
var scr_Transition:MovieClip;
var num_FinalScore:Number;
public function GameOver(_arg1:GameEntry, _arg2:GameManager){
super(_arg1, _arg2);
}
function waitForTopScore():void{
if (gameContext.isTopScoreFinished()){
btn_PlayAgain.addEventListener(MouseEvent.MOUSE_UP, handlePlayButton, false, 0, true);
step = waitForPlayAgain;
};
}
function waitForTransitionOut():void{
var _local1:int;
if (scr_Transition != null){
_local1 = anim_Transition.animateSprite();
if (_local1 == 1){
gameData._screen.removeChild(scr_Transition);
scr_Transition = null;
};
} else {
pauseTimer.start();
step = pauseForUserToReadScore;
};
}
public function handlePlayButton(_arg1:Event):void{
playAgain = true;
}
function waitForTransition():void{
var _local1:int;
_local1 = transition.animateSprite();
if (_local1 == 1){
if (gameData._screen.contains(scr_GameOver)){
gameData._screen.removeChild(scr_GameOver);
};
snd.stopAllSounds();
gameManager.setNextState(GamePlay);
};
}
override public function Entry():void{
trace((this + " @ --> ENTER"));
step = new Function();
num_FinalScore = gameData.finalScore;
Achievements.SetScore(num_FinalScore);
Achievements.Ended();
scr_GameOver = new scrn_EndScreen();
txt_FinalScore = (scr_GameOver.getChildByName("_txtScore") as TextField);
txt_FinalScore.text = String(num_FinalScore);
btn_PlayAgain = (scr_GameOver.getChildByName("btn_Play") as SimpleButton);
gameData._screen.addChildAt(scr_GameOver, 0);
pauseTimer = new Timer(2000, 1);
pauseTimer.addEventListener(TimerEvent.TIMER_COMPLETE, pauseForUserToReadScore, false, 0, true);
step = startTransitionOut;
}
function waitForPlayAgain():void{
if (playAgain){
gameData.finalScore = 0;
gameData.gameReplay = true;
transition = new SpriteEntity(gameContext, "scrn_SnowTransition", gameData._screen);
transition.getMovieClip().name = "replayTransition";
transition.startAnimating(AnimationData.SCRN_TRANS_IN.start, AnimationData.SCRN_TRANS_IN.end, AnimationData.SCRN_TRANS_IN.loop);
step = waitForTransition;
};
}
override public function Update():void{
step();
}
public function toString():String{
return ("GameOver()");
}
function startTransitionOut():void{
scr_Transition = (gameData._screen.getChildByName("transition") as MovieClip);
if (scr_Transition != null){
anim_Transition = new SpriteAnimator(gameContext, scr_Transition);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_OUT.start, AnimationData.SCRN_TRANS_OUT.end, false);
};
step = waitForTransitionOut;
}
function pauseForUserToReadScore(_arg1:TimerEvent=null):void{
if (_arg1 != null){
pauseTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, pauseForUserToReadScore);
pauseTimer = null;
gameContext.submitScore(num_FinalScore);
step = waitForTopScore;
};
}
override public function Exit():void{
trace((this + " @ <-- EXIT"));
}
}
}//package game.states
Section 129
//GamePlay (game.states.GamePlay)
package game.states {
import flash.display.*;
import base.ui.*;
import base.display.*;
import base.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import game.collision.*;
import Box2D.Collision.*;
import base.animation.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.counters.*;
import base.utils.*;
import game.*;
import game.objects.*;
import org.flintparticles.twoD.emitters.*;
import flash.text.*;
import game.particles.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.renderers.*;
public class GamePlay extends GameState {
const hill_lg:Array;
const mogul_lg:Array;
const hill_md:Array;
const gap_sm:Array;
const LNK_HUD_CONFETTI:String = "CONFETTI";
const KEY_UP:int = 38;
const TILE_WIDTH:Number = 600;
const KEY_DEBUG_TOGGLE:int = 32;
const hill_xlg:Array;
const hill_sm:Array;
const mogul_sm:Array;
const WRAP_WIDTH:Number = 6000;
const LNK_HUD_WINDVANE:String = "WINDVANE";
const LNK_HUD_TRICK_FLAGS:String = "TRICK_FLAGS";
const LNK_HUD_SCORE_1:String = "TRICK_SCORE_1S";
const KEY_LEFT:int = 37;
const LNK_HUD_SCORE_3:String = "TRICK_SCORE_100S";
const LNK_HUD_SCORE_4:String = "TRICK_SCORE_1000S";
const LNK_HUD_SCORE_5:String = "TRICK_SCORE_10000S";
const LNK_HUD_SCORE_2:String = "TRICK_SCORE_10S";
const LNK_HUD_STEAM:String = "STEAM";
const mogul_set:Array;
const FLIPS_WOW:int = 9;
const LNK_HUD_PISTONS:String = "PISTONS";
const FLIPS_NICE:int = 5;
const obstacle:Array;
const FLIPS_GREAT:int = 3;
const KEY_DOWN:int = 40;
const LNK_HUD_TRICK_METER:String = "TRICK_METER";
const KEY_DEBUG_PAUSE:int = 80;
const FLIPS_SWEET:int = 7;
const jump_lg:Array;
const LNK_HUD_HEIGHT_METER:String = "HEIGHT_METER";
const flat:Array;
const gap_lg:Array;
const gap_md:Array;
const hill_xxlg:Array;
const LNK_HUD_TRICK_METER_ALERT:String = "TRICK_METER_ALERT";
const TILE_HEIGHT:Number = 400;
const FLIPS_GOOD:int = 1;
const KEY_RIGHT:int = 39;
var m_physScale:Number;// = 30
var hud_Windvane:SpriteEntity;
var curTileToRiderDY:Number;
var frTik:int;
var buttonPress:Boolean;// = false
var nextTileX:int;
var nextTileY:int;
var riderIsCrashing:Boolean;// = false
var screenLayer:Sprite;
var hud_ScoreDisplay:Array;
var m_iterations:int;// = 10
var segEnd:b2Vec2;
var riderTumbleEmitter:Sprite;
var tileUnderFoot:Tile;
var scorPopUp:MovieClip;
var hud_TrickMeter:MovieClip;
var airLZ:LineZone;
var b2SetV:b2Vec2;
var anim_Transition:SpriteAnimator;
var snowEmitter:Emitter2D;
var velSetCur:b2Vec2;
var jumpCharge:Number;// = -10
var gameTimeTotalSecs:int;// = 0
var speedMin:Number;// = 12
var dbgDraw:b2DebugDraw;
var btn_Press:SimpleButton;
var hud_btnShowInstruct:SimpleButton;
var velSetMin:b2Vec2;
var curAngleDeg:Number;// = 0
var angleLock:Boolean;// = true
var numDigitsFinished:int;// = 0
var numDigitsAnimating:int;// = 0
var jumpActive:Boolean;
var scr_Instruct:MovieClip;
var spawnPos:b2Vec2;
var totalTimeScore:int;// = 0
var riderOnGround:Boolean;// = false
var speedAtCrash:Number;
var normal:b2Vec2;
var safeToLand:Boolean;// = true
var hud:MovieClip;
var frCnt:int;
var riderBoardContacts:ContactListener;
var tilesOnBoard:Array;
var hud_btnMusicToggleOff:SimpleButton;
var segStart:b2Vec2;
var curTile:Tile;
var riderInGap:Boolean;// = false
var riderX:Number;
var riderY:Number;
var anim_Story:SpriteAnimator;
var riderBoardCollisions:CollisionListener;
var scorPopUpText:TextField;
var scrnAnimComplete:int;// = 0
var curVel:b2Vec2;
var m_world:b2World;
var riderBoardEmitter:Sprite;
var timeScoreDisplay:TextField;
var riderTumbleLoop:SoundChannel;
var riderBoardLoop:SoundChannel;
var curTilesetLib:Array;
var riderCrashEmitter:Sprite;
var distRiderToTile:Number;
private var riderSnowEmitter:Emitter2D;
var curRotationIndex:int;// = 0
var colHandler:CollisionHandler;
var vShift:Number;// = 0
var scr_Transition:MovieClip;
var crashSnow:BlastSnow;
var floorY:Number;// = 0
var riderSprite:SpriteEntity;
var airSnow:RiderSnow;
var tumbleSnow:TumbleSnow;
var riderAnimComplete:int;
var scorPopUpAnim:SpriteAnimator;
var hud_TotalScore:TextField;
var riderState:Function;
var totalResourceScore:int;// = 100
var hudDigitLoop:SoundChannel;
var digitSpinLoop:SoundChannel;
var jumpMax:Number;// = -55
var hud_Score_1:SpriteEntity;
var hud_Score_2:SpriteEntity;
var hud_Score_3:SpriteEntity;
var hud_Score_4:SpriteEntity;
var hud_Score_5:SpriteEntity;
var totalNumTilesCreated:int;// = 0
var tokenScoreDisplay:TextField;
var gameTimer:Timer;
var riderBoardShape:b2Shape;
var scr_Story:MovieClip;
var rider:b2Body;
var totalTokenScore:int;// = 0
var totalCompletedFlips:int;// = 0
var riderHeadCollisions:CollisionListener;
var debugVisible:Boolean;// = false
var riderIsDucking:Boolean;// = false
var gameOverMode:Boolean;// = false
var hud_Pistons:SpriteEntity;
var hud_ScoreDigitClips:Array;
var m_timeStep:Number;// = 0.0333333333333333
var step:Function;
var totalGameScore:int;// = 0
var flipScoreDisplay:TextField;
var hud_btnMusicToggleOn:SimpleButton;
var board:Sprite;
var hud_Confetti:SpriteEntity;
var riderCrashEmitter2:Sprite;
var boardLZ:LineZone;
var gameOverTimer:int;// = 0
var angleLandMaxDeg:Number;// = 300
var wrapWidthScaled:Number;
var riderSnowVelocity:Velocity;
var stepb:int;// = 0
var camera:GameCamera;
var curTileContact:Contact;
var trickNum:int;// = 1
var riderAirLoop:SoundChannel;
var gameOverTiles:Boolean;// = false
var numCompletedFlips:int;// = 0
var jumpMin:Number;// = -25
var totalFlipScore:int;// = 0
var hud_HeightMeter:MovieClip;
var segment:b2Segment;
var totalTimeDisplay:TextField;
var angleLandMinDeg:Number;// = 40
var hud_TrickFlags:SpriteEntity;
var raycastOffsetX:int;// = 4
var snowVelocity:TargetVelocity;
var speedMax:Number;// = 30
var hud_TrickMeterAlert:SpriteEntity;
var crashSnow2:BlastSnow;
var velocityLock:Boolean;// = true
var riderOnObstacle:Boolean;// = false
var gamePaused:Boolean;// = false
var lambda;
var anim_Instruct:SpriteAnimator;
var input:Input;
var dbgSprite:Sprite;
var gameEndWarning:Boolean;// = false
var tileMap:Array;
var scr_Title:MovieClip;
var obstaclesOnBoard:Array;
var gameOver:Boolean;// = false
var riderIsSpawning:Boolean;// = false
var hud_Steam:SpriteEntity;
var angleCurVel:Number;// = 0
var curPos:b2Vec2;
var reticuleDisplay:MovieClip;
var entityAnimator:SpriteEntityAnimator;
static const TRICK_1:int = 1;
static const TRICK_2:int = 2;
static const TRICK_3:int = 3;
public function GamePlay(_arg1:GameEntry, _arg2:GameManager){
gamePaused = false;
debugVisible = false;
gameTimeTotalSecs = 0;
m_iterations = 10;
m_physScale = 30;
m_timeStep = (1 / 30);
riderInGap = false;
riderOnGround = false;
riderOnObstacle = false;
riderIsDucking = false;
riderIsCrashing = false;
riderIsSpawning = false;
velocityLock = true;
jumpMin = -25;
jumpMax = -55;
jumpCharge = -10;
speedMin = 12;
speedMax = 30;
curPos = new b2Vec2();
spawnPos = new b2Vec2();
curVel = new b2Vec2();
velSetCur = new b2Vec2(speedMin, 1);
velSetMin = new b2Vec2(speedMin, 1);
angleLock = true;
safeToLand = true;
curAngleDeg = 0;
angleCurVel = 0;
angleLandMinDeg = 40;
angleLandMaxDeg = 300;
trickNum = 1;
curRotationIndex = 0;
numCompletedFlips = 0;
totalCompletedFlips = 0;
totalResourceScore = 100;
totalGameScore = 0;
totalTimeScore = 0;
totalFlipScore = 0;
totalTokenScore = 0;
wrapWidthScaled = (WRAP_WIDTH / m_physScale);
tilesOnBoard = new Array();
totalNumTilesCreated = 0;
flat = [Tile.FLATLAND, Tile.FLATLAND, Tile.FLATLAND];
mogul_set = [Tile.FLATLAND, Tile.MOGUL_SET, Tile.FLATLAND];
mogul_sm = [Tile.FLATLAND, Tile.MOGUL_SMALL, Tile.FLATLAND];
mogul_lg = [Tile.FLATLAND, Tile.MOGUL_LARGE, Tile.FLATLAND, Tile.FLATLAND, Tile.FLATLAND];
hill_sm = [Tile.HILL_IN, Tile.HILL_DOWN, Tile.HILL_OUT, Tile.FLATLAND];
hill_md = [Tile.HILL_IN, Tile.HILL_DOWN, Tile.HILL_DOWN_EXT, Tile.HILL_OUT, Tile.FLATLAND, Tile.FLATLAND];
hill_lg = [Tile.HILL_IN, Tile.HILL_DOWN, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_OUT, Tile.FLATLAND, Tile.FLATLAND, Tile.FLATLAND];
hill_xlg = [Tile.HILL_IN, Tile.HILL_DOWN, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_OUT, Tile.FLATLAND, Tile.FLATLAND, Tile.FLATLAND];
hill_xxlg = [Tile.HILL_IN, Tile.HILL_DOWN, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_DOWN_EXT, Tile.HILL_OUT, Tile.FLATLAND, Tile.FLATLAND, Tile.FLATLAND];
jump_lg = [Tile.FLATLAND, Tile.JUMP_LARGE, Tile.HILL_IN, Tile.HILL_DOWN, Tile.HILL_OUT, Tile.FLATLAND, Tile.FLATLAND, Tile.FLATLAND];
gap_sm = [Tile.FLATLAND_GAP_WARNING, Tile.GAP_SMALL, Tile.FLATLAND];
gap_md = [Tile.FLATLAND_GAP_WARNING, Tile.GAP_MED, Tile.FLATLAND];
gap_lg = [Tile.FLATLAND_GAP_WARNING, undefined, Tile.GAP_LARGE, Tile.FLATLAND];
obstacle = [Tile.FLATLAND_OBSTACLE_WARNING, Tile.FLATLAND_OBSTACLE];
obstaclesOnBoard = [];
hud_ScoreDigitClips = [];
hud_ScoreDisplay = [0, 0, 0, 0, 0];
scrnAnimComplete = 0;
buttonPress = false;
stepb = 0;
b2SetV = new b2Vec2();
numDigitsAnimating = 0;
numDigitsFinished = 0;
gameOver = false;
gameOverTimer = 0;
gameOverTiles = false;
gameOverMode = false;
gameEndWarning = false;
lambda = [1];
normal = new b2Vec2();
segStart = new b2Vec2();
segEnd = new b2Vec2();
segment = new b2Segment();
raycastOffsetX = 4;
floorY = 0;
vShift = 0;
super(_arg1, _arg2);
}
function riderInGapEnter():void{
Achievements.AddWipeout();
stopAirLoopSfx();
stopTumbleLoopSfx();
stopBoardLoopSfx();
stopRiderSnow();
stopTumbleSnow();
zeroOutFlipCounter();
jumpActive = false;
jumpCharge = jumpMin;
angleLock = false;
velocityLock = false;
riderIsDucking = false;
riderIsCrashing = true;
camera.shouldFollowTarget = false;
speedAtCrash = calulateSpeedDamage();
velSetCur.y = 8;
rider.SetLinearVelocity(velSetCur);
spawnPos.x = (curTileContact._shape2.GetBody().GetPosition().x + 7);
spawnPos.y = (curTileContact._shape2.GetBody().GetPosition().y - 3);
snd.playSoundByEvent(SoundData.SFX_HERO_FALL_OFFSCREEN);
riderSprite.startAnimating(AnimationData.FALL_IN_GAP.start, AnimationData.FALL_IN_GAP.end, AnimationData.FALL_IN_GAP.loop);
camera.setTruckSpeedX(0.2);
camera.setTruckSpeedY(0.2);
setSnowVelocityZero();
setFramesDelay(15);
riderState = riderInGapUpdate;
}
function addNextTile():void{
var _local1:int;
var _local2:int;
if (tileMap.length == 0){
if (((gameOverMode) && ((gameOverTiles == false)))){
tileMap = tileMap.concat(flat);
gameOverTiles = true;
} else {
_local2 = RandomNumber.nextIntRange(1, curTilesetLib.length);
tileMap = tileMap.concat(curTilesetLib[(_local2 - 1)]);
};
};
if (tileMap[0] == Tile.FLATLAND_GAP_WARNING){
if ((nextTileX + TILE_WIDTH) >= (WRAP_WIDTH - 900)){
_local1 = Tile.FLATLAND;
} else {
_local1 = tileMap.shift();
};
} else {
_local1 = tileMap.shift();
};
if (_local1 == Tile.HILL_DOWN){
nextTileX = (nextTileX + TILE_WIDTH);
nextTileY = (nextTileY + TILE_HEIGHT);
} else {
if (_local1 == Tile.HILL_DOWN_EXT){
nextTileX = (nextTileX + 300);
nextTileY = (nextTileY + 350);
} else {
if (_local1 == Tile.HILL_OUT){
nextTileX = (nextTileX + (TILE_WIDTH / 2));
} else {
nextTileX = (nextTileX + TILE_WIDTH);
};
};
};
if (_local1 == Tile.FLATLAND_OBSTACLE){
obstaclesOnBoard.push(new Obstacle(Obstacle.GENERIC, nextTileX, (nextTileY - 130), m_world, board));
};
if (_local1 == Tile.GAP_SMALL){
if (curVel.x > 21){
_local1 = Tile.GAP_LARGE;
} else {
if (curVel.x > 14){
_local1 = Tile.GAP_MED;
};
};
};
tilesOnBoard.push(new Tile(_local1, nextTileX, nextTileY, m_world, board));
totalNumTilesCreated++;
}
function riderInAirFlipping():void{
if (riderInGap){
riderState = riderInGapEnter;
return;
};
if (curAngleDeg <= angleLandMinDeg){
if (curRotationIndex > angleLandMinDeg){
numCompletedFlips++;
curRotationIndex = 0;
if (numCompletedFlips > 5){
trickNum = RandomNumber.nextIntRange(TRICK_1, TRICK_3);
} else {
if (numCompletedFlips == 4){
trickNum = TRICK_2;
} else {
if (numCompletedFlips == 3){
trickNum = TRICK_3;
} else {
if (numCompletedFlips == 2){
trickNum = TRICK_1;
} else {
if (numCompletedFlips == 1){
trickNum = TRICK_2;
};
};
};
};
};
startTrickAnimation(trickNum);
showScorePopUp(("Flip x " + numCompletedFlips), riderX, riderY);
snd.playSoundByEvent(SoundData.SFX_SPIN_MULTIPLIER);
};
} else {
curRotationIndex = curAngleDeg;
};
if (riderOnGround == true){
stopAirLoopSfx();
if (isRiderSafeToLand()){
safeToLand = true;
doRiderFlipScore();
zeroOutFlipCounter();
velSetCur.x = ((velSetCur.x)<speedMax) ? (velSetCur.x + 1) : speedMax;
velSetCur.y = curVel.y;
rider.SetLinearVelocity(velSetCur);
changeSnowVelocity();
startBoardLoopSfx();
startRiderSnow();
angleLock = true;
riderSprite.startAnimating(AnimationData.IDLE.start, AnimationData.IDLE.end, AnimationData.IDLE.loop);
riderState = riderOnGroundIdle;
} else {
safeToLand = false;
zeroOutFlipCounter();
startCrashSnow();
rider.SetPositionAndAngle(curPos, 0);
riderState = riderStartCrash;
Achievements.AddWipeout();
};
return;
};
if (Input.mouseReleased){
rider.SetAngularVelocity(0);
if (isRiderSafeToLand()){
safeToLand = true;
riderSprite.startAnimating(AnimationData.SPINSTOP_GOOD.start, AnimationData.SPINSTOP_GOOD.end, AnimationData.SPINSTOP_GOOD.loop);
} else {
safeToLand = false;
riderSprite.startAnimating(AnimationData.SPINSTOP_BAD.start, AnimationData.SPINSTOP_BAD.end, AnimationData.SPINSTOP_BAD.loop);
};
riderState = riderInAirStopFlipping;
};
}
function update_Instruct():void{
if (buttonPress){
buttonPress = false;
step = exit_Instruct;
};
}
function removeOldObstacles():void{
var _local1:int;
var _local2:Obstacle;
var _local3:Number;
var _local4:Number;
_local1 = obstaclesOnBoard.length;
while (_local1--) {
_local2 = obstaclesOnBoard[_local1];
_local3 = (_local2.pos.x * m_physScale);
_local4 = (camera.currCamX - 900);
if (_local3 < _local4){
obstaclesOnBoard.splice(_local1, 1);
_local2.cleanup();
_local2 = null;
};
};
}
function moveObstaclesToStart():void{
var _local1:int;
var _local2:Obstacle;
var _local3:Number;
var _local4:Number;
_local1 = obstaclesOnBoard.length;
while (_local1--) {
_local2 = obstaclesOnBoard[_local1];
_local3 = (_local2.pos.x - wrapWidthScaled);
_local4 = (_local2.pos.y - vShift);
_local2.moveTo(_local3, _local4);
};
}
function hideScorePopUp(_arg1:AnimationEvent=null):void{
scorPopUp.gotoAndStop(1);
scorPopUp.x = -100;
scorPopUp.y = -100;
}
function stopAirLoopSfx():void{
if (riderAirLoop){
snd.stopSound(riderAirLoop);
};
}
function showScorePopUp(_arg1:String, _arg2:Number, _arg3:Number):void{
var _local4:Point;
scorPopUpText.text = _arg1;
_local4 = board.localToGlobal(new Point(_arg2, (_arg3 - 120)));
scorPopUp.x = _local4.x;
scorPopUp.y = _local4.y;
scorPopUpAnim.startAnimating(1, 30);
}
override public function Entry():void{
trace((this + " @ --> ENTER"));
gameData.init();
screenLayer = gameData._screen;
input = new Input(gameData._world);
gameContext.setQuality(StageQuality.MEDIUM);
entityAnimator = new SpriteEntityAnimator();
step = new Function();
if (gameData.gameReplay){
step = startFromReplay;
} else {
Achievements.Loaded();
step = startFromTitle;
};
}
function isRiderSafeToLand():Boolean{
if ((((curAngleDeg >= angleLandMaxDeg)) || ((curAngleDeg <= angleLandMinDeg)))){
return (true);
};
return (false);
}
function startAirLoopSfx():void{
if (!snd.soundIsPlaying(SoundData.SFX_AIRBOURNE_LOOP)){
riderAirLoop = snd.playSoundByEvent(SoundData.SFX_AIRBOURNE_LOOP);
};
}
function enter_Story():void{
switch (stepb){
case 0:
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
anim_Instruct.moveToFrame(1);
screenLayer.addChildAt(scr_Story, 0);
anim_Story.moveToFrame(1);
if (screenLayer.contains(scr_Instruct)){
screenLayer.removeChild(scr_Instruct);
anim_Instruct.moveToFrame(1);
};
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_OUT.start, AnimationData.SCRN_TRANS_OUT.end, false);
stepb = 1;
};
break;
case 1:
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
initPlayButton(scr_Story);
if (screenLayer.contains(scr_Transition)){
screenLayer.removeChild(scr_Transition);
};
stepb = 0;
step = update_Story;
};
break;
};
}
function riderOnGroundSlide():void{
riderTumbleEmitter.x = riderX;
riderTumbleEmitter.y = riderY;
if (riderInGap){
riderState = riderInGapEnter;
return;
};
if (riderOnGround == false){
stopBoardLoopSfx();
stopTumbleLoopSfx();
startAirLoopSfx();
stopTumbleSnow();
riderSprite.startAnimating(AnimationData.TUMBLE.start, AnimationData.TUMBLE.end, AnimationData.TUMBLE.loop);
riderState = riderCrashTumble;
return;
};
velSetCur.y = ((velSetCur.y)<0) ? 0 : curVel.y;
if (velSetCur.x > 0){
velSetCur.x = (velSetCur.x - 0.5);
};
rider.SetLinearVelocity(velSetCur);
changeSnowVelocity();
if (((riderAnimComplete) && ((velSetCur.x < 1)))){
stopBoardLoopSfx();
stopTumbleLoopSfx();
stopTumbleSnow();
snd.playSoundByEvent(SoundData.SFX_FACEPLANT_TUMBLE_END);
riderSprite.startAnimating(AnimationData.TUMBLE3.start, AnimationData.TUMBLE3.end, AnimationData.TUMBLE3.loop);
riderState = riderFinishSlide;
};
}
function riderInAirStopFlipping():void{
if (riderInGap){
riderState = riderInGapEnter;
return;
};
if (riderOnGround == true){
stopAirLoopSfx();
if (safeToLand){
doRiderFlipScore();
zeroOutFlipCounter();
velSetCur.x = ((velSetCur.x)<speedMax) ? (velSetCur.x + 1) : speedMax;
velSetCur.y = curVel.y;
rider.SetLinearVelocity(velSetCur);
changeSnowVelocity();
startBoardLoopSfx();
startRiderSnow();
angleLock = true;
riderSprite.startAnimating(AnimationData.IDLE.start, AnimationData.IDLE.end, AnimationData.IDLE.loop);
riderState = riderOnGroundIdle;
} else {
zeroOutFlipCounter();
startCrashSnow();
rider.SetPositionAndAngle(curPos, 0);
riderState = riderStartCrash;
Achievements.AddWipeout();
};
};
if (Input.mouseDown){
if (checkMouseArea()){
angleLock = false;
rider.SetAngularVelocity(angleCurVel);
startTrickAnimation(trickNum);
riderState = riderInAirFlipping;
return;
};
};
}
function setVShift():void{
var _local1:Tile;
var _local2:Number;
_local1 = tilesOnBoard[0];
_local2 = _local1.pos.y;
vShift = (_local2 - 10);
}
function updateObstacleSprites():void{
var _local1:int;
var _local2:Obstacle;
_local1 = obstaclesOnBoard.length;
while (_local1--) {
_local2 = obstaclesOnBoard[_local1];
_local2.updateSprite();
};
}
function initPlayButton(_arg1:MovieClip):void{
btn_Press = (_arg1.getChildByName("btn_Play") as SimpleButton);
btn_Press.addEventListener(MouseEvent.MOUSE_UP, handleButtonPress, false, 0, true);
}
function riderInGapUpdate():void{
if (((getFramesDelay(frTik++)) && ((riderInGap == false)))){
riderSprite.setVisibility(false);
rider.SetPositionAndAngle(spawnPos, 0);
rider.PutToSleep();
angleLock = true;
velocityLock = true;
camera.shouldFollowTarget = true;
riderIsSpawning = true;
riderState = riderGapRespawn;
};
}
function startGamePlay():void{
trace((this + ".startGamePlay()"));
Achievements.Started();
gameContext.stage.stageFocusRect = false;
gameContext.stage.focus = gameData._world;
gameTimer.start();
hud_Windvane.startAnimating(AnimationData.HUD_WINDVANE.start, AnimationData.HUD_WINDVANE.end, AnimationData.HUD_WINDVANE.loop);
entityAnimator.addSpriteToAnimate(hud_Windvane);
riderSprite.startAnimating(AnimationData.JUMP_LAND.start, AnimationData.JUMP_LAND.end, true);
rider.SetLinearVelocity(new b2Vec2(speedMin, 0));
screenLayer.x = 600;
snd.playMusic(SoundData.getSoundLinkage(SoundData.MUSIC_GAMELOOP));
}
function riderOnGroundIdle():void{
angleLock = true;
velocityLock = true;
riderBoardEmitter.x = riderX;
riderBoardEmitter.y = riderY;
riderBoardEmitter.rotation = curAngleDeg;
if (riderInGap){
stopBoardLoopSfx();
riderState = riderInGapEnter;
return;
};
if (gameOver){
stopBoardLoopSfx();
riderState = riderStartCrash;
return;
};
if (riderOnGround == false){
stopRiderSnow();
startAirLoopSfx();
stopBoardLoopSfx();
jumpActive = false;
jumpCharge = jumpMin;
zeroOutFlipCounter();
riderState = riderInAirIdle;
return;
};
if (Input.mouseDown){
if (checkMouseArea()){
riderIsDucking = true;
snd.playSoundByEvent(SoundData.SFX_HERO_DUCK);
riderState = riderOnGroundCrouching;
};
};
}
function waitForTransitionToInstructionIn():void{
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
initPlayButton(scr_Instruct);
screenLayer.addChildAt(scr_Instruct, 0);
scrnAnimComplete = 0;
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_OUT.start, AnimationData.SCRN_TRANS_OUT.end, false);
step = waitForTransitionToInstructionOut;
};
}
function startRiderSnow():void{
setNewBoardSnowVelocity();
if (riderSnowEmitter.running == false){
riderSnowEmitter.start();
} else {
riderSnowEmitter.counter.resume();
};
}
function waitForTransitionToInstructionOut():void{
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
buttonPress = false;
if (screenLayer.contains(scr_Transition)){
screenLayer.removeChild(scr_Transition);
};
scr_Instruct.play();
step = instructionPause;
};
}
function setAirBoardSnowVelocity():void{
airLZ.endX = (velSetCur.x * 10);
airSnow.start();
}
override public function Update():void{
step();
if (m_world){
m_world.Step(m_timeStep, m_iterations, m_iterations);
};
Input.update();
entityAnimator.Update();
}
function riderRollToGameOver():void{
riderTumbleEmitter.x = riderX;
riderTumbleEmitter.y = riderY;
if (velSetCur.x > 0){
velSetCur.x = (velSetCur.x - 0.5);
};
rider.SetLinearVelocity(new b2Vec2(velSetCur.x, curVel.y));
changeSnowVelocity();
if (velSetCur.x < 1){
stopTumbleLoopSfx();
setSnowVelocityZero();
velSetCur.x = 0;
velSetCur.y = 0;
rider.SetLinearVelocity(velSetCur);
riderSprite.startAnimating(AnimationData.RIDER_VICTORY_DANCE.start, AnimationData.RIDER_VICTORY_DANCE.end, AnimationData.RIDER_VICTORY_DANCE.loop);
stopRiderSnow();
stopTumbleSnow();
snd.playSoundByEvent(SoundData.STING_GAME_END);
setFramesDelay(90);
riderState = riderDance;
};
}
function handleButtonPress(_arg1:MouseEvent):void{
buttonPress = true;
}
function handleToggleMusicOff(_arg1:MouseEvent):void{
hud_btnMusicToggleOn.x = 151;
hud_btnMusicToggleOff.x = 251;
snd.setMusicMute(true);
}
function riderHeadHitObstacleCrash():void{
if (riderAnimComplete){
velocityLock = true;
riderOnGround = true;
riderIsCrashing = false;
zeroOutFlipCounter();
velSetCur.x = ((speedAtCrash)>=speedMin) ? speedAtCrash : speedMin;
velSetCur.y = 0;
rider.SetLinearVelocity(velSetCur);
riderSprite.startAnimating(AnimationData.IDLE.start, AnimationData.IDLE.end, AnimationData.IDLE.loop);
riderState = riderOnGroundIdle;
};
}
function updateScoreDisplay(_arg1:Array):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:SpriteEntity;
var _local6:Object;
var _local7:int;
var _local8:int;
_local2 = 5;
while (_local2--) {
_local3 = _arg1[_local2];
_local4 = hud_ScoreDisplay[_local2];
_local5 = (hud_ScoreDigitClips[_local2] as SpriteEntity);
if ((((_local3 == 0)) && ((_local4 == 0)))){
} else {
if (_local3 > _local4){
numDigitsAnimating++;
_local6 = AnimationData.createDigitIncrement(_local4, _local3);
_local5.startAnimating(_local6.start, _local6.end, _local6.loop);
entityAnimator.addSpriteToAnimate(_local5, this, handleDigitAnimationEnd);
} else {
if (_local3 <= _local4){
_local7 = _local5.getCurrentFrame();
_local8 = AnimationData.HUD_TRICK_SCORE_00_00.end;
_local5.startAnimating(_local7, _local8, false);
entityAnimator.addSpriteToAnimate(_local5, this, animateToDigitFromZero, [_local2, _local3]);
};
};
};
};
playHudPistons();
startDigitLoopSfx();
hud_ScoreDisplay = _arg1;
}
function stopRiderSnow():void{
riderSnowEmitter.counter.stop();
setAirBoardSnowVelocity();
}
override public function Exit():void{
var _local1:int;
_local1 = board.numChildren;
while (_local1--) {
board.removeChildAt(_local1);
};
cleanupWorld();
cleanupWorldSnow();
screenLayer.x = 0;
trace((this + " @ <-- EXIT"));
trace("");
}
function castHeight():Number{
var _local1:b2Shape;
var _local2:Number;
lambda = [1];
segStart.x = (curPos.x + raycastOffsetX);
segStart.y = curPos.y;
segEnd.x = (curPos.x + raycastOffsetX);
segEnd.y = (curPos.y + 100);
segment.p1 = segStart;
segment.p2 = segEnd;
_local1 = m_world.RaycastOne(segment, lambda, normal, true, null);
lambda = lambda[0];
_local2 = ((segment.p2.y * lambda) + ((1 - lambda) * segment.p1.y));
return (Math.floor((_local2 - curPos.y)));
}
function handleTimerUpdate(_arg1:TimerEvent):void{
if (gamePaused){
return;
};
if (gameOverMode){
if (gameOverTiles){
gameOverTimer++;
if (gameOverTimer >= 2){
gameOver = true;
gameTimer.stop();
gameData.finalScore = totalGameScore;
};
};
return;
} else {
totalTimeScore++;
totalResourceScore = (totalResourceScore - 1);
};
if ((((totalResourceScore <= 0)) && ((gameOverMode == false)))){
snd.playSoundByEvent(SoundData.SFX_TRICK_METER_LOW);
hud_Steam.startAnimating(AnimationData.HUD_STEAM.start, AnimationData.HUD_STEAM.end, AnimationData.HUD_STEAM.loop);
entityAnimator.addSpriteToAnimate(hud_Steam);
hud_TrickMeterAlert.startAnimating(AnimationData.HUD_TRICK_METER_GAMEOVER.start, AnimationData.HUD_TRICK_METER_GAMEOVER.end, AnimationData.HUD_TRICK_METER_GAMEOVER.loop);
gameOverMode = true;
return;
};
if ((((totalResourceScore <= 15)) && ((gameEndWarning == false)))){
snd.playSoundByEvent(SoundData.SFX_TRICK_METER_LOW);
hud_Steam.startAnimating(AnimationData.HUD_STEAM.start, AnimationData.HUD_STEAM.end, AnimationData.HUD_STEAM.loop);
entityAnimator.addSpriteToAnimate(hud_Steam);
hud_TrickMeterAlert.startAnimating(AnimationData.HUD_TRICK_METER_ALERT.start, AnimationData.HUD_TRICK_METER_ALERT.end, AnimationData.HUD_TRICK_METER_ALERT.loop);
entityAnimator.addSpriteToAnimate(hud_TrickMeterAlert);
gameEndWarning = true;
};
if ((((totalResourceScore > 15)) && ((gameEndWarning == true)))){
hud_TrickMeterAlert.startAnimating(1, 1, false);
gameEndWarning = false;
};
}
function moveRiderToStart():void{
var _local1:Number;
var _local2:Number;
_local1 = (rider.GetPosition().x - wrapWidthScaled);
_local2 = (curTile.pos.y - curTileToRiderDY);
rider.SetXForm(new b2XForm(new b2Vec2(_local1, _local2), new b2Mat22(rider.GetAngle())));
rider.SetLinearVelocity(new b2Vec2(curVel.x, curVel.y));
rider.GetUserData().x = (rider.GetPosition().x * m_physScale);
rider.GetUserData().y = (rider.GetPosition().y * m_physScale);
rider.GetUserData().rotation = (rider.GetAngle() * (180 / Math.PI));
}
function riderDance():void{
if (getFramesDelay(frTik++)){
riderState = riderPause;
step = pauseGamePlay;
};
}
function zeroOutFlipCounter():void{
Achievements.ResetFlipCounter();
curRotationIndex = 0;
numCompletedFlips = 0;
}
function waitForTransitionToGameOut():void{
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
if (screenLayer.contains(scr_Transition)){
screenLayer.removeChild(scr_Transition);
};
screenLayer.x = 600;
gamePaused = false;
rider.WakeUp();
riderState = riderInAirIdle;
step = updateGamePlay;
};
}
function exitGamePlay():void{
screenLayer.x = 0;
screenLayer.addChild(scr_Transition);
snd.playSoundByEvent(SoundData.SFX_SNOW_TRANSITION_ANIM);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_IN.start, AnimationData.SCRN_TRANS_IN.end, false);
step = waitForTransitionToGameOver;
}
function initGameObjects():void{
var _local1:DisplayObject;
var _local2:Number;
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:b2AABB;
var _local13:Boolean;
var _local14:b2Vec2;
var _local15:b2BodyDef;
var _local16:b2CircleDef;
var _local17:b2PolygonDef;
var _local18:b2CircleDef;
var _local19:b2PolygonDef;
var _local20:b2CircleDef;
var _local21:b2Shape;
var _local22:MovieClip;
board = (gameData.getGameLayer(GameData.BOARD) as Sprite);
_local1 = board;
_local2 = 400;
_local3 = 330;
_local4 = 600;
_local5 = 400;
_local6 = -400;
_local7 = 9999999;
_local8 = -5000;
_local9 = 9999999;
_local10 = -400;
_local11 = -300;
camera = new GameCamera(gameContext, _local1, _local2, _local3, _local4, _local5, _local6, _local7, _local8, _local9, _local10, _local11);
camera.addScrollingFlat("background01", 600, 400, 0, 0, gameData._background, 1, 1, 0, 0, 0, 0);
camera.addScrollingFlat("Background02", 600, 400, 0, 50, gameData._background, 1, 1, 0, 0, 0, 0.25);
camera.addScrollingFlat("Background03", 600, 400, 0, 50, gameData._background, 1, 1, 0, 0, 1, 1);
_local12 = new b2AABB();
_local12.lowerBound.Set(-100, -100);
_local12.upperBound.Set(1000, 1000);
_local13 = true;
_local14 = new b2Vec2(0, 20);
m_world = new b2World(_local12, _local14, _local13);
dbgDraw = new b2DebugDraw();
dbgSprite = new Sprite();
dbgDraw.SetSprite(dbgSprite);
dbgDraw.SetDrawScale(30);
dbgDraw.SetFillAlpha(0);
dbgDraw.SetLineThickness(1);
dbgDraw.SetFlags(4294967295);
if (debugVisible){
board.addChild(dbgSprite);
m_world.SetDebugDraw(dbgDraw);
};
colHandler = new CollisionHandler();
m_world.SetContactListener(colHandler);
nextTileX = 300;
nextTileY = 300;
tilesOnBoard.push(new Tile(Tile.FLATLAND, nextTileX, nextTileY, m_world, board));
tileMap = [Tile.FLATLAND, Tile.FLATLAND, Tile.MOGUL_SMALL, Tile.FLATLAND, Tile.MOGUL_SMALL, Tile.FLATLAND, Tile.FLATLAND, Tile.MOGUL_LARGE, Tile.FLATLAND, Tile.FLATLAND, Tile.GAP_SMALL, Tile.FLATLAND, Tile.MOGUL_SET, Tile.FLATLAND, Tile.JUMP_LARGE];
curTilesetLib = [flat, mogul_set, mogul_sm, mogul_lg, hill_sm, hill_md, hill_lg, hill_xlg, hill_xxlg, obstacle, jump_lg, jump_lg, gap_sm];
_local15 = new b2BodyDef();
_local15.position.x = 4;
_local15.position.y = 9;
_local15.angularDamping = 0.5;
riderSprite = new SpriteEntity(gameContext, "char_Flapjack", board);
_local15.userData = riderSprite.getMovieClip();
_local16 = new b2CircleDef();
_local16.radius = 0.4;
_local16.density = 2;
_local16.friction = 0;
_local16.restitution = 0;
_local16.localPosition.Set(0.8, 0);
_local17 = new b2PolygonDef();
_local17.density = 2;
_local17.friction = 0;
_local17.restitution = 0;
_local17.SetAsOrientedBox(0.6, 0.4);
_local18 = new b2CircleDef();
_local18.radius = 0.4;
_local18.density = 2.2;
_local18.friction = 0;
_local18.restitution = 0;
_local18.localPosition.Set(-0.8, 0);
_local19 = new b2PolygonDef();
_local19.userData = "rider_board";
_local19.SetAsOrientedBox(1, 0.6);
_local19.isSensor = true;
_local20 = new b2CircleDef();
_local20.userData = "rider_head";
_local20.radius = 0.7;
_local20.density = 0;
_local20.localPosition.Set(0.6, -1.4);
rider = m_world.CreateBody(_local15);
rider.CreateShape(_local16);
rider.CreateShape(_local17);
rider.CreateShape(_local18);
riderBoardShape = rider.CreateShape(_local19);
_local21 = rider.CreateShape(_local20);
rider.SetMassFromShapes();
rider.AllowSleeping(false);
riderBoardContacts = new ContactListener(riderBoardShape);
colHandler.addContactListener(riderBoardContacts);
riderHeadCollisions = new CollisionListener(_local21);
riderHeadCollisions.addEventListener(CollisionEvent.FIRST_COLLIDE, handleHeadCollision, false, 0, true);
colHandler.addCollisionListener(riderHeadCollisions);
curPos.x = 4;
curPos.y = 7;
rider.SetPositionAndAngle(curPos, 0);
riderX = (curPos.x * m_physScale);
riderY = (curPos.y * m_physScale);
rider.GetUserData().x = riderX;
rider.GetUserData().y = riderY;
camera.setTargetToFollow(_local15.userData, 0, 0);
camera.setTargetOffsetXY(300, 50);
camera.Update();
riderBoardEmitter = new boardEmitter();
board.addChild(riderBoardEmitter);
riderTumbleEmitter = new Sprite();
board.addChild(riderTumbleEmitter);
riderCrashEmitter = new Sprite();
board.addChild(riderCrashEmitter);
riderCrashEmitter2 = new Sprite();
board.addChild(riderCrashEmitter2);
hud = new hud_Main();
hud.x = 380;
hud.y = 0;
hud_btnShowInstruct = (hud.getChildByName("btn_ShowInstruct") as SimpleButton);
hud_btnShowInstruct.addEventListener(MouseEvent.MOUSE_UP, handleHudInstructionButton, false, 0, true);
hud_btnMusicToggleOn = new btn_MusicOn();
hud_btnMusicToggleOn.x = 251;
hud_btnMusicToggleOn.y = 344;
hud_btnMusicToggleOn.addEventListener(MouseEvent.MOUSE_UP, handleToggleMusicOn, false, 0, true);
hud.addChild(hud_btnMusicToggleOn);
hud_btnMusicToggleOff = new btn_MusicOff();
hud_btnMusicToggleOff.x = 151;
hud_btnMusicToggleOff.y = 344;
hud_btnMusicToggleOff.addEventListener(MouseEvent.MOUSE_UP, handleToggleMusicOff, false, 0, true);
hud.addChild(hud_btnMusicToggleOff);
hud_TrickMeter = (hud.getChildByName(LNK_HUD_TRICK_METER) as MovieClip);
hud_TrickMeter.gotoAndStop(totalResourceScore);
hud_HeightMeter = (hud.getChildByName(LNK_HUD_HEIGHT_METER) as MovieClip);
hud_HeightMeter.gotoAndStop(1);
hud_Steam = new SpriteEntity(gameContext, LNK_HUD_STEAM, hud);
hud_Windvane = new SpriteEntity(gameContext, LNK_HUD_WINDVANE, hud);
hud_Confetti = new SpriteEntity(gameContext, LNK_HUD_CONFETTI, hud);
hud_Pistons = new SpriteEntity(gameContext, LNK_HUD_PISTONS, hud);
hud_TrickFlags = new SpriteEntity(gameContext, LNK_HUD_TRICK_FLAGS, hud);
hud_TrickMeterAlert = new SpriteEntity(gameContext, LNK_HUD_TRICK_METER_ALERT, hud);
hud_Score_1 = new SpriteEntity(gameContext, LNK_HUD_SCORE_1, hud);
hud_Score_1.moveToFrame(60);
hud_Score_2 = new SpriteEntity(gameContext, LNK_HUD_SCORE_2, hud);
hud_Score_2.moveToFrame(60);
hud_Score_3 = new SpriteEntity(gameContext, LNK_HUD_SCORE_3, hud);
hud_Score_3.moveToFrame(60);
hud_Score_4 = new SpriteEntity(gameContext, LNK_HUD_SCORE_4, hud);
hud_Score_4.moveToFrame(60);
hud_Score_5 = new SpriteEntity(gameContext, LNK_HUD_SCORE_5, hud);
hud_Score_5.moveToFrame(60);
hud_TotalScore = (hud.getChildByName("txt_TotalScore") as TextField);
hud_ScoreDigitClips = [hud_Score_5, hud_Score_4, hud_Score_3, hud_Score_2, hud_Score_1];
gameData._world.addChild(hud);
scorPopUp = new fx_ScoringPopUp();
hideScorePopUp();
gameData._world.addChild(scorPopUp);
_local22 = (scorPopUp.getChildByName("box") as MovieClip);
scorPopUpText = (_local22.getChildByName("_msg") as TextField);
scorPopUpAnim = new SpriteAnimator(gameContext, scorPopUp);
scorPopUpAnim.addEventListener(AnimationEvent.COMPLETE, hideScorePopUp, false, 0, true);
gameTimer = new Timer(1000);
gameTimer.addEventListener(TimerEvent.TIMER, handleTimerUpdate, false, 0, true);
riderState = new Function();
riderState = riderInAirIdle;
initRiderSnow();
}
function scoreToArray(_arg1:Number):Array{
var _local2:String;
var _local3:int;
var _local4:String;
var _local5:Array;
var _local6:int;
_local2 = String(_arg1);
_local3 = (5 - _local2.length);
_local4 = "";
while (_local3--) {
_local4 = (_local4 + "0");
};
_local2 = _local4.concat(_local2);
_local5 = [0, 0, 0, 0, 0];
_local6 = 0;
while (_local6 < 5) {
_local5[_local6] = int(_local2.charAt(_local6));
_local6++;
};
return (_local5);
}
function waitForTransitionToGameIn():void{
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
if (screenLayer.contains(scr_Instruct)){
screenLayer.removeChild(scr_Instruct);
anim_Instruct.moveToFrame(1);
};
scrnAnimComplete = 0;
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_OUT.start, AnimationData.SCRN_TRANS_OUT.end, false);
step = waitForTransitionToGameOut;
};
}
function updateResourceMeter():void{
hud_TrickMeter.gotoAndStop(totalResourceScore);
}
function moveTilesToStart():void{
var _local1:int;
var _local2:int;
var _local3:Number;
var _local4:Tile;
var _local5:Tile;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local1 = tilesOnBoard.length;
_local2 = (_local1 - 1);
_local3 = 999999999;
while (_local1--) {
_local5 = tilesOnBoard[_local1];
_local6 = (_local5.pos.x - riderX);
_local7 = (((_local5.pos.x - riderX) ^ (_local6 >> 31)) - (_local6 >> 31));
if (_local7 < _local3){
_local3 = _local7;
curTile = _local5;
curTileToRiderDY = (_local5.pos.y - rider.GetPosition().y);
};
_local8 = (_local5.pos.x - wrapWidthScaled);
_local9 = (_local5.pos.y - vShift);
_local5.moveTo(_local8, _local9);
};
_local4 = tilesOnBoard[_local2];
nextTileX = (_local4.pos.x * m_physScale);
nextTileY = (_local4.pos.y * m_physScale);
}
function startCrashSnow2():void{
if (curTileContact){
riderCrashEmitter2.x = (curTileContact._pos.x * 30);
riderCrashEmitter2.y = (curTileContact._pos.y * 30);
} else {
riderCrashEmitter2.x = riderX;
riderCrashEmitter2.y = riderY;
};
crashSnow2.start();
}
function animateToDigitFromZero(_arg1:int, _arg2:int):void{
var _local3:SpriteEntity;
var _local4:int;
_local3 = (hud_ScoreDigitClips[_arg1] as SpriteEntity);
_local4 = AnimationData.getEndFrameForDigit(_arg2);
numDigitsAnimating++;
_local3.startAnimating(0, _local4, false);
entityAnimator.addSpriteToAnimate(_local3, this, handleDigitAnimationEnd);
}
function cleanupWorldSnow():void{
if (snowEmitter){
snowEmitter.killAllParticles();
snowEmitter.stop();
snowEmitter = null;
};
}
function startWorldSnow():void{
var _local1:DisplayObjectRenderer;
snowEmitter = new WorldSnow();
_local1 = new DisplayObjectRenderer();
_local1.addEmitter(snowEmitter);
gameContext.addChild(_local1);
snowVelocity = new TargetVelocity(0, 150, 1);
snowEmitter.addAction(snowVelocity);
snowEmitter.start();
snowEmitter.runAhead(10);
}
function update_Story():void{
switch (stepb){
case 0:
if (buttonPress){
anim_Story.startAnimating(AnimationData.SCRN_STORY.start, AnimationData.SCRN_STORY.end, AnimationData.SCRN_STORY.loop);
buttonPress = false;
stepb = 1;
};
break;
case 1:
scrnAnimComplete = anim_Story.animateSprite();
if (scrnAnimComplete == 1){
screenLayer.addChild(scr_Transition);
snd.playSoundByEvent(SoundData.SFX_SNOW_TRANSITION_ANIM);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_IN.start, AnimationData.SCRN_TRANS_IN.end, false);
step = exit_Story;
};
break;
};
}
function riderInAirIdle():void{
angleLock = true;
if (riderInGap){
riderState = riderInGapEnter;
return;
};
if (riderOnObstacle){
zeroOutFlipCounter();
jumpActive = false;
riderOnGround = false;
curTileContact._shape2.GetBody().ApplyImpulse(new b2Vec2(20, 0), curTileContact._shape2.GetBody().GetPosition());
startCrashSnow();
riderState = riderStartCrash;
Achievements.AddWipeout();
return;
};
if (riderOnGround){
stopAirLoopSfx();
startBoardLoopSfx();
startRiderSnow();
snd.playSoundByEvent(SoundData.SFX_LAND_FROM_JUMP);
zeroOutFlipCounter();
riderSprite.startAnimating(AnimationData.IDLE.start, AnimationData.IDLE.end, AnimationData.IDLE.loop);
riderState = riderOnGroundIdle;
return;
};
if (Input.mouseReleased){
jumpActive = false;
};
if (Input.mouseDown){
if (checkMouseArea()){
if (!jumpActive){
trickNum = 1;
angleLock = false;
angleCurVel = (curVel.x * -0.8);
rider.SetAngularVelocity(angleCurVel);
startTrickAnimation(trickNum);
riderState = riderInAirFlipping;
return;
};
};
};
if (curVel.y >= 0){
riderSprite.startAnimating(AnimationData.JUMP_LAND.start, AnimationData.JUMP_LAND.end, AnimationData.JUMP_LAND.loop);
} else {
riderSprite.startAnimating(AnimationData.JUMP_AIR.start, AnimationData.JUMP_AIR.end, AnimationData.JUMP_AIR.loop);
};
}
function instructionPause():void{
if (gameOver){
gamePaused = false;
step = exitGamePlay;
return;
};
if (buttonPress){
buttonPress = false;
screenLayer.addChild(scr_Transition);
scrnAnimComplete = 0;
snd.playSoundByEvent(SoundData.SFX_SNOW_TRANSITION_ANIM);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_IN.start, AnimationData.SCRN_TRANS_IN.end, false);
step = waitForTransitionToGameIn;
};
}
function riderFinishSlide():void{
riderTumbleEmitter.x = riderX;
riderTumbleEmitter.y = riderY;
if (riderAnimComplete){
riderIsCrashing = false;
velSetCur.x = ((speedAtCrash)>=speedMin) ? speedAtCrash : speedMin;
velSetCur.y = 0;
rider.SetLinearVelocity(velSetCur);
changeSnowVelocity();
startRiderSnow();
startBoardLoopSfx();
riderSprite.startAnimating(AnimationData.IDLE.start, AnimationData.IDLE.end, AnimationData.IDLE.loop);
riderState = riderOnGroundIdle;
};
}
function updateHeightMeter(_arg1:Number):void{
hud_HeightMeter.gotoAndStop(_arg1);
}
function updateGamePlay():void{
var _local1:int;
var _local2:Number;
var _local3:Point;
curAngleDeg = resolveAngle(rider.GetAngle());
curPos = rider.GetPosition();
curVel = rider.GetLinearVelocity();
riderX = (curPos.x * m_physScale);
riderY = ((curPos.y * m_physScale) + 4);
if ((camera.currCamX + TILE_WIDTH) >= nextTileX){
addNextTile();
};
removeOldTiles();
removeOldObstacles();
if (camera.currCamX >= WRAP_WIDTH){
rider.GetUserData().x = riderX;
rider.GetUserData().y = riderY;
camera.Update();
_local3 = camera.getDistanceToTarget();
setVShift();
moveTilesToStart();
moveObstaclesToStart();
moveRiderToStart();
camera.setCamToTarget(_local3);
return;
};
if (velocityLock){
if ((((curVel.x < velSetCur.x)) || ((curVel.x > velSetCur.x)))){
b2SetV.x = velSetCur.x;
b2SetV.y = curVel.y;
rider.SetLinearVelocity(b2SetV);
};
};
if (angleLock){
if ((((curAngleDeg < 320)) && ((curAngleDeg >= 180)))){
rider.SetPositionAndAngle(curPos, TwoDMath.degreesInRadians(320));
};
if ((((curAngleDeg > 40)) && ((curAngleDeg <= 180)))){
rider.SetPositionAndAngle(curPos, TwoDMath.degreesInRadians(40));
};
};
rider.GetUserData().x = riderX;
rider.GetUserData().y = riderY;
rider.GetUserData().rotation = curAngleDeg;
riderAnimComplete = riderSprite.animateSprite();
updateObstacleSprites();
camera.Update();
scorPopUpAnim.animateSprite();
updateResourceMeter();
updateTotalScore();
_local1 = riderBoardContacts.getNumContacts();
if (_local1 < 1){
riderInGap = false;
riderOnObstacle = false;
curTileContact = null;
if (riderOnGround == true){
riderOnGround = false;
};
} else {
curTileContact = riderBoardContacts.processContacts();
riderInGap = ((curTileContact._shape2.GetUserData())=="gap") ? true : false;
riderOnObstacle = ((curTileContact._shape2.GetUserData())=="airobstacle") ? true : false;
if ((((((riderOnGround == false)) && ((riderInGap == false)))) && ((riderOnObstacle == false)))){
riderOnGround = true;
};
};
riderState();
_local2 = (((((riderInGap) || (riderIsSpawning))) || (riderIsCrashing))) ? 0 : castHeight();
updateHeightMeter(_local2);
if (gameOver == false){
camera.updateScrollingFlats(0.25, -((_local2 * 2)));
};
if (anim_Transition){
anim_Transition.animateSprite();
};
}
function doRiderFlipScore():void{
var _local1:int;
var _local2:Object;
if (numCompletedFlips > 0){
Achievements.AddFlips(numCompletedFlips);
};
Achievements.EndJump();
if (numCompletedFlips < 1){
updateScoreDisplay([0, 0, 0, 0, 0]);
return;
};
snd.playSoundByEvent(SoundData.SFX_LAND_GOOD);
_local1 = 0;
totalCompletedFlips = (totalCompletedFlips + numCompletedFlips);
_local2 = null;
switch (true){
case (numCompletedFlips > FLIPS_WOW):
_local2 = AnimationData.HUD_TRICK_FLAG_WOW;
break;
case (numCompletedFlips > FLIPS_SWEET):
_local2 = AnimationData.HUD_TRICK_FLAG_SWEET;
break;
case (numCompletedFlips > FLIPS_NICE):
_local2 = AnimationData.HUD_TRICK_FLAG_NICE;
break;
case (numCompletedFlips > FLIPS_GREAT):
_local2 = AnimationData.HUD_TRICK_FLAG_GREAT;
break;
case (numCompletedFlips > FLIPS_GOOD):
_local2 = AnimationData.HUD_TRICK_FLAG_GOOD;
break;
};
if (_local2 != null){
hud_TrickFlags.startAnimating(_local2.start, _local2.end, _local2.loop);
entityAnimator.addSpriteToAnimate(hud_TrickFlags);
snd.playSoundByEvent(SoundData.SFX_TRICK_RATING_FLAG);
};
if (numCompletedFlips > FLIPS_WOW){
hud_Confetti.startAnimating(AnimationData.HUD_CONFETTI.start, AnimationData.HUD_CONFETTI.end, AnimationData.HUD_CONFETTI.loop);
entityAnimator.addSpriteToAnimate(hud_Confetti);
snd.playSoundByEvent(SoundData.SFX_CONFETTI_CANNON);
};
while (numCompletedFlips--) {
_local1 = (_local1 + ((numCompletedFlips + 1) * 50));
};
totalFlipScore = (totalFlipScore + _local1);
totalResourceScore = (totalResourceScore + (_local1 / 125));
updateScoreDisplay(scoreToArray(_local1));
}
function startFromReplay():void{
scr_Transition = (screenLayer.getChildByName("replayTransition") as MovieClip);
scr_Transition.name = "transition";
anim_Transition = new SpriteAnimator(gameContext, scr_Transition);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_OUT.start, AnimationData.SCRN_TRANS_OUT.end, false);
scr_Instruct = new scrn_Instructions();
anim_Instruct = new SpriteAnimator(gameContext, scr_Instruct);
anim_Instruct.moveToFrame(1);
initGameObjects();
startGamePlay();
updateGamePlay();
startWorldSnow();
scrnAnimComplete = 0;
step = waitForReplayTransitionEnd;
}
function resolveAngle(_arg1:Number):int{
var _local2:Number;
_local2 = (_arg1 * (180 / Math.PI));
_local2 = (_local2 % 360);
_local2 = ((_local2)<0) ? (_local2 + 360) : _local2;
return (int(_local2));
}
function removeOldTiles():void{
var _local1:int;
var _local2:Tile;
var _local3:Number;
var _local4:Number;
_local1 = tilesOnBoard.length;
while (_local1--) {
_local2 = tilesOnBoard[_local1];
_local3 = (_local2.pos.x * m_physScale);
_local4 = (camera.currCamX - 900);
if (_local3 < _local4){
tilesOnBoard.splice(_local1, 1);
_local2.cleanup();
_local2 = null;
};
};
}
function pauseGamePlay():void{
if (gameOver){
step = exitGamePlay;
return;
};
if (Input.isKeyPressed(KEY_DEBUG_PAUSE)){
rider.WakeUp();
riderState = riderOnGroundIdle;
step = updateGamePlay;
};
}
public function toString():String{
return ("GamePlay()");
}
function stopDigitLoopSfx():void{
if (digitSpinLoop){
snd.stopSound(digitSpinLoop);
};
}
function exit_Story():void{
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
if (screenLayer.contains(scr_Story)){
screenLayer.removeChild(scr_Story);
};
startGamePlay();
updateGamePlay();
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_OUT.start, AnimationData.SCRN_TRANS_OUT.end, false);
step = waitForStoryTransitionEnd;
};
}
function showTransitionToInstructFromGame():void{
screenLayer.x = 0;
screenLayer.addChild(scr_Transition);
snd.playSoundByEvent(SoundData.SFX_SNOW_TRANSITION_ANIM);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_IN.start, AnimationData.SCRN_TRANS_IN.end, false);
stopAirLoopSfx();
stopBoardLoopSfx();
stopTumbleLoopSfx();
rider.PutToSleep();
riderState = riderPause;
step = waitForTransitionToInstructionIn;
}
function waitForStoryTransitionEnd():void{
updateGamePlay();
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
if (screenLayer.contains(scr_Transition)){
screenLayer.removeChild(scr_Transition);
};
step = updateGamePlay;
};
}
function riderStartCrash():void{
riderTumbleEmitter.x = riderX;
riderTumbleEmitter.y = riderY;
riderIsCrashing = true;
startTumbleLoopSfx();
stopAirLoopSfx();
stopRiderSnow();
snd.playSoundByEvent(SoundData.SFX_LAND_BAD);
updateScoreDisplay([0, 0, 0, 0, 0]);
angleLock = true;
speedAtCrash = calulateSpeedDamage();
riderSprite.startAnimating(AnimationData.TUMBLE.start, AnimationData.TUMBLE.end, AnimationData.TUMBLE.loop);
riderState = riderCrashTumble;
}
function resetScore():void{
totalCompletedFlips = 0;
totalFlipScore = 0;
totalTimeScore = 0;
totalTokenScore = 0;
totalResourceScore = 100;
totalGameScore = 0;
gameTimeTotalSecs = 0;
velSetCur = velSetMin;
rider.SetLinearVelocity(velSetMin);
}
function startTrickAnimation(_arg1:int):void{
switch (_arg1){
case TRICK_1:
riderSprite.startAnimating(AnimationData.TRICK_1.start, AnimationData.TRICK_1.end, AnimationData.TRICK_1.loop);
break;
case TRICK_2:
riderSprite.startAnimating(AnimationData.TRICK_2.start, AnimationData.TRICK_2.end, AnimationData.TRICK_2.loop);
break;
case TRICK_3:
riderSprite.startAnimating(AnimationData.TRICK_3.start, AnimationData.TRICK_3.end, AnimationData.TRICK_3.loop);
break;
};
}
function startFromTitle():void{
scr_Instruct = new scrn_Instructions();
anim_Instruct = new SpriteAnimator(gameContext, scr_Instruct);
anim_Instruct.moveToFrame(1);
scr_Story = new scrn_Story();
anim_Story = new SpriteAnimator(gameContext, scr_Story);
anim_Story.moveToFrame(1);
scr_Transition = new scrn_SnowTransition();
scr_Transition.name = "transition";
anim_Transition = new SpriteAnimator(gameContext, scr_Transition);
scr_Title = new scrn_TitleCard();
scr_Title.gotoAndStop(5);
screenLayer.addChildAt(scr_Title, 0);
snd.playMusic(SoundData.getSoundLinkage(SoundData.MUSIC_TITLE));
initPlayButton(scr_Title);
initGameObjects();
step = update_Title;
}
function stopBoardLoopSfx():void{
if (riderBoardLoop){
snd.stopSound(riderBoardLoop);
};
}
function checkMouseArea():Boolean{
var _local1:Boolean;
_local1 = true;
if (gameData._world.mouseX > 510){
if (gameData._world.mouseY > 350){
_local1 = false;
};
};
return (_local1);
}
function setFramesDelay(_arg1:int):void{
frCnt = _arg1;
frTik = 0;
}
function startGameNow():void{
startGamePlay();
step = updateGamePlay;
}
function calulateSpeedDamage():Number{
var _local1:Number;
var _local2:Number;
_local1 = (velSetCur.x - speedMin);
if (_local1 < speedMin){
return (speedMin);
};
_local2 = (velSetCur.x - (_local1 * 0.25));
return (((_local2)<speedMin) ? speedMin : _local2);
}
function setSnowVelocityZero():void{
snowEmitter.x = 0;
snowVelocity.targetVelocityX = 0;
}
function startDigitLoopSfx():void{
if (!snd.soundIsPlaying(SoundData.SFX_SPIN_MULTIPLIER)){
digitSpinLoop = snd.playSoundByEvent(SoundData.SFX_SPIN_MULTIPLIER);
};
}
function enter_Instruct():void{
switch (stepb){
case 0:
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
screenLayer.addChildAt(scr_Instruct, 0);
scr_Instruct.play();
if (screenLayer.contains(scr_Title)){
screenLayer.removeChild(scr_Title);
};
startWorldSnow();
scrnAnimComplete = 0;
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_OUT.start, AnimationData.SCRN_TRANS_OUT.end, false);
stepb = 1;
};
break;
case 1:
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
initPlayButton(scr_Instruct);
if (screenLayer.contains(scr_Transition)){
screenLayer.removeChild(scr_Transition);
};
step = update_Instruct;
};
break;
};
}
function riderOnGroundCrouching():void{
riderBoardEmitter.x = riderX;
riderBoardEmitter.y = riderY;
riderBoardEmitter.rotation = curAngleDeg;
if (riderInGap){
riderState = riderInGapEnter;
return;
};
if (riderOnGround == false){
startAirLoopSfx();
stopBoardLoopSfx();
stopRiderSnow();
jumpCharge = jumpMin;
riderIsDucking = false;
riderState = riderInAirIdle;
return;
};
if (jumpCharge > jumpMax){
jumpCharge = (jumpCharge - 5);
} else {
jumpCharge = jumpMax;
};
if (jumpActive == false){
jumpActive = true;
riderSprite.startAnimating(AnimationData.JUMP_READY.start, AnimationData.JUMP_READY.end, AnimationData.JUMP_READY.loop);
};
if (((Input.mouseReleased) && ((jumpActive == true)))){
Achievements.StartJump();
startAirLoopSfx();
stopBoardLoopSfx();
stopRiderSnow();
rider.ApplyImpulse(new b2Vec2(0, jumpCharge), rider.GetPosition());
jumpActive = false;
jumpCharge = jumpMin;
riderIsDucking = false;
zeroOutFlipCounter();
riderState = riderInAirIdle;
};
}
function waitForReplayTransitionEnd():void{
updateGamePlay();
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
if (screenLayer.contains(scr_Transition)){
screenLayer.removeChild(scr_Transition);
};
step = updateGamePlay;
};
}
function startBoardLoopSfx():void{
if (!snd.soundIsPlaying(SoundData.SFX_SNOWBOARDING_LOOP)){
riderBoardLoop = snd.playSoundByEvent(SoundData.SFX_SNOWBOARDING_LOOP);
};
}
function startTumbleLoopSfx():void{
if (!snd.soundIsPlaying(SoundData.SFX_HERO_ROLL_GROUND_LOOP)){
riderTumbleLoop = snd.playSoundByEvent(SoundData.SFX_HERO_ROLL_GROUND_LOOP);
};
}
function update_Title():void{
if (buttonPress){
buttonPress = false;
step = exit_Title;
};
}
function handleDigitAnimationEnd():void{
numDigitsFinished++;
if (numDigitsFinished >= numDigitsAnimating){
stopDigitLoopSfx();
};
}
function getFramesDelay(_arg1:int):Boolean{
return (((_arg1)>=frCnt) ? true : false);
}
function cleanupWorld():void{
if (gameData._world.contains(hud)){
gameData._world.removeChild(hud);
};
if (gameData._world.contains(scorPopUp)){
gameData._world.removeChild(scorPopUp);
};
}
function setNewBoardSnowVelocity():void{
boardLZ.endX = (velSetCur.x * -10);
boardLZ.endY = (velSetCur.x * -3);
}
function updateTotalScore():void{
totalGameScore = ((totalFlipScore + totalTimeScore) + totalTokenScore);
hud_TotalScore.text = String(totalGameScore);
}
function changeSnowVelocity():void{
snowEmitter.x = (velSetCur.x * 10);
snowVelocity.targetVelocityX = ((velSetCur.x * 10) * -1);
}
function exit_Instruct():void{
stepb = 0;
screenLayer.addChild(scr_Transition);
snd.playSoundByEvent(SoundData.SFX_SNOW_TRANSITION_ANIM);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_IN.start, AnimationData.SCRN_TRANS_IN.end, false);
step = enter_Story;
}
function handleHudInstructionButton(_arg1:MouseEvent):void{
if (gameOverMode){
return;
};
gamePaused = true;
step = showTransitionToInstructFromGame;
}
function playHudPistons():void{
hud_Pistons.startAnimating(AnimationData.HUD_PISTON.start, AnimationData.HUD_PISTON.end, AnimationData.HUD_PISTON.loop);
entityAnimator.addSpriteToAnimate(hud_Pistons);
}
function riderCrashTumble():void{
riderTumbleEmitter.x = riderX;
riderTumbleEmitter.y = riderY;
if (riderInGap){
riderState = riderInGapEnter;
return;
};
if (riderOnGround){
startCrashSnow2();
startTumbleSnow();
if (gameOver){
snd.stopMusic();
riderState = riderRollToGameOver;
} else {
startBoardLoopSfx();
stopAirLoopSfx();
stopTumbleLoopSfx();
riderSprite.startAnimating(AnimationData.TUMBLE1.start, AnimationData.TUMBLE1.end, AnimationData.TUMBLE1.loop);
riderState = riderOnGroundSlide;
};
};
}
function startCrashSnow():void{
if (curTileContact){
riderCrashEmitter.x = (curTileContact._pos.x * 30);
riderCrashEmitter.y = (curTileContact._pos.y * 30);
} else {
riderCrashEmitter.x = riderX;
riderCrashEmitter.y = riderY;
};
crashSnow.start();
}
function riderGapRespawn():void{
var _local1:Boolean;
_local1 = (((camera.isOnTargetX) && (camera.isOnTargetY))) ? true : false;
if (_local1){
camera.setTruckSpeedX(1);
camera.setTruckSpeedY(1);
riderSprite.setVisibility(true);
riderSprite.startAnimating(AnimationData.JUMP_LAND.start, AnimationData.JUMP_LAND.end, AnimationData.JUMP_LAND.loop);
snd.playSoundByEvent(SoundData.SFX_HERO_RESPAWN);
rider.WakeUp();
velSetCur.x = ((speedAtCrash)>=speedMin) ? speedAtCrash : speedMin;
velSetCur.y = 0;
rider.SetLinearVelocity(velSetCur);
changeSnowVelocity();
velocityLock = true;
riderIsSpawning = false;
riderIsCrashing = false;
riderState = riderInAirIdle;
};
}
function stopTumbleLoopSfx():void{
if (riderTumbleLoop){
snd.stopSound(riderTumbleLoop);
};
}
function riderPause():void{
}
function stopTumbleSnow():void{
tumbleSnow.counter.stop();
}
function exit_Title():void{
screenLayer.addChild(scr_Transition);
snd.playSoundByEvent(SoundData.SFX_SNOW_TRANSITION_ANIM);
anim_Transition.startAnimating(AnimationData.SCRN_TRANS_IN.start, AnimationData.SCRN_TRANS_IN.end, false);
step = enter_Instruct;
}
function handleToggleMusicOn(_arg1:MouseEvent):void{
hud_btnMusicToggleOn.x = 251;
hud_btnMusicToggleOff.x = 151;
snd.setMusicMute(false);
}
function waitForTransitionToGameOver():void{
scrnAnimComplete = anim_Transition.animateSprite();
if (scrnAnimComplete == 1){
gameManager.setNextState(GameOver);
};
}
function initRiderSnow():void{
var _local1:DisplayObjectRenderer;
var _local2:DisplayObjectRenderer;
var _local3:DisplayObjectRenderer;
var _local4:DisplayObjectRenderer;
var _local5:DisplayObjectRenderer;
riderSnowEmitter = new RiderSnow();
boardLZ = new LineZone(new Point(-15, 10), new Point(-50, -30));
riderSnowVelocity = new Velocity(boardLZ);
riderSnowEmitter.addInitializer(riderSnowVelocity);
_local1 = new DisplayObjectRenderer();
_local1.addEmitter(riderSnowEmitter);
riderBoardEmitter.addChild(_local1);
airSnow = new RiderSnow();
airSnow.counter = new Blast(10);
airLZ = new LineZone(new Point(0, 0), new Point(50, 50));
airSnow.addInitializer(new Velocity(airLZ));
_local2 = new DisplayObjectRenderer();
_local2.addEmitter(airSnow);
riderBoardEmitter.addChild(_local2);
tumbleSnow = new TumbleSnow();
_local3 = new DisplayObjectRenderer();
_local3.addEmitter(tumbleSnow);
riderTumbleEmitter.addChild(_local3);
crashSnow = new BlastSnow();
_local4 = new DisplayObjectRenderer();
_local4.addEmitter(crashSnow);
riderCrashEmitter.addChild(_local4);
crashSnow2 = new BlastSnow();
_local5 = new DisplayObjectRenderer();
_local5.addEmitter(crashSnow2);
riderCrashEmitter2.addChild(_local5);
}
function handleHeadCollision(_arg1:CollisionEvent):void{
var _local2:String;
if (((((riderInGap) || (riderIsCrashing))) || (riderIsSpawning))){
return;
};
_local2 = _arg1.otherShape.GetUserData();
if (_local2 == "airobstacle"){
if (((riderIsDucking) || ((riderOnGround == false)))){
return;
};
Achievements.AddWipeout();
velocityLock = false;
speedAtCrash = calulateSpeedDamage();
velSetCur.x = 2;
rider.SetLinearVelocity(new b2Vec2(velSetCur.x, curVel.y));
_arg1.otherShape.GetBody().ApplyImpulse(new b2Vec2(20, 0), _arg1.otherShape.GetBody().GetPosition());
snd.playSoundByEvent(SoundData.SFX_HIT_OBSTACLE);
riderSprite.startAnimating(AnimationData.HEADHITOBSTACLE.start, AnimationData.HEADHITOBSTACLE.end, AnimationData.HEADHITOBSTACLE.loop);
riderState = riderHeadHitObstacleCrash;
} else {
riderIsCrashing = true;
riderCrashEmitter.x = (_arg1.collidingPoint.position.x * 30);
riderCrashEmitter.y = (_arg1.collidingPoint.position.y * 30);
crashSnow.start();
if (riderInGap){
riderState = riderInGapEnter;
return;
};
rider.SetPositionAndAngle(curPos, 0);
riderState = riderStartCrash;
Achievements.AddWipeout();
};
}
function startTumbleSnow():void{
if (tumbleSnow.running == false){
tumbleSnow.start();
} else {
tumbleSnow.counter.resume();
};
}
}
}//package game.states
Section 130
//AnimationData (game.AnimationData)
package game {
public class AnimationData {
public static var HUD_TRICK_METER_ALERT:Object = {start:1, end:20, loop:true};
public static var SCRN_TRANS_OUT:Object = {start:18, end:34, loop:false};
public static var HUD_TRICK_SCORE_05_06:Object = {start:16, end:18, loop:false};
public static var SCRN_TRANS_IN:Object = {start:1, end:18, loop:false};
public static var HUD_WINDVANE:Object = {start:1, end:200, loop:true};
public static var JUMP_AIR:Object = {start:30, end:30, loop:false};
public static var HUD_TRICK_SCORE_00_01:Object = {start:1, end:3, loop:false};
public static var TRICK_1:Object = {start:50, end:50, loop:true};
public static var TRICK_2:Object = {start:60, end:60, loop:true};
public static var TRICK_3:Object = {start:70, end:81, loop:true};
public static var HEADHITOBSTACLE:Object = {start:100, end:109, loop:false};
public static var HUD_TRICK_SCORE_04_05:Object = {start:13, end:15, loop:false};
public static var HUD_TRICK_FLAG_WOW:Object = {start:201, end:240, loop:false};
public static var HUD_TRICK_FLAG_SWEET:Object = {start:151, end:190, loop:false};
public static var HUD_TRICK_SCORE_08_09:Object = {start:25, end:27, loop:false};
public static var HUD_HEIGHT_METER:Object = {start:1, end:100, loop:false};
public static var HUD_TRICK_SCORE_03_04:Object = {start:10, end:12, loop:false};
public static var HUD_HEIGHT_METER_BUBBLES:Object = {start:1, end:31, loop:true};
public static var TUMBLE1:Object = {start:124, end:141, loop:false};
public static var HUD_TRICK_FLAG_GOOD:Object = {start:1, end:40, loop:false};
public static var HUD_TRICK_SCORE_07_08:Object = {start:22, end:24, loop:false};
public static var HUD_STEAM:Object = {start:1, end:70, loop:false};
public static var TUMBLE3:Object = {start:142, end:156, loop:false};
public static var TUMBLE:Object = {start:110, end:131, loop:true};
public static var HUD_TRICK_METER_GAMEOVER:Object = {start:20, end:20, loop:false};
public static var IDLE:Object = {start:1, end:8, loop:true};
public static var HUD_TRICK_FLAG_GREAT:Object = {start:51, end:90, loop:false};
public static var HUD_TRICK_SCORE_00_00:Object = {start:30, end:30, loop:false};
public static var SPINSTOP_GOOD:Object = {start:160, end:165, loop:true};
public static var SCRN_INSTR:Object = {start:1, end:100, loop:true};
public static var SPAWN:Object = {start:1, end:1, loop:true};
public static var JUMP_LAND:Object = {start:40, end:40, loop:false};
public static var JUMP_READY:Object = {start:10, end:12, loop:false};
public static var FALL_IN_GAP:Object = {start:170, end:175, loop:true};
public static var RIDER_VICTORY_DANCE:Object = {start:180, end:201, loop:true};
public static var SCRN_STORY:Object = {start:1, end:46, loop:false};
public static var HUD_TRICK_SCORE_02_03:Object = {start:7, end:9, loop:false};
public static var HUD_PISTON:Object = {start:1, end:60, loop:false};
public static var SPINSTOP_BAD:Object = {start:170, end:175, loop:true};
public static var HUD_TRICK_SCORE_06_07:Object = {start:19, end:21, loop:false};
public static var HUD_CONFETTI:Object = {start:1, end:31, loop:false};
public static var HUD_TRICK_FLAG_NICE:Object = {start:101, end:140, loop:false};
public static var HUD_TRICK_SCORE_09_00:Object = {start:28, end:30, loop:false};
public static var HUD_TRICK_METER:Object = {start:1, end:100, loop:false};
public static var HUD_TRICK_SCORE_01_02:Object = {start:4, end:6, loop:false};
public static function getEndFrameForDigit(_arg1:int):int{
var _local2:int;
_local2 = 0;
switch (_arg1){
case 1:
_local2 = HUD_TRICK_SCORE_00_01.end;
break;
case 2:
_local2 = HUD_TRICK_SCORE_01_02.end;
break;
case 3:
_local2 = HUD_TRICK_SCORE_02_03.end;
break;
case 4:
_local2 = HUD_TRICK_SCORE_03_04.end;
break;
case 5:
_local2 = HUD_TRICK_SCORE_04_05.end;
break;
case 6:
_local2 = HUD_TRICK_SCORE_05_06.end;
break;
case 7:
_local2 = HUD_TRICK_SCORE_06_07.end;
break;
case 8:
_local2 = HUD_TRICK_SCORE_07_08.end;
break;
case 9:
_local2 = HUD_TRICK_SCORE_08_09.end;
break;
case 0:
_local2 = HUD_TRICK_SCORE_09_00.end;
break;
};
return (_local2);
}
public static function createDigitIncrement(_arg1:int, _arg2:int):Object{
var _local3:int;
var _local4:int;
switch (_arg1){
case 0:
_local3 = HUD_TRICK_SCORE_00_01.start;
break;
case 1:
_local3 = HUD_TRICK_SCORE_01_02.start;
break;
case 2:
_local3 = HUD_TRICK_SCORE_02_03.start;
break;
case 3:
_local3 = HUD_TRICK_SCORE_03_04.start;
break;
case 4:
_local3 = HUD_TRICK_SCORE_04_05.start;
break;
case 5:
_local3 = HUD_TRICK_SCORE_05_06.start;
break;
case 6:
_local3 = HUD_TRICK_SCORE_06_07.start;
break;
case 7:
_local3 = HUD_TRICK_SCORE_07_08.start;
break;
case 8:
_local3 = HUD_TRICK_SCORE_08_09.start;
break;
case 9:
_local3 = HUD_TRICK_SCORE_09_00.start;
break;
};
switch (_arg2){
case 1:
_local4 = HUD_TRICK_SCORE_00_01.end;
break;
case 2:
_local4 = HUD_TRICK_SCORE_01_02.end;
break;
case 3:
_local4 = HUD_TRICK_SCORE_02_03.end;
break;
case 4:
_local4 = HUD_TRICK_SCORE_03_04.end;
break;
case 5:
_local4 = HUD_TRICK_SCORE_04_05.end;
break;
case 6:
_local4 = HUD_TRICK_SCORE_05_06.end;
break;
case 7:
_local4 = HUD_TRICK_SCORE_06_07.end;
break;
case 8:
_local4 = HUD_TRICK_SCORE_07_08.end;
break;
case 9:
_local4 = HUD_TRICK_SCORE_08_09.end;
break;
case 0:
_local4 = HUD_TRICK_SCORE_09_00.end;
break;
};
return ({start:_local3, end:_local4, loop:false});
}
}
}//package game
Section 131
//GameData (game.GameData)
package game {
import flash.display.*;
import base.utils.*;
public class GameData {
public var _screen:Sprite;
public var _background:Sprite;
public var _world:Sprite;
private var _gameReplay:Boolean;// = false
private var _finalScore:Number;// = 0
var _gameContext:GameEntry;
public var _board:Sprite;
public static const WORLD:int = 1;
public static const BACKGROUND:int = 3;
public static const BOARD:int = 2;
public static const STAGE:int = 0;
public function GameData(_arg1:GameEntry){
_finalScore = 0;
_gameReplay = false;
super();
_gameContext = _arg1;
configGameLayers();
}
public function clearGameLayers():void{
if (((!((_background == null))) && (_world.contains(_background)))){
_world.removeChild(_background);
_background = null;
};
if (((!((_board == null))) && (_world.contains(_board)))){
_world.removeChild(_board);
_board = null;
};
if (((!((_world == null))) && (_gameContext.contains(_world)))){
_gameContext.removeChild(_world);
_world = null;
};
}
public function getGameLayer(_arg1:Number):DisplayObjectContainer{
switch (_arg1){
case STAGE:
return (_gameContext);
case WORLD:
return (_world);
case BACKGROUND:
return (_background);
case BOARD:
return (_board);
default:
return (_gameContext);
};
}
public function init():void{
RandomNumber.seed = Math.floor(((Math.random() * 20) + 1));
}
public function cleanup():void{
}
public function toString():String{
return ("GameData()");
}
public function set gameReplay(_arg1:Boolean):void{
_gameReplay = _arg1;
}
public function submitFinalScore():void{
}
public function configGameLayers():void{
_world = new Sprite();
_gameContext.addChild(_world);
_background = new Sprite();
_world.addChild(_background);
_board = new Sprite();
_world.addChild(_board);
_screen = new Sprite();
_gameContext.addChild(_screen);
}
public function set finalScore(_arg1:Number):void{
_finalScore = _arg1;
}
public function get gameReplay():Boolean{
return (_gameReplay);
}
public function get finalScore():Number{
return (_finalScore);
}
}
}//package game
Section 132
//SoundData (game.SoundData)
package game {
public class SoundData {
public static var SFX_HERO_FALL_OFFSCREEN:Object = {linkage:"sfx_Fall_Offscreen", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_TRICK_SCORE_TILE_FLIP:Object = {linkage:"sfx_TrickScoreTileFlip", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_SPIN_MULTIPLIER:Object = {linkage:"sfx_SpinMultiplierChime", vol:1, pan:0, offset:0, loop:false, force:true};
public static var SFX_SNOWBOARDING_LOOP:Object = {linkage:"sfx_SnowboardingLoop", vol:1, pan:0, offset:0, loop:true, force:true};
public static var SFX_HERO_DUCK:Object = {linkage:"sfx_Duck", vol:1, pan:0, offset:0, loop:false, force:false};
public static var MUSIC_GAMELOOP:Object = {linkage:"Music_InGame", vol:0.8, pan:0, offset:0, loop:true, force:false};
public static var SFX_SNOW_TRANSITION_ANIM:Object = {linkage:"sfx_Snow_Transition", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_HERO_ROLL_GROUND_LOOP:Object = {linkage:"sfx_Tumble_Loop", vol:1, pan:0, offset:0, loop:true, force:false};
public static var SFX_TRICK_RATING_FLAG:Object = {linkage:"sfx_TrickRatingFlagAppear", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_LAND_FROM_JUMP:Object = {linkage:"sfx_LandFromJump", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_LAND_BAD:Object = {linkage:"sfx_LandBad", vol:1, pan:0, offset:0, loop:false, force:false};
public static var STING_GAME_END:Object = {linkage:"Sting_EndGame", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_GROUND_TUMBLE:Object = {linkage:"sfx_GroundTumble", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_AIRBOURNE_LOOP:Object = {linkage:"sfx_AirbourneWindLoop", vol:1, pan:0, offset:0, loop:true, force:false};
public static var SFX_HIT_OBSTACLE:Object = {linkage:"sfx_HitOverheadObstacle", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_FACEPLANT_TUMBLE_END:Object = {linkage:"sfx_Faceplant", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_LAND_GOOD:Object = {linkage:"sfx_LandGood", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_TRICK_METER_LOW:Object = {linkage:"sfx_TrickMeterLowAlert", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_HERO_JUMP:Object = {linkage:"sfx_Jump", vol:1, pan:0, offset:0, loop:false, force:false};
public static var SFX_CONFETTI_CANNON:Object = {linkage:"sfx_ConfettiCannonBurst", vol:1, pan:0, offset:0, loop:false, force:false};
public static var MUSIC_TITLE:Object = {linkage:"Music_Title", vol:1, pan:0, offset:0, loop:true, force:false};
public static var SFX_HERO_RESPAWN:Object = {linkage:"sfx_Respawn", vol:1, pan:0, offset:0, loop:false, force:false};
public static function setTransform(_arg1:Object, _arg2:Number, _arg3:Number){
_arg1.vol = _arg2;
_arg1.pan = _arg3;
}
public static function getSoundLinkage(_arg1:Object):String{
return (_arg1.linkage);
}
}
}//package game
Section 133
//Action (org.flintparticles.common.actions.Action)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.behaviours.*;
public interface Action extends Behaviour {
function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void;
}
}//package org.flintparticles.common.actions
Section 134
//ActionBase (org.flintparticles.common.actions.ActionBase)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class ActionBase implements Action {
protected var _priority:int;// = 0
public function ActionBase(){
_priority = 0;
super();
}
public function get priority():int{
return (_priority);
}
public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
}
public function set priority(_arg1:int):void{
_priority = _arg1;
}
public function addedToEmitter(_arg1:Emitter):void{
}
public function removedFromEmitter(_arg1:Emitter):void{
}
}
}//package org.flintparticles.common.actions
Section 135
//Age (org.flintparticles.common.actions.Age)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.energyEasing.*;
public class Age extends ActionBase {
private var _easing:Function;
public function Age(_arg1:Function=null){
if (_arg1 == null){
_easing = Linear.easeNone;
} else {
_easing = _arg1;
};
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
_arg2.age = (_arg2.age + _arg3);
if (_arg2.age >= _arg2.lifetime){
_arg2.energy = 0;
_arg2.isDead = true;
} else {
_arg2.energy = _easing(_arg2.age, _arg2.lifetime);
};
}
public function get easing():Function{
return (_easing);
}
public function set easing(_arg1:Function):void{
_easing = _arg1;
}
}
}//package org.flintparticles.common.actions
Section 136
//Fade (org.flintparticles.common.actions.Fade)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class Fade extends ActionBase {
private var _endAlpha:Number;
private var _diffAlpha:Number;
public function Fade(_arg1:Number=1, _arg2:Number=0){
priority = -5;
_diffAlpha = (_arg1 - _arg2);
_endAlpha = _arg2;
}
public function get endAlpha():Number{
return (_endAlpha);
}
public function set endAlpha(_arg1:Number):void{
_diffAlpha = ((_endAlpha + _diffAlpha) - _arg1);
_endAlpha = _arg1;
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
var _local4:Number;
_local4 = (_endAlpha + (_diffAlpha * _arg2.energy));
_arg2.color = ((_arg2.color & 0xFFFFFF) | (Math.round((_local4 * 0xFF)) << 24));
}
public function set startAlpha(_arg1:Number):void{
_diffAlpha = (_arg1 - _endAlpha);
}
public function get startAlpha():Number{
return ((_endAlpha + _diffAlpha));
}
}
}//package org.flintparticles.common.actions
Section 137
//ScaleImage (org.flintparticles.common.actions.ScaleImage)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class ScaleImage extends ActionBase {
private var _diffScale:Number;
private var _endScale:Number;
public function ScaleImage(_arg1:Number=1, _arg2:Number=1){
_diffScale = (_arg1 - _arg2);
_endScale = _arg2;
}
public function set endScale(_arg1:Number):void{
_diffScale = ((_endScale + _diffScale) - _arg1);
_endScale = _arg1;
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
_arg2.scale = (_endScale + (_diffScale * _arg2.energy));
}
public function get startScale():Number{
return ((_endScale + _diffScale));
}
public function get endScale():Number{
return (_endScale);
}
public function set startScale(_arg1:Number):void{
_diffScale = (_arg1 - _endScale);
}
}
}//package org.flintparticles.common.actions
Section 138
//Activity (org.flintparticles.common.activities.Activity)
package org.flintparticles.common.activities {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.behaviours.*;
public interface Activity extends Behaviour {
function initialize(_arg1:Emitter):void;
function update(_arg1:Emitter, _arg2:Number):void;
}
}//package org.flintparticles.common.activities
Section 139
//Behaviour (org.flintparticles.common.behaviours.Behaviour)
package org.flintparticles.common.behaviours {
import org.flintparticles.common.emitters.*;
public interface Behaviour {
function addedToEmitter(_arg1:Emitter):void;
function get priority():int;
function set priority(_arg1:int):void;
function removedFromEmitter(_arg1:Emitter):void;
}
}//package org.flintparticles.common.behaviours
Section 140
//BehaviourArrayUtils (org.flintparticles.common.behaviours.BehaviourArrayUtils)
package org.flintparticles.common.behaviours {
public class BehaviourArrayUtils {
public static function add(_arg1:Array, _arg2:Behaviour):uint{
var _local3:uint;
var _local4:uint;
_local3 = _arg1.length;
_local4 = 0;
while (_local4 < _local3) {
if (Behaviour(_arg1[_local4]).priority < _arg2.priority){
break;
};
_local4++;
};
_arg1.splice(_local4, 0, _arg2);
return ((_local3 + 1));
}
public static function remove(_arg1:Array, _arg2:Behaviour):Boolean{
var _local3:int;
_local3 = _arg1.indexOf(_arg2);
if (_local3 != -1){
_arg1.splice(_local3, 1);
return (true);
};
return (false);
}
public static function removeAt(_arg1:Array, _arg2:uint):Behaviour{
var _local3:Behaviour;
_local3 = (_arg1[_arg2] as Behaviour);
_arg1.splice(_arg2, 1);
return (_local3);
}
public static function containsType(_arg1:Array, _arg2:Class):Boolean{
var _local3:uint;
var _local4:uint;
_local3 = _arg1.length;
_local4 = 0;
while (_local4 < _local3) {
if ((_arg1[_local4] is _arg2)){
return (true);
};
_local4++;
};
return (false);
}
public static function sortArray(_arg1:Array):void{
_arg1.sortOn("priority", Array.NUMERIC);
}
public static function clear(_arg1:Array):void{
_arg1.length = 0;
}
public static function contains(_arg1:Array, _arg2:Behaviour):Boolean{
return (!((_arg1.indexOf(_arg2) == -1)));
}
}
}//package org.flintparticles.common.behaviours
Section 141
//Blast (org.flintparticles.common.counters.Blast)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class Blast implements Counter {
private var _done:Boolean;// = false
private var _startCount:uint;
public function Blast(_arg1:uint=0){
_done = false;
super();
_startCount = _arg1;
}
public function updateEmitter(_arg1:Emitter, _arg2:Number):uint{
return (0);
}
public function get startCount():Number{
return (_startCount);
}
public function stop():void{
}
public function resume():void{
}
public function get complete():Boolean{
return (_done);
}
public function set startCount(_arg1:Number):void{
_startCount = _arg1;
}
public function startEmitter(_arg1:Emitter):uint{
_arg1.dispatchCounterComplete();
return (_startCount);
}
}
}//package org.flintparticles.common.counters
Section 142
//Counter (org.flintparticles.common.counters.Counter)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public interface Counter {
function stop():void;
function updateEmitter(_arg1:Emitter, _arg2:Number):uint;
function get complete():Boolean;
function startEmitter(_arg1:Emitter):uint;
function resume():void;
}
}//package org.flintparticles.common.counters
Section 143
//Steady (org.flintparticles.common.counters.Steady)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class Steady implements Counter {
private var _stop:Boolean;
private var _rateInv:Number;
private var _timeToNext:Number;
private var _rate:Number;
public function Steady(_arg1:Number=0){
_stop = false;
_rate = _arg1;
_rateInv = (1 / _rate);
}
public function get rate():Number{
return (_rate);
}
public function updateEmitter(_arg1:Emitter, _arg2:Number):uint{
var _local3:uint;
if (_stop){
return (0);
};
_local3 = 0;
_timeToNext = (_timeToNext - _arg2);
while (_timeToNext <= 0) {
_local3++;
_timeToNext = (_timeToNext + _rateInv);
};
return (_local3);
}
public function stop():void{
_stop = true;
}
public function startEmitter(_arg1:Emitter):uint{
_timeToNext = _rateInv;
return (0);
}
public function resume():void{
_stop = false;
}
public function set rate(_arg1:Number):void{
_rate = _arg1;
_rateInv = (1 / _arg1);
}
public function get complete():Boolean{
return (false);
}
}
}//package org.flintparticles.common.counters
Section 144
//ZeroCounter (org.flintparticles.common.counters.ZeroCounter)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class ZeroCounter implements Counter {
public function stop():void{
}
public function startEmitter(_arg1:Emitter):uint{
return (0);
}
public function updateEmitter(_arg1:Emitter, _arg2:Number):uint{
return (0);
}
public function resume():void{
}
public function get complete():Boolean{
return (true);
}
}
}//package org.flintparticles.common.counters
Section 145
//Emitter (org.flintparticles.common.emitters.Emitter)
package org.flintparticles.common.emitters {
import flash.events.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.behaviours.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.activities.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.events.*;
import org.flintparticles.common.utils.*;
public class Emitter extends EventDispatcher {
protected var _running:Boolean;// = false
protected var _activities:Array;
protected var _particles:Array;
protected var _initializers:Array;
protected var _dispatchCounterComplete:Boolean;// = false
protected var _counter:Counter;
protected var _started:Boolean;// = false
protected var _actions:Array;
protected var _useInternalTick:Boolean;// = true
protected var _fixedFrameTime:Number;// = 0
protected var _particleFactory:ParticleFactory;
protected var _maximumFrameTime:Number;// = 0.1
public function Emitter(){
_useInternalTick = true;
_fixedFrameTime = 0;
_running = false;
_started = false;
_maximumFrameTime = 0.1;
_dispatchCounterComplete = false;
super();
_particles = new Array();
_actions = new Array();
_initializers = new Array();
_activities = new Array();
_counter = new ZeroCounter();
}
public function dispatchCounterComplete():void{
_dispatchCounterComplete = true;
}
public function get counter():Counter{
return (_counter);
}
public function runAhead(_arg1:Number, _arg2:Number=10):void{
var _local3:Number;
var _local4:Number;
_local3 = _maximumFrameTime;
_local4 = (1 / _arg2);
_maximumFrameTime = _local4;
while (_arg1 > 0) {
_arg1 = (_arg1 - _local4);
update(_local4);
};
_maximumFrameTime = _local3;
}
public function addInitializer(_arg1:Initializer):void{
BehaviourArrayUtils.add(_initializers, _arg1);
_arg1.addedToEmitter(this);
}
public function killAllParticles():void{
var _local1:int;
var _local2:int;
_local1 = _particles.length;
_local2 = 0;
while (_local2 < _local1) {
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_DEAD, _particles[_local2]));
_particleFactory.disposeParticle(_particles[_local2]);
_local2++;
};
_particles.length = 0;
}
public function stop():void{
if (_useInternalTick){
FrameUpdater.instance.removeEventListener(UpdateEvent.UPDATE, updateEventListener);
};
_started = false;
killAllParticles();
}
public function set fixedFrameTime(_arg1:Number):void{
_fixedFrameTime = _arg1;
}
public function get maximumFrameTime():Number{
return (_maximumFrameTime);
}
public function set particles(_arg1:Array):void{
killAllParticles();
addExistingParticles(_arg1, false);
}
public function get useInternalTick():Boolean{
return (_useInternalTick);
}
public function set initializers(_arg1:Array):void{
var _local2:Initializer;
for each (_local2 in _initializers) {
_local2.removedFromEmitter(this);
};
_initializers = _arg1.slice();
BehaviourArrayUtils.sortArray(_initializers);
for each (_local2 in _arg1) {
_local2.addedToEmitter(this);
};
}
public function get particleFactory():ParticleFactory{
return (_particleFactory);
}
private function updateEventListener(_arg1:UpdateEvent):void{
if (_fixedFrameTime){
update(_fixedFrameTime);
} else {
update(_arg1.time);
};
}
protected function createParticle():Particle{
var _local1:Particle;
var _local2:int;
var _local3:int;
_local1 = _particleFactory.createParticle();
_local2 = _initializers.length;
initParticle(_local1);
_local3 = 0;
while (_local3 < _local2) {
Initializer(_initializers[_local3]).initialize(this, _local1);
_local3++;
};
_particles.push(_local1);
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_CREATED, _local1));
return (_local1);
}
protected function sortParticles():void{
}
public function set maximumFrameTime(_arg1:Number):void{
_maximumFrameTime = _arg1;
}
protected function initParticle(_arg1:Particle):void{
}
public function addAction(_arg1:Action):void{
BehaviourArrayUtils.add(_actions, _arg1);
_arg1.addedToEmitter(this);
}
public function hasInitializerOfType(_arg1:Class):Boolean{
return (BehaviourArrayUtils.containsType(_initializers, _arg1));
}
public function removeActivity(_arg1:Activity):void{
if (BehaviourArrayUtils.remove(_activities, _arg1)){
_arg1.removedFromEmitter(this);
};
}
public function removeInitializer(_arg1:Initializer):void{
if (BehaviourArrayUtils.remove(_initializers, _arg1)){
_arg1.removedFromEmitter(this);
};
}
public function get running():Boolean{
return (_running);
}
public function hasActionOfType(_arg1:Class):Boolean{
return (BehaviourArrayUtils.containsType(_actions, _arg1));
}
public function get fixedFrameTime():Number{
return (_fixedFrameTime);
}
public function set particleFactory(_arg1:ParticleFactory):void{
_particleFactory = _arg1;
}
public function hasActivity(_arg1:Activity):Boolean{
return (BehaviourArrayUtils.contains(_activities, _arg1));
}
public function get particles():Array{
return (_particles);
}
public function addActivity(_arg1:Activity):void{
BehaviourArrayUtils.add(_activities, _arg1);
_arg1.addedToEmitter(this);
}
public function get initializers():Array{
return (_initializers);
}
public function removeAction(_arg1:Action):void{
if (BehaviourArrayUtils.remove(_actions, _arg1)){
_arg1.removedFromEmitter(this);
};
}
public function set activities(_arg1:Array):void{
var _local2:Activity;
for each (_local2 in _activities) {
_local2.removedFromEmitter(this);
};
_activities = _arg1.slice();
BehaviourArrayUtils.sortArray(_activities);
for each (_local2 in _activities) {
_local2.addedToEmitter(this);
};
}
public function addExistingParticles(_arg1:Array, _arg2:Boolean=false):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
_local3 = _arg1.length;
if (_arg2){
_local5 = _initializers.length;
_local6 = 0;
while (_local6 < _local5) {
_local4 = 0;
while (_local4 < _local3) {
Initializer(_initializers[_local6]).initialize(this, _arg1[_local4]);
_local4++;
};
_local6++;
};
};
_local4 = 0;
while (_local4 < _local3) {
_particles.push(_arg1[_local4]);
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_ADDED, _arg1[_local4]));
_local4++;
};
}
public function set useInternalTick(_arg1:Boolean):void{
if (_useInternalTick != _arg1){
_useInternalTick = _arg1;
if (_started){
if (_useInternalTick){
FrameUpdater.instance.addEventListener(UpdateEvent.UPDATE, updateEventListener, false, 0, true);
} else {
FrameUpdater.instance.removeEventListener(UpdateEvent.UPDATE, updateEventListener);
};
};
};
}
public function resume():void{
_running = true;
}
public function hasInitializer(_arg1:Initializer):Boolean{
return (BehaviourArrayUtils.contains(_initializers, _arg1));
}
public function hasActivityOfType(_arg1:Class):Boolean{
return (BehaviourArrayUtils.containsType(_activities, _arg1));
}
public function update(_arg1:Number):void{
var _local2:int;
var _local3:Particle;
var _local4:int;
var _local5:Action;
var _local6:int;
var _local7:int;
if (!_running){
return;
};
if (_arg1 > _maximumFrameTime){
_arg1 = _maximumFrameTime;
};
_local4 = _counter.updateEmitter(this, _arg1);
_local2 = 0;
while (_local2 < _local4) {
createParticle();
_local2++;
};
sortParticles();
_local4 = _activities.length;
_local2 = 0;
while (_local2 < _local4) {
Activity(_activities[_local2]).update(this, _arg1);
_local2++;
};
if (_particles.length > 0){
_local4 = _actions.length;
_local6 = _particles.length;
_local7 = 0;
while (_local7 < _local4) {
_local5 = _actions[_local7];
_local2 = 0;
while (_local2 < _local6) {
_local3 = _particles[_local2];
_local5.update(this, _local3, _arg1);
_local2++;
};
_local7++;
};
_local2 = _local6;
while (_local2--) {
_local3 = _particles[_local2];
if (_local3.isDead){
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_DEAD, _local3));
_particleFactory.disposeParticle(_local3);
_particles.splice(_local2, 1);
};
};
} else {
dispatchEvent(new EmitterEvent(EmitterEvent.EMITTER_EMPTY));
};
dispatchEvent(new EmitterEvent(EmitterEvent.EMITTER_UPDATED));
if (_dispatchCounterComplete){
_dispatchCounterComplete = false;
dispatchEvent(new EmitterEvent(EmitterEvent.COUNTER_COMPLETE));
};
}
public function get activities():Array{
return (_activities);
}
public function hasAction(_arg1:Action):Boolean{
return (BehaviourArrayUtils.contains(_actions, _arg1));
}
public function start():void{
var _local1:int;
var _local2:int;
if (_useInternalTick){
FrameUpdater.instance.addEventListener(UpdateEvent.UPDATE, updateEventListener, false, 0, true);
};
_started = true;
_running = true;
_local1 = _activities.length;
_local2 = 0;
while (_local2 < _local1) {
Activity(_activities[_local2]).initialize(this);
_local2++;
};
_local1 = _counter.startEmitter(this);
_local2 = 0;
while (_local2 < _local1) {
createParticle();
_local2++;
};
}
public function pause():void{
_running = false;
}
public function set actions(_arg1:Array):void{
var _local2:Action;
for each (_local2 in _actions) {
_local2.removedFromEmitter(this);
};
_actions = _arg1.slice();
BehaviourArrayUtils.sortArray(_actions);
for each (_local2 in _arg1) {
_local2.addedToEmitter(this);
};
}
public function get actions():Array{
return (_actions);
}
public function set counter(_arg1:Counter):void{
_counter = _arg1;
if (running){
_counter.startEmitter(this);
};
}
}
}//package org.flintparticles.common.emitters
Section 146
//Linear (org.flintparticles.common.energyEasing.Linear)
package org.flintparticles.common.energyEasing {
public class Linear {
public static function easeOut(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
public static function easeIn(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
public static function easeInOut(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
public static function easeNone(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
}
}//package org.flintparticles.common.energyEasing
Section 147
//EmitterEvent (org.flintparticles.common.events.EmitterEvent)
package org.flintparticles.common.events {
import flash.events.*;
public class EmitterEvent extends Event {
public static var COUNTER_COMPLETE:String = "counterComplete";
public static var EMITTER_UPDATED:String = "emitterUpdated";
public static var EMITTER_EMPTY:String = "emitterEmpty";
public function EmitterEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
}
}//package org.flintparticles.common.events
Section 148
//ParticleEvent (org.flintparticles.common.events.ParticleEvent)
package org.flintparticles.common.events {
import flash.events.*;
import org.flintparticles.common.particles.*;
public class ParticleEvent extends Event {
public var particle:Particle;
public var otherObject;
public static var PARTICLES_COLLISION:String = "particlesCollision";
public static var PARTICLE_ADDED:String = "particleAdded";
public static var PARTICLE_DEAD:String = "particleDead";
public static var PARTICLE_CREATED:String = "particleCreated";
public function ParticleEvent(_arg1:String, _arg2:Particle=null, _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.particle = _arg2;
}
override public function clone():Event{
var _local1:ParticleEvent;
_local1 = new ParticleEvent(type, particle, bubbles, cancelable);
_local1.otherObject = otherObject;
return (_local1);
}
}
}//package org.flintparticles.common.events
Section 149
//UpdateEvent (org.flintparticles.common.events.UpdateEvent)
package org.flintparticles.common.events {
import flash.events.*;
public class UpdateEvent extends Event {
public var time:Number;
public static var UPDATE:String = "update";
public function UpdateEvent(_arg1:String, _arg2:Number=NaN, _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.time = _arg2;
}
override public function clone():Event{
return (new UpdateEvent(type, time, bubbles, cancelable));
}
}
}//package org.flintparticles.common.events
Section 150
//ImageClass (org.flintparticles.common.initializers.ImageClass)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.utils.*;
public class ImageClass extends InitializerBase {
private var _parameters:Array;
private var _imageClass:Class;
public function ImageClass(_arg1:Class=null, ... _args){
_imageClass = _arg1;
_parameters = _args;
}
public function set imageClass(_arg1:Class):void{
_imageClass = _arg1;
}
public function get parameters():Array{
return (_parameters);
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
_arg2.image = construct(_imageClass, _parameters);
}
public function set parameters(_arg1:Array):void{
_parameters = _arg1;
}
public function get imageClass():Class{
return (_imageClass);
}
}
}//package org.flintparticles.common.initializers
Section 151
//Initializer (org.flintparticles.common.initializers.Initializer)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.behaviours.*;
public interface Initializer extends Behaviour {
function initialize(_arg1:Emitter, _arg2:Particle):void;
}
}//package org.flintparticles.common.initializers
Section 152
//InitializerBase (org.flintparticles.common.initializers.InitializerBase)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class InitializerBase implements Initializer {
protected var _priority:int;// = 0
public function InitializerBase(){
_priority = 0;
super();
}
public function get priority():int{
return (_priority);
}
public function set priority(_arg1:int):void{
_priority = _arg1;
}
public function initialize(_arg1:Emitter, _arg2:Particle):void{
}
public function addedToEmitter(_arg1:Emitter):void{
}
public function removedFromEmitter(_arg1:Emitter):void{
}
}
}//package org.flintparticles.common.initializers
Section 153
//Lifetime (org.flintparticles.common.initializers.Lifetime)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class Lifetime extends InitializerBase {
private var _min:Number;
private var _max:Number;
public function Lifetime(_arg1:Number=1.79769313486232E308, _arg2:Number=NaN){
_max = _arg2;
_min = _arg1;
}
public function get lifetime():Number{
return (((_min == _max)) ? _min : ((_max + _min) * 0.5));
}
public function get maxLifetime():Number{
return (_max);
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
if (isNaN(_max)){
_arg2.lifetime = _min;
} else {
_arg2.lifetime = (_min + (Math.random() * (_max - _min)));
};
}
public function set lifetime(_arg1:Number):void{
_max = (_min = _arg1);
}
public function set maxLifetime(_arg1:Number):void{
_max = _arg1;
}
public function set minLifetime(_arg1:Number):void{
_min = _arg1;
}
public function get minLifetime():Number{
return (_min);
}
}
}//package org.flintparticles.common.initializers
Section 154
//ScaleImageInit (org.flintparticles.common.initializers.ScaleImageInit)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class ScaleImageInit extends InitializerBase {
private var _min:Number;
private var _max:Number;
public function ScaleImageInit(_arg1:Number=1, _arg2:Number=NaN){
_min = _arg1;
if (isNaN(_arg2)){
_max = _min;
} else {
_max = _arg2;
};
}
public function set maxScale(_arg1:Number):void{
_max = _arg1;
}
public function get maxScale():Number{
return (_max);
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
if (_max == _min){
_arg2.scale = _min;
} else {
_arg2.scale = (_min + (Math.random() * (_max - _min)));
};
}
public function get scale():Number{
return (((_min == _max)) ? _min : ((_max + _min) / 2));
}
public function set scale(_arg1:Number):void{
_max = (_min = _arg1);
}
public function get minScale():Number{
return (_min);
}
public function set minScale(_arg1:Number):void{
_min = _arg1;
}
}
}//package org.flintparticles.common.initializers
Section 155
//Particle (org.flintparticles.common.particles.Particle)
package org.flintparticles.common.particles {
import flash.utils.*;
import flash.geom.*;
public class Particle {
public var lifetime:Number;// = 0
public var scale:Number;// = 1
public var energy:Number;// = 1
public var image;// = null
public var color:uint;// = 4294967295
public var collisionRadius:Number;// = 1
private var _colorTransform:ColorTransform;// = null
private var _previousColor:uint;
public var isDead:Boolean;// = false
public var mass:Number;// = 1
private var _dictionary:Dictionary;// = null
public var age:Number;// = 0
public function Particle(){
color = 4294967295;
_colorTransform = null;
scale = 1;
mass = 1;
collisionRadius = 1;
image = null;
lifetime = 0;
age = 0;
energy = 1;
isDead = false;
_dictionary = null;
super();
}
public function get dictionary():Dictionary{
if (_dictionary == null){
_dictionary = new Dictionary(true);
};
return (_dictionary);
}
public function get colorTransform():ColorTransform{
if (((!(_colorTransform)) || (!((_previousColor == color))))){
_colorTransform = new ColorTransform((((color >>> 16) & 0xFF) / 0xFF), (((color >>> 8) & 0xFF) / 0xFF), ((color & 0xFF) / 0xFF), (((color >>> 24) & 0xFF) / 0xFF), 0, 0, 0, 0);
_previousColor = color;
};
return (_colorTransform);
}
protected function cloneInto(_arg1:Particle):Particle{
var _local2:Object;
_arg1.color = color;
_arg1.scale = scale;
_arg1.mass = mass;
_arg1.collisionRadius = collisionRadius;
_arg1.lifetime = lifetime;
_arg1.age = age;
_arg1.energy = energy;
_arg1.isDead = isDead;
_arg1.image = image;
if (_dictionary){
_arg1._dictionary = new Dictionary(true);
for (_local2 in _dictionary) {
_arg1._dictionary[_local2] = _dictionary[_local2];
};
};
return (_arg1);
}
public function get alpha():Number{
return ((((color & 4278190080) >>> 24) / 0xFF));
}
public function clone(_arg1:ParticleFactory=null):Particle{
var _local2:Particle;
if (_arg1){
_local2 = _arg1.createParticle();
} else {
_local2 = new Particle();
};
return (cloneInto(_local2));
}
public function initialize():void{
color = 4294967295;
scale = 1;
mass = 1;
collisionRadius = 1;
lifetime = 0;
age = 0;
energy = 1;
isDead = false;
image = null;
_dictionary = null;
_colorTransform = null;
}
}
}//package org.flintparticles.common.particles
Section 156
//ParticleFactory (org.flintparticles.common.particles.ParticleFactory)
package org.flintparticles.common.particles {
public interface ParticleFactory {
function createParticle():Particle;
function disposeParticle(_arg1:Particle):void;
function clearAllParticles():void;
}
}//package org.flintparticles.common.particles
Section 157
//Renderer (org.flintparticles.common.renderers.Renderer)
package org.flintparticles.common.renderers {
import org.flintparticles.common.emitters.*;
public interface Renderer {
function removeEmitter(_arg1:Emitter):void;
function addEmitter(_arg1:Emitter):void;
}
}//package org.flintparticles.common.renderers
Section 158
//SpriteRendererBase (org.flintparticles.common.renderers.SpriteRendererBase)
package org.flintparticles.common.renderers {
import flash.display.*;
import flash.events.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.events.*;
public class SpriteRendererBase extends Sprite implements Renderer {
protected var _emitters:Array;
public function SpriteRendererBase(){
_emitters = new Array();
mouseEnabled = false;
mouseChildren = false;
addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);
}
private function particleAdded(_arg1:ParticleEvent):void{
addParticle(_arg1.particle);
if (stage){
stage.invalidate();
};
}
private function addedToStage(_arg1:Event):void{
if (stage){
stage.invalidate();
};
}
protected function removeParticle(_arg1:Particle):void{
}
protected function addParticle(_arg1:Particle):void{
}
public function removeEmitter(_arg1:Emitter):void{
var _local2:int;
var _local3:Particle;
_local2 = 0;
while (_local2 < _emitters.length) {
if (_emitters[_local2] == _arg1){
_emitters.splice(_local2, 1);
_arg1.removeEventListener(EmitterEvent.EMITTER_UPDATED, emitterUpdated);
_arg1.removeEventListener(ParticleEvent.PARTICLE_CREATED, particleAdded);
_arg1.removeEventListener(ParticleEvent.PARTICLE_ADDED, particleAdded);
_arg1.removeEventListener(ParticleEvent.PARTICLE_DEAD, particleRemoved);
for each (_local3 in _arg1.particles) {
removeParticle(_local3);
};
if (_emitters.length == 0){
removeEventListener(Event.RENDER, updateParticles);
renderParticles([]);
} else {
if (stage){
stage.invalidate();
};
};
return;
};
_local2++;
};
}
private function emitterUpdated(_arg1:EmitterEvent):void{
if (stage){
stage.invalidate();
};
}
public function set emitters(_arg1:Array):void{
var _local2:Emitter;
for each (_local2 in _emitters) {
removeEmitter(_local2);
};
for each (_local2 in _arg1) {
addEmitter(_local2);
};
}
public function addEmitter(_arg1:Emitter):void{
var _local2:Particle;
_emitters.push(_arg1);
if (stage){
stage.invalidate();
};
_arg1.addEventListener(EmitterEvent.EMITTER_UPDATED, emitterUpdated, false, 0, true);
_arg1.addEventListener(ParticleEvent.PARTICLE_CREATED, particleAdded, false, 0, true);
_arg1.addEventListener(ParticleEvent.PARTICLE_ADDED, particleAdded, false, 0, true);
_arg1.addEventListener(ParticleEvent.PARTICLE_DEAD, particleRemoved, false, 0, true);
for each (_local2 in _arg1.particles) {
addParticle(_local2);
};
if (_emitters.length == 1){
addEventListener(Event.RENDER, updateParticles, false, 0, true);
};
}
protected function renderParticles(_arg1:Array):void{
}
public function get emitters():Array{
return (_emitters);
}
private function updateParticles(_arg1:Event):void{
var _local2:Array;
var _local3:int;
_local2 = new Array();
_local3 = 0;
while (_local3 < _emitters.length) {
_local2 = _local2.concat(Emitter(_emitters[_local3]).particles);
_local3++;
};
renderParticles(_local2);
}
private function particleRemoved(_arg1:ParticleEvent):void{
removeParticle(_arg1.particle);
if (stage){
stage.invalidate();
};
}
}
}//package org.flintparticles.common.renderers
Section 159
//construct (org.flintparticles.common.utils.construct)
package org.flintparticles.common.utils {
public function construct(_arg1:Class, _arg2:Array){
switch (_arg2.length){
case 0:
return (new (_arg1));
case 1:
return (new _arg1(_arg2[0]));
case 2:
return (new _arg1(_arg2[0], _arg2[1]));
case 3:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2]));
case 4:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2], _arg2[3]));
case 5:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2], _arg2[3], _arg2[4]));
case 6:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2], _arg2[3], _arg2[4], _arg2[5]));
case 7:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2], _arg2[3], _arg2[4], _arg2[5], _arg2[6]));
case 8:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2], _arg2[3], _arg2[4], _arg2[5], _arg2[6], _arg2[7]));
case 9:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2], _arg2[3], _arg2[4], _arg2[5], _arg2[6], _arg2[7], _arg2[8]));
case 10:
return (new _arg1(_arg2[0], _arg2[1], _arg2[2], _arg2[3], _arg2[4], _arg2[5], _arg2[6], _arg2[7], _arg2[8], _arg2[9]));
default:
return (null);
};
}
}//package org.flintparticles.common.utils
Section 160
//FrameUpdater (org.flintparticles.common.utils.FrameUpdater)
package org.flintparticles.common.utils {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import org.flintparticles.common.events.*;
public class FrameUpdater extends EventDispatcher {
private var _shape:Shape;
private var _time:Number;
private var _running:Boolean;// = false
private static var _instance:FrameUpdater;
public function FrameUpdater(){
_running = false;
super();
_shape = new Shape();
}
private function stopTimer():void{
_shape.removeEventListener(Event.ENTER_FRAME, frameUpdate);
_running = false;
}
override public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
super.removeEventListener(_arg1, _arg2, _arg3);
if (((_running) && (!(hasEventListener(UpdateEvent.UPDATE))))){
stopTimer();
};
}
private function startTimer():void{
_shape.addEventListener(Event.ENTER_FRAME, frameUpdate, false, 0, true);
_time = getTimer();
_running = true;
}
private function frameUpdate(_arg1:Event):void{
var _local2:int;
var _local3:Number;
_local2 = _time;
_time = getTimer();
_local3 = ((_time - _local2) * 0.001);
dispatchEvent(new UpdateEvent(UpdateEvent.UPDATE, _local3));
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
if (((!(_running)) && (hasEventListener(UpdateEvent.UPDATE)))){
startTimer();
};
}
public static function get instance():FrameUpdater{
if (_instance == null){
_instance = new (FrameUpdater);
};
return (_instance);
}
}
}//package org.flintparticles.common.utils
Section 161
//Maths (org.flintparticles.common.utils.Maths)
package org.flintparticles.common.utils {
public class Maths {
private static const DEGTORAD:Number = 0.0174532925199433;
private static const RADTODEG:Number = 57.2957795130823;
public static function asRadians(_arg1:Number):Number{
return ((_arg1 * DEGTORAD));
}
public static function asDegrees(_arg1:Number):Number{
return ((_arg1 * RADTODEG));
}
}
}//package org.flintparticles.common.utils
Section 162
//DeathZone (org.flintparticles.twoD.actions.DeathZone)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.twoD.particles.*;
public class DeathZone extends ActionBase {
private var _zone:Zone2D;
private var _invertZone:Boolean;
private var p:Particle2D;
private var inside:Boolean;
public function DeathZone(_arg1:Zone2D=null, _arg2:Boolean=false){
priority = -20;
this.zone = _arg1;
this.zoneIsSafe = _arg2;
}
public function set zoneIsSafe(_arg1:Boolean):void{
_invertZone = _arg1;
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
p = Particle2D(_arg2);
inside = _zone.contains(p.x, p.y);
if (_invertZone){
if (!inside){
p.isDead = true;
};
} else {
if (inside){
p.isDead = true;
};
};
}
public function set zone(_arg1:Zone2D):void{
_zone = _arg1;
}
public function get zoneIsSafe():Boolean{
return (_invertZone);
}
public function get zone():Zone2D{
return (_zone);
}
}
}//package org.flintparticles.twoD.actions
Section 163
//Move (org.flintparticles.twoD.actions.Move)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.twoD.particles.*;
public class Move extends ActionBase {
public function Move(){
priority = -10;
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
var _local4:Particle2D;
_local4 = Particle2D(_arg2);
Particle2D(_arg2).previousX = _local4.x;
_local4.previousY = _local4.y;
_local4.x = (_local4.x + (_local4.velX * _arg3));
_local4.y = (_local4.y + (_local4.velY * _arg3));
}
}
}//package org.flintparticles.twoD.actions
Section 164
//TargetVelocity (org.flintparticles.twoD.actions.TargetVelocity)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.twoD.particles.*;
public class TargetVelocity extends ActionBase {
private var _velX:Number;
private var _velY:Number;
private var _rate:Number;
public function TargetVelocity(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0.1){
this.targetVelocityX = _arg1;
this.targetVelocityY = _arg2;
this.rate = _arg3;
}
public function set rate(_arg1:Number):void{
_rate = _arg1;
}
public function get targetVelocityX():Number{
return (_velX);
}
public function get targetVelocityY():Number{
return (_velY);
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
var _local4:Particle2D;
_local4 = Particle2D(_arg2);
Particle2D(_arg2).velX = (_local4.velX + (((_velX - _local4.velX) * _rate) * _arg3));
_local4.velY = (_local4.velY + (((_velY - _local4.velY) * _rate) * _arg3));
}
public function set targetVelocityX(_arg1:Number):void{
_velX = _arg1;
}
public function set targetVelocityY(_arg1:Number):void{
_velY = _arg1;
}
public function get rate():Number{
return (_rate);
}
}
}//package org.flintparticles.twoD.actions
Section 165
//Emitter2D (org.flintparticles.twoD.emitters.Emitter2D)
package org.flintparticles.twoD.emitters {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.utils.*;
import org.flintparticles.twoD.particles.*;
public class Emitter2D extends Emitter {
protected var _y:Number;// = 0
protected var _x:Number;// = 0
public var spaceSort:Boolean;// = false
public var spaceSortedX:Array;
protected var _rotation:Number;// = 0
protected static var _creator:ParticleCreator2D = new ParticleCreator2D();
public function Emitter2D(){
_x = 0;
_y = 0;
_rotation = 0;
spaceSort = false;
super();
_particleFactory = _creator;
}
public function set rotation(_arg1:Number):void{
_rotation = Maths.asRadians(_arg1);
}
public function get x():Number{
return (_x);
}
public function set y(_arg1:Number):void{
_y = _arg1;
}
override protected function sortParticles():void{
var _local1:int;
var _local2:int;
if (spaceSort){
spaceSortedX = _particles.sortOn("x", (Array.NUMERIC | Array.RETURNINDEXEDARRAY));
_local1 = _particles.length;
_local2 = 0;
while (_local2 < _local1) {
Particle2D(_particles[spaceSortedX[_local2]]).sortID = _local2;
_local2++;
};
};
}
public function get y():Number{
return (_y);
}
override protected function initParticle(_arg1:Particle):void{
var _local2:Particle2D;
_local2 = Particle2D(_arg1);
_local2.x = _x;
_local2.y = _y;
_local2.previousX = _x;
_local2.previousY = _y;
_local2.rotation = _rotation;
}
public function set rotRadians(_arg1:Number):void{
_rotation = _arg1;
}
public function get rotRadians():Number{
return (_rotation);
}
public function set x(_arg1:Number):void{
_x = _arg1;
}
public function get rotation():Number{
return (Maths.asDegrees(_rotation));
}
public static function get defaultParticleFactory():ParticleFactory{
return (_creator);
}
}
}//package org.flintparticles.twoD.emitters
Section 166
//Position (org.flintparticles.twoD.initializers.Position)
package org.flintparticles.twoD.initializers {
import flash.geom.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.particles.*;
public class Position extends InitializerBase {
private var _zone:Zone2D;
public function Position(_arg1:Zone2D=null){
this.zone = _arg1;
}
public function get zone():Zone2D{
return (_zone);
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
var _local3:Particle2D;
var _local4:Point;
var _local5:Number;
var _local6:Number;
_local3 = Particle2D(_arg2);
_local4 = _zone.getLocation();
if (_local3.rotation == 0){
_local3.x = (_local3.x + _local4.x);
_local3.y = (_local3.y + _local4.y);
} else {
_local5 = Math.sin(_local3.rotation);
_local6 = Math.cos(_local3.rotation);
_local3.x = (_local3.x + ((_local6 * _local4.x) - (_local5 * _local4.y)));
_local3.y = (_local3.y + ((_local6 * _local4.y) + (_local5 * _local4.x)));
};
_local3.previousX = _local3.x;
_local3.previousY = _local3.y;
}
public function set zone(_arg1:Zone2D):void{
_zone = _arg1;
}
}
}//package org.flintparticles.twoD.initializers
Section 167
//Velocity (org.flintparticles.twoD.initializers.Velocity)
package org.flintparticles.twoD.initializers {
import flash.geom.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.particles.*;
public class Velocity extends InitializerBase {
private var _zone:Zone2D;
public function Velocity(_arg1:Zone2D=null){
this.zone = _arg1;
}
public function get zone():Zone2D{
return (_zone);
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
var _local3:Particle2D;
var _local4:Point;
var _local5:Number;
var _local6:Number;
_local3 = Particle2D(_arg2);
_local4 = _zone.getLocation();
if (_local3.rotation == 0){
_local3.velX = _local4.x;
_local3.velY = _local4.y;
} else {
_local5 = Math.sin(_local3.rotation);
_local6 = Math.cos(_local3.rotation);
_local3.velX = ((_local6 * _local4.x) - (_local5 * _local4.y));
_local3.velY = ((_local6 * _local4.y) + (_local5 * _local4.x));
};
}
public function set zone(_arg1:Zone2D):void{
_zone = _arg1;
}
}
}//package org.flintparticles.twoD.initializers
Section 168
//Particle2D (org.flintparticles.twoD.particles.Particle2D)
package org.flintparticles.twoD.particles {
import flash.geom.*;
import org.flintparticles.common.particles.*;
public class Particle2D extends Particle {
private var _previousRadius:Number;
public var sortID:int;// = -1
public var previousX:Number;// = 0
public var previousY:Number;// = 0
public var angVelocity:Number;// = 0
public var velX:Number;// = 0
private var _previousMass:Number;
public var velY:Number;// = 0
public var x:Number;// = 0
public var y:Number;// = 0
private var _inertia:Number;
public var rotation:Number;// = 0
public function Particle2D(){
x = 0;
y = 0;
previousX = 0;
previousY = 0;
velX = 0;
velY = 0;
rotation = 0;
angVelocity = 0;
sortID = -1;
super();
}
override public function initialize():void{
super.initialize();
x = 0;
y = 0;
previousX = 0;
previousY = 0;
velX = 0;
velY = 0;
rotation = 0;
angVelocity = 0;
sortID = -1;
}
public function get matrixTransform():Matrix{
var _local1:Number;
var _local2:Number;
_local1 = (scale * Math.cos(rotation));
_local2 = (scale * Math.sin(rotation));
return (new Matrix(_local1, _local2, -(_local2), _local1, x, y));
}
public function get inertia():Number{
if (((!((mass == _previousMass))) || (!((collisionRadius == _previousRadius))))){
_inertia = (((mass * collisionRadius) * collisionRadius) * 0.5);
_previousMass = mass;
_previousRadius = collisionRadius;
};
return (_inertia);
}
override public function clone(_arg1:ParticleFactory=null):Particle{
var _local2:Particle2D;
if (_arg1){
_local2 = (_arg1.createParticle() as Particle2D);
} else {
_local2 = new Particle2D();
};
cloneInto(_local2);
_local2.x = x;
_local2.y = y;
_local2.velX = velX;
_local2.velY = velY;
_local2.rotation = rotation;
_local2.angVelocity = angVelocity;
return (_local2);
}
}
}//package org.flintparticles.twoD.particles
Section 169
//ParticleCreator2D (org.flintparticles.twoD.particles.ParticleCreator2D)
package org.flintparticles.twoD.particles {
import org.flintparticles.common.particles.*;
public class ParticleCreator2D implements ParticleFactory {
private var _particles:Array;
public function ParticleCreator2D(){
_particles = new Array();
}
public function clearAllParticles():void{
_particles = new Array();
}
public function createParticle():Particle{
if (_particles.length){
return (_particles.pop());
};
return (new Particle2D());
}
public function disposeParticle(_arg1:Particle):void{
if ((_arg1 is Particle2D)){
_arg1.initialize();
_particles.push(_arg1);
};
}
}
}//package org.flintparticles.twoD.particles
Section 170
//DisplayObjectRenderer (org.flintparticles.twoD.renderers.DisplayObjectRenderer)
package org.flintparticles.twoD.renderers {
import flash.display.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.renderers.*;
import org.flintparticles.twoD.particles.*;
public class DisplayObjectRenderer extends SpriteRendererBase {
override protected function removeParticle(_arg1:Particle):void{
removeChild(_arg1.image);
}
override protected function addParticle(_arg1:Particle):void{
var _local2:Particle2D;
var _local3:DisplayObject;
_local2 = (_arg1 as Particle2D);
addChildAt(_local2.image, 0);
_local3 = _local2.image;
_local3.transform.colorTransform = _local2.colorTransform;
_local3.transform.matrix = _local2.matrixTransform;
}
override protected function renderParticles(_arg1:Array):void{
var _local2:Particle2D;
var _local3:DisplayObject;
var _local4:int;
var _local5:int;
_local4 = _arg1.length;
_local5 = 0;
while (_local5 < _local4) {
_local2 = _arg1[_local5];
_local3 = _local2.image;
_local3.transform.colorTransform = _local2.colorTransform;
_local3.transform.matrix = _local2.matrixTransform;
_local5++;
};
}
}
}//package org.flintparticles.twoD.renderers
Section 171
//DiscSectorZone (org.flintparticles.twoD.zones.DiscSectorZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class DiscSectorZone implements Zone2D {
private var _minAngle:Number;
private var _innerRadius:Number;
private var _minAllowed:Number;
private var _innerSq:Number;
private var _outerRadius:Number;
private var _center:Point;
private var _maxAngle:Number;
private var _outerSq:Number;
private static var TWOPI:Number = 6.28318530717959;
public function DiscSectorZone(_arg1:Point=null, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0){
if (_arg2 < _arg3){
throw (new Error((((("The outerRadius (" + _arg2) + ") can't be smaller than the innerRadius (") + _arg3) + ") in your DiscSectorZone. N.B. the outerRadius is the second argument in the constructor and the innerRadius is the third argument.")));
};
_center = (_arg1) ? _arg1.clone() : new Point(0, 0);
_innerRadius = _arg3;
_outerRadius = _arg2;
_innerSq = (_innerRadius * _innerRadius);
_outerSq = (_outerRadius * _outerRadius);
_minAngle = _arg4;
_maxAngle = _arg5;
if (_maxAngle){
while (_maxAngle > TWOPI) {
_maxAngle = (_maxAngle - TWOPI);
};
while (_maxAngle < 0) {
_maxAngle = (_maxAngle + TWOPI);
};
_minAllowed = (_maxAngle - TWOPI);
if (_minAngle){
if (_arg4 == _arg5){
_minAngle = _maxAngle;
} else {
_minAngle = clamp(_minAngle);
};
};
};
}
public function set minAngle(_arg1:Number):void{
_minAngle = clamp(_arg1);
}
public function get outerRadius():Number{
return (_outerRadius);
}
public function set centerX(_arg1:Number):void{
_center.x = _arg1;
}
public function set centerY(_arg1:Number):void{
_center.y = _arg1;
}
public function getArea():Number{
return (((Math.PI * _outerSq) - (Math.PI * _innerSq)));
}
public function set innerRadius(_arg1:Number):void{
_innerRadius = _arg1;
_innerSq = (_innerRadius * _innerRadius);
}
public function get maxAngle():Number{
return (_maxAngle);
}
public function get innerRadius():Number{
return (_innerRadius);
}
public function set outerRadius(_arg1:Number):void{
_outerRadius = _arg1;
_outerSq = (_outerRadius * _outerRadius);
}
public function set maxAngle(_arg1:Number):void{
_maxAngle = _arg1;
while (_maxAngle > TWOPI) {
_maxAngle = (_maxAngle - TWOPI);
};
while (_maxAngle < 0) {
_maxAngle = (_maxAngle + TWOPI);
};
_minAllowed = (_maxAngle - TWOPI);
_minAngle = clamp(_minAngle);
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
var _local4:Number;
_arg1 = (_arg1 - _center.x);
_arg2 = (_arg2 - _center.y);
_local3 = ((_arg1 * _arg1) + (_arg2 * _arg2));
if ((((_local3 > _outerSq)) || ((_local3 < _innerSq)))){
return (false);
};
_local4 = Math.atan2(_arg2, _arg1);
_local4 = clamp(_local4);
return ((_local4 >= _minAngle));
}
public function get minAngle():Number{
return (_minAngle);
}
public function get centerX():Number{
return (_center.x);
}
public function get center():Point{
return (_center);
}
public function getLocation():Point{
var _local1:Number;
var _local2:Point;
_local1 = Math.random();
_local2 = Point.polar((_innerRadius + ((1 - (_local1 * _local1)) * (_outerRadius - _innerRadius))), (_minAngle + (Math.random() * (_maxAngle - _minAngle))));
_local2.x = (_local2.x + _center.x);
_local2.y = (_local2.y + _center.y);
return (_local2);
}
public function set center(_arg1:Point):void{
_center = _arg1;
}
private function clamp(_arg1:Number):Number{
if (_maxAngle){
while (_arg1 > _maxAngle) {
_arg1 = (_arg1 - TWOPI);
};
while (_arg1 < _minAllowed) {
_arg1 = (_arg1 + TWOPI);
};
};
return (_arg1);
}
public function get centerY():Number{
return (_center.y);
}
}
}//package org.flintparticles.twoD.zones
Section 172
//DiscZone (org.flintparticles.twoD.zones.DiscZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class DiscZone implements Zone2D {
private var _innerRadius:Number;
private var _innerSq:Number;
private var _outerRadius:Number;
private var _center:Point;
private var _outerSq:Number;
private static const TWOPI:Number = 6.28318530717959;
public function DiscZone(_arg1:Point=null, _arg2:Number=0, _arg3:Number=0){
if (_arg2 < _arg3){
throw (new Error((((("The outerRadius (" + _arg2) + ") can't be smaller than the innerRadius (") + _arg3) + ") in your DiscZone. N.B. the outerRadius is the second argument in the constructor and the innerRadius is the third argument.")));
};
if (_arg1 == null){
_center = new Point(0, 0);
} else {
_center = _arg1;
};
_innerRadius = _arg3;
_outerRadius = _arg2;
_innerSq = (_innerRadius * _innerRadius);
_outerSq = (_outerRadius * _outerRadius);
}
public function set centerX(_arg1:Number):void{
_center.x = _arg1;
}
public function get innerRadius():Number{
return (_innerRadius);
}
public function getArea():Number{
return ((Math.PI * (_outerSq - _innerSq)));
}
public function set innerRadius(_arg1:Number):void{
_innerRadius = _arg1;
_innerSq = (_innerRadius * _innerRadius);
}
public function get center():Point{
return (_center);
}
public function set centerY(_arg1:Number):void{
_center.y = _arg1;
}
public function set outerRadius(_arg1:Number):void{
_outerRadius = _arg1;
_outerSq = (_outerRadius * _outerRadius);
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
_arg1 = (_arg1 - _center.x);
_arg2 = (_arg2 - _center.y);
_local3 = ((_arg1 * _arg1) + (_arg2 * _arg2));
return ((((_local3 <= _outerSq)) && ((_local3 >= _innerSq))));
}
public function get centerX():Number{
return (_center.x);
}
public function get centerY():Number{
return (_center.y);
}
public function get outerRadius():Number{
return (_outerRadius);
}
public function set center(_arg1:Point):void{
_center = _arg1;
}
public function getLocation():Point{
var _local1:Number;
var _local2:Point;
_local1 = Math.random();
_local2 = Point.polar((_innerRadius + ((1 - (_local1 * _local1)) * (_outerRadius - _innerRadius))), (Math.random() * TWOPI));
_local2.x = (_local2.x + _center.x);
_local2.y = (_local2.y + _center.y);
return (_local2);
}
}
}//package org.flintparticles.twoD.zones
Section 173
//LineZone (org.flintparticles.twoD.zones.LineZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class LineZone implements Zone2D {
private var _length:Point;
private var _end:Point;
private var _start:Point;
public function LineZone(_arg1:Point=null, _arg2:Point=null){
if (_arg1 == null){
_start = new Point(0, 0);
} else {
_start = _arg1;
};
if (_arg2 == null){
_end = new Point(0, 0);
} else {
_end = _arg2;
};
_length = _end.subtract(_start);
}
public function getArea():Number{
return (_length.length);
}
public function set start(_arg1:Point):void{
_start = _arg1;
_length = _end.subtract(_start);
}
public function get end():Point{
return (_end);
}
public function get endX():Number{
return (_end.x);
}
public function get endY():Number{
return (_end.y);
}
public function get start():Point{
return (_start);
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
if ((((_arg1 - _start.x) * _length.y) - ((_arg2 - _start.y) * _length.x)) != 0){
return (false);
};
return (((((_arg1 - _start.x) * (_arg1 - _end.x)) + ((_arg2 - _start.y) * (_arg2 - _end.y))) <= 0));
}
public function getLocation():Point{
var _local1:Point;
var _local2:Number;
_local1 = _start.clone();
_local2 = Math.random();
_local1.x = (_local1.x + (_length.x * _local2));
_local1.y = (_local1.y + (_length.y * _local2));
return (_local1);
}
public function set startX(_arg1:Number):void{
_start.x = _arg1;
_length = _end.subtract(_start);
}
public function set startY(_arg1:Number):void{
_start.y = _arg1;
_length = _end.subtract(_start);
}
public function set end(_arg1:Point):void{
_end = _arg1;
_length = _end.subtract(_start);
}
public function get startY():Number{
return (_start.y);
}
public function set endX(_arg1:Number):void{
_end.x = _arg1;
_length = _end.subtract(_start);
}
public function set endY(_arg1:Number):void{
_end.y = _arg1;
_length = _end.subtract(_start);
}
public function get startX():Number{
return (_start.x);
}
}
}//package org.flintparticles.twoD.zones
Section 174
//MultiZone (org.flintparticles.twoD.zones.MultiZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class MultiZone implements Zone2D {
private var _areas:Array;
private var _zones:Array;
private var _totalArea:Number;
public function MultiZone(){
_zones = new Array();
_areas = new Array();
_totalArea = 0;
}
public function getArea():Number{
return (_totalArea);
}
public function getLocation():Point{
var _local1:Number;
var _local2:int;
var _local3:int;
_local1 = (Math.random() * _totalArea);
_local2 = _zones.length;
_local3 = 0;
while (_local3 < _local2) {
_local1 = (_local1 - _areas[_local3]);
if (_local1 <= 0){
return (Zone2D(_zones[_local3]).getLocation());
};
_local3++;
};
if (_zones.length == 0){
throw (new Error("Attempt to use a MultiZone object that contains no Zones"));
};
return (Zone2D(_zones[0]).getLocation());
}
public function addZone(_arg1:Zone2D):void{
var _local2:Number;
_zones.push(_arg1);
_local2 = _arg1.getArea();
_areas.push(_local2);
_totalArea = (_totalArea + _local2);
}
public function removeZone(_arg1:Zone2D):void{
var _local2:int;
var _local3:int;
_local2 = _zones.length;
_local3 = 0;
while (_local3 < _local2) {
if (_zones[_local3] == _arg1){
_totalArea = (_totalArea - _areas[_local3]);
_areas.splice(_local3, 1);
_zones.splice(_local3, 1);
return;
};
_local3++;
};
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
var _local3:int;
var _local4:int;
_local3 = _zones.length;
_local4 = 0;
while (_local4 < _local3) {
if (Zone2D(_zones[_local4]).contains(_arg1, _arg2)){
return (true);
};
_local4++;
};
return (false);
}
}
}//package org.flintparticles.twoD.zones
Section 175
//RectangleZone (org.flintparticles.twoD.zones.RectangleZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class RectangleZone implements Zone2D {
private var _height:Number;
private var _bottom:Number;
private var _width:Number;
private var _right:Number;
private var _top:Number;
private var _left:Number;
public function RectangleZone(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0){
_left = _arg1;
_top = _arg2;
_right = _arg3;
_bottom = _arg4;
_width = (_arg3 - _arg1);
_height = (_arg4 - _arg2);
}
public function getArea():Number{
return ((_width * _height));
}
public function get top():Number{
return (_top);
}
public function set bottom(_arg1:Number):void{
_bottom = _arg1;
if (((!(isNaN(_top))) && (!(isNaN(_bottom))))){
_height = (bottom - top);
};
}
public function get right():Number{
return (_right);
}
public function set left(_arg1:Number):void{
_left = _arg1;
if (((!(isNaN(_right))) && (!(isNaN(_left))))){
_width = (right - left);
};
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
return ((((((((_arg1 >= _left)) && ((_arg1 <= _right)))) && ((_arg2 >= _top)))) && ((_arg2 <= _bottom))));
}
public function get left():Number{
return (_left);
}
public function set top(_arg1:Number):void{
_top = _arg1;
if (((!(isNaN(_top))) && (!(isNaN(_bottom))))){
_height = (bottom - top);
};
}
public function get bottom():Number{
return (_bottom);
}
public function getLocation():Point{
return (new Point((_left + (Math.random() * _width)), (_top + (Math.random() * _height))));
}
public function set right(_arg1:Number):void{
_right = _arg1;
if (((!(isNaN(_right))) && (!(isNaN(_left))))){
_width = (right - left);
};
}
}
}//package org.flintparticles.twoD.zones
Section 176
//Zone2D (org.flintparticles.twoD.zones.Zone2D)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public interface Zone2D {
function getArea():Number;
function getLocation():Point;
function contains(_arg1:Number, _arg2:Number):Boolean;
}
}//package org.flintparticles.twoD.zones
Section 177
//Achievements (Achievements)
package {
import flash.display.*;
import com.cartoonnetwork.AchievementSystem.*;
public class Achievements {
private static var _jumps:int;
private static var _flips:int;
private static var _wipeouts:int;
private static var _total_flips:int;
private static var _score:int;
private static var _sys:AchievementAS3;
public static function ResetFlipCounter():void{
_flips = 0;
}
public static function Started():void{
_sys.achievementNotificationGameStarted();
_score = 0;
_jumps = 0;
_flips = 0;
_total_flips = 0;
_wipeouts = 0;
}
public static function Loaded():void{
_sys.achievementNotificationGameLoaded();
}
public static function EndJump():void{
if (_flips > 0){
_sys.sendStat("200", _flips);
};
}
public static function Init(_arg1:Sprite):void{
var _local2:MovieClip;
_local2 = new MovieClip();
_arg1.addChild(_local2);
_sys = new AchievementAS3(_local2);
}
public static function AddFlips(_arg1:int):void{
_flips = (_flips + _arg1);
_total_flips = (_total_flips + _arg1);
}
public static function SetScore(_arg1:int):void{
_score = _arg1;
}
public static function Ended():void{
if (_wipeouts < 1){
_sys.sendStat("203", 1);
};
_sys.sendStat("201", _total_flips);
_sys.sendStat("202", _wipeouts);
_sys.achievementNotificationGameEnded();
}
public static function LevelEnded():void{
}
public static function AddWipeout():void{
_wipeouts++;
}
public static function StartJump():void{
_jumps++;
}
}
}//package
Section 178
//background01 (background01)
package {
import flash.display.*;
public dynamic class background01 extends MovieClip {
}
}//package
Section 179
//Background02 (Background02)
package {
import flash.display.*;
public dynamic class Background02 extends MovieClip {
}
}//package
Section 180
//Background03 (Background03)
package {
import flash.display.*;
public dynamic class Background03 extends MovieClip {
}
}//package
Section 181
//boardEmitter (boardEmitter)
package {
import flash.display.*;
public dynamic class boardEmitter extends MovieClip {
}
}//package
Section 182
//btn_MusicOff (btn_MusicOff)
package {
import flash.display.*;
public dynamic class btn_MusicOff extends SimpleButton {
}
}//package
Section 183
//btn_MusicOn (btn_MusicOn)
package {
import flash.display.*;
public dynamic class btn_MusicOn extends SimpleButton {
}
}//package
Section 184
//char_Flapjack (char_Flapjack)
package {
import flash.display.*;
public dynamic class char_Flapjack extends MovieClip {
public var particleEmitter:boardEmitter;
}
}//package
Section 185
//CN_Game (CN_Game)
package {
import com.cartoonnetwork.highscores.*;
import flash.events.*;
import flash.display.*;
public class CN_Game extends MovieClip {
public var loadDisplay:MovieClip;
var _loadInfo:LoaderInfo;
var _loaded:Boolean;
public function CN_Game(){
addFrameScript(104, frame105);
_loadInfo = this.loaderInfo;
this.gotoAndStop(5);
_loadInfo.addEventListener(Event.INIT, onRootLoaderInit, false, 0, true);
_loadInfo.addEventListener(ProgressEvent.PROGRESS, onRootLoaderProgress, false, 0, true);
_loadInfo.addEventListener(Event.COMPLETE, onRootLoaderComplete, false, 0, true);
}
public function onRootLoaderInit(_arg1:Event):void{
this.loadDisplay.gotoAndStop(2);
}
public function onRootLoaderProgress(_arg1:Event):void{
var _local2:*;
_local2 = Math.round(((loaderInfo.bytesLoaded / loaderInfo.bytesTotal) * 100));
this.loadDisplay.done_txt.text = (_local2 + "%");
}
public function onRootLoaderComplete(_arg1:Event):void{
_loadInfo.removeEventListener(Event.INIT, onRootLoaderInit);
_loadInfo.removeEventListener(ProgressEvent.PROGRESS, onRootLoaderProgress);
_loadInfo.removeEventListener(Event.COMPLETE, onRootLoaderComplete);
this.loadDisplay.gotoAndPlay(3);
_loaded = true;
addEventListener("enterFrame", UpdateLoader, false, 0, true);
}
public function UpdateLoader(_arg1:Event):void{
if (_loaded){
if (this.loadDisplay.currentFrame < 39){
return;
};
removeEventListener("enterFrame", UpdateLoader);
gotoAndStop(100);
};
}
function frame105(){
stop();
}
public static function getTopScoreFinished():Boolean{
return (true);
}
public static function submitTopScore(_arg1:Number):void{
trace((" attempting to submit score: " + _arg1));
SubmitScore.getInstance().submitScore(_arg1);
}
}
}//package
Section 186
//fx_ScoringPopUp (fx_ScoringPopUp)
package {
import flash.display.*;
public dynamic class fx_ScoringPopUp extends MovieClip {
public var box:MovieClip;
public function fx_ScoringPopUp(){
addFrameScript(30, frame31);
}
function frame31(){
gotoAndStop(1);
}
}
}//package
Section 187
//GameEntry (GameEntry)
package {
import flash.display.*;
import base.ui.*;
import base.display.*;
import base.*;
import flash.events.*;
import base.utils.*;
import base.pad.*;
import game.*;
import base.sound.*;
import base.tracker.*;
import game.states.*;
import flash.text.*;
public class GameEntry extends MovieClip {
var _displayObjectFactory:DisplayObjectFactory;
var _loadInfo:LoaderInfo;
var _gameData:GameData;
var fps_txt:TextField;
var _loaded:Boolean;
var _profiler:Profile;
var _gameMgr:GameManager;
var _padMgr:PadManager;
var _soundModule:SoundModule;
var step:Function;
var _timeMgr:Time;
var _uiMgr:UIManager;
var _tracker:GameTrack_AS3;
var _stage:Stage;
public function GameEntry(){
trace("|----@ GAME ENTRY @----|");
Achievements.Init(this);
_stage = this.stage;
_stage.showDefaultContextMenu = false;
initGameContext();
}
public function getUIManager():UIManager{
return (_uiMgr);
}
public function updateFramerateDisplay():void{
var _local1:*;
_local1 = Math.floor((1000 / _timeMgr.getAverageDeltaMilliseconds()));
fps_txt.text = ("avgFps: " + _local1);
}
public function getGameManager():GameManager{
return (_gameMgr);
}
public function getSoundModule():SoundModule{
return (_soundModule);
}
public function isTopScoreFinished():Boolean{
return (true);
}
public function getGameData():GameData{
return (_gameData);
}
public function initGameContext():void{
addEventListener(Event.ENTER_FRAME, updateGame, false, 0, true);
_padMgr = null;
_timeMgr = new Time();
_uiMgr = new UIManager(this);
_displayObjectFactory = new DisplayObjectFactory();
_soundModule = new SoundModule();
_gameData = new GameData(this);
_gameMgr = new GameManager(this, GamePlay);
}
public function setQuality(_arg1:String):void{
this.stage.quality = _arg1;
}
public function getStageSprite(){
return (_stage);
}
function updateGame(_arg1:Event):void{
_timeMgr.markTimeThisTick();
_gameMgr.Update();
}
public function getProfiler():Profile{
return (_profiler);
}
public function getDT(){
return (_timeMgr.getFrameDeltaSeconds());
}
public function submitScore(_arg1:Number):void{
CN_Game.submitTopScore(_arg1);
}
public function getPadManager():PadManager{
return (_padMgr);
}
public function getDisplayObjectFactory():DisplayObjectFactory{
return (_displayObjectFactory);
}
public function getParent(){
return (_stage);
}
public function getTimeManager():Time{
return (_timeMgr);
}
}
}//package
Section 188
//hud_Main (hud_Main)
package {
import flash.display.*;
import flash.text.*;
public dynamic class hud_Main extends MovieClip {
public var PISTONS:MovieClip;
public var STEAM:MovieClip;
public var TRICK_METER:MovieClip;
public var HEIGHT_METER:MovieClip;
public var TRICK_FLAGS:MovieClip;
public var CONFETTI:MovieClip;
public var btn_ShowInstruct:SimpleButton;
public var WINDVANE:MovieClip;
public var TRICK_SCORE_100S:MovieClip;
public var TRICK_SCORE_10S:MovieClip;
public var TRICK_SCORE_10000S:MovieClip;
public var TRICK_SCORE_1S:MovieClip;
public var TRICK_METER_ALERT:MovieClip;
public var TRICK_SCORE_1000S:MovieClip;
public var txt_TotalScore:TextField;
}
}//package
Section 189
//Music_InGame (Music_InGame)
package {
import flash.media.*;
public dynamic class Music_InGame extends Sound {
}
}//package
Section 190
//Music_Title (Music_Title)
package {
import flash.media.*;
public dynamic class Music_Title extends Sound {
}
}//package
Section 191
//obs_Generic (obs_Generic)
package {
import flash.display.*;
public dynamic class obs_Generic extends MovieClip {
}
}//package
Section 192
//reticule (reticule)
package {
import flash.display.*;
public dynamic class reticule extends MovieClip {
}
}//package
Section 193
//scrn_EndScreen (scrn_EndScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class scrn_EndScreen extends MovieClip {
public var btn_Play:SimpleButton;
public var _txtScore:TextField;
}
}//package
Section 194
//scrn_Instructions (scrn_Instructions)
package {
import flash.display.*;
public dynamic class scrn_Instructions extends MovieClip {
public var btn_Play:SimpleButton;
}
}//package
Section 195
//scrn_SnowTransition (scrn_SnowTransition)
package {
import flash.display.*;
public dynamic class scrn_SnowTransition extends MovieClip {
}
}//package
Section 196
//scrn_Story (scrn_Story)
package {
import flash.display.*;
public dynamic class scrn_Story extends MovieClip {
public var btn_Play:SimpleButton;
}
}//package
Section 197
//scrn_TitleCard (scrn_TitleCard)
package {
import flash.display.*;
public dynamic class scrn_TitleCard extends MovieClip {
public var btn_Play:SimpleButton;
public function scrn_TitleCard(){
addFrameScript(0, frame1, 4, frame5);
}
function frame1(){
gotoAndStop(5);
}
function frame5(){
stop();
}
}
}//package
Section 198
//sfx_AirbourneWindLoop (sfx_AirbourneWindLoop)
package {
import flash.media.*;
public dynamic class sfx_AirbourneWindLoop extends Sound {
}
}//package
Section 199
//sfx_ConfettiCannonBurst (sfx_ConfettiCannonBurst)
package {
import flash.media.*;
public dynamic class sfx_ConfettiCannonBurst extends Sound {
}
}//package
Section 200
//sfx_Duck (sfx_Duck)
package {
import flash.media.*;
public dynamic class sfx_Duck extends Sound {
}
}//package
Section 201
//sfx_Faceplant (sfx_Faceplant)
package {
import flash.media.*;
public dynamic class sfx_Faceplant extends Sound {
}
}//package
Section 202
//sfx_Fall_Offscreen (sfx_Fall_Offscreen)
package {
import flash.media.*;
public dynamic class sfx_Fall_Offscreen extends Sound {
}
}//package
Section 203
//sfx_GroundTumble (sfx_GroundTumble)
package {
import flash.media.*;
public dynamic class sfx_GroundTumble extends Sound {
}
}//package
Section 204
//sfx_HitOverheadObstacle (sfx_HitOverheadObstacle)
package {
import flash.media.*;
public dynamic class sfx_HitOverheadObstacle extends Sound {
}
}//package
Section 205
//sfx_Jump (sfx_Jump)
package {
import flash.media.*;
public dynamic class sfx_Jump extends Sound {
}
}//package
Section 206
//sfx_LandBad (sfx_LandBad)
package {
import flash.media.*;
public dynamic class sfx_LandBad extends Sound {
}
}//package
Section 207
//sfx_LandFromJump (sfx_LandFromJump)
package {
import flash.media.*;
public dynamic class sfx_LandFromJump extends Sound {
}
}//package
Section 208
//sfx_LandGood (sfx_LandGood)
package {
import flash.media.*;
public dynamic class sfx_LandGood extends Sound {
}
}//package
Section 209
//sfx_Respawn (sfx_Respawn)
package {
import flash.media.*;
public dynamic class sfx_Respawn extends Sound {
}
}//package
Section 210
//sfx_Snow_Transition (sfx_Snow_Transition)
package {
import flash.media.*;
public dynamic class sfx_Snow_Transition extends Sound {
}
}//package
Section 211
//sfx_SnowboardingLoop (sfx_SnowboardingLoop)
package {
import flash.media.*;
public dynamic class sfx_SnowboardingLoop extends Sound {
}
}//package
Section 212
//sfx_SpinMultiplierChime (sfx_SpinMultiplierChime)
package {
import flash.media.*;
public dynamic class sfx_SpinMultiplierChime extends Sound {
}
}//package
Section 213
//sfx_TrickMeterLowAlert (sfx_TrickMeterLowAlert)
package {
import flash.media.*;
public dynamic class sfx_TrickMeterLowAlert extends Sound {
}
}//package
Section 214
//sfx_TrickRatingFlagAppear (sfx_TrickRatingFlagAppear)
package {
import flash.media.*;
public dynamic class sfx_TrickRatingFlagAppear extends Sound {
}
}//package
Section 215
//sfx_TrickScoreTileFlip (sfx_TrickScoreTileFlip)
package {
import flash.media.*;
public dynamic class sfx_TrickScoreTileFlip extends Sound {
}
}//package
Section 216
//sfx_Tumble_Loop (sfx_Tumble_Loop)
package {
import flash.media.*;
public dynamic class sfx_Tumble_Loop extends Sound {
}
}//package
Section 217
//snowflake_mc1 (snowflake_mc1)
package {
import flash.display.*;
public dynamic class snowflake_mc1 extends MovieClip {
}
}//package
Section 218
//snowflake_mc2 (snowflake_mc2)
package {
import flash.display.*;
public dynamic class snowflake_mc2 extends MovieClip {
}
}//package
Section 219
//snowflake_mc3 (snowflake_mc3)
package {
import flash.display.*;
public dynamic class snowflake_mc3 extends MovieClip {
}
}//package
Section 220
//snowflake_mc4 (snowflake_mc4)
package {
import flash.display.*;
public dynamic class snowflake_mc4 extends MovieClip {
}
}//package
Section 221
//snowflake_mc5 (snowflake_mc5)
package {
import flash.display.*;
public dynamic class snowflake_mc5 extends MovieClip {
}
}//package
Section 222
//snowflake_mc6 (snowflake_mc6)
package {
import flash.display.*;
public dynamic class snowflake_mc6 extends MovieClip {
}
}//package
Section 223
//snowParticle (snowParticle)
package {
import flash.display.*;
public dynamic class snowParticle extends MovieClip {
}
}//package
Section 224
//Sting_EndGame (Sting_EndGame)
package {
import flash.media.*;
public dynamic class Sting_EndGame extends Sound {
}
}//package
Section 225
//t_Flatland (t_Flatland)
package {
import flash.display.*;
public dynamic class t_Flatland extends MovieClip {
}
}//package
Section 226
//t_Flatland_GapWarning (t_Flatland_GapWarning)
package {
import flash.display.*;
public dynamic class t_Flatland_GapWarning extends MovieClip {
}
}//package
Section 227
//t_Flatland_Obstacle (t_Flatland_Obstacle)
package {
import flash.display.*;
public dynamic class t_Flatland_Obstacle extends MovieClip {
}
}//package
Section 228
//t_Flatland_ObstacleWarning (t_Flatland_ObstacleWarning)
package {
import flash.display.*;
public dynamic class t_Flatland_ObstacleWarning extends MovieClip {
}
}//package
Section 229
//t_Gap_Large (t_Gap_Large)
package {
import flash.display.*;
public dynamic class t_Gap_Large extends MovieClip {
}
}//package
Section 230
//t_Gap_Med (t_Gap_Med)
package {
import flash.display.*;
public dynamic class t_Gap_Med extends MovieClip {
}
}//package
Section 231
//t_Gap_Small (t_Gap_Small)
package {
import flash.display.*;
public dynamic class t_Gap_Small extends MovieClip {
}
}//package
Section 232
//t_Hill_Down (t_Hill_Down)
package {
import flash.display.*;
public dynamic class t_Hill_Down extends MovieClip {
}
}//package
Section 233
//t_Hill_In (t_Hill_In)
package {
import flash.display.*;
public dynamic class t_Hill_In extends MovieClip {
}
}//package
Section 234
//t_Hill_Out (t_Hill_Out)
package {
import flash.display.*;
public dynamic class t_Hill_Out extends MovieClip {
}
}//package
Section 235
//t_Jump (t_Jump)
package {
import flash.display.*;
public dynamic class t_Jump extends MovieClip {
}
}//package
Section 236
//t_Mogul_Large (t_Mogul_Large)
package {
import flash.display.*;
public dynamic class t_Mogul_Large extends MovieClip {
}
}//package
Section 237
//t_Mogul_Set (t_Mogul_Set)
package {
import flash.display.*;
public dynamic class t_Mogul_Set extends MovieClip {
}
}//package
Section 238
//t_Mogul_Small (t_Mogul_Small)
package {
import flash.display.*;
public dynamic class t_Mogul_Small extends MovieClip {
}
}//package