Section 1
//b2BoxDef (Box2D.Collision.Shapes.b2BoxDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2BoxDef extends b2ShapeDef {
public var extents:b2Vec2;
public function b2BoxDef(){
type = b2Shape.e_boxShape;
extents = new b2Vec2(1, 1);
}
}
}//package Box2D.Collision.Shapes
Section 2
//b2CircleDef (Box2D.Collision.Shapes.b2CircleDef)
package Box2D.Collision.Shapes {
public class b2CircleDef extends b2ShapeDef {
public var radius:Number;
public function b2CircleDef(){
type = b2Shape.e_circleShape;
radius = 1;
}
}
}//package Box2D.Collision.Shapes
Section 3
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2CircleShape extends b2Shape {
public var m_localPosition:b2Vec2;
public var m_radius:Number;
public function b2CircleShape(_arg1:b2ShapeDef, _arg2:b2Body, _arg3:b2Vec2){
var _local4:b2CircleDef;
var _local5:Number;
var _local6:Number;
var _local7:b2AABB;
var _local8:b2BroadPhase;
m_localPosition = new b2Vec2();
super(_arg1, _arg2);
_local4 = (_arg1 as b2CircleDef);
m_localPosition.Set((_arg1.localPosition.x - _arg3.x), (_arg1.localPosition.y - _arg3.y));
m_type = b2Shape.e_circleShape;
m_radius = _local4.radius;
m_R.SetM(m_body.m_R);
_local5 = ((m_R.col1.x * m_localPosition.x) + (m_R.col2.x * m_localPosition.y));
_local6 = ((m_R.col1.y * m_localPosition.x) + (m_R.col2.y * m_localPosition.y));
m_position.x = (m_body.m_position.x + _local5);
m_position.y = (m_body.m_position.y + _local6);
m_maxRadius = (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))) + m_radius);
_local7 = new b2AABB();
_local7.minVertex.Set((m_position.x - m_radius), (m_position.y - m_radius));
_local7.maxVertex.Set((m_position.x + m_radius), (m_position.y + m_radius));
_local8 = m_body.m_world.m_broadPhase;
if (_local8.InRange(_local7)){
m_proxyId = _local8.CreateProxy(_local7, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function ResetProxy(_arg1:b2BroadPhase):void{
var _local2:b2Proxy;
var _local3:b2AABB;
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local2 = _arg1.GetProxy(m_proxyId);
_arg1.DestroyProxy(m_proxyId);
_local2 = null;
_local3 = new b2AABB();
_local3.minVertex.Set((m_position.x - m_radius), (m_position.y - m_radius));
_local3.maxVertex.Set((m_position.x + m_radius), (m_position.y + m_radius));
if (_arg1.InRange(_local3)){
m_proxyId = _arg1.CreateProxy(_local3, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function QuickSync(_arg1:b2Vec2, _arg2:b2Mat22):void{
m_R.SetM(_arg2);
m_position.x = (((_arg2.col1.x * m_localPosition.x) + (_arg2.col2.x * m_localPosition.y)) + _arg1.x);
m_position.y = (((_arg2.col1.y * m_localPosition.x) + (_arg2.col2.y * m_localPosition.y)) + _arg1.y);
}
override public function Support(_arg1:Number, _arg2:Number, _arg3:b2Vec2):void{
var _local4:Number;
_local4 = Math.sqrt(((_arg1 * _arg1) + (_arg2 * _arg2)));
_arg1 = (_arg1 / _local4);
_arg2 = (_arg2 / _local4);
_arg3.Set((m_position.x + (m_radius * _arg1)), (m_position.y + (m_radius * _arg2)));
}
override public function Synchronize(_arg1:b2Vec2, _arg2:b2Mat22, _arg3:b2Vec2, _arg4:b2Mat22):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2AABB;
var _local12:b2BroadPhase;
m_R.SetM(_arg4);
m_position.x = (((_arg4.col1.x * m_localPosition.x) + (_arg4.col2.x * m_localPosition.y)) + _arg3.x);
m_position.y = (((_arg4.col1.y * m_localPosition.x) + (_arg4.col2.y * m_localPosition.y)) + _arg3.y);
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local5 = (_arg1.x + ((_arg2.col1.x * m_localPosition.x) + (_arg2.col2.x * m_localPosition.y)));
_local6 = (_arg1.y + ((_arg2.col1.y * m_localPosition.x) + (_arg2.col2.y * m_localPosition.y)));
_local7 = Math.min(_local5, m_position.x);
_local8 = Math.min(_local6, m_position.y);
_local9 = Math.max(_local5, m_position.x);
_local10 = Math.max(_local6, m_position.y);
_local11 = new b2AABB();
_local11.minVertex.Set((_local7 - m_radius), (_local8 - m_radius));
_local11.maxVertex.Set((_local9 + m_radius), (_local10 + m_radius));
_local12 = m_body.m_world.m_broadPhase;
if (_local12.InRange(_local11)){
_local12.MoveProxy(m_proxyId, _local11);
} else {
m_body.Freeze();
};
}
override public function TestPoint(_arg1:b2Vec2):Boolean{
var _local2:b2Vec2;
_local2 = new b2Vec2();
_local2.SetV(_arg1);
_local2.Subtract(m_position);
return ((b2Math.b2Dot(_local2, _local2) <= (m_radius * m_radius)));
}
}
}//package Box2D.Collision.Shapes
Section 4
//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 5
//b2PolyDef (Box2D.Collision.Shapes.b2PolyDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PolyDef extends b2ShapeDef {
public var vertexCount:int;
public var vertices:Array;
public function b2PolyDef(){
var _local1:int;
vertices = new Array(b2Settings.b2_maxPolyVertices);
super();
type = b2Shape.e_polyShape;
vertexCount = 0;
_local1 = 0;
while (_local1 < b2Settings.b2_maxPolyVertices) {
vertices[_local1] = new b2Vec2();
_local1++;
};
}
}
}//package Box2D.Collision.Shapes
Section 6
//b2PolyShape (Box2D.Collision.Shapes.b2PolyShape)
package Box2D.Collision.Shapes {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PolyShape extends b2Shape {
public var m_vertices:Array;
public var m_localOBB:b2OBB;
public var m_normals:Array;
public var m_vertexCount:int;
private var syncMat:b2Mat22;
public var m_coreVertices:Array;
public var m_localCentroid:b2Vec2;
private var syncAABB:b2AABB;
private static var tempVec:b2Vec2 = new b2Vec2();
private static var tAbsR:b2Mat22 = new b2Mat22();
public function b2PolyShape(_arg1:b2ShapeDef, _arg2:b2Body, _arg3:b2Vec2){
var _local4:int;
var _local5:Number;
var _local6:Number;
var _local7:b2Vec2;
var _local8:b2AABB;
var _local9:b2Mat22;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local15:int;
var _local16:Number;
var _local17:Number;
var _local18:b2BroadPhase;
var _local19:b2BoxDef;
var _local20:Number;
var _local21:Number;
var _local22:b2PolyDef;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:b2Vec2;
syncAABB = new b2AABB();
syncMat = new b2Mat22();
m_localCentroid = new b2Vec2();
m_localOBB = new b2OBB();
super(_arg1, _arg2);
_local8 = new b2AABB();
m_vertices = new Array(b2Settings.b2_maxPolyVertices);
m_coreVertices = new Array(b2Settings.b2_maxPolyVertices);
m_normals = new Array(b2Settings.b2_maxPolyVertices);
m_type = b2Shape.e_polyShape;
_local9 = new b2Mat22(_arg1.localRotation);
if (_arg1.type == b2Shape.e_boxShape){
m_localCentroid.x = (_arg1.localPosition.x - _arg3.x);
m_localCentroid.y = (_arg1.localPosition.y - _arg3.y);
_local19 = (_arg1 as b2BoxDef);
m_vertexCount = 4;
_local5 = _local19.extents.x;
_local6 = _local19.extents.y;
_local20 = Math.max(0, (_local5 - (2 * b2Settings.b2_linearSlop)));
_local21 = Math.max(0, (_local6 - (2 * b2Settings.b2_linearSlop)));
_local7 = (m_vertices[0] = new b2Vec2());
_local7.x = ((_local9.col1.x * _local5) + (_local9.col2.x * _local6));
_local7.y = ((_local9.col1.y * _local5) + (_local9.col2.y * _local6));
_local7 = (m_vertices[1] = new b2Vec2());
_local7.x = ((_local9.col1.x * -(_local5)) + (_local9.col2.x * _local6));
_local7.y = ((_local9.col1.y * -(_local5)) + (_local9.col2.y * _local6));
_local7 = (m_vertices[2] = new b2Vec2());
_local7.x = ((_local9.col1.x * -(_local5)) + (_local9.col2.x * -(_local6)));
_local7.y = ((_local9.col1.y * -(_local5)) + (_local9.col2.y * -(_local6)));
_local7 = (m_vertices[3] = new b2Vec2());
_local7.x = ((_local9.col1.x * _local5) + (_local9.col2.x * -(_local6)));
_local7.y = ((_local9.col1.y * _local5) + (_local9.col2.y * -(_local6)));
_local7 = (m_coreVertices[0] = new b2Vec2());
_local7.x = ((_local9.col1.x * _local20) + (_local9.col2.x * _local21));
_local7.y = ((_local9.col1.y * _local20) + (_local9.col2.y * _local21));
_local7 = (m_coreVertices[1] = new b2Vec2());
_local7.x = ((_local9.col1.x * -(_local20)) + (_local9.col2.x * _local21));
_local7.y = ((_local9.col1.y * -(_local20)) + (_local9.col2.y * _local21));
_local7 = (m_coreVertices[2] = new b2Vec2());
_local7.x = ((_local9.col1.x * -(_local20)) + (_local9.col2.x * -(_local21)));
_local7.y = ((_local9.col1.y * -(_local20)) + (_local9.col2.y * -(_local21)));
_local7 = (m_coreVertices[3] = new b2Vec2());
_local7.x = ((_local9.col1.x * _local20) + (_local9.col2.x * -(_local21)));
_local7.y = ((_local9.col1.y * _local20) + (_local9.col2.y * -(_local21)));
} else {
_local22 = (_arg1 as b2PolyDef);
m_vertexCount = _local22.vertexCount;
PolyCentroid(_local22.vertices, _local22.vertexCount, tempVec);
_local23 = tempVec.x;
_local24 = tempVec.y;
m_localCentroid.x = ((_arg1.localPosition.x + ((_local9.col1.x * _local23) + (_local9.col2.x * _local24))) - _arg3.x);
m_localCentroid.y = ((_arg1.localPosition.y + ((_local9.col1.y * _local23) + (_local9.col2.y * _local24))) - _arg3.y);
_local4 = 0;
while (_local4 < m_vertexCount) {
m_vertices[_local4] = new b2Vec2();
m_coreVertices[_local4] = new b2Vec2();
_local5 = (_local22.vertices[_local4].x - _local23);
_local6 = (_local22.vertices[_local4].y - _local24);
m_vertices[_local4].x = ((_local9.col1.x * _local5) + (_local9.col2.x * _local6));
m_vertices[_local4].y = ((_local9.col1.y * _local5) + (_local9.col2.y * _local6));
_local25 = m_vertices[_local4].x;
_local26 = m_vertices[_local4].y;
_local27 = Math.sqrt(((_local25 * _local25) + (_local26 * _local26)));
if (_local27 > Number.MIN_VALUE){
_local25 = (_local25 * (1 / _local27));
_local26 = (_local26 * (1 / _local27));
};
m_coreVertices[_local4].x = (m_vertices[_local4].x - ((2 * b2Settings.b2_linearSlop) * _local25));
m_coreVertices[_local4].y = (m_vertices[_local4].y - ((2 * b2Settings.b2_linearSlop) * _local26));
_local4++;
};
};
_local10 = Number.MAX_VALUE;
_local11 = Number.MAX_VALUE;
_local12 = -(Number.MAX_VALUE);
_local13 = -(Number.MAX_VALUE);
m_maxRadius = 0;
_local4 = 0;
while (_local4 < m_vertexCount) {
_local28 = m_vertices[_local4];
_local10 = Math.min(_local10, _local28.x);
_local11 = Math.min(_local11, _local28.y);
_local12 = Math.max(_local12, _local28.x);
_local13 = Math.max(_local13, _local28.y);
m_maxRadius = Math.max(m_maxRadius, _local28.Length());
_local4++;
};
m_localOBB.R.SetIdentity();
m_localOBB.center.Set(((_local10 + _local12) * 0.5), ((_local11 + _local13) * 0.5));
m_localOBB.extents.Set(((_local12 - _local10) * 0.5), ((_local13 - _local11) * 0.5));
_local4 = 0;
while (_local4 < m_vertexCount) {
m_normals[_local4] = new b2Vec2();
_local14 = _local4;
_local15 = (((_local4 + 1) < m_vertexCount)) ? (_local4 + 1) : 0;
m_normals[_local4].x = (m_vertices[_local15].y - m_vertices[_local14].y);
m_normals[_local4].y = -((m_vertices[_local15].x - m_vertices[_local14].x));
m_normals[_local4].Normalize();
_local4++;
};
_local4 = 0;
while (_local4 < m_vertexCount) {
_local14 = _local4;
_local15 = (((_local4 + 1) < m_vertexCount)) ? (_local4 + 1) : 0;
_local4++;
};
m_R.SetM(m_body.m_R);
m_position.x = (m_body.m_position.x + ((m_R.col1.x * m_localCentroid.x) + (m_R.col2.x * m_localCentroid.y)));
m_position.y = (m_body.m_position.y + ((m_R.col1.y * m_localCentroid.x) + (m_R.col2.y * m_localCentroid.y)));
tAbsR.col1.x = ((m_R.col1.x * m_localOBB.R.col1.x) + (m_R.col2.x * m_localOBB.R.col1.y));
tAbsR.col1.y = ((m_R.col1.y * m_localOBB.R.col1.x) + (m_R.col2.y * m_localOBB.R.col1.y));
tAbsR.col2.x = ((m_R.col1.x * m_localOBB.R.col2.x) + (m_R.col2.x * m_localOBB.R.col2.y));
tAbsR.col2.y = ((m_R.col1.y * m_localOBB.R.col2.x) + (m_R.col2.y * m_localOBB.R.col2.y));
tAbsR.Abs();
_local5 = ((tAbsR.col1.x * m_localOBB.extents.x) + (tAbsR.col2.x * m_localOBB.extents.y));
_local6 = ((tAbsR.col1.y * m_localOBB.extents.x) + (tAbsR.col2.y * m_localOBB.extents.y));
_local16 = (m_position.x + ((m_R.col1.x * m_localOBB.center.x) + (m_R.col2.x * m_localOBB.center.y)));
_local17 = (m_position.y + ((m_R.col1.y * m_localOBB.center.x) + (m_R.col2.y * m_localOBB.center.y)));
_local8.minVertex.x = (_local16 - _local5);
_local8.minVertex.y = (_local17 - _local6);
_local8.maxVertex.x = (_local16 + _local5);
_local8.maxVertex.y = (_local17 + _local6);
_local18 = m_body.m_world.m_broadPhase;
if (_local18.InRange(_local8)){
m_proxyId = _local18.CreateProxy(_local8, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function QuickSync(_arg1:b2Vec2, _arg2:b2Mat22):void{
m_R.SetM(_arg2);
m_position.x = (_arg1.x + ((_arg2.col1.x * m_localCentroid.x) + (_arg2.col2.x * m_localCentroid.y)));
m_position.y = (_arg1.y + ((_arg2.col1.y * m_localCentroid.x) + (_arg2.col2.y * m_localCentroid.y)));
}
override public function Support(_arg1:Number, _arg2:Number, _arg3:b2Vec2):void{
var _local4:Number;
var _local5:Number;
var _local6:int;
var _local7:Number;
var _local8:int;
var _local9:Number;
_local4 = ((_arg1 * m_R.col1.x) + (_arg2 * m_R.col1.y));
_local5 = ((_arg1 * m_R.col2.x) + (_arg2 * m_R.col2.y));
_local6 = 0;
_local7 = ((m_coreVertices[0].x * _local4) + (m_coreVertices[0].y * _local5));
_local8 = 1;
while (_local8 < m_vertexCount) {
_local9 = ((m_coreVertices[_local8].x * _local4) + (m_coreVertices[_local8].y * _local5));
if (_local9 > _local7){
_local6 = _local8;
_local7 = _local9;
};
_local8++;
};
_arg3.Set((m_position.x + ((m_R.col1.x * m_coreVertices[_local6].x) + (m_R.col2.x * m_coreVertices[_local6].y))), (m_position.y + ((m_R.col1.y * m_coreVertices[_local6].x) + (m_R.col2.y * m_coreVertices[_local6].y))));
}
override public function Synchronize(_arg1:b2Vec2, _arg2:b2Mat22, _arg3:b2Vec2, _arg4:b2Mat22):void{
var _local5:Number;
var _local6:Number;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
var _local13:b2BroadPhase;
m_R.SetM(_arg4);
m_position.x = (m_body.m_position.x + ((_arg4.col1.x * m_localCentroid.x) + (_arg4.col2.x * m_localCentroid.y)));
m_position.y = (m_body.m_position.y + ((_arg4.col1.y * m_localCentroid.x) + (_arg4.col2.y * m_localCentroid.y)));
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local7 = _arg2.col1;
_local8 = _arg2.col2;
_local9 = m_localOBB.R.col1;
_local10 = m_localOBB.R.col2;
syncMat.col1.x = ((_local7.x * _local9.x) + (_local8.x * _local9.y));
syncMat.col1.y = ((_local7.y * _local9.x) + (_local8.y * _local9.y));
syncMat.col2.x = ((_local7.x * _local10.x) + (_local8.x * _local10.y));
syncMat.col2.y = ((_local7.y * _local10.x) + (_local8.y * _local10.y));
syncMat.Abs();
_local5 = (m_localCentroid.x + m_localOBB.center.x);
_local6 = (m_localCentroid.y + m_localOBB.center.y);
_local11 = (_arg1.x + ((_arg2.col1.x * _local5) + (_arg2.col2.x * _local6)));
_local12 = (_arg1.y + ((_arg2.col1.y * _local5) + (_arg2.col2.y * _local6)));
_local5 = ((syncMat.col1.x * m_localOBB.extents.x) + (syncMat.col2.x * m_localOBB.extents.y));
_local6 = ((syncMat.col1.y * m_localOBB.extents.x) + (syncMat.col2.y * m_localOBB.extents.y));
syncAABB.minVertex.x = (_local11 - _local5);
syncAABB.minVertex.y = (_local12 - _local6);
syncAABB.maxVertex.x = (_local11 + _local5);
syncAABB.maxVertex.y = (_local12 + _local6);
_local7 = _arg4.col1;
_local8 = _arg4.col2;
_local9 = m_localOBB.R.col1;
_local10 = m_localOBB.R.col2;
syncMat.col1.x = ((_local7.x * _local9.x) + (_local8.x * _local9.y));
syncMat.col1.y = ((_local7.y * _local9.x) + (_local8.y * _local9.y));
syncMat.col2.x = ((_local7.x * _local10.x) + (_local8.x * _local10.y));
syncMat.col2.y = ((_local7.y * _local10.x) + (_local8.y * _local10.y));
syncMat.Abs();
_local5 = (m_localCentroid.x + m_localOBB.center.x);
_local6 = (m_localCentroid.y + m_localOBB.center.y);
_local11 = (_arg3.x + ((_arg4.col1.x * _local5) + (_arg4.col2.x * _local6)));
_local12 = (_arg3.y + ((_arg4.col1.y * _local5) + (_arg4.col2.y * _local6)));
_local5 = ((syncMat.col1.x * m_localOBB.extents.x) + (syncMat.col2.x * m_localOBB.extents.y));
_local6 = ((syncMat.col1.y * m_localOBB.extents.x) + (syncMat.col2.y * m_localOBB.extents.y));
syncAABB.minVertex.x = Math.min(syncAABB.minVertex.x, (_local11 - _local5));
syncAABB.minVertex.y = Math.min(syncAABB.minVertex.y, (_local12 - _local6));
syncAABB.maxVertex.x = Math.max(syncAABB.maxVertex.x, (_local11 + _local5));
syncAABB.maxVertex.y = Math.max(syncAABB.maxVertex.y, (_local12 + _local6));
_local13 = m_body.m_world.m_broadPhase;
if (_local13.InRange(syncAABB)){
_local13.MoveProxy(m_proxyId, syncAABB);
} else {
m_body.Freeze();
};
}
override public function TestPoint(_arg1:b2Vec2):Boolean{
var _local2:b2Vec2;
var _local3:int;
var _local4:b2Vec2;
var _local5:Number;
_local2 = new b2Vec2();
_local2.SetV(_arg1);
_local2.Subtract(m_position);
_local2.MulTM(m_R);
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = new b2Vec2();
_local4.SetV(_local2);
_local4.Subtract(m_vertices[_local3]);
_local5 = b2Math.b2Dot(m_normals[_local3], _local4);
if (_local5 > 0){
return (false);
};
_local3++;
};
return (true);
}
override public function ResetProxy(_arg1:b2BroadPhase):void{
var _local2:b2Proxy;
var _local3:b2Mat22;
var _local4:b2Mat22;
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2AABB;
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local2 = _arg1.GetProxy(m_proxyId);
_arg1.DestroyProxy(m_proxyId);
_local2 = null;
_local3 = b2Math.b2MulMM(m_R, m_localOBB.R);
_local4 = b2Math.b2AbsM(_local3);
_local5 = b2Math.b2MulMV(_local4, m_localOBB.extents);
_local6 = b2Math.b2MulMV(m_R, m_localOBB.center);
_local6.Add(m_position);
_local7 = new b2AABB();
_local7.minVertex.SetV(_local6);
_local7.minVertex.Subtract(_local5);
_local7.maxVertex.SetV(_local6);
_local7.maxVertex.Add(_local5);
if (_arg1.InRange(_local7)){
m_proxyId = _arg1.CreateProxy(_local7, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
}
}//package Box2D.Collision.Shapes
Section 7
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2Shape {
public var m_body:b2Body;
public var m_maxRadius:Number;
public var m_next:b2Shape;
public var m_R:b2Mat22;
public var m_type:int;
public var m_friction:Number;
public var m_proxyId:uint;
public var m_maskBits:uint;
public var m_groupIndex:int;
public var m_userData;// = null
public var m_restitution:Number;
public var m_position:b2Vec2;
public var m_categoryBits:uint;
public static const e_boxShape:int = 1;
public static const e_unknownShape:int = -1;
public static const e_shapeTypeCount:int = 4;
public static const e_circleShape:int = 0;
public static const e_meshShape:int = 3;
public static const e_polyShape:int = 2;
public function b2Shape(_arg1:b2ShapeDef, _arg2:b2Body){
m_R = new b2Mat22();
m_position = new b2Vec2();
m_userData = null;
super();
m_userData = _arg1.userData;
m_friction = _arg1.friction;
m_restitution = _arg1.restitution;
m_body = _arg2;
m_proxyId = b2Pair.b2_nullProxy;
m_maxRadius = 0;
m_categoryBits = _arg1.categoryBits;
m_maskBits = _arg1.maskBits;
m_groupIndex = _arg1.groupIndex;
}
public function GetMaxRadius():Number{
return (m_maxRadius);
}
public function GetPosition():b2Vec2{
return (m_position);
}
public function QuickSync(_arg1:b2Vec2, _arg2:b2Mat22):void{
}
public function GetNext():b2Shape{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function GetUserData(){
return (m_userData);
}
public function Support(_arg1:Number, _arg2:Number, _arg3:b2Vec2):void{
}
public function Synchronize(_arg1:b2Vec2, _arg2:b2Mat22, _arg3:b2Vec2, _arg4:b2Mat22):void{
}
public function DestroyProxy():void{
if (m_proxyId != b2Pair.b2_nullProxy){
m_body.m_world.m_broadPhase.DestroyProxy(m_proxyId);
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function GetRotationMatrix():b2Mat22{
return (m_R);
}
public function GetBody():b2Body{
return (m_body);
}
public function TestPoint(_arg1:b2Vec2):Boolean{
return (false);
}
public function ResetProxy(_arg1:b2BroadPhase):void{
}
public static function Destroy(_arg1:b2Shape):void{
if (_arg1.m_proxyId != b2Pair.b2_nullProxy){
_arg1.m_body.m_world.m_broadPhase.DestroyProxy(_arg1.m_proxyId);
};
}
public static function PolyMass(_arg1:b2MassData, _arg2:Array, _arg3:int, _arg4:Number):void{
var _local5:b2Vec2;
var _local6:Number;
var _local7:Number;
var _local8:b2Vec2;
var _local9:Number;
var _local10:int;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local14:b2Vec2;
var _local15:b2Vec2;
var _local16:Number;
var _local17:Number;
var _local18:b2Vec2;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local5 = new b2Vec2();
_local5.SetZero();
_local6 = 0;
_local7 = 0;
_local8 = new b2Vec2(0, 0);
_local9 = (1 / 3);
_local10 = 0;
while (_local10 < _arg3) {
_local11 = _local8;
_local12 = _arg2[_local10];
_local13 = (((_local10 + 1) < _arg3)) ? _arg2[(_local10 + 1)] : _arg2[0];
_local14 = b2Math.SubtractVV(_local12, _local11);
_local15 = b2Math.SubtractVV(_local13, _local11);
_local16 = b2Math.b2CrossVV(_local14, _local15);
_local17 = (0.5 * _local16);
_local6 = (_local6 + _local17);
_local18 = new b2Vec2();
_local18.SetV(_local11);
_local18.Add(_local12);
_local18.Add(_local13);
_local18.Multiply((_local9 * _local17));
_local5.Add(_local18);
_local19 = _local11.x;
_local20 = _local11.y;
_local21 = _local14.x;
_local22 = _local14.y;
_local23 = _local15.x;
_local24 = _local15.y;
_local25 = ((_local9 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19));
_local26 = ((_local9 * ((0.25 * (((_local22 * _local22) + (_local24 * _local22)) + (_local24 * _local24))) + ((_local20 * _local22) + (_local20 * _local24)))) + ((0.5 * _local20) * _local20));
_local7 = (_local7 + (_local16 * (_local25 + _local26)));
_local10++;
};
_arg1.mass = (_arg4 * _local6);
_local5.Multiply((1 / _local6));
_arg1.center = _local5;
_local7 = (_arg4 * (_local7 - (_local6 * b2Math.b2Dot(_local5, _local5))));
_arg1.I = _local7;
}
public static function PolyCentroid(_arg1:Array, _arg2:int, _arg3:b2Vec2):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:int;
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;
_local4 = 0;
_local5 = 0;
_local6 = 0;
_local7 = 0;
_local8 = 0;
_local9 = (1 / 3);
_local10 = 0;
while (_local10 < _arg2) {
_local11 = _local7;
_local12 = _local8;
_local13 = _arg1[_local10].x;
_local14 = _arg1[_local10].y;
_local15 = (((_local10 + 1) < _arg2)) ? _arg1[(_local10 + 1)].x : _arg1[0].x;
_local16 = (((_local10 + 1) < _arg2)) ? _arg1[(_local10 + 1)].y : _arg1[0].y;
_local17 = (_local13 - _local11);
_local18 = (_local14 - _local12);
_local19 = (_local15 - _local11);
_local20 = (_local16 - _local12);
_local21 = ((_local17 * _local20) - (_local18 * _local19));
_local22 = (0.5 * _local21);
_local6 = (_local6 + _local22);
_local4 = (_local4 + ((_local22 * _local9) * ((_local11 + _local13) + _local15)));
_local5 = (_local5 + ((_local22 * _local9) * ((_local12 + _local14) + _local16)));
_local10++;
};
_local4 = (_local4 * (1 / _local6));
_local5 = (_local5 * (1 / _local6));
_arg3.Set(_local4, _local5);
}
public static function Create(_arg1:b2ShapeDef, _arg2:b2Body, _arg3:b2Vec2):b2Shape{
switch (_arg1.type){
case e_circleShape:
return (new b2CircleShape(_arg1, _arg2, _arg3));
case e_boxShape:
case e_polyShape:
return (new b2PolyShape(_arg1, _arg2, _arg3));
};
return (null);
}
}
}//package Box2D.Collision.Shapes
Section 8
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2ShapeDef {
public var groupIndex:int;
public var categoryBits:int;
public var localRotation:Number;
public var restitution:Number;
public var userData;// = null
public var density:Number;
public var maskBits:int;
public var type:int;
public var localPosition:b2Vec2;
public var friction:Number;
public function b2ShapeDef(){
userData = null;
super();
type = b2Shape.e_unknownShape;
userData = null;
localPosition = new b2Vec2(0, 0);
localRotation = 0;
friction = 0.2;
restitution = 0;
density = 0;
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
}
public function ComputeMass(_arg1:b2MassData):void{
var _local2:b2CircleDef;
var _local3:b2BoxDef;
var _local4:b2PolyDef;
_arg1.center = new b2Vec2(0, 0);
if (density == 0){
_arg1.mass = 0;
_arg1.center.Set(0, 0);
_arg1.I = 0;
};
switch (type){
case b2Shape.e_circleShape:
_local2 = (this as b2CircleDef);
_arg1.mass = (((density * b2Settings.b2_pi) * _local2.radius) * _local2.radius);
_arg1.center.Set(0, 0);
_arg1.I = (((0.5 * _arg1.mass) * _local2.radius) * _local2.radius);
break;
case b2Shape.e_boxShape:
_local3 = (this as b2BoxDef);
_arg1.mass = (((4 * density) * _local3.extents.x) * _local3.extents.y);
_arg1.center.Set(0, 0);
_arg1.I = ((_arg1.mass / 3) * b2Math.b2Dot(_local3.extents, _local3.extents));
break;
case b2Shape.e_polyShape:
_local4 = (this as b2PolyDef);
b2Shape.PolyMass(_arg1, _local4.vertices, _local4.vertexCount, density);
break;
default:
_arg1.mass = 0;
_arg1.center.Set(0, 0);
_arg1.I = 0;
break;
};
}
}
}//package Box2D.Collision.Shapes
Section 9
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var minVertex:b2Vec2;
public var maxVertex:b2Vec2;
public function b2AABB(){
minVertex = new b2Vec2();
maxVertex = new b2Vec2();
super();
}
public function IsValid():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:Boolean;
_local1 = maxVertex.x;
_local2 = maxVertex.y;
_local1 = maxVertex.x;
_local2 = maxVertex.y;
_local1 = (_local1 - minVertex.x);
_local2 = (_local2 - minVertex.y);
_local3 = (((_local1 >= 0)) && ((_local2 >= 0)));
_local3 = ((((_local3) && (minVertex.IsValid()))) && (maxVertex.IsValid()));
return (_local3);
}
}
}//package Box2D.Collision
Section 10
//b2Bound (Box2D.Collision.b2Bound)
package Box2D.Collision {
public class b2Bound {
public var proxyId:uint;
public var stabbingCount:uint;
public var value:uint;
public function Swap(_arg1:b2Bound):void{
var _local2:uint;
var _local3:uint;
var _local4:uint;
_local2 = value;
_local3 = proxyId;
_local4 = stabbingCount;
value = _arg1.value;
proxyId = _arg1.proxyId;
stabbingCount = _arg1.stabbingCount;
_arg1.value = _local2;
_arg1.proxyId = _local3;
_arg1.stabbingCount = _local4;
}
public function IsLower():Boolean{
return (((value & 1) == 0));
}
public function IsUpper():Boolean{
return (((value & 1) == 1));
}
}
}//package Box2D.Collision
Section 11
//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 12
//b2BroadPhase (Box2D.Collision.b2BroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2BroadPhase {
public var m_quantizationFactor:b2Vec2;
public var m_worldAABB:b2AABB;
public var m_bounds:Array;
public var m_freeProxy:uint;
public var m_proxyCount:int;
public var m_proxyPool:Array;
public var m_queryResultCount:int;
public var m_pairManager:b2PairManager;
public var m_timeStamp:uint;
public 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;
var _local6:b2Proxy;
var _local7:int;
m_pairManager = new b2PairManager();
m_proxyPool = new Array(b2Settings.b2_maxPairs);
m_bounds = new Array((2 * b2Settings.b2_maxProxies));
m_queryResults = new Array(b2Settings.b2_maxProxies);
m_quantizationFactor = new b2Vec2();
super();
m_pairManager.Initialize(this, _arg2);
m_worldAABB = _arg1;
m_proxyCount = 0;
_local3 = 0;
while (_local3 < b2Settings.b2_maxProxies) {
m_queryResults[_local3] = 0;
_local3++;
};
m_bounds = new Array(2);
_local3 = 0;
while (_local3 < 2) {
m_bounds[_local3] = new Array((2 * b2Settings.b2_maxProxies));
_local7 = 0;
while (_local7 < (2 * b2Settings.b2_maxProxies)) {
m_bounds[_local3][_local7] = new b2Bound();
_local7++;
};
_local3++;
};
_local4 = _arg1.maxVertex.x;
_local5 = _arg1.maxVertex.y;
_local4 = (_local4 - _arg1.minVertex.x);
_local5 = (_local5 - _arg1.minVertex.y);
m_quantizationFactor.x = (b2Settings.USHRT_MAX / _local4);
m_quantizationFactor.y = (b2Settings.USHRT_MAX / _local5);
_local3 = 0;
while (_local3 < (b2Settings.b2_maxProxies - 1)) {
_local6 = new b2Proxy();
m_proxyPool[_local3] = _local6;
_local6.SetNext((_local3 + 1));
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
_local3++;
};
_local6 = new b2Proxy();
m_proxyPool[(b2Settings.b2_maxProxies - 1)] = _local6;
_local6.SetNext(b2Pair.b2_nullProxy);
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
m_freeProxy = 0;
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_proxyPool[m_queryResults[_local11]];
_arg2[_local11] = _local12.userData;
_local11++;
_local10++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local10);
}
public function Commit():void{
m_pairManager.Commit();
}
public function GetProxy(_arg1:int):b2Proxy{
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((m_proxyPool[_arg1].IsValid() == false)))){
return (null);
};
return (m_proxyPool[_arg1]);
}
private function IncrementTimeStamp():void{
var _local1:uint;
if (m_timeStamp == b2Settings.USHRT_MAX){
_local1 = 0;
while (_local1 < b2Settings.b2_maxProxies) {
m_proxyPool[_local1].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:uint;
var _local11:int;
var _local12:int;
var _local13:b2Proxy;
_local8 = BinarySearch(_arg5, _arg6, _arg3);
_local9 = BinarySearch(_arg5, _arg6, _arg4);
_local10 = _local8;
while (_local10 < _local9) {
if (_arg5[_local10].IsLower()){
IncrementOverlapCount(_arg5[_local10].proxyId);
};
_local10++;
};
if (_local8 > 0){
_local11 = (_local8 - 1);
_local12 = _arg5[_local11].stabbingCount;
while (_local12) {
if (_arg5[_local11].IsLower()){
_local13 = m_proxyPool[_arg5[_local11].proxyId];
if (_local8 <= _local13.upperBounds[_arg7]){
IncrementOverlapCount(_arg5[_local11].proxyId);
_local12--;
};
};
_local11--;
};
};
_arg1[0] = _local8;
_arg2[0] = _local9;
}
private function TestOverlapValidate(_arg1:b2Proxy, _arg2:b2Proxy):Boolean{
var _local3:int;
var _local4:Array;
_local3 = 0;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
if (_local4[_arg1.lowerBounds[_local3]].value > _local4[_arg2.upperBounds[_local3]].value){
return (false);
};
if (_local4[_arg1.upperBounds[_local3]].value < _local4[_arg2.lowerBounds[_local3]].value){
return (false);
};
_local3++;
};
return (true);
}
private function ComputeBounds(_arg1:Array, _arg2:Array, _arg3:b2AABB):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local4 = _arg3.minVertex.x;
_local5 = _arg3.minVertex.y;
_local4 = b2Math.b2Min(_local4, m_worldAABB.maxVertex.x);
_local5 = b2Math.b2Min(_local5, m_worldAABB.maxVertex.y);
_local4 = b2Math.b2Max(_local4, m_worldAABB.minVertex.x);
_local5 = b2Math.b2Max(_local5, m_worldAABB.minVertex.y);
_local6 = _arg3.maxVertex.x;
_local7 = _arg3.maxVertex.y;
_local6 = b2Math.b2Min(_local6, m_worldAABB.maxVertex.x);
_local7 = b2Math.b2Min(_local7, m_worldAABB.maxVertex.y);
_local6 = b2Math.b2Max(_local6, m_worldAABB.minVertex.x);
_local7 = b2Math.b2Max(_local7, m_worldAABB.minVertex.y);
_arg1[0] = (uint((m_quantizationFactor.x * (_local4 - m_worldAABB.minVertex.x))) & (b2Settings.USHRT_MAX - 1));
_arg2[0] = ((uint((m_quantizationFactor.x * (_local6 - m_worldAABB.minVertex.x))) & 0xFFFF) | 1);
_arg1[1] = (uint((m_quantizationFactor.y * (_local5 - m_worldAABB.minVertex.y))) & (b2Settings.USHRT_MAX - 1));
_arg2[1] = ((uint((m_quantizationFactor.y * (_local7 - m_worldAABB.minVertex.y))) & 0xFFFF) | 1);
}
public function CreateProxy(_arg1:b2AABB, _arg2):uint{
var _local3:uint;
var _local4:b2Proxy;
var _local5:uint;
var _local6:uint;
var _local7:Array;
var _local8:Array;
var _local9:int;
var _local10:int;
var _local11:Array;
var _local12:uint;
var _local13:uint;
var _local14:Array;
var _local15:Array;
var _local16:Array;
var _local17:int;
var _local18:int;
var _local19:b2Bound;
var _local20:b2Bound;
var _local21:int;
var _local22:b2Proxy;
_local5 = m_freeProxy;
_local4 = m_proxyPool[_local5];
m_freeProxy = _local4.GetNext();
_local4.overlapCount = 0;
_local4.userData = _arg2;
_local6 = (2 * m_proxyCount);
_local7 = new Array();
_local8 = new Array();
ComputeBounds(_local7, _local8, _arg1);
_local9 = 0;
while (_local9 < 2) {
_local11 = m_bounds[_local9];
_local14 = [_local12];
_local15 = [_local13];
Query(_local14, _local15, _local7[_local9], _local8[_local9], _local11, _local6, _local9);
_local12 = _local14[0];
_local13 = _local15[0];
_local16 = new Array();
_local18 = (_local6 - _local13);
_local17 = 0;
while (_local17 < _local18) {
_local16[_local17] = new b2Bound();
_local19 = _local16[_local17];
_local20 = _local11[(_local13 + _local17)];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local18 = _local16.length;
_local21 = (_local13 + 2);
_local17 = 0;
while (_local17 < _local18) {
_local20 = _local16[_local17];
_local19 = _local11[(_local21 + _local17)];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local16 = new Array();
_local18 = (_local13 - _local12);
_local17 = 0;
while (_local17 < _local18) {
_local16[_local17] = new b2Bound();
_local19 = _local16[_local17];
_local20 = _local11[(_local12 + _local17)];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local18 = _local16.length;
_local21 = (_local12 + 1);
_local17 = 0;
while (_local17 < _local18) {
_local20 = _local16[_local17];
_local19 = _local11[(_local21 + _local17)];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local13++;
_local11[_local12].value = _local7[_local9];
_local11[_local12].proxyId = _local5;
_local11[_local13].value = _local8[_local9];
_local11[_local13].proxyId = _local5;
_local11[_local12].stabbingCount = ((_local12 == 0)) ? 0 : _local11[(_local12 - 1)].stabbingCount;
_local11[_local13].stabbingCount = _local11[(_local13 - 1)].stabbingCount;
_local3 = _local12;
while (_local3 < _local13) {
_local11[_local3].stabbingCount++;
_local3++;
};
_local3 = _local12;
while (_local3 < (_local6 + 2)) {
_local22 = m_proxyPool[_local11[_local3].proxyId];
if (_local11[_local3].IsLower()){
_local22.lowerBounds[_local9] = _local3;
} else {
_local22.upperBounds[_local9] = _local3;
};
_local3++;
};
_local9++;
};
m_proxyCount++;
_local10 = 0;
while (_local10 < m_queryResultCount) {
m_pairManager.AddBufferedPair(_local5, m_queryResults[_local10]);
_local10++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local5);
}
public function DestroyProxy(_arg1:uint):void{
var _local2:b2Proxy;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:Array;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:uint;
var _local11:Array;
var _local12:int;
var _local13:int;
var _local14:b2Bound;
var _local15:b2Bound;
var _local16:int;
var _local17:uint;
var _local18:int;
var _local19:b2Proxy;
_local2 = m_proxyPool[_arg1];
_local3 = (2 * m_proxyCount);
_local4 = 0;
while (_local4 < 2) {
_local6 = m_bounds[_local4];
_local7 = _local2.lowerBounds[_local4];
_local8 = _local2.upperBounds[_local4];
_local9 = _local6[_local7].value;
_local10 = _local6[_local8].value;
_local11 = new Array();
_local13 = ((_local8 - _local7) - 1);
_local12 = 0;
while (_local12 < _local13) {
_local11[_local12] = new b2Bound();
_local14 = _local11[_local12];
_local15 = _local6[((_local7 + 1) + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local13 = _local11.length;
_local16 = _local7;
_local12 = 0;
while (_local12 < _local13) {
_local15 = _local11[_local12];
_local14 = _local6[(_local16 + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local11 = new Array();
_local13 = ((_local3 - _local8) - 1);
_local12 = 0;
while (_local12 < _local13) {
_local11[_local12] = new b2Bound();
_local14 = _local11[_local12];
_local15 = _local6[((_local8 + 1) + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local13 = _local11.length;
_local16 = (_local8 - 1);
_local12 = 0;
while (_local12 < _local13) {
_local15 = _local11[_local12];
_local14 = _local6[(_local16 + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local13 = (_local3 - 2);
_local17 = _local7;
while (_local17 < _local13) {
_local19 = m_proxyPool[_local6[_local17].proxyId];
if (_local6[_local17].IsLower()){
_local19.lowerBounds[_local4] = _local17;
} else {
_local19.upperBounds[_local4] = _local17;
};
_local17++;
};
_local13 = (_local8 - 1);
_local18 = _local7;
while (_local18 < _local13) {
_local6[_local18].stabbingCount--;
_local18++;
};
Query([0], [0], _local9, _local10, _local6, (_local3 - 2), _local4);
_local4++;
};
_local5 = 0;
while (_local5 < m_queryResultCount) {
m_pairManager.RemoveBufferedPair(_arg1, m_queryResults[_local5]);
_local5++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
_local2.userData = null;
_local2.overlapCount = b2_invalid;
_local2.lowerBounds[0] = b2_invalid;
_local2.lowerBounds[1] = b2_invalid;
_local2.upperBounds[0] = b2_invalid;
_local2.upperBounds[1] = b2_invalid;
_local2.SetNext(m_freeProxy);
m_freeProxy = _arg1;
m_proxyCount--;
}
public function TestOverlap(_arg1:b2BoundValues, _arg2:b2Proxy):Boolean{
var _local3:int;
var _local4:Array;
_local3 = 0;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
if (_arg1.lowerValues[_local3] > _local4[_arg2.upperBounds[_local3]].value){
return (false);
};
if (_arg1.upperValues[_local3] < _local4[_arg2.lowerBounds[_local3]].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:uint):void{
var _local2:b2Proxy;
_local2 = m_proxyPool[_arg1];
if (_local2.timeStamp < m_timeStamp){
_local2.timeStamp = m_timeStamp;
_local2.overlapCount = 1;
} else {
_local2.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.minVertex.x;
_local3 = _arg1.minVertex.y;
_local2 = (_local2 - m_worldAABB.maxVertex.x);
_local3 = (_local3 - m_worldAABB.maxVertex.y);
_local4 = m_worldAABB.minVertex.x;
_local5 = m_worldAABB.minVertex.y;
_local4 = (_local4 - _arg1.maxVertex.x);
_local5 = (_local5 - _arg1.maxVertex.y);
_local2 = b2Math.b2Max(_local2, _local4);
_local3 = b2Math.b2Max(_local3, _local5);
return ((b2Math.b2Max(_local2, _local3) < 0));
}
public function MoveProxy(_arg1:uint, _arg2:b2AABB):void{
var _local3:uint;
var _local4:uint;
var _local5:b2Bound;
var _local6:b2Bound;
var _local7:b2Bound;
var _local8:uint;
var _local9:b2Proxy;
var _local10:uint;
var _local11:b2Proxy;
var _local12:b2BoundValues;
var _local13:b2BoundValues;
var _local14:Array;
var _local15:uint;
var _local16:uint;
var _local17:uint;
var _local18:uint;
var _local19:int;
var _local20:int;
var _local21:uint;
var _local22:b2Proxy;
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((b2Settings.b2_maxProxies <= _arg1)))){
return;
};
if (_arg2.IsValid() == false){
return;
};
_local10 = (2 * m_proxyCount);
_local11 = m_proxyPool[_arg1];
_local12 = new b2BoundValues();
ComputeBounds(_local12.lowerValues, _local12.upperValues, _arg2);
_local13 = new b2BoundValues();
_local3 = 0;
while (_local3 < 2) {
_local13.lowerValues[_local3] = m_bounds[_local3][_local11.lowerBounds[_local3]].value;
_local13.upperValues[_local3] = m_bounds[_local3][_local11.upperBounds[_local3]].value;
_local3++;
};
_local3 = 0;
while (_local3 < 2) {
_local14 = m_bounds[_local3];
_local15 = _local11.lowerBounds[_local3];
_local16 = _local11.upperBounds[_local3];
_local17 = _local12.lowerValues[_local3];
_local18 = _local12.upperValues[_local3];
_local19 = (_local17 - _local14[_local15].value);
_local20 = (_local18 - _local14[_local16].value);
_local14[_local15].value = _local17;
_local14[_local16].value = _local18;
if (_local19 < 0){
_local4 = _local15;
while ((((_local4 > 0)) && ((_local17 < _local14[(_local4 - 1)].value)))) {
_local5 = _local14[_local4];
_local6 = _local14[(_local4 - 1)];
_local21 = _local6.proxyId;
_local22 = m_proxyPool[_local6.proxyId];
_local6.stabbingCount++;
if (_local6.IsUpper() == true){
if (TestOverlap(_local12, _local22)){
m_pairManager.AddBufferedPair(_arg1, _local21);
};
var _local23 = _local22.upperBounds;
var _local24 = _local3;
var _local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local5.stabbingCount++;
} else {
_local23 = _local22.lowerBounds;
_local24 = _local3;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local5.stabbingCount--;
};
_local23 = _local11.lowerBounds;
_local24 = _local3;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local5.Swap(_local6);
_local4--;
};
};
if (_local20 > 0){
_local4 = _local16;
while ((((_local4 < (_local10 - 1))) && ((_local14[(_local4 + 1)].value <= _local18)))) {
_local5 = _local14[_local4];
_local7 = _local14[(_local4 + 1)];
_local8 = _local7.proxyId;
_local9 = m_proxyPool[_local8];
_local7.stabbingCount++;
if (_local7.IsLower() == true){
if (TestOverlap(_local12, _local9)){
m_pairManager.AddBufferedPair(_arg1, _local8);
};
_local23 = _local9.lowerBounds;
_local24 = _local3;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local5.stabbingCount++;
} else {
_local23 = _local9.upperBounds;
_local24 = _local3;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local5.stabbingCount--;
};
_local23 = _local11.upperBounds;
_local24 = _local3;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local5.Swap(_local7);
_local4++;
};
};
if (_local19 > 0){
_local4 = _local15;
while ((((_local4 < (_local10 - 1))) && ((_local14[(_local4 + 1)].value <= _local17)))) {
_local5 = _local14[_local4];
_local7 = _local14[(_local4 + 1)];
_local8 = _local7.proxyId;
_local9 = m_proxyPool[_local8];
_local7.stabbingCount--;
if (_local7.IsUpper()){
if (TestOverlap(_local13, _local9)){
m_pairManager.RemoveBufferedPair(_arg1, _local8);
};
_local23 = _local9.upperBounds;
_local24 = _local3;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local5.stabbingCount--;
} else {
_local23 = _local9.lowerBounds;
_local24 = _local3;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local5.stabbingCount++;
};
_local23 = _local11.lowerBounds;
_local24 = _local3;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local5.Swap(_local7);
_local4++;
};
};
if (_local20 < 0){
_local4 = _local16;
while ((((_local4 > 0)) && ((_local18 < _local14[(_local4 - 1)].value)))) {
_local5 = _local14[_local4];
_local6 = _local14[(_local4 - 1)];
_local21 = _local6.proxyId;
_local22 = m_proxyPool[_local21];
_local6.stabbingCount--;
if (_local6.IsLower() == true){
if (TestOverlap(_local13, _local22)){
m_pairManager.RemoveBufferedPair(_arg1, _local21);
};
_local23 = _local22.lowerBounds;
_local24 = _local3;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local5.stabbingCount--;
} else {
_local23 = _local22.upperBounds;
_local24 = _local3;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local5.stabbingCount++;
};
_local23 = _local11.upperBounds;
_local24 = _local3;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local5.Swap(_local6);
_local4--;
};
};
_local3++;
};
}
public static function BinarySearch(_arg1:Array, _arg2:int, _arg3:uint):uint{
var _local4:int;
var _local5:int;
var _local6:int;
_local4 = 0;
_local5 = (_arg2 - 1);
while (_local4 <= _local5) {
_local6 = ((_local4 + _local5) / 2);
if (_arg1[_local6].value > _arg3){
_local5 = (_local6 - 1);
} else {
if (_arg1[_local6].value < _arg3){
_local4 = (_local6 + 1);
} else {
return (uint(_local6));
};
};
};
return (uint(_local4));
}
}
}//package Box2D.Collision
Section 13
//b2BufferedPair (Box2D.Collision.b2BufferedPair)
package Box2D.Collision {
public class b2BufferedPair {
public var proxyId1:uint;
public var proxyId2:uint;
}
}//package Box2D.Collision
Section 14
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
public static function EdgeSeparation(_arg1:b2PolyShape, _arg2:int, _arg3:b2PolyShape):Number{
var _local4:Array;
var _local5:int;
var _local6:Array;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:int;
var _local14:Number;
var _local15:int;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:b2Vec2;
var _local22:Number;
_local4 = _arg1.m_vertices;
_local5 = _arg3.m_vertexCount;
_local6 = _arg3.m_vertices;
_local7 = _arg1.m_normals[_arg2].x;
_local8 = _arg1.m_normals[_arg2].y;
_local9 = _local7;
_local10 = _arg1.m_R;
_local7 = ((_local10.col1.x * _local9) + (_local10.col2.x * _local8));
_local8 = ((_local10.col1.y * _local9) + (_local10.col2.y * _local8));
_local11 = _local7;
_local12 = _local8;
_local10 = _arg3.m_R;
_local9 = ((_local11 * _local10.col1.x) + (_local12 * _local10.col1.y));
_local12 = ((_local11 * _local10.col2.x) + (_local12 * _local10.col2.y));
_local11 = _local9;
_local13 = 0;
_local14 = Number.MAX_VALUE;
_local15 = 0;
while (_local15 < _local5) {
_local21 = _local6[_local15];
_local22 = ((_local21.x * _local11) + (_local21.y * _local12));
if (_local22 < _local14){
_local14 = _local22;
_local13 = _local15;
};
_local15++;
};
_local10 = _arg1.m_R;
_local16 = (_arg1.m_position.x + ((_local10.col1.x * _local4[_arg2].x) + (_local10.col2.x * _local4[_arg2].y)));
_local17 = (_arg1.m_position.y + ((_local10.col1.y * _local4[_arg2].x) + (_local10.col2.y * _local4[_arg2].y)));
_local10 = _arg3.m_R;
_local18 = (_arg3.m_position.x + ((_local10.col1.x * _local6[_local13].x) + (_local10.col2.x * _local6[_local13].y)));
_local19 = (_arg3.m_position.y + ((_local10.col1.y * _local6[_local13].x) + (_local10.col2.y * _local6[_local13].y)));
_local18 = (_local18 - _local16);
_local19 = (_local19 - _local17);
_local20 = ((_local18 * _local7) + (_local19 * _local8));
return (_local20);
}
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.minVertex;
_local4 = _arg1.maxVertex;
_local5 = (_local3.x - _local4.x);
_local6 = (_local3.y - _local4.y);
_local3 = _arg1.minVertex;
_local4 = _arg2.maxVertex;
_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:b2PolyShape, _arg3:int, _arg4:b2PolyShape):void{
var _local5:int;
var _local6:Array;
var _local7:int;
var _local8:Array;
var _local9:int;
var _local10:int;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:b2Mat22;
var _local19:Number;
var _local20:Number;
var _local21:int;
var _local22:int;
var _local23:Number;
var _local24:int;
var _local25:ClipVertex;
var _local26:int;
var _local27:int;
var _local28:Number;
var _local29:Number;
var _local30:Number;
_local5 = _arg2.m_vertexCount;
_local6 = _arg2.m_vertices;
_local7 = _arg4.m_vertexCount;
_local8 = _arg4.m_vertices;
_local9 = _arg3;
_local10 = (((_arg3 + 1) == _local5)) ? 0 : (_arg3 + 1);
_local11 = _local6[_local10];
_local12 = _local11.x;
_local13 = _local11.y;
_local11 = _local6[_local9];
_local12 = (_local12 - _local11.x);
_local13 = (_local13 - _local11.y);
_local14 = _local12;
_local12 = _local13;
_local13 = -(_local14);
_local15 = (1 / Math.sqrt(((_local12 * _local12) + (_local13 * _local13))));
_local12 = (_local12 * _local15);
_local13 = (_local13 * _local15);
_local16 = _local12;
_local17 = _local13;
_local14 = _local16;
_local18 = _arg2.m_R;
_local16 = ((_local18.col1.x * _local14) + (_local18.col2.x * _local17));
_local17 = ((_local18.col1.y * _local14) + (_local18.col2.y * _local17));
_local19 = _local16;
_local20 = _local17;
_local18 = _arg4.m_R;
_local14 = ((_local19 * _local18.col1.x) + (_local20 * _local18.col1.y));
_local20 = ((_local19 * _local18.col2.x) + (_local20 * _local18.col2.y));
_local19 = _local14;
_local23 = Number.MAX_VALUE;
_local24 = 0;
while (_local24 < _local7) {
_local26 = _local24;
_local27 = (((_local24 + 1) < _local7)) ? (_local24 + 1) : 0;
_local11 = _local8[_local27];
_local28 = _local11.x;
_local29 = _local11.y;
_local11 = _local8[_local26];
_local28 = (_local28 - _local11.x);
_local29 = (_local29 - _local11.y);
_local14 = _local28;
_local28 = _local29;
_local29 = -(_local14);
_local15 = (1 / Math.sqrt(((_local28 * _local28) + (_local29 * _local29))));
_local28 = (_local28 * _local15);
_local29 = (_local29 * _local15);
_local30 = ((_local28 * _local19) + (_local29 * _local20));
if (_local30 < _local23){
_local23 = _local30;
_local21 = _local26;
_local22 = _local27;
};
_local24++;
};
_local25 = _arg1[0];
_local11 = _local25.v;
_local11.SetV(_local8[_local21]);
_local11.MulM(_arg4.m_R);
_local11.Add(_arg4.m_position);
_local25.id.features.referenceFace = _arg3;
_local25.id.features.incidentEdge = _local21;
_local25.id.features.incidentVertex = _local21;
_local25 = _arg1[1];
_local11 = _local25.v;
_local11.SetV(_local8[_local22]);
_local11.MulM(_arg4.m_R);
_local11.Add(_arg4.m_position);
_local25.id.features.referenceFace = _arg3;
_local25.id.features.incidentEdge = _local21;
_local25.id.features.incidentVertex = _local22;
}
public static function b2CollidePolyAndCircle(_arg1:b2Manifold, _arg2:b2PolyShape, _arg3:b2CircleShape, _arg4:Boolean):void{
var _local5:b2ContactPoint;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:int;
var _local14:Number;
var _local15:Number;
var _local16:int;
var _local17:int;
var _local18:int;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:b2Vec2;
_arg1.pointCount = 0;
_local8 = (_arg3.m_position.x - _arg2.m_position.x);
_local9 = (_arg3.m_position.y - _arg2.m_position.y);
_local10 = _arg2.m_R;
_local11 = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y));
_local9 = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y));
_local8 = _local11;
_local13 = 0;
_local14 = -(Number.MAX_VALUE);
_local15 = _arg3.m_radius;
_local16 = 0;
while (_local16 < _arg2.m_vertexCount) {
_local25 = ((_arg2.m_normals[_local16].x * (_local8 - _arg2.m_vertices[_local16].x)) + (_arg2.m_normals[_local16].y * (_local9 - _arg2.m_vertices[_local16].y)));
if (_local25 > _local15){
return;
};
if (_local25 > _local14){
_local14 = _local25;
_local13 = _local16;
};
_local16++;
};
if (_local14 < Number.MIN_VALUE){
_arg1.pointCount = 1;
_local26 = _arg2.m_normals[_local13];
_arg1.normal.x = ((_local10.col1.x * _local26.x) + (_local10.col2.x * _local26.y));
_arg1.normal.y = ((_local10.col1.y * _local26.x) + (_local10.col2.y * _local26.y));
_local5 = _arg1.points[0];
_local5.id.features.incidentEdge = _local13;
_local5.id.features.incidentVertex = b2_nullFeature;
_local5.id.features.referenceFace = b2_nullFeature;
_local5.id.features.flip = 0;
_local5.position.x = (_arg3.m_position.x - (_local15 * _arg1.normal.x));
_local5.position.y = (_arg3.m_position.y - (_local15 * _arg1.normal.y));
_local5.separation = (_local14 - _local15);
return;
};
_local17 = _local13;
_local18 = (((_local17 + 1) < _arg2.m_vertexCount)) ? (_local17 + 1) : 0;
_local19 = (_arg2.m_vertices[_local18].x - _arg2.m_vertices[_local17].x);
_local20 = (_arg2.m_vertices[_local18].y - _arg2.m_vertices[_local17].y);
_local21 = Math.sqrt(((_local19 * _local19) + (_local20 * _local20)));
_local19 = (_local19 / _local21);
_local20 = (_local20 / _local21);
if (_local21 < Number.MIN_VALUE){
_local6 = (_local8 - _arg2.m_vertices[_local17].x);
_local7 = (_local9 - _arg2.m_vertices[_local17].y);
_local12 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
_local6 = (_local6 / _local12);
_local7 = (_local7 / _local12);
if (_local12 > _local15){
return;
};
_arg1.pointCount = 1;
_arg1.normal.Set(((_local10.col1.x * _local6) + (_local10.col2.x * _local7)), ((_local10.col1.y * _local6) + (_local10.col2.y * _local7)));
_local5 = _arg1.points[0];
_local5.id.features.incidentEdge = b2_nullFeature;
_local5.id.features.incidentVertex = _local17;
_local5.id.features.referenceFace = b2_nullFeature;
_local5.id.features.flip = 0;
_local5.position.x = (_arg3.m_position.x - (_local15 * _arg1.normal.x));
_local5.position.y = (_arg3.m_position.y - (_local15 * _arg1.normal.y));
_local5.separation = (_local12 - _local15);
return;
};
_local22 = (((_local8 - _arg2.m_vertices[_local17].x) * _local19) + ((_local9 - _arg2.m_vertices[_local17].y) * _local20));
_local5 = _arg1.points[0];
_local5.id.features.incidentEdge = b2_nullFeature;
_local5.id.features.incidentVertex = b2_nullFeature;
_local5.id.features.referenceFace = b2_nullFeature;
_local5.id.features.flip = 0;
if (_local22 <= 0){
_local23 = _arg2.m_vertices[_local17].x;
_local24 = _arg2.m_vertices[_local17].y;
_local5.id.features.incidentVertex = _local17;
} else {
if (_local22 >= _local21){
_local23 = _arg2.m_vertices[_local18].x;
_local24 = _arg2.m_vertices[_local18].y;
_local5.id.features.incidentVertex = _local18;
} else {
_local23 = ((_local19 * _local22) + _arg2.m_vertices[_local17].x);
_local24 = ((_local20 * _local22) + _arg2.m_vertices[_local17].y);
_local5.id.features.incidentEdge = _local17;
};
};
_local6 = (_local8 - _local23);
_local7 = (_local9 - _local24);
_local12 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
_local6 = (_local6 / _local12);
_local7 = (_local7 / _local12);
if (_local12 > _local15){
return;
};
_arg1.pointCount = 1;
_arg1.normal.Set(((_local10.col1.x * _local6) + (_local10.col2.x * _local7)), ((_local10.col1.y * _local6) + (_local10.col2.y * _local7)));
_local5.position.x = (_arg3.m_position.x - (_local15 * _arg1.normal.x));
_local5.position.y = (_arg3.m_position.y - (_local15 * _arg1.normal.y));
_local5.separation = (_local12 - _local15);
}
public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolyShape, _arg3:b2PolyShape, _arg4:Boolean):Number{
var _local5:int;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local11:Number;
var _local12:int;
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;
_local5 = _arg2.m_vertexCount;
_local6 = (_arg3.m_position.x - _arg2.m_position.x);
_local7 = (_arg3.m_position.y - _arg2.m_position.y);
_local8 = ((_local6 * _arg2.m_R.col1.x) + (_local7 * _arg2.m_R.col1.y));
_local9 = ((_local6 * _arg2.m_R.col2.x) + (_local7 * _arg2.m_R.col2.y));
_local10 = 0;
_local11 = -(Number.MAX_VALUE);
_local12 = 0;
while (_local12 < _local5) {
_local21 = ((_arg2.m_normals[_local12].x * _local8) + (_arg2.m_normals[_local12].y * _local9));
if (_local21 > _local11){
_local11 = _local21;
_local10 = _local12;
};
_local12++;
};
_local13 = EdgeSeparation(_arg2, _local10, _arg3);
if ((((_local13 > 0)) && ((_arg4 == false)))){
return (_local13);
};
_local14 = (((_local10 - 1) >= 0)) ? (_local10 - 1) : (_local5 - 1);
_local15 = EdgeSeparation(_arg2, _local14, _arg3);
if ((((_local15 > 0)) && ((_arg4 == false)))){
return (_local15);
};
_local16 = (((_local10 + 1) < _local5)) ? (_local10 + 1) : 0;
_local17 = EdgeSeparation(_arg2, _local16, _arg3);
if ((((_local17 > 0)) && ((_arg4 == false)))){
return (_local17);
};
if ((((_local15 > _local13)) && ((_local15 > _local17)))){
_local20 = -1;
_local18 = _local14;
_local19 = _local15;
} else {
if (_local17 > _local13){
_local20 = 1;
_local18 = _local16;
_local19 = _local17;
} else {
_arg1[0] = _local10;
return (_local13);
};
};
while (true) {
if (_local20 == -1){
_local10 = (((_local18 - 1) >= 0)) ? (_local18 - 1) : (_local5 - 1);
} else {
_local10 = (((_local18 + 1) < _local5)) ? (_local18 + 1) : 0;
};
_local13 = EdgeSeparation(_arg2, _local10, _arg3);
if ((((_local13 > 0)) && ((_arg4 == false)))){
return (_local13);
};
if (_local13 > _local19){
_local18 = _local10;
_local19 = _local13;
} else {
break;
};
};
_arg1[0] = _local18;
return (_local19);
}
public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{
var _local5:int;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
_local5 = 0;
_local6 = _arg2[0].v;
_local7 = _arg2[1].v;
_local8 = (b2Math.b2Dot(_arg3, _arg2[0].v) - _arg4);
_local9 = (b2Math.b2Dot(_arg3, _arg2[1].v) - _arg4);
if (_local8 <= 0){
var _temp1 = _local5;
_local5 = (_local5 + 1);
var _local12 = _temp1;
_arg1[_local12] = _arg2[0];
};
if (_local9 <= 0){
var _temp2 = _local5;
_local5 = (_local5 + 1);
_local12 = _temp2;
_arg1[_local12] = _arg2[1];
};
if ((_local8 * _local9) < 0){
_local10 = (_local8 / (_local8 - _local9));
_local11 = _arg1[_local5].v;
_local11.x = (_local6.x + (_local10 * (_local7.x - _local6.x)));
_local11.y = (_local6.y + (_local10 * (_local7.y - _local6.y)));
if (_local8 > 0){
_arg1[_local5].id = _arg2[0].id;
} else {
_arg1[_local5].id = _arg2[1].id;
};
_local5++;
};
return (_local5);
}
public static function b2CollidePoly(_arg1:b2Manifold, _arg2:b2PolyShape, _arg3:b2PolyShape, _arg4:Boolean):void{
var _local5:int;
var _local6:Array;
var _local7:Number;
var _local8:int;
var _local9:Array;
var _local10:Number;
var _local11:b2PolyShape;
var _local12:b2PolyShape;
var _local13:int;
var _local14:int;
var _local15:Number;
var _local16:Number;
var _local17:Array;
var _local18:int;
var _local19:Array;
var _local20:b2Vec2;
var _local21:b2Vec2;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:b2Mat22;
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:Array;
var _local39:Array;
var _local40:int;
var _local41:int;
var _local42:int;
var _local43:b2Vec2;
var _local44:Number;
var _local45:b2ContactPoint;
_arg1.pointCount = 0;
_local5 = 0;
_local6 = [_local5];
_local7 = FindMaxSeparation(_local6, _arg2, _arg3, _arg4);
_local5 = _local6[0];
if ((((_local7 > 0)) && ((_arg4 == false)))){
return;
};
_local8 = 0;
_local9 = [_local8];
_local10 = FindMaxSeparation(_local9, _arg3, _arg2, _arg4);
_local8 = _local9[0];
if ((((_local10 > 0)) && ((_arg4 == false)))){
return;
};
_local15 = 0.98;
_local16 = 0.001;
if (_local10 > ((_local15 * _local7) + _local16)){
_local11 = _arg3;
_local12 = _arg2;
_local13 = _local8;
_local14 = 1;
} else {
_local11 = _arg2;
_local12 = _arg3;
_local13 = _local5;
_local14 = 0;
};
_local17 = [new ClipVertex(), new ClipVertex()];
FindIncidentEdge(_local17, _local11, _local13, _local12);
_local18 = _local11.m_vertexCount;
_local19 = _local11.m_vertices;
_local20 = _local19[_local13];
_local21 = (((_local13 + 1) < _local18)) ? _local19[(_local13 + 1)] : _local19[0];
_local22 = (_local21.x - _local20.x);
_local23 = (_local21.y - _local20.y);
_local24 = (_local21.x - _local20.x);
_local25 = (_local21.y - _local20.y);
_local26 = _local24;
_local27 = _local11.m_R;
_local24 = ((_local27.col1.x * _local26) + (_local27.col2.x * _local25));
_local25 = ((_local27.col1.y * _local26) + (_local27.col2.y * _local25));
_local28 = (1 / Math.sqrt(((_local24 * _local24) + (_local25 * _local25))));
_local24 = (_local24 * _local28);
_local25 = (_local25 * _local28);
_local29 = _local24;
_local30 = _local25;
_local26 = _local29;
_local29 = _local30;
_local30 = -(_local26);
_local31 = _local20.x;
_local32 = _local20.y;
_local26 = _local31;
_local27 = _local11.m_R;
_local31 = ((_local27.col1.x * _local26) + (_local27.col2.x * _local32));
_local32 = ((_local27.col1.y * _local26) + (_local27.col2.y * _local32));
_local31 = (_local31 + _local11.m_position.x);
_local32 = (_local32 + _local11.m_position.y);
_local33 = _local21.x;
_local34 = _local21.y;
_local26 = _local33;
_local27 = _local11.m_R;
_local33 = ((_local27.col1.x * _local26) + (_local27.col2.x * _local34));
_local34 = ((_local27.col1.y * _local26) + (_local27.col2.y * _local34));
_local33 = (_local33 + _local11.m_position.x);
_local34 = (_local34 + _local11.m_position.y);
_local35 = ((_local29 * _local31) + (_local30 * _local32));
_local36 = -(((_local24 * _local31) + (_local25 * _local32)));
_local37 = ((_local24 * _local33) + (_local25 * _local34));
_local38 = [new ClipVertex(), new ClipVertex()];
_local39 = [new ClipVertex(), new ClipVertex()];
b2CollidePolyTempVec.Set(-(_local24), -(_local25));
_local40 = ClipSegmentToLine(_local38, _local17, b2CollidePolyTempVec, _local36);
if (_local40 < 2){
return;
};
b2CollidePolyTempVec.Set(_local24, _local25);
_local40 = ClipSegmentToLine(_local39, _local38, b2CollidePolyTempVec, _local37);
if (_local40 < 2){
return;
};
if (_local14){
_arg1.normal.Set(-(_local29), -(_local30));
} else {
_arg1.normal.Set(_local29, _local30);
};
_local41 = 0;
_local42 = 0;
while (_local42 < b2Settings.b2_maxManifoldPoints) {
_local43 = _local39[_local42].v;
_local44 = (((_local29 * _local43.x) + (_local30 * _local43.y)) - _local35);
if ((((_local44 <= 0)) || ((_arg4 == true)))){
_local45 = _arg1.points[_local41];
_local45.separation = _local44;
_local45.position.SetV(_local39[_local42].v);
_local45.id.Set(_local39[_local42].id);
_local45.id.features.flip = _local14;
_local41++;
};
_local42++;
};
_arg1.pointCount = _local41;
}
public static function b2CollideCircle(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2CircleShape, _arg4:Boolean):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:b2ContactPoint;
var _local11:Number;
var _local12:Number;
_arg1.pointCount = 0;
_local5 = (_arg3.m_position.x - _arg2.m_position.x);
_local6 = (_arg3.m_position.y - _arg2.m_position.y);
_local7 = ((_local5 * _local5) + (_local6 * _local6));
_local8 = (_arg2.m_radius + _arg3.m_radius);
if ((((_local7 > (_local8 * _local8))) && ((_arg4 == false)))){
return;
};
if (_local7 < Number.MIN_VALUE){
_local9 = -(_local8);
_arg1.normal.Set(0, 1);
} else {
_local11 = Math.sqrt(_local7);
_local9 = (_local11 - _local8);
_local12 = (1 / _local11);
_arg1.normal.x = (_local12 * _local5);
_arg1.normal.y = (_local12 * _local6);
};
_arg1.pointCount = 1;
_local10 = _arg1.points[0];
_local10.id.key = 0;
_local10.separation = _local9;
_local10.position.x = (_arg3.m_position.x - (_arg3.m_radius * _arg1.normal.x));
_local10.position.y = (_arg3.m_position.y - (_arg3.m_radius * _arg1.normal.y));
}
}
}//package Box2D.Collision
Section 15
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
public class b2ContactID {
public 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._referenceFace = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
}
}//package Box2D.Collision
Section 16
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ContactPoint {
public var separation:Number;
public var position:b2Vec2;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var id:b2ContactID;
public function b2ContactPoint(){
position = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 17
//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;
public var normal:b2Vec2;
public function b2Manifold(){
var _local1:int;
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
_local1 = 0;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactPoint();
_local1++;
};
normal = new b2Vec2();
}
}
}//package Box2D.Collision
Section 18
//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 19
//b2Pair (Box2D.Collision.b2Pair)
package Box2D.Collision {
public class b2Pair {
public var userData;// = null
public var proxyId1:uint;
public var proxyId2:uint;
public var status:uint;
public var next:uint;
public static var e_pairFinal:uint = 4;
public static var b2_tableMask:int = (b2_tableCapacity - 1);
public static var e_pairRemoved:uint = 2;
public static var b2_nullPair:uint = 0xFFFF;
public static var e_pairBuffered:uint = 1;
public static var b2_nullProxy:uint = 0xFFFF;
public static var b2_tableCapacity:int = 8192;
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 20
//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 21
//b2PairManager (Box2D.Collision.b2PairManager)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PairManager {
public var m_pairCount:int;
public var m_pairBuffer:Array;
public var m_callback:b2PairCallback;
public var m_pairs:Array;
public var m_pairBufferCount:int;
public var m_hashTable:Array;
public var m_broadPhase:b2BroadPhase;
public var m_freePair:uint;
public function b2PairManager(){
var _local1:uint;
super();
m_hashTable = new Array(b2Pair.b2_tableCapacity);
_local1 = 0;
while (_local1 < b2Pair.b2_tableCapacity) {
m_hashTable[_local1] = b2Pair.b2_nullPair;
_local1++;
};
m_pairs = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairs[_local1] = new b2Pair();
_local1++;
};
m_pairBuffer = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairBuffer[_local1] = new b2BufferedPair();
_local1++;
};
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairs[_local1].proxyId1 = b2Pair.b2_nullProxy;
m_pairs[_local1].proxyId2 = b2Pair.b2_nullProxy;
m_pairs[_local1].userData = null;
m_pairs[_local1].status = 0;
m_pairs[_local1].next = (_local1 + 1);
_local1++;
};
m_pairs[(b2Settings.b2_maxPairs - 1)].next = b2Pair.b2_nullPair;
m_pairCount = 0;
}
private function FindHash(_arg1:uint, _arg2:uint, _arg3:uint):b2Pair{
var _local4:uint;
_local4 = m_hashTable[_arg3];
while (((!((_local4 == b2Pair.b2_nullPair))) && ((Equals(m_pairs[_local4], _arg1, _arg2) == false)))) {
_local4 = m_pairs[_local4].next;
};
if (_local4 == b2Pair.b2_nullPair){
return (null);
};
return (m_pairs[_local4]);
}
private function Find(_arg1:uint, _arg2:uint):b2Pair{
var _local3:uint;
var _local4:uint;
if (_arg1 > _arg2){
_local4 = _arg1;
_arg1 = _arg2;
_arg2 = _local4;
};
_local3 = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
return (FindHash(_arg1, _arg2, _local3));
}
private function ValidateBuffer():void{
}
public function Commit():void{
var _local1:int;
var _local2:int;
var _local3:Array;
var _local4:b2Pair;
var _local5:b2Proxy;
var _local6:b2Proxy;
_local2 = 0;
_local3 = m_broadPhase.m_proxyPool;
_local1 = 0;
while (_local1 < m_pairBufferCount) {
_local4 = Find(m_pairBuffer[_local1].proxyId1, m_pairBuffer[_local1].proxyId2);
_local4.ClearBuffered();
_local5 = _local3[_local4.proxyId1];
_local6 = _local3[_local4.proxyId2];
if (_local4.IsRemoved()){
if (_local4.IsFinal() == true){
m_callback.PairRemoved(_local5.userData, _local6.userData, _local4.userData);
};
m_pairBuffer[_local2].proxyId1 = _local4.proxyId1;
m_pairBuffer[_local2].proxyId2 = _local4.proxyId2;
_local2++;
} else {
if (_local4.IsFinal() == false){
_local4.userData = m_callback.PairAdded(_local5.userData, _local6.userData);
_local4.SetFinal();
};
};
_local1++;
};
_local1 = 0;
while (_local1 < _local2) {
RemovePair(m_pairBuffer[_local1].proxyId1, m_pairBuffer[_local1].proxyId2);
_local1++;
};
m_pairBufferCount = 0;
if (b2BroadPhase.s_validate){
ValidateTable();
};
}
public function RemoveBufferedPair(_arg1:int, _arg2:int):void{
var _local3:b2Pair;
_local3 = Find(_arg1, _arg2);
if (_local3 == null){
return;
};
if (_local3.IsBuffered() == false){
_local3.SetBuffered();
m_pairBuffer[m_pairBufferCount].proxyId1 = _local3.proxyId1;
m_pairBuffer[m_pairBufferCount].proxyId2 = _local3.proxyId2;
m_pairBufferCount++;
};
_local3.SetRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function RemovePair(_arg1:uint, _arg2:uint){
var _local3:uint;
var _local4:uint;
var _local5:b2Pair;
var _local6:uint;
var _local7:uint;
var _local8:b2Pair;
var _local9:*;
if (_arg1 > _arg2){
_local6 = _arg1;
_arg1 = _arg2;
_arg2 = _local6;
};
_local3 = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
_local4 = m_hashTable[_local3];
_local5 = null;
while (_local4 != b2Pair.b2_nullPair) {
if (Equals(m_pairs[_local4], _arg1, _arg2)){
_local7 = _local4;
if (_local5){
_local5.next = m_pairs[_local4].next;
} else {
m_hashTable[_local3] = m_pairs[_local4].next;
};
_local8 = m_pairs[_local7];
_local9 = _local8.userData;
_local8.next = m_freePair;
_local8.proxyId1 = b2Pair.b2_nullProxy;
_local8.proxyId2 = b2Pair.b2_nullProxy;
_local8.userData = null;
_local8.status = 0;
m_freePair = _local7;
m_pairCount--;
return (_local9);
} else {
_local5 = m_pairs[_local4];
_local4 = _local5.next;
};
};
return (null);
}
public function Initialize(_arg1:b2BroadPhase, _arg2:b2PairCallback):void{
m_broadPhase = _arg1;
m_callback = _arg2;
}
public function AddBufferedPair(_arg1:int, _arg2:int):void{
var _local3:b2Pair;
_local3 = AddPair(_arg1, _arg2);
if (_local3.IsBuffered() == false){
_local3.SetBuffered();
m_pairBuffer[m_pairBufferCount].proxyId1 = _local3.proxyId1;
m_pairBuffer[m_pairBufferCount].proxyId2 = _local3.proxyId2;
m_pairBufferCount++;
};
_local3.ClearRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function AddPair(_arg1:uint, _arg2:uint):b2Pair{
var _local3:uint;
var _local4:b2Pair;
var _local5:uint;
var _local6:uint;
if (_arg1 > _arg2){
_local6 = _arg1;
_arg1 = _arg2;
_arg2 = _local6;
};
_local3 = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
_local4 = FindHash(_arg1, _arg2, _local3);
if (_local4 != null){
return (_local4);
};
_local5 = m_freePair;
_local4 = m_pairs[_local5];
m_freePair = _local4.next;
_local4.proxyId1 = _arg1;
_local4.proxyId2 = _arg2;
_local4.status = 0;
_local4.userData = null;
_local4.next = m_hashTable[_local3];
m_hashTable[_local3] = _local5;
m_pairCount++;
return (_local4);
}
private function ValidateTable():void{
}
public static function EqualsPair(_arg1:b2BufferedPair, _arg2:b2BufferedPair):Boolean{
return ((((_arg1.proxyId1 == _arg2.proxyId1)) && ((_arg1.proxyId2 == _arg2.proxyId2))));
}
public static function Hash(_arg1:uint, _arg2:uint):uint{
var _local3:uint;
_local3 = (((_arg2 << 16) & 4294901760) | _arg1);
_local3 = (~(_local3) + ((_local3 << 15) & 4294934528));
_local3 = (_local3 ^ ((_local3 >> 12) & 1048575));
_local3 = (_local3 + ((_local3 << 2) & 4294967292));
_local3 = (_local3 ^ ((_local3 >> 4) & 268435455));
_local3 = (_local3 * 2057);
_local3 = (_local3 ^ ((_local3 >> 16) & 0xFFFF));
return (_local3);
}
public static function Equals(_arg1:b2Pair, _arg2:uint, _arg3:uint):Boolean{
return ((((_arg1.proxyId1 == _arg2)) && ((_arg1.proxyId2 == _arg3))));
}
}
}//package Box2D.Collision
Section 22
//b2Proxy (Box2D.Collision.b2Proxy)
package Box2D.Collision {
public class b2Proxy {
public var overlapCount:uint;
public var lowerBounds:Array;
public var upperBounds:Array;
public var userData;// = null
public var timeStamp:uint;
public function b2Proxy(){
lowerBounds = [uint(0), uint(0)];
upperBounds = [uint(0), uint(0)];
userData = null;
super();
}
public function GetNext():uint{
return (lowerBounds[0]);
}
public function IsValid():Boolean{
return (!((overlapCount == b2BroadPhase.b2_invalid)));
}
public function SetNext(_arg1:uint):void{
lowerBounds[0] = (_arg1 & 0xFFFF);
}
}
}//package Box2D.Collision
Section 23
//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 24
//Features (Box2D.Collision.Features)
package Box2D.Collision {
public class Features {
public var _referenceFace:int;
public var _incidentEdge:int;
public var _flip:int;
public var _incidentVertex:int;
public var _m_id:b2ContactID;
public function get referenceFace():int{
return (_referenceFace);
}
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 referenceFace(_arg1:int):void{
_referenceFace = _arg1;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceFace & 0xFF));
}
public function set flip(_arg1:int):void{
_flip = _arg1;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set incidentEdge(_arg1:int):void{
_incidentEdge = _arg1;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Box2D.Collision
Section 25
//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 Invert(_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 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 26
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
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 b2Swap(_arg1:Array, _arg2:Array):void{
var _local3:*;
_local3 = _arg1[0];
_arg1[0] = _arg2[0];
_arg2[0] = _local3;
}
public static function b2Abs(_arg1:Number):Number{
return (((_arg1 > 0)) ? _arg1 : -(_arg1));
}
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 b2CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
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 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 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 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 MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y));
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 27
//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 Add(_arg1:b2Vec2):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function SetZero():void{
x = 0;
y = 0;
}
public function CrossVF(_arg1:Number):void{
var _local2:Number;
_local2 = x;
x = (_arg1 * y);
y = (-(_arg1) * _local2);
}
public function MaxV(_arg1:b2Vec2):void{
x = ((x > _arg1.x)) ? x : _arg1.x;
y = ((y > _arg1.y)) ? y : _arg1.y;
}
public function SetV(_arg1:b2Vec2):void{
x = _arg1.x;
y = _arg1.y;
}
public function Negative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function Abs():void{
x = Math.abs(x);
y = Math.abs(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 = Length();
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 28
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Settings {
public static const b2_lengthUnitsPerMeter:Number = 1;
public static const b2_angularSleepTolerance:Number = 0.0111111111111111;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_angularSlop:Number = 0.0349065850398866;
public static const b2_linearSlop:Number = 0.005;
public static const b2_pi:Number = 3.14159265358979;
public static const b2_maxShapesPerBody:int = 64;
public static const b2_maxProxies:int = 0x0400;
public static const b2_velocityThreshold:Number = 1;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxPairs:int = 8192;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_massUnitsPerKilogram:Number = 1;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const USHRT_MAX:int = 0xFFFF;
public static const b2_maxLinearCorrection:Number = 0.2;
public static const b2_maxPolyVertices:int = 32;
public static const b2_timeUnitsPerSecond:Number = 1;
public static function b2Assert(_arg1:Boolean):void{
var _local2:b2Vec2;
if (!_arg1){
_local2.x++;
};
}
}
}//package Box2D.Common
Section 29
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
public var m_manifold:Array;
public function b2CircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifold = [new b2Manifold()];
super(_arg1, _arg2);
m_manifold[0].pointCount = 0;
m_manifold[0].points[0].normalImpulse = 0;
m_manifold[0].points[0].tangentImpulse = 0;
}
override public function GetManifolds():Array{
return (m_manifold);
}
override public function Evaluate():void{
b2Collision.b2CollideCircle(m_manifold[0], (m_shape1 as b2CircleShape), (m_shape2 as b2CircleShape), false);
if (m_manifold[0].pointCount > 0){
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
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 30
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Contact {
public var m_shape1:b2Shape;
public var m_shape2:b2Shape;
public var m_prev:b2Contact;
public var m_next:b2Contact;
public var m_friction:Number;
public var m_manifoldCount:int;
public var m_node1:b2ContactNode;
public var m_node2:b2ContactNode;
public var m_restitution:Number;
public var m_flags:uint;
public static var s_registers:Array;
public static var s_initialized:Boolean = false;
public static var e_islandFlag:uint = 1;
public static var e_destroyFlag:uint = 2;
public function b2Contact(_arg1:b2Shape=null, _arg2:b2Shape=null){
m_node1 = new b2ContactNode();
m_node2 = new b2ContactNode();
super();
m_flags = 0;
if (((!(_arg1)) || (!(_arg2)))){
m_shape1 = null;
m_shape2 = null;
return;
};
m_shape1 = _arg1;
m_shape2 = _arg2;
m_manifoldCount = 0;
m_friction = Math.sqrt((m_shape1.m_friction * m_shape2.m_friction));
m_restitution = b2Math.b2Max(m_shape1.m_restitution, m_shape2.m_restitution);
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 GetNext():b2Contact{
return (m_next);
}
public function GetShape2():b2Shape{
return (m_shape2);
}
public function GetManifoldCount():int{
return (m_manifoldCount);
}
public function GetManifolds():Array{
return (null);
}
public function Evaluate():void{
}
public 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_polyShape, b2Shape.e_circleShape);
AddType(b2PolyContact.Create, b2PolyContact.Destroy, b2Shape.e_polyShape, b2Shape.e_polyShape);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
var _local3:int;
var _local4:int;
var _local5:*;
if (_arg1.GetManifoldCount() > 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].destroyFcn;
_local5(_arg1, _arg2);
}
public static function AddType(_arg1, _arg2, _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;
};
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
var _local4:int;
var _local5:int;
var _local6:*;
var _local7:b2Contact;
var _local8:int;
var _local9:b2Manifold;
if (s_initialized == false){
InitializeRegisters();
s_initialized = true;
};
_local4 = _arg1.m_type;
_local5 = _arg2.m_type;
_local6 = s_registers[_local4][_local5].createFcn;
if (_local6){
if (s_registers[_local4][_local5].primary){
return (_local6(_arg1, _arg2, _arg3));
};
_local7 = _local6(_arg2, _arg1, _arg3);
_local8 = 0;
while (_local8 < _local7.GetManifoldCount()) {
_local9 = _local7.GetManifolds()[_local8];
_local7.GetManifolds()[_local8].normal = _local9.normal.Negative();
_local8++;
};
return (_local7);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 31
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var points:Array;
public var restitution:Number;
public var body1:b2Body;
public var manifold:b2Manifold;
public var normal:b2Vec2;
public var body2:b2Body;
public var friction:Number;
public var pointCount:int;
public function b2ContactConstraint(){
var _local1:int;
normal = new b2Vec2();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
_local1 = 0;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactConstraintPoint();
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 32
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var separation:Number;
public var positionImpulse:Number;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var tangentMass:Number;
public var normalMass:Number;
public var velocityBias:Number;
public function b2ContactConstraintPoint(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 33
//b2ContactNode (Box2D.Dynamics.Contacts.b2ContactNode)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactNode {
public var next:b2ContactNode;
public var other:b2Body;
public var contact:b2Contact;
public var prev:b2ContactNode;
}
}//package Box2D.Dynamics.Contacts
Section 34
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var createFcn;
public var destroyFcn;
}
}//package Box2D.Dynamics.Contacts
Section 35
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2ContactSolver {
public var m_constraintCount:int;
public var m_constraints:Array;
public var m_allocator;
public function b2ContactSolver(_arg1:Array, _arg2:int, _arg3){
var _local4:int;
var _local5:b2Vec2;
var _local6:b2Mat22;
var _local7:int;
var _local8:b2Contact;
var _local9:b2Body;
var _local10:b2Body;
var _local11:int;
var _local12:Array;
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:int;
var _local22:b2Manifold;
var _local23:Number;
var _local24:Number;
var _local25:b2ContactConstraint;
var _local26:uint;
var _local27:b2ContactPoint;
var _local28:b2ContactConstraintPoint;
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;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
m_constraints = new Array();
super();
m_allocator = _arg3;
m_constraintCount = 0;
_local4 = 0;
while (_local4 < _arg2) {
m_constraintCount = (m_constraintCount + _arg1[_local4].GetManifoldCount());
_local4++;
};
_local4 = 0;
while (_local4 < m_constraintCount) {
m_constraints[_local4] = new b2ContactConstraint();
_local4++;
};
_local7 = 0;
_local4 = 0;
while (_local4 < _arg2) {
_local8 = _arg1[_local4];
_local9 = _local8.m_shape1.m_body;
_local10 = _local8.m_shape2.m_body;
_local11 = _local8.GetManifoldCount();
_local12 = _local8.GetManifolds();
_local13 = _local8.m_friction;
_local14 = _local8.m_restitution;
_local15 = _local9.m_linearVelocity.x;
_local16 = _local9.m_linearVelocity.y;
_local17 = _local10.m_linearVelocity.x;
_local18 = _local10.m_linearVelocity.y;
_local19 = _local9.m_angularVelocity;
_local20 = _local10.m_angularVelocity;
_local21 = 0;
while (_local21 < _local11) {
_local22 = _local12[_local21];
_local23 = _local22.normal.x;
_local24 = _local22.normal.y;
_local25 = m_constraints[_local7];
_local25.body1 = _local9;
_local25.body2 = _local10;
_local25.manifold = _local22;
_local25.normal.x = _local23;
_local25.normal.y = _local24;
_local25.pointCount = _local22.pointCount;
_local25.friction = _local13;
_local25.restitution = _local14;
_local26 = 0;
while (_local26 < _local25.pointCount) {
_local27 = _local22.points[_local26];
_local28 = _local25.points[_local26];
_local28.normalImpulse = _local27.normalImpulse;
_local28.tangentImpulse = _local27.tangentImpulse;
_local28.separation = _local27.separation;
_local29 = (_local27.position.x - _local9.m_position.x);
_local30 = (_local27.position.y - _local9.m_position.y);
_local31 = (_local27.position.x - _local10.m_position.x);
_local32 = (_local27.position.y - _local10.m_position.y);
_local5 = _local28.localAnchor1;
_local6 = _local9.m_R;
_local5.x = ((_local29 * _local6.col1.x) + (_local30 * _local6.col1.y));
_local5.y = ((_local29 * _local6.col2.x) + (_local30 * _local6.col2.y));
_local5 = _local28.localAnchor2;
_local6 = _local10.m_R;
_local5.x = ((_local31 * _local6.col1.x) + (_local32 * _local6.col1.y));
_local5.y = ((_local31 * _local6.col2.x) + (_local32 * _local6.col2.y));
_local33 = ((_local29 * _local29) + (_local30 * _local30));
_local34 = ((_local31 * _local31) + (_local32 * _local32));
_local35 = ((_local29 * _local23) + (_local30 * _local24));
_local36 = ((_local31 * _local23) + (_local32 * _local24));
_local37 = (_local9.m_invMass + _local10.m_invMass);
_local37 = (_local37 + ((_local9.m_invI * (_local33 - (_local35 * _local35))) + (_local10.m_invI * (_local34 - (_local36 * _local36)))));
_local28.normalMass = (1 / _local37);
_local38 = _local24;
_local39 = -(_local23);
_local40 = ((_local29 * _local38) + (_local30 * _local39));
_local41 = ((_local31 * _local38) + (_local32 * _local39));
_local42 = (_local9.m_invMass + _local10.m_invMass);
_local42 = (_local42 + ((_local9.m_invI * (_local33 - (_local40 * _local40))) + (_local10.m_invI * (_local34 - (_local41 * _local41)))));
_local28.tangentMass = (1 / _local42);
_local28.velocityBias = 0;
if (_local28.separation > 0){
_local28.velocityBias = (-60 * _local28.separation);
};
_local43 = (((_local17 + (-(_local20) * _local32)) - _local15) - (-(_local19) * _local30));
_local44 = (((_local18 + (_local20 * _local31)) - _local16) - (_local19 * _local29));
_local45 = ((_local25.normal.x * _local43) + (_local25.normal.y * _local44));
if (_local45 < -(b2Settings.b2_velocityThreshold)){
_local28.velocityBias = (_local28.velocityBias + (-(_local25.restitution) * _local45));
};
_local26++;
};
_local7++;
_local21++;
};
_local4++;
};
}
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:Number;
var _local20:Number;
var _local21:int;
var _local22:int;
var _local23:b2ContactConstraintPoint;
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;
_local2 = 0;
_local5 = 0;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_local9 = _local7.m_position;
_local10 = _local7.m_rotation;
_local11 = _local8.m_position;
_local12 = _local8.m_rotation;
_local13 = _local7.m_invMass;
_local14 = _local7.m_invI;
_local15 = _local8.m_invMass;
_local16 = _local8.m_invI;
_local17 = _local6.normal.x;
_local18 = _local6.normal.y;
_local19 = _local18;
_local20 = -(_local17);
_local21 = _local6.pointCount;
_local22 = 0;
while (_local22 < _local21) {
_local23 = _local6.points[_local22];
_local3 = _local7.m_R;
_local4 = _local23.localAnchor1;
_local24 = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local25 = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local3 = _local8.m_R;
_local4 = _local23.localAnchor2;
_local26 = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local27 = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local28 = (_local9.x + _local24);
_local29 = (_local9.y + _local25);
_local30 = (_local11.x + _local26);
_local31 = (_local11.y + _local27);
_local32 = (_local30 - _local28);
_local33 = (_local31 - _local29);
_local34 = (((_local32 * _local17) + (_local33 * _local18)) + _local23.separation);
_local2 = b2Math.b2Min(_local2, _local34);
_local35 = (_arg1 * b2Math.b2Clamp((_local34 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0));
_local36 = (-(_local23.normalMass) * _local35);
_local37 = _local23.positionImpulse;
_local23.positionImpulse = b2Math.b2Max((_local37 + _local36), 0);
_local36 = (_local23.positionImpulse - _local37);
_local38 = (_local36 * _local17);
_local39 = (_local36 * _local18);
_local9.x = (_local9.x - (_local13 * _local38));
_local9.y = (_local9.y - (_local13 * _local39));
_local10 = (_local10 - (_local14 * ((_local24 * _local39) - (_local25 * _local38))));
_local7.m_R.Set(_local10);
_local11.x = (_local11.x + (_local15 * _local38));
_local11.y = (_local11.y + (_local15 * _local39));
_local12 = (_local12 + (_local16 * ((_local26 * _local39) - (_local27 * _local38))));
_local8.m_R.Set(_local12);
_local22++;
};
_local7.m_rotation = _local10;
_local8.m_rotation = _local12;
_local5++;
};
return ((_local2 >= -(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:b2Mat22;
var _local14:b2Vec2;
var _local15:int;
var _local16:b2ContactConstraint;
var _local17:b2Body;
var _local18:b2Body;
var _local19:Number;
var _local20:b2Vec2;
var _local21:Number;
var _local22:b2Vec2;
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:int;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_local15 = 0;
while (_local15 < m_constraintCount) {
_local16 = m_constraints[_local15];
_local17 = _local16.body1;
_local18 = _local16.body2;
_local19 = _local17.m_angularVelocity;
_local20 = _local17.m_linearVelocity;
_local21 = _local18.m_angularVelocity;
_local22 = _local18.m_linearVelocity;
_local23 = _local17.m_invMass;
_local24 = _local17.m_invI;
_local25 = _local18.m_invMass;
_local26 = _local18.m_invI;
_local27 = _local16.normal.x;
_local28 = _local16.normal.y;
_local29 = _local28;
_local30 = -(_local27);
_local31 = _local16.pointCount;
_local1 = 0;
while (_local1 < _local31) {
_local2 = _local16.points[_local1];
_local13 = _local17.m_R;
_local14 = _local2.localAnchor1;
_local3 = ((_local13.col1.x * _local14.x) + (_local13.col2.x * _local14.y));
_local4 = ((_local13.col1.y * _local14.x) + (_local13.col2.y * _local14.y));
_local13 = _local18.m_R;
_local14 = _local2.localAnchor2;
_local5 = ((_local13.col1.x * _local14.x) + (_local13.col2.x * _local14.y));
_local6 = ((_local13.col1.y * _local14.x) + (_local13.col2.y * _local14.y));
_local7 = (((_local22.x + (-(_local21) * _local6)) - _local20.x) - (-(_local19) * _local4));
_local8 = (((_local22.y + (_local21 * _local5)) - _local20.y) - (_local19 * _local3));
_local32 = ((_local7 * _local27) + (_local8 * _local28));
_local9 = (-(_local2.normalMass) * (_local32 - _local2.velocityBias));
_local10 = b2Math.b2Max((_local2.normalImpulse + _local9), 0);
_local9 = (_local10 - _local2.normalImpulse);
_local11 = (_local9 * _local27);
_local12 = (_local9 * _local28);
_local20.x = (_local20.x - (_local23 * _local11));
_local20.y = (_local20.y - (_local23 * _local12));
_local19 = (_local19 - (_local24 * ((_local3 * _local12) - (_local4 * _local11))));
_local22.x = (_local22.x + (_local25 * _local11));
_local22.y = (_local22.y + (_local25 * _local12));
_local21 = (_local21 + (_local26 * ((_local5 * _local12) - (_local6 * _local11))));
_local2.normalImpulse = _local10;
_local7 = (((_local22.x + (-(_local21) * _local6)) - _local20.x) - (-(_local19) * _local4));
_local8 = (((_local22.y + (_local21 * _local5)) - _local20.y) - (_local19 * _local3));
_local33 = ((_local7 * _local29) + (_local8 * _local30));
_local9 = (_local2.tangentMass * -(_local33));
_local34 = (_local16.friction * _local2.normalImpulse);
_local10 = b2Math.b2Clamp((_local2.tangentImpulse + _local9), -(_local34), _local34);
_local9 = (_local10 - _local2.tangentImpulse);
_local11 = (_local9 * _local29);
_local12 = (_local9 * _local30);
_local20.x = (_local20.x - (_local23 * _local11));
_local20.y = (_local20.y - (_local23 * _local12));
_local19 = (_local19 - (_local24 * ((_local3 * _local12) - (_local4 * _local11))));
_local22.x = (_local22.x + (_local25 * _local11));
_local22.y = (_local22.y + (_local25 * _local12));
_local21 = (_local21 + (_local26 * ((_local5 * _local12) - (_local6 * _local11))));
_local2.tangentImpulse = _local10;
_local1++;
};
_local17.m_angularVelocity = _local19;
_local18.m_angularVelocity = _local21;
_local15++;
};
}
public function PreSolve():void{
var _local1:b2Vec2;
var _local2:b2Vec2;
var _local3:b2Mat22;
var _local4:int;
var _local5:b2ContactConstraint;
var _local6:b2Body;
var _local7:b2Body;
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:int;
var _local17:int;
var _local18:b2ContactConstraintPoint;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:b2ContactConstraintPoint;
_local4 = 0;
while (_local4 < m_constraintCount) {
_local5 = m_constraints[_local4];
_local6 = _local5.body1;
_local7 = _local5.body2;
_local8 = _local6.m_invMass;
_local9 = _local6.m_invI;
_local10 = _local7.m_invMass;
_local11 = _local7.m_invI;
_local12 = _local5.normal.x;
_local13 = _local5.normal.y;
_local14 = _local13;
_local15 = -(_local12);
if (b2World.s_enableWarmStarting){
_local17 = _local5.pointCount;
_local16 = 0;
while (_local16 < _local17) {
_local18 = _local5.points[_local16];
_local19 = ((_local18.normalImpulse * _local12) + (_local18.tangentImpulse * _local14));
_local20 = ((_local18.normalImpulse * _local13) + (_local18.tangentImpulse * _local15));
_local3 = _local6.m_R;
_local1 = _local18.localAnchor1;
_local21 = ((_local3.col1.x * _local1.x) + (_local3.col2.x * _local1.y));
_local22 = ((_local3.col1.y * _local1.x) + (_local3.col2.y * _local1.y));
_local3 = _local7.m_R;
_local1 = _local18.localAnchor2;
_local23 = ((_local3.col1.x * _local1.x) + (_local3.col2.x * _local1.y));
_local24 = ((_local3.col1.y * _local1.x) + (_local3.col2.y * _local1.y));
_local6.m_angularVelocity = (_local6.m_angularVelocity - (_local9 * ((_local21 * _local20) - (_local22 * _local19))));
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x - (_local8 * _local19));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y - (_local8 * _local20));
_local7.m_angularVelocity = (_local7.m_angularVelocity + (_local11 * ((_local23 * _local20) - (_local24 * _local19))));
_local7.m_linearVelocity.x = (_local7.m_linearVelocity.x + (_local10 * _local19));
_local7.m_linearVelocity.y = (_local7.m_linearVelocity.y + (_local10 * _local20));
_local18.positionImpulse = 0;
_local16++;
};
} else {
_local17 = _local5.pointCount;
_local16 = 0;
while (_local16 < _local17) {
_local25 = _local5.points[_local16];
_local25.normalImpulse = 0;
_local25.tangentImpulse = 0;
_local25.positionImpulse = 0;
_local16++;
};
};
_local4++;
};
}
public function PostSolve():void{
var _local1:int;
var _local2:b2ContactConstraint;
var _local3:b2Manifold;
var _local4:int;
var _local5:b2ContactPoint;
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 36
//b2NullContact (Box2D.Dynamics.Contacts.b2NullContact)
package Box2D.Dynamics.Contacts {
public class b2NullContact extends b2Contact {
public function b2NullContact():void{
}
override public function GetManifolds():Array{
return (null);
}
override public function Evaluate():void{
}
}
}//package Box2D.Dynamics.Contacts
Section 37
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
public var m_manifold:Array;
public function b2PolyAndCircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifold = [new b2Manifold()];
super(_arg1, _arg2);
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polyShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_circleShape));
m_manifold[0].pointCount = 0;
m_manifold[0].points[0].normalImpulse = 0;
m_manifold[0].points[0].tangentImpulse = 0;
}
override public function GetManifolds():Array{
return (m_manifold);
}
override public function Evaluate():void{
b2Collision.b2CollidePolyAndCircle(m_manifold[0], (m_shape1 as b2PolyShape), (m_shape2 as b2CircleShape), false);
if (m_manifold[0].pointCount > 0){
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
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 38
//b2PolyContact (Box2D.Dynamics.Contacts.b2PolyContact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyContact extends b2Contact {
public var m_manifold:Array;
private var m0:b2Manifold;
public function b2PolyContact(_arg1:b2Shape, _arg2:b2Shape):void{
m0 = new b2Manifold();
m_manifold = [new b2Manifold()];
super(_arg1, _arg2);
m_manifold[0].pointCount = 0;
}
override public function GetManifolds():Array{
return (m_manifold);
}
override public function Evaluate():void{
var _local1:b2Manifold;
var _local2:Array;
var _local3:int;
var _local4:b2ContactPoint;
var _local5:b2ContactPoint;
var _local6:Array;
var _local7:int;
var _local8:b2ContactPoint;
var _local9:uint;
var _local10:int;
var _local11:b2ContactPoint;
var _local12:b2ContactID;
_local1 = m_manifold[0];
_local2 = m0.points;
_local3 = 0;
while (_local3 < _local1.pointCount) {
_local4 = _local2[_local3];
_local5 = _local1.points[_local3];
_local4.normalImpulse = _local5.normalImpulse;
_local4.tangentImpulse = _local5.tangentImpulse;
_local4.id = _local5.id.Copy();
_local3++;
};
m0.pointCount = _local1.pointCount;
b2Collision.b2CollidePoly(_local1, (m_shape1 as b2PolyShape), (m_shape2 as b2PolyShape), false);
if (_local1.pointCount > 0){
_local6 = [false, false];
_local7 = 0;
while (_local7 < _local1.pointCount) {
_local8 = _local1.points[_local7];
_local8.normalImpulse = 0;
_local8.tangentImpulse = 0;
_local9 = _local8.id.key;
_local10 = 0;
while (_local10 < m0.pointCount) {
if (_local6[_local10] == true){
} else {
_local11 = m0.points[_local10];
_local12 = _local11.id;
if (_local12.key == _local9){
_local6[_local10] = true;
_local8.normalImpulse = _local11.normalImpulse;
_local8.tangentImpulse = _local11.tangentImpulse;
break;
};
};
_local10++;
};
_local7++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolyContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 39
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
public var m_localAnchor2:b2Vec2;
public var m_mass:Number;
public var m_localAnchor1:b2Vec2;
public var m_u:b2Vec2;
public var m_impulse:Number;
public 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);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint1.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint1.y - m_body1.m_position.y);
m_localAnchor1.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor1.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint2.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint2.y - m_body2.m_position.y);
m_localAnchor2.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor2.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local3 = (_arg1.anchorPoint2.x - _arg1.anchorPoint1.x);
_local4 = (_arg1.anchorPoint2.y - _arg1.anchorPoint1.y);
m_length = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
m_impulse = 0;
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
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;
_local2 = m_body1.m_R;
_local3 = ((_local2.col1.x * m_localAnchor1.x) + (_local2.col2.x * m_localAnchor1.y));
_local4 = ((_local2.col1.y * m_localAnchor1.x) + (_local2.col2.y * m_localAnchor1.y));
_local2 = m_body2.m_R;
_local5 = ((_local2.col1.x * m_localAnchor2.x) + (_local2.col2.x * m_localAnchor2.y));
_local6 = ((_local2.col1.y * m_localAnchor2.x) + (_local2.col2.y * m_localAnchor2.y));
_local7 = (m_body1.m_linearVelocity.x + (-(m_body1.m_angularVelocity) * _local4));
_local8 = (m_body1.m_linearVelocity.y + (m_body1.m_angularVelocity * _local3));
_local9 = (m_body2.m_linearVelocity.x + (-(m_body2.m_angularVelocity) * _local6));
_local10 = (m_body2.m_linearVelocity.y + (m_body2.m_angularVelocity * _local5));
_local11 = ((m_u.x * (_local9 - _local7)) + (m_u.y * (_local10 - _local8)));
_local12 = (-(m_mass) * _local11);
m_impulse = (m_impulse + _local12);
_local13 = (_local12 * m_u.x);
_local14 = (_local12 * m_u.y);
m_body1.m_linearVelocity.x = (m_body1.m_linearVelocity.x - (m_body1.m_invMass * _local13));
m_body1.m_linearVelocity.y = (m_body1.m_linearVelocity.y - (m_body1.m_invMass * _local14));
m_body1.m_angularVelocity = (m_body1.m_angularVelocity - (m_body1.m_invI * ((_local3 * _local14) - (_local4 * _local13))));
m_body2.m_linearVelocity.x = (m_body2.m_linearVelocity.x + (m_body2.m_invMass * _local13));
m_body2.m_linearVelocity.y = (m_body2.m_linearVelocity.y + (m_body2.m_invMass * _local14));
m_body2.m_angularVelocity = (m_body2.m_angularVelocity + (m_body2.m_invI * ((_local5 * _local14) - (_local6 * _local13))));
}
override public function GetAnchor1():b2Vec2{
return (b2Math.AddVV(m_body1.m_position, b2Math.b2MulMV(m_body1.m_R, m_localAnchor1)));
}
override public function GetAnchor2():b2Vec2{
return (b2Math.AddVV(m_body2.m_position, b2Math.b2MulMV(m_body2.m_R, m_localAnchor2)));
}
override public function PrepareVelocitySolver():void{
var _local1:b2Mat22;
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;
_local1 = m_body1.m_R;
_local2 = ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y));
_local3 = ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y));
_local1 = m_body2.m_R;
_local4 = ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y));
_local5 = ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y));
m_u.x = (((m_body2.m_position.x + _local4) - m_body1.m_position.x) - _local2);
m_u.y = (((m_body2.m_position.y + _local5) - m_body1.m_position.y) - _local3);
_local6 = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (_local6 > b2Settings.b2_linearSlop){
m_u.Multiply((1 / _local6));
} else {
m_u.SetZero();
};
_local7 = ((_local2 * m_u.y) - (_local3 * m_u.x));
_local8 = ((_local4 * m_u.y) - (_local5 * m_u.x));
m_mass = (((m_body1.m_invMass + ((m_body1.m_invI * _local7) * _local7)) + m_body2.m_invMass) + ((m_body2.m_invI * _local8) * _local8));
m_mass = (1 / m_mass);
if (b2World.s_enableWarmStarting){
_local9 = (m_impulse * m_u.x);
_local10 = (m_impulse * m_u.y);
m_body1.m_linearVelocity.x = (m_body1.m_linearVelocity.x - (m_body1.m_invMass * _local9));
m_body1.m_linearVelocity.y = (m_body1.m_linearVelocity.y - (m_body1.m_invMass * _local10));
m_body1.m_angularVelocity = (m_body1.m_angularVelocity - (m_body1.m_invI * ((_local2 * _local10) - (_local3 * _local9))));
m_body2.m_linearVelocity.x = (m_body2.m_linearVelocity.x + (m_body2.m_invMass * _local9));
m_body2.m_linearVelocity.y = (m_body2.m_linearVelocity.y + (m_body2.m_invMass * _local10));
m_body2.m_angularVelocity = (m_body2.m_angularVelocity + (m_body2.m_invI * ((_local4 * _local10) - (_local5 * _local9))));
} else {
m_impulse = 0;
};
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:b2Vec2;
_local2 = new b2Vec2();
_local2.SetV(m_u);
_local2.Multiply((m_impulse * _arg1));
return (_local2);
}
override public function SolvePositionConstraints():Boolean{
var _local1:b2Mat22;
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:Number;
_local1 = m_body1.m_R;
_local2 = ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y));
_local3 = ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y));
_local1 = m_body2.m_R;
_local4 = ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y));
_local5 = ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y));
_local6 = (((m_body2.m_position.x + _local4) - m_body1.m_position.x) - _local2);
_local7 = (((m_body2.m_position.y + _local5) - m_body1.m_position.y) - _local3);
_local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
_local6 = (_local6 / _local8);
_local7 = (_local7 / _local8);
_local9 = (_local8 - m_length);
_local9 = b2Math.b2Clamp(_local9, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local10 = (-(m_mass) * _local9);
m_u.Set(_local6, _local7);
_local11 = (_local10 * m_u.x);
_local12 = (_local10 * m_u.y);
m_body1.m_position.x = (m_body1.m_position.x - (m_body1.m_invMass * _local11));
m_body1.m_position.y = (m_body1.m_position.y - (m_body1.m_invMass * _local12));
m_body1.m_rotation = (m_body1.m_rotation - (m_body1.m_invI * ((_local2 * _local12) - (_local3 * _local11))));
m_body2.m_position.x = (m_body2.m_position.x + (m_body2.m_invMass * _local11));
m_body2.m_position.y = (m_body2.m_position.y + (m_body2.m_invMass * _local12));
m_body2.m_rotation = (m_body2.m_rotation + (m_body2.m_invI * ((_local4 * _local12) - (_local5 * _local11))));
m_body1.m_R.Set(m_body1.m_rotation);
m_body2.m_R.Set(m_body2.m_rotation);
return ((b2Math.b2Abs(_local9) < b2Settings.b2_linearSlop));
}
}
}//package Box2D.Dynamics.Joints
Section 40
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2DistanceJointDef extends b2JointDef {
public var anchorPoint2:b2Vec2;
public var anchorPoint1:b2Vec2;
public function b2DistanceJointDef(){
anchorPoint1 = new b2Vec2();
anchorPoint2 = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
}
}
}//package Box2D.Dynamics.Joints
Section 41
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
public var m_impulse:Number;
public var m_mass:Number;
public var m_prismatic1:b2PrismaticJoint;
public var m_prismatic2:b2PrismaticJoint;
public var m_ground1:b2Body;
public var m_ground2:b2Body;
public var m_constant:Number;
public var m_revolute1:b2RevoluteJoint;
public var m_revolute2:b2RevoluteJoint;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_ratio:Number;
public var m_J:b2Jacobian;
public function b2GearJoint(_arg1:b2GearJointDef){
var _local2:Number;
var _local3:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(_arg1);
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 (_arg1.joint1.m_type == b2Joint.e_revoluteJoint){
m_revolute1 = (_arg1.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
_local2 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (_arg1.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
_local2 = m_prismatic1.GetJointTranslation();
};
m_ground2 = _arg1.joint2.m_body1;
m_body2 = _arg1.joint2.m_body2;
if (_arg1.joint2.m_type == b2Joint.e_revoluteJoint){
m_revolute2 = (_arg1.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
_local3 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (_arg1.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
_local3 = m_prismatic2.GetJointTranslation();
};
m_ratio = _arg1.ratio;
m_constant = (_local2 + (m_ratio * _local3));
m_impulse = 0;
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver():void{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Body;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:b2Mat22;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
_local1 = m_ground1;
_local2 = m_ground2;
_local3 = m_body1;
_local4 = m_body2;
_local12 = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angular1 = -1;
_local12 = (_local12 + _local3.m_invI);
} else {
_local9 = _local1.m_R;
_local10 = m_prismatic1.m_localXAxis1;
_local5 = ((_local9.col1.x * _local10.x) + (_local9.col2.x * _local10.y));
_local6 = ((_local9.col1.y * _local10.x) + (_local9.col2.y * _local10.y));
_local9 = _local3.m_R;
_local7 = ((_local9.col1.x * m_localAnchor1.x) + (_local9.col2.x * m_localAnchor1.y));
_local8 = ((_local9.col1.y * m_localAnchor1.x) + (_local9.col2.y * m_localAnchor1.y));
_local11 = ((_local7 * _local6) - (_local8 * _local5));
m_J.linear1.Set(-(_local5), -(_local6));
m_J.angular1 = -(_local11);
_local12 = (_local12 + (_local3.m_invMass + ((_local3.m_invI * _local11) * _local11)));
};
if (m_revolute2){
m_J.angular2 = -(m_ratio);
_local12 = (_local12 + ((m_ratio * m_ratio) * _local4.m_invI));
} else {
_local9 = _local2.m_R;
_local10 = m_prismatic2.m_localXAxis1;
_local5 = ((_local9.col1.x * _local10.x) + (_local9.col2.x * _local10.y));
_local6 = ((_local9.col1.y * _local10.x) + (_local9.col2.y * _local10.y));
_local9 = _local4.m_R;
_local7 = ((_local9.col1.x * m_localAnchor2.x) + (_local9.col2.x * m_localAnchor2.y));
_local8 = ((_local9.col1.y * m_localAnchor2.x) + (_local9.col2.y * m_localAnchor2.y));
_local11 = ((_local7 * _local6) - (_local8 * _local5));
m_J.linear2.Set((-(m_ratio) * _local5), (-(m_ratio) * _local6));
m_J.angular2 = (-(m_ratio) * _local11);
_local12 = (_local12 + ((m_ratio * m_ratio) * (_local4.m_invMass + ((_local4.m_invI * _local11) * _local11))));
};
m_mass = (1 / _local12);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * m_impulse) * m_J.linear1.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * m_impulse) * m_J.linear1.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * m_impulse) * m_J.angular1));
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * m_impulse) * m_J.linear2.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * m_impulse) * m_J.linear2.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * m_impulse) * m_J.angular2));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2());
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:b2Body;
var _local3:b2Body;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local1 = 0;
_local2 = m_body1;
_local3 = m_body2;
if (m_revolute1){
_local4 = m_revolute1.GetJointAngle();
} else {
_local4 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
_local5 = m_revolute2.GetJointAngle();
} else {
_local5 = m_prismatic2.GetJointTranslation();
};
_local6 = (m_constant - (_local4 + (m_ratio * _local5)));
_local7 = (-(m_mass) * _local6);
_local2.m_position.x = (_local2.m_position.x + ((_local2.m_invMass * _local7) * m_J.linear1.x));
_local2.m_position.y = (_local2.m_position.y + ((_local2.m_invMass * _local7) * m_J.linear1.y));
_local2.m_rotation = (_local2.m_rotation + ((_local2.m_invI * _local7) * m_J.angular1));
_local3.m_position.x = (_local3.m_position.x + ((_local3.m_invMass * _local7) * m_J.linear2.x));
_local3.m_position.y = (_local3.m_position.y + ((_local3.m_invMass * _local7) * m_J.linear2.y));
_local3.m_rotation = (_local3.m_rotation + ((_local3.m_invI * _local7) * m_J.angular2));
_local2.m_R.Set(_local2.m_rotation);
_local3.m_R.Set(_local3.m_rotation);
return ((_local1 < b2Settings.b2_linearSlop));
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
override public 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 42
//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 43
//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 44
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2Joint {
public var m_islandFlag:Boolean;
public var m_collideConnected:Boolean;
public var m_prev:b2Joint;
public var m_next:b2Joint;
public var m_type:int;
public var m_node1:b2JointNode;
public var m_node2:b2JointNode;
public var m_userData;
public var m_body1:b2Body;
public var m_body2:b2Body;
public static const e_unknownJoint:int = 0;
public static const e_inactiveLimit:int = 0;
public static const e_atUpperLimit:int = 2;
public static const e_atLowerLimit:int = 1;
public static const e_gearJoint:int = 6;
public static const e_revoluteJoint:int = 1;
public static const e_equalLimits:int = 3;
public static const e_distanceJoint:int = 3;
public static const e_pulleyJoint:int = 4;
public static const e_prismaticJoint:int = 2;
public static const e_mouseJoint:int = 5;
public function b2Joint(_arg1:b2JointDef){
m_node1 = new b2JointNode();
m_node2 = new b2JointNode();
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;
}
public function GetAnchor1():b2Vec2{
return (null);
}
public function GetAnchor2():b2Vec2{
return (null);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function GetBody2():b2Body{
return (m_body2);
}
public function PrepareVelocitySolver():void{
}
public function PreparePositionSolver():void{
}
public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce(_arg1:Number):b2Vec2{
return (null);
}
public function SolvePositionConstraints():Boolean{
return (false);
}
public function GetBody1():b2Body{
return (m_body1);
}
public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
}
public static function Destroy(_arg1:b2Joint, _arg2):void{
}
public 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;
default:
break;
};
return (_local3);
}
}
}//package Box2D.Dynamics.Joints
Section 45
//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 46
//b2JointNode (Box2D.Dynamics.Joints.b2JointNode)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointNode {
public var joint:b2Joint;
public var other:b2Body;
public var next:b2JointNode;
public var prev:b2JointNode;
}
}//package Box2D.Dynamics.Joints
Section 47
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2MouseJoint extends b2Joint {
public var m_beta:Number;
public var m_target:b2Vec2;
public var m_impulse:b2Vec2;
public var m_ptpMass:b2Mat22;
public var m_localAnchor:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K:b2Mat22;
public var m_gamma:Number;
public var m_C:b2Vec2;
public var m_maxForce:Number;
public function b2MouseJoint(_arg1:b2MouseJointDef){
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_ptpMass = new b2Mat22();
m_C = new b2Vec2();
super(_arg1);
m_target.SetV(_arg1.target);
_local2 = (m_target.x - m_body2.m_position.x);
_local3 = (m_target.y - m_body2.m_position.y);
m_localAnchor.x = ((_local2 * m_body2.m_R.col1.x) + (_local3 * m_body2.m_R.col1.y));
m_localAnchor.y = ((_local2 * m_body2.m_R.col2.x) + (_local3 * m_body2.m_R.col2.y));
m_maxForce = _arg1.maxForce;
m_impulse.SetZero();
_local4 = m_body2.m_mass;
_local5 = ((2 * b2Settings.b2_pi) * _arg1.frequencyHz);
_local6 = (((2 * _local4) * _arg1.dampingRatio) * _local5);
_local7 = ((_local4 * _local5) * _local5);
m_gamma = (1 / (_local6 + (_arg1.timeStep * _local7)));
m_beta = ((_arg1.timeStep * _local7) / (_local6 + (_arg1.timeStep * _local7)));
}
override public function GetAnchor1():b2Vec2{
return (m_target);
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Vec2;
_local1 = b2Math.b2MulMV(m_body2.m_R, m_localAnchor);
_local1.Add(m_body2.m_position);
return (_local1);
}
override public function PrepareVelocitySolver():void{
var _local1:b2Body;
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = m_body2;
_local2 = _local1.m_R;
_local3 = ((_local2.col1.x * m_localAnchor.x) + (_local2.col2.x * m_localAnchor.y));
_local4 = ((_local2.col1.y * m_localAnchor.x) + (_local2.col2.y * m_localAnchor.y));
_local5 = _local1.m_invMass;
_local6 = _local1.m_invI;
K1.col1.x = _local5;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = _local5;
K2.col1.x = ((_local6 * _local4) * _local4);
K2.col2.x = ((-(_local6) * _local3) * _local4);
K2.col1.y = ((-(_local6) * _local3) * _local4);
K2.col2.y = ((_local6 * _local3) * _local3);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.Invert(m_ptpMass);
m_C.x = ((_local1.m_position.x + _local3) - m_target.x);
m_C.y = ((_local1.m_position.y + _local4) - m_target.y);
_local1.m_angularVelocity = (_local1.m_angularVelocity * 0.98);
_local7 = m_impulse.x;
_local8 = m_impulse.y;
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x + (_local5 * _local7));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y + (_local5 * _local8));
_local1.m_angularVelocity = (_local1.m_angularVelocity + (_local6 * ((_local3 * _local8) - (_local4 * _local7))));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:b2Vec2;
_local2 = new b2Vec2();
_local2.SetV(m_impulse);
_local2.Multiply(_arg1);
return (_local2);
}
override public function SolvePositionConstraints():Boolean{
return (true);
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function SetTarget(_arg1:b2Vec2):void{
m_body2.WakeUp();
m_target = _arg1;
}
override public 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_R;
_local4 = ((_local3.col1.x * m_localAnchor.x) + (_local3.col2.x * m_localAnchor.y));
_local5 = ((_local3.col1.y * m_localAnchor.x) + (_local3.col2.y * m_localAnchor.y));
_local6 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local5));
_local7 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local4));
_local3 = m_ptpMass;
_local8 = ((_local6 + ((m_beta * _arg1.inv_dt) * m_C.x)) + (m_gamma * m_impulse.x));
_local9 = ((_local7 + ((m_beta * _arg1.inv_dt) * m_C.y)) + (m_gamma * m_impulse.y));
_local10 = -(((_local3.col1.x * _local8) + (_local3.col2.x * _local9)));
_local11 = -(((_local3.col1.y * _local8) + (_local3.col2.y * _local9)));
_local12 = m_impulse.x;
_local13 = m_impulse.y;
m_impulse.x = (m_impulse.x + _local10);
m_impulse.y = (m_impulse.y + _local11);
_local14 = m_impulse.Length();
if (_local14 > (_arg1.dt * m_maxForce)){
m_impulse.Multiply(((_arg1.dt * m_maxForce) / _local14));
};
_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 * ((_local4 * _local11) - (_local5 * _local10))));
}
}
}//package Box2D.Dynamics.Joints
Section 48
//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 var timeStep:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
timeStep = (1 / 60);
}
}
}//package Box2D.Dynamics.Joints
Section 49
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
public var m_initialAngle:Number;
public var m_lowerTranslation:Number;
public var m_localXAxis1:b2Vec2;
public var m_enableLimit:Boolean;
public var m_maxMotorForce:Number;
public var m_angularMass:Number;
public var m_localYAxis1:b2Vec2;
public var m_linearImpulse:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_motorMass:Number;
public var m_limitState:int;
public var m_linearMass:Number;
public var m_upperTranslation:Number;
public var m_angularImpulse:Number;
public var m_motorImpulse:Number;
public var m_motorJacobian:b2Jacobian;
public var m_limitImpulse:Number;
public var m_motorSpeed:Number;
public var m_enableMotor:Boolean;
public var m_limitPositionImpulse:Number;
public var m_linearJacobian:b2Jacobian;
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_linearJacobian = new b2Jacobian();
m_motorJacobian = new b2Jacobian();
super(_arg1);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body1.m_position.y);
m_localAnchor1.Set(((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y)), ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y)));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body2.m_position.y);
m_localAnchor2.Set(((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y)), ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y)));
_local2 = m_body1.m_R;
_local3 = _arg1.axis.x;
_local4 = _arg1.axis.y;
m_localXAxis1.Set(((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y)), ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y)));
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_initialAngle = (m_body2.m_rotation - m_body1.m_rotation);
m_linearJacobian.SetZero();
m_linearMass = 0;
m_linearImpulse = 0;
m_angularMass = 0;
m_angularImpulse = 0;
m_motorJacobian.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_limitImpulse = 0;
m_limitPositionImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.motorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Body;
var _local2:b2Vec2;
_local1 = m_body1;
_local2 = new b2Vec2();
_local2.SetV(m_localAnchor1);
_local2.MulM(_local1.m_R);
_local2.Add(_local1.m_position);
return (_local2);
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Body;
var _local2:b2Vec2;
_local1 = m_body2;
_local2 = new b2Vec2();
_local2.SetV(m_localAnchor2);
_local2.MulM(_local1.m_R);
_local2.Add(_local1.m_position);
return (_local2);
}
override public function PrepareVelocitySolver():void{
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: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;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = _local1.m_invMass;
_local9 = _local2.m_invMass;
_local10 = _local1.m_invI;
_local11 = _local2.m_invI;
_local3 = _local1.m_R;
_local12 = ((_local3.col1.x * m_localYAxis1.x) + (_local3.col2.x * m_localYAxis1.y));
_local13 = ((_local3.col1.y * m_localYAxis1.x) + (_local3.col2.y * m_localYAxis1.y));
_local14 = ((_local2.m_position.x + _local6) - _local1.m_position.x);
_local15 = ((_local2.m_position.y + _local7) - _local1.m_position.y);
m_linearJacobian.linear1.x = -(_local12);
m_linearJacobian.linear1.y = -(_local13);
m_linearJacobian.linear2.x = _local12;
m_linearJacobian.linear2.y = _local13;
m_linearJacobian.angular1 = -(((_local14 * _local13) - (_local15 * _local12)));
m_linearJacobian.angular2 = ((_local6 * _local13) - (_local7 * _local12));
m_linearMass = (((_local8 + ((_local10 * m_linearJacobian.angular1) * m_linearJacobian.angular1)) + _local9) + ((_local11 * m_linearJacobian.angular2) * m_linearJacobian.angular2));
m_linearMass = (1 / m_linearMass);
m_angularMass = (1 / (_local10 + _local11));
if (((m_enableLimit) || (m_enableMotor))){
_local3 = _local1.m_R;
_local16 = ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y));
_local17 = ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y));
m_motorJacobian.linear1.x = -(_local16);
m_motorJacobian.linear1.y = -(_local17);
m_motorJacobian.linear2.x = _local16;
m_motorJacobian.linear2.y = _local17;
m_motorJacobian.angular1 = -(((_local14 * _local17) - (_local15 * _local16)));
m_motorJacobian.angular2 = ((_local6 * _local17) - (_local7 * _local16));
m_motorMass = (((_local8 + ((_local10 * m_motorJacobian.angular1) * m_motorJacobian.angular1)) + _local9) + ((_local11 * m_motorJacobian.angular2) * m_motorJacobian.angular2));
m_motorMass = (1 / m_motorMass);
if (m_enableLimit){
_local18 = (_local14 - _local4);
_local19 = (_local15 - _local5);
_local20 = ((_local16 * _local18) + (_local17 * _local19));
if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local20 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitImpulse = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local20 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitImpulse = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitImpulse = 0;
};
};
};
};
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit == false){
m_limitImpulse = 0;
};
if (b2World.s_enableWarmStarting){
_local21 = ((m_linearImpulse * m_linearJacobian.linear1.x) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear1.x));
_local22 = ((m_linearImpulse * m_linearJacobian.linear1.y) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear1.y));
_local23 = ((m_linearImpulse * m_linearJacobian.linear2.x) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear2.x));
_local24 = ((m_linearImpulse * m_linearJacobian.linear2.y) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear2.y));
_local25 = (((m_linearImpulse * m_linearJacobian.angular1) - m_angularImpulse) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.angular1));
_local26 = (((m_linearImpulse * m_linearJacobian.angular2) + m_angularImpulse) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.angular2));
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x + (_local8 * _local21));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y + (_local8 * _local22));
_local1.m_angularVelocity = (_local1.m_angularVelocity + (_local10 * _local25));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local9 * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local9 * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local11 * _local26));
} else {
m_linearImpulse = 0;
m_angularImpulse = 0;
m_limitImpulse = 0;
m_motorImpulse = 0;
};
m_limitPositionImpulse = 0;
}
public function GetJointTranslation():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:Number;
var _local16:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = (_local1.m_position.x + _local4);
_local9 = (_local1.m_position.y + _local5);
_local10 = (_local2.m_position.x + _local6);
_local11 = (_local2.m_position.y + _local7);
_local12 = (_local10 - _local8);
_local13 = (_local11 - _local9);
_local3 = _local1.m_R;
_local14 = ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y));
_local15 = ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y));
_local16 = ((_local14 * _local12) + (_local15 * _local13));
return (_local16);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:Number;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local2 = (_arg1 * m_limitImpulse);
_local3 = m_body1.m_R;
_local4 = (_local2 * ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y)));
_local5 = (_local2 * ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y)));
_local6 = (_local2 * ((_local3.col1.x * m_localYAxis1.x) + (_local3.col2.x * m_localYAxis1.y)));
_local7 = (_local2 * ((_local3.col1.y * m_localYAxis1.x) + (_local3.col2.y * m_localYAxis1.y)));
return (new b2Vec2((_local4 + _local6), (_local5 + _local7)));
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:b2Body;
var _local4:b2Body;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:b2Mat22;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _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;
_local3 = m_body1;
_local4 = m_body2;
_local5 = _local3.m_invMass;
_local6 = _local4.m_invMass;
_local7 = _local3.m_invI;
_local8 = _local4.m_invI;
_local9 = _local3.m_R;
_local10 = ((_local9.col1.x * m_localAnchor1.x) + (_local9.col2.x * m_localAnchor1.y));
_local11 = ((_local9.col1.y * m_localAnchor1.x) + (_local9.col2.y * m_localAnchor1.y));
_local9 = _local4.m_R;
_local12 = ((_local9.col1.x * m_localAnchor2.x) + (_local9.col2.x * m_localAnchor2.y));
_local13 = ((_local9.col1.y * m_localAnchor2.x) + (_local9.col2.y * m_localAnchor2.y));
_local14 = (_local3.m_position.x + _local10);
_local15 = (_local3.m_position.y + _local11);
_local16 = (_local4.m_position.x + _local12);
_local17 = (_local4.m_position.y + _local13);
_local18 = (_local16 - _local14);
_local19 = (_local17 - _local15);
_local9 = _local3.m_R;
_local20 = ((_local9.col1.x * m_localYAxis1.x) + (_local9.col2.x * m_localYAxis1.y));
_local21 = ((_local9.col1.y * m_localYAxis1.x) + (_local9.col2.y * m_localYAxis1.y));
_local22 = ((_local20 * _local18) + (_local21 * _local19));
_local22 = b2Math.b2Clamp(_local22, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local23 = (-(m_linearMass) * _local22);
_local3.m_position.x = (_local3.m_position.x + ((_local5 * _local23) * m_linearJacobian.linear1.x));
_local3.m_position.y = (_local3.m_position.y + ((_local5 * _local23) * m_linearJacobian.linear1.y));
_local3.m_rotation = (_local3.m_rotation + ((_local7 * _local23) * m_linearJacobian.angular1));
_local4.m_position.x = (_local4.m_position.x + ((_local6 * _local23) * m_linearJacobian.linear2.x));
_local4.m_position.y = (_local4.m_position.y + ((_local6 * _local23) * m_linearJacobian.linear2.y));
_local4.m_rotation = (_local4.m_rotation + ((_local8 * _local23) * m_linearJacobian.angular2));
_local24 = b2Math.b2Abs(_local22);
_local25 = ((_local4.m_rotation - _local3.m_rotation) - m_initialAngle);
_local25 = b2Math.b2Clamp(_local25, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_angularMass) * _local25);
_local3.m_rotation = (_local3.m_rotation - (_local3.m_invI * _local26));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_rotation = (_local4.m_rotation + (_local4.m_invI * _local26));
_local4.m_R.Set(_local4.m_rotation);
_local27 = b2Math.b2Abs(_local25);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local9 = _local3.m_R;
_local10 = ((_local9.col1.x * m_localAnchor1.x) + (_local9.col2.x * m_localAnchor1.y));
_local11 = ((_local9.col1.y * m_localAnchor1.x) + (_local9.col2.y * m_localAnchor1.y));
_local9 = _local4.m_R;
_local12 = ((_local9.col1.x * m_localAnchor2.x) + (_local9.col2.x * m_localAnchor2.y));
_local13 = ((_local9.col1.y * m_localAnchor2.x) + (_local9.col2.y * m_localAnchor2.y));
_local14 = (_local3.m_position.x + _local10);
_local15 = (_local3.m_position.y + _local11);
_local16 = (_local4.m_position.x + _local12);
_local17 = (_local4.m_position.y + _local13);
_local18 = (_local16 - _local14);
_local19 = (_local17 - _local15);
_local9 = _local3.m_R;
_local28 = ((_local9.col1.x * m_localXAxis1.x) + (_local9.col2.x * m_localXAxis1.y));
_local29 = ((_local9.col1.y * m_localXAxis1.x) + (_local9.col2.y * m_localXAxis1.y));
_local30 = ((_local28 * _local18) + (_local29 * _local19));
_local31 = 0;
if (m_limitState == e_equalLimits){
_local1 = b2Math.b2Clamp(_local30, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local31 = (-(m_motorMass) * _local1);
_local24 = b2Math.b2Max(_local24, b2Math.b2Abs(_local25));
} else {
if (m_limitState == e_atLowerLimit){
_local1 = (_local30 - m_lowerTranslation);
_local24 = b2Math.b2Max(_local24, -(_local1));
_local1 = b2Math.b2Clamp((_local1 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local31 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local31), 0);
_local31 = (m_limitPositionImpulse - _local2);
} else {
if (m_limitState == e_atUpperLimit){
_local1 = (_local30 - m_upperTranslation);
_local24 = b2Math.b2Max(_local24, _local1);
_local1 = b2Math.b2Clamp((_local1 - b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local31 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local31), 0);
_local31 = (m_limitPositionImpulse - _local2);
};
};
};
_local3.m_position.x = (_local3.m_position.x + ((_local5 * _local31) * m_motorJacobian.linear1.x));
_local3.m_position.y = (_local3.m_position.y + ((_local5 * _local31) * m_motorJacobian.linear1.y));
_local3.m_rotation = (_local3.m_rotation + ((_local7 * _local31) * m_motorJacobian.angular1));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_position.x = (_local4.m_position.x + ((_local6 * _local31) * m_motorJacobian.linear2.x));
_local4.m_position.y = (_local4.m_position.y + ((_local6 * _local31) * m_motorJacobian.linear2.y));
_local4.m_rotation = (_local4.m_rotation + ((_local8 * _local31) * m_motorJacobian.angular2));
_local4.m_R.Set(_local4.m_rotation);
};
return ((((_local24 <= b2Settings.b2_linearSlop)) && ((_local27 <= 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:Number;
var _local16:b2Vec2;
var _local17:b2Vec2;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = (_local1.m_position.x + _local4);
_local9 = (_local1.m_position.y + _local5);
_local10 = (_local2.m_position.x + _local6);
_local11 = (_local2.m_position.y + _local7);
_local12 = (_local10 - _local8);
_local13 = (_local11 - _local9);
_local3 = _local1.m_R;
_local14 = ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y));
_local15 = ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y));
_local16 = _local1.m_linearVelocity;
_local17 = _local2.m_linearVelocity;
_local18 = _local1.m_angularVelocity;
_local19 = _local2.m_angularVelocity;
_local20 = (((_local12 * (-(_local18) * _local15)) + (_local13 * (_local18 * _local14))) + ((_local14 * (((_local17.x + (-(_local19) * _local7)) - _local16.x) - (-(_local18) * _local5))) + (_local15 * (((_local17.y + (_local19 * _local6)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
public function SetMotorSpeed(_arg1:Number):void{
m_motorSpeed = _arg1;
}
public function GetMotorForce(_arg1:Number):Number{
return ((_arg1 * m_motorImpulse));
}
public function SetMotorForce(_arg1:Number):void{
m_maxMotorForce = _arg1;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_angularImpulse));
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
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;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_invMass;
_local5 = _local3.m_invMass;
_local6 = _local2.m_invI;
_local7 = _local3.m_invI;
_local9 = m_linearJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local10 = (-(m_linearMass) * _local9);
m_linearImpulse = (m_linearImpulse + _local10);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local10) * m_linearJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local10) * m_linearJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local10) * m_linearJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local10) * m_linearJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local10) * m_linearJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local10) * m_linearJacobian.angular2));
_local11 = (_local3.m_angularVelocity - _local2.m_angularVelocity);
_local12 = (-(m_angularMass) * _local11);
m_angularImpulse = (m_angularImpulse + _local12);
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local6 * _local12));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local7 * _local12));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local13 = (m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity) - m_motorSpeed);
_local14 = (-(m_motorMass) * _local13);
_local15 = m_motorImpulse;
m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + _local14), (-(_arg1.dt) * m_maxMotorForce), (_arg1.dt * m_maxMotorForce));
_local14 = (m_motorImpulse - _local15);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local14) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local14) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local14) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local14) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local14) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local14) * m_motorJacobian.angular2));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local16 = m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local17 = (-(m_motorMass) * _local16);
if (m_limitState == e_equalLimits){
m_limitImpulse = (m_limitImpulse + _local17);
} else {
if (m_limitState == e_atLowerLimit){
_local8 = m_limitImpulse;
m_limitImpulse = b2Math.b2Max((m_limitImpulse + _local17), 0);
_local17 = (m_limitImpulse - _local8);
} else {
if (m_limitState == e_atUpperLimit){
_local8 = m_limitImpulse;
m_limitImpulse = b2Math.b2Min((m_limitImpulse + _local17), 0);
_local17 = (m_limitImpulse - _local8);
};
};
};
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local17) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local17) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local17) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local17) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local17) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local17) * m_motorJacobian.angular2));
};
}
}
}//package Box2D.Dynamics.Joints
Section 50
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2PrismaticJointDef extends b2JointDef {
public var motorSpeed:Number;
public var anchorPoint:b2Vec2;
public var axis:b2Vec2;
public var upperTranslation:Number;
public var lowerTranslation:Number;
public var enableMotor:Boolean;
public var motorForce:Number;
public var enableLimit:Boolean;
public function b2PrismaticJointDef(){
type = b2Joint.e_prismaticJoint;
anchorPoint = new b2Vec2(0, 0);
axis = new b2Vec2(0, 0);
lowerTranslation = 0;
upperTranslation = 0;
motorForce = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
}
}//package Box2D.Dynamics.Joints
Section 51
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
public var m_ground:b2Body;
public var m_maxLength2:Number;
public var m_limitState1:int;
public var m_maxLength1:Number;
public var m_pulleyImpulse:Number;
public var m_limitPositionImpulse1:Number;
public var m_constant:Number;
public var m_ratio:Number;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_limitPositionImpulse2:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitState2:int;
public var m_limitMass2:Number;
public var m_limitMass1:Number;
public var m_limitImpulse2:Number;
public var m_u1:b2Vec2;
public var m_u2:b2Vec2;
public var m_limitImpulse1:Number;
public var m_pulleyMass:Number;
public static var b2_minPulleyLength:Number = 1;
public function b2PulleyJoint(_arg1:b2PulleyJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8: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.groundPoint1.x - m_ground.m_position.x);
m_groundAnchor1.y = (_arg1.groundPoint1.y - m_ground.m_position.y);
m_groundAnchor2.x = (_arg1.groundPoint2.x - m_ground.m_position.x);
m_groundAnchor2.y = (_arg1.groundPoint2.y - m_ground.m_position.y);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint1.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint1.y - m_body1.m_position.y);
m_localAnchor1.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor1.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint2.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint2.y - m_body2.m_position.y);
m_localAnchor2.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor2.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
m_ratio = _arg1.ratio;
_local3 = (_arg1.groundPoint1.x - _arg1.anchorPoint1.x);
_local4 = (_arg1.groundPoint1.y - _arg1.anchorPoint1.y);
_local5 = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
_local3 = (_arg1.groundPoint2.x - _arg1.anchorPoint2.x);
_local4 = (_arg1.groundPoint2.y - _arg1.anchorPoint2.y);
_local6 = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
_local7 = b2Math.b2Max((0.5 * b2_minPulleyLength), _local5);
_local8 = b2Math.b2Max((0.5 * b2_minPulleyLength), _local6);
m_constant = (_local7 + (m_ratio * _local8));
m_maxLength1 = b2Math.b2Clamp(_arg1.maxLength1, _local7, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.b2Clamp(_arg1.maxLength2, _local8, ((m_constant - b2_minPulleyLength) / m_ratio));
m_pulleyImpulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
}
public function GetLength1():Number{
var _local1:b2Mat22;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = m_body1.m_R;
_local2 = (m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y)));
_local3 = (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)));
_local4 = (_local2 - (m_ground.m_position.x + m_groundAnchor1.x));
_local5 = (_local3 - (m_ground.m_position.y + m_groundAnchor1.y));
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver():void{
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: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;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = (_local1.m_position.x + _local4);
_local9 = (_local1.m_position.y + _local5);
_local10 = (_local2.m_position.x + _local6);
_local11 = (_local2.m_position.y + _local7);
_local12 = (m_ground.m_position.x + m_groundAnchor1.x);
_local13 = (m_ground.m_position.y + m_groundAnchor1.y);
_local14 = (m_ground.m_position.x + m_groundAnchor2.x);
_local15 = (m_ground.m_position.y + m_groundAnchor2.y);
m_u1.Set((_local8 - _local12), (_local9 - _local13));
m_u2.Set((_local10 - _local14), (_local11 - _local15));
_local16 = m_u1.Length();
_local17 = m_u2.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local16));
} else {
m_u1.SetZero();
};
if (_local17 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local17));
} else {
m_u2.SetZero();
};
if (_local16 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitImpulse1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
m_limitPositionImpulse1 = 0;
};
if (_local17 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitImpulse2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
m_limitPositionImpulse2 = 0;
};
_local18 = ((_local4 * m_u1.y) - (_local5 * m_u1.x));
_local19 = ((_local6 * m_u2.y) - (_local7 * m_u2.x));
m_limitMass1 = (_local1.m_invMass + ((_local1.m_invI * _local18) * _local18));
m_limitMass2 = (_local2.m_invMass + ((_local2.m_invI * _local19) * _local19));
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);
_local20 = ((-(m_pulleyImpulse) - m_limitImpulse1) * m_u1.x);
_local21 = ((-(m_pulleyImpulse) - m_limitImpulse1) * m_u1.y);
_local22 = (((-(m_ratio) * m_pulleyImpulse) - m_limitImpulse2) * m_u2.x);
_local23 = (((-(m_ratio) * m_pulleyImpulse) - m_limitImpulse2) * m_u2.y);
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x + (_local1.m_invMass * _local20));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y + (_local1.m_invMass * _local21));
_local1.m_angularVelocity = (_local1.m_angularVelocity + (_local1.m_invI * ((_local4 * _local21) - (_local5 * _local20))));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local22));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local23));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local6 * _local23) - (_local7 * _local22))));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2());
}
override public function SolvePositionConstraints():Boolean{
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:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
_local1 = m_body1;
_local2 = m_body2;
_local4 = (m_ground.m_position.x + m_groundAnchor1.x);
_local5 = (m_ground.m_position.y + m_groundAnchor1.y);
_local6 = (m_ground.m_position.x + m_groundAnchor2.x);
_local7 = (m_ground.m_position.y + m_groundAnchor2.y);
_local21 = 0;
_local3 = _local1.m_R;
_local8 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local9 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local10 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local11 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local12 = (_local1.m_position.x + _local8);
_local13 = (_local1.m_position.y + _local9);
_local14 = (_local2.m_position.x + _local10);
_local15 = (_local2.m_position.y + _local11);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local16 = m_u1.Length();
_local17 = m_u2.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local16));
} else {
m_u1.SetZero();
};
if (_local17 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = ((m_constant - _local16) - (m_ratio * _local17));
_local21 = b2Math.b2Max(_local21, Math.abs(_local18));
_local18 = b2Math.b2Clamp(_local18, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local19 = (-(m_pulleyMass) * _local18);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local14 = ((-(m_ratio) * _local19) * m_u2.x);
_local15 = ((-(m_ratio) * _local19) * m_u2.y);
_local1.m_position.x = (_local1.m_position.x + (_local1.m_invMass * _local12));
_local1.m_position.y = (_local1.m_position.y + (_local1.m_invMass * _local13));
_local1.m_rotation = (_local1.m_rotation + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local2.m_position.x = (_local2.m_position.x + (_local2.m_invMass * _local14));
_local2.m_position.y = (_local2.m_position.y + (_local2.m_invMass * _local15));
_local2.m_rotation = (_local2.m_rotation + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local1.m_R.Set(_local1.m_rotation);
_local2.m_R.Set(_local2.m_rotation);
if (m_limitState1 == e_atUpperLimit){
_local3 = _local1.m_R;
_local8 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local9 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local12 = (_local1.m_position.x + _local8);
_local13 = (_local1.m_position.y + _local9);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
_local16 = m_u1.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / _local16));
m_u1.y = (m_u1.y * (1 / _local16));
} else {
m_u1.SetZero();
};
_local18 = (m_maxLength1 - _local16);
_local21 = b2Math.b2Max(_local21, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass1) * _local18);
_local20 = m_limitPositionImpulse1;
m_limitPositionImpulse1 = b2Math.b2Max(0, (m_limitPositionImpulse1 + _local19));
_local19 = (m_limitPositionImpulse1 - _local20);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local1.m_position.x = (_local1.m_position.x + (_local1.m_invMass * _local12));
_local1.m_position.y = (_local1.m_position.y + (_local1.m_invMass * _local13));
_local1.m_rotation = (_local1.m_rotation + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local1.m_R.Set(_local1.m_rotation);
};
if (m_limitState2 == e_atUpperLimit){
_local3 = _local2.m_R;
_local10 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local11 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local14 = (_local2.m_position.x + _local10);
_local15 = (_local2.m_position.y + _local11);
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local17 = m_u2.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / _local17));
m_u2.y = (m_u2.y * (1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = (m_maxLength2 - _local17);
_local21 = b2Math.b2Max(_local21, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass2) * _local18);
_local20 = m_limitPositionImpulse2;
m_limitPositionImpulse2 = b2Math.b2Max(0, (m_limitPositionImpulse2 + _local19));
_local19 = (m_limitPositionImpulse2 - _local20);
_local14 = (-(_local19) * m_u2.x);
_local15 = (-(_local19) * m_u2.y);
_local2.m_position.x = (_local2.m_position.x + (_local2.m_invMass * _local14));
_local2.m_position.y = (_local2.m_position.y + (_local2.m_invMass * _local15));
_local2.m_rotation = (_local2.m_rotation + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local2.m_R.Set(_local2.m_rotation);
};
return ((_local21 < b2Settings.b2_linearSlop));
}
public function GetGroundPoint1():b2Vec2{
return (new b2Vec2((m_ground.m_position.x + m_groundAnchor1.x), (m_ground.m_position.y + m_groundAnchor1.y)));
}
public function GetGroundPoint2():b2Vec2{
return (new b2Vec2((m_ground.m_position.x + m_groundAnchor2.x), (m_ground.m_position.y + m_groundAnchor2.y)));
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
public function GetLength2():Number{
var _local1:b2Mat22;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = m_body2.m_R;
_local2 = (m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y)));
_local3 = (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)));
_local4 = (_local2 - (m_ground.m_position.x + m_groundAnchor2.x));
_local5 = (_local3 - (m_ground.m_position.y + m_groundAnchor2.y));
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
override public 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;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_R;
_local5 = ((_local4.col1.x * m_localAnchor1.x) + (_local4.col2.x * m_localAnchor1.y));
_local6 = ((_local4.col1.y * m_localAnchor1.x) + (_local4.col2.y * m_localAnchor1.y));
_local4 = _local3.m_R;
_local7 = ((_local4.col1.x * m_localAnchor2.x) + (_local4.col2.x * m_localAnchor2.y));
_local8 = ((_local4.col1.y * m_localAnchor2.x) + (_local4.col2.y * m_localAnchor2.y));
_local9 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local10 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local11 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local8));
_local12 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local7));
_local17 = (-(((m_u1.x * _local9) + (m_u1.y * _local10))) - (m_ratio * ((m_u2.x * _local11) + (m_u2.y * _local12))));
_local18 = (-(m_pulleyMass) * _local17);
m_pulleyImpulse = (m_pulleyImpulse + _local18);
_local13 = (-(_local18) * m_u1.x);
_local14 = (-(_local18) * m_u1.y);
_local15 = ((-(m_ratio) * _local18) * m_u2.x);
_local16 = ((-(m_ratio) * _local18) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local13));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local14));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local14) - (_local6 * _local13))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local7 * _local16) - (_local8 * _local15))));
if (m_limitState1 == e_atUpperLimit){
_local9 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local10 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local17 = -(((m_u1.x * _local9) + (m_u1.y * _local10)));
_local18 = (-(m_limitMass1) * _local17);
_local19 = m_limitImpulse1;
m_limitImpulse1 = b2Math.b2Max(0, (m_limitImpulse1 + _local18));
_local18 = (m_limitImpulse1 - _local19);
_local13 = (-(_local18) * m_u1.x);
_local14 = (-(_local18) * m_u1.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local13));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local14));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local14) - (_local6 * _local13))));
};
if (m_limitState2 == e_atUpperLimit){
_local11 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local8));
_local12 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local7));
_local17 = -(((m_u2.x * _local11) + (m_u2.y * _local12)));
_local18 = (-(m_limitMass2) * _local17);
_local19 = m_limitImpulse2;
m_limitImpulse2 = b2Math.b2Max(0, (m_limitImpulse2 + _local18));
_local18 = (m_limitImpulse2 - _local19);
_local15 = (-(_local18) * m_u2.x);
_local16 = (-(_local18) * m_u2.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local7 * _local16) - (_local8 * _local15))));
};
}
}
}//package Box2D.Dynamics.Joints
Section 52
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2PulleyJointDef extends b2JointDef {
public var groundPoint1:b2Vec2;
public var groundPoint2:b2Vec2;
public var ratio:Number;
public var maxLength1:Number;
public var maxLength2:Number;
public var anchorPoint1:b2Vec2;
public var anchorPoint2:b2Vec2;
public function b2PulleyJointDef(){
groundPoint1 = new b2Vec2();
groundPoint2 = new b2Vec2();
anchorPoint1 = new b2Vec2();
anchorPoint2 = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundPoint1.Set(-1, 1);
groundPoint2.Set(1, 1);
anchorPoint1.Set(-1, 0);
anchorPoint2.Set(1, 0);
maxLength1 = (0.5 * b2PulleyJoint.b2_minPulleyLength);
maxLength2 = (0.5 * b2PulleyJoint.b2_minPulleyLength);
ratio = 1;
collideConnected = true;
}
}
}//package Box2D.Dynamics.Joints
Section 53
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
public var m_intialAngle:Number;
public var m_enableLimit:Boolean;
public var m_limitState:int;
public var m_ptpMass:b2Mat22;
public var m_motorMass:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
public var m_limitImpulse:Number;
public var m_motorImpulse:Number;
public var m_enableMotor:Boolean;
public var m_lowerAngle:Number;
public var m_limitPositionImpulse:Number;
public var m_maxMotorTorque:Number;
public var m_upperAngle:Number;
public var m_motorSpeed:Number;
public var m_ptpImpulse:b2Vec2;
public static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(_arg1:b2RevoluteJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_ptpImpulse = new b2Vec2();
m_ptpMass = new b2Mat22();
super(_arg1);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body1.m_position.y);
m_localAnchor1.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor1.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body2.m_position.y);
m_localAnchor2.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor2.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
m_intialAngle = (m_body2.m_rotation - m_body1.m_rotation);
m_ptpImpulse.Set(0, 0);
m_motorImpulse = 0;
m_limitImpulse = 0;
m_limitPositionImpulse = 0;
m_lowerAngle = _arg1.lowerAngle;
m_upperAngle = _arg1.upperAngle;
m_maxMotorTorque = _arg1.motorTorque;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver():void{
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;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = _local1.m_invMass;
_local9 = _local2.m_invMass;
_local10 = _local1.m_invI;
_local11 = _local2.m_invI;
K1.col1.x = (_local8 + _local9);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local8 + _local9);
K2.col1.x = ((_local10 * _local5) * _local5);
K2.col2.x = ((-(_local10) * _local4) * _local5);
K2.col1.y = ((-(_local10) * _local4) * _local5);
K2.col2.y = ((_local10 * _local4) * _local4);
K3.col1.x = ((_local11 * _local7) * _local7);
K3.col2.x = ((-(_local11) * _local6) * _local7);
K3.col1.y = ((-(_local11) * _local6) * _local7);
K3.col2.y = ((_local11 * _local6) * _local6);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Invert(m_ptpMass);
m_motorMass = (1 / (_local10 + _local11));
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit){
_local12 = ((_local2.m_rotation - _local1.m_rotation) - m_intialAngle);
if (b2Math.b2Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (_local12 <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_limitImpulse = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local12 >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_limitImpulse = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitImpulse = 0;
};
};
};
} else {
m_limitImpulse = 0;
};
if (b2World.s_enableWarmStarting){
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x - (_local8 * m_ptpImpulse.x));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y - (_local8 * m_ptpImpulse.y));
_local1.m_angularVelocity = (_local1.m_angularVelocity - (_local10 * ((((_local4 * m_ptpImpulse.y) - (_local5 * m_ptpImpulse.x)) + m_motorImpulse) + m_limitImpulse)));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local9 * m_ptpImpulse.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local9 * m_ptpImpulse.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local11 * ((((_local6 * m_ptpImpulse.y) - (_local7 * m_ptpImpulse.x)) + m_motorImpulse) + m_limitImpulse)));
} else {
m_ptpImpulse.SetZero();
m_motorImpulse = 0;
m_limitImpulse = 0;
};
m_limitPositionImpulse = 0;
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:b2Vec2;
_local2 = m_ptpImpulse.Copy();
_local2.Multiply(_arg1);
return (_local2);
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:b2Body;
var _local4:b2Body;
var _local5:Number;
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;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
_local3 = m_body1;
_local4 = m_body2;
_local5 = 0;
_local6 = _local3.m_R;
_local7 = ((_local6.col1.x * m_localAnchor1.x) + (_local6.col2.x * m_localAnchor1.y));
_local8 = ((_local6.col1.y * m_localAnchor1.x) + (_local6.col2.y * m_localAnchor1.y));
_local6 = _local4.m_R;
_local9 = ((_local6.col1.x * m_localAnchor2.x) + (_local6.col2.x * m_localAnchor2.y));
_local10 = ((_local6.col1.y * m_localAnchor2.x) + (_local6.col2.y * m_localAnchor2.y));
_local11 = (_local3.m_position.x + _local7);
_local12 = (_local3.m_position.y + _local8);
_local13 = (_local4.m_position.x + _local9);
_local14 = (_local4.m_position.y + _local10);
_local15 = (_local13 - _local11);
_local16 = (_local14 - _local12);
_local5 = Math.sqrt(((_local15 * _local15) + (_local16 * _local16)));
_local17 = _local3.m_invMass;
_local18 = _local4.m_invMass;
_local19 = _local3.m_invI;
_local20 = _local4.m_invI;
K1.col1.x = (_local17 + _local18);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local17 + _local18);
K2.col1.x = ((_local19 * _local8) * _local8);
K2.col2.x = ((-(_local19) * _local7) * _local8);
K2.col1.y = ((-(_local19) * _local7) * _local8);
K2.col2.y = ((_local19 * _local7) * _local7);
K3.col1.x = ((_local20 * _local10) * _local10);
K3.col2.x = ((-(_local20) * _local9) * _local10);
K3.col1.y = ((-(_local20) * _local9) * _local10);
K3.col2.y = ((_local20 * _local9) * _local9);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(_local15), -(_local16));
_local21 = tImpulse.x;
_local22 = tImpulse.y;
_local3.m_position.x = (_local3.m_position.x - (_local3.m_invMass * _local21));
_local3.m_position.y = (_local3.m_position.y - (_local3.m_invMass * _local22));
_local3.m_rotation = (_local3.m_rotation - (_local3.m_invI * ((_local7 * _local22) - (_local8 * _local21))));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_position.x = (_local4.m_position.x + (_local4.m_invMass * _local21));
_local4.m_position.y = (_local4.m_position.y + (_local4.m_invMass * _local22));
_local4.m_rotation = (_local4.m_rotation + (_local4.m_invI * ((_local9 * _local22) - (_local10 * _local21))));
_local4.m_R.Set(_local4.m_rotation);
_local23 = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local24 = ((_local4.m_rotation - _local3.m_rotation) - m_intialAngle);
_local25 = 0;
if (m_limitState == e_equalLimits){
_local2 = b2Math.b2Clamp(_local24, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local25 = (-(m_motorMass) * _local2);
_local23 = b2Math.b2Abs(_local2);
} else {
if (m_limitState == e_atLowerLimit){
_local2 = (_local24 - m_lowerAngle);
_local23 = b2Math.b2Max(0, -(_local2));
_local2 = b2Math.b2Clamp((_local2 + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
_local25 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local25), 0);
_local25 = (m_limitPositionImpulse - _local1);
} else {
if (m_limitState == e_atUpperLimit){
_local2 = (_local24 - m_upperAngle);
_local23 = b2Math.b2Max(0, _local2);
_local2 = b2Math.b2Clamp((_local2 - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
_local25 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local25), 0);
_local25 = (m_limitPositionImpulse - _local1);
};
};
};
_local3.m_rotation = (_local3.m_rotation - (_local3.m_invI * _local25));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_rotation = (_local4.m_rotation + (_local4.m_invI * _local25));
_local4.m_R.Set(_local4.m_rotation);
};
return ((((_local5 <= b2Settings.b2_linearSlop)) && ((_local23 <= b2Settings.b2_angularSlop))));
}
public function GetJointSpeed():Number{
return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity));
}
public function SetMotorSpeed(_arg1:Number):void{
m_motorSpeed = _arg1;
}
public function SetMotorTorque(_arg1:Number):void{
m_maxMotorTorque = _arg1;
}
public function GetJointAngle():Number{
return ((m_body2.m_rotation - m_body1.m_rotation));
}
public function GetMotorTorque(_arg1:Number):Number{
return ((_arg1 * m_motorImpulse));
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_limitImpulse));
}
override public 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;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_R;
_local5 = ((_local4.col1.x * m_localAnchor1.x) + (_local4.col2.x * m_localAnchor1.y));
_local6 = ((_local4.col1.y * m_localAnchor1.x) + (_local4.col2.y * m_localAnchor1.y));
_local4 = _local3.m_R;
_local7 = ((_local4.col1.x * m_localAnchor2.x) + (_local4.col2.x * m_localAnchor2.y));
_local8 = ((_local4.col1.y * m_localAnchor2.x) + (_local4.col2.y * m_localAnchor2.y));
_local10 = (((_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local8)) - _local2.m_linearVelocity.x) - (-(_local2.m_angularVelocity) * _local6));
_local11 = (((_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local7)) - _local2.m_linearVelocity.y) - (_local2.m_angularVelocity * _local5));
_local12 = -(((m_ptpMass.col1.x * _local10) + (m_ptpMass.col2.x * _local11)));
_local13 = -(((m_ptpMass.col1.y * _local10) + (m_ptpMass.col2.y * _local11)));
m_ptpImpulse.x = (m_ptpImpulse.x + _local12);
m_ptpImpulse.y = (m_ptpImpulse.y + _local13);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (_local2.m_invMass * _local12));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (_local2.m_invMass * _local13));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * ((_local5 * _local13) - (_local6 * _local12))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local12));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local13));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local7 * _local13) - (_local8 * _local12))));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local14 = ((_local3.m_angularVelocity - _local2.m_angularVelocity) - m_motorSpeed);
_local15 = (-(m_motorMass) * _local14);
_local16 = m_motorImpulse;
m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + _local15), (-(_arg1.dt) * m_maxMotorTorque), (_arg1.dt * m_maxMotorTorque));
_local15 = (m_motorImpulse - _local16);
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * _local15));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * _local15));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local17 = (_local3.m_angularVelocity - _local2.m_angularVelocity);
_local18 = (-(m_motorMass) * _local17);
if (m_limitState == e_equalLimits){
m_limitImpulse = (m_limitImpulse + _local18);
} else {
if (m_limitState == e_atLowerLimit){
_local9 = m_limitImpulse;
m_limitImpulse = b2Math.b2Max((m_limitImpulse + _local18), 0);
_local18 = (m_limitImpulse - _local9);
} else {
if (m_limitState == e_atUpperLimit){
_local9 = m_limitImpulse;
m_limitImpulse = b2Math.b2Min((m_limitImpulse + _local18), 0);
_local18 = (m_limitImpulse - _local9);
};
};
};
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * _local18));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * _local18));
};
}
}
}//package Box2D.Dynamics.Joints
Section 54
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2RevoluteJointDef extends b2JointDef {
public var upperAngle:Number;
public var lowerAngle:Number;
public var motorSpeed:Number;
public var anchorPoint:b2Vec2;
public var motorTorque:Number;
public var enableMotor:Boolean;
public var enableLimit:Boolean;
public function b2RevoluteJointDef(){
type = b2Joint.e_revoluteJoint;
anchorPoint = new b2Vec2(0, 0);
lowerAngle = 0;
upperAngle = 0;
motorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
}
}//package Box2D.Dynamics.Joints
Section 55
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Body {
public var m_next:b2Body;
public var m_mass:Number;
public var m_contactList:b2ContactNode;
public var m_angularVelocity:Number;
public var m_rotation:Number;
public var m_shapeList:b2Shape;
public var m_R:b2Mat22;
public var m_force:b2Vec2;
public var m_torque:Number;
public var m_rotation0:Number;
public var m_userData;
public var m_linearVelocity:b2Vec2;
public var m_invMass:Number;
public var m_position:b2Vec2;
public var m_flags:uint;
public var m_invI:Number;
public var m_linearDamping:Number;
public var m_prev:b2Body;
public var m_world:b2World;
public var m_angularDamping:Number;
public var m_position0:b2Vec2;
private var sMat0:b2Mat22;
public var m_center:b2Vec2;
public var m_sleepTime:Number;
public var m_shapeCount:int;
public var m_I:Number;
public var m_jointList:b2JointNode;
public static var e_frozenFlag:uint = 2;
public static var e_sleepFlag:uint = 8;
public static var e_islandFlag:uint = 4;
public static var e_destroyFlag:uint = 32;
public static var e_allowSleepFlag:uint = 16;
public static var e_staticFlag:uint = 1;
public function b2Body(_arg1:b2BodyDef, _arg2:b2World){
var _local3:int;
var _local4:b2ShapeDef;
var _local5:b2MassData;
var _local6:Array;
var _local7:b2Vec2;
var _local8:b2Shape;
sMat0 = new b2Mat22();
m_position = new b2Vec2();
m_R = new b2Mat22(0);
m_position0 = new b2Vec2();
super();
m_flags = 0;
m_position.SetV(_arg1.position);
m_rotation = _arg1.rotation;
m_R.Set(m_rotation);
m_position0.SetV(m_position);
m_rotation0 = m_rotation;
m_world = _arg2;
m_linearDamping = b2Math.b2Clamp((1 - _arg1.linearDamping), 0, 1);
m_angularDamping = b2Math.b2Clamp((1 - _arg1.angularDamping), 0, 1);
m_force = new b2Vec2(0, 0);
m_torque = 0;
m_mass = 0;
_local6 = new Array(b2Settings.b2_maxShapesPerBody);
_local3 = 0;
while (_local3 < b2Settings.b2_maxShapesPerBody) {
_local6[_local3] = new b2MassData();
_local3++;
};
m_shapeCount = 0;
m_center = new b2Vec2(0, 0);
_local3 = 0;
while (_local3 < b2Settings.b2_maxShapesPerBody) {
_local4 = _arg1.shapes[_local3];
if (_local4 == null){
break;
};
_local5 = _local6[_local3];
_local4.ComputeMass(_local5);
m_mass = (m_mass + _local5.mass);
m_center.x = (m_center.x + (_local5.mass * (_local4.localPosition.x + _local5.center.x)));
m_center.y = (m_center.y + (_local5.mass * (_local4.localPosition.y + _local5.center.y)));
m_shapeCount++;
_local3++;
};
if (m_mass > 0){
m_center.Multiply((1 / m_mass));
m_position.Add(b2Math.b2MulMV(m_R, m_center));
} else {
m_flags = (m_flags | e_staticFlag);
};
m_I = 0;
_local3 = 0;
while (_local3 < m_shapeCount) {
_local4 = _arg1.shapes[_local3];
_local5 = _local6[_local3];
m_I = (m_I + _local5.I);
_local7 = b2Math.SubtractVV(b2Math.AddVV(_local4.localPosition, _local5.center), m_center);
m_I = (m_I + (_local5.mass * b2Math.b2Dot(_local7, _local7)));
_local3++;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
} else {
m_invMass = 0;
};
if ((((m_I > 0)) && ((_arg1.preventRotation == false)))){
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
m_linearVelocity = b2Math.AddVV(_arg1.linearVelocity, b2Math.b2CrossFV(_arg1.angularVelocity, m_center));
m_angularVelocity = _arg1.angularVelocity;
m_jointList = null;
m_contactList = null;
m_prev = null;
m_next = null;
m_shapeList = null;
_local3 = 0;
while (_local3 < m_shapeCount) {
_local4 = _arg1.shapes[_local3];
_local8 = b2Shape.Create(_local4, this, m_center);
_local8.m_next = m_shapeList;
m_shapeList = _local8;
_local3++;
};
m_sleepTime = 0;
if (_arg1.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (_arg1.isSleeping){
m_flags = (m_flags | e_sleepFlag);
};
if ((((m_flags & e_sleepFlag)) || ((m_invMass == 0)))){
m_linearVelocity.Set(0, 0);
m_angularVelocity = 0;
};
m_userData = _arg1.userData;
}
public function SetCenterPosition(_arg1:b2Vec2, _arg2:Number):void{
var _local3:b2Shape;
if (IsFrozen()){
return;
};
m_rotation = _arg2;
m_R.Set(m_rotation);
m_position.SetV(_arg1);
m_position0.SetV(m_position);
m_rotation0 = m_rotation;
_local3 = m_shapeList;
while (_local3 != null) {
_local3.Synchronize(m_position, m_R, m_position, m_R);
_local3 = _local3.m_next;
};
m_world.m_broadPhase.Commit();
}
public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.AddVV(m_position, b2Math.b2MulMV(m_R, _arg1)));
}
public function SetLinearVelocity(_arg1:b2Vec2):void{
m_linearVelocity.SetV(_arg1);
}
public function IsFrozen():Boolean{
return (((m_flags & e_frozenFlag) == e_frozenFlag));
}
public function IsSleeping():Boolean{
return (((m_flags & e_sleepFlag) == e_sleepFlag));
}
public function QuickSyncShapes():void{
var _local1:b2Shape;
_local1 = m_shapeList;
while (_local1 != null) {
_local1.QuickSync(m_position, m_R);
_local1 = _local1.m_next;
};
}
public function GetInertia():Number{
return (m_I);
}
public function GetLocalVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_R, _arg1));
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function GetJointList():b2JointNode{
return (m_jointList);
}
public function GetRotationMatrix():b2Mat22{
return (m_R);
}
public function Freeze():void{
var _local1:b2Shape;
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
_local1 = m_shapeList;
while (_local1 != null) {
_local1.DestroyProxy();
_local1 = _local1.m_next;
};
}
public function SetAngularVelocity(_arg1:Number):void{
m_angularVelocity = _arg1;
}
public function SynchronizeShapes():void{
var _local1:b2Shape;
sMat0.Set(m_rotation0);
_local1 = m_shapeList;
while (_local1 != null) {
_local1.Synchronize(m_position0, sMat0, m_position, m_R);
_local1 = _local1.m_next;
};
}
public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping() == false){
m_force.Add(_arg1);
m_torque = (m_torque + b2Math.b2CrossVV(b2Math.SubtractVV(_arg2, m_position), _arg1));
};
}
public function GetOriginPosition():b2Vec2{
return (b2Math.SubtractVV(m_position, b2Math.b2MulMV(m_R, m_center)));
}
public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping() == false){
m_linearVelocity.Add(b2Math.MulFV(m_invMass, _arg1));
m_angularVelocity = (m_angularVelocity + (m_invI * b2Math.b2CrossVV(b2Math.SubtractVV(_arg2, m_position), _arg1)));
};
}
public function GetContactList():b2ContactNode{
return (m_contactList);
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function GetMass():Number{
return (m_mass);
}
public function GetShapeList():b2Shape{
return (m_shapeList);
}
public function SetOriginPosition(_arg1:b2Vec2, _arg2:Number):void{
var _local3:b2Shape;
if (IsFrozen()){
return;
};
m_rotation = _arg2;
m_R.Set(m_rotation);
m_position = b2Math.AddVV(_arg1, b2Math.b2MulMV(m_R, m_center));
m_position0.SetV(m_position);
m_rotation0 = m_rotation;
_local3 = m_shapeList;
while (_local3 != null) {
_local3.Synchronize(m_position, m_R, m_position, m_R);
_local3 = _local3.m_next;
};
m_world.m_broadPhase.Commit();
}
public function GetLocalPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_R, b2Math.SubtractVV(_arg1, m_position)));
}
public function GetRotation():Number{
return (m_rotation);
}
public function IsStatic():Boolean{
return (((m_flags & e_staticFlag) == e_staticFlag));
}
public function Destroy():void{
var _local1:b2Shape;
var _local2:b2Shape;
_local1 = m_shapeList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.m_next;
b2Shape.Destroy(_local2);
};
}
public function GetWorldVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulMV(m_R, _arg1));
}
public function GetNext():b2Body{
return (m_next);
}
public function IsConnected(_arg1:b2Body):Boolean{
var _local2:b2JointNode;
_local2 = m_jointList;
while (_local2 != null) {
if (_local2.other == _arg1){
return ((_local2.joint.m_collideConnected == false));
};
_local2 = _local2.next;
};
return (false);
}
public function GetUserData(){
return (m_userData);
}
public function GetCenterPosition():b2Vec2{
return (m_position);
}
public function ApplyTorque(_arg1:Number):void{
if (IsSleeping() == false){
m_torque = (m_torque + _arg1);
};
}
public function AllowSleeping(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
WakeUp();
};
}
public function WakeUp():void{
m_flags = (m_flags & ~(e_sleepFlag));
m_sleepTime = 0;
}
}
}//package Box2D.Dynamics
Section 56
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2BodyDef {
public var angularDamping:Number;
public var rotation:Number;
public var allowSleep:Boolean;
public var userData;
public var linearDamping:Number;
public var angularVelocity:Number;
public var linearVelocity:b2Vec2;
public var position:b2Vec2;
public var shapes:Array;
public var isSleeping:Boolean;
public var preventRotation:Boolean;
public function b2BodyDef(){
var _local1:int;
shapes = new Array();
super();
userData = null;
_local1 = 0;
while (_local1 < b2Settings.b2_maxShapesPerBody) {
shapes[_local1] = null;
_local1++;
};
position = new b2Vec2(0, 0);
rotation = 0;
linearVelocity = new b2Vec2(0, 0);
angularVelocity = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
isSleeping = false;
preventRotation = false;
}
public function AddShape(_arg1:b2ShapeDef):void{
var _local2:int;
_local2 = 0;
while (_local2 < b2Settings.b2_maxShapesPerBody) {
if (shapes[_local2] == null){
shapes[_local2] = _arg1;
break;
};
_local2++;
};
}
}
}//package Box2D.Dynamics
Section 57
//b2CollisionFilter (Box2D.Dynamics.b2CollisionFilter)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2CollisionFilter {
public static var b2_defaultFilter:b2CollisionFilter = new (b2CollisionFilter);
;
public function ShouldCollide(_arg1:b2Shape, _arg2:b2Shape):Boolean{
var _local3:Boolean;
if ((((_arg1.m_groupIndex == _arg2.m_groupIndex)) && (!((_arg1.m_groupIndex == 0))))){
return ((_arg1.m_groupIndex > 0));
};
_local3 = ((!(((_arg1.m_maskBits & _arg2.m_categoryBits) == 0))) && (!(((_arg1.m_categoryBits & _arg2.m_maskBits) == 0))));
return (_local3);
}
}
}//package Box2D.Dynamics
Section 58
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
public class b2ContactManager extends b2PairCallback {
public var m_world:b2World;
public var m_destroyImmediate:Boolean;
public var m_nullContact:b2NullContact;
public function b2ContactManager(){
m_nullContact = new b2NullContact();
super();
m_world = null;
m_destroyImmediate = false;
}
public function Collide():void{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2ContactNode;
var _local4:b2ContactNode;
var _local5:b2Contact;
var _local6:int;
var _local7:int;
_local5 = m_world.m_contactList;
while (_local5 != null) {
if (((_local5.m_shape1.m_body.IsSleeping()) && (_local5.m_shape2.m_body.IsSleeping()))){
} else {
_local6 = _local5.GetManifoldCount();
_local5.Evaluate();
_local7 = _local5.GetManifoldCount();
if ((((_local6 == 0)) && ((_local7 > 0)))){
_local1 = _local5.m_shape1.m_body;
_local2 = _local5.m_shape2.m_body;
_local3 = _local5.m_node1;
_local4 = _local5.m_node2;
_local3.contact = _local5;
_local3.other = _local2;
_local3.prev = null;
_local3.next = _local1.m_contactList;
if (_local3.next != null){
_local3.next.prev = _local5.m_node1;
};
_local1.m_contactList = _local5.m_node1;
_local4.contact = _local5;
_local4.other = _local1;
_local4.prev = null;
_local4.next = _local2.m_contactList;
if (_local4.next != null){
_local4.next.prev = _local4;
};
_local2.m_contactList = _local4;
} else {
if ((((_local6 > 0)) && ((_local7 == 0)))){
_local1 = _local5.m_shape1.m_body;
_local2 = _local5.m_shape2.m_body;
_local3 = _local5.m_node1;
_local4 = _local5.m_node2;
if (_local3.prev){
_local3.prev.next = _local3.next;
};
if (_local3.next){
_local3.next.prev = _local3.prev;
};
if (_local3 == _local1.m_contactList){
_local1.m_contactList = _local3.next;
};
_local3.prev = null;
_local3.next = null;
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4 == _local2.m_contactList){
_local2.m_contactList = _local4.next;
};
_local4.prev = null;
_local4.next = null;
};
};
};
_local5 = _local5.m_next;
};
}
public function DestroyContact(_arg1:b2Contact):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2ContactNode;
var _local5:b2ContactNode;
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.GetManifoldCount() > 0){
_local2 = _arg1.m_shape1.m_body;
_local3 = _arg1.m_shape2.m_body;
_local4 = _arg1.m_node1;
_local5 = _arg1.m_node2;
_local2.WakeUp();
_local3.WakeUp();
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4 == _local2.m_contactList){
_local2.m_contactList = _local4.next;
};
_local4.prev = null;
_local4.next = null;
if (_local5.prev){
_local5.prev.next = _local5.next;
};
if (_local5.next){
_local5.next.prev = _local5.prev;
};
if (_local5 == _local3.m_contactList){
_local3.m_contactList = _local5.next;
};
_local5.prev = null;
_local5.next = null;
};
b2Contact.Destroy(_arg1, m_world.m_blockAllocator);
m_world.m_contactCount--;
}
override public function PairAdded(_arg1, _arg2){
var _local3:b2Shape;
var _local4:b2Shape;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2Contact;
var _local8:b2Shape;
var _local9:b2Body;
_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_filter == null))) && ((m_world.m_filter.ShouldCollide(_local3, _local4) == false)))){
return (m_nullContact);
};
if (_local6.m_invMass == 0){
_local8 = _local3;
_local3 = _local4;
_local4 = _local8;
_local9 = _local5;
_local5 = _local6;
_local6 = _local9;
};
_local7 = b2Contact.Create(_local3, _local4, m_world.m_blockAllocator);
if (_local7 == null){
return (m_nullContact);
};
_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;
m_world.m_contactCount++;
return (_local7);
}
public function CleanContactList():void{
var _local1:b2Contact;
var _local2:b2Contact;
_local1 = m_world.m_contactList;
while (_local1 != null) {
_local2 = _local1;
_local1 = _local1.m_next;
if ((_local2.m_flags & b2Contact.e_destroyFlag)){
DestroyContact(_local2);
_local2 = null;
};
};
}
override public function PairRemoved(_arg1, _arg2, _arg3):void{
var _local4:b2Contact;
if (_arg3 == null){
return;
};
_local4 = (_arg3 as b2Contact);
if (_local4 != m_nullContact){
if (m_destroyImmediate == true){
DestroyContact(_local4);
_local4 = null;
} else {
_local4.m_flags = (_local4.m_flags | b2Contact.e_destroyFlag);
};
};
}
}
}//package Box2D.Dynamics
Section 59
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Island {
public var m_positionError:Number;
public var m_bodyCapacity:int;
public var m_bodies:Array;
public var m_joints:Array;
public var m_jointCapacity:int;
public var m_contactCount:int;
public var m_contacts:Array;
public var m_contactCapacity:int;
public var m_jointCount:int;
public var m_allocator;
public var m_bodyCount:int;
public static var m_positionIterationCount:uint;
public function b2Island(_arg1:int, _arg2:int, _arg3:int, _arg4):void{
var _local5:int;
super();
m_bodyCapacity = _arg1;
m_contactCapacity = _arg2;
m_jointCapacity = _arg3;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_bodies = new Array(_arg1);
_local5 = 0;
while (_local5 < _arg1) {
m_bodies[_local5] = null;
_local5++;
};
m_contacts = new Array(_arg2);
_local5 = 0;
while (_local5 < _arg2) {
m_contacts[_local5] = null;
_local5++;
};
m_joints = new Array(_arg3);
_local5 = 0;
while (_local5 < _arg3) {
m_joints[_local5] = null;
_local5++;
};
m_allocator = _arg4;
}
public function AddBody(_arg1:b2Body):void{
var _local2 = m_bodyCount++;
m_bodies[_local2] = _arg1;
}
public function AddJoint(_arg1:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = _arg1;
}
public function Solve(_arg1:b2TimeStep, _arg2:b2Vec2):void{
var _local3:int;
var _local4:b2Body;
var _local5:b2ContactSolver;
var _local6:int;
var _local7:Boolean;
var _local8:Boolean;
var _local9:Boolean;
_local3 = 0;
while (_local3 < m_bodyCount) {
_local4 = m_bodies[_local3];
if (_local4.m_invMass == 0){
} else {
_local4.m_linearVelocity.Add(b2Math.MulFV(_arg1.dt, b2Math.AddVV(_arg2, b2Math.MulFV(_local4.m_invMass, _local4.m_force))));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_arg1.dt * _local4.m_invI) * _local4.m_torque));
_local4.m_linearVelocity.Multiply(_local4.m_linearDamping);
_local4.m_angularVelocity = (_local4.m_angularVelocity * _local4.m_angularDamping);
_local4.m_position0.SetV(_local4.m_position);
_local4.m_rotation0 = _local4.m_rotation;
};
_local3++;
};
_local5 = new b2ContactSolver(m_contacts, m_contactCount, m_allocator);
_local5.PreSolve();
_local3 = 0;
while (_local3 < m_jointCount) {
m_joints[_local3].PrepareVelocitySolver();
_local3++;
};
_local3 = 0;
while (_local3 < _arg1.iterations) {
_local5.SolveVelocityConstraints();
_local6 = 0;
while (_local6 < m_jointCount) {
m_joints[_local6].SolveVelocityConstraints(_arg1);
_local6++;
};
_local3++;
};
_local3 = 0;
while (_local3 < m_bodyCount) {
_local4 = m_bodies[_local3];
if (_local4.m_invMass == 0){
} else {
_local4.m_position.x = (_local4.m_position.x + (_arg1.dt * _local4.m_linearVelocity.x));
_local4.m_position.y = (_local4.m_position.y + (_arg1.dt * _local4.m_linearVelocity.y));
_local4.m_rotation = (_local4.m_rotation + (_arg1.dt * _local4.m_angularVelocity));
_local4.m_R.Set(_local4.m_rotation);
};
_local3++;
};
_local3 = 0;
while (_local3 < m_jointCount) {
m_joints[_local3].PreparePositionSolver();
_local3++;
};
if (b2World.s_enablePositionCorrection){
m_positionIterationCount = 0;
while (m_positionIterationCount < _arg1.iterations) {
_local7 = _local5.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local8 = true;
_local3 = 0;
while (_local3 < m_jointCount) {
_local9 = m_joints[_local3].SolvePositionConstraints();
_local8 = ((_local8) && (_local9));
_local3++;
};
if (((_local7) && (_local8))){
break;
};
m_positionIterationCount++;
};
};
_local5.PostSolve();
_local3 = 0;
while (_local3 < m_bodyCount) {
_local4 = m_bodies[_local3];
if (_local4.m_invMass == 0){
} else {
_local4.m_R.Set(_local4.m_rotation);
_local4.SynchronizeShapes();
_local4.m_force.Set(0, 0);
_local4.m_torque = 0;
};
_local3++;
};
}
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 UpdateSleep(_arg1:Number):void{
var _local2:int;
var _local3:b2Body;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local4 = Number.MAX_VALUE;
_local5 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
_local6 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
_local2 = 0;
while (_local2 < m_bodyCount) {
_local3 = m_bodies[_local2];
if (_local3.m_invMass == 0){
} else {
if ((_local3.m_flags & b2Body.e_allowSleepFlag) == 0){
_local3.m_sleepTime = 0;
_local4 = 0;
};
if (((((((_local3.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local3.m_angularVelocity * _local3.m_angularVelocity) > _local6)))) || ((b2Math.b2Dot(_local3.m_linearVelocity, _local3.m_linearVelocity) > _local5)))){
_local3.m_sleepTime = 0;
_local4 = 0;
} else {
_local3.m_sleepTime = (_local3.m_sleepTime + _arg1);
_local4 = b2Math.b2Min(_local4, _local3.m_sleepTime);
};
};
_local2++;
};
if (_local4 >= b2Settings.b2_timeToSleep){
_local2 = 0;
while (_local2 < m_bodyCount) {
_local3 = m_bodies[_local2];
_local3.m_flags = (_local3.m_flags | b2Body.e_sleepFlag);
_local2++;
};
};
}
}
}//package Box2D.Dynamics
Section 60
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var dt:Number;
public var iterations:int;
public var inv_dt:Number;
}
}//package Box2D.Dynamics
Section 61
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
public class b2World {
public var m_filter:b2CollisionFilter;
public var m_blockAllocator;
public var m_contactList:b2Contact;
public var m_broadPhase:b2BroadPhase;
public var m_allowSleep:Boolean;
public var m_jointCount:int;
public var m_bodyCount:int;
public var m_listener:b2WorldListener;
private var step:b2TimeStep;
public var m_positionIterationCount:int;
public var m_groundBody:b2Body;
public var m_contactCount:int;
public var m_bodyDestroyList:b2Body;
public var m_bodyList:b2Body;
public var m_stackAllocator;
public var m_gravity:b2Vec2;
public var m_jointList:b2Joint;
public var m_contactManager:b2ContactManager;
public static var s_enableWarmStarting:int = 1;
public static var s_enablePositionCorrection:int = 1;
public function b2World(_arg1:b2AABB, _arg2:b2Vec2, _arg3:Boolean){
var _local4:b2BodyDef;
step = new b2TimeStep();
m_contactManager = new b2ContactManager();
super();
m_listener = null;
m_filter = b2CollisionFilter.b2_defaultFilter;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_bodyDestroyList = null;
m_allowSleep = _arg3;
m_gravity = _arg2;
m_contactManager.m_world = this;
m_broadPhase = new b2BroadPhase(_arg1, m_contactManager);
_local4 = new b2BodyDef();
m_groundBody = CreateBody(_local4);
}
public function SetListener(_arg1:b2WorldListener):void{
m_listener = _arg1;
}
public function DestroyBody(_arg1:b2Body):void{
if ((_arg1.m_flags & b2Body.e_destroyFlag)){
return;
};
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;
};
_arg1.m_flags = (_arg1.m_flags | b2Body.e_destroyFlag);
m_bodyCount--;
_arg1.m_prev = null;
_arg1.m_next = m_bodyDestroyList;
m_bodyDestroyList = _arg1;
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function Query(_arg1:b2AABB, _arg2:Array, _arg3:int):int{
var _local4:Array;
var _local5:int;
var _local6:int;
_local4 = new Array();
_local5 = m_broadPhase.QueryAABB(_arg1, _local4, _arg3);
_local6 = 0;
while (_local6 < _local5) {
_arg2[_local6] = (_local4[_local6] as b2Shape);
_local6++;
};
return (_local5);
}
public function CleanBodyList():void{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2JointNode;
var _local4:b2JointNode;
m_contactManager.m_destroyImmediate = true;
_local1 = m_bodyDestroyList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.m_next;
_local3 = _local2.m_jointList;
while (_local3) {
_local4 = _local3;
_local3 = _local3.next;
if (m_listener){
m_listener.NotifyJointDestroyed(_local4.joint);
};
DestroyJoint(_local4.joint);
};
_local2.Destroy();
};
m_bodyDestroyList = null;
m_contactManager.m_destroyImmediate = false;
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
public function GetContactList():b2Contact{
return (m_contactList);
}
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.ResetProxy(m_broadPhase);
_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.ResetProxy(m_broadPhase);
_local6 = _local6.m_next;
};
};
}
public function SetFilter(_arg1:b2CollisionFilter):void{
m_filter = _arg1;
}
public function CreateBody(_arg1:b2BodyDef):b2Body{
var _local2:b2Body;
_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);
}
public function Step(_arg1:Number, _arg2:int):void{
var _local3:b2Body;
var _local4:b2Body;
var _local5:b2Island;
var _local6:b2Contact;
var _local7:b2Joint;
var _local8:int;
var _local9:Array;
var _local10:int;
var _local11:b2Body;
var _local12:int;
var _local13:int;
var _local14:b2ContactNode;
var _local15:b2JointNode;
var _local16:uint;
step.dt = _arg1;
step.iterations = _arg2;
if (_arg1 > 0){
step.inv_dt = (1 / _arg1);
} else {
step.inv_dt = 0;
};
m_positionIterationCount = 0;
m_contactManager.CleanContactList();
CleanBodyList();
m_contactManager.Collide();
_local5 = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator);
_local3 = m_bodyList;
while (_local3 != null) {
_local3.m_flags = (_local3.m_flags & ~(b2Body.e_islandFlag));
_local3 = _local3.m_next;
};
_local6 = m_contactList;
while (_local6 != null) {
_local6.m_flags = (_local6.m_flags & ~(b2Contact.e_islandFlag));
_local6 = _local6.m_next;
};
_local7 = m_jointList;
while (_local7 != null) {
_local7.m_islandFlag = false;
_local7 = _local7.m_next;
};
_local8 = m_bodyCount;
_local9 = new Array(m_bodyCount);
_local10 = 0;
while (_local10 < m_bodyCount) {
_local9[_local10] = null;
_local10++;
};
_local11 = m_bodyList;
while (_local11 != null) {
if ((_local11.m_flags & (((b2Body.e_staticFlag | b2Body.e_islandFlag) | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){
} else {
_local5.Clear();
_local12 = 0;
var _temp1 = _local12;
_local12 = (_local12 + 1);
var _local17 = _temp1;
_local9[_local17] = _local11;
_local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag);
while (_local12 > 0) {
--_local12;
_local3 = _local9[_local12];
_local5.AddBody(_local3);
_local3.m_flags = (_local3.m_flags & ~(b2Body.e_sleepFlag));
if ((_local3.m_flags & b2Body.e_staticFlag)){
} else {
_local14 = _local3.m_contactList;
while (_local14 != null) {
if ((_local14.contact.m_flags & b2Contact.e_islandFlag)){
} else {
_local5.AddContact(_local14.contact);
_local14.contact.m_flags = (_local14.contact.m_flags | b2Contact.e_islandFlag);
_local4 = _local14.other;
if ((_local4.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = _local12;
_local12 = (_local12 + 1);
var _local18 = _temp2;
_local9[_local18] = _local4;
_local4.m_flags = (_local4.m_flags | b2Body.e_islandFlag);
};
};
_local14 = _local14.next;
};
_local15 = _local3.m_jointList;
while (_local15 != null) {
if (_local15.joint.m_islandFlag == true){
} else {
_local5.AddJoint(_local15.joint);
_local15.joint.m_islandFlag = true;
_local4 = _local15.other;
if ((_local4.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = _local12;
_local12 = (_local12 + 1);
_local18 = _temp3;
_local9[_local18] = _local4;
_local4.m_flags = (_local4.m_flags | b2Body.e_islandFlag);
};
};
_local15 = _local15.next;
};
};
};
_local5.Solve(step, m_gravity);
m_positionIterationCount = b2Math.b2Max(m_positionIterationCount, b2Island.m_positionIterationCount);
if (m_allowSleep){
_local5.UpdateSleep(_arg1);
};
_local13 = 0;
while (_local13 < _local5.m_bodyCount) {
_local3 = _local5.m_bodies[_local13];
if ((_local3.m_flags & b2Body.e_staticFlag)){
_local3.m_flags = (_local3.m_flags & ~(b2Body.e_islandFlag));
};
if (((_local3.IsFrozen()) && (m_listener))){
_local16 = m_listener.NotifyBoundaryViolated(_local3);
if (_local16 == b2WorldListener.b2_destroyBody){
DestroyBody(_local3);
_local3 = null;
_local5.m_bodies[_local13] = null;
};
};
_local13++;
};
};
_local11 = _local11.m_next;
};
m_broadPhase.Commit();
}
}
}//package Box2D.Dynamics
Section 62
//b2WorldListener (Box2D.Dynamics.b2WorldListener)
package Box2D.Dynamics {
import Box2D.Dynamics.Joints.*;
public class b2WorldListener {
public static var b2_freezeBody:uint = 0;
public static var b2_destroyBody:uint = 1;
public function NotifyBoundaryViolated(_arg1:b2Body):uint{
return (b2_freezeBody);
}
public function NotifyJointDestroyed(_arg1:b2Joint):void{
}
}
}//package Box2D.Dynamics
Section 63
//MochiScores (mochi.MochiScores)
package mochi {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi
Section 64
//MochiServices (mochi.MochiServices)
package mochi {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _sendChannel:LocalConnection;
private static var _rcvChannelName:String;
private static var _gatewayURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _startTime:Number;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__mochiservices";
private static var _rcvChannel:LocalConnection;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
public static function get id():String{
return (_id);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function getVersion():String{
return ("1.31");
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
_rcvChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
return (_local2);
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion()});
_rcvChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = this.client._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
_rcvChannel.connect(_rcvChannelName);
trace("connected!");
_connecting = false;
_connected = true;
_listenChannel.close();
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
_rcvChannelName = _arg1;
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var clipname:String;
var f:Function;
var req:URLRequest;
var id = _arg1;
var clip = _arg2;
clipname = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
MochiServices.allowDomains(_gatewayURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
_timer = new Timer(1000, 0);
_startTime = getTimer();
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
f = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest(_gatewayURL);
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_rcvChannel = new LocalConnection();
_rcvChannel.allowDomain("*", "localhost");
_rcvChannel.allowInsecureDomain("*", "localhost");
_rcvChannel.client = _clip;
_clip._nextcallbackID = 0;
_clip._callbacks = {};
listen();
return (_clip);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if ((getTimer() - _startTime) > 10000){
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_timer.stop();
};
}
}
}//package mochi
Section 65
//Settings (obg.Global.Settings)
package obg.Global {
import flash.display.*;
public class Settings {
public static var scene:MovieClip = null;
public static var MapX:Number = 0;
public static var MapY:Number = 0;
public static var ShadowsEnabled:Boolean = true;
public static function getStageWidth(){
return (scene.stage.stageWidth);
}
public static function getStageHeight(){
return (scene.stage.stageHeight);
}
}
}//package obg.Global
Section 66
//UserInput (obg.Input.UserInput)
package obg.Input {
import flash.events.*;
import obg.Global.*;
public class UserInput {
public static var keyPressedCode:Array = new Array(128);
public static var mouseX:Number = 0;
public static var mouseY:Number = 0;
public static var keyCode:Number = 0;
public static var keyDownCode:Array = new Array(128);
public static var mDown:Boolean = false;
public static var mPressed:Boolean = false;
public static var mouseOnStage:Boolean = true;
public static function isMousePressed():Boolean{
var _local1:Boolean;
_local1 = mPressed;
mPressed = false;
return (_local1);
}
public static function mouseUpHandler(_arg1:MouseEvent):void{
mPressed = mDown;
mDown = false;
}
public static function mouseEnterStage(_arg1:Event){
mouseOnStage = true;
}
public static function anyKeyPressed():Boolean{
var _local1:*;
var _local2:*;
_local1 = 0;
while (_local1 < keyPressedCode.length) {
if (keyPressedCode[_local1]){
_local2 = 0;
while (_local2 < keyPressedCode.length) {
keyPressedCode[_local2] = false;
_local2++;
};
return (true);
};
_local1++;
};
return (false);
}
public static function mouseLeftStage(_arg1:Event){
mouseOnStage = false;
mDown = false;
}
public static function SetupEvents(){
Settings.scene.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeftStage);
Settings.scene.stage.addEventListener(MouseEvent.MOUSE_OVER, mouseEnterStage);
}
public static function keyUpHandler(_arg1:KeyboardEvent):void{
keyPressedCode[_arg1.keyCode] = true;
keyDownCode[_arg1.keyCode] = false;
}
public static function mouseMoving(_arg1:MouseEvent){
mouseX = _arg1.stageX;
mouseY = _arg1.stageY;
}
public static function mouseDownHandler(_arg1:MouseEvent):void{
mDown = true;
}
public static function keyDownHandler(_arg1:KeyboardEvent):void{
keyDownCode[_arg1.keyCode] = true;
}
public static function getKeyCode():Number{
var _local1:Number;
_local1 = keyCode;
keyCode = 0;
return (_local1);
}
public static function getKeyPressed(_arg1:Number):Boolean{
var _local2:Boolean;
_local2 = keyPressedCode[_arg1];
keyPressedCode[_arg1] = false;
return (_local2);
}
public static function resetInput(){
var _local1:*;
_local1 = 0;
while (_local1 < keyDownCode.length) {
keyDownCode[_local1] = false;
keyPressedCode[_local1] = false;
_local1++;
};
mDown = false;
mPressed = false;
keyCode = 0;
}
public static function resetKeysPressed(){
var _local1:*;
_local1 = 0;
while (_local1 < keyDownCode.length) {
keyPressedCode[_local1] = false;
_local1++;
};
}
}
}//package obg.Input
Section 67
//MessageText_85 (RedneckOlympics_fla.MessageText_85)
package RedneckOlympics_fla {
import flash.display.*;
import flash.text.*;
public dynamic class MessageText_85 extends MovieClip {
public var Text:TextField;
}
}//package RedneckOlympics_fla
Section 68
//OverallAnimation_2 (RedneckOlympics_fla.OverallAnimation_2)
package RedneckOlympics_fla {
import flash.display.*;
public dynamic class OverallAnimation_2 extends MovieClip {
public var BeeLogo:MovieClip;
public var OBGLogo:MovieClip;
public function OverallAnimation_2(){
addFrameScript(59, frame60);
}
function frame60(){
stop();
}
}
}//package RedneckOlympics_fla
Section 69
//SlideOut_76 (RedneckOlympics_fla.SlideOut_76)
package RedneckOlympics_fla {
import flash.display.*;
public dynamic class SlideOut_76 extends MovieClip {
public var HSHT:MovieClip;
public var HSPS:MovieClip;
public var HSAE:MovieClip;
public var HSDown:MovieClip;
public var HSCC:MovieClip;
}
}//package RedneckOlympics_fla
Section 70
//BackHogLeg (BackHogLeg)
package {
import flash.display.*;
public dynamic class BackHogLeg extends MovieClip {
}
}//package
Section 71
//Barn (Barn)
package {
import flash.display.*;
public dynamic class Barn extends MovieClip {
}
}//package
Section 72
//BoxBody (BoxBody)
package {
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
class BoxBody {
var staticMC:CMovieClip;
var staticBody:b2BodyDef;
var worldBody:b2Body;
var locRot:Number;
var id:Number;
function BoxBody(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:String, _arg6:Number=0xFFFFFF, _arg7:Number=0xFFFFFF, _arg8:Number=0, _arg9:Number=0){
var _local10:b2BoxDef;
super();
id = _arg1;
staticMC = new CMovieClip(_arg5);
staticMC.AddToScene();
_local10 = new b2BoxDef();
staticBody = new b2BodyDef();
_local10.extents.Set(((staticMC.GetWidth() / 2) / MainGame.m_physScale), ((staticMC.GetHeight() / 2) / MainGame.m_physScale));
_local10.restitution = _arg9;
_local10.friction = 2;
_local10.density = _arg4;
_local10.maskBits = _arg6;
_local10.categoryBits = _arg7;
_local10.localRotation = _arg8;
locRot = ((_arg8 * 180) / Math.PI);
staticBody.AddShape(_local10);
staticBody.position.Set((_arg2 / MainGame.m_physScale), (_arg3 / MainGame.m_physScale));
worldBody = MainGame.m_world.CreateBody(staticBody);
worldBody.m_userData = id;
}
public function Update(_arg1:Number){
var _local2:Number;
var _local3:Number;
_local2 = CCamera.GetPixelX();
_local3 = CCamera.GetPixelY();
staticMC.SetPos(((worldBody.m_position.x * MainGame.m_physScale) - _local2), ((worldBody.m_position.y * MainGame.m_physScale) - _local3));
staticMC.SetRot((((worldBody.m_rotation * 180) / Math.PI) + locRot));
}
public function destroy(){
MainGame.m_world.DestroyBody(worldBody);
staticMC.RemoveFromScene();
}
}
}//package
Section 73
//Car1 (Car1)
package {
import flash.display.*;
public dynamic class Car1 extends MovieClip {
}
}//package
Section 74
//CarCrush1 (CarCrush1)
package {
import flash.media.*;
public dynamic class CarCrush1 extends Sound {
}
}//package
Section 75
//CarCrush2 (CarCrush2)
package {
import flash.media.*;
public dynamic class CarCrush2 extends Sound {
}
}//package
Section 76
//CarCrushinHelp (CarCrushinHelp)
package {
import flash.display.*;
public dynamic class CarCrushinHelp extends MovieClip {
}
}//package
Section 77
//CCamera (CCamera)
package {
import Box2D.Dynamics.*;
import flash.geom.*;
public class CCamera {
public static var bLockX:Boolean = false;
public static var bLockY:Boolean = false;
public static var target:b2Body = null;
public static var pos:Point = new Point(0, 0);
public static var lastPos:Point = new Point(0, 0);
public static var centerX:Number = (320 / MainGame.m_physScale);
public static var centerY:Number = (240 / MainGame.m_physScale);
public static var curr:Point = new Point(0, 0);
public static function UnlockXPos(){
bLockX = false;
}
public static function SetPixelPos(_arg1:Number, _arg2:Number){
pos.x = (_arg1 / MainGame.m_physScale);
pos.y = (_arg2 / MainGame.m_physScale);
}
public static function LockPixelXPos(_arg1:Number){
bLockX = true;
pos.x = (_arg1 / MainGame.m_physScale);
lastPos.x = pos.x;
}
public static function SetCenterPos(_arg1:Number, _arg2:Number){
centerX = (_arg1 / MainGame.m_physScale);
centerY = (_arg2 / MainGame.m_physScale);
}
public static function UnlockYPos(){
bLockY = false;
}
public static function GetLastPixelX():Number{
return (((lastPos.x * MainGame.m_physScale) - 320));
}
public static function GetLastPixelY():Number{
return ((lastPos.y * MainGame.m_physScale));
}
public static function GetY():Number{
return ((pos.y - centerY));
}
public static function GetLastX():Number{
return (lastPos.x);
}
public static function SetMeterPos(_arg1:Number, _arg2:Number){
pos.x = _arg1;
pos.y = _arg2;
}
public static function GetPixelX():Number{
return (((pos.x * MainGame.m_physScale) - (centerX * MainGame.m_physScale)));
}
public static function GetPixelY():Number{
return (((pos.y * MainGame.m_physScale) - (centerY * MainGame.m_physScale)));
}
public static function GetX():Number{
return ((pos.x - centerX));
}
public static function SetTarget(_arg1:b2Body){
target = _arg1;
}
public static function GetLastY():Number{
return (lastPos.y);
}
public static function LockPixelYPos(_arg1:Number){
bLockY = true;
pos.y = (_arg1 / MainGame.m_physScale);
lastPos.y = pos.y;
}
public static function Update(_arg1:Number){
var _local2:Number;
var _local3:Number;
if (target != null){
lastPos.x = pos.x;
lastPos.y = pos.y;
_local2 = (Math.abs((target.m_position.x - curr.x)) * 25);
_local3 = (Math.abs((target.m_position.y - curr.y)) * 25);
if (!bLockX){
curr.x = target.m_position.x;
pos.x = curr.x;
};
if (!bLockY){
curr.y = target.m_position.y;
pos.y = curr.y;
};
};
}
public static function ResetAll(){
pos.x = 0;
pos.y = 0;
curr.x = 0;
curr.y = 0;
target = null;
lastPos.x = 0;
lastPos.y = 0;
bLockY = false;
bLockX = false;
centerX = (320 / MainGame.m_physScale);
centerY = (240 / MainGame.m_physScale);
}
}
}//package
Section 78
//CCar (CCar)
package {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
class CCar {
var worldCar:b2Body;
var crushedVerts:Array;
var normalBody:b2BodyDef;
var crushCount:Number;
var crushedMC:CMovieClip;
var normalVerts:Array;
var crushedBody:b2BodyDef;
var normalMC:CMovieClip;
function CCar(_arg1:Number, _arg2:Number, _arg3:String, _arg4:String, _arg5:Number){
var _local6:Number;
var _local7:b2PolyDef;
super();
_local6 = 0;
crushedVerts = new Array(40.5, 12, -41.5, 12, -34.5, -2, -22, -6, 22.5, -6, 34, -4.5);
normalVerts = new Array(-42, 10, -30, -3, -12, -16, 12, -16, 25, -7, 37, 9);
crushedMC = new CMovieClip(_arg4);
normalMC = new CMovieClip(_arg3);
normalMC.AddToScene();
crushCount = _arg5;
_local7 = new b2PolyDef();
normalBody = new b2BodyDef();
crushedBody = new b2BodyDef();
_local7.vertexCount = (normalVerts.length / 2);
_local6 = 0;
while (_local6 < _local7.vertexCount) {
_local7.vertices[_local6].Set((normalVerts[(_local6 * 2)] / MainGame.m_physScale), (normalVerts[((_local6 * 2) + 1)] / MainGame.m_physScale));
_local6++;
};
_local7.friction = 5;
_local7.density = 9;
normalBody.AddShape(_local7);
normalBody.position.Set((_arg1 / MainGame.m_physScale), (_arg2 / MainGame.m_physScale));
worldCar = MainGame.m_world.CreateBody(normalBody);
_local7.vertexCount = (crushedVerts.length / 2);
_local6 = 0;
while (_local6 < _local7.vertexCount) {
_local7.vertices[_local6].Set((crushedVerts[(_local6 * 2)] / MainGame.m_physScale), (crushedVerts[((_local6 * 2) + 1)] / MainGame.m_physScale));
_local6++;
};
_local7.friction = 5;
_local7.density = 9;
crushedBody.AddShape(_local7);
crushedBody.position.Set((_arg1 / MainGame.m_physScale), (_arg2 / MainGame.m_physScale));
}
public function Update(_arg1:Number){
var _local2:Number;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
_local2 = CCamera.GetPixelX();
_local3 = CCamera.GetPixelY();
_local4 = false;
crushedMC.SetPos(((worldCar.m_position.x * MainGame.m_physScale) - _local2), ((worldCar.m_position.y * MainGame.m_physScale) - _local3));
if (normalMC != null){
normalMC.SetPos(crushedMC.GetX(), crushedMC.GetY());
};
crushedMC.SetRot(((worldCar.m_rotation * 180) / Math.PI));
if (normalMC != null){
normalMC.SetRot(crushedMC.GetRot());
};
_local5 = (0.1 * ((1 / _arg1) / 120));
if (crushCount > 0){
if (Math.sqrt(((worldCar.m_linearVelocity.x * worldCar.m_linearVelocity.x) + (worldCar.m_linearVelocity.y * worldCar.m_linearVelocity.y))) >= _local5){
crushCount--;
if (crushCount <= 0){
_local6 = worldCar.m_position.x;
_local7 = worldCar.m_position.y;
_local8 = worldCar.m_rotation;
_local9 = worldCar.m_linearVelocity.x;
_local10 = worldCar.m_linearVelocity.y;
normalMC.Destroy();
normalMC = null;
crushedMC.AddToScene();
MainGame.m_world.DestroyBody(worldCar);
worldCar = MainGame.m_world.CreateBody(crushedBody);
worldCar.m_position.x = _local6;
worldCar.m_position.y = _local7;
worldCar.m_rotation = _local8;
worldCar.m_linearVelocity.x = _local9;
worldCar.m_linearVelocity.y = _local10;
_local4 = true;
};
};
};
return (_local4);
}
public function destroy(){
normalBody = null;
crushedBody = null;
if (normalMC != null){
normalMC.Destroy();
normalMC = null;
crushedMC = null;
} else {
crushedMC.Destroy();
crushedMC = null;
};
crushedVerts.splice(0, crushedVerts.length);
normalVerts.splice(0, normalVerts.length);
MainGame.m_world.DestroyBody(worldCar);
}
}
}//package
Section 79
//Cloud1 (Cloud1)
package {
import flash.display.*;
public dynamic class Cloud1 extends MovieClip {
}
}//package
Section 80
//CMonsterTruck (CMonsterTruck)
package {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import obg.Global.*;
import obg.Input.*;
public class CMonsterTruck {
var rAxleBody:b2Body;
var rWheel:CMovieClip;
var time:Number;
var fWheel:CMovieClip;
var angleStart:Number;
var bGameOverStart:Boolean;
var playAccelSound:Boolean;
private var rotBonus:Number;
var chassisBody:b2Body;
var bCountRotations:Boolean;
var fAxleBody:b2Body;
var frontShockMotor:b2PrismaticJoint;
var rearShockMotor:b2PrismaticJoint;
var vBody:CMovieClip;
public function CMonsterTruck(_arg1:Number, _arg2:Number){
var _local3:b2BodyDef;
var _local4:b2Body;
var _local5:b2CircleDef;
var _local6:b2BoxDef;
var _local7:b2PrismaticJointDef;
super();
playAccelSound = true;
bGameOverStart = false;
time = 0;
_local5 = new b2CircleDef();
_local6 = new b2BoxDef();
_local7 = new b2PrismaticJointDef();
rWheel = new CMovieClip("Tire");
fWheel = new CMovieClip("Tire");
vBody = new CMovieClip("MonsterTruck");
_local6.extents.Set(2.15, 0.57);
_local6.friction = 0.3;
_local6.density = 8;
_local6.localPosition.Set(0, 0);
_local3 = new b2BodyDef();
_local3.AddShape(_local6);
_local3.position.Set((_arg1 / MainGame.m_physScale), (_arg2 / MainGame.m_physScale));
_local3.angularDamping = 0.11;
_local3.linearDamping = 0.0075;
chassisBody = MainGame.m_world.CreateBody(_local3);
_local5.radius = 0.8;
_local5.density = 12;
_local5.friction = 0;
_local5.restitution = 0.05;
_local3 = new b2BodyDef();
_local3.AddShape(_local5);
_local3.position.Set(((_arg1 - 36) / MainGame.m_physScale), ((_arg2 + 33) / MainGame.m_physScale));
rAxleBody = MainGame.m_world.CreateBody(_local3);
_local7.anchorPoint.Set(((_arg1 - 36) / MainGame.m_physScale), ((_arg2 + 33) / MainGame.m_physScale));
_local7.axis.Set(0.05, 0.95);
_local7.lowerTranslation = -0.145;
_local7.upperTranslation = 0.14;
_local7.enableLimit = true;
_local7.motorForce = 1;
_local7.motorSpeed = 0;
_local7.enableMotor = true;
_local7.body1 = chassisBody;
_local7.body2 = rAxleBody;
rearShockMotor = (MainGame.m_world.CreateJoint(_local7) as b2PrismaticJoint);
_local5.density = 16.5;
_local3 = new b2BodyDef();
_local3.AddShape(_local5);
_local3.position.Set(((_arg1 + 40) / MainGame.m_physScale), ((_arg2 + 33) / MainGame.m_physScale));
fAxleBody = MainGame.m_world.CreateBody(_local3);
_local7.anchorPoint.Set(((_arg1 + 40) / MainGame.m_physScale), ((_arg2 + 33) / MainGame.m_physScale));
_local7.body1 = chassisBody;
_local7.body2 = fAxleBody;
frontShockMotor = (MainGame.m_world.CreateJoint(_local7) as b2PrismaticJoint);
rearShockMotor.SetMotorForce(-1000);
frontShockMotor.SetMotorForce(-1000);
vBody.AddToScene();
rWheel.AddToScene();
fWheel.AddToScene();
rotBonus = 0;
}
public function GetX():Number{
return (chassisBody.m_position.x);
}
public function GetY():Number{
return (chassisBody.m_position.y);
}
public function Update(_arg1:Number):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Boolean;
var _local8:Number;
var _local9:Boolean;
var _local10:Number;
var _local11:Number;
var _local12:Number;
_local5 = CCamera.GetPixelX();
_local6 = CCamera.GetPixelY();
rWheel.SetPos(((rAxleBody.m_position.x * MainGame.m_physScale) - _local5), ((rAxleBody.m_position.y * MainGame.m_physScale) - _local6));
fWheel.SetPos(((fAxleBody.m_position.x * MainGame.m_physScale) - _local5), ((fAxleBody.m_position.y * MainGame.m_physScale) - _local6));
vBody.SetPos(((chassisBody.m_position.x * MainGame.m_physScale) - _local5), ((chassisBody.m_position.y * MainGame.m_physScale) - _local6));
vBody.SetRot(((chassisBody.m_rotation * 180) / Math.PI));
_local7 = false;
if (rAxleBody.m_contactList != null){
_local7 = true;
};
if (chassisBody.m_linearVelocity.x > 30){
chassisBody.m_linearVelocity.x = 30;
};
if (chassisBody.m_linearVelocity.x < -25){
chassisBody.m_linearVelocity.x = -25;
};
_local8 = (((((chassisBody.m_linearVelocity.x * _arg1) / ((0.75 * Math.PI) * 2)) * 180) / Math.PI) * (Math.PI * 2));
rWheel.AddRot(_local8);
fWheel.AddRot(_local8);
_local9 = ((_local7) && (!((fAxleBody.m_contactList == null))));
if (((((!(_local7)) && ((fAxleBody.m_contactList == null)))) || ((((chassisBody.m_linearVelocity.x < 0.5)) && (((!(_local7)) || ((fAxleBody.m_contactList == null)))))))){
_local10 = 10500;
if (chassisBody.m_contactList != null){
_local10 = 12500;
};
if (UserInput.keyDownCode[39]){
_local11 = (_local10 * (120 / (1 / _arg1)));
chassisBody.ApplyTorque(_local11);
};
if (UserInput.keyDownCode[37]){
_local11 = (_local10 * (120 / (1 / _arg1)));
chassisBody.ApplyTorque(-(_local11));
};
if (chassisBody.m_contactList == null){
if (!bCountRotations){
bCountRotations = true;
angleStart = chassisBody.m_rotation;
};
_local12 = Math.abs((chassisBody.m_rotation - angleStart));
if (_local12 >= (Math.PI * 1.6)){
_local12 = 0;
angleStart = chassisBody.m_rotation;
rotBonus++;
};
} else {
bCountRotations = false;
};
} else {
bCountRotations = false;
};
if (chassisBody.m_position.x < 436){
if (!UserInput.keyDownCode[38]){
playAccelSound = true;
if (Settings.scene.GameObject.soundEffect[MainGame.SFX_ENGINEACCEL]){
if (Settings.scene.GameObject.soundEffect[MainGame.SFX_ENGINEACCEL].bPlaying){
Settings.scene.GameObject.soundEffect[MainGame.SFX_ENGINEACCEL].fadeOut(0.3);
};
};
};
if (((UserInput.keyDownCode[38]) && (_local7))){
if (playAccelSound){
Settings.scene.GameObject.soundEffect[MainGame.SFX_ENGINEACCEL].play(0, MainGame.sfxVol);
playAccelSound = false;
};
fAxleBody.WakeUp();
_local11 = (4200 * (120 / (1 / _arg1)));
if (_local9){
_local3 = (Math.cos(chassisBody.m_rotation) * _local11);
_local4 = (Math.sin(chassisBody.m_rotation) * _local11);
fAxleBody.ApplyForce(new b2Vec2(_local3, _local4), fAxleBody.GetCenterPosition());
} else {
fAxleBody.ApplyForce(new b2Vec2(_local11, 0), fAxleBody.GetCenterPosition());
};
} else {
if (((UserInput.keyDownCode[40]) && (_local7))){
rAxleBody.WakeUp();
_local11 = (-4000 * (120 / (1 / _arg1)));
if (_local9){
_local3 = (Math.cos(chassisBody.m_rotation) * _local11);
_local4 = (Math.sin(chassisBody.m_rotation) * _local11);
rAxleBody.ApplyForce(new b2Vec2(_local3, _local4), rAxleBody.GetCenterPosition());
} else {
rAxleBody.ApplyForce(new b2Vec2(_local11, 0), rAxleBody.GetCenterPosition());
};
};
};
} else {
if (chassisBody.m_linearVelocity.x > 0){
rAxleBody.WakeUp();
_local11 = (6500 * (120 / (1 / _arg1)));
rAxleBody.ApplyForce(new b2Vec2(-(_local11), 0), rAxleBody.GetCenterPosition());
if (!bGameOverStart){
bGameOverStart = true;
time = 0;
};
};
};
if (bGameOverStart){
time = (time + _arg1);
};
if (((bGameOverStart) && ((time >= 1)))){
return (true);
};
if ((((chassisBody.m_position.x < -3)) && ((chassisBody.m_linearVelocity.x < 0)))){
rAxleBody.WakeUp();
rAxleBody.ApplyForce(new b2Vec2(10500, 0), rAxleBody.GetCenterPosition());
};
return (false);
}
public function GetRotBonus():Number{
var _local1:Number;
_local1 = rotBonus;
rotBonus = 0;
return (_local1);
}
public function destroy(){
rWheel.Destroy();
fWheel.Destroy();
vBody.Destroy();
MainGame.m_world.DestroyJoint(rearShockMotor);
MainGame.m_world.DestroyJoint(frontShockMotor);
MainGame.m_world.DestroyBody(chassisBody);
MainGame.m_world.DestroyBody(rAxleBody);
MainGame.m_world.DestroyBody(fAxleBody);
}
}
}//package
Section 81
//CMovieClip (CMovieClip)
package {
import flash.display.*;
import flash.events.*;
import obg.Global.*;
import flash.utils.*;
class CMovieClip {
var rot:Number;
var mc:MovieClip;
function CMovieClip(_arg1:String){
var _local2:Object;
super();
_local2 = getDefinitionByName(_arg1);
mc = new (_local2);
mc.x = -1000;
mc.y = -1000;
mc.cacheAsBitmap = true;
mc.stageFocusRect = false;
rot = 0;
}
public function IsVisible():Boolean{
return (mc.visible);
}
public function AddToScene(){
Settings.scene.addChild(mc);
}
public function GetFade():Number{
return (mc.alpha);
}
public function AddRot(_arg1:Number){
rot = (rot + _arg1);
SetRot(rot);
}
public function GetRot():Number{
return (mc.rotation);
}
public function Destroy(){
RemoveFromScene();
mc = null;
}
public function SetX(_arg1:Number){
mc.x = _arg1;
}
public function SetFade(_arg1:Number){
if (mc.alpha != _arg1){
mc.alpha = _arg1;
if (mc.alpha > 1){
mc.alpha = 1;
};
if (mc.alpha < 0){
mc.alpha = 0;
};
};
}
public function Hide(){
mc.visible = false;
}
public function GetY():Number{
return (mc.y);
}
public function Show(){
mc.visible = true;
}
public function SetY(_arg1:Number){
mc.y = _arg1;
}
public function SetScale(_arg1:Number, _arg2:Number){
if (mc.scaleX != _arg1){
mc.scaleX = _arg1;
};
if (mc.scaleY != _arg2){
mc.scaleY = _arg2;
};
}
public function GetX():Number{
return (mc.x);
}
public function SetMouseCallBacks(_arg1:Function, _arg2:Function, _arg3:Function){
mc.useHandCursor = true;
mc.buttonMode = true;
if (_arg1 != null){
mc.addEventListener(MouseEvent.MOUSE_OVER, _arg1);
};
if (_arg2 != null){
mc.addEventListener(MouseEvent.MOUSE_OUT, _arg2);
};
if (_arg3 != null){
mc.addEventListener(MouseEvent.CLICK, _arg3);
};
}
public function GetWidth():Number{
return (mc.width);
}
public function SetPos(_arg1:Number, _arg2:Number){
mc.x = _arg1;
mc.y = _arg2;
}
public function SetRot(_arg1:Number){
rot = _arg1;
if (mc.rotation != rot){
mc.rotation = rot;
};
}
public function AddX(_arg1:Number){
mc.x = (mc.x + _arg1);
}
public function AddY(_arg1:Number){
mc.y = (mc.y + _arg1);
}
public function GetHeight():Number{
return (mc.height);
}
public function RemoveFromScene(){
Settings.scene.removeChild(mc);
}
}
}//package
Section 82
//CrossHairs (CrossHairs)
package {
import flash.display.*;
public dynamic class CrossHairs extends MovieClip {
}
}//package
Section 83
//CrushedCar1 (CrushedCar1)
package {
import flash.display.*;
public dynamic class CrushedCar1 extends MovieClip {
}
}//package
Section 84
//CSoundClip (CSoundClip)
package {
import flash.media.*;
import flash.utils.*;
class CSoundClip {
var currVol:Number;
var sound:Sound;
var sc:SoundChannel;
var isMusic:Boolean;
var position:Number;
var bPlaying:Boolean;
var timeStep:Number;
function CSoundClip(_arg1:String, _arg2:Boolean){
var _local3:Object;
super();
_local3 = getDefinitionByName(_arg1);
sound = new (_local3);
sc = null;
timeStep = 0;
isMusic = _arg2;
bPlaying = false;
}
public function fadeInLoop(_arg1:Number, _arg2:Boolean, _arg3:Number){
timeStep = (1 / _arg1);
if (!bPlaying){
loop((_arg2) ? position : 0, 0, _arg3);
};
}
public function fadeIn(_arg1:Number, _arg2:Boolean){
timeStep = (1 / _arg1);
if (!bPlaying){
play((_arg2) ? position : 0, 0);
};
}
public function stop(){
if (sc != null){
position = sc.position;
sc.stop();
};
bPlaying = false;
}
public function fadeOut(_arg1:Number){
timeStep = (-1 / _arg1);
bPlaying = false;
}
public function Destroy(){
stop();
sound = null;
}
public function setVolume(_arg1:Number, _arg2:Boolean){
var _local3:Boolean;
var _local4:SoundTransform;
if (sc == null){
return (false);
};
_local3 = false;
if ((((_arg1 > 1)) || ((_arg1 < 0)))){
_local3 = true;
};
if (_arg1 > 1){
_arg1 = 1;
currVol = 1;
};
if (_arg1 < 0){
_arg1 = 0;
currVol = 0;
};
_local4 = sc.soundTransform;
if (_arg2){
if (isMusic){
_local4.volume = (_arg1 * MainGame.musicVol);
} else {
_local4.volume = (_arg1 * MainGame.sfxVol);
};
} else {
_local4.volume = _arg1;
};
sc.soundTransform = _local4;
return (_local3);
}
public function loop(_arg1:Number, _arg2:Number, _arg3:Number){
sc = sound.play(_arg1, _arg3);
currVol = _arg2;
setVolume(_arg2, false);
bPlaying = true;
}
public function Update(_arg1:Number){
if (timeStep != 0){
currVol = (currVol + (timeStep * _arg1));
if (setVolume(currVol, true)){
if (currVol == 0){
stop();
};
timeStep = 0;
};
};
}
public function play(_arg1:Number, _arg2:Number=1){
sc = sound.play(_arg1);
currVol = _arg2;
setVolume(_arg2, false);
bPlaying = true;
}
}
}//package
Section 85
//Engine (Engine)
package {
import flash.media.*;
public dynamic class Engine extends Sound {
}
}//package
Section 86
//EngineAccel (EngineAccel)
package {
import flash.media.*;
public dynamic class EngineAccel extends Sound {
}
}//package
Section 87
//FadeScreen (FadeScreen)
package {
import flash.display.*;
public dynamic class FadeScreen extends MovieClip {
}
}//package
Section 88
//FenceRepeat1 (FenceRepeat1)
package {
import flash.display.*;
public dynamic class FenceRepeat1 extends MovieClip {
}
}//package
Section 89
//Finish (Finish)
package {
import flash.display.*;
public dynamic class Finish extends MovieClip {
}
}//package
Section 90
//FlipBonus (FlipBonus)
package {
import flash.media.*;
public dynamic class FlipBonus extends Sound {
}
}//package
Section 91
//FrontHogLeg (FrontHogLeg)
package {
import flash.display.*;
public dynamic class FrontHogLeg extends MovieClip {
}
}//package
Section 92
//GameOverBox (GameOverBox)
package {
import flash.display.*;
import flash.text.*;
public dynamic class GameOverBox extends MovieClip {
public var Line1Info:TextField;
public var BottomMessage:TextField;
public var Line5Title:TextField;
public var Line2Title:TextField;
public var BoxTitle:TextField;
public var Line2Info:TextField;
public var SubmitButton:Submit;
public var QuitButton:Quit;
public var Line4Title:TextField;
public var Line4Info:TextField;
public var Line1Title:TextField;
public var PlayAgainButton:PlayAgain;
public var Line3Info:TextField;
public var Line5Info:TextField;
public var Line3Title:TextField;
}
}//package
Section 93
//GHighScoresOff (GHighScoresOff)
package {
import flash.display.*;
public dynamic class GHighScoresOff extends MovieClip {
}
}//package
Section 94
//GHighScoresOn (GHighScoresOn)
package {
import flash.display.*;
public dynamic class GHighScoresOn extends MovieClip {
}
}//package
Section 95
//GMenuOff (GMenuOff)
package {
import flash.display.*;
public dynamic class GMenuOff extends MovieClip {
}
}//package
Section 96
//GMenuOn (GMenuOn)
package {
import flash.display.*;
public dynamic class GMenuOn extends MovieClip {
}
}//package
Section 97
//GNPBody (GNPBody)
package {
import flash.geom.*;
class GNPBody {
var staticMC:CMovieClip;
var pos:Point;
var mScale:Number;
function GNPBody(_arg1:Number, _arg2:Number, _arg3:String){
staticMC = new CMovieClip(_arg3);
staticMC.AddToScene();
pos = new Point((_arg1 / MainGame.m_physScale), (_arg2 / MainGame.m_physScale));
mScale = 1;
}
public function Update(_arg1:Number){
var _local2:Number;
var _local3:Number;
_local2 = (CCamera.GetPixelX() * mScale);
_local3 = (CCamera.GetPixelY() * mScale);
staticMC.SetPos(((pos.x * MainGame.m_physScale) - _local2), ((pos.y * MainGame.m_physScale) - _local3));
}
public function SetMoveScale(_arg1:Number){
mScale = _arg1;
}
public function destroy(){
staticMC.RemoveFromScene();
}
}
}//package
Section 98
//GQuitOff (GQuitOff)
package {
import flash.display.*;
public dynamic class GQuitOff extends MovieClip {
}
}//package
Section 99
//GQuitOn (GQuitOn)
package {
import flash.display.*;
public dynamic class GQuitOn extends MovieClip {
}
}//package
Section 100
//Ground (Ground)
package {
import flash.display.*;
public dynamic class Ground extends MovieClip {
}
}//package
Section 101
//GunShot (GunShot)
package {
import flash.media.*;
public dynamic class GunShot extends Sound {
}
}//package
Section 102
//Hill1 (Hill1)
package {
import flash.display.*;
public dynamic class Hill1 extends MovieClip {
}
}//package
Section 103
//Hog (Hog)
package {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
class Hog {
var hitTime:Number;
var hogParts:Array;
var joint:Array;
var staticBody:b2BodyDef;
var hit:Boolean;
var hitReset:Boolean;
static var HOG_PART:int = 99;
function Hog(_arg1:Number, _arg2:Number){
var _local3:b2RevoluteJointDef;
var _local4:b2Vec2;
super();
hogParts = new Array();
hogParts[0] = new BoxBody(HOG_PART, _arg1, _arg2, 0.75, "HogBody", 1, 65534, 0, 0.25);
hogParts[1] = new BoxBody(HOG_PART, (_arg1 + 21), (_arg2 - 1), 0.3, "HogHead", 1, 65534, 0, 0.25);
hogParts[2] = new BoxBody(HOG_PART, (_arg1 - 14.5), (_arg2 + 8), 0.15, "BackHogLeg", 1, 65534, 0, 0.25);
hogParts[3] = new BoxBody(HOG_PART, (_arg1 + 11), (_arg2 + 8), 0.15, "FrontHogLeg", 1, 65534, 0, 0.25);
hogParts[4] = new BoxBody(HOG_PART, (_arg1 - 21), _arg2, 0.01, "PigTail", 0, 0);
hit = false;
hitReset = true;
hitTime = 0;
joint = new Array();
_local3 = new b2RevoluteJointDef();
_local3.body1 = hogParts[0].worldBody;
_local3.enableLimit = true;
_local4 = new b2Vec2((hogParts[0].worldBody.GetCenterPosition().x + (10 / MainGame.m_physScale)), hogParts[0].worldBody.GetCenterPosition().y);
_local3.anchorPoint = _local4;
_local3.lowerAngle = -0.3;
_local3.upperAngle = 0.3;
_local3.body2 = hogParts[1].worldBody;
_local3.enableLimit = true;
joint[0] = MainGame.m_world.CreateJoint(_local3);
_local4 = new b2Vec2((hogParts[0].worldBody.GetCenterPosition().x - (14.5 / MainGame.m_physScale)), (hogParts[0].worldBody.GetCenterPosition().y + (3 / MainGame.m_physScale)));
_local3.anchorPoint = _local4;
_local3.lowerAngle = -0.5;
_local3.upperAngle = 0.5;
_local3.body2 = hogParts[2].worldBody;
_local3.enableLimit = true;
joint[1] = MainGame.m_world.CreateJoint(_local3);
_local4 = new b2Vec2((hogParts[0].worldBody.GetCenterPosition().x + (11 / MainGame.m_physScale)), (hogParts[0].worldBody.GetCenterPosition().y + (3 / MainGame.m_physScale)));
_local3.anchorPoint = _local4;
_local3.lowerAngle = -0.5;
_local3.upperAngle = 0.5;
_local3.body2 = hogParts[3].worldBody;
_local3.enableLimit = true;
joint[2] = MainGame.m_world.CreateJoint(_local3);
_local4 = new b2Vec2((hogParts[0].worldBody.GetCenterPosition().x - (21 / MainGame.m_physScale)), hogParts[0].worldBody.GetCenterPosition().y);
_local3.anchorPoint = _local4;
_local3.lowerAngle = -0.5;
_local3.upperAngle = 0.5;
_local3.body2 = hogParts[4].worldBody;
_local3.enableLimit = true;
joint[3] = MainGame.m_world.CreateJoint(_local3);
}
public function destroy(){
var _local1:*;
var _local2:*;
_local1 = 0;
while (_local1 < joint.length) {
MainGame.m_world.DestroyJoint(joint[_local1]);
_local1++;
};
joint.splice(0, joint.length);
joint = null;
_local2 = 0;
while (_local2 < hogParts.length) {
hogParts[_local2].destroy();
_local2++;
};
hogParts.splice(0, hogParts.length);
hogParts = null;
}
public function Update(_arg1:Number){
var _local2:Boolean;
var _local3:*;
_local2 = true;
_local3 = 0;
while (_local3 < hogParts.length) {
hogParts[_local3].Update(_arg1);
if (((!((hogParts[_local3].worldBody.m_contactList == null))) && (!((hogParts[_local3].worldBody.m_contactList.other.m_userData == HOG_PART))))){
_local2 = false;
if (hitReset){
hit = true;
hitReset = false;
hitTime = 0.35;
};
};
_local3++;
};
hitTime = (hitTime - _arg1);
if ((((((hitReset == false)) && (_local2))) && ((hitTime <= 0)))){
hitReset = true;
};
}
}
}//package
Section 104
//HogBody (HogBody)
package {
import flash.display.*;
public dynamic class HogBody extends MovieClip {
}
}//package
Section 105
//HogHead (HogHead)
package {
import flash.display.*;
public dynamic class HogHead extends MovieClip {
}
}//package
Section 106
//HogTossBox (HogTossBox)
package {
import flash.display.*;
public dynamic class HogTossBox extends MovieClip {
}
}//package
Section 107
//HogTossHelp (HogTossHelp)
package {
import flash.display.*;
public dynamic class HogTossHelp extends MovieClip {
}
}//package
Section 108
//Jump1 (Jump1)
package {
import flash.display.*;
public dynamic class Jump1 extends MovieClip {
}
}//package
Section 109
//Kicker (Kicker)
package {
import flash.display.*;
public dynamic class Kicker extends MovieClip {
}
}//package
Section 110
//LowTime (LowTime)
package {
import flash.media.*;
public dynamic class LowTime extends Sound {
}
}//package
Section 111
//main (main)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.geom.*;
import obg.Global.*;
import mochi.*;
import flash.net.*;
import flash.utils.*;
import flash.external.*;
public dynamic class main extends MovieClip {
public var BBA:MovieClip;
public var tdt:Number;
public var menuMusic:CSoundClip;
public var OpeningLeaderBoards:Boolean;
public var ButtonPumpkinShoot:MovieClip;
private var RunInit:Boolean;
public var ButtonCarCrushinOn:MovieClip;
public var LogoRad:Number;
public var Intro:MovieClip;
public var bb15:String;
public var ButtonHogTossOn:MovieClip;
public var draggingMusicSlider:Boolean;
public var ButtonMoreGamesOn:MovieClip;
public var ButtonHogToss:MovieClip;
public var ButtonCarCrush:MovieClip;
public var OBG:MovieClip;
public var rollSfx:CSoundClip;
public var ButtonAllEventsOn:MovieClip;
public var ButtonAllEvents:MovieClip;
private var fadeMC:CMovieClip;
public var ButtonMoreGames:MovieClip;
public var draggingSfxSlider:Boolean;
public var MusicSlider:SliderButton;
public var Paused:MovieClip;
public var lpc:TextField;
public var ob15:String;
public var frame:Number;
public var tTime:Number;
public var SkipText:MovieClip;
public var notConnected:Boolean;
public var CopyRight:MovieClip;
public var SfxSlider:SliderButton;
private var frameDest:Number;
public var MessageText:MovieClip;
public var ButtonPumpkinShootOn:MovieClip;
public var waitTime:Number;
public var GameObject:MainGame;
public var SlideOut:MovieClip;
private static var LastTime:Number;
public static var FadeScreenOut:Boolean;
public static var FadeScreenIn:Boolean;
private static var dt:Number;
private static var Time:Number;
public function main(){
addFrameScript(0, frame1, 1, frame2, 4, frame5, 9, frame10, 14, frame15);
stage.showDefaultContextMenu = false;
RunInit = true;
Init();
menuMusic = null;
rollSfx = null;
OpeningLeaderBoards = false;
}
private function UpdateFrame(_arg1:Event):void{
UpdateTimer();
if ((((currentFrame == 2)) && (RunInit))){
RunInit = false;
InitResources();
};
if (menuMusic != null){
menuMusic.Update(dt);
};
if (currentFrame == 5){
GameObject.Update(dt, mouseX, mouseY);
};
if (((FadeScreenIn) || (FadeScreenOut))){
UpdateFade();
};
}
public function displayHSPS(_arg1:MouseEvent){
Settings.scene.OpeningLeaderBoards = true;
MochiScores.showLeaderboard({boardID:"cf1dda93c80dc3e8", onClose:closeLB});
}
public function mouseMove(_arg1:MouseEvent){
var _local2:Number;
_local2 = Settings.scene.stage.mouseX;
if (SfxSlider.visible){
if (_local2 < 504){
_local2 = 504;
};
if (_local2 > 628){
_local2 = 628;
};
if (draggingMusicSlider){
MusicSlider.x = _local2;
MainGame.musicVol = ((_local2 - 504) / 130);
Settings.scene.menuMusic.setVolume(MainGame.musicVol, false);
};
if (draggingSfxSlider){
SfxSlider.x = _local2;
MainGame.sfxVol = ((_local2 - 504) / 130);
};
};
if (Settings.scene.stage.mouseX < (640 - 174)){
SlideOut.x = 620;
MusicSlider.visible = false;
SfxSlider.visible = false;
};
}
public function mouseUp(_arg1:MouseEvent){
draggingMusicSlider = false;
draggingSfxSlider = false;
}
public function SetupFadeOut(_arg1:Number):void{
frameDest = _arg1;
FadeScreenOut = true;
FadeScreenIn = false;
fadeMC.SetPos(0, 0);
fadeMC.SetFade(1);
if (Settings.scene.getChildIndex(fadeMC.mc) != (Settings.scene.numChildren - 1)){
Settings.scene.setChildIndex(fadeMC.mc, (Settings.scene.numChildren - 1));
};
UpdateTimer();
UpdateTimer();
}
public function displayHSAE(_arg1:MouseEvent){
Settings.scene.OpeningLeaderBoards = true;
MochiScores.showLeaderboard({boardID:"f50b592eeda563b9", onClose:closeLB});
}
public function onRollOver3(_arg1:MouseEvent){
ButtonHogTossOn.visible = true;
Settings.scene.rollSfx.play(0, MainGame.sfxVol);
}
public function onRollOver4(_arg1:MouseEvent){
ButtonPumpkinShootOn.visible = true;
Settings.scene.rollSfx.play(0, MainGame.sfxVol);
}
public function onRollOver5(_arg1:MouseEvent){
ButtonMoreGamesOn.visible = true;
Settings.scene.rollSfx.play(0, MainGame.sfxVol);
}
public function onRollOver1(_arg1:MouseEvent){
ButtonAllEventsOn.visible = true;
Settings.scene.rollSfx.play(0, MainGame.sfxVol);
}
function frame15(){
ob15 = DeEcho("12C61EC2E481D9C921C9D8C10DB70BC00CC40FB724B711B317B71D800DC117");
bb15 = DeEcho("12C61EC2E481D9C921C9D8B41FC523B40FB70BC40DB30EB7D8B519BF");
BBA.addEventListener(MouseEvent.CLICK, clickBBA15);
OBG.addEventListener(MouseEvent.CLICK, clickOBG15);
BBA.addEventListener(MouseEvent.MOUSE_OVER, overBBA15);
OBG.addEventListener(MouseEvent.MOUSE_OVER, overOBG15);
BBA.useHandCursor = true;
BBA.buttonMode = true;
OBG.useHandCursor = true;
OBG.buttonMode = true;
CopyRight.selectable = false;
MessageText.Text.selectable = false;
}
function frame10(){
stop();
Settings.scene.InitMenuSounds();
ButtonAllEventsOn.visible = false;
ButtonCarCrushinOn.visible = false;
ButtonHogTossOn.visible = false;
ButtonPumpkinShootOn.visible = false;
ButtonMoreGamesOn.visible = false;
draggingSfxSlider = false;
draggingMusicSlider = false;
SetAsButton(MusicSlider);
SetAsButton(SfxSlider);
SetAsButton(SlideOut.HSAE);
SetAsButton(SlideOut.HSCC);
SetAsButton(SlideOut.HSHT);
SetAsButton(SlideOut.HSPS);
SetAsButton(ButtonAllEventsOn);
SetAsButton(ButtonAllEvents);
SetAsButton(ButtonCarCrush);
SetAsButton(ButtonCarCrushinOn);
SetAsButton(ButtonHogToss);
SetAsButton(ButtonHogTossOn);
SetAsButton(ButtonPumpkinShoot);
SetAsButton(ButtonPumpkinShootOn);
SetAsButton(ButtonMoreGames);
SetAsButton(ButtonMoreGamesOn);
if (!Settings.scene.notConnected){
SlideOut.HSDown.visible = false;
SlideOut.HSAE.visible = true;
SlideOut.HSCC.visible = true;
SlideOut.HSHT.visible = true;
SlideOut.HSPS.visible = true;
} else {
SlideOut.HSDown.visible = true;
SlideOut.HSAE.visible = false;
SlideOut.HSCC.visible = false;
SlideOut.HSHT.visible = false;
SlideOut.HSPS.visible = false;
};
addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
addEventListener(MouseEvent.MOUSE_UP, mouseUp);
Settings.scene.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeave);
MusicSlider.addEventListener(MouseEvent.MOUSE_DOWN, grabMusicSlider);
SfxSlider.addEventListener(MouseEvent.MOUSE_DOWN, grabSfxSlider);
SlideOut.HSAE.addEventListener(MouseEvent.CLICK, displayHSAE);
SlideOut.HSCC.addEventListener(MouseEvent.CLICK, displayHSCC);
SlideOut.HSHT.addEventListener(MouseEvent.CLICK, displayHSHT);
SlideOut.HSPS.addEventListener(MouseEvent.CLICK, displayHSPS);
SlideOut.addEventListener(MouseEvent.MOUSE_OVER, onSlideOutOver);
ButtonAllEvents.addEventListener(MouseEvent.MOUSE_OVER, onRollOver1);
ButtonAllEventsOn.addEventListener(MouseEvent.MOUSE_OUT, onRollOut1);
ButtonAllEventsOn.addEventListener(MouseEvent.CLICK, startAllEvents);
ButtonCarCrush.addEventListener(MouseEvent.MOUSE_OVER, onRollOver2);
ButtonCarCrushinOn.addEventListener(MouseEvent.MOUSE_OUT, onRollOut2);
ButtonCarCrushinOn.addEventListener(MouseEvent.CLICK, startCarCrushin);
ButtonHogToss.addEventListener(MouseEvent.MOUSE_OVER, onRollOver3);
ButtonHogTossOn.addEventListener(MouseEvent.MOUSE_OUT, onRollOut3);
ButtonHogTossOn.addEventListener(MouseEvent.CLICK, startHogToss);
ButtonPumpkinShoot.addEventListener(MouseEvent.MOUSE_OVER, onRollOver4);
ButtonPumpkinShootOn.addEventListener(MouseEvent.MOUSE_OUT, onRollOut4);
ButtonPumpkinShootOn.addEventListener(MouseEvent.CLICK, startPumpkinShoot);
ButtonMoreGames.addEventListener(MouseEvent.MOUSE_OVER, onRollOver5);
ButtonMoreGamesOn.addEventListener(MouseEvent.MOUSE_OUT, onRollOut5);
ButtonMoreGamesOn.addEventListener(MouseEvent.CLICK, visitSponsor);
}
function frame2(){
stop();
tdt = 0;
tTime = 0;
frame = 0;
waitTime = 8;
LogoRad = 0;
SkipText.alpha = 0;
SkipText.visible = false;
Intro.OBGLogo.addEventListener(MouseEvent.CLICK, clickOBG2);
Intro.BeeLogo.addEventListener(MouseEvent.CLICK, clickBBA2);
Intro.OBGLogo.useHandCursor = true;
Intro.OBGLogo.buttonMode = true;
Intro.BeeLogo.useHandCursor = true;
Intro.BeeLogo.buttonMode = true;
SkipText.addEventListener(MouseEvent.CLICK, clickSkip);
SkipText.useHandCursor = true;
SkipText.buttonMode = true;
this.addEventListener("enterFrame", onEnterFrame);
}
public function SetAsButton(_arg1:MovieClip){
_arg1.useHandCursor = true;
_arg1.buttonMode = true;
}
function frame5(){
Paused.visible = false;
stop();
}
public function displayHSCC(_arg1:MouseEvent){
Settings.scene.OpeningLeaderBoards = true;
MochiScores.showLeaderboard({boardID:"f3c941a135f304a0", onClose:closeLB});
}
public function onRollOver2(_arg1:MouseEvent){
ButtonCarCrushinOn.visible = true;
Settings.scene.rollSfx.play(0, MainGame.sfxVol);
}
function frame1(){
stop();
MochiServices.connect("0ba6c9025737d807", root, ErrorConnecting);
MochiAd.showPreGameAd({clip:root, id:"0ba6c9025737d807", res:"640x480"});
MochiBot.track(this, "bfa60726");
notConnected = false;
}
public function startCarCrushin(_arg1:MouseEvent){
if (!Settings.scene.OpeningLeaderBoards){
MainGame.StartNewGame = true;
MainGame.StartGameID = MainGame.CARCRUSH;
DoSetupFadeIn();
};
}
public function onEnterFrame(_arg1:Event){
var _local2:Number;
_local2 = getTimer();
tdt = ((_local2 - tTime) / 1000);
if (tTime == 0){
tdt = 0;
};
tTime = _local2;
waitTime = (waitTime - tdt);
if (waitTime <= 0){
clickSkip(null);
return;
};
if (waitTime < 6){
SkipText.visible = true;
SkipText.alpha = (SkipText.alpha + (tdt * 2));
if (SkipText.alpha > 1){
SkipText.alpha = 1;
};
};
}
public function ErrorConnecting(_arg1:String){
notConnected = true;
}
public function InitMenuSounds():void{
if (menuMusic == null){
menuMusic = new CSoundClip("MenuMusic", true);
menuMusic.fadeInLoop(1, false, 99999);
};
if (rollSfx == null){
rollSfx = new CSoundClip("RollOver", false);
};
}
private function InitResources():void{
Settings.scene = this;
GameObject = new MainGame();
}
public function grabSfxSlider(_arg1:MouseEvent){
if (!draggingMusicSlider){
draggingSfxSlider = true;
};
}
public function UpdateFade():void{
var _local1:DisplayObject;
if (fadeMC != null){
if ((1 / dt) < 30){
dt = (1 / 30);
};
if (FadeScreenOut){
fadeMC.SetFade((fadeMC.GetFade() - (dt * 4)));
if (fadeMC.GetFade() <= 0){
Settings.scene.swapChildren(fadeMC.mc, GameObject.gButtons[5].mc);
fadeMC.RemoveFromScene();
fadeMC = null;
FadeScreenOut = false;
};
} else {
if (FadeScreenIn){
fadeMC.SetFade((fadeMC.GetFade() + (dt * 4)));
if (fadeMC.GetFade() >= 1){
FadeScreenIn = false;
if (frameDest != -1){
if (GameObject.FromGameDestroy){
GameObject.Destroy(true);
GameObject.FromGameDestroy = false;
};
this.gotoAndStop(frameDest);
SetupFadeOut(frameDest);
};
};
};
};
if (fadeMC != null){
if (Settings.scene.getChildIndex(fadeMC.mc) != (Settings.scene.numChildren - 1)){
_local1 = Settings.scene.getChildAt((Settings.scene.numChildren - 1));
Settings.scene.swapChildren(_local1, fadeMC.mc);
};
};
};
}
public function mouseLeave(_arg1:Event){
draggingMusicSlider = false;
draggingSfxSlider = false;
}
public function displayHSHT(_arg1:MouseEvent){
Settings.scene.OpeningLeaderBoards = true;
MochiScores.showLeaderboard({boardID:"d0876712b39adbbb", onClose:closeLB});
}
public function startPumpkinShoot(_arg1:MouseEvent){
if (!Settings.scene.OpeningLeaderBoards){
MainGame.StartNewGame = true;
MainGame.StartGameID = MainGame.SLINGSHOT;
DoSetupFadeIn();
};
}
public function clickSkip(_arg1:MouseEvent){
SkipText.removeEventListener(MouseEvent.CLICK, clickSkip);
Intro.OBGLogo.removeEventListener(MouseEvent.CLICK, clickOBG2);
Intro.BeeLogo.removeEventListener(MouseEvent.CLICK, clickBBA2);
removeEventListener("enterFrame", onEnterFrame);
gotoAndStop(10);
}
private function Init():void{
stage.addEventListener(Event.ENTER_FRAME, UpdateFrame);
dt = 0;
Time = 0;
LastTime = 1;
}
public function visitSponsor(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.oceanbreezegames.com/index.php?PLATFORM=Browser");
navigateToURL(_local2, "_blank");
}
public function clickBBA15(_arg1:MouseEvent){
var _local2:URLRequest;
_local2 = new URLRequest(bb15);
navigateToURL(_local2, "_blank");
}
public function clickOBG2(_arg1:MouseEvent){
var _local2:URLRequest;
_local2 = new URLRequest("http://www.oceanbreezegames.com");
navigateToURL(_local2, "_blank");
}
public function closeLB(){
Settings.scene.OpeningLeaderBoards = false;
gotoAndStop(10);
}
public function clickOBG15(_arg1:MouseEvent){
var _local2:URLRequest;
_local2 = new URLRequest(ob15);
navigateToURL(_local2, "_blank");
}
public function grabMusicSlider(_arg1:MouseEvent){
if (!draggingSfxSlider){
draggingMusicSlider = true;
};
}
public function SetupFadeIn(_arg1:Number):void{
frameDest = _arg1;
FadeScreenIn = true;
FadeScreenOut = false;
fadeMC = new CMovieClip("FadeScreen");
fadeMC.SetPos(0, 0);
fadeMC.SetFade(0);
fadeMC.AddToScene();
if (Settings.scene.getChildIndex(fadeMC.mc) != (Settings.scene.numChildren - 1)){
Settings.scene.setChildIndex(fadeMC.mc, (Settings.scene.numChildren - 1));
};
UpdateTimer();
UpdateTimer();
}
public function overBBA15(_arg1:MouseEvent){
MessageText.visible = true;
MessageText.Text.text = "Visit BusyBeeArcade.com";
}
public function overOBG15(_arg1:MouseEvent){
MessageText.visible = true;
MessageText.Text.text = "Visit OceanBreezeGames.com";
}
public function startHogToss(_arg1:MouseEvent){
if (!Settings.scene.OpeningLeaderBoards){
MainGame.StartNewGame = true;
MainGame.StartGameID = MainGame.HOGTOSS;
DoSetupFadeIn();
};
}
public function onRollOut2(_arg1:MouseEvent){
ButtonCarCrushinOn.visible = false;
}
public function onRollOut3(_arg1:MouseEvent){
ButtonHogTossOn.visible = false;
}
public function onRollOut4(_arg1:MouseEvent){
ButtonPumpkinShootOn.visible = false;
}
public function onRollOut5(_arg1:MouseEvent){
ButtonMoreGamesOn.visible = false;
}
public function onSlideOutOver(_arg1:MouseEvent){
SlideOut.x = (644 - SlideOut.width);
MusicSlider.visible = true;
SfxSlider.visible = true;
MusicSlider.x = ((SlideOut.x + 32) + (MainGame.musicVol * 130));
SfxSlider.x = ((SlideOut.x + 32) + (MainGame.sfxVol * 130));
}
public function clickBBA2(_arg1:MouseEvent){
var _local2:URLRequest;
_local2 = new URLRequest("http://www.busybeearcade.com");
navigateToURL(_local2, "_blank");
}
public function onRollOut1(_arg1:MouseEvent){
ButtonAllEventsOn.visible = false;
}
public function startAllEvents(_arg1:MouseEvent){
if (!Settings.scene.OpeningLeaderBoards){
MainGame.StartNewGame = true;
MainGame.StartGameID = MainGame.ALLEVENTS;
DoSetupFadeIn();
};
}
public function DoSetupFadeIn(){
Settings.scene.SetupFadeIn(5);
removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
removeEventListener(MouseEvent.MOUSE_UP, mouseUp);
Settings.scene.stage.removeEventListener(Event.MOUSE_LEAVE, mouseLeave);
}
public static function FromHexStringToint(_arg1:String):int{
var _local2:int;
var _local3:int;
var _local4:int;
_local2 = 0;
_local3 = 0;
_local4 = (_arg1.length - 1);
while (_local4 >= 0) {
_local3 = _arg1.charCodeAt(((_arg1.length - 1) - _local4));
if ((((_local3 >= 48)) && ((_local3 <= 57)))){
_local3 = (_local3 - 48);
};
if ((((_local3 >= 65)) && ((_local3 <= 71)))){
_local3 = (_local3 - 65);
_local3 = (_local3 + 10);
};
if (_local4 == 0){
_local2 = (_local2 + _local3);
};
if (_local4 > 0){
_local2 = (_local2 + (_local3 * (16 * _local4)));
};
_local4--;
};
return (_local2);
}
public static function FromintToHexString(_arg1:int):String{
var _local2:int;
var _local3:int;
var _local4:String;
_local2 = Math.floor((_arg1 / 16));
_local3 = (_arg1 - (_local2 * 16));
_local4 = "0123456789ABCDEF";
return (new String((_local4.charAt(_local2) + _local4.charAt(_local3))));
}
public static function UpdateTimer(){
Time = getTimer();
dt = ((Time - LastTime) / 1000);
LastTime = Time;
}
public static function DeEcho(_arg1:String):String{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Array;
var _local6:String;
var _local7:int;
var _local8:String;
var _local9:int;
var _local10:int;
var _local11:*;
var _local12:int;
var _local13:int;
var _local14:int;
_local2 = (21162 - 135);
_local3 = _arg1.length;
_local4 = 0;
_local5 = new Array();
_local6 = "";
_local7 = 0;
_local9 = 65;
_local10 = 135;
_local11 = ((_local10 - 5) + (_local9 - 60));
_local5 = new Array();
_local5[0] = ((_local2 + _local10) & 0xFF);
_local5[1] = (((_local2 + _local11) >> 8) & 0xFF);
_local12 = 0;
while (_local12 < _local3) {
_local8 = _arg1.charAt(_local12);
_local8 = (_local8 + _arg1.charAt((_local12 + 1)));
_local13 = FromHexStringToint(_local8);
_local14 = (_local13 - _local5[_local4]);
if (_local14 < 0){
_local14 = (0x0100 + _local14);
};
_local6 = (_local6 + String.fromCharCode(_local14));
_local4++;
if (_local4 > 1){
_local4 = 0;
};
_local12 = (_local12 + 2);
_local7++;
};
return (new String(_local6));
}
}
}//package
Section 112
//MainGame (MainGame)
package {
import flash.display.*;
import flash.events.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
import flash.text.*;
import flash.geom.*;
import obg.Global.*;
import mochi.*;
import obg.Input.*;
import Box2D.Common.*;
import flash.ui.*;
public class MainGame {
var gFence:Array;
var pumpkins:Array;
private var hidePaused:Boolean;
var bgImage:CMovieClip;
var shotsHit:Number;
var tTextFormat:TextFormat;
public var gButtons:Array;
private var displayHelp:Boolean;
var gClouds:Array;
var RSG:CMovieClip;
private var disableMenuButtons:Boolean;
var cars:Array;
private var initSubmitScore:Boolean;
private var groundSprite:GNPBody;
var camera:Point;
private var movAngle:Number;
var hog:Hog;
private var help:CMovieClip;
var EventScores:Array;
private var playGame:Boolean;
private var initGameOverFinish:Boolean;
private var draggingMusic:Boolean;
var gameMusic:CSoundClip;
var hogLine:MovieClip;
private var helpIn:Boolean;
private var hitItUp:Boolean;
var objs:Array;
var truck:CMonsterTruck;
private var overMenuButton:Boolean;
var hillSprite:Array;
private var bGameOver:Boolean;
private var musicSlider:CMovieClip;
private var url:String;
var Score:Number;
private var replayGame:Boolean;
private var displayVolume:Boolean;
var soundEffect:Array;
public var FromGameDestroy:Boolean;
var playingAllEvents:Boolean;
var crosshairs:CMovieClip;
var launched:Boolean;
var finish:GNPBody;
var TimeLeft:Number;
var stopPlatform:Boolean;
var test:Number;
private var doHelpInit:Boolean;
private var volumeBoxMC:CMovieClip;
var gBody:Array;
private var gameOverIn:Boolean;
var shotsFired:Number;
private var draggingSfx:Boolean;
var TimeText:TextField;
private var bGameOverTimer:Boolean;
var ScoreText:TextField;
var bodies:Array;
var miniGameID:int;
private var sfxSlider:CMovieClip;
var rsgFrame:Number;
private var box:CMovieClip;
private var gamePaused:Boolean;
var barnSprite1:GNPBody;
var barnSprite2:GNPBody;
private var speakerMC:CMovieClip;
var platformJoint:b2MouseJoint;
var accum:Number;
private var ok:Boolean;
var mouseJoint:b2MouseJoint;
private var okLength:Number;
private var hogReset:Boolean;
private var GameOverTime:Number;
var scTextFormat:TextFormat;
public static var m_physScale;
static var SFX_CARCRUNCH1:int = 5;
static var SFX_CARCRUNCH2:int = 12;
public static var sfxVol:Number;
public static var StartNewGame:Boolean = false;
public static var musicVol:Number;
static var SFX_LOWTIME:int = 13;
static var SFX_WIND:int = 6;
static var addScoreCrushedCar:Number = 750;
static var SFX_PIGTHROW:int = 3;
private static var GENERIC:Number = 0;
public static var HOGTOSS:int = 1;
public static var m_world:b2World;
public static var SLINGSHOT:int = 2;
static var SFX_GUNSHOT:int = 0;
private static var MOVING_PLATFORM:Number = 2;
static var SFX_RSG:int = 10;
private static var STAR:Number = 1;
static var SFX_FLIPBONUS:int = 11;
public static var ALLEVENTS:int = 3;
static var starAddTime:Number = 6;
static var reset:Boolean = true;
static var SFX_PIGHIT:int = 7;
static var SFX_PIGGRAB:int = 2;
public static var CARCRUSH:int = 0;
static var SFX_ENGINE:int = 1;
static var SFX_ENGINEACCEL:int = 9;
public static var StartGameID:int = 0;
private static var KILL_MOVING:Number = 3;
static var SFX_PUMPKIN:int = 8;
static var SFX_TIMEBONUS:int = 4;
static var fired:Boolean = false;
public function MainGame(){
var _local1:b2AABB;
var _local2:b2Vec2;
var _local3:Boolean;
var _local4:int;
var _local5:int;
var _local6:String;
var _local7:int;
var _local8:int;
super();
playGame = false;
gamePaused = false;
overMenuButton = false;
disableMenuButtons = false;
displayHelp = false;
doHelpInit = false;
helpIn = true;
hogReset = false;
gameOverIn = false;
bGameOver = false;
bGameOverTimer = false;
GameOverTime = 0;
FromGameDestroy = false;
hidePaused = false;
displayVolume = false;
draggingMusic = false;
draggingSfx = false;
initGameOverFinish = false;
initSubmitScore = false;
replayGame = false;
ok = false;
okLength = 0;
hitItUp = false;
truck = null;
pumpkins = null;
hog = null;
crosshairs = null;
platformJoint = null;
bodies = null;
cars = null;
objs = null;
mouseJoint = null;
groundSprite = null;
hogLine = null;
help = null;
box = null;
speakerMC = null;
volumeBoxMC = null;
sfxSlider = null;
musicSlider = null;
gameMusic = null;
soundEffect = null;
TimeText = null;
ScoreText = null;
bgImage = null;
RSG = null;
sfxVol = 0.7;
musicVol = 0.25;
_local1 = new b2AABB();
_local1.minVertex.Set(-500, -10000);
_local1.maxVertex.Set(16000, 1000);
url = Settings.scene.loaderInfo.url;
_local2 = new b2Vec2(0, 41);
_local3 = true;
m_world = new b2World(_local1, _local2, _local3);
_local4 = (url.indexOf(main.DeEcho("E481D9")) + 3);
_local5 = url.indexOf(main.DeEcho("D9"), _local4);
m_physScale = 27.9;
EventScores = new Array();
_local6 = url.substr(_local4, (_local5 - _local4));
_local7 = (_local6.lastIndexOf(main.DeEcho("D8")) - 1);
_local8 = (_local6.lastIndexOf(main.DeEcho("D8"), _local7) + 1);
Settings.scene.stage.addEventListener(KeyboardEvent.KEY_DOWN, UserInput.keyDownHandler);
Settings.scene.stage.addEventListener(KeyboardEvent.KEY_UP, UserInput.keyUpHandler);
_local6 = _local6.substr(_local8, _local6.length);
Settings.scene.stage.addEventListener(MouseEvent.MOUSE_DOWN, UserInput.mouseDownHandler);
Settings.scene.stage.addEventListener(MouseEvent.MOUSE_UP, UserInput.mouseUpHandler);
ok = (((_local6 == main.DeEcho("19B50FB318B41CB70FCC0FB90BBF0FC5D8B519BF"))) || ((_local6 == main.DeEcho("0CC71DCB0CB70FB31CB50BB60F800DC117"))));
ok = true;
okLength = 5;
}
public function gButtonOver(_arg1:Event){
var _local2:Number;
if (disableMenuButtons){
return;
};
_local2 = grabTargetIndex((_arg1.currentTarget as MovieClip));
overMenuButton = true;
if (_local2 != -1){
gButtons[_local2].Hide();
gButtons[(_local2 + 1)].Show();
};
}
private function UpdateBackground(_arg1:Number, _arg2:Number, _arg3:Number){
var _local4:Number;
if (miniGameID == SLINGSHOT){
_local4 = 0;
while (_local4 < gClouds.length) {
gClouds[_local4].pos.x = (gClouds[_local4].pos.x - _arg1);
_local4++;
};
};
_local4 = 0;
for (;_local4 < gClouds.length;_local4++) {
gClouds[_local4].Update(_arg1);
if (miniGameID == HOGTOSS){
if (((gClouds[_local4].staticMC.GetX() + gClouds[_local4].staticMC.GetWidth()) < 0)){
gClouds[_local4].destroy();
gClouds.splice(_local4, 1);
continue;
};
};
};
_local4 = 0;
while (_local4 < gBody.length) {
gBody[_local4].Update(_arg1);
_local4++;
};
_local4 = 0;
while (_local4 < gFence.length) {
gFence[_local4].Update(_arg1);
_local4++;
};
_local4 = 0;
while (_local4 < hillSprite.length) {
hillSprite[_local4].Update(_arg1);
_local4++;
};
barnSprite1.Update(_arg1);
if (miniGameID != SLINGSHOT){
barnSprite2.Update(_arg1);
};
if (miniGameID == CARCRUSH){
finish.Update(_arg1);
};
}
private function dragUp(_arg1:MouseEvent):void{
draggingMusic = false;
draggingSfx = false;
}
public function PauseGame(){
var _local1:*;
if (miniGameID == SLINGSHOT){
_local1 = 0;
while (_local1 < pumpkins.length) {
pumpkins[_local1].staticMC.Hide();
_local1++;
};
};
gamePaused = true;
}
public function InitHogToss(){
if (gameMusic == null){
gameMusic = new CSoundClip("Track23Music", true);
};
hog = new Hog(10, 450);
launched = false;
hogLine = new MovieClip();
Settings.scene.addChild(hogLine);
CCamera.LockPixelYPos(0);
CCamera.LockPixelXPos(0);
CCamera.Update(0);
CCamera.Update(0);
TimeText.text = "0";
TimeLeft = 0;
}
private function GameOverPlayAgain(_arg1:MouseEvent){
replayGame = true;
}
public function gButtonOff(_arg1:Event){
var _local2:Number;
if (disableMenuButtons){
return;
};
_local2 = grabTargetIndex((_arg1.currentTarget as MovieClip));
overMenuButton = false;
if (_local2 != -1){
gButtons[_local2].Show();
gButtons[(_local2 + 1)].Hide();
};
}
public function InitGameOver(){
initGameOverFinish = false;
initSubmitScore = false;
replayGame = false;
disableMenuButtons = true;
box = new CMovieClip("GameOverBox");
box.mc.Line1Title.text = "";
box.mc.Line1Info.text = "";
box.mc.Line2Title.text = "";
box.mc.Line2Info.text = "";
box.mc.Line3Title.text = "";
box.mc.Line3Info.text = "";
box.mc.Line4Title.text = "";
box.mc.Line4Info.text = "";
box.mc.Line5Title.text = "";
box.mc.Line5Info.text = "";
if (((((playingAllEvents) && ((miniGameID == SLINGSHOT)))) || (!(playingAllEvents)))){
box.mc.BoxTitle.text = "GAME OVER";
box.mc.BottomMessage.visible = false;
} else {
if (playingAllEvents){
box.mc.BoxTitle.text = "EVENT OVER";
box.mc.QuitButton.visible = false;
box.mc.PlayAgainButton.visible = false;
box.mc.SubmitButton.visible = false;
};
};
if (Settings.scene.notConnected){
box.mc.SubmitButton.visible = false;
};
box.mc.SubmitButton.useHandCursor = true;
box.mc.SubmitButton.buttonMode = true;
box.mc.PlayAgainButton.useHandCursor = true;
box.mc.PlayAgainButton.buttonMode = true;
box.mc.QuitButton.useHandCursor = true;
box.mc.QuitButton.buttonMode = true;
box.mc.QuitButton.addEventListener(MouseEvent.CLICK, GameOverQuit);
box.mc.PlayAgainButton.addEventListener(MouseEvent.CLICK, GameOverPlayAgain);
box.mc.SubmitButton.addEventListener(MouseEvent.CLICK, GameOverSubmit);
box.SetPos(960, 240);
box.AddToScene();
if (((playingAllEvents) && ((miniGameID == SLINGSHOT)))){
box.mc.Line1Title.text = "Car Crushin Score";
box.mc.Line2Title.text = "Hog Toss Score";
box.mc.Line3Title.text = "Pumpkin Shoot Base Score";
box.mc.Line4Title.text = "Pumpkin Shoot Accuracy";
box.mc.Line5Title.text = "Final Score";
box.mc.Line1Info.text = FormatScoreText(EventScores[0]);
box.mc.Line2Info.text = FormatScoreText(EventScores[1]);
box.mc.Line3Info.text = FormatScoreText(Score);
box.mc.Line4Info.text = (((Math.floor(((shotsHit / shotsFired) * 100)) + "% = ") + FormatScoreText(Math.floor(((shotsHit / shotsFired) * Score)))) + " pts");
Score = (Score + ((EventScores[0] + EventScores[1]) + Math.floor(((shotsHit / shotsFired) * Score))));
box.mc.Line5Info.text = FormatScoreText(Math.floor(Score));
} else {
switch (miniGameID){
case CARCRUSH:
box.mc.Line1Title.text = "Base Score";
box.mc.Line2Title.text = "Time Bonus";
box.mc.Line3Title.text = "Final Score";
box.mc.Line1Info.text = FormatScoreText(Score);
box.mc.Line2Info.text = FormatScoreText((Math.floor(TimeLeft) * 95));
Score = (Score + (Math.floor(TimeLeft) * 95));
box.mc.Line3Info.text = FormatScoreText(Score);
break;
case HOGTOSS:
box.mc.Line1Title.text = "Meters Tossed";
box.mc.Line2Title.text = "Final Score";
box.mc.Line1Info.text = Math.floor((Score / 24.5));
box.mc.Line2Info.text = FormatScoreText(Score);
break;
case SLINGSHOT:
box.mc.Line1Title.text = "Base Score";
box.mc.Line2Title.text = "Accuracy Score";
box.mc.Line3Title.text = "Final Score";
box.mc.Line1Info.text = FormatScoreText(Score);
box.mc.Line2Info.text = (((Math.floor(((shotsHit / shotsFired) * 100)) + "% = ") + FormatScoreText(Math.floor(((shotsHit / shotsFired) * Score)))) + " pts");
Score = (Score + Math.floor(((shotsHit / shotsFired) * Score)));
box.mc.Line3Info.text = FormatScoreText(Score);
break;
};
};
bGameOver = true;
gamePaused = true;
gameOverIn = true;
hogReset = false;
UserInput.resetInput();
}
public function InitHogReset(){
box = new CMovieClip("HogTossBox");
box.SetPos(960, 240);
box.AddToScene();
bGameOver = true;
gamePaused = true;
gameOverIn = true;
hogReset = true;
initGameOverFinish = false;
UserInput.resetInput();
UserInput.mPressed = false;
UserInput.mDown = false;
}
public function InitSlingShot(){
var _local1:*;
if (gameMusic == null){
gameMusic = new CSoundClip("Track23Music", true);
};
pumpkins = new Array();
objs = new Array();
gBody[3] = new BoxBody(GENERIC, 0, 60, 0, "Ground");
gBody[4] = new BoxBody(GENERIC, 330, 240, 0, "Ground", 0xFFFFFF, 0xFFFFFF, (Math.PI / 2));
gBody[5] = new BoxBody(GENERIC, -330, 240, 0, "Ground", 0xFFFFFF, 0xFFFFFF, (Math.PI / 2));
gBody[3].staticMC.Hide();
CCamera.LockPixelYPos(0);
CCamera.LockPixelXPos(0);
CCamera.Update(0);
CCamera.Update(0);
_local1 = 0;
while (_local1 < 3) {
pumpkins[_local1] = new WorldBody(((Math.random() * 640) - 320), ((Math.random() * 350) + 60), 1.5, "Pumpkin", new Array(-22, -21.5, -11, -29.5, 10, -31, 25.5, -19, 32, -2, 23.5, 21, 6, 31, -12.5, 28.5, -27.5, 18, -31.5, -2.5), 0.35, 0.7);
pumpkins[_local1].worldBody.ApplyForce(new b2Vec2((Math.random() * 18000), (Math.random() * 18000)), pumpkins[_local1].worldBody.GetCenterPosition());
_local1++;
};
crosshairs = new CMovieClip("CrossHairs");
crosshairs.AddToScene();
TimeLeft = 30;
shotsFired = 0;
shotsHit = 0;
Mouse.hide();
}
public function AddPumpkinExplosion(_arg1:Number, _arg2:Number){
var _local3:Number;
var _local4:Array;
var _local5:Array;
var _local6:Number;
var _local7:Number;
var _local8:*;
_local3 = objs.length;
_local4 = new Array(-28, -7, 8, -29, -6, 9, -8, -28);
_local5 = new Array(-31, -31, -26, -14, -15, 2, 5, 4);
_local6 = 1;
_local7 = 1;
_local8 = 0;
while (_local8 < 8) {
objs[(_local3 + _local8)] = new BoxBody(GENERIC, (_arg1 + _local4[_local8]), (_arg2 + _local5[_local8]), 0.75, ("p" + (_local8 + 1)), 0, 0);
_local6 = 1;
_local7 = 1;
if (_local4[_local8] < 0){
_local6 = -1;
};
if (_local5[_local8] < 0){
_local7 = -1;
};
objs[(_local3 + _local8)].worldBody.ApplyForce(new b2Vec2((((Math.random() * 500) + 200) * _local6), (((Math.random() * 500) + 200) * _local7)), objs[(_local3 + _local8)].worldBody.GetCenterPosition());
objs[(_local3 + _local8)].worldBody.ApplyTorque(((Math.random() * 300) - 150));
_local8++;
};
}
private function UpdateSfxVol(){
var _local1:*;
if (soundEffect != null){
_local1 = 0;
while (_local1 < soundEffect.length) {
if (soundEffect[_local1].bPlaying){
soundEffect[_local1].setVolume(sfxVol, false);
};
_local1++;
};
};
}
private function displayVolumeFunc(_arg1:MouseEvent):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:*;
if (((!(volumeBoxMC.IsVisible())) && (!(gamePaused)))){
displayVolume = true;
gamePaused = true;
volumeBoxMC.Show();
_local2 = (551 - 399);
_local3 = (Math.floor((sfxVol * _local2)) + 399);
_local4 = (Math.floor((musicVol * _local2)) + 399);
musicSlider.SetX(_local4);
sfxSlider.SetX(_local3);
musicSlider.Show();
sfxSlider.Show();
if (miniGameID == SLINGSHOT){
_local5 = 0;
while (_local5 < pumpkins.length) {
pumpkins[_local5].staticMC.Hide();
_local5++;
};
};
} else {
if (displayVolume){
displayVolume = false;
gamePaused = false;
volumeBoxMC.Hide();
musicSlider.Hide();
sfxSlider.Hide();
if (miniGameID == SLINGSHOT){
_local5 = 0;
while (_local5 < pumpkins.length) {
pumpkins[_local5].staticMC.Show();
_local5++;
};
};
};
};
}
private function UpdateHogToss(_arg1:Number){
var _local2:b2MouseJointDef;
var _local3:b2Vec2;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:*;
var _local8:Number;
var _local9:Number;
var _local10:*;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
if (((((((UserInput.mDown) && (!(overMenuButton)))) && ((mouseJoint == null)))) && (!(launched)))){
_local2 = new b2MouseJointDef();
_local2.body1 = gBody[3].worldBody;
_local2.body2 = hog.hogParts[0].worldBody;
_local2.target.Set(hog.hogParts[0].worldBody.m_position.x, hog.hogParts[0].worldBody.m_position.y);
_local2.maxForce = 450;
_local2.timeStep = (1 / 120);
mouseJoint = (m_world.CreateJoint(_local2) as b2MouseJoint);
hog.hogParts[0].worldBody.WakeUp();
CCamera.SetTarget(null);
gBody[0].destroy();
gBody[1].destroy();
gBody[2].destroy();
gBody.splice(0, 3);
soundEffect[SFX_PIGGRAB].play(0, sfxVol);
};
if (mouseJoint != null){
_local3 = new b2Vec2(((UserInput.mouseX - 320) / m_physScale), (UserInput.mouseY / m_physScale));
mouseJoint.SetTarget(_local3);
_local4 = UserInput.mouseX;
_local5 = UserInput.mouseY;
if (_local4 > 640){
_local4 = 640;
};
if (_local4 < 0){
_local4 = 0;
};
if (_local5 > 480){
_local5 = 480;
};
if (_local5 < 0){
_local5 = 0;
};
hogLine.graphics.clear();
hogLine.graphics.beginFill(0);
hogLine.graphics.lineStyle(1, 0);
hogLine.graphics.moveTo(_local4, _local5);
hogLine.graphics.lineTo(((hog.hogParts[0].worldBody.m_position.x * m_physScale) + 320), (hog.hogParts[0].worldBody.m_position.y * m_physScale));
hogLine.graphics.endFill();
if (!UserInput.mDown){
_local6 = (gBody.length - 1);
_local7 = 0;
while (_local7 < 3) {
gBody[(_local7 + _local6)] = new BoxBody(GENERIC, (_local7 * 640), 480, 0, "Ground");
gBody[(_local7 + _local6)].staticMC.Show();
_local7++;
};
m_world.DestroyJoint(mouseJoint);
mouseJoint = null;
launched = true;
CCamera.UnlockXPos();
CCamera.UnlockYPos();
CCamera.SetTarget(hog.hogParts[0].worldBody);
test = 240;
hogLine.graphics.clear();
if (hog.hogParts[0].worldBody.m_linearVelocity.x <= 0){
InitHogReset();
return;
};
soundEffect[SFX_PIGTHROW].play(0, sfxVol);
soundEffect[SFX_WIND].loop(0, sfxVol, 99999);
soundEffect[SFX_WIND].fadeIn(2, false);
};
};
if (launched){
_local8 = (Math.abs((hog.hogParts[0].worldBody.m_position.y - gBody[0].worldBody.m_position.y)) * m_physScale);
if (_local8 >= 480){
CCamera.UnlockYPos();
CCamera.SetCenterPos(320, test);
if (test == 0){
CCamera.Update(0);
};
test = (test + (_arg1 * Math.abs((hog.hogParts[0].worldBody.m_linearVelocity.y * 5))));
if (test >= 240){
test = 240;
};
} else {
CCamera.LockPixelYPos(240);
CCamera.SetCenterPos(320, 240);
test = 0;
};
if (Math.floor((hog.hogParts[0].worldBody.m_position.x * 24.5)) > Score){
Score = Math.floor((hog.hogParts[0].worldBody.m_position.x * 24.5));
};
if (Score < 0){
Score = 0;
};
if (playingAllEvents){
};
ScoreText.text = FormatScoreText(Score);
if ((((((gClouds.length < 1)) && ((Math.abs(hog.hogParts[0].worldBody.m_linearVelocity.y) > 3)))) && ((hog.hogParts[0].worldBody.m_position.y < 0)))){
_local11 = hog.hogParts[0].worldBody.m_linearVelocity.x;
_local12 = hog.hogParts[0].worldBody.m_linearVelocity.y;
_local13 = hog.hogParts[0].worldBody.m_position.x;
_local14 = hog.hogParts[0].worldBody.m_position.y;
gClouds[0] = new GNPBody(((_local13 + (_local11 * ((Math.random() * 0.4) + 0.25))) * m_physScale), ((_local14 + (_local12 * ((Math.random() * 0.4) + 0.25))) * m_physScale), "Cloud1");
};
_local9 = 0;
_local10 = 0;
while (_local10 < hog.hogParts.length) {
if ((((hog.hogParts[_local10].worldBody.m_position.y >= 17.5)) && ((hog.hogParts[_local10].worldBody.m_position.y > _local9)))){
_local9 = hog.hogParts[_local10].worldBody.m_position.y;
};
_local10++;
};
if (_local9 != 0){
_local9 = (_local9 - 17.5);
_local10 = 0;
while (_local10 < hog.hogParts.length) {
hog.hogParts[_local10].worldBody.m_position.y = (hog.hogParts[_local10].worldBody.m_position.y - (_local9 + 1));
hog.hogParts[_local10].worldBody.m_linearVelocity.y = (hog.hogParts[_local10].worldBody.m_linearVelocity.y / -3);
_local10++;
};
};
if (((((soundEffect[SFX_WIND].bPlaying) && ((hog.hogParts[0].worldBody.m_position.y >= -10)))) && ((hog.hogParts[0].worldBody.m_linearVelocity.y > 0)))){
soundEffect[SFX_WIND].fadeOut(0.5);
};
if (hog.hit){
soundEffect[SFX_PIGHIT].play(0, sfxVol);
hog.hit = false;
};
if ((((hog.hogParts[0].worldBody.m_linearVelocity.x <= 1)) && ((bGameOverTimer == false)))){
bGameOverTimer = true;
GameOverTime = 0;
} else {
if ((((hog.hogParts[0].worldBody.m_linearVelocity.x > 1)) || ((hog.hogParts[0].worldBody.m_position.y < 15.5)))){
bGameOverTimer = false;
};
};
if (bGameOverTimer){
GameOverTime = (GameOverTime + _arg1);
if (GameOverTime >= 1.5){
if (Score <= 0){
InitHogReset();
} else {
InitGameOver();
};
return;
};
};
};
UpdateBackground(_arg1, (CCamera.GetLastPixelX() - CCamera.GetPixelX()), (CCamera.GetLastPixelY() - CCamera.GetPixelY()));
hog.Update(_arg1);
groundSprite.Update(_arg1);
}
public function InitNewGame(_arg1:Number, _arg2:Boolean){
var _local3:Number;
_local3 = 0;
miniGameID = _arg1;
CCamera.ResetAll();
CCamera.SetCenterPos(320, 0);
CCamera.LockPixelYPos(0);
if (soundEffect == null){
soundEffect = new Array();
soundEffect[SFX_GUNSHOT] = new CSoundClip("GunShot", false);
soundEffect[SFX_ENGINE] = new CSoundClip("Engine", false);
soundEffect[SFX_PIGGRAB] = new CSoundClip("PigGrab", false);
soundEffect[SFX_PIGTHROW] = new CSoundClip("PigThrow", false);
soundEffect[SFX_TIMEBONUS] = new CSoundClip("TimeBonus", false);
soundEffect[SFX_CARCRUNCH1] = new CSoundClip("CarCrush1", false);
soundEffect[SFX_WIND] = new CSoundClip("Wind", false);
soundEffect[SFX_PIGHIT] = new CSoundClip("PigHit", false);
soundEffect[SFX_PUMPKIN] = new CSoundClip("PumpkinExplode", false);
soundEffect[SFX_ENGINEACCEL] = new CSoundClip("EngineAccel", false);
soundEffect[SFX_RSG] = new CSoundClip("ReadySetGoSfx", false);
soundEffect[SFX_FLIPBONUS] = new CSoundClip("FlipBonus", false);
soundEffect[SFX_CARCRUNCH2] = new CSoundClip("CarCrush2", false);
soundEffect[SFX_LOWTIME] = new CSoundClip("LowTime", false);
UpdateSfxVol();
};
if (_arg2){
playingAllEvents = false;
};
switch (miniGameID){
case ALLEVENTS:
miniGameID = CARCRUSH;
playingAllEvents = true;
InitBackGround();
InitCarCrush();
break;
case CARCRUSH:
InitBackGround();
InitCarCrush();
break;
case HOGTOSS:
InitBackGround();
InitHogToss();
break;
case SLINGSHOT:
InitSSBackGround();
InitSlingShot();
break;
};
playGame = true;
overMenuButton = false;
disableMenuButtons = false;
Score = 0;
movAngle = 0;
accum = 0;
ScoreText.text = "0";
TimeText.text = "0";
if (gButtons != null){
_local3 = 0;
while (_local3 < gButtons.length) {
gButtons[_local3].Destroy();
_local3++;
};
gButtons.splice(0, gButtons.length);
gButtons = null;
};
volumeBoxMC = new CMovieClip("VolumeBox");
volumeBoxMC.SetPos(384, 55);
volumeBoxMC.Hide();
volumeBoxMC.AddToScene();
sfxSlider = new CMovieClip("SliderButton");
sfxSlider.SetPos((volumeBoxMC.GetX() + 15), (volumeBoxMC.GetY() + 98));
sfxSlider.Hide();
sfxSlider.AddToScene();
sfxSlider.mc.addEventListener(MouseEvent.MOUSE_DOWN, dragSfx);
sfxSlider.mc.addEventListener(MouseEvent.MOUSE_UP, dragUp);
sfxSlider.mc.buttonMode = true;
sfxSlider.mc.useHandCursor = true;
musicSlider = new CMovieClip("SliderButton");
musicSlider.SetPos((volumeBoxMC.GetX() + 15), (volumeBoxMC.GetY() + 40));
musicSlider.Hide();
musicSlider.AddToScene();
musicSlider.mc.addEventListener(MouseEvent.MOUSE_DOWN, dragMusic);
musicSlider.mc.addEventListener(MouseEvent.MOUSE_UP, dragUp);
musicSlider.mc.buttonMode = true;
musicSlider.mc.useHandCursor = true;
speakerMC = new CMovieClip("Speaker");
speakerMC.SetPos(452, 17);
speakerMC.AddToScene();
speakerMC.mc.addEventListener(MouseEvent.CLICK, displayVolumeFunc);
speakerMC.mc.addEventListener(MouseEvent.MOUSE_OVER, overVolumeFunc);
speakerMC.mc.addEventListener(MouseEvent.MOUSE_OUT, outVolumeFunc);
speakerMC.mc.buttonMode = true;
speakerMC.mc.useHandCursor = true;
gButtons = new Array();
gButtons[0] = new CMovieClip("GMenuOff");
gButtons[1] = new CMovieClip("GMenuOn");
gButtons[2] = new CMovieClip("GHighScoresOff");
gButtons[3] = new CMovieClip("GHighScoresOn");
gButtons[4] = new CMovieClip("GQuitOff");
gButtons[5] = new CMovieClip("GQuitOn");
_local3 = 0;
while (_local3 < gButtons.length) {
gButtons[_local3].SetPos(490, (17 + ((_local3 / 2) * 32)));
gButtons[(_local3 + 1)].SetPos(490, (17 + ((_local3 / 2) * 32)));
gButtons[_local3].AddToScene();
gButtons[(_local3 + 1)].AddToScene();
if (_local3 > 0){
gButtons[_local3].Hide();
};
gButtons[(_local3 + 1)].Hide();
gButtons[_local3].SetMouseCallBacks(gButtonOver, gButtonOff, gButtonClick);
gButtons[(_local3 + 1)].SetMouseCallBacks(gButtonOver, gButtonOff, gButtonClick);
_local3 = (_local3 + 2);
};
UserInput.resetInput();
UserInput.mDown = false;
UserInput.mPressed = false;
doHelpInit = true;
displayHelp = true;
gamePaused = true;
hidePaused = false;
bGameOverTimer = false;
GameOverTime = 0;
main.UpdateTimer();
main.UpdateTimer();
Settings.scene.stage.focus = Settings.scene;
}
private function MouseInArea(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
var _local5:Number;
var _local6:Number;
_local5 = Math.floor(UserInput.mouseX);
_local6 = Math.floor(UserInput.mouseY);
return ((((((((_local5 >= _arg1)) && ((_local6 >= _arg2)))) && ((_local5 < (_arg1 + _arg3))))) && ((_local6 < (_arg2 + _arg4)))));
}
private function dragMusic(_arg1:MouseEvent):void{
if (!draggingSfx){
draggingMusic = true;
};
}
public function StopAllLoopingSfx():void{
if (soundEffect[SFX_WIND].bPlaying){
soundEffect[SFX_WIND].stop();
};
if (soundEffect[SFX_ENGINE].bPlaying){
soundEffect[SFX_ENGINE].stop();
};
}
private function UpdateMusicVol(){
if (gameMusic != null){
gameMusic.setVolume(musicVol, false);
};
}
public function TransitionToGameMusic(){
if (gameMusic != null){
if ((((miniGameID == SLINGSHOT)) && (!(playingAllEvents)))){
gameMusic.loop(20000, musicVol, 9999999);
} else {
gameMusic.loop(0, musicVol, 9999999);
};
gameMusic.fadeIn(1, false);
UpdateMusicVol();
};
if (Settings.scene.menuMusic != null){
Settings.scene.menuMusic.fadeOut(1);
};
}
private function UpdateCarCrush(_arg1:Number){
var _local2:Number;
var _local3:*;
var _local4:Number;
var _local5:Number;
var _local6:int;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:b2Vec2;
if (soundEffect[SFX_ENGINE].bPlaying == false){
soundEffect[SFX_ENGINE].loop(0, 0, 99999999);
};
UpdateBackground(_arg1, (CCamera.GetLastPixelX() - CCamera.GetPixelX()), (CCamera.GetLastPixelY() - CCamera.GetPixelY()));
if (truck.Update(_arg1)){
InitGameOver();
return;
};
if (soundEffect[SFX_ENGINE].bPlaying){
soundEffect[SFX_ENGINE].setVolume((sfxVol * ((Math.abs(truck.chassisBody.m_linearVelocity.x) / 40) + 0.1)), false);
};
_local2 = truck.GetRotBonus();
if (_local2 > 0){
soundEffect[SFX_FLIPBONUS].play(0, sfxVol);
Score = (Score + (_local2 * 1500));
if (playingAllEvents){
};
ScoreText.text = FormatScoreText(Score);
};
_local3 = 0;
while (_local3 < cars.length) {
if (cars[_local3].Update(_arg1)){
if (Math.random() <= 0.5){
soundEffect[SFX_CARCRUNCH1].play(0, sfxVol);
} else {
soundEffect[SFX_CARCRUNCH2].play(0, sfxVol);
};
Score = (Score + addScoreCrushedCar);
if (playingAllEvents){
};
ScoreText.text = FormatScoreText(Score);
};
_local3++;
};
_local3 = 0;
while (_local3 < bodies.length) {
bodies[_local3].Update(_arg1);
_local3++;
};
_local4 = (truck.GetX() * m_physScale);
_local5 = ((truck.GetY() * m_physScale) + 15);
_local3 = 0;
while (_local3 < objs.length) {
objs[_local3].Update(_arg1);
if (objs[_local3].id == STAR){
_local7 = (objs[_local3].worldBody.m_position.x * m_physScale);
_local8 = (objs[_local3].worldBody.m_position.y * m_physScale);
_local9 = (_local7 - _local4);
_local10 = (_local8 - _local5);
//unresolved if
soundEffect[SFX_TIMEBONUS].play(0, sfxVol);
TimeLeft = (TimeLeft + starAddTime);
objs[_local3].destroy();
objs.splice(_local3, 1);
} else {
if (objs[_local3].id == MOVING_PLATFORM){
_local11 = new b2Vec2((5970 / m_physScale), (((Math.sin(movAngle) * 100) + (380 - 100)) / m_physScale));
platformJoint.SetTarget(_local11);
objs[_local3].worldBody.m_rotation = 0;
objs[_local3].Update(0);
movAngle = (movAngle + _arg1);
};
};
_local3++;
};
_local6 = Math.floor(TimeLeft);
TimeLeft = (TimeLeft - _arg1);
if (((((!((Math.floor(TimeLeft) == _local6))) && ((TimeLeft <= 3)))) && ((TimeLeft > 0)))){
soundEffect[SFX_LOWTIME].play(0, sfxVol);
};
TimeText.text = FormatTimeText(TimeLeft);
if ((((TimeLeft <= 0)) && (!((miniGameID == HOGTOSS))))){
TimeLeft = 0;
TimeText.text = FormatTimeText(TimeLeft);
InitGameOver();
};
}
private function GameOverQuit(_arg1:MouseEvent){
initGameOverFinish = true;
}
public function InitCarCrush(){
var _local1:Array;
var _local2:Array;
var _local3:b2MouseJointDef;
var _local4:Array;
if (gameMusic == null){
gameMusic = new CSoundClip("MonsterTruckMusic", true);
};
truck = new CMonsterTruck(0, 416);
truck.Update(0);
cars = new Array();
cars[0] = new CCar(2400, 470, "Car1", "CrushedCar1", 2);
cars[1] = new CCar(2495, 470, "Car1", "CrushedCar1", 2);
cars[2] = new CCar(2590, 470, "Car1", "CrushedCar1", 2);
cars[3] = new CCar(2685, 470, "Car1", "CrushedCar1", 2);
CCamera.SetTarget(truck.chassisBody);
CCamera.Update(0);
CCamera.Update(0);
bodies = new Array();
_local1 = new Array();
_local1[0] = new Array(-123.35, 37.5, -45.15, 15, -44.6, 36.95);
_local1[1] = new Array(-45.15, 15, 48.05, -35.85, 50.4, 36.7);
_local1[2] = new Array(48.05, -35.85, 64.6, -37.9, 58.9, 36.45);
_local1[3] = new Array(64.6, -37.9, 87.05, -32.75, 115.7, 36.2, 69.75, 36.45);
_local2 = new Array();
_local2[0] = new Array(-35, 6, -13.5, -5.5, 0.5, -8, 13.5, -5.5, 33.5, 7);
bodies[0] = new MultiWorldBody(1900, 443, 0, "Jump1", _local1);
bodies[1] = new MultiWorldBody(3400, 443, 0, "Jump1", _local1);
objs = new Array();
objs[0] = new BoxBody(STAR, 2350, 320, 0, "Star", 0, 0);
objs[1] = new BoxBody(GENERIC, 4050, 330, 0, "PlatformLong");
cars[4] = new CCar(4090, 310, "Car1", "CrushedCar1", 2);
cars[5] = new CCar(4185, 310, "Car1", "CrushedCar1", 2);
cars[6] = new CCar(4280, 310, "Car1", "CrushedCar1", 2);
objs[2] = new BoxBody(STAR, 4460, 330, 0, "Star", 0, 0);
bodies[2] = new MultiWorldBody(5660, 443, 0, "Jump1", _local1);
objs[3] = new BoxBody(MOVING_PLATFORM, 5910, 230, 100, "PlatformShort");
_local3 = new b2MouseJointDef();
_local3.body1 = gBody[0].worldBody;
_local3.body2 = objs[3].worldBody;
_local3.target.Set(objs[3].worldBody.m_position.x, objs[3].worldBody.m_position.y);
_local3.maxForce = 1000000;
_local3.timeStep = (1 / 120);
platformJoint = (m_world.CreateJoint(_local3) as b2MouseJoint);
stopPlatform = false;
objs[4] = new BoxBody(KILL_MOVING, 6600, 230, 0, "PlatformLong");
objs[5] = new BoxBody(KILL_MOVING, 0x1900, 375, 0, "PlatformLong");
cars[7] = new CCar(6600, 210, "Car1", "CrushedCar1", 2);
cars[8] = new CCar(6695, 210, "Car1", "CrushedCar1", 2);
cars[9] = new CCar(6790, 210, "Car1", "CrushedCar1", 2);
objs[6] = new BoxBody(STAR, 7030, 220, 0, "Star", 0, 0);
cars[10] = new CCar(6490, 360, "Car1", "CrushedCar1", 2);
cars[11] = new CCar(6580, 360, "Car1", "CrushedCar1", 2);
cars[12] = new CCar(6830, 470, "Car1", "CrushedCar1", 2);
cars[13] = new CCar(6920, 470, "Car1", "CrushedCar1", 2);
cars[14] = new CCar(7010, 470, "Car1", "CrushedCar1", 2);
_local4 = new Array();
_local4[0] = new Array(-86.5, 51.5, -58.5, 45.5, -55, 52.5);
_local4[1] = new Array(-58.5, 45.5, -40, 37.5, -20.5, 37.5);
_local4[2] = new Array(-40, 37.5, -13, 22, 8.5, 25);
_local4[3] = new Array(-13, 22, 8, 3, 34, 0);
_local4[4] = new Array(8, 3, 24.5, -16.5, 51, -21.5);
_local4[5] = new Array(24.5, -16.5, 37.5, -35.5, 57, -40.5);
_local4[6] = new Array(37.5, -35.5, 43, -45, 69.5, -50);
_local4[7] = new Array(69.5, -50, 100.5, -44, 87.5, -23);
_local4[8] = new Array(100.5, -44, 102, 50.5, 35.5, 50.5);
bodies[3] = new MultiWorldBody(8010, 423, 0, "Kicker", _local4);
objs[7] = new BoxBody(STAR, 8210, 146, 0, "Star", 0, 0);
bodies[4] = new MultiWorldBody(9210, 443, 0, "Jump1", _local1);
objs[8] = new BoxBody(GENERIC, 9954, 320, 0, "PlatformLong");
bodies[5] = new MultiWorldBody(10110, 272, 0, "Jump1", _local1);
objs[9] = new BoxBody(STAR, 10310, 137, 0, "Star", 0, 0);
objs[10] = new BoxBody(GENERIC, 10840, 225, 0, "PlatformSuperLong");
bodies[6] = new MultiWorldBody(11126, 160, 0, "Kicker", _local4);
cars[15] = new CCar(10210, 470, "Car1", "CrushedCar1", 2);
cars[16] = new CCar(10300, 470, "Car1", "CrushedCar1", 2);
cars[17] = new CCar(10390, 470, "Car1", "CrushedCar1", 2);
TimeLeft = 25;
}
private function UpdateSlingShot(_arg1:Number){
var _local2:Number;
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local2 = 0;
if (UserInput.mouseY <= 60){
Mouse.show();
crosshairs.Hide();
} else {
Mouse.hide();
crosshairs.Show();
};
crosshairs.SetPos(UserInput.mouseX, UserInput.mouseY);
UpdateBackground(_arg1, (CCamera.GetLastPixelX() - CCamera.GetPixelX()), (CCamera.GetLastPixelY() - CCamera.GetPixelY()));
if (pumpkins.length < 3){
pumpkins[pumpkins.length] = new WorldBody(((Math.random() * 640) - 320), ((Math.random() * 350) + 60), 1.5, "Pumpkin", new Array(-22, -21.5, -11, -29.5, 10, -31, 25.5, -19, 32, -2, 23.5, 21, 6, 31, -12.5, 28.5, -27.5, 18, -31.5, -2.5), 0.35, 0.7);
pumpkins[(pumpkins.length - 1)].worldBody.ApplyForce(new b2Vec2((Math.random() * 18000), (Math.random() * 18000)), pumpkins[(pumpkins.length - 1)].worldBody.GetCenterPosition());
Settings.scene.swapChildren(pumpkins[(pumpkins.length - 1)].staticMC.mc, crosshairs.mc);
};
if (((((UserInput.mDown) && (reset))) && (crosshairs.IsVisible()))){
fired = true;
reset = false;
};
if (UserInput.mDown == false){
reset = true;
};
_local2 = 0;
while (_local2 < pumpkins.length) {
pumpkins[_local2].Update(_arg1);
if (pumpkins[_local2].worldBody.m_position.y > 15.5){
_local4 = pumpkins[_local2].worldBody.m_position.x;
pumpkins[_local2].worldBody.WakeUp();
pumpkins[_local2].worldBody.ApplyForce(new b2Vec2((-(_local4) * 10), -8950), pumpkins[_local2].worldBody.GetCenterPosition());
};
if (fired){
_local5 = (pumpkins[_local2].staticMC.GetX() - UserInput.mouseX);
_local6 = (pumpkins[_local2].staticMC.GetY() - UserInput.mouseY);
soundEffect[SFX_GUNSHOT].play(0, sfxVol);
shotsFired++;
if (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))) < 32){
shotsHit++;
Score = (Score + 325);
if (playingAllEvents){
};
ScoreText.text = FormatScoreText(Score);
AddPumpkinExplosion((pumpkins[_local2].worldBody.m_position.x * m_physScale), (pumpkins[_local2].worldBody.m_position.y * m_physScale));
pumpkins[_local2].destroy();
pumpkins.splice(_local2, 1);
soundEffect[SFX_PUMPKIN].play(0, sfxVol);
fired = false;
};
};
_local2++;
};
_local2 = 0;
while (_local2 < objs.length) {
objs[_local2].Update(_arg1);
if (objs[_local2].worldBody.m_position.y > 20){
objs[_local2].destroy();
objs.splice(_local2, 1);
};
_local2++;
};
_local3 = Math.floor(TimeLeft);
TimeLeft = (TimeLeft - _arg1);
if (((((!((Math.floor(TimeLeft) == _local3))) && ((TimeLeft <= 3)))) && ((TimeLeft > 0)))){
soundEffect[SFX_LOWTIME].play(0, sfxVol);
};
TimeText.text = FormatTimeText(TimeLeft);
if ((((TimeLeft <= 0)) && (!((miniGameID == HOGTOSS))))){
TimeLeft = 0;
crosshairs.Hide();
Mouse.show();
InitGameOver();
};
TimeText.text = FormatTimeText(TimeLeft);
fired = false;
}
public function gButtonClick(_arg1:Event){
var _local2:Number;
if (disableMenuButtons){
return;
};
_local2 = grabTargetIndex((_arg1.currentTarget as MovieClip));
if (_local2 != -1){
if ((((_local2 == 0)) && (!(gButtons[2].IsVisible())))){
gButtons[2].Show();
gButtons[4].Show();
PauseGame();
} else {
if (_local2 == 0){
gButtons[2].Hide();
gButtons[4].Hide();
};
};
if (_local2 == 2){
if (!Settings.scene.notConnected){
Settings.scene.OpeningLeaderBoards = true;
if (playingAllEvents){
MochiScores.showLeaderboard({boardID:"f50b592eeda563b9", onClose:closedLB});
} else {
switch (miniGameID){
case CARCRUSH:
MochiScores.showLeaderboard({boardID:"f3c941a135f304a0", onClose:closedLB});
break;
case HOGTOSS:
MochiScores.showLeaderboard({boardID:"d0876712b39adbbb", onClose:closedLB});
break;
case SLINGSHOT:
MochiScores.showLeaderboard({boardID:"cf1dda93c80dc3e8", onClose:closedLB});
break;
};
};
PauseGame();
};
};
if (_local2 == 4){
if (Settings.scene.menuMusic != null){
Settings.scene.menuMusic.fadeInLoop(1, false, 999999);
};
if (gameMusic != null){
gameMusic.fadeOut(1);
};
StopAllLoopingSfx();
FromGameDestroy = true;
Settings.scene.SetupFadeIn(10);
};
};
}
public function InitHelp(){
switch (miniGameID){
case CARCRUSH:
help = new CMovieClip("CarCrushinHelp");
break;
case HOGTOSS:
help = new CMovieClip("HogTossHelp");
break;
case SLINGSHOT:
help = new CMovieClip("PumpkinShootHelp");
break;
};
help.AddToScene();
help.SetX(320);
help.SetY(240);
help.SetFade(0);
helpIn = true;
Settings.scene.setChildIndex(help.mc, (Settings.scene.numChildren - 2));
displayHelp = false;
gamePaused = false;
doHelpInit = false;
Update(0.1, 0, 0);
TimeLeft = (TimeLeft + 0.1);
TimeText.text = FormatTimeText(TimeLeft);
main.UpdateTimer();
main.UpdateTimer();
gamePaused = true;
displayHelp = true;
disableMenuButtons = true;
}
public function InitBackGround(){
var _local1:Number;
_local1 = 0;
hillSprite = new Array();
hillSprite[0] = new GNPBody(0, 480, "Hill1");
hillSprite[0].SetMoveScale(0.5);
hillSprite[1] = new GNPBody(1240, 480, "Hill1");
hillSprite[1].SetMoveScale(0.5);
hillSprite[2] = new GNPBody(2240, 480, "Hill1");
hillSprite[2].SetMoveScale(0.5);
barnSprite1 = new GNPBody(0x0400, 480, "Barn");
barnSprite1.SetMoveScale(0.7);
barnSprite2 = new GNPBody(3024, 480, "Barn");
barnSprite2.SetMoveScale(0.7);
if (CARCRUSH == miniGameID){
gFence = new Array();
_local1 = 0;
while (_local1 < 61) {
gFence[_local1] = new GNPBody((-392 + (_local1 * 196)), 480, "FenceRepeat1");
gFence[_local1].SetMoveScale(0.9);
_local1++;
};
gBody = new Array();
_local1 = 0;
while (_local1 < 23) {
gBody[_local1] = new BoxBody(GENERIC, (-1280 + (_local1 * 640)), 480, 0, "Ground");
_local1++;
};
finish = new GNPBody(11167, 475, "Finish");
finish.SetMoveScale(0.9);
} else {
gFence = new Array();
_local1 = 0;
while (_local1 < 300) {
gFence[_local1] = new GNPBody((-320 + (_local1 * 196)), 480, "FenceRepeat1");
gFence[_local1].SetMoveScale(1);
_local1++;
};
gBody = new Array();
_local1 = 0;
while (_local1 < 260) {
gBody[_local1] = new BoxBody(GENERIC, (_local1 * 640), 480, 0, "Ground");
_local1++;
};
gBody[0].staticMC.mc.visible = false;
gBody[259] = new BoxBody(GENERIC, 166000, 240, 0, "Ground", 0xFFFFFF, 0xFFFFFF, (Math.PI / 2));
groundSprite = new GNPBody(0, 480, "Ground");
};
gClouds = new Array();
_local1 = 0;
while (_local1 < 14) {
switch (miniGameID){
case CARCRUSH:
gClouds[_local1] = new GNPBody((((Math.random() * 440) - 220) + (_local1 * 820)), (Math.random() * 230), "Cloud1");
break;
case HOGTOSS:
break;
};
_local1++;
};
}
private function dragSfx(_arg1:MouseEvent):void{
if (!draggingMusic){
draggingSfx = true;
};
}
private function GameOverSubmit(_arg1:MouseEvent){
initSubmitScore = true;
}
private function FormatScoreText(_arg1:Number):String{
var _local2:String;
var _local3:String;
var _local4:Number;
var _local5:Array;
var _local6:*;
var _local7:Number;
var _local8:Number;
_local2 = ("" + _arg1);
_local3 = "";
_local4 = Math.floor((_local2.length / 3));
_local5 = new Array();
_local6 = 0;
while (_local6 < _local4) {
_local5[_local6] = (((_local6 + 1) * 3) - 1);
_local6++;
};
_local7 = 0;
_local8 = (_local2.length - 1);
_local6 = 0;
while (_local6 < _local2.length) {
_local3 = (_local3 + _local2.charAt(_local6));
if ((((((_local8 == 3)) && ((_local2.length > 3)))) || ((((_local8 == 6)) && ((_local2.length > 6)))))){
_local3 = (_local3 + ",");
};
_local8--;
_local6++;
};
return (_local3);
}
public function FormatTimeText(_arg1:Number):String{
var _local2:Number;
_local2 = Math.floor(_arg1);
return (("" + _local2));
}
public function Destroy(_arg1:Boolean=false){
var _local2:Number;
if (((!((gameMusic == null))) && (_arg1))){
gameMusic.Destroy();
gameMusic = null;
};
if (soundEffect != null){
_local2 = 0;
while (_local2 < soundEffect.length) {
if (soundEffect[_local2].bPlaying){
soundEffect[_local2].stop();
};
soundEffect[_local2].Destroy();
soundEffect[_local2] = null;
_local2++;
};
soundEffect.splice(0, soundEffect.length);
soundEffect = null;
};
_local2 = 0;
_local2 = 0;
while (_local2 < hillSprite.length) {
hillSprite[_local2].destroy();
_local2++;
};
hillSprite.splice(0, hillSprite.length);
hillSprite = null;
barnSprite1.destroy();
barnSprite1 = null;
if (barnSprite2 != null){
barnSprite2.destroy();
barnSprite2 = null;
};
_local2 = 0;
while (_local2 < gFence.length) {
gFence[_local2].destroy();
_local2++;
};
gFence.splice(0, gFence.length);
gFence = null;
_local2 = 0;
while (_local2 < gBody.length) {
gBody[_local2].destroy();
_local2++;
};
gBody.splice(0, gBody.length);
gBody = null;
if (finish != null){
finish.destroy();
finish = null;
};
_local2 = 0;
while (_local2 < gClouds.length) {
gClouds[_local2].destroy();
_local2++;
};
gClouds.splice(0, gClouds.length);
gClouds = null;
if (truck != null){
truck.destroy();
truck = null;
};
if (cars != null){
_local2 = 0;
while (_local2 < cars.length) {
cars[_local2].destroy();
_local2++;
};
cars.splice(0, cars.length);
cars = null;
};
if (bodies != null){
_local2 = 0;
while (_local2 < bodies.length) {
bodies[_local2].destroy();
_local2++;
};
bodies.splice(0, bodies.length);
bodies = null;
};
if (hog != null){
hog.destroy();
hog = null;
};
if (hogLine){
Settings.scene.removeChild(hogLine);
hogLine = null;
};
camera = null;
if (pumpkins != null){
_local2 = 0;
while (_local2 < pumpkins.length) {
pumpkins[_local2].destroy();
_local2++;
};
pumpkins.splice(0, pumpkins.length);
pumpkins = null;
};
if (objs != null){
_local2 = 0;
while (_local2 < objs.length) {
objs[_local2].destroy();
_local2++;
};
objs.splice(0, objs.length);
objs = null;
};
if (crosshairs != null){
crosshairs.Destroy();
crosshairs = null;
};
if (platformJoint != null){
m_world.DestroyJoint(platformJoint);
platformJoint = null;
};
if (mouseJoint != null){
m_world.DestroyJoint(mouseJoint);
mouseJoint = null;
};
if (groundSprite != null){
groundSprite.destroy();
groundSprite = null;
};
if (speakerMC != null){
speakerMC.mc.removeEventListener(MouseEvent.CLICK, displayVolumeFunc);
speakerMC.mc.removeEventListener(MouseEvent.MOUSE_OVER, overVolumeFunc);
speakerMC.mc.removeEventListener(MouseEvent.MOUSE_OUT, outVolumeFunc);
speakerMC.RemoveFromScene();
speakerMC = null;
};
if (volumeBoxMC != null){
volumeBoxMC.RemoveFromScene();
volumeBoxMC = null;
};
if (musicSlider != null){
musicSlider.RemoveFromScene();
musicSlider = null;
};
if (sfxSlider != null){
sfxSlider.RemoveFromScene();
sfxSlider = null;
};
playGame = false;
}
public function UpdateHelp(_arg1:Number){
if (helpIn){
help.SetFade((help.GetFade() + (_arg1 * 2)));
} else {
help.SetFade((help.GetFade() - (_arg1 * 2)));
};
if (((UserInput.isMousePressed()) || (UserInput.anyKeyPressed()))){
helpIn = false;
};
if ((((help.GetFade() <= 0)) && ((RSG == null)))){
RSG = new CMovieClip("ReadySetGo");
RSG.SetPos(320, 240);
RSG.AddToScene();
rsgFrame = 0;
if (miniGameID != HOGTOSS){
soundEffect[SFX_RSG].play(0, sfxVol);
};
};
if (RSG != null){
if (miniGameID == HOGTOSS){
RSG.mc.gotoAndStop((RSG.mc.totalFrames - 1));
};
if (RSG.IsVisible()){
rsgFrame = (rsgFrame + (_arg1 * 120));
while ((((rsgFrame >= 1)) && ((RSG.mc.currentFrame < RSG.mc.totalFrames)))) {
RSG.mc.nextFrame();
rsgFrame = (rsgFrame - 1);
};
};
};
if (((((!(helpIn)) && ((help.GetFade() <= 0)))) && ((((miniGameID == HOGTOSS)) || ((RSG.mc.currentFrame == RSG.mc.totalFrames)))))){
RSG.Destroy();
RSG = null;
help.Destroy();
help = null;
displayHelp = false;
gamePaused = false;
disableMenuButtons = false;
if (((!(replayGame)) && ((gameMusic.bPlaying == false)))){
TransitionToGameMusic();
};
replayGame = false;
};
}
public function Update(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
_local4 = 0;
if (hitItUp){
ok = false;
okLength = 5;
hitItUp = false;
if (Settings.scene.menuMusic != null){
Settings.scene.menuMusic.fadeInLoop(1, false, 999999);
};
if (gameMusic != null){
gameMusic.fadeOut(1);
};
PauseGame();
StopAllLoopingSfx();
FromGameDestroy = true;
Settings.scene.SetupFadeIn(15);
Mouse.show();
};
if (bgImage == null){
bgImage = new CMovieClip("TheGameBackground");
bgImage.AddToScene();
bgImage.SetPos(0, 0);
Settings.scene.swapChildrenAt(0, Settings.scene.getChildIndex(bgImage.mc));
};
if (TimeText == null){
TimeText = new TextField();
ScoreText = new TextField();
tTextFormat = new TextFormat("Ink Pad", 36);
scTextFormat = new TextFormat("Ink Pad", 36);
scTextFormat.align = "left";
tTextFormat.align = "left";
TimeText.text = "0";
ScoreText.text = "0";
TimeText.multiline = false;
ScoreText.multiline = false;
TimeText.defaultTextFormat = tTextFormat;
ScoreText.defaultTextFormat = scTextFormat;
TimeText.embedFonts = true;
ScoreText.embedFonts = true;
ScoreText.textColor = 0xFFFFFF;
TimeText.textColor = 0xFFFFFF;
TimeText.x = 100;
TimeText.y = 2;
TimeText.width = 65;
TimeText.height = 38;
TimeText.selectable = false;
ScoreText.x = 320;
ScoreText.y = 2;
ScoreText.width = 128;
ScoreText.height = 38;
ScoreText.selectable = false;
Settings.scene.addChild(TimeText);
Settings.scene.addChild(ScoreText);
};
if (StartNewGame){
InitNewGame(StartGameID, true);
StartNewGame = false;
};
if (!playGame){
return;
};
if (doHelpInit){
InitHelp();
return;
};
UserInput.mouseX = _arg2;
UserInput.mouseY = _arg3;
if (!gamePaused){
if (!ok){
okLength = (okLength - _arg1);
};
if (okLength <= 0){
hitItUp = true;
};
accum = (accum + _arg1);
while (accum >= (1 / 120)) {
m_world.Step((1 / 120), 10);
accum = (accum - (1 / 120));
};
CCamera.Update(_arg1);
switch (miniGameID){
case CARCRUSH:
UpdateCarCrush(_arg1);
break;
case HOGTOSS:
UpdateHogToss(_arg1);
break;
case SLINGSHOT:
UpdateSlingShot(_arg1);
break;
};
if (!bGameOver){
disableMenuButtons = false;
};
_local4 = 0;
while (_local4 < soundEffect.length) {
soundEffect[_local4].Update(_arg1);
_local4++;
};
} else {
if (bGameOver){
UpdateGameOver(_arg1);
} else {
if (displayVolume){
_local5 = UserInput.mouseX;
if (_local5 < 399){
_local5 = 399;
};
if (_local5 > 551){
_local5 = 551;
};
if (draggingMusic){
musicSlider.SetX(_local5);
musicVol = ((_local5 - 399) / (551 - 399));
UpdateMusicVol();
};
if (draggingSfx){
sfxSlider.SetX(_local5);
sfxVol = ((_local5 - 399) / (551 - 399));
UpdateSfxVol();
};
if (UserInput.mDown == false){
draggingSfx = false;
draggingMusic = false;
};
} else {
if (displayHelp){
UpdateHelp(_arg1);
} else {
if (gamePaused){
Settings.scene.Paused.visible = !(hidePaused);
if (((UserInput.anyKeyPressed()) && (!(Settings.scene.OpeningLeaderBoards)))){
disableMenuButtons = false;
Settings.scene.Paused.visible = false;
gamePaused = false;
gButtons[2].Hide();
gButtons[3].Hide();
gButtons[4].Hide();
gButtons[5].Hide();
if (miniGameID == SLINGSHOT){
_local4 = 0;
while (_local4 < pumpkins.length) {
pumpkins[_local4].staticMC.Show();
_local4++;
};
};
};
};
};
};
};
};
if (gameMusic != null){
if (gameMusic.bPlaying){
gameMusic.Update(_arg1);
};
};
UserInput.resetKeysPressed();
}
public function UpdateGameOver(_arg1:Number){
if (gameOverIn){
if (box.GetX() > 320){
box.AddX((-(_arg1) * 0x0500));
} else {
box.SetX(320);
};
} else {
if (box.GetX() > -320){
box.AddX((-(_arg1) * 0x0500));
} else {
box.SetX(-320);
};
};
if (initSubmitScore){
initSubmitScore = false;
box.mc.SubmitButton.visible = false;
if (playingAllEvents){
MochiScores.showLeaderboard({boardID:"f50b592eeda563b9", score:Score, onClose:closedLB});
} else {
switch (miniGameID){
case CARCRUSH:
MochiScores.showLeaderboard({boardID:"f3c941a135f304a0", score:Score, onClose:closedLB});
break;
case HOGTOSS:
MochiScores.showLeaderboard({boardID:"d0876712b39adbbb", score:Score, onClose:closedLB});
break;
case SLINGSHOT:
MochiScores.showLeaderboard({boardID:"cf1dda93c80dc3e8", score:Score, onClose:closedLB});
break;
};
};
};
if (!hogReset){
if (((((((((box.mc.BottomMessage.visible) && (UserInput.isMousePressed()))) && (gameOverIn))) && ((box.GetX() == 320)))) || (replayGame))){
initGameOverFinish = true;
};
} else {
if (((((UserInput.isMousePressed()) && (gameOverIn))) && ((box.GetX() == 320)))){
initGameOverFinish = true;
};
};
if (((((initGameOverFinish) && (gameOverIn))) && ((box.GetX() == 320)))){
gameOverIn = false;
hidePaused = true;
initGameOverFinish = false;
};
if (((!(gameOverIn)) && ((box.GetX() <= -320)))){
disableMenuButtons = false;
if (!hogReset){
box.mc.QuitButton.removeEventListener(MouseEvent.CLICK, GameOverQuit);
box.mc.PlayAgainButton.removeEventListener(MouseEvent.CLICK, GameOverPlayAgain);
box.mc.SubmitButton.removeEventListener(MouseEvent.CLICK, GameOverSubmit);
};
box.Destroy();
box = null;
bGameOver = false;
if (((((!(replayGame)) && (!(hogReset)))) && (!(playingAllEvents)))){
if (Settings.scene.menuMusic != null){
Settings.scene.menuMusic.fadeInLoop(1, false, 999999);
};
if (gameMusic != null){
gameMusic.fadeOut(1);
};
};
if (playingAllEvents){
if (!hogReset){
miniGameID++;
};
if (miniGameID > SLINGSHOT){
if (replayGame){
Destroy(true);
replayGame = false;
InitNewGame(ALLEVENTS, true);
} else {
if (Settings.scene.menuMusic != null){
Settings.scene.menuMusic.fadeInLoop(1, false, 999999);
};
if (gameMusic != null){
gameMusic.fadeOut(1);
};
StopAllLoopingSfx();
FromGameDestroy = true;
Settings.scene.SetupFadeIn(10);
};
} else {
switch ((miniGameID - 1)){
case CARCRUSH:
Score = (Score + (Math.floor(TimeLeft) * 95));
Destroy(true);
break;
case HOGTOSS:
Destroy(false);
break;
case SLINGSHOT:
Destroy(false);
break;
};
if (!hogReset){
EventScores[(miniGameID - 1)] = Score;
};
InitNewGame(miniGameID, false);
if (gameMusic.bPlaying == false){
if ((((miniGameID == SLINGSHOT)) && (!(playingAllEvents)))){
gameMusic.loop(20000, musicVol, 9999999);
} else {
gameMusic.loop(0, musicVol, 9999999);
};
gameMusic.fadeIn(1, false);
UpdateMusicVol();
};
};
hogReset = false;
} else {
if (((hogReset) || (replayGame))){
Destroy();
InitNewGame(miniGameID, true);
} else {
StopAllLoopingSfx();
FromGameDestroy = true;
Settings.scene.SetupFadeIn(10);
};
};
if (((((!(replayGame)) && (!(hogReset)))) && (!(playingAllEvents)))){
if (gameMusic != null){
gameMusic.Destroy();
gameMusic = null;
};
};
StopAllLoopingSfx();
};
}
public function grabTargetIndex(_arg1:MovieClip){
var _local2:*;
_local2 = 0;
while (_local2 < gButtons.length) {
if ((((_arg1 == gButtons[_local2].mc)) || ((_arg1 == gButtons[(_local2 + 1)].mc)))){
return (_local2);
};
_local2 = (_local2 + 2);
};
return (-1);
}
private function overVolumeFunc(_arg1:MouseEvent):void{
overMenuButton = true;
}
public function closedLB(){
Settings.scene.OpeningLeaderBoards = false;
}
private function outVolumeFunc(_arg1:MouseEvent):void{
overMenuButton = false;
}
public function InitSSBackGround(){
var _local1:Number;
_local1 = 0;
hillSprite = new Array();
hillSprite[0] = new GNPBody(0, 480, "Hill1");
hillSprite[0].SetMoveScale(0.5);
barnSprite1 = new GNPBody(-304, 480, "Barn");
barnSprite2 = null;
gFence = new Array();
_local1 = 0;
while (_local1 < 9) {
gFence[_local1] = new GNPBody((-588 + (_local1 * 196)), 480, "FenceRepeat1");
_local1++;
};
gBody = new Array();
_local1 = 0;
while (_local1 < 3) {
gBody[_local1] = new BoxBody(GENERIC, (-640 + (_local1 * 640)), 480, 0, "Ground");
_local1++;
};
gClouds = new Array();
_local1 = 0;
while (_local1 < 12) {
gClouds[_local1] = new GNPBody((((Math.random() * 640) - 320) + (_local1 * 480)), (Math.random() * 300), "Cloud1");
_local1++;
};
TimeLeft = 45;
}
}
}//package
Section 113
//MenuMusic (MenuMusic)
package {
import flash.media.*;
public dynamic class MenuMusic extends Sound {
}
}//package
Section 114
//MochiAd (MochiAd)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.2");
}
public static function showTimedAd(_arg1:Object):void{
MochiAd.showInterLevelAd(_arg1);
}
public static function _allowDomains(_arg1:String):String{
var _local2:String;
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function load(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var depth:Number;
var mc:MovieClip;
var wh:Array;
var lv:URLVariables;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var f:Function;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
DEFAULTS = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
lv = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
f = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
mc._mochiad_ctr_failed = true;
};
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function sendHighScore(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["sendHighScore", _arg1], _arg2, _arg3);
return (true);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local3:Object;
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
_local3 = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _cleanup(_arg1:Object):void{
var idx:Number;
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
idx = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = _local1.loaderInfo.bytesTotal;
if ((((_local4 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
_local3 = true;
};
};
};
if ((((_local2 > chk.ad_msec)) || (this.parent._mochiad_ctr_failed))){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local3:Object;
var _local4:Number;
var _local5:Number;
var _local6:Array;
_local3 = _arg2.getBounds(_arg2.root);
_local4 = 0;
_local5 = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip;
_local4 = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _loadCommunicator(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var clipname:String;
var server:String;
var depth:Number;
var mc:MovieClip;
var lv:URLVariables;
var k:String;
var lc:LocalConnection;
var name:String;
var req:URLRequest;
var loader:Loader;
var options = _arg1;
DEFAULTS = {com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
clipname = ("_mochiad_com_" + options.id);
if (!MochiAd._isNetworkAvailable()){
return (null);
};
if (clip[clipname]){
return (clip[clipname]);
};
server = (options.com_server + options.id);
MochiAd._allowDomains(server);
delete options.id;
delete options.com_server;
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, clipname, depth);
lv = new URLVariables();
for (k in options) {
lv[k] = options[k];
};
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.name = name;
mc.lc = lc;
lv.lc = name;
mc._id = 0;
mc._queue = [];
mc.rpcResult = function (_arg1:Object):void{
var _local3:Array;
var _local4:Array;
var _local5:Number;
var _local6:Object;
var _local7:Object;
_arg1 = parseInt(_arg1.toString());
_local3 = mc._callbacks[_arg1];
if (typeof(_local3) == "undefined"){
return;
};
delete mc._callbacks[_arg1];
_local4 = [];
_local5 = 2;
while (_local5 < _local3.length) {
_local4.push(_local3[_local5]);
_local5++;
};
_local5 = 1;
while (_local5 < arguments.length) {
_local4.push(arguments[_local5]);
_local5++;
};
_local6 = _local3[1];
_local7 = _local3[0];
if (((_local7) && ((typeof(_local6) == "string")))){
_local6 = _local7[_local6];
};
if (typeof(_local6) == "function"){
_local6.apply(_local7, _local4);
};
};
mc._didConnect = function (_arg1:String):void{
var _local2:Array;
var _local3:Function;
var _local4:Number;
var _local5:Array;
mc._endpoint = _arg1;
_local2 = mc._queue;
delete mc._queue;
_local3 = mc.doSend;
_local4 = 0;
while (_local4 < _local2.length) {
_local5 = _local2[_local4];
_local3.apply(this, _local5);
_local4++;
};
};
mc.doSend = function (_arg1:Array, _arg2:Object, _arg3:Object):void{
var _local5:Number;
var _local6:LocalConnection;
var _local7:Array;
var _local8:Number;
if (mc._endpoint == null){
_local7 = [];
_local8 = 0;
while (_local8 < arguments.length) {
_local7.push(arguments[_local8]);
_local8++;
};
mc._queue.push(_local7);
return;
};
mc._id = (mc._id + 1);
_local5 = mc._id;
mc._callbacks[_local5] = [_arg2, ((_arg3) || (_arg2))];
_local6 = new LocalConnection();
_local6.send(mc._endpoint, "rpc", _local5, _arg1);
};
mc._callbacks = {};
mc._callbacks[0] = [mc, "_didConnect"];
lv.st = getTimer();
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader = new Loader();
loader.load(req);
mc.addChild(loader);
mc._mochiad_com = loader;
return (mc);
}
public static function showPreGameAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var bar:MovieClip;
var bar_color:Number;
var bar_background:Number;
var bar_outline:Number;
var backing_mc:MovieClip;
var backing:Object;
var inside_mc:MovieClip;
var inside:Object;
var outline_mc:MovieClip;
var outline:Object;
var complete:Boolean;
var unloaded:Boolean;
var f:Function;
var r:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
var fn:Function;
MochiAd._cleanup(mc);
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
bar = createEmptyMovieClip(chk, "_mochiad_bar", 4);
bar.x = 10;
bar.y = (h - 20);
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
f = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Object;
var _local10:Number;
var _local11:Number;
if (!this.parent.parent){
delete this["onEnterFrame"];
return;
};
_local1 = this.parent.parent.root;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
_local7 = ((100 * _local6) / _local5);
_local8 = ((100 * _local3) / chk.ad_msec);
_local9 = this._mochiad_bar._inside;
_local10 = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
if (!chk.showing){
_local11 = _local2.loaderInfo.bytesTotal;
if ((((_local11 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local3 > chk.ad_timeout){
_local4 = true;
};
};
};
if ((((_local3 > chk.ad_msec)) || (this.parent._mochiad_ctr_failed))){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
MochiAd.showPreGameAd(_arg1);
}
public static function fetchHighScores(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["fetchHighScores", _arg1], _arg2, _arg3);
return (true);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var f:Function;
var mc = _arg1;
f = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 115
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 116
//MonsterTruck (MonsterTruck)
package {
import flash.display.*;
public dynamic class MonsterTruck extends MovieClip {
}
}//package
Section 117
//MonsterTruckMusic (MonsterTruckMusic)
package {
import flash.media.*;
public dynamic class MonsterTruckMusic extends Sound {
}
}//package
Section 118
//MultiWorldBody (MultiWorldBody)
package {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
class MultiWorldBody {
var staticBody:b2BodyDef;
var worldBody:b2Body;
var staticMC:CMovieClip;
function MultiWorldBody(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:String, _arg5:Array, _arg6:Number=1, _arg7:Number=0){
var _local8:*;
var _local9:b2PolyDef;
var _local10:*;
super();
staticMC = new CMovieClip(_arg4);
staticMC.AddToScene();
staticBody = new b2BodyDef();
_local8 = 0;
while (_local8 < _arg5.length) {
_local9 = new b2PolyDef();
_local9.vertexCount = (_arg5[_local8].length / 2);
_local10 = 0;
while (_local10 < _local9.vertexCount) {
_local9.vertices[_local10].Set((_arg5[_local8][(_local10 * 2)] / MainGame.m_physScale), (_arg5[_local8][((_local10 * 2) + 1)] / MainGame.m_physScale));
_local10++;
};
_local9.friction = _arg6;
_local9.density = _arg3;
_local9.restitution = _arg7;
staticBody.AddShape(_local9);
_local8++;
};
staticBody.position.Set((_arg1 / MainGame.m_physScale), (_arg2 / MainGame.m_physScale));
worldBody = MainGame.m_world.CreateBody(staticBody);
}
public function Update(_arg1:Number){
var _local2:Number;
var _local3:Number;
_local2 = CCamera.GetPixelX();
_local3 = CCamera.GetPixelY();
staticMC.SetPos(((worldBody.m_position.x * MainGame.m_physScale) - _local2), ((worldBody.m_position.y * MainGame.m_physScale) - _local3));
staticMC.SetRot(((worldBody.m_rotation * 180) / Math.PI));
}
public function destroy(){
MainGame.m_world.DestroyBody(worldBody);
staticMC.RemoveFromScene();
}
}
}//package
Section 119
//p1 (p1)
package {
import flash.display.*;
public dynamic class p1 extends MovieClip {
}
}//package
Section 120
//p2 (p2)
package {
import flash.display.*;
public dynamic class p2 extends MovieClip {
}
}//package
Section 121
//p3 (p3)
package {
import flash.display.*;
public dynamic class p3 extends MovieClip {
}
}//package
Section 122
//p4 (p4)
package {
import flash.display.*;
public dynamic class p4 extends MovieClip {
}
}//package
Section 123
//p5 (p5)
package {
import flash.display.*;
public dynamic class p5 extends MovieClip {
}
}//package
Section 124
//p6 (p6)
package {
import flash.display.*;
public dynamic class p6 extends MovieClip {
}
}//package
Section 125
//p7 (p7)
package {
import flash.display.*;
public dynamic class p7 extends MovieClip {
}
}//package
Section 126
//p8 (p8)
package {
import flash.display.*;
public dynamic class p8 extends MovieClip {
}
}//package
Section 127
//PigGrab (PigGrab)
package {
import flash.media.*;
public dynamic class PigGrab extends Sound {
}
}//package
Section 128
//PigHit (PigHit)
package {
import flash.media.*;
public dynamic class PigHit extends Sound {
}
}//package
Section 129
//PigTail (PigTail)
package {
import flash.display.*;
public dynamic class PigTail extends MovieClip {
}
}//package
Section 130
//PigThrow (PigThrow)
package {
import flash.media.*;
public dynamic class PigThrow extends Sound {
}
}//package
Section 131
//PlatformLong (PlatformLong)
package {
import flash.display.*;
public dynamic class PlatformLong extends MovieClip {
}
}//package
Section 132
//PlatformShort (PlatformShort)
package {
import flash.display.*;
public dynamic class PlatformShort extends MovieClip {
}
}//package
Section 133
//PlatformSuperLong (PlatformSuperLong)
package {
import flash.display.*;
public dynamic class PlatformSuperLong extends MovieClip {
}
}//package
Section 134
//PlayAgain (PlayAgain)
package {
import flash.display.*;
public dynamic class PlayAgain extends MovieClip {
}
}//package
Section 135
//Pumpkin (Pumpkin)
package {
import flash.display.*;
public dynamic class Pumpkin extends MovieClip {
}
}//package
Section 136
//PumpkinExplode (PumpkinExplode)
package {
import flash.media.*;
public dynamic class PumpkinExplode extends Sound {
}
}//package
Section 137
//PumpkinShootHelp (PumpkinShootHelp)
package {
import flash.display.*;
public dynamic class PumpkinShootHelp extends MovieClip {
}
}//package
Section 138
//Quit (Quit)
package {
import flash.display.*;
public dynamic class Quit extends MovieClip {
}
}//package
Section 139
//ReadySetGo (ReadySetGo)
package {
import flash.display.*;
public dynamic class ReadySetGo extends MovieClip {
public function ReadySetGo(){
addFrameScript(0, frame1, 178, frame179);
}
function frame1(){
stop();
}
function frame179(){
stop();
}
}
}//package
Section 140
//ReadySetGoSfx (ReadySetGoSfx)
package {
import flash.media.*;
public dynamic class ReadySetGoSfx extends Sound {
}
}//package
Section 141
//Rock (Rock)
package {
import flash.display.*;
public dynamic class Rock extends MovieClip {
}
}//package
Section 142
//RollOver (RollOver)
package {
import flash.media.*;
public dynamic class RollOver extends Sound {
}
}//package
Section 143
//SliderButton (SliderButton)
package {
import flash.display.*;
public dynamic class SliderButton extends MovieClip {
}
}//package
Section 144
//Speaker (Speaker)
package {
import flash.display.*;
public dynamic class Speaker extends MovieClip {
}
}//package
Section 145
//Star (Star)
package {
import flash.display.*;
public dynamic class Star extends MovieClip {
}
}//package
Section 146
//Submit (Submit)
package {
import flash.display.*;
public dynamic class Submit extends MovieClip {
}
}//package
Section 147
//SunStars1 (SunStars1)
package {
import flash.display.*;
public dynamic class SunStars1 extends MovieClip {
}
}//package
Section 148
//TheGameBackground (TheGameBackground)
package {
import flash.display.*;
public dynamic class TheGameBackground extends MovieClip {
}
}//package
Section 149
//TimeBonus (TimeBonus)
package {
import flash.media.*;
public dynamic class TimeBonus extends Sound {
}
}//package
Section 150
//Tire (Tire)
package {
import flash.display.*;
public dynamic class Tire extends MovieClip {
}
}//package
Section 151
//Title (Title)
package {
import flash.display.*;
public dynamic class Title extends MovieClip {
}
}//package
Section 152
//Track23Music (Track23Music)
package {
import flash.media.*;
public dynamic class Track23Music extends Sound {
}
}//package
Section 153
//Wind (Wind)
package {
import flash.media.*;
public dynamic class Wind extends Sound {
}
}//package
Section 154
//VolumeBox (VolumeBox)
package {
import flash.display.*;
public dynamic class VolumeBox extends MovieClip {
}
}//package
Section 155
//WorldBody (WorldBody)
package {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
class WorldBody {
var staticBody:b2BodyDef;
var worldBody:b2Body;
var staticMC:CMovieClip;
function WorldBody(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:String, _arg5:Array, _arg6:Number=1, _arg7:Number=0){
var _local8:b2PolyDef;
var _local9:*;
super();
staticMC = new CMovieClip(_arg4);
staticMC.AddToScene();
_local8 = new b2PolyDef();
staticBody = new b2BodyDef();
_local8.vertexCount = (_arg5.length / 2);
_local9 = 0;
while (_local9 < _local8.vertexCount) {
_local8.vertices[_local9].Set((_arg5[(_local9 * 2)] / MainGame.m_physScale), (_arg5[((_local9 * 2) + 1)] / MainGame.m_physScale));
_local9++;
};
_local8.friction = _arg6;
_local8.density = _arg3;
_local8.restitution = _arg7;
staticBody.AddShape(_local8);
staticBody.position.Set((_arg1 / MainGame.m_physScale), (_arg2 / MainGame.m_physScale));
worldBody = MainGame.m_world.CreateBody(staticBody);
}
public function Update(_arg1:Number){
var _local2:Number;
var _local3:Number;
_local2 = CCamera.GetPixelX();
_local3 = CCamera.GetPixelY();
staticMC.SetPos(((worldBody.m_position.x * MainGame.m_physScale) - _local2), ((worldBody.m_position.y * MainGame.m_physScale) - _local3));
staticMC.SetRot(((worldBody.m_rotation * 180) / Math.PI));
}
public function destroy(){
MainGame.m_world.DestroyBody(worldBody);
staticMC.RemoveFromScene();
}
}
}//package