STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229595
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2595 · P5190

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/43689596?noj=FRM43689596-22DC" width="1" height="1"></div>

inFAMOUS Precinct Assault.swf

This is the info page for
Flash #74587

(Click the ID number above for more basic data on this flash file.)


ActionScript [AS3]
Section 1
//AbstractMain (com.kerb.game.AbstractMain) package com.kerb.game { import flash.events.*; import flash.display.*; public class AbstractMain extends Sprite { protected var PreviousSectionClass:Class; protected var currentSection:AbstractSection; protected var overlaySprite:Sprite; protected var contentSprite:Sprite; public function AbstractMain(){ contentSprite = new Sprite(); addChild(contentSprite); overlaySprite = new Sprite(); overlaySprite.mouseEnabled = false; addChild(overlaySprite); } protected function gotoSection(_arg1:Class):void{ disposeCurrentSection(); currentSection = new (_arg1); currentSection.setPreviousSection(PreviousSectionClass); currentSection.addEventListener(Event.COMPLETE, onSectionComplete); contentSprite.addChild(currentSection); PreviousSectionClass = _arg1; } protected function disposeCurrentSection():void{ if (currentSection != null){ currentSection.removeEventListener(Event.COMPLETE, onSectionComplete); currentSection.dispose(); contentSprite.removeChild(currentSection); }; } protected function onIdentClick(_arg1:MouseEvent):void{ } protected function onIdentComplete(_arg1:Event):void{ currentSection.removeEventListener(MouseEvent.CLICK, onIdentClick); onSectionComplete(_arg1); } protected function showIdent(_arg1:MovieClip, _arg2:Class):void{ disposeCurrentSection(); currentSection = new Ident(_arg1, _arg2); currentSection.addEventListener(Event.COMPLETE, onIdentComplete); currentSection.addEventListener(MouseEvent.CLICK, onIdentClick); currentSection.buttonMode = true; contentSprite.addChild(currentSection); } protected function onSectionComplete(_arg1:Event):void{ gotoSection(currentSection.getNextSection()); } } }//package com.kerb.game
Section 2
//AbstractPreload (com.kerb.game.AbstractPreload) package com.kerb.game { import flash.events.*; import flash.display.*; import flash.ui.*; import flash.utils.*; import flash.net.*; public class AbstractPreload extends MovieClip { protected var lowQualityItem:ContextMenuItem; protected var url:String; protected var highQualityItem:ContextMenuItem; protected var mediumQualityItem:ContextMenuItem; public static const KERB_SITE_URL:String = "http://www.kerb.co.uk"; public static const DOWNLOAD_THIS_GAME_URL:String = "http://blog.kerb.co.uk/download.php?url="; public static const KERB_GAMES_URL:String = "http://www.kerbgames.com"; public function AbstractPreload(){ initStage(); initContextMenu(); } protected function initContextMenu():void{ var _local1:ContextMenuItem; contextMenu = new ContextMenu(); contextMenu.hideBuiltInItems(); url = loaderInfo.url; _local1 = new ContextMenuItem("Built by Kerb!", false); _local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onKerbMenuItemSelect); contextMenu.customItems.push(_local1); lowQualityItem = new ContextMenuItem("Low Quality (fastest)", true); lowQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect); contextMenu.customItems.push(lowQualityItem); mediumQualityItem = new ContextMenuItem("Medium Quality", false); mediumQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect); contextMenu.customItems.push(mediumQualityItem); highQualityItem = new ContextMenuItem("• High Quality (slowest)", false); highQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect); contextMenu.customItems.push(highQualityItem); _local1 = new ContextMenuItem("Download This Game", true); _local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onDownloadMenuItemSelect); contextMenu.customItems.push(_local1); } protected function onKerbMenuItemSelect(_arg1:Event):void{ navigateToURL(new URLRequest(KERB_SITE_URL), "_blank"); } protected function initStage():void{ stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.stageFocusRect = false; } protected function onDownloadMenuItemSelect(_arg1:Event):void{ navigateToURL(new URLRequest((DOWNLOAD_THIS_GAME_URL + url)), "_blank"); } protected function initMainContent(_arg1:String):void{ var _local2:Class = Class(getDefinitionByName(_arg1)); if (_local2){ addChild((new (_local2) as DisplayObject)); }; } protected function onQualityMenuItemSelect(_arg1:Event):void{ lowQualityItem.caption = "Low Quality (fast)"; mediumQualityItem.caption = "Medium Quality"; highQualityItem.caption = "High Quality (slow)"; switch (_arg1.currentTarget){ case lowQualityItem: lowQualityItem.caption = ("• " + lowQualityItem.caption); stage.quality = StageQuality.LOW; break; case mediumQualityItem: mediumQualityItem.caption = ("• " + mediumQualityItem.caption); stage.quality = StageQuality.MEDIUM; break; case highQualityItem: highQualityItem.caption = ("• " + highQualityItem.caption); stage.quality = StageQuality.HIGH; break; }; } } }//package com.kerb.game
Section 3
//AbstractSection (com.kerb.game.AbstractSection) package com.kerb.game { import flash.events.*; import flash.display.*; import com.kerb.utils.*; public class AbstractSection extends MovieClip implements IDisposable { protected var NextSectionClass:Class; protected var PreviousSectionClass:Class; protected var keyboardNavigator:KeyboardNavigator; public function AbstractSection(){ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } protected function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); keyboardNavigator = new KeyboardNavigator(stage); init(); } public function setPreviousSection(_arg1:Class):void{ this.PreviousSectionClass = _arg1; } public function dispose():void{ keyboardNavigator.dispose(); } protected function gotoNextSection():void{ dispatchEvent(new Event(Event.COMPLETE)); } protected function init():void{ } public function getNextSection():Class{ return (NextSectionClass); } } }//package com.kerb.game
Section 4
//Ident (com.kerb.game.Ident) package com.kerb.game { import flash.events.*; import flash.display.*; public class Ident extends AbstractSection { protected var mc:MovieClip; public function Ident(_arg1:MovieClip, _arg2:Class){ this.mc = _arg1; this.NextSectionClass = _arg2; } override protected function init():void{ mc.x = (0.5 * stage.stageWidth); mc.y = (0.5 * stage.stageHeight); addChild(mc); addEventListener(Event.ENTER_FRAME, onEnterFrame); } protected function onEnterFrame(_arg1:Event):void{ if (mc.currentFrame == mc.totalFrames){ mc.stop(); removeEventListener(Event.ENTER_FRAME, onEnterFrame); dispatchEvent(new Event(Event.COMPLETE)); }; } override public function dispose():void{ removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.game
Section 5
//KeyboardNavigator (com.kerb.game.KeyboardNavigator) package com.kerb.game { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.ui.*; public class KeyboardNavigator { private var stage:Stage; private var tabIndexes:Array; private var keyListenerSet:Boolean; private var controllableItems:Dictionary; private var defaultAction:Function; public function KeyboardNavigator(_arg1:Stage){ this.stage = _arg1; init(); } public function addInteractiveObject(_arg1:InteractiveObject, _arg2:Function, _arg3:int=-1):void{ controllableItems[_arg1] = _arg2; if (_arg3 > -1){ tabIndexes[_arg3] = _arg1; _arg1.tabEnabled = true; }; _arg1.tabIndex = _arg3; active = true; } protected function onKeyDown(_arg1:KeyboardEvent):void{ var _local2:Function; var _local3:int; var _local4:InteractiveObject; if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){ _local2 = controllableItems[stage.focus]; if (_local2 == null){ defaultAction(); } else { _local2(); }; } else { _local3 = -1; _local4 = null; if ((((stage.focus is InteractiveObject)) && (!((stage.focus == stage))))){ _local3 = (stage.focus as InteractiveObject).tabIndex; }; if (_local3 == -1){ } else { if (_arg1.keyCode == Keyboard.LEFT){ _local4 = getNextLowestTabIndex(_local3); if (_local4 == null){ _local4 = getHighestTabIndex(); }; } else { if (_arg1.keyCode == Keyboard.RIGHT){ _local4 = getNextHighestTabIndex(_local3); if (_local4 == null){ _local4 = getLowestTabIndex(); }; }; }; }; if (_local4){ stage.focus = _local4; }; }; } public function setDefaultAction(_arg1:Function):void{ this.defaultAction = _arg1; active = true; } public function get active():Boolean{ return (keyListenerSet); } protected function getNextLowestTabIndex(_arg1:int):InteractiveObject{ var _local2:InteractiveObject; var _local3:int = tabIndexes.length; var _local4:int = (_arg1 - 1); while (_local4 >= 0) { if (tabIndexes[_local4] != undefined){ _local2 = tabIndexes[_local4]; break; }; _local4--; }; return (_local2); } public function set active(_arg1:Boolean):void{ if (((keyListenerSet) && (!(_arg1)))){ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); keyListenerSet = false; } else { if (((!(keyListenerSet)) && (_arg1))){ stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); keyListenerSet = true; }; }; } protected function init():void{ controllableItems = new Dictionary(); tabIndexes = new Array(); defaultAction = new Function(); stage.focus = stage; keyListenerSet = false; } protected function getHighestTabIndex():InteractiveObject{ var _local1:InteractiveObject; var _local2:int = (tabIndexes.length - 1); while (_local2 >= 0) { if (tabIndexes[_local2] != undefined){ _local1 = tabIndexes[_local2]; break; }; _local2--; }; return (_local1); } protected function getLowestTabIndex():InteractiveObject{ var _local1:InteractiveObject; var _local2:int = tabIndexes.length; var _local3:int; while (_local3 < _local2) { if (tabIndexes[_local3] != undefined){ _local1 = tabIndexes[_local3]; break; }; _local3++; }; return (_local1); } protected function getNextHighestTabIndex(_arg1:int):InteractiveObject{ var _local2:InteractiveObject; var _local3:int = tabIndexes.length; var _local4:int = (_arg1 + 1); while (_local4 < _local3) { if (tabIndexes[_local4] != undefined){ _local2 = tabIndexes[_local4]; break; }; _local4++; }; return (_local2); } public function dispose():void{ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); controllableItems = null; tabIndexes = null; defaultAction = null; } } }//package com.kerb.game
Section 6
//Car (com.kerb.infamous.game.dynamicBodies.Car) package com.kerb.infamous.game.dynamicBodies { import flash.display.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.collision.shapes.data.*; public class Car { public var rb:RigidBody; private var torqueDir:int;// = 1 public var mc:MovieClip; private static const RAD_2_DEG:Number = 57.2957795130823; public function Car(_arg1:Number, _arg2:Number, _arg3:Physics){ var _local5:ShapeData; var _local6:RigidBodyData; super(); var _local4:Number = 1; _local6 = new RigidBodyData(_arg1, _arg2); _local5 = new BoxData(_local4, 115.9, 26); _local5.mx = -3.5; _local5.my = 11.5; _local5.mr = 0; _local6.addShapeData(_local5); _local5 = new CircleData(_local4, 13.25); _local5.mx = 62.05; _local5.my = 6.5; _local6.addShapeData(_local5); _local5 = new CircleData(_local4, 13.25); _local5.mx = 45.05; _local5.my = 15.25; _local6.addShapeData(_local5); _local5 = new CircleData(_local4, 13.25); _local5.mx = -39.2; _local5.my = 15.25; _local6.addShapeData(_local5); _local5 = new BoxData(_local4, 43.2, 21.2); _local5.mx = -23.75; _local5.my = -4; _local5.mr = -0.398; _local6.addShapeData(_local5); _local5 = new BoxData(_local4, 51, 18.4); _local5.mx = 48.6; _local5.my = -3.3; _local5.mr = 0.324; _local6.addShapeData(_local5); _local5 = new CircleData(_local4, 15.25); _local5.mx = -61.45; _local5.my = 9.25; _local6.addShapeData(_local5); _local5 = new BoxData(_local4, 35.6, 26); _local5.mx = 8.9; _local5.my = -8.15; _local5.mr = 0.053; _local6.addShapeData(_local5); rb = _arg3.createRigidBody(_local6, "dynamic"); rb.userData.owner = this; mc = Main.assetFactory.createMovieClip("PoliceCarAsset"); mc.smashed.visible = false; } public function update():void{ mc.x = rb.x; mc.y = rb.y; mc.rotation = (RAD_2_DEG * rb.r); } public function hitGrenade(_arg1:Physics):RigidBody{ return (rb); } public function hitTKBlast(_arg1:Physics):RigidBody{ rb.wakeUp(); rb.applyImpulse(0, -500000); rb.applyTorque((torqueDir * 50000000)); torqueDir = -(torqueDir); mc.normal.visible = false; mc.smashed.visible = true; return (rb); } } }//package com.kerb.infamous.game.dynamicBodies
Section 7
//CellDoor (com.kerb.infamous.game.dynamicBodies.CellDoor) package com.kerb.infamous.game.dynamicBodies { import flash.display.*; import com.kerb.infamous.game.targets.*; public class CellDoor { public var lock:LockTarget; public var pedRef:String; public var mc:MovieClip; public var isOpen:Boolean; public function CellDoor(_arg1:String){ this.pedRef = _arg1; } public function explode():void{ mc.cacheAsBitmap = false; mc.gotoAndStop("explode"); } public function open():void{ if (!isOpen){ isOpen = true; mc.cacheAsBitmap = false; mc.play(); }; } } }//package com.kerb.infamous.game.dynamicBodies
Section 8
//Character (com.kerb.infamous.game.dynamicBodies.Character) package com.kerb.infamous.game.dynamicBodies { import flash.events.*; import flash.display.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import de.polygonal.ds.*; import com.kerb.infamous.game.render.*; import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.collision.shapes.data.*; import de.polygonal.motor2.dynamics.contact.*; public class Character extends EventDispatcher { public var node:SListNode; protected var animation:MovieClip; protected var walkSpeed:Number; protected var prevStateAnimation:String; protected var walking:Boolean; protected var animationFinished:Boolean; protected var _x:Number; protected var deadEvent:Event; protected var body:RigidBody; protected var mc:MovieClip; protected var actionStep:int; protected var parent:Sprite; protected var prevStateFunction:Function; protected var vh:Number; protected var bodyID:String; protected var updateStateFunction:Function; protected var vw:Number; protected var _life:Number; protected var _y:Number; protected var actions:Array; public var direction:int; public static const EVENT_DEAD:String = "onDead"; public static const EVENT_INJURED:String = "onInjured"; protected static const RAD_2_DEG:Number = 57.2957795130823; public function Character(_arg1:Number, _arg2:Number, _arg3:Physics, _arg4:Renderer, _arg5:String){ _x = _arg1; _y = _arg2; init(_arg3, _arg4, _arg5); } public function finishLightning():void{ if (_life > 0){ if (walking){ setState("walk", updateAutomation); } else { if (prevStateFunction != null){ setState(prevStateAnimation, prevStateFunction); }; }; }; } protected function init(_arg1:Physics, _arg2:Renderer, _arg3:String):void{ var _local5:MovieClip; actions = new Array(); updateStateFunction = updateNothing; deadEvent = new Event(EVENT_DEAD); _life = 1; direction = Avatar.RIGHT; mc = Main.assetFactory.createMovieClip(_arg3); mc.x = _x; mc.y = _y; var _local4:int; while (_local4 < mc.numChildren) { _local5 = (mc.getChildAt(_local4) as MovieClip); if (_local5 != animation){ _local5.stop(); _local5.visible = false; }; _local4++; }; _arg2.addCharacter(mc); parent = (mc.parent as Sprite); parent.removeChild(mc); } public function initLightning():void{ setState("shot", updateNothing); } public function get shape():ShapeSkeleton{ return (body.shapeList); } protected function updateAutomation():void{ } public function update(_arg1:Number, _arg2:Number):void{ var _local5:ContactNode; var _local6:Contact; var _local7:Manifold; var _local8:Number; _x = body.x; _y = body.y; var _local3:Number = (body.x - _arg1); var _local4:Number = (body.y - _arg2); if (_local3 < 0){ _local3 = -(_local3); }; if (_local4 < 0){ _local4 = -(_local4); }; if ((((_local3 < vw)) && ((_local4 < vh)))){ if (!mc.parent){ parent.addChild(mc); }; mc.x = _x; mc.y = _y; } else { if (mc.parent){ parent.removeChild(mc); }; }; if (updateStateFunction != updateDead){ _local5 = body.contactList; while (_local5) { _local6 = _local5.contact; if (_local6.shape1.body.userData.id == "dynamic"){ _local7 = _local6.manifolds[0]; _local8 = _local7.ny; if (_local8 > 0){ _life = 0; setState("dead", updateDead); body.world.destroyBody(body); break; }; }; _local5 = _local5.next; }; }; animationFinished = (animation.currentFrame == animation.totalFrames); updateStateFunction(); } protected function updateDead():void{ if (animationFinished){ animation.stop(); body.world.destroyBody(body); dispatchEvent(deadEvent); }; mc.rotation = (mc.rotation * 0.6); } protected function setState(_arg1:String, _arg2:Function):void{ prevStateAnimation = animation.name; prevStateFunction = updateStateFunction; animation.visible = false; animation.stop(); animation = mc[_arg1]; animation.gotoAndPlay(1); animation.visible = true; updateStateFunction = _arg2; } public function setRenderLimits(_arg1:Number, _arg2:Number):void{ vw = (0.7 * _arg1); vh = (0.7 * _arg2); } protected function initStandingRigidBody(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Physics):void{ var _local6:BoxData = new BoxData(_arg3, _arg1, _arg2); _local6.clrCategoryBit(0); _local6.setCategoryBit(1); _local6.friction = _arg4; var _local7:RigidBodyData = new RigidBodyData(_x, _y); _local7.preventRotation = true; _local7.addShapeData(_local6); body = _arg5.createRigidBody(_local7, bodyID); body.userData.owner = this; } protected function updateNothing():void{ } protected function updateLand():void{ if (animationFinished){ animation.stop(); body.world.destroyBody(body); dispatchEvent(deadEvent); }; mc.rotation = (mc.rotation * 0.6); } protected function updateFly():void{ mc.rotation = (RAD_2_DEG * body.r); if (body.contactList){ mc.rotation = 0; setState("land", updateLand); }; } protected function initFlyingRigidBody(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Physics):void{ var _local5:CircleData = new CircleData(_arg2, _arg1); _local5.friction = _arg3; var _local6:RigidBodyData = new RigidBodyData(_x, _y); _local6.addShapeData(_local5); body = _arg4.createRigidBody(_local6, bodyID); body.userData.owner = this; } public function hitLightning(_arg1:Number):void{ if (_life > 0){ _life = (_life - _arg1); if (_life <= 0){ _life = 0; setState("dead", updateDead); }; }; } public function get x():Number{ return (_x); } public function get y():Number{ return (_y); } public function get life():Number{ return (_life); } } }//package com.kerb.infamous.game.dynamicBodies
Section 9
//Door (com.kerb.infamous.game.dynamicBodies.Door) package com.kerb.infamous.game.dynamicBodies { import flash.display.*; import com.kerb.infamous.game.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.collision.shapes.data.*; public class Door { private var physics:Physics; private var rb:RigidBody; private var rbd:RigidBodyData; public var mc:MovieClip; private var isOpen:Boolean; public function Door(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Physics){ var _local6:BoxData; super(); this.physics = _arg5; _local6 = new BoxData(0, _arg3, _arg4); _local6.friction = 0.3; rbd = new RigidBodyData(_arg1, _arg2, 0); rbd.addShapeData(_local6); rb = _arg5.createRigidBody(rbd); isOpen = false; } public function toggle():void{ if (isOpen){ close(); } else { open(); }; } public function open():void{ if (!isOpen){ physics.destroyRigidBody(rb); rb = null; isOpen = true; if (mc){ mc.gotoAndPlay("opening"); }; }; } public function close():void{ if (isOpen){ rb = physics.createRigidBody(rbd); isOpen = false; if (mc){ mc.gotoAndPlay("closing"); }; }; } } }//package com.kerb.infamous.game.dynamicBodies
Section 10
//DynamicBox (com.kerb.infamous.game.dynamicBodies.DynamicBox) package com.kerb.infamous.game.dynamicBodies { import flash.display.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import de.polygonal.motor2.dynamics.*; public class DynamicBox { public var rb:RigidBody; public var mc:MovieClip; private static const RAD_2_DEG:Number = 57.2957795130823; public function DynamicBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:String, _arg7:Physics, _arg8:Number=1){ rb = _arg7.addBox(_arg1, _arg2, _arg3, _arg4, _arg8, _arg5, 1, "dynamic"); rb.userData.owner = this; mc = Main.assetFactory.createMovieClip(_arg6); mc.width = _arg3; mc.height = _arg4; } public function update():void{ mc.x = rb.x; mc.y = rb.y; mc.rotation = (RAD_2_DEG * rb.r); } public function hitGrenade(_arg1:Physics):RigidBody{ return (rb); } public function hitTKBlast(_arg1:Physics):RigidBody{ return (rb); } } }//package com.kerb.infamous.game.dynamicBodies
Section 11
//Ped (com.kerb.infamous.game.dynamicBodies.Ped) package com.kerb.infamous.game.dynamicBodies { import flash.events.*; import com.kerb.infamous.*; import com.kerb.sound.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.targets.*; import com.kerb.infamous.game.render.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.dynamics.contact.*; public class Ped extends Character { private var physics:Physics; protected var injuredEvent:Event; private var walkPauseCounter:int; private var sfxID:int; public var sickPedTarget:SickPedTarget; private var turnCounter:int; private static const FRICTION:Number = 0.1; public static const KARMA_RANDOM_VARIANCE:Number = 0.05; private static const DENSITY:Number = 4; public static const KARMA_PER_FRAME_INJURY:Number = -0.025; public static const KARMA_PER_CELL_UNLOCK:Number = 0.3; public static const KARMA_PER_DEATH:Number = -0.3; private static const KNEELING_WIDTH:Number = 22; public static const KARMA_PER_FRAME_HEAL:Number = 0.001; private static const KNEELING_HEIGHT:Number = 38; private static const WALK_SPEED:Number = 2; private static const STANDING_WIDTH:Number = 22; private static const INJURED_HEALTH_THRESHOLD:Number = 0.7; private static const STANDING_HEIGHT:Number = 54; private static const FLY_RADIUS:Number = 18; public function Ped(_arg1:Number, _arg2:Number, _arg3:Physics, _arg4:Renderer, _arg5:String){ this.physics = _arg3; super(_arg1, _arg2, _arg3, _arg4, _arg5); bodyID = "ped"; injuredEvent = new Event(EVENT_INJURED); turnCounter = 0; animation = mc["walk"]; animation.gotoAndPlay(1); animation.visible = true; initStandingRigidBody(STANDING_WIDTH, STANDING_HEIGHT, DENSITY, FRICTION, _arg3); updateStateFunction = updateWalk; if (Math.random() < 0.5){ direction = Avatar.LEFT; mc.scaleX = -1; }; switch (_arg5){ case "PedOfficeWomanAsset": sfxID = 1; break; case "PedPoliceWomanAsset": sfxID = 2; break; case "PedPrisonerAsset": sfxID = 3; break; case "PedPoliceManAsset": sfxID = 4; break; }; } private function updateHealFinish():void{ if (animationFinished){ setState("walk", updateWalk); }; } public function hitTKBlast(_arg1:Physics):RigidBody{ body.world.destroyBody(body); initFlyingRigidBody(FLY_RADIUS, DENSITY, FRICTION, _arg1); setState("fly", updateFly); playRandomSound(); return (body); } public function healed():void{ sickPedTarget = null; switchToStandingBody(); setState("healFinish", updateHealFinish); } public function addToLife(_arg1:Number, _arg2:Boolean):void{ _arg1 = (_arg1 + _life); if (_arg1 <= 0){ _arg1 = 0; setState("dead", updateDead); } else { if ((((_arg1 < INJURED_HEALTH_THRESHOLD)) && ((_life >= INJURED_HEALTH_THRESHOLD)))){ switchToKneelingBody(); setState("injured", updateInjured); if (mc.injured.sparks){ mc.injured.sparks.visible = !(_arg2); }; } else { if (_arg1 > 1){ _arg1 = 1; }; }; }; _life = _arg1; } override public function initLightning():void{ playRandomSound(); super.initLightning(); } private function initReadyToHeal():void{ animation.stop(); updateStateFunction = updateNothing; dispatchEvent(injuredEvent); } public function deductLife(_arg1:Number, _arg2:Boolean):void{ addToLife(-(_arg1), _arg2); } private function updateInjured():void{ if (animationFinished){ if (_life > INJURED_HEALTH_THRESHOLD){ setState("walk", updateWalk); } else { if (_life > 0){ initReadyToHeal(); }; }; }; } private function switchToKneelingBody():void{ body.world.destroyBody(body); initStandingRigidBody(KNEELING_WIDTH, KNEELING_HEIGHT, DENSITY, FRICTION, physics); body.y = (body.y + (0.5 * (STANDING_HEIGHT - KNEELING_HEIGHT))); mc.x = body.x; mc.y = body.y; } private function updateWalk():void{ var _local1:ContactNode; var _local2:int; var _local3:Manifold; if (walkPauseCounter > 0){ if (--walkPauseCounter == 0){ switchToStandingBody(); setState("walk", updateWalk); animation.play(); }; return; }; if (turnCounter == 0){ _local1 = body.contactList; _local2 = 0; while (_local1) { _local3 = _local1.contact.manifolds[0]; _local2 = (_local2 + _local3.pointCount); _local1 = _local1.next; }; if (_local2 > 2){ if (direction == Avatar.LEFT){ direction = Avatar.RIGHT; mc.scaleX = 1; } else { direction = Avatar.LEFT; mc.scaleX = -1; }; turnCounter = ((Math.random() * 8) + 8); } else { if (Math.random() < 0.002){ walkPauseCounter = (int((Math.random() * 30)) + 10); switchToKneelingBody(); setState("crouch", updateWalk); }; }; } else { turnCounter--; }; body.wakeUp(); body.x = (body.x + ((direction)==Avatar.RIGHT) ? -(WALK_SPEED) : WALK_SPEED); } override public function finishLightning():void{ if (_life > INJURED_HEALTH_THRESHOLD){ setState(prevStateAnimation, prevStateFunction); } else { if (_life > 0){ switchToKneelingBody(); setState("injured", updateInjured); if (mc.injured.sparks){ mc.injured.sparks.visible = true; }; }; }; } public function playRandomSound():void{ var _local1:int = (Math.random() * 3); var _local2:ExtendedSound = Main.smSFX.getSoundByClassName(((("Ped" + sfxID) + _local1) + "Sound")); _local2.play(); } public function hitGrenade(_arg1:Physics):RigidBody{ body.world.destroyBody(body); initFlyingRigidBody(FLY_RADIUS, DENSITY, FRICTION, _arg1); setState("fly", updateFly); playRandomSound(); return (body); } private function switchToStandingBody():void{ body.world.destroyBody(body); initStandingRigidBody(STANDING_WIDTH, STANDING_HEIGHT, DENSITY, FRICTION, physics); body.y = (body.y - (0.5 * (STANDING_HEIGHT - KNEELING_HEIGHT))); mc.x = body.x; mc.y = body.y; } } }//package com.kerb.infamous.game.dynamicBodies
Section 12
//Reaper (com.kerb.infamous.game.dynamicBodies.Reaper) package com.kerb.infamous.game.dynamicBodies { import flash.events.*; import com.kerb.infamous.*; import com.kerb.sound.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.render.*; import de.polygonal.motor2.dynamics.*; import flash.media.*; public class Reaper extends Character { private var automationStep:int; private var ay:Number; protected var weaponFiredEvent:Event; public var gunYOffset:Number; private var ax:Number; public var bulletDamage:Number; private var automation:Array; private var automationWaitCounter:int; private var isStatic:Boolean; private var sfxChannel:SoundChannel; private static const FRICTION:Number = 0.01; private static const FLY_RADIUS:Number = 20; private static const DENSITY:Number = 4; private static const STANDING_GUN_Y_OFFSET:Number = -14; private static const CROUCHING_GUN_Y_OFFSET:Number = -14; public static const EVENT_WEAPON_FIRED:String = "onWeaponFired"; public static const KARMA_PER_DEATH:Number = 0.1; private static const KNEELING_WIDTH:Number = 28; public static const BULLET_RAYCAST_DISTANCE:Number = 350; private static const KNEELING_GUN_Y_OFFSET:Number = -24; private static const KNEELING_HEIGHT:Number = 60; private static const WALK_SPEED:Number = 2; public static const KARMA_PER_FRAME_DAMAGE:Number = 0.001; private static const STANDING_WIDTH:Number = 28; private static const STANDING_HEIGHT:Number = 80; private static const VIEW_X:Number = 300; private static const VIEW_Y:Number = 30; public function Reaper(_arg1:Number, _arg2:Number, _arg3:Physics, _arg4:Renderer, _arg5:String){ super(_arg1, _arg2, _arg3, _arg4, _arg5); bodyID = "reaper"; initStandingRigidBody(STANDING_WIDTH, STANDING_HEIGHT, DENSITY, FRICTION, _arg3); gunYOffset = STANDING_GUN_Y_OFFSET; animation = mc["stand"]; animation.gotoAndPlay(1); animation.visible = true; } protected function updateWaitingToShoot():void{ checkLineOfSight(); } override public function update(_arg1:Number, _arg2:Number):void{ this.ax = _arg1; this.ay = _arg2; super.update(_arg1, _arg2); } private function checkLineOfSight():void{ if (mc.scaleX == 1){ if ((((ax > _x)) && ((ax < (_x + VIEW_X))))){ if ((((ay > (_y - VIEW_Y))) && ((ay < (_y + VIEW_Y))))){ mc.scaleX = 1; this.direction = Avatar.RIGHT; playRandomSound(); setState("standFire", updateStandFire); }; }; } else { if (mc.scaleX == -1){ if ((((ax > (_x - VIEW_X))) && ((ax < _x)))){ if ((((ay > (_y - VIEW_Y))) && ((ay < (_y + VIEW_Y))))){ mc.scaleX = -1; this.direction = Avatar.LEFT; playRandomSound(); setState("standFire", updateStandFire); }; }; }; }; } public function hitTKBlast(_arg1:Physics):RigidBody{ playRandomSound(); body.world.destroyBody(body); initFlyingRigidBody(FLY_RADIUS, DENSITY, FRICTION, _arg1); setState("fly", updateFly); return (body); } override public function initLightning():void{ playRandomSound(); } public function setAsKneelingSniper(_arg1:int, _arg2:Physics):void{ body.world.destroyBody(body); initStandingRigidBody(KNEELING_WIDTH, KNEELING_HEIGHT, DENSITY, FRICTION, _arg2); setState("kneelFire", updateSniper); mc.scaleX = ((_arg1)==Avatar.LEFT) ? -1 : 1; animation.stop(); gunYOffset = KNEELING_GUN_Y_OFFSET; this.direction = _arg1; } private function checkStandingLineOfSight():void{ if ((((ax > (_x - VIEW_X))) && ((ax < (_x + VIEW_X))))){ if ((((ay > (_y - VIEW_Y))) && ((ay < (_y + VIEW_Y))))){ mc.scaleX = ((ax > _x)) ? 1 : -1; this.direction = ((mc.scaleX == 1)) ? Avatar.RIGHT : Avatar.LEFT; playRandomSound(); setState("standFire", updateStandFire); }; }; } public function addAutomation(_arg1:Number, _arg2:int):void{ automation.push([_arg1, _arg2]); isStatic = false; updateStateFunction = updateAutomation; } private function onSoundComplete(_arg1:Event):void{ sfxChannel.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete); sfxChannel = null; } public function setAsCrouchingSniper(_arg1:int, _arg2:Physics):void{ body.world.destroyBody(body); initStandingRigidBody(KNEELING_WIDTH, KNEELING_HEIGHT, DENSITY, FRICTION, _arg2); setState("crouchFire", updateSniper); mc.scaleX = ((_arg1)==Avatar.LEFT) ? -1 : 1; animation.stop(); gunYOffset = CROUCHING_GUN_Y_OFFSET; this.direction = _arg1; } public function playRandomSound():void{ var _local1:int; var _local2:ExtendedSound; if (!sfxChannel){ _local1 = (Math.random() * 7); _local2 = Main.smSFX.getSoundByClassName((("Reaper" + _local1) + "Sound")); _local2.play(); sfxChannel = _local2.getSoundChannel(); sfxChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete); }; } protected function updateSniper():void{ if (animation.currentFrame == 1){ animation.stop(); }; if ((((ax > _x)) && ((ax < (_x + VIEW_X))))){ if ((((ay > (_y - VIEW_Y))) && ((ay < (_y + VIEW_Y))))){ if (mc.scaleX == -1){ mc.scaleX = 1; direction = Avatar.RIGHT; }; animation.play(); }; } else { if ((((ax > (_x - VIEW_X))) && ((ax < _x)))){ if ((((ay > (_y - VIEW_Y))) && ((ay < (_y + VIEW_Y))))){ if (mc.scaleX == 1){ mc.scaleX = -1; direction = Avatar.LEFT; }; animation.play(); }; }; }; } override protected function init(_arg1:Physics, _arg2:Renderer, _arg3:String):void{ super.init(_arg1, _arg2, _arg3); isStatic = true; automation = new Array(); automationStep = 0; automationWaitCounter = 0; walking = false; weaponFiredEvent = new Event(EVENT_WEAPON_FIRED); } protected function updateStandFire():void{ if (animationFinished){ if (isStatic){ setState("stand", updateNothing); } else { if (walking){ setState("walk", updateAutomation); } else { setState("stand", updateAutomation); }; }; }; } override protected function updateAutomation():void{ var _local1:Number = automation[automationStep][0]; var _local2:Number = _x; if (_local2 < _local1){ if (!walking){ walking = true; setState("walk", updateAutomation); }; mc.scaleX = 1; this.direction = Avatar.RIGHT; _local2 = (_local2 + WALK_SPEED); if (_local2 > _local1){ _local2 = _local1; }; checkLineOfSight(); } else { if (_local2 > _local1){ if (!walking){ walking = true; setState("walk", updateAutomation); }; mc.scaleX = -1; this.direction = Avatar.LEFT; _local2 = (_local2 - WALK_SPEED); if (_local2 < _local1){ _local2 = _local1; }; checkLineOfSight(); } else { if (walking){ walking = false; setState("stand", updateAutomation); }; if (automationWaitCounter++ == automation[automationStep][1]){ automationWaitCounter = 0; automationStep++; automationStep = (automationStep % automation.length); }; checkStandingLineOfSight(); }; }; body.wakeUp(); body.x = _local2; } public function setAsStandingSniper(_arg1:int, _arg2:Physics):void{ setState("standFire", updateSniper); mc.scaleX = ((_arg1)==Avatar.LEFT) ? -1 : 1; animation.stop(); gunYOffset = STANDING_GUN_Y_OFFSET; this.direction = _arg1; } public function hitGrenade(_arg1:Physics):RigidBody{ playRandomSound(); body.world.destroyBody(body); initFlyingRigidBody(FLY_RADIUS, DENSITY, FRICTION, _arg1); setState("fly", updateFly); return (body); } } }//package com.kerb.infamous.game.dynamicBodies
Section 13
//RedReaper (com.kerb.infamous.game.dynamicBodies.RedReaper) package com.kerb.infamous.game.dynamicBodies { import com.kerb.infamous.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.render.*; public class RedReaper extends Reaper { public static const BULLET_DAMAGE:Number = 0.1; public function RedReaper(_arg1:Number, _arg2:Number, _arg3:Physics, _arg4:Renderer){ super(_arg1, _arg2, _arg3, _arg4, "RedReaperAsset"); bulletDamage = BULLET_DAMAGE; } override protected function updateSniper():void{ if ((((animation.currentFrame == 20)) || ((animation.currentFrame == 34)))){ Main.smSFX.getSoundByClassName("ReaperRifleSound").play(); }; if ((((animation.currentFrame == 21)) || ((animation.currentFrame == 35)))){ dispatchEvent(weaponFiredEvent); }; super.updateSniper(); } override protected function updateStandFire():void{ if ((((animation.currentFrame == 20)) || ((animation.currentFrame == 34)))){ Main.smSFX.getSoundByClassName("ReaperRifleSound").play(); }; if ((((animation.currentFrame == 21)) || ((animation.currentFrame == 35)))){ dispatchEvent(weaponFiredEvent); }; super.updateStandFire(); } } }//package com.kerb.infamous.game.dynamicBodies
Section 14
//WhiteReaper (com.kerb.infamous.game.dynamicBodies.WhiteReaper) package com.kerb.infamous.game.dynamicBodies { import com.kerb.infamous.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.render.*; public class WhiteReaper extends Reaper { public static const BULLET_DAMAGE:Number = 0.05; public function WhiteReaper(_arg1:Number, _arg2:Number, _arg3:Physics, _arg4:Renderer){ super(_arg1, _arg2, _arg3, _arg4, "WhiteReaperAsset"); bulletDamage = BULLET_DAMAGE; } override protected function updateSniper():void{ if (animation.currentFrame == 20){ Main.smSFX.getSoundByClassName("ReaperMachineGunSound").play(); }; var _local1:int = animation.currentFrame; if ((((((_local1 > 20)) && ((_local1 < 38)))) && (((_local1 % 2) == 1)))){ dispatchEvent(weaponFiredEvent); }; super.updateSniper(); } override protected function updateStandFire():void{ if (animation.currentFrame == 20){ Main.smSFX.getSoundByClassName("ReaperMachineGunSound").play(); }; var _local1:int = animation.currentFrame; if ((((((_local1 > 20)) && ((_local1 < 38)))) && (((_local1 % 2) == 1)))){ dispatchEvent(weaponFiredEvent); }; super.updateStandFire(); } } }//package com.kerb.infamous.game.dynamicBodies
Section 15
//BaseLevel (com.kerb.infamous.game.levels.BaseLevel) package com.kerb.infamous.game.levels { import flash.events.*; import flash.display.*; import com.kerb.infamous.*; import com.kerb.infamous.game.screens.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.dynamicBodies.*; import com.kerb.infamous.game.targets.*; import de.polygonal.ds.*; import com.kerb.infamous.game.weapons.*; import com.kerb.infamous.game.render.*; import de.polygonal.motor2.dynamics.*; import com.kerb.input.*; import com.kerb.infamous.ui.*; import mx.core.*; import flash.utils.*; import flash.media.*; import flash.ui.*; public class BaseLevel extends AbstractScreen { protected var reapers:SLinkedList; protected var message:MovieClip; protected var grenadePool:Array; protected var weapon:int; protected var exit:Target; protected var grabs:SLinkedList; protected var dangers:SLinkedList; protected var xDown:Boolean; protected var udm:UserDataManager; protected var renderer:Renderer; protected var peds:SLinkedList; protected var physics:Physics; protected var spaceDown:Boolean; protected var lightning:Lightning; protected var sickPedTargets:SLinkedList; protected var worldWidth:Number; protected var kc:KeyControl; protected var worldHeight:Number; protected var energyTargets:SLinkedList; protected var levelComplete:Boolean; protected var dynamicBodies:SLinkedList; protected var avatar:Avatar; protected var upDown:Boolean; protected var grenades:SLinkedList; protected var levelNum:int; protected var downDown:Boolean; protected var hud:HUD; protected var messageTimer:Timer; private static const KARMA_TO_POINTS_MULTIPLIER:int = 1000; public static const WEAPONS:Array = ["lightning", "grenade", "tkBlast", "rocket"]; public function BaseLevel(_arg1:UserDataManager, _arg2:int){ dynamicBodies = new SLinkedList(); energyTargets = new SLinkedList(); reapers = new SLinkedList(); peds = new SLinkedList(); sickPedTargets = new SLinkedList(); grabs = new SLinkedList(); dangers = new SLinkedList(); super(); this.udm = _arg1; this.levelNum = _arg2; } private function onWeaponFired(_arg1:Event):void{ switch (WEAPONS[weapon]){ case "lightning": lightning.init(avatar.x, avatar.y, avatar.direction); break; case "grenade": launchGrenade(); break; case "tkBlast": fireTKBlast(); break; case "rocket": launchRocket(); break; }; } private function updateAvatar():void{ var _local1:Target; _local1 = checkTargetList(dangers); if (_local1){ if (avatar.deductLife(_local1.value)){ avatar.electrocute(); lose(); }; renderer.showDamage(); hud.setLife(avatar.life); } else { _local1 = checkCustomTargets(); if (((!(_local1)) && (!(avatar.jumping)))){ _local1 = checkTargetList(energyTargets); if (!_local1){ _local1 = checkTargetList(sickPedTargets); if (!_local1){ if (((!(_local1)) && (!(levelComplete)))){ if (checkExit()){ win(); }; }; }; }; } else { if (avatar.jumping){ avatar.grabTarget = (checkTargetList(grabs) as GrabTarget); }; }; }; avatar.standTarget = _local1; if (_local1){ hud.showAction(_local1.hudAction); } else { hud.hideAction(); }; avatar.addLife(Avatar.LIFE_GAINED_PER_FRAME); hud.setLife(avatar.life); avatar.update(physics.avatarOnGround); } protected function initIntroText():void{ var _local1:MovieClip; var _local2:TextBox; var _local3:String; _local1 = Main.assetFactory.createMovieClip("LevelIntroMessageAsset"); _local3 = InfamousTextManager.getInstance().getTextById((("level." + (levelNum + 1)) + ".intro")).toUpperCase(); _local2 = new TextBox(_local1.orange); _local2.setText(_local3, TextBox.RULE_MIN_LINES); _local3 = InfamousTextManager.getInstance().getTextById((("level." + (levelNum + 1)) + ".intro.description")).toUpperCase(); _local2 = new TextBox(_local1.white); _local2.setText(_local3, TextBox.RULE_MIN_LINES); renderer.setIntroText(_local1); } private function selectNextWeapon():void{ weapon++; if (weapon == WEAPONS.length){ setWeapon(0); } else { if ((((weapon == (WEAPONS.length - 1))) && (!(Constants.useSpecialWeapon)))){ setWeapon(0); } else { setWeapon(weapon); }; }; } protected function onReaperFire(_arg1:Event):void{ fireGun((_arg1.target as Reaper)); } protected function onReaperDead(_arg1:Event):void{ var _local2:Reaper = (_arg1.target as Reaper); _local2.removeEventListener(Character.EVENT_DEAD, onReaperDead); _local2.removeEventListener(Reaper.EVENT_WEAPON_FIRED, onReaperFire); _local2.playRandomSound(); var _local3:SListIterator = reapers.getListIterator(); _local3.node = _local2.node; reapers.remove(_local3); applyKarma(Reaper.KARMA_PER_DEATH); } private function updateCharacters():void{ var _local1:SListNode; var _local2:Number; var _local3:Number; if (((levelComplete) && ((avatar.life > 0)))){ _local3 = -300000; _local2 = _local3; } else { _local2 = avatar.x; _local3 = avatar.y; }; _local1 = reapers.head; while (_local1) { _local1.data.update(_local2, _local3); _local1 = _local1.next; }; _local1 = peds.head; while (_local1) { _local1.data.update(_local2, _local3); _local1 = _local1.next; }; } private function applyGrenadeDamage(_arg1:Grenade):void{ var _local4:RigidBody; var _local5:Number; var _local6:Number; var _local7:Number; var _local2:Array = physics.circularRaycast(_arg1.x, _arg1.y, Grenade.BLAST_RADIUS); var _local3:int = _local2.length; while (_local3-- > 0) { _local4 = _local2[_local3]; if (_local4.userData.owner){ _local4 = _local4.userData.owner.hitGrenade(physics); }; if (_local4.userData.id){ _local5 = (_local4.x - _arg1.x); _local6 = (_local4.y - _arg1.y); if (_local6 < 0){ _local6 = -(_local6); }; _local7 = (Grenade.BLAST_FORCE / (Math.abs(_local5) + _local6)); _local5 = (_local5 * _local7); _local6 = (_local6 * -(_local7)); _local4.wakeUp(); _local4.applyImpulseAt(_local5, _local6, _arg1.x, _arg1.y); }; }; } override protected function init():void{ weapon = 0; avatar.addEventListener(Avatar.EVENT_WEAPON_FIRED, onWeaponFired); avatar.addEventListener(Avatar.EVENT_HOVER_LAND, onHoverLand); avatar.addEventListener(Avatar.EVENT_LOCK_ACTIVATED, onLockActivated); renderer.fixCameraPosition(avatar.x, avatar.y); renderer.x = 10; renderer.y = 10; addChild(renderer); lightning = new Lightning(); renderer.addLightning(lightning.sprite); initObjectPools(); hud = new HUD(udm.getTotalScore(), udm.getKarma(), avatar.energy); hud.addEventListener(HUD.EVENT_HELP, onHelp); addChild(hud); kc = KeyControl.getInstance(); kc.init(stage); kc.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); kc.addEventListener(KeyboardEvent.KEY_UP, onKeyUp); levelComplete = false; spaceDown = false; xDown = false; upDown = false; downDown = false; initIntroText(); var _local1:SoundTransform = new SoundTransform(0.5); Main.smMusic.getSoundByClassName("InGameMusicSound").play(0, 999999, _local1); Main.smSFX.getSoundByClassName("BoomSound").play(); start(); } protected function onPedInjured(_arg1:Event):void{ var _local3:SickPedTarget; var _local4:SListNode; var _local2:Ped = (_arg1.target as Ped); if (_local2.sickPedTarget == null){ _local3 = new SickPedTarget(_local2, this); _local4 = sickPedTargets.append(_local3); _local3.setCallbacks(sickPedTargets, _local4); }; } protected function checkTargetList(_arg1:SLinkedList):Target{ var _local3:Target; var _local2:SListNode = _arg1.head; var _local4:Target; while (_local2) { _local3 = _local2.data; if (_local3.hitTest(avatar.x, avatar.y)){ _local4 = _local3; break; }; _local2 = _local2.next; }; return (_local4); } override public function dispose():void{ kc.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); kc.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp); hud.removeEventListener(HUD.EVENT_HELP, onHelp); var _local1:SListIterator = sickPedTargets.getListIterator(); _local1.start(); while (_local1.valid()) { sickPedTargets.remove(_local1); _local1.forth(); }; removeEventListener(Event.ENTER_FRAME, onEnterFrame); avatar.removeEventListener(Avatar.EVENT_WEAPON_FIRED, onWeaponFired); avatar.removeEventListener(Avatar.EVENT_HOVER_LAND, onHoverLand); avatar.removeEventListener(Avatar.EVENT_LOCK_ACTIVATED, onLockActivated); _local1 = reapers.getListIterator(); _local1.start(); while (_local1.valid()) { _local1.data.removeEventListener(Character.EVENT_DEAD, onReaperDead); _local1.data.removeEventListener(Reaper.EVENT_WEAPON_FIRED, onReaperFire); _local1.forth(); }; _local1 = peds.getListIterator(); _local1.start(); while (_local1.valid()) { _local1.data.removeEventListener(Character.EVENT_DEAD, onPedDead); _local1.data.removeEventListener(Character.EVENT_INJURED, onPedInjured); _local1.forth(); }; } protected function checkKeys():void{ var _local1:int; if (!levelComplete){ if (kc.keyIsDown(Keyboard.LEFT)){ _local1 = (_local1 + Avatar.LEFT); }; if (kc.keyIsDown(Keyboard.RIGHT)){ _local1 = (_local1 + Avatar.RIGHT); }; if (kc.keyIsDown(Keyboard.UP)){ _local1 = (_local1 + Avatar.UP); if (!upDown){ upDown = true; _local1 = (_local1 + Avatar.UP_PRESSED); }; }; if (kc.keyIsDown(Keyboard.DOWN)){ _local1 = (_local1 + Avatar.DOWN); if (!downDown){ downDown = true; _local1 = (_local1 + Avatar.DOWN_PRESSED); }; }; if (kc.keyIsDown(Keyboard.SPACE)){ _local1 = (_local1 + Avatar.SPACE); if (!spaceDown){ spaceDown = true; _local1 = (_local1 + Avatar.SPACE_PRESSED); }; }; if (kc.keyIsDown(88)){ _local1 = (_local1 + Avatar.X); if (!xDown){ xDown = true; _local1 = (_local1 + Avatar.X_PRESSED); }; }; }; avatar.keyBits = _local1; } protected function createRedReaper(_arg1:Number, _arg2:Number, _arg3:String, _arg4:String):Reaper{ var _local5:Reaper = createReaper(_arg1, _arg2, RedReaper); var _local6:int = ((_arg4 == "left")) ? Avatar.LEFT : Avatar.RIGHT; switch (_arg3){ case "standing": _local5.setAsStandingSniper(_local6, physics); break; case "kneeling": _local5.setAsKneelingSniper(_local6, physics); break; case "crouching": _local5.setAsCrouchingSniper(_local6, physics); break; }; return (_local5); } private function setWeapon(_arg1:int):void{ this.weapon = _arg1; hud.setWeapon(WEAPONS[_arg1]); avatar.weapon = WEAPONS[_arg1]; } public function applyKarma(_arg1:Number):void{ avatar.karma = (avatar.karma + _arg1); hud.setKarma(avatar.karma, (_arg1 > 0)); udm.addToKarma(_arg1); udm.addToScore((_arg1 * KARMA_TO_POINTS_MULTIPLIER), levelNum); hud.setLevelScore(udm.getLevelScore(levelNum)); hud.setTotalScore(udm.getTotalScore()); } protected function loadXMLData(_arg1:Class):XML{ var _local2:ByteArrayAsset = ByteArrayAsset(new (_arg1)); var _local3:String = _local2.readUTFBytes(3); if (_local3.length == 1){ return (new XML(_local2.readUTFBytes((_local2.length - 3)))); }; return (new XML((_local3 + _local2.readUTFBytes((_local2.length - 3))))); } protected function lose():void{ if (!levelComplete){ levelComplete = true; dispatchEvent(new Event(Game.EVENT_LOSE_LEVEL)); }; } private function onHoverLand(_arg1:Event):void{ var _local2:Number; renderer.initShake(0, 0.8); if (avatar.landingVelocity > 100){ _local2 = (0.001 * avatar.landingVelocity); if (avatar.deductLife(_local2)){ lose(); }; renderer.showDamage(); hud.setLife(avatar.life); }; } private function fireGun(_arg1:Reaper):void{ var _local2:Number; var _local3:Number; var _local4:Number; var _local5:RaycastResult; _local2 = _arg1.x; if (_arg1.direction == Avatar.LEFT){ _local4 = (_local2 - Reaper.BULLET_RAYCAST_DISTANCE); } else { _local4 = (_local2 + Reaper.BULLET_RAYCAST_DISTANCE); }; _local3 = (_arg1.y + _arg1.gunYOffset); _local5 = physics.linearRaycast(_local2, _local3, _local4, _local3, _arg1.shape); if (((_local5) && (_local5.body))){ if (_local5.body.userData.id == "avatar"){ if (avatar.deductLife(_arg1.bulletDamage)){ lose(); }; renderer.showDamage(); hud.setLife(avatar.life); } else { if (_local5.body.userData.id == "ped"){ _local5.body.userData.owner.deductLife(_arg1.bulletDamage, true); }; }; }; } private function showRunningLowMessage(_arg1:String, _arg2:String):void{ var _local3:TextBox; var _local4:String; var _local5:MovieClip; message = Main.assetFactory.createMovieClip("InGameInstructionsAsset"); message.x = 50; message.y = 80; _local3 = new TextBox(message.orange.box); _local3.setText(_arg1, TextBox.RULE_MIN_LINES); _local3 = new TextBox(message.white.box); _local3.setText(_arg2, TextBox.RULE_MIN_LINES); if (message.orange.box.label_txt.numLines == 1){ message.white.y = message.orange.height; } else { message.white.y = (message.orange.height - 10); }; renderer.addChild(message); messageTimer = new Timer(5000); messageTimer.addEventListener(TimerEvent.TIMER, onMessageTimer); messageTimer.start(); } protected function onEnterFrame(_arg1:Event):void{ var _local2:int; var _local3:String; var _local4:String; checkKeys(); physics.step(); updateAvatar(); updateCharacters(); if (lightning.active){ _local2 = lightning.update(physics, avatar); if (_local2 == 1){ applyKarma(Ped.KARMA_PER_FRAME_INJURY); } else { if (_local2 == 2){ applyKarma(Reaper.KARMA_PER_FRAME_DAMAGE); }; }; if (lightning.duration == 0){ avatar.finishLightning(); }; }; updateGrenades(); hud.setEnergy(avatar.energy); renderer.setCameraPosition(avatar.renderX, avatar.renderY); renderer.draw(physics); if (Constants.tutorialComplete){ if (((((!(Constants.energyMessageShown)) && ((avatar.energy < 0.21)))) && (!(message)))){ _local3 = InfamousTextManager.getInstance().getTextById("message.1.1").toUpperCase(); _local4 = InfamousTextManager.getInstance().getTextById("message.1.2").toUpperCase(); showRunningLowMessage(_local3, _local4); Constants.energyMessageShown = true; } else { if (((((!(Constants.lifeMessageShown)) && ((avatar.life < 0.1)))) && (!(message)))){ _local3 = InfamousTextManager.getInstance().getTextById("message.2.1").toUpperCase(); _local4 = InfamousTextManager.getInstance().getTextById("message.2.2").toUpperCase(); showRunningLowMessage(_local3, _local4); Constants.energyMessageShown = true; }; }; if (((message) && ((avatar.life <= 0)))){ onMessageTimer(); }; }; } private function launchGrenade():void{ var _local1:Number = avatar.x; var _local2:Number = (avatar.y - 33); if (grenadePool.length == 0){ grenadePool.push(createGrenade()); }; var _local3:Grenade = grenadePool.pop(); _local3.init(_local1, _local2, avatar.direction, physics, false); grenades.append(_local3); } private function onHelp(_arg1:Event):void{ removeEventListener(Event.ENTER_FRAME, onEnterFrame); dispatchEvent(_arg1); } private function onKeyDown(_arg1:KeyboardEvent):void{ if (levelComplete){ return; }; if (_arg1.keyCode == 67){ selectNextWeapon(); } else { if (_arg1.keyCode == 49){ setWeapon(0); } else { if (_arg1.keyCode == 50){ setWeapon(1); } else { if (_arg1.keyCode == 51){ setWeapon(2); } else { if ((((_arg1.keyCode == 52)) && (Constants.useSpecialWeapon))){ setWeapon(3); }; }; }; }; }; } protected function checkExit():Boolean{ return (exit.hitTest(avatar.x, avatar.y)); } protected function onPedDead(_arg1:Event):void{ var _local3:SListIterator; var _local2:Ped = (_arg1.target as Ped); if (_local2.sickPedTarget){ _local3 = sickPedTargets.getListIterator(); _local3.node = _local2.sickPedTarget.node; sickPedTargets.remove(_local3); }; _local2.removeEventListener(Character.EVENT_INJURED, onPedInjured); _local2.removeEventListener(Character.EVENT_DEAD, onPedDead); _local3 = peds.getListIterator(); _local3.node = _local2.node; peds.remove(_local3); applyKarma(Ped.KARMA_PER_DEATH); } private function fireTKBlast():void{ var _local1:Array; var _local3:RigidBody; var _local4:Number; var _local5:Number; var _local6:Number; if (avatar.direction == Avatar.LEFT){ _local1 = physics.angularRaycast(avatar.x, avatar.y, (Math.PI - TKBlast.ANGLE), (Math.PI + TKBlast.ANGLE), TKBlast.RADIUS, avatar.shape); } else { _local1 = physics.angularRaycast(avatar.x, avatar.y, -(TKBlast.ANGLE), TKBlast.ANGLE, TKBlast.RADIUS, avatar.shape); }; var _local2:int = _local1.length; while (_local2-- > 0) { _local3 = _local1[_local2]; if (_local3.userData.owner){ _local3 = _local3.userData.owner.hitTKBlast(physics); }; if (_local3.userData.id){ _local4 = (_local3.x - avatar.x); _local5 = (_local3.y - avatar.y); if (_local5 < 0){ _local5 = -(_local5); }; _local6 = (TKBlast.FORCE / (Math.abs(_local4) + _local5)); _local4 = (_local4 * _local6); _local5 = (_local5 * -(_local6)); _local3.wakeUp(); _local3.applyImpulseAt(_local4, _local5, avatar.x, avatar.y); }; }; renderer.initShake(1.8, 0); } private function onKeyUp(_arg1:KeyboardEvent):void{ if (_arg1.keyCode == Keyboard.UP){ avatar.hovering = false; upDown = false; } else { if (_arg1.keyCode == Keyboard.DOWN){ downDown = false; } else { if (_arg1.keyCode == Keyboard.SPACE){ spaceDown = false; } else { if (_arg1.keyCode == 88){ xDown = false; }; }; }; }; } private function initObjectPools():void{ var _local1:int; grenadePool = new Array(); _local1 = 0; while (_local1 < 5) { grenadePool.push(createGrenade()); _local1++; }; grenades = new SLinkedList(); } protected function onLockActivated(_arg1:Event):void{ } protected function parseLevelData(_arg1:XML):void{ var _local2:XML; for each (_local2 in _arg1.children()) { createItemFromXML(_local2); }; } protected function win():void{ if (!levelComplete){ levelComplete = true; dispatchEvent(new Event(Game.EVENT_WIN_LEVEL)); }; } protected function createItemFromXML(_arg1:XML):void{ var _local11:RigidBody; var _local12:Target; var _local13:Reaper; var _local14:Number; var _local2:String = _arg1.@id; var _local3:String = _arg1.@type; var _local4:String = _arg1.@dir; var _local5:Number = parseFloat(_arg1.@x); var _local6:Number = parseFloat(_arg1.@y); var _local7:Number = parseFloat(_arg1.@w); var _local8:Number = parseFloat(_arg1.@h); var _local9:Number = parseFloat(_arg1.@r); var _local10:Number = parseFloat(_arg1.@radius); switch (_local2){ case "avatar": avatar = new Avatar(_local5, _local6, 1, physics, renderer); break; case "ped": createPed(_local5, _local6); break; case "redReaper": _local13 = createRedReaper(_local5, _local6, _local3, _local4); break; case "whiteReaper": _local13 = createWhiteReaper(_local5, _local6, _arg1.children()); break; case "exit": exit = new Target(_local5, _local6, Target.TYPE_EXIT); break; case "energy": _local12 = new EnergyTarget(_local5, _local6); energyTargets.append(_local12); break; case "danger": _local12 = new Target(_local5, _local6, Target.TYPE_DANGER, _local7, _local8, Avatar.WATER_LIFE_LOST_PER_FRAME); dangers.append(_local12); break; case "pullLeft": _local12 = new GrabTarget(_local5, _local6, Target.TYPE_PULL_UP, Avatar.LEFT); grabs.append(_local12); break; case "pullRight": _local12 = new GrabTarget(_local5, _local6, Target.TYPE_PULL_UP, Avatar.RIGHT); grabs.append(_local12); break; case "swingLeft": _local12 = new GrabTarget(_local5, _local6, Target.TYPE_SWING_UP, Avatar.LEFT); grabs.append(_local12); break; case "swingRight": _local12 = new GrabTarget(_local5, _local6, Target.TYPE_SWING_UP, Avatar.RIGHT); grabs.append(_local12); break; case "dyn": _local14 = 2; _local11 = physics.addBox(_local5, _local6, _local7, _local8, _local14, _local9, 1, "dynamic"); dynamicBodies.append(_local11); break; default: _local11 = physics.addBox(_local5, _local6, _local7, _local8); }; } private function updateGrenades():void{ var _local2:Grenade; var _local1:SListNode = grenades.head; while (_local1) { _local2 = _local1.data; if (_local2.update()){ _local2.destroy(physics); applyGrenadeDamage(_local2); Main.smSFX.getSoundByClassName("MegawattExplosionSound").play(); }; _local1 = _local1.next; }; } protected function checkCustomTargets():Target{ return (null); } public function start():void{ addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function createReaper(_arg1:Number, _arg2:Number, _arg3:Class):Reaper{ var _local4:Reaper = new _arg3(_arg1, _arg2, physics, renderer); _local4.addEventListener(Character.EVENT_DEAD, onReaperDead); _local4.addEventListener(Reaper.EVENT_WEAPON_FIRED, onReaperFire); _local4.node = reapers.append(_local4); _local4.setRenderLimits(renderer.viewportWidth, renderer.viewportHeight); return (_local4); } protected function createPed(_arg1:Number, _arg2:Number, _arg3:String=""):Ped{ var _local4:Ped; var _local5:Array; var _local6:int; if (_arg3 == ""){ _local5 = ["PedOfficeWomanAsset", "PedPoliceWomanAsset", "PedPoliceManAsset", "PedPrisonerAsset"]; _local6 = (Math.random() * _local5.length); _local4 = new Ped(_arg1, _arg2, physics, renderer, _local5[_local6]); } else { _local4 = new Ped(_arg1, _arg2, physics, renderer, _arg3); }; _local4.addEventListener(Character.EVENT_DEAD, onPedDead); _local4.addEventListener(Character.EVENT_INJURED, onPedInjured); _local4.node = peds.append(_local4); _local4.setRenderLimits(renderer.viewportWidth, renderer.viewportHeight); return (_local4); } protected function createWhiteReaper(_arg1:Number, _arg2:Number, _arg3:XMLList):Reaper{ var _local5:Number; var _local6:XML; var _local4:Reaper = createReaper(_arg1, _arg2, WhiteReaper); for each (_local6 in _arg3) { _local5 = parseFloat(_local6.@x); _local4.addAutomation(_local5, _arg2); }; return (_local4); } public function pause():void{ removeEventListener(Event.ENTER_FRAME, onEnterFrame); } private function createGrenade():Grenade{ var _local1:MovieClip; var _local2:MovieClip; _local1 = Main.assetFactory.createMovieClip("GrenadeAsset"); _local2 = Main.assetFactory.createMovieClip("GrenadeExplosionAsset"); renderer.addProjectile(_local1); renderer.addExplosion(_local2); return (new Grenade(_local1, _local2)); } private function onMessageTimer(_arg1:TimerEvent=null):void{ messageTimer.removeEventListener(TimerEvent.TIMER, onMessageTimer); messageTimer = null; renderer.removeChild(message); message = null; } private function launchRocket():void{ var _local1:Number = avatar.x; var _local2:Number = (avatar.y - 10); _local1 = (_local1 + ((avatar.direction)==Avatar.LEFT) ? -20 : 20); if (grenadePool.length == 0){ grenadePool.push(createGrenade()); }; var _local3:Grenade = grenadePool.pop(); _local3.init(_local1, _local2, avatar.direction, physics, true); grenades.append(_local3); } } }//package com.kerb.infamous.game.levels
Section 16
//Level1 (com.kerb.infamous.game.levels.Level1) package com.kerb.infamous.game.levels { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.dynamicBodies.*; import com.kerb.infamous.game.targets.*; import de.polygonal.ds.*; import com.kerb.infamous.game.render.*; import com.kerb.infamous.ui.*; import flash.utils.*; public class Level1 extends BaseLevel { public var XMLData:Class; private var hydrantNode:SListNode; private var instructionsActive:Boolean; private var steam:Target; private var instructionsStep:int; private var instructionsSickPed:Ped; private var car1:Car; private var car2:Car; private var steamMC:MovieClip; private var instructionsTimer:Timer; private var skipButton:MovieClip; private var instructionsStepsShown:Array; private var buttonBG:MovieClip; private var boxes:SLinkedList; private var hydrantMC:MovieClip; public function Level1(_arg1:UserDataManager, _arg2:int){ XMLData = Level1_XMLData; boxes = new SLinkedList(); super(_arg1, _arg2); } private function initInstructionsText(_arg1:int, _arg2:Number, _arg3:Number, _arg4:String=null, _arg5:MovieClip=null):void{ var _local6:MovieClip; var _local7:TextBox; var _local8:String; var _local9:MovieClip; if (_arg1 == instructionsStep){ return; }; _local6 = Main.assetFactory.createMovieClip("InGameInstructionsAsset"); _local6.x = _arg2; _local6.y = _arg3; _local6.id = _arg1; _local6.arrow = _arg5; _local8 = InfamousTextManager.getInstance().getTextById((("instructions." + _arg1) + ".1")).toUpperCase(); _local7 = new TextBox(_local6.orange.box); _local7.setText(_local8, TextBox.RULE_MIN_LINES); _local8 = InfamousTextManager.getInstance().getTextById((("instructions." + _arg1) + ".2")).toUpperCase(); _local7 = new TextBox(_local6.white.box); _local7.setText(_local8, TextBox.RULE_MIN_LINES); if (_local6.orange.box.label_txt.numLines == 1){ _local6.white.y = _local6.orange.height; } else { _local6.white.y = (_local6.orange.height - 10); }; if (_arg4){ _local9 = Main.assetFactory.createMovieClip(_arg4); _local9.x = (_local6.orange.width + 10); _local9.y = (5 - (0.5 * _local9.height)); _local6.addChild(_local9); }; (renderer as Level1Renderer).showInstructionsText(_local6); instructionsStep = _arg1; instructionsStepsShown[_arg1] = true; } private function initSkipButton():void{ buttonBG = Main.assetFactory.createMovieClip("SkipButtonBGAsset"); buttonBG.x = 310; buttonBG.y = 271.9; hud.addChildAt(buttonBG, 0); skipButton = Main.assetFactory.createMovieClip("FooButtonAsset"); skipButton.x = 445; skipButton.y = 300; hud.addChild(skipButton); skipButton.addEventListener(MouseEvent.CLICK, onSkipClick, false, 0, true); skipButton.addEventListener(MouseEvent.ROLL_OVER, onSkipRollOver, false, 0, true); skipButton.addEventListener(MouseEvent.ROLL_OUT, onSkipRollOut, false, 0, true); skipButton.addEventListener(MouseEvent.MOUSE_DOWN, onSkipMouseDown, false, 0, true); InfamousTextManager.getInstance().setText(skipButton.down.label_txt, "instructions.skip"); InfamousTextManager.getInstance().setText(skipButton.up.label_txt, "instructions.skip"); InfamousTextManager.getInstance().setText(skipButton.over.label.label_txt, "instructions.skip"); skipButton.hitArea = skipButton.hit; skipButton.hit.visible = false; skipButton.over.visible = false; skipButton.down.visible = false; skipButton.buttonMode = true; skipButton.mouseChildren = false; } private function onSkipMouseDown(_arg1:MouseEvent):void{ skipButton.up.visible = false; skipButton.over.visible = false; skipButton.down.visible = true; } private function checkInstructions():void{ var _local1:MovieClip; if ((((avatar.x < 590)) && (!(instructionsStepsShown[1])))){ initInstructionsText(1, 44, 100, "CursorKeysAsset"); } else { if ((((((avatar.x > 590)) && ((avatar.x < 860)))) && ((instructionsSickPed.life < 1)))){ initInstructionsText(2, 44, 100, "XKeyAsset"); } else { if ((((((avatar.x < 870)) && ((instructionsSickPed.life == 1)))) && (!(instructionsStepsShown[3])))){ _local1 = hud.showKarmaArrow(); initInstructionsText(3, 44, 100, null, _local1); } else { if ((((((((avatar.x > 870)) && ((avatar.x < 1830)))) && ((avatar.y > 710)))) && (!(instructionsStepsShown[4])))){ initInstructionsText(4, 44, 100, "UpKeyAsset"); } else { if ((((((avatar.x > 900)) && ((avatar.x < 1061)))) && ((avatar.y > 350)))){ (renderer as Level1Renderer).hideInstructionsText(); } else { if ((((((((avatar.x > 1061)) && ((avatar.x < 1290)))) && ((avatar.y < 470)))) && (!(instructionsStepsShown[5])))){ _local1 = hud.showEnergyArrow(); initInstructionsText(5, 50, 235, "XKeyAsset", _local1); } else { if ((((((((avatar.x < 1830)) && ((avatar.y < 330)))) && ((reapers.size == 6)))) && (!(instructionsStepsShown[6])))){ initInstructionsText(6, 50, 235, "SpacebarAsset"); } else { if ((((((((((avatar.x < 1830)) && ((avatar.y < 330)))) && ((reapers.size < 6)))) && (instructionsStepsShown[6]))) && (!(instructionsStepsShown[7])))){ initInstructionsText(7, 120, 240, "ZKeyAsset"); } else { if ((((((((((((avatar.x > 1730)) && ((avatar.x < 1830)))) && ((avatar.y < 330)))) && ((reapers.size == 5)))) && (instructionsStepsShown[7]))) && (!(instructionsStepsShown[8])))){ initInstructionsText(8, 50, 220, "ZKeyAsset"); } else { if ((((((avatar.x > 1765)) && ((avatar.y < 330)))) && (!(instructionsStepsShown[9])))){ initInstructionsText(9, 50, 220, "UpKeyAsset"); } else { if ((((((avatar.x > 1765)) && ((avatar.y > 710)))) && (!(instructionsStepsShown[10])))){ _local1 = hud.showLifeArrow(); initInstructionsText(10, 44, 100, "XKeyAsset", _local1); } else { if (avatar.updateStateFunction == avatar.updateCharge){ (renderer as Level1Renderer).hideInstructionsText(); } else { if ((((((avatar.x > 2250)) && ((avatar.x < 2650)))) && (!(instructionsStepsShown[11])))){ initInstructionsText(11, 44, 100); } else { if (avatar.x > 2650){ initInstructionsText(12, 44, 100); Constants.tutorialComplete = true; hud.removeChild(skipButton); hud.removeChild(buttonBG); instructionsTimer.start(); }; }; }; }; }; }; }; }; }; }; }; }; }; }; } private function onSkipRollOver(_arg1:MouseEvent):void{ skipButton.up.visible = false; skipButton.over.visible = true; skipButton.down.visible = false; } private function onSkipRollOut(_arg1:MouseEvent):void{ skipButton.up.visible = true; skipButton.over.visible = false; skipButton.down.visible = false; } override protected function init():void{ worldWidth = 6450; worldHeight = 750; physics = new Physics(worldWidth, worldHeight); renderer = new Level1Renderer(530, 365, worldWidth, worldHeight); renderer.cameraXOffset = -100; initCustomItems(); parseLevelData(loadXMLData(XMLData)); if (Constants.tutorialComplete){ avatar = new Avatar(1900, 725, 1, physics, renderer); } else { avatar = new Avatar(228, 715, 1, physics, renderer); }; initGraphics(); initCustomGraphics(); peds.reverse(); var _local1:SListNode = peds.head; _local1.data.deductLife(0.4, true); _local1 = _local1.next; _local1.data.deductLife(0.4, true); _local1 = _local1.next; _local1.data.deductLife(0.4, true); _local1 = _local1.next; instructionsSickPed = createPed(630, 715, "PedOfficeWomanAsset"); instructionsSickPed.deductLife(0.4, true); peds.append(instructionsSickPed); super.init(); instructionsActive = false; instructionsStepsShown = [null, false, false, false, false, false, false, false, false, false, false, false]; instructionsTimer = new Timer(4000); instructionsTimer.addEventListener(TimerEvent.TIMER, onInstructionsTimer, false, 0, true); instructionsTimer.start(); instructionsStep = 0; if (!Constants.tutorialComplete){ initSkipButton(); avatar.deductEnergy(0.2); }; } private function onInstructionsTimer(_arg1:TimerEvent):void{ instructionsTimer.stop(); instructionsActive = true; (renderer as Level1Renderer).hideInstructionsText(); } private function initCustomGraphics():void{ renderer.addToForeground(car1.mc); renderer.addToForeground(car2.mc); var _local1:SListNode = boxes.head; while (_local1) { renderer.addToForeground(_local1.data.mc); _local1 = _local1.next; }; } private function initCustomItems():void{ var _local1:DynamicBox; car1 = new Car(3039, 726, physics); dynamicBodies.append(car1.rb); car2 = new Car(5762, 722, physics); dynamicBodies.append(car2.rb); _local1 = new DynamicBox(1816, 330, 70, 70, 0, "WoodenBoxAsset", physics); _local1.mc.removable = true; boxes.append(_local1); _local1 = new DynamicBox(1803, 260, 70, 70, 0, "WoodenBoxAsset", physics); boxes.append(_local1); _local1.mc.removable = true; _local1 = new DynamicBox(1798, 190, 70, 70, 0, "WoodenBoxAsset", physics); boxes.append(_local1); _local1.mc.removable = true; _local1 = new DynamicBox(4675, 568, 40, 40, 0, "MetalBoxAsset", physics); boxes.append(_local1); _local1 = new DynamicBox(4679, 527, 40, 40, 0, "MetalBoxAsset", physics); boxes.append(_local1); _local1 = new DynamicBox(4666, 485, 30, 40, 0, "MetalBoxAsset", physics); boxes.append(_local1); _local1 = new DynamicBox(4619, 567, 30, 40, 0, "MetalBoxAsset", physics); boxes.append(_local1); var _local2:Target = new Target(6145, 606, Target.TYPE_DANGER, 70, 300, Avatar.WATER_LIFE_LOST_PER_FRAME); hydrantNode = dangers.append(_local2); steam = new Target(5467, 750, Target.TYPE_DANGER, 50, 10, Avatar.WATER_LIFE_LOST_PER_FRAME); dangers.append(steam); } private function onSkipClick(_arg1:MouseEvent):void{ (renderer as Level1Renderer).hideInstructionsText(); Constants.tutorialComplete = true; instructionsTimer.stop(); hud.removeChild(skipButton); hud.removeChild(buttonBG); stage.focus = stage; avatar.moveTo(2700, 715); } override protected function onEnterFrame(_arg1:Event):void{ var _local4:SListIterator; super.onEnterFrame(_arg1); car1.update(); car2.update(); var _local2:SListNode = boxes.head; while (_local2) { _local2.data.update(); _local2 = _local2.next; }; var _local3:int = steamMC.currentFrame; if (_local3 == 1){ steam.setYMin(749); steam.setYMax(755); } else { if (_local3 < 56){ steam.setYMin((755 - (3 * _local3))); } else { if (_local3 > 67){ steam.setYMax((755 - (3 * (_local3 - 67)))); }; }; }; _local4 = boxes.getListIterator(); _local4.start(); while (_local4.valid()) { if (_local4.node.data.mc.removable){ if (_local4.node.data.rb.y > 700){ physics.destroyRigidBody(_local4.node.data.rb); _local4.node.data.mc.visible = false; _local4.remove(); }; }; _local4.forth(); }; if ((((car2.rb.x > 6080)) && (hydrantNode))){ _local4 = dangers.getListIterator(); _local4.start(); while (_local4.valid()) { if (_local4.node == hydrantNode){ _local4.remove(); break; }; _local4.forth(); }; hydrantNode = null; hydrantMC.gotoAndStop("off"); }; if (!Constants.tutorialComplete){ if (instructionsActive){ checkInstructions(); }; }; } private function initGraphics():void{ var _local1:AssetFactory = Main.assetFactory; var _local2:MovieClip = _local1.createMovieClip("Level1BackdropAsset"); var _local3:MovieClip = _local1.createMovieClip("Level1BackParallaxAsset"); var _local4:MovieClip = _local1.createMovieClip("Level1FrontParallaxAsset"); renderer.setParallaxGraphics(_local2, _local3, _local4); var _local5:MovieClip = _local1.createMovieClip("Level1ForegroundAsset"); var _local6:MovieClip = _local1.createMovieClip("Level1BackgroundAsset"); renderer.setForegroundGraphics(_local5, _local6); hydrantMC = _local6.animatedGraphics.hydrant; steamMC = _local5.steam; if (!Game.pumaAllowed){ _local6.animatedGraphics.puma1.gotoAndStop("other"); _local6.animatedGraphics.puma2.gotoAndStop("other"); }; } } }//package com.kerb.infamous.game.levels
Section 17
//Level1_XMLData (com.kerb.infamous.game.levels.Level1_XMLData) package com.kerb.infamous.game.levels { import mx.core.*; public class Level1_XMLData extends ByteArrayAsset { } }//package com.kerb.infamous.game.levels
Section 18
//Level2 (com.kerb.infamous.game.levels.Level2) package com.kerb.infamous.game.levels { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.infamous.*; import com.kerb.sound.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.dynamicBodies.*; import com.kerb.infamous.game.targets.*; import de.polygonal.ds.*; import com.kerb.infamous.game.render.*; public class Level2 extends BaseLevel { private var boxes:SLinkedList; public var XMLData:Class; private var waterStreamMC:MovieClip; private var bottomWaterBox:DynamicBox; private var waterStream:Target; private var steam1:Target; private var steam2:Target; private var bottomWaterBoxSet:Boolean; private var topWaterBox:DynamicBox; private var steam1MC:MovieClip; private var waterSound:ExtendedSound; private var topWaterBoxSet:Boolean; private var steam2MC:MovieClip; public function Level2(_arg1:UserDataManager, _arg2:int){ XMLData = Level2_XMLData; boxes = new SLinkedList(); super(_arg1, _arg2); } private function initCustomGraphics():void{ var _local1:SListNode = boxes.head; while (_local1) { renderer.addToForeground(_local1.data.mc); _local1 = _local1.next; }; } override protected function init():void{ worldWidth = 2500; worldHeight = 1400; physics = new Physics(worldWidth, worldHeight); renderer = new Renderer(530, 365, worldWidth, worldHeight); renderer.cameraXOffset = 100; initCustomItems(); parseLevelData(loadXMLData(XMLData)); initGraphics(); initCustomGraphics(); var _local1:SListNode = peds.head; _local1.data.deductLife(0.4, true); _local1 = _local1.next; _local1.data.deductLife(0.4, true); topWaterBoxSet = false; bottomWaterBoxSet = false; super.init(); waterSound = Main.smSFX.getSoundByClassName("WaterSound"); waterSound.play(0, 9999999); } override protected function lose():void{ if (!levelComplete){ levelComplete = true; waterSound.stop(); dispatchEvent(new Event(Game.EVENT_LOSE_LEVEL)); }; } override protected function win():void{ if (!levelComplete){ levelComplete = true; waterSound.stop(); dispatchEvent(new Event(Game.EVENT_WIN_LEVEL)); }; } private function initCustomItems():void{ var _local1:DynamicBox; _local1 = new DynamicBox(1189, 1343, 114, 15, -0.9, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1265, 1261, 78, 23, 0.14, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1252, 0x0500, 86, 13, 0.118, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1270, 1309, 72, 32, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(0x0500, 1377, 107, 18, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1266, 1346, 91, 40, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(98, 741, 54, 22, 0, "MetalBoxAsset", physics, 3); boxes.append(_local1); _local1 = new DynamicBox(91, 719, 31, 20, 0, "MetalBoxAsset", physics, 3.5); boxes.append(_local1); _local1 = new DynamicBox(96, 695, 41, 12, 0, "MetalBoxAsset", physics, 3.5); boxes.append(_local1); _local1 = new DynamicBox(139, 732, 20, 40, 0, "MetalBoxAsset", physics, 3.5); boxes.append(_local1); _local1 = new DynamicBox(166, 730, 41, 15, 1.047, "MetalBoxAsset", physics, 3.5); boxes.append(_local1); topWaterBox = new DynamicBox(967, 580, 60, 60, 0, "WoodenBoxAsset", physics, 3); boxes.append(topWaterBox); bottomWaterBox = new DynamicBox(1065, 1082, 82, 80, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(bottomWaterBox); steam1 = new Target(2290, 600, Target.TYPE_DANGER, 50, 10, Avatar.WATER_LIFE_LOST_PER_FRAME); dangers.append(steam1); steam2 = new Target(2000, 1420, Target.TYPE_DANGER, 50, 10, Avatar.WATER_LIFE_LOST_PER_FRAME); dangers.append(steam2); waterStream = new Target(1011, 827, Target.TYPE_DANGER, 30, 1130, Avatar.WATER_LIFE_LOST_PER_FRAME); dangers.append(waterStream); } override protected function onEnterFrame(_arg1:Event):void{ var _local3:int; var _local4:Number; super.onEnterFrame(_arg1); var _local2:SListNode = boxes.head; while (_local2) { _local2.data.update(); _local2 = _local2.next; }; _local3 = steam1MC.currentFrame; if (_local3 == 1){ steam1.setYMin(600); steam1.setYMax(605); } else { if (_local3 < 56){ steam1.setYMin((600 - (3 * _local3))); } else { if (_local3 > 67){ steam1.setYMax((600 - (3 * (_local3 - 67)))); }; }; }; _local3 = steam2MC.currentFrame; if (_local3 == 1){ steam2.setYMin(1420); steam2.setYMax(1425); } else { if (_local3 < 56){ steam2.setYMin((1420 - (3 * _local3))); } else { if (_local3 > 67){ steam2.setYMax((1420 - (3 * (_local3 - 67)))); }; }; }; if (((!(topWaterBoxSet)) && ((topWaterBox.rb.x > 1000)))){ waterStreamMC.gotoAndStop("top"); waterStream.setYMax(550); topWaterBoxSet = true; } else { if (((!(bottomWaterBoxSet)) && ((bottomWaterBox.rb.x < 1050)))){ waterStreamMC.gotoAndStop("mid"); waterStream.setYMax(1042); bottomWaterBoxSet = true; }; }; var _local5:Number = (((-2 * avatar.x) / 2500) + 1); waterSound.setPan(_local5); if (_local5 < 0){ _local5 = -(_local5); }; _local5 = (_local5 * 0.25); waterSound.setVolume((0.5 - _local5)); } private function initGraphics():void{ var _local1:AssetFactory = Main.assetFactory; var _local2:MovieClip = _local1.createMovieClip("Level2BackdropAsset"); var _local3:MovieClip = _local1.createMovieClip("Level2BackParallaxAsset"); var _local4:MovieClip = _local1.createMovieClip("Level2FrontParallaxAsset"); renderer.setParallaxGraphics(_local2, _local3, _local4); var _local5:MovieClip = _local1.createMovieClip("Level2ForegroundAsset"); var _local6:MovieClip = _local1.createMovieClip("Level2BackgroundAsset"); renderer.setForegroundGraphics(_local5, _local6); steam1MC = _local5.steam1; steam2MC = _local5.steam2; waterStreamMC = _local6.animatedGraphics.waterStream; } } }//package com.kerb.infamous.game.levels
Section 19
//Level2_XMLData (com.kerb.infamous.game.levels.Level2_XMLData) package com.kerb.infamous.game.levels { import mx.core.*; public class Level2_XMLData extends ByteArrayAsset { } }//package com.kerb.infamous.game.levels
Section 20
//Level3 (com.kerb.infamous.game.levels.Level3) package com.kerb.infamous.game.levels { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.dynamicBodies.*; import com.kerb.infamous.game.targets.*; import de.polygonal.ds.*; import com.kerb.infamous.game.render.*; import com.kerb.infamous.ui.*; public class Level3 extends BaseLevel { public var XMLData:Class; private var cellDoors:Array; private var doors:Array; private var switchAnimationFinished:Boolean;// = false private var instructionsText:MovieClip; private var lockMessageShown:Boolean;// = false private var doorLocks:SLinkedList; private var avatarBySwitch:Boolean;// = false private var cellLocks:SLinkedList; private var boxes:SLinkedList; public function Level3(_arg1:UserDataManager, _arg2:int){ XMLData = Level3_XMLData; boxes = new SLinkedList(); doorLocks = new SLinkedList(); cellLocks = new SLinkedList(); doors = new Array(); cellDoors = new Array(); super(_arg1, _arg2); } override protected function onLockActivated(_arg1:Event):void{ var _local5:Array; var _local6:int; var _local2:LockTarget = (avatar.standTarget as LockTarget); if (!_local2){ return; }; _local2.performActions(); Main.smSFX.getSoundByClassName("DoorOpenSound").play(); var _local3:SListIterator = cellLocks.getListIterator(); var _local4:Boolean; _local3.start(); while (_local3.valid()) { if (_local3.data == _local2){ _local3.remove(); _local4 = true; break; }; _local3.forth(); }; if (!_local4){ hideLockMessage(); _local5 = _local2.checkCells(); if (_local5){ _local6 = _local5.length; while (--_local6 > -1) { Main.smSFX.getSoundByClassName("MegawattExplosionSound").play(); Main.smSFX.getSoundByClassName("ScreamSound").play(); applyKarma(Ped.KARMA_PER_DEATH); _local3 = cellLocks.getListIterator(); _local3.start(); while (_local3.valid()) { if (_local3.data == _local5[_local6]){ _local3.remove(); break; }; _local3.forth(); }; }; }; }; } override protected function init():void{ worldWidth = 1800; worldHeight = 2900; physics = new Physics(worldWidth, worldHeight); renderer = new Renderer(530, 365, worldWidth, worldHeight); renderer.cameraXOffset = -87; initCustomItems(); parseLevelData(loadXMLData(XMLData)); initGraphics(); initCustomGraphics(); super.init(); } private function initCustomGraphics():void{ var _local1:SListNode = boxes.head; while (_local1) { renderer.addToForeground(_local1.data.mc); _local1 = _local1.next; }; } override protected function win():void{ levelComplete = true; } private function initGraphics():void{ var _local8:MovieClip; var _local1:AssetFactory = Main.assetFactory; var _local2:MovieClip = _local1.createMovieClip("Level3BackdropAsset"); var _local3:MovieClip = _local1.createMovieClip("Level3BackParallaxAsset"); var _local4:MovieClip = _local1.createMovieClip("Level3FrontParallaxAsset"); renderer.setParallaxGraphics(_local2, _local3, _local4); _local2.cacheAsBitmap = true; _local3.cacheAsBitmap = true; _local4.cacheAsBitmap = true; var _local5:MovieClip = _local1.createMovieClip("Level3ForegroundAsset"); var _local6:MovieClip = _local1.createMovieClip("Level3BackgroundAsset"); var _local7:int; while (_local7 < 8) { _local8 = (_local6.animatedGraphics.getChildByName(("cellDoor" + _local7)) as MovieClip); _local8.cacheAsBitmap = true; cellDoors[_local7].mc = _local8; _local8 = (_local6.animatedGraphics.getChildByName(("door" + _local7)) as MovieClip); _local8.gotoAndStop(((((_local7 == 2)) || ((_local7 == 5)))) ? "open" : "closed"); doors[_local7].mc = _local8; _local7++; }; if (!Game.pumaAllowed){ _local6.animatedGraphics.puma1.gotoAndStop("other"); _local6.animatedGraphics.puma2.gotoAndStop("other"); }; renderer.setForegroundGraphics(_local5, _local6); } private function initCustomItems():void{ var _local1:DynamicBox; var _local2:CellDoor; var _local4:Door; var _local5:LockTarget; _local1 = new DynamicBox(810, 2584, 50, 25, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(820, 2553, 50, 25, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1183, 2804, 50, 40, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1194, 2757, 40, 50, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1736, 2804, 50, 40, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1747, 2757, 40, 50, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1672, 2803, 45, 45, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(1702, 2755, 30, 50, 0.524, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(342, 1486, 60, 31, 0, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(406, 1470, 87, 31, 0.524, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(332, 1442, 51, 44, 1.571, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(876, 411, 24, 113, 1.571, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local1 = new DynamicBox(890, 382, 24, 113, 1.571, "WoodenBoxAsset", physics, 1.5); boxes.append(_local1); _local2 = new CellDoor("PedPoliceManAsset"); cellDoors.push(_local2); _local2 = new CellDoor("PedOfficeWomanAsset"); cellDoors.push(_local2); _local2 = new CellDoor("PedPrisonerAsset"); cellDoors.push(_local2); _local2 = new CellDoor("PedPoliceWomanAsset"); cellDoors.push(_local2); _local2 = new CellDoor("PedPoliceWomanAsset"); cellDoors.push(_local2); _local2 = new CellDoor("PedPrisonerAsset"); cellDoors.push(_local2); _local2 = new CellDoor("PedOfficeWomanAsset"); cellDoors.push(_local2); _local2 = new CellDoor("PedPoliceManAsset"); cellDoors.push(_local2); var _local3:Array = new Array(); _local5 = new LockTarget(393, 2558); _local5.addAction(cellDoors[0].open); cellLocks.append(_local5); _local3.push(_local5); _local5 = new LockTarget(492, 2558); _local5.addAction(cellDoors[1].open); cellLocks.append(_local5); _local3.push(_local5); _local5 = new LockTarget(1126, 2558); _local5.addAction(cellDoors[2].open); cellLocks.append(_local5); _local3.push(_local5); _local5 = new LockTarget(1226, 2558); _local5.addAction(cellDoors[3].open); cellLocks.append(_local5); _local3.push(_local5); _local5 = new LockTarget(393, 2348); _local5.addAction(cellDoors[4].open); cellLocks.append(_local5); _local3.push(_local5); _local5 = new LockTarget(492, 2348); _local5.addAction(cellDoors[5].open); cellLocks.append(_local5); _local3.push(_local5); _local5 = new LockTarget(1126, 2348); _local5.addAction(cellDoors[6].open); cellLocks.append(_local5); _local3.push(_local5); _local5 = new LockTarget(1226, 2348); _local5.addAction(cellDoors[7].open); cellLocks.append(_local5); _local3.push(_local5); _local4 = new Door(201, 2551, 22, 95, physics); doors.push(_local4); _local4 = new Door(679, 2551, 22, 95, physics); doors.push(_local4); _local4 = new Door(931, 2551, 22, 95, physics); _local4.open(); doors.push(_local4); _local4 = new Door(1409, 2551, 22, 95, physics); doors.push(_local4); _local4 = new Door(201, 2341, 22, 95, physics); doors.push(_local4); _local4 = new Door(679, 2341, 22, 95, physics); _local4.open(); doors.push(_local4); _local4 = new Door(931, 2341, 22, 95, physics); doors.push(_local4); _local4 = new Door(1409, 2341, 22, 95, physics); doors.push(_local4); _local5 = new LockTarget(180, 0x0A00); _local5.addAction(doors[0].toggle); doorLocks.append(_local5); _local5 = new LockTarget(660, 0x0A00); _local5.addAction(doors[1].toggle); _local5.addAction(doors[2].toggle); _local5.addCell(cellDoors[0], _local3[0]); _local5.addCell(cellDoors[1], _local3[1]); doorLocks.append(_local5); _local5 = new LockTarget(1000, 0x0A00); _local5.addAction(doors[1].toggle); _local5.addAction(doors[2].toggle); _local5.addCell(cellDoors[2], _local3[2]); _local5.addCell(cellDoors[3], _local3[3]); doorLocks.append(_local5); _local5 = new LockTarget(1485, 0x0A00); _local5.addAction(doors[3].toggle); doorLocks.append(_local5); _local5 = new LockTarget(275, 2356); _local5.addAction(doors[4].toggle); _local5.addCell(cellDoors[4], _local3[4]); _local5.addCell(cellDoors[5], _local3[5]); doorLocks.append(_local5); _local5 = new LockTarget(660, 2356); _local5.addAction(doors[5].toggle); _local5.addAction(doors[6].toggle); doorLocks.append(_local5); _local5 = new LockTarget(1000, 2356); _local5.addAction(doors[5].toggle); _local5.addAction(doors[6].toggle); doorLocks.append(_local5); _local5 = new LockTarget(1390, 2356); _local5.addAction(doors[7].toggle); _local5.addCell(cellDoors[6], _local3[6]); _local5.addCell(cellDoors[7], _local3[7]); doorLocks.append(_local5); } override protected function checkCustomTargets():Target{ var _local1:Target = checkTargetList(doorLocks); if (_local1){ if (!lockMessageShown){ showLockMessage(); lockMessageShown = true; }; } else { _local1 = checkTargetList(cellLocks); }; return (_local1); } private function showLockMessage():void{ var _local1:TextBox; var _local2:String; var _local3:MovieClip; instructionsText = Main.assetFactory.createMovieClip("InGameInstructionsAsset"); instructionsText.x = 220; instructionsText.y = 200; _local2 = InfamousTextManager.getInstance().getTextById("instructions.lock.1").toUpperCase(); _local1 = new TextBox(instructionsText.orange.box); _local1.setText(_local2, TextBox.RULE_MIN_LINES); _local2 = InfamousTextManager.getInstance().getTextById("instructions.lock.2").toUpperCase(); _local1 = new TextBox(instructionsText.white.box); _local1.setText(_local2, TextBox.RULE_MIN_LINES); if (instructionsText.orange.box.label_txt.numLines == 1){ instructionsText.white.y = instructionsText.orange.height; } else { instructionsText.white.y = (instructionsText.orange.height - 10); }; renderer.addChild(instructionsText); } private function hideLockMessage():void{ if (instructionsText){ renderer.removeChild(instructionsText); instructionsText = null; }; } override protected function onEnterFrame(_arg1:Event):void{ var _local4:int; var _local5:Number; var _local6:Number; var _local7:Ped; super.onEnterFrame(_arg1); var _local2:SListNode = boxes.head; while (_local2) { _local2.data.update(); _local2 = _local2.next; }; var _local3:int; while (_local3 < 8) { _local4 = cellDoors[_local3].mc.currentFrame; if (_local4 == 62){ _local5 = (cellDoors[_local3].mc.x + 22.1); _local6 = (cellDoors[_local3].mc.y + 60); _local7 = createPed(_local5, _local6, cellDoors[_local3].pedRef); applyKarma(Ped.KARMA_PER_CELL_UNLOCK); }; _local3++; }; renderer.cameraXOffset = ((0.1 * avatar.x) - 100); if (((levelComplete) && ((avatar.life > 0)))){ if (avatarBySwitch){ if (!switchAnimationFinished){ if (renderer.switchAnimationComplete()){ switchAnimationFinished = true; dispatchEvent(new Event(Game.EVENT_WIN_LEVEL)); }; }; } else { if (avatar.moveTowardsSwitch()){ avatarBySwitch = true; renderer.startSwitchAnimation(); Main.smSFX.getSoundByClassName("DoorOpenSound").play(); Main.smSFX.getSoundByClassName("LockSound").play(); Main.smSFX.getSoundByClassName("GrenadeThrowSound").play(); Main.smSFX.getSoundByClassName("GeneratorSound").play(); }; }; }; } } }//package com.kerb.infamous.game.levels
Section 21
//Level3_XMLData (com.kerb.infamous.game.levels.Level3_XMLData) package com.kerb.infamous.game.levels { import mx.core.*; public class Level3_XMLData extends ByteArrayAsset { } }//package com.kerb.infamous.game.levels
Section 22
//Level1Renderer (com.kerb.infamous.game.render.Level1Renderer) package com.kerb.infamous.game.render { import flash.display.*; import com.kerb.infamous.game.*; public class Level1Renderer extends Renderer { private var currInstructionsText:MovieClip; private var nextInstructionsText:MovieClip; private var finishedInstructions:Array; public function Level1Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){ super(_arg1, _arg2, _arg3, _arg4); finishedInstructions = new Array(); } public function hideInstructionsText():void{ var _local2:MovieClip; var _local1:int = finishedInstructions.length; while (--_local1 > -1) { _local2 = finishedInstructions[_local1]; if (!_local2.hiding){ _local2.white.gotoAndPlay("hide"); _local2.orange.gotoAndPlay("hide"); if (_local2.arrow){ _local2.arrow.gotoAndPlay("hide"); }; _local2.arrow = null; _local2.hiding = true; }; }; } override public function draw(_arg1:Physics):void{ var _local3:MovieClip; super.draw(_arg1); if (currInstructionsText){ if (currInstructionsText.white.currentFrame == currInstructionsText.white.totalFrames){ currInstructionsText = nextInstructionsText; nextInstructionsText = null; if (currInstructionsText){ currInstructionsText.white.play(); currInstructionsText.orange.play(); }; }; }; var _local2:int = finishedInstructions.length; while (--_local2 > -1) { _local3 = finishedInstructions[_local2]; if ((((_local3.white.currentFrame == _local3.white.totalFrames)) || ((_local3.orange.currentFrame == _local3.orange.totalFrames)))){ removeChild(_local3); finishedInstructions.splice(_local2, 1); }; }; } public function showInstructionsText(_arg1:MovieClip):void{ addChild(_arg1); if (currInstructionsText){ nextInstructionsText = _arg1; nextInstructionsText.stop(); hideInstructionsText(); } else { currInstructionsText = _arg1; nextInstructionsText = null; }; finishedInstructions.push(_arg1); _arg1.hiding = false; } } }//package com.kerb.infamous.game.render
Section 23
//Renderer (com.kerb.infamous.game.render.Renderer) package com.kerb.infamous.game.render { import flash.display.*; import com.kerb.utils.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import flash.geom.*; public class Renderer extends Sprite { private var shakeCounterX:int; private var shakeCounterY:int; private var cameraYGoal:Number; private var projectileSprite:Sprite; private var damageSprite:Sprite; private var staticGraphics:MovieClip; private var cameraXRange:Number; private var parallaxFrontSprite:Sprite; private var staticGraphicsChildren:Array; private var explosionSprite:Sprite; public var cameraXOffset:Number; private var characterSprite:Sprite; private var animatedGraphics:MovieClip; protected var worldHeight:Number; protected var worldWidth:Number; private var vignetteX:Number; private var vignetteY:Number; private var yAxisLocked:Boolean; private var animatedGraphicsChildren:Array; private var renderXMin:Number; public var viewportHeight:Number; private var avatarSprite:Sprite; private var renderXMax:Number; private var parallaxBackSprite:Sprite; private var cameraXGoal:Number; public var cameraYOffset:Number; private var backgroundSprite:Sprite; private var shakePowerX:Number; private var shakePowerY:Number; private var vignetteSprite:Sprite; private var xAxisLocked:Boolean; private var introText:MovieClip; private var backdropSprite:Sprite; public var viewportWidth:Number; private var cameraYRange:Number; private var renderYMin:Number; private var cameraX:Number; private var cameraY:Number; private var renderYMax:Number; private var shakeInitX:Number; private var foregroundSprite:Sprite; private var shakeInitY:Number; protected var renderSprite:Sprite; private static const HORIZONTAL_LIMIT:Number = 30; private static const BACK_PARALLAX_Y_DIST:Number = 50; private static const CAMERA_EASING:Number = 0.6; private static const RENDER_PADDING:Number = 20; private static const MAX_SHAKE_DISTANCE:Number = 0; private static const SHAKE_DURATION:int = 15; private static const VIGNETTE_EASING:Number = 0.3; private static const RENDER_PADDING_TWICE:Number = 40; private static const VERTICAL_LIMIT:Number = 40; private static const FRONT_PARALLAX_Y_DIST:Number = 100; public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){ this.viewportWidth = _arg1; this.viewportHeight = _arg2; this.worldWidth = _arg3; this.worldHeight = _arg4; init(); } public function switchAnimationComplete():Boolean{ if (animatedGraphics.bigSwitch.animation){ return ((animatedGraphics.bigSwitch.animation.currentFrame == animatedGraphics.bigSwitch.animation.totalFrames)); }; return (false); } private function init():void{ xAxisLocked = false; yAxisLocked = false; initRenderLimits(); initCamera(); initSprites(); } private function shakeX():void{ shakeCounterX--; var _local1:Number = ((shakeCounterX * shakePowerX) * MAX_SHAKE_DISTANCE); if ((shakeCounterX % 2) == 1){ _local1 = -(_local1); }; x = (shakeInitX + _local1); } private function shakeY():void{ shakeCounterY--; var _local1:Number = ((shakeCounterY * shakePowerY) * MAX_SHAKE_DISTANCE); if ((shakeCounterY % 2) == 1){ _local1 = -(_local1); }; y = (shakeInitY + _local1); } private function initSprites():void{ var _local2:MovieClip; var _local1:AssetFactory = Main.assetFactory; backdropSprite = new Sprite(); addChild(backdropSprite); parallaxBackSprite = new Sprite(); backdropSprite.addChild(parallaxBackSprite); parallaxFrontSprite = new Sprite(); backdropSprite.addChild(parallaxFrontSprite); renderSprite = new Sprite(); addChild(renderSprite); backgroundSprite = new Sprite(); renderSprite.addChild(backgroundSprite); explosionSprite = new Sprite(); renderSprite.addChild(explosionSprite); projectileSprite = new Sprite(); renderSprite.addChild(projectileSprite); avatarSprite = new Sprite(); renderSprite.addChild(avatarSprite); characterSprite = new Sprite(); renderSprite.addChild(characterSprite); foregroundSprite = new Sprite(); renderSprite.addChild(foregroundSprite); vignetteSprite = new Sprite(); renderSprite.addChild(vignetteSprite); damageSprite = new Sprite(); damageSprite.blendMode = BlendMode.DARKEN; _local2 = _local1.createMovieClip("DamageAsset"); _local2.name = "animation"; damageSprite.addChild(_local2); damageSprite.visible = false; addChild(damageSprite); var _local3:Shape = new Shape(); _local3.graphics.beginFill(0); _local3.graphics.drawRect(0, 0, viewportWidth, viewportHeight); addChild(_local3); renderSprite.mask = _local3; } public function addLightning(_arg1:Sprite):void{ projectileSprite.addChild(_arg1); } public function draw(_arg1:Physics):void{ var _local2:Number; var _local3:Number; if (!xAxisLocked){ cameraX = (cameraX + (CAMERA_EASING * (cameraXGoal - cameraX))); _local2 = (cameraXRange * ((cameraX / worldWidth) - 0.5)); renderSprite.x = ((((0.5 * viewportWidth) - cameraX) + _local2) + cameraXOffset); }; if (!yAxisLocked){ cameraY = (cameraY + (CAMERA_EASING * (cameraYGoal - cameraY))); _local3 = (cameraYRange * ((cameraY / worldHeight) - 0.5)); renderSprite.y = ((((0.5 * viewportHeight) - cameraY) + _local3) + cameraYOffset); }; updateGraphics(staticGraphics, staticGraphicsChildren); updateGraphics(animatedGraphics, animatedGraphicsChildren); vignetteX = (vignetteX + (VIGNETTE_EASING * (cameraXGoal - vignetteX))); vignetteY = (vignetteY + (VIGNETTE_EASING * (cameraYGoal - vignetteY))); updateParallax(); if (shakeCounterX > 0){ shakeX(); }; if (shakeCounterY > 0){ shakeY(); }; if (introText){ if (introText.currentFrame == introText.totalFrames){ removeChild(introText); introText = null; }; }; } public function lockYAxis():void{ yAxisLocked = true; } public function addAvatar(_arg1:MovieClip):void{ avatarSprite.addChild(_arg1); } private function initCamera():void{ cameraXRange = 50; cameraYRange = 200; cameraXOffset = 0; cameraYOffset = 0; } public function addToForeground(_arg1:MovieClip):void{ foregroundSprite.addChild(_arg1); } public function addProjectile(_arg1:MovieClip):void{ projectileSprite.addChild(_arg1); } public function addExplosion(_arg1:MovieClip):void{ explosionSprite.addChild(_arg1); } public function setIntroText(_arg1:MovieClip):void{ this.introText = _arg1; addChild(_arg1); } private function initRenderLimits():void{ renderXMin = HORIZONTAL_LIMIT; renderXMax = (viewportWidth - HORIZONTAL_LIMIT); renderYMin = VERTICAL_LIMIT; renderYMax = (viewportHeight - VERTICAL_LIMIT); } public function addCharacter(_arg1:MovieClip):void{ characterSprite.addChild(_arg1); } private function updateParallax():void{ var _local1:Number; var _local2:Number; if (!xAxisLocked){ _local1 = ((cameraX + renderXMin) / worldWidth); parallaxBackSprite.x = ((_local1 * ((viewportWidth - parallaxBackSprite.width) + RENDER_PADDING_TWICE)) - RENDER_PADDING); parallaxFrontSprite.x = ((_local1 * ((viewportWidth - parallaxFrontSprite.width) + RENDER_PADDING_TWICE)) - RENDER_PADDING); }; if (!yAxisLocked){ _local2 = (1 - ((cameraY + renderYMin) / worldHeight)); parallaxFrontSprite.y = (_local2 * FRONT_PARALLAX_Y_DIST); parallaxBackSprite.y = (_local2 * BACK_PARALLAX_Y_DIST); }; } private function updateGraphics(_arg1:MovieClip, _arg2:Array):void{ var _local4:MovieClip; var _local9:Boolean; var _local10:int; var _local11:int; var _local12:MovieClip; var _local13:int; var _local3:int = _arg2.length; var _local5:Number = -(renderSprite.x); var _local6:Number = -(renderSprite.y); var _local7:Number = (_local5 + viewportWidth); var _local8:Number = (_local6 + viewportHeight); while (--_local3 > -1) { _local4 = _arg2[_local3]; _local9 = (((((((_local4.right > _local5)) && ((_local4.left < _local7)))) && ((_local4.bottom > _local6)))) && ((_local4.top < _local8))); if (_local9){ if (!_local4.parent){ _local10 = 0; _local11 = 0; while (_local11 < _arg1.numChildren) { _local12 = (_arg1.getChildAt(_local11) as MovieClip); if (_local12){ if (_local12.z > _local4.z){ _local10 = _local11; break; } else { _local10 = (_local11 + 1); }; }; _local11++; }; _arg1.addChildAt(_local4, _local10); }; } else { if (_local4.parent){ _arg1.removeChild(_local4); }; }; }; } public function setCameraPosition(_arg1:Number, _arg2:Number):void{ cameraXGoal = _arg1; cameraYGoal = _arg2; } public function setParallaxGraphics(_arg1:MovieClip, _arg2:MovieClip, _arg3:MovieClip):void{ if (_arg1){ _arg1.x = -(RENDER_PADDING); _arg1.y = -(RENDER_PADDING); backdropSprite.addChild(_arg1); backdropSprite.setChildIndex(_arg1, 0); }; if (_arg2){ parallaxBackSprite.addChild(_arg2); }; if (_arg3){ parallaxFrontSprite.addChild(_arg3); }; } public function showDamage():void{ damageSprite.visible = true; (damageSprite.getChildByName("animation") as MovieClip).gotoAndPlay("active"); } public function lockXAxis():void{ xAxisLocked = true; } public function initShake(_arg1:Number, _arg2:Number):void{ this.shakePowerX = _arg1; this.shakePowerY = _arg2; shakeCounterX = (_arg1 * SHAKE_DURATION); shakeCounterY = (_arg2 * SHAKE_DURATION); shakeInitX = x; shakeInitY = y; } public function fixCameraPosition(_arg1:Number, _arg2:Number):void{ cameraXGoal = _arg1; cameraYGoal = _arg2; cameraX = _arg1; cameraY = _arg2; vignetteX = _arg1; vignetteY = _arg2; } public function startSwitchAnimation():void{ animatedGraphics.bigSwitch.gotoAndStop("active"); } public function setForegroundGraphics(_arg1:MovieClip, _arg2:MovieClip):void{ var _local3:int; var _local4:MovieClip; var _local5:Rectangle; foregroundSprite.addChild(_arg1); backgroundSprite.addChild(_arg2); staticGraphics = _arg2.staticGraphics; animatedGraphics = _arg2.animatedGraphics; _local3 = staticGraphics.numChildren; staticGraphicsChildren = new Array(); while (--_local3 > -1) { _local4 = (staticGraphics.getChildAt(_local3) as MovieClip); if (_local4){ staticGraphicsChildren.push(_local4); _local4.cacheAsBitmap = true; _local5 = _local4.getBounds(staticGraphics); _local4.left = _local5.left; _local4.right = _local5.right; _local4.top = _local5.top; _local4.bottom = _local5.bottom; _local4.z = _local3; staticGraphics.removeChild(_local4); }; }; _local3 = animatedGraphics.numChildren; animatedGraphicsChildren = new Array(); while (--_local3 > -1) { _local4 = (animatedGraphics.getChildAt(_local3) as MovieClip); if (_local4){ animatedGraphicsChildren.push(_local4); _local5 = _local4.getBounds(staticGraphics); _local4.left = (_local5.left - 50); _local4.right = (_local5.right + 50); _local4.top = (_local5.top - 50); _local4.bottom = (_local5.bottom + 50); _local4.z = _local3; animatedGraphics.removeChild(_local4); }; }; } } }//package com.kerb.infamous.game.render
Section 24
//AbstractScreen (com.kerb.infamous.game.screens.AbstractScreen) package com.kerb.infamous.game.screens { import flash.events.*; import flash.display.*; import com.kerb.utils.*; public class AbstractScreen extends Sprite implements IDisposable { protected var mc:MovieClip; public function AbstractScreen(){ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } protected function init():void{ } private function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); init(); } public function dispose():void{ } } }//package com.kerb.infamous.game.screens
Section 25
//HelpScreen (com.kerb.infamous.game.screens.HelpScreen) package com.kerb.infamous.game.screens { import flash.events.*; import com.kerb.infamous.*; import flash.text.*; import com.kerb.infamous.ui.*; import com.kerb.tracking.*; public class HelpScreen extends AbstractScreen { private var tooltipBox:TextBox; private var backLabel:String; private var websiteButton:WebsiteButton; private function onBackClick(_arg1:MouseEvent):void{ stage.focus = stage; dispatchEvent(new Event(Event.COMPLETE)); } private function initForumButton():void{ mc.forum_btn.addEventListener(MouseEvent.CLICK, onForumClick, false, 0, true); mc.forum_btn.addEventListener(MouseEvent.ROLL_OVER, onForumRollOver, false, 0, true); mc.forum_btn.addEventListener(MouseEvent.ROLL_OUT, onForumRollOut, false, 0, true); mc.forum_btn.addEventListener(MouseEvent.MOUSE_DOWN, onForumMouseDown, false, 0, true); mc.forum_btn.addEventListener(MouseEvent.CLICK, onForumClick, false, 0, true); mc.forum_btn.buttonMode = true; mc.forum_btn.mouseChildren = false; mc.forum_btn.over.visible = false; mc.forum_btn.down.visible = false; mc.forum_btn.hitArea = mc.forum_btn.hit; mc.forum_btn.hit.visible = false; mc.forum_btn.over.addEventListener(Event.ENTER_FRAME, _onForumButtonOverEnterFrame); InfamousTextManager.getInstance().setText(mc.forum_btn.up.label_txt, "help.forum"); InfamousTextManager.getInstance().setText(mc.forum_btn.down.label_txt, "help.forum"); } private function onForumMouseDown(_arg1:MouseEvent):void{ mc.forum_btn.up.visible = false; mc.forum_btn.over.visible = false; mc.forum_btn.down.visible = true; } private function onBackRollOut(_arg1:MouseEvent):void{ mc.back_btn.up.visible = true; mc.back_btn.over.visible = false; mc.back_btn.down.visible = false; } private function onForumRollOver(_arg1:MouseEvent):void{ mc.forum_btn.up.visible = false; mc.forum_btn.over.visible = true; mc.forum_btn.down.visible = false; } private function onTooltipRollOut(_arg1:MouseEvent):void{ mc.tooltip.gotoAndPlay("hide"); } override protected function init():void{ super.init(); mc = Main.assetFactory.createMovieClip("HelpScreenAsset"); addChild(mc); websiteButton = new WebsiteButton(mc.website_btn); mc.help_btn.addEventListener(MouseEvent.CLICK, onBackClick, false, 0, true); initBackButton(); initForumButton(); var _local1:InfamousTextManager = InfamousTextManager.getInstance(); _local1.setText(mc.title_txt, "help.title", false); _local1.setText(mc.up_txt); mc.up_txt.text = splitPhrase(_local1.getTextById("help.up")); _local1.setText(mc.down_txt); mc.down_txt.text = splitPhrase(_local1.getTextById("help.down")); _local1.setText(mc.left_txt); mc.left_txt.text = splitPhrase(_local1.getTextById("help.left")); _local1.setText(mc.right_txt); mc.right_txt.text = splitPhrase(_local1.getTextById("help.right")); _local1.setText(mc.space_txt); mc.space_txt.text = _local1.getTextById("help.space"); _local1.setText(mc.doubleUp_txt); mc.doubleUp_txt.text = splitPhrase(_local1.getTextById("help.double.up")); _local1.setText(mc.z_txt); mc.z_txt.text = _local1.getTextById("help.z"); _local1.setText(mc.x_txt); mc.x_txt.text = _local1.getTextById("help.x"); _local1.setText(mc.actions1_txt); mc.actions1_txt.text = splitPhrase(_local1.getTextById("help.actions.1")); _local1.setText(mc.actions2_txt); mc.actions2_txt.text = splitPhrase(_local1.getTextById("help.actions.2")); _local1.setText(mc.actions3_txt); mc.actions3_txt.text = splitPhrase(_local1.getTextById("help.actions.3")); _local1.setText(mc.actions4_txt); mc.actions4_txt.text = splitPhrase(_local1.getTextById("help.actions.4")); _local1.setText(mc.powers1_txt); mc.powers1_txt.text = splitPhrase(_local1.getTextById("help.powers.1")); _local1.setText(mc.powers2_txt); mc.powers2_txt.text = splitPhrase(_local1.getTextById("help.powers.2")); _local1.setText(mc.powers3_txt); mc.powers3_txt.text = splitPhrase(_local1.getTextById("help.powers.3")); _local1.setText(mc.powers4_txt); mc.powers4_txt.text = splitPhrase(_local1.getTextById("help.powers.4")); mc.controls.label_txt.autoSize = TextFieldAutoSize.LEFT; _local1.setText(mc.controls.label_txt, "help.controls", false); mc.controls.bg.width = (mc.controls.label_txt.width + 16); mc.powers.label_txt.autoSize = TextFieldAutoSize.LEFT; _local1.setText(mc.powers.label_txt, "help.powers", false); mc.powers.bg.width = (mc.powers.label_txt.width + 16); mc.actions.label_txt.autoSize = TextFieldAutoSize.LEFT; _local1.setText(mc.actions.label_txt, "help.actions"); mc.actions.bg.width = (mc.actions.label_txt.width + 16); addEventListener(Event.ENTER_FRAME, onEnterFrame); Main.smSFX.getSoundByClassName("BoomSound").play(); mc.action1.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.action1.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.action2.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.action2.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.action3.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.action3.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.action4.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.action4.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.action1.buttonMode = true; mc.action2.buttonMode = true; mc.action3.buttonMode = true; mc.action4.buttonMode = true; mc.power1.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.power1.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.power2.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.power2.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.power3.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.power3.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.power4.addEventListener(MouseEvent.ROLL_OVER, onTooltipRollOver, false, 0, true); mc.power4.addEventListener(MouseEvent.ROLL_OUT, onTooltipRollOut, false, 0, true); mc.power1.buttonMode = true; mc.power2.buttonMode = true; mc.power3.buttonMode = true; mc.power4.buttonMode = true; tooltipBox = new TextBox(mc.tooltip.box); mc.tooltip.mouseEnabled = false; mc.tooltip.mouseChildren = false; } private function _onForumButtonOverEnterFrame(_arg1:Event):void{ InfamousTextManager.getInstance().setText(mc.forum_btn.over.label.label_txt, "help.forum"); } override public function dispose():void{ super.dispose(); removeEventListener(Event.ENTER_FRAME, onEnterFrame); } private function _onBackButtonOverEnterFrame(_arg1:Event):void{ InfamousTextManager.getInstance().setText(mc.back_btn.over.label.label_txt, "help.back"); } private function onBackMouseDown(_arg1:MouseEvent):void{ mc.back_btn.up.visible = false; mc.back_btn.over.visible = false; mc.back_btn.down.visible = true; } private function onForumClick(_arg1:MouseEvent):void{ stage.focus = stage; DoubleQuick.click(Tracking.getForumClickWatchIdFromLocale()); } private function initBackButton():void{ mc.back_btn.addEventListener(MouseEvent.CLICK, onBackClick, false, 0, true); mc.back_btn.addEventListener(MouseEvent.ROLL_OVER, onBackRollOver, false, 0, true); mc.back_btn.addEventListener(MouseEvent.ROLL_OUT, onBackRollOut, false, 0, true); mc.back_btn.addEventListener(MouseEvent.MOUSE_DOWN, onBackMouseDown, false, 0, true); mc.back_btn.addEventListener(MouseEvent.CLICK, onBackClick, false, 0, true); mc.back_btn.buttonMode = true; mc.back_btn.mouseChildren = false; mc.back_btn.over.visible = false; mc.back_btn.down.visible = false; mc.back_btn.hitArea = mc.back_btn.hit; mc.back_btn.hit.visible = false; mc.back_btn.over.addEventListener(Event.ENTER_FRAME, _onBackButtonOverEnterFrame); InfamousTextManager.getInstance().setText(mc.back_btn.up.label_txt, "help.back"); InfamousTextManager.getInstance().setText(mc.back_btn.down.label_txt, "help.back"); } private function onForumRollOut(_arg1:MouseEvent):void{ mc.forum_btn.up.visible = true; mc.forum_btn.over.visible = false; mc.forum_btn.down.visible = false; } private function splitPhrase(_arg1:String):String{ var _local2:Array = _arg1.split(" "); return (((_local2.shift() + "\n") + _local2.join(" "))); } private function onEnterFrame(_arg1:Event):void{ } private function onTooltipRollOver(_arg1:MouseEvent):void{ var _local2 = ""; var _local3:InfamousTextManager = InfamousTextManager.getInstance(); switch (_arg1.currentTarget){ case mc.action1: _local2 = _local3.getTextById("help.actions.desc.1"); break; case mc.action2: _local2 = _local3.getTextById("help.actions.desc.2"); break; case mc.action3: _local2 = _local3.getTextById("help.actions.desc.3"); break; case mc.action4: _local2 = _local3.getTextById("help.actions.desc.4"); break; case mc.power1: _local2 = _local3.getTextById("help.powers.desc.1"); break; case mc.power2: _local2 = _local3.getTextById("help.powers.desc.2"); break; case mc.power3: _local2 = _local3.getTextById("help.powers.desc.3"); break; case mc.power4: _local2 = _local3.getTextById("help.powers.desc.4"); break; }; tooltipBox.setText(_local2, TextBox.RULE_CLOSEST_ASPECT_RATIO); mc.tooltip.x = (_arg1.currentTarget.x + 30); mc.tooltip.y = (_arg1.currentTarget.y + 25); mc.tooltip.gotoAndPlay("show"); } private function onBackRollOver(_arg1:MouseEvent):void{ mc.back_btn.up.visible = false; mc.back_btn.over.visible = true; mc.back_btn.down.visible = false; } } }//package com.kerb.infamous.game.screens
Section 26
//LevelLose (com.kerb.infamous.game.screens.LevelLose) package com.kerb.infamous.game.screens { import flash.events.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import flash.geom.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class LevelLose extends AbstractScreen { private var tryAgainLabel:String; private var score:int; private var websiteButton:WebsiteButton; private var keyboardNavigator:KeyboardNavigator; private var ct:ColorTransform; private var submitLabel:String; private static const BAD_KARMA_COLOUR:uint = 13049374; private static const GOOD_KARMA_COLOUR:uint = 616959; public function LevelLose(_arg1:int){ this.score = _arg1; Main.smSFX.getSoundByClassName("BoomSound").play(); Main.smMusic.getSoundByClassName("OutGameMusicSound").play(0, 999999); } private function onTryAgainClick(_arg1:MouseEvent=null):void{ Main.smMusic.getSoundByClassName("OutGameMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_RETRY_LEVEL)); } private function onTryAgainRollOut(_arg1:MouseEvent):void{ mc.tryAgain_btn.up.visible = true; mc.tryAgain_btn.over.visible = false; mc.tryAgain_btn.down.visible = false; } private function onSubmitMouseDown(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = false; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = true; } override protected function init():void{ super.init(); mc = Main.assetFactory.createMovieClip("LevelLoseScreenAsset"); addChild(mc); websiteButton = new WebsiteButton(mc.website_btn); mc.tryAgain_btn.addEventListener(MouseEvent.CLICK, onTryAgainClick); initText(); initSubmitButton(); initTryAgainButton(); keyboardNavigator = new KeyboardNavigator(stage); keyboardNavigator.setDefaultAction(onTryAgainClick); keyboardNavigator.addInteractiveObject(mc.tryAgain_btn, onTryAgainClick, 1); keyboardNavigator.addInteractiveObject(mc.submit_btn, onSubmitClick, 2); if (!Game.pumaAllowed){ mc.puma.visible = false; mc.andWin.visible = false; mc.blueSplat.visible = false; mc.tandc.visible = false; mc.tandcBG.visible = false; mc.shoe.visible = false; }; if (!Constants.viral){ mc.tandc.visible = false; mc.tandcBG.visible = false; }; new GoodOrBadChoiceEndGame(mc); addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function initSubmitButton():void{ mc.submit_btn.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.submit_btn.addEventListener(MouseEvent.ROLL_OVER, onSubmitRollOver); mc.submit_btn.addEventListener(MouseEvent.ROLL_OUT, onSubmitRollOut); mc.submit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSubmitMouseDown); mc.submit_btn.buttonMode = true; mc.submit_btn.mouseChildren = false; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = false; mc.submit_btn.hitArea = mc.submit_btn.hit; mc.submit_btn.hit.visible = false; InfamousTextManager.getInstance().setText(mc.submit_btn.up.label_txt, "level.complete.submit"); InfamousTextManager.getInstance().setText(mc.submit_btn.down.label_txt, "level.complete.submit"); InfamousTextManager.getInstance().setText(mc.submit_btn.over.label.label_txt, "level.complete.submit"); mc.puma.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.puma.mouseChildren = false; mc.puma.buttonMode = true; mc.blueSplat.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.blueSplat.mouseChildren = false; mc.blueSplat.buttonMode = true; mc.andWin.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.andWin.mouseChildren = false; mc.andWin.buttonMode = true; mc.shoe.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.shoe.mouseChildren = false; mc.shoe.buttonMode = true; } private function initText():void{ var _local1:InfamousTextManager = InfamousTextManager.getInstance(); var _local2:String = _local1.getTextById("level.lose.title").toUpperCase(); var _local3:int = _local2.lastIndexOf(" "); _local1.setText(mc.missionFailed.label_txt); mc.missionFailed.label_txt.text = ((_local2.substring(0, _local3) + "\n") + _local2.substring((_local3 + 1))); _local1.setText(mc.scoreLabel.label_txt, "level.complete.total.score"); _local1.setText(mc.karmaLabel.label_txt, "level.complete.karma"); mc.tandc.btn.addEventListener(MouseEvent.CLICK, onTAndCLinkClick, false, 0, true); _local1.setText(mc.andWin.label_txt, "level.complete.title"); ct = new ColorTransform(); ct.color = ((score)<0) ? BAD_KARMA_COLOUR : GOOD_KARMA_COLOUR; mc.karma.alpha = 0; if (score < 0){ _local1.setText(mc.karma.label_txt, "level.complete.bad"); } else { _local1.setText(mc.karma.label_txt, "level.complete.good"); }; } private function onTryAgainMouseDown(_arg1:MouseEvent):void{ mc.tryAgain_btn.up.visible = false; mc.tryAgain_btn.over.visible = false; mc.tryAgain_btn.down.visible = true; } override public function dispose():void{ removeEventListener(Event.ENTER_FRAME, onEnterFrame); mc.tryAgain_btn.removeEventListener(MouseEvent.CLICK, onTryAgainClick); mc.submit_btn.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.submit_btn.removeEventListener(MouseEvent.ROLL_OVER, onSubmitRollOver); mc.submit_btn.removeEventListener(MouseEvent.ROLL_OUT, onSubmitRollOut); mc.submit_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onSubmitMouseDown); mc.tryAgain_btn.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.tryAgain_btn.removeEventListener(MouseEvent.ROLL_OVER, onSubmitRollOver); mc.tryAgain_btn.removeEventListener(MouseEvent.ROLL_OUT, onSubmitRollOut); mc.tryAgain_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onSubmitMouseDown); mc.puma.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.blueSplat.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.andWin.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.shoe.removeEventListener(MouseEvent.CLICK, onSubmitClick); super.dispose(); } private function initTryAgainButton():void{ mc.tryAgain_btn.addEventListener(MouseEvent.CLICK, onTryAgainClick); mc.tryAgain_btn.addEventListener(MouseEvent.ROLL_OVER, onTryAgainRollOver); mc.tryAgain_btn.addEventListener(MouseEvent.ROLL_OUT, onTryAgainRollOut); mc.tryAgain_btn.addEventListener(MouseEvent.MOUSE_DOWN, onTryAgainMouseDown); mc.tryAgain_btn.buttonMode = true; mc.tryAgain_btn.mouseChildren = false; mc.tryAgain_btn.over.visible = false; mc.tryAgain_btn.down.visible = false; mc.tryAgain_btn.hitArea = mc.tryAgain_btn.hit; mc.tryAgain_btn.hit.visible = false; InfamousTextManager.getInstance().setText(mc.tryAgain_btn.up.label_txt, "level.lose.return"); InfamousTextManager.getInstance().setText(mc.tryAgain_btn.down.label_txt, "level.lose.return"); InfamousTextManager.getInstance().setText(mc.tryAgain_btn.over.label.label_txt, "level.lose.return"); } private function onSubmitRollOver(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = false; mc.submit_btn.over.visible = true; mc.submit_btn.down.visible = false; } private function onSubmitClick(_arg1:MouseEvent=null):void{ SubmitScore.submit(score); } private function onTAndCLinkClick(_arg1:MouseEvent):void{ if (Constants.viral){ Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_VIRAL); } else { Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_SITE); }; } private function onTryAgainRollOver(_arg1:MouseEvent):void{ mc.tryAgain_btn.up.visible = false; mc.tryAgain_btn.over.visible = true; mc.tryAgain_btn.down.visible = false; } private function onSubmitRollOut(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = true; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = false; } private function onEnterFrame(_arg1:Event):void{ var _local3:int; var _local2:int = mc.currentFrame; if (_local2 == 75){ score = Math.abs(score); } else { if (_local2 == 134){ mc.score.transform.colorTransform = ct; }; }; if (_local2 == 175){ mc.score.label_txt.text = ("0000" + score).substr(-4); } else { if ((((_local2 >= 134)) && ((_local2 < 175)))){ _local3 = (Math.random() * 9999); mc.score.label_txt.text = ("0000" + _local3).substr(-4); }; }; if (_local2 >= 176){ mc.karma.alpha = 1; mc.karma.transform.colorTransform = ct; }; } } }//package com.kerb.infamous.game.screens
Section 27
//LevelWin (com.kerb.infamous.game.screens.LevelWin) package com.kerb.infamous.game.screens { import flash.events.*; import com.kerb.infamous.*; import com.kerb.infamous.game.*; import flash.geom.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class LevelWin extends AbstractScreen { private var nextLabel:String; private var websiteButton:WebsiteButton; private var levelScore:int; private var keyboardNavigator:KeyboardNavigator; private var ct:ColorTransform; private var totalScore:int; private var submitLabel:String; private static const BAD_KARMA_COLOUR:uint = 13049374; private static const GOOD_KARMA_COLOUR:uint = 616959; public function LevelWin(_arg1:int, _arg2:int){ this.levelScore = _arg1; this.totalScore = _arg2; Main.smSFX.getSoundByClassName("BoomSound").play(); Main.smMusic.getSoundByClassName("OutGameMusicSound").play(0, 999999); } private function onSubmitClick(_arg1:MouseEvent=null):void{ SubmitScore.submit(totalScore); } private function onNextRollOver(_arg1:MouseEvent):void{ mc.next_btn.up.visible = false; mc.next_btn.over.visible = true; mc.next_btn.down.visible = false; } private function initNextButton():void{ mc.next_btn.addEventListener(MouseEvent.CLICK, onNextClick, false, 0, true); mc.next_btn.addEventListener(MouseEvent.ROLL_OVER, onNextRollOver, false, 0, true); mc.next_btn.addEventListener(MouseEvent.ROLL_OUT, onNextRollOut, false, 0, true); mc.next_btn.addEventListener(MouseEvent.MOUSE_DOWN, onNextMouseDown, false, 0, true); mc.next_btn.buttonMode = true; mc.next_btn.mouseChildren = false; mc.next_btn.over.visible = false; mc.next_btn.down.visible = false; mc.next_btn.hitArea = mc.next_btn.hit; mc.next_btn.hit.visible = false; InfamousTextManager.getInstance().setText(mc.next_btn.up.label_txt, "level.complete.next"); InfamousTextManager.getInstance().setText(mc.next_btn.down.label_txt, "level.complete.next"); InfamousTextManager.getInstance().setText(mc.next_btn.over.label.label_txt, "level.complete.next"); } private function onSubmitMouseDown(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = false; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = true; } private function onNextMouseDown(_arg1:MouseEvent):void{ mc.next_btn.up.visible = false; mc.next_btn.over.visible = false; mc.next_btn.down.visible = true; } override protected function init():void{ super.init(); mc = Main.assetFactory.createMovieClip("LevelWinScreenAsset"); addChild(mc); websiteButton = new WebsiteButton(mc.website_btn); initText(); initSubmitButton(); initNextButton(); keyboardNavigator = new KeyboardNavigator(stage); keyboardNavigator.setDefaultAction(onNextClick); keyboardNavigator.addInteractiveObject(mc.next_btn, onNextClick, 1); keyboardNavigator.addInteractiveObject(mc.submit_btn, onSubmitClick, 2); if (!Game.pumaAllowed){ mc.puma.visible = false; mc.andWin.visible = false; mc.blueSplat.visible = false; mc.tandc.visible = false; mc.tandcBG.visible = false; mc.shoe.visible = false; }; if (!Constants.viral){ mc.tandc.visible = false; mc.tandcBG.visible = false; }; new GoodOrBadChoiceEndGame(mc); addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function initSubmitButton():void{ mc.submit_btn.addEventListener(MouseEvent.CLICK, onSubmitClick, false, 0, true); mc.submit_btn.addEventListener(MouseEvent.ROLL_OVER, onSubmitRollOver, false, 0, true); mc.submit_btn.addEventListener(MouseEvent.ROLL_OUT, onSubmitRollOut, false, 0, true); mc.submit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSubmitMouseDown, false, 0, true); mc.submit_btn.buttonMode = true; mc.submit_btn.mouseChildren = false; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = false; mc.submit_btn.hitArea = mc.submit_btn.hit; mc.submit_btn.hit.visible = false; InfamousTextManager.getInstance().setText(mc.submit_btn.up.label_txt, "level.complete.submit"); InfamousTextManager.getInstance().setText(mc.submit_btn.down.label_txt, "level.complete.submit"); InfamousTextManager.getInstance().setText(mc.submit_btn.over.label.label_txt, "level.complete.submit"); mc.puma.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.puma.mouseChildren = false; mc.puma.buttonMode = true; mc.blueSplat.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.blueSplat.mouseChildren = false; mc.blueSplat.buttonMode = true; mc.andWin.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.andWin.mouseChildren = false; mc.andWin.buttonMode = true; mc.shoe.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.shoe.mouseChildren = false; mc.shoe.buttonMode = true; } private function initText():void{ var _local1:InfamousTextManager = InfamousTextManager.getInstance(); var _local2:String = _local1.getTextById("level.win.title").toUpperCase(); var _local3:int = _local2.lastIndexOf(" "); _local1.setText(mc.levelComplete.label_txt); mc.levelComplete.label_txt.text = ((_local2.substring(0, _local3) + "\n") + _local2.substring((_local3 + 1))); mc.checkpoint.label_txt.autoSize = "left"; _local1.setText(mc.checkpoint.label_txt, "level.win.checkpoint"); mc.checkpoint.bg.width = (mc.checkpoint.label_txt.width + 16); _local1.setText(mc.levelScoreLabel.label_txt, "level.complete.you.scored"); _local1.setText(mc.totalScoreLabel.label_txt, "level.complete.total.score"); _local1.setText(mc.karmaLabel.label_txt, "level.complete.karma"); mc.tandc.btn.addEventListener(MouseEvent.CLICK, onTAndCLinkClick, false, 0, true); _local1.setText(mc.andWin.label_txt, "level.complete.title"); ct = new ColorTransform(); ct.color = ((totalScore)<0) ? BAD_KARMA_COLOUR : GOOD_KARMA_COLOUR; mc.karma.alpha = 0; if (totalScore < 0){ _local1.setText(mc.karma.label_txt, "level.complete.bad"); } else { _local1.setText(mc.karma.label_txt, "level.complete.good"); }; } override public function dispose():void{ removeEventListener(Event.ENTER_FRAME, onEnterFrame); mc.puma.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.blueSplat.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.andWin.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.shoe.removeEventListener(MouseEvent.CLICK, onSubmitClick); super.dispose(); } private function onSubmitRollOver(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = false; mc.submit_btn.over.visible = true; mc.submit_btn.down.visible = false; } private function onTAndCLinkClick(_arg1:MouseEvent):void{ if (Constants.viral){ Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_VIRAL); } else { Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_SITE); }; } private function onNextClick(_arg1:MouseEvent=null):void{ Main.smMusic.getSoundByClassName("OutGameMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_NEXT_LEVEL)); } private function onSubmitRollOut(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = true; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = false; } private function onEnterFrame(_arg1:Event):void{ var _local3:int; var _local2:int = mc.currentFrame; if (_local2 == 145){ levelScore = Math.abs(levelScore); }; if ((((_local2 >= 145)) && ((_local2 < 159)))){ _local3 = (Math.random() * 9999); mc.levelScore.label_txt.text = ("0000" + _local3).substr(-4); } else { if (_local2 == 159){ mc.levelScore.label_txt.text = ("0000" + levelScore).substr(-4); }; }; if (_local2 == 181){ totalScore = Math.abs(totalScore); }; if ((((_local2 >= 181)) && ((_local2 < 195)))){ _local3 = (Math.random() * 9999); mc.totalScore.label_txt.text = ("0000" + _local3).substr(-4); } else { if (_local2 >= 195){ mc.totalScore.label_txt.text = ("0000" + totalScore).substr(-4); }; }; if (_local2 >= 145){ mc.levelScore.transform.colorTransform = ct; }; if (_local2 >= 181){ mc.totalScore.transform.colorTransform = ct; }; if (_local2 >= 215){ mc.karma.alpha = 1; mc.karma.transform.colorTransform = ct; }; } private function onNextRollOut(_arg1:MouseEvent):void{ mc.next_btn.up.visible = true; mc.next_btn.over.visible = false; mc.next_btn.down.visible = false; } } }//package com.kerb.infamous.game.screens
Section 28
//EnergyTarget (com.kerb.infamous.game.targets.EnergyTarget) package com.kerb.infamous.game.targets { public class EnergyTarget extends Target { private var energy:Number;// = 0.01 public function EnergyTarget(_arg1:Number, _arg2:Number, _arg3:Number=50, _arg4:Number=80){ super(_arg1, _arg2, Target.TYPE_ENERGY, _arg3, _arg4, energy); hudAction = "energy"; } } }//package com.kerb.infamous.game.targets
Section 29
//GrabTarget (com.kerb.infamous.game.targets.GrabTarget) package com.kerb.infamous.game.targets { import com.kerb.infamous.game.*; public class GrabTarget extends Target { private var yMin:Number; private var xMin:Number; public var grabStartX:Number; public var grabStartY:Number; private var yMax:Number; private var xMax:Number; public var grabFinishX:Number; public var grabFinishY:Number; public var direction:int; private static const WIDTH:Number = 50; private static const HEIGHT:Number = 70; public static const X_HIT_TEST_OFFSET:Number = 20; public static const Y_HIT_TEST_OFFSET:Number = 20; public static const Y_START_OFFSET:Number = 45; public static const X_START_OFFSET:Number = 16; public static const X_FINISH_OFFSET:Number = -16; public static const Y_FINISH_OFFSET:Number = -36; public function GrabTarget(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int){ super(_arg1, _arg2, _arg3, WIDTH); this.direction = _arg4; if (_arg4 == Avatar.LEFT){ hx = (hx - X_HIT_TEST_OFFSET); hy = (hy + Y_HIT_TEST_OFFSET); grabStartX = (_arg1 - X_START_OFFSET); grabStartY = (_arg2 + Y_START_OFFSET); grabFinishX = (_arg1 - X_FINISH_OFFSET); grabFinishY = (_arg2 + Y_FINISH_OFFSET); } else { if (_arg4 == Avatar.RIGHT){ hx = (hx + X_HIT_TEST_OFFSET); hy = (hy + Y_HIT_TEST_OFFSET); grabStartX = (_arg1 + X_START_OFFSET); grabStartY = (_arg2 + Y_START_OFFSET); grabFinishX = (_arg1 + X_FINISH_OFFSET); grabFinishY = (_arg2 + Y_FINISH_OFFSET); }; }; xMin = (hx - (0.5 * WIDTH)); xMax = (xMin + WIDTH); yMin = (hy - (0.5 * HEIGHT)); yMax = (yMin + HEIGHT); } override public function hitTest(_arg1:Number, _arg2:Number):Boolean{ if (_arg1 > xMin){ if (_arg1 < xMax){ if (_arg2 > yMin){ if (_arg2 < yMax){ return (true); }; }; }; }; return (false); } } }//package com.kerb.infamous.game.targets
Section 30
//LockTarget (com.kerb.infamous.game.targets.LockTarget) package com.kerb.infamous.game.targets { import com.kerb.infamous.game.dynamicBodies.*; public class LockTarget extends Target { private var cellDoors:Array; private var actionFunctions:Array; private var cellLocks:Array; public function LockTarget(_arg1:Number, _arg2:Number){ super(_arg1, _arg2, Target.TYPE_LOCK, DEFAULT_WIDTH, DEFAULT_HEIGHT, 1); actionFunctions = new Array(); cellLocks = new Array(); cellDoors = new Array(); hudAction = "unlock"; } public function performActions():void{ var _local1:int; _local1 = 0; while (_local1 < actionFunctions.length) { var _local2 = actionFunctions; _local2[_local1](); _local1++; }; } public function addAction(_arg1:Function):void{ actionFunctions.push(_arg1); } public function checkCells():Array{ var _local1:int = cellLocks.length; var _local2:Boolean; while (--_local1 > -1) { if (!cellDoors[_local1].isOpen){ cellDoors[_local1].explode(); _local2 = false; }; }; return ((_local2) ? null : cellLocks); } public function addCell(_arg1:CellDoor, _arg2:LockTarget):void{ cellDoors.push(_arg1); cellLocks.push(_arg2); } } }//package com.kerb.infamous.game.targets
Section 31
//SickPedTarget (com.kerb.infamous.game.targets.SickPedTarget) package com.kerb.infamous.game.targets { import com.kerb.infamous.game.dynamicBodies.*; import de.polygonal.ds.*; import com.kerb.infamous.game.levels.*; public class SickPedTarget extends Target { public var node:SListNode; public var list:SLinkedList; private var healthToGainPerFrame:Number;// = 0.004 private var ped:Ped; private var baseLevel:BaseLevel; public function SickPedTarget(_arg1:Ped, _arg2:BaseLevel){ super(_arg1.x, _arg1.y, Target.TYPE_SICK_PED, 80, DEFAULT_HEIGHT); this.ped = _arg1; this.baseLevel = _arg2; _arg1.sickPedTarget = this; hudAction = "heal"; } public function heal():Boolean{ var _local1:SListIterator; ped.addToLife(healthToGainPerFrame, false); baseLevel.applyKarma(Ped.KARMA_PER_FRAME_HEAL); if (ped.life == 1){ ped.healed(); _local1 = new SListIterator(list, node); list.remove(_local1); return (true); }; return (false); } public function setCallbacks(_arg1:SLinkedList, _arg2:SListNode):void{ this.list = _arg1; this.node = _arg2; } } }//package com.kerb.infamous.game.targets
Section 32
//Target (com.kerb.infamous.game.targets.Target) package com.kerb.infamous.game.targets { import flash.display.*; public class Target { public var y:Number; private var xMin:Number; private var xMax:Number; public var hudAction:String; protected var hx:Number; protected var hy:Number; private var yMin:Number; private var yMax:Number; public var value:Number; public var x:Number; public var type:int; public static const TYPE_SWING_UP:int = 5; public static const TYPE_EXIT:int = 7; protected static const DEFAULT_HEIGHT:Number = 80; public static const TYPE_DANGER:int = 6; protected static const DEFAULT_VALUE:Number = 1; public static const TYPE_ENERGY:int = 1; protected static const DEFAULT_WIDTH:Number = 50; public static const TYPE_LOCK:int = 3; public static const TYPE_SICK_PED:int = 2; public static const TYPE_PULL_UP:int = 4; public function Target(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Number=50, _arg5:Number=80, _arg6:Number=1){ this.x = _arg1; this.y = _arg2; this.type = _arg3; this.value = _arg6; xMin = (_arg1 - (0.5 * _arg4)); xMax = (_arg1 + (0.5 * _arg4)); yMin = (_arg2 - (0.5 * _arg5)); yMax = (_arg2 + (0.5 * _arg5)); hx = _arg1; hy = _arg2; } public function hitTest(_arg1:Number, _arg2:Number):Boolean{ if (_arg1 > xMin){ if (_arg1 < xMax){ if (_arg2 > yMin){ if (_arg2 < yMax){ return (true); }; }; }; }; return (false); } public function getYMin():Number{ return (yMin); } public function setYMin(_arg1:Number):void{ this.yMin = _arg1; } public function getYMax():Number{ return (yMax); } public function toString():String{ return (((yMin + ", ") + yMax)); } public function setYMax(_arg1:Number):void{ this.yMax = _arg1; } public function debugDraw(_arg1:Graphics, _arg2:uint):void{ _arg1.beginFill(_arg2, 0.3); _arg1.moveTo(xMin, yMin); _arg1.lineTo(xMax, yMin); _arg1.lineTo(xMax, yMax); _arg1.lineTo(xMin, yMax); _arg1.lineTo(xMin, yMin); _arg1.endFill(); } } }//package com.kerb.infamous.game.targets
Section 33
//Grenade (com.kerb.infamous.game.weapons.Grenade) package com.kerb.infamous.game.weapons { import flash.display.*; import com.kerb.infamous.game.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.collision.shapes.data.*; import de.polygonal.motor2.dynamics.contact.*; import flash.filters.*; public class Grenade { private var yForce:Number; private var impulseX:Number; private var impulseY:Number; private var hit:Boolean; private var explosion:MovieClip; private var body:RigidBody; private var blur:BlurFilter; private var projectile:MovieClip; private var rbd:RigidBodyData; public var x:Number; public var y:Number; public static const ROCKET_Y_FORCE:Number = -2600; public static const ROCKET_IMPULSE_X:Number = 5000; public static const BLAST_FORCE:Number = 100000; private static const RADIUS:Number = 4; public static const ROCKET_IMPULSE_Y:Number = 0; private static const RAD_2_DEG:Number = 57.2957795130823; private static const DENSITY:Number = 1; public static const BLAST_RADIUS:Number = 100; public static const GRENADE_IMPULSE_X:Number = 1600; public static const GRENADE_IMPULSE_Y:Number = -3200; public function Grenade(_arg1:MovieClip, _arg2:MovieClip){ var _local3:CircleData; super(); this.projectile = _arg1; _arg1.visible = false; _arg1.gotoAndStop(1); this.explosion = _arg2; _arg2.visible = false; _arg2.gotoAndStop(1); _local3 = new CircleData(DENSITY, RADIUS); rbd = new RigidBodyData(0, 0); rbd.addShapeData(_local3); blur = new BlurFilter(20, 0); } public function update():Boolean{ var _local1:Manifold; var _local2:Number; if (hit){ if (explosion.currentFrame == explosion.totalFrames){ explosion.visible = false; explosion.gotoAndStop(1); }; } else { body.applyForce(0, yForce); x = (projectile.x = body.x); y = (projectile.y = body.y); if (body.contactList){ _local1 = body.contactList.contact.manifolds[0]; _local2 = (RAD_2_DEG * Math.atan2(_local1.nx, -(_local1.ny))); explosion.rotation = _local2; hit = true; explode(); return (true); }; }; return (false); } public function init(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Physics, _arg5:Boolean):RigidBody{ var _local6:Number; var _local7:Number; if (_arg5){ yForce = ROCKET_Y_FORCE; projectile.scaleX = 10; projectile.filters = [blur]; _local6 = ROCKET_IMPULSE_X; _local7 = ROCKET_IMPULSE_Y; } else { yForce = 0; projectile.scaleX = 1; projectile.filters = []; _local6 = GRENADE_IMPULSE_X; _local7 = GRENADE_IMPULSE_Y; }; this.yForce = yForce; hit = false; projectile.visible = true; projectile.play(); rbd.x = _arg1; rbd.y = _arg2; body = _arg4.createRigidBody(rbd); if (_arg3 == Avatar.LEFT){ body.applyImpulse(-(_local6), _local7); } else { body.applyImpulse(_local6, _local7); }; return (body); } private function explode():void{ explosion.x = x; explosion.y = y; explosion.visible = true; explosion.play(); projectile.visible = false; projectile.gotoAndStop(1); } public function destroy(_arg1:Physics):void{ _arg1.destroyRigidBody(body); } } }//package com.kerb.infamous.game.weapons
Section 34
//Lightning (com.kerb.infamous.game.weapons.Lightning) package com.kerb.infamous.game.weapons { import flash.display.*; import com.kerb.infamous.game.*; import com.kerb.infamous.game.dynamicBodies.*; import de.polygonal.motor2.dynamics.*; import flash.filters.*; public class Lightning { public var sprite:Sprite; private var durationCounter:int; public var active:Boolean; private var detail:Number;// = 0.95 private var colour:uint;// = 0xFFFFFF private var displacement:Number;// = 40 private var numBolts:Number;// = 2 private var x1:Number; private var lineThickness:Number;// = 3 public var currTarget:Character; private var glowColour:uint;// = 16777164 private var glowSpread:Number;// = 8 private var glowAlpha:Number;// = 0.8 private var glowStrength:Number;// = 2 private var x0:Number; private var y:Number; private var x2:Number; private var direction:int; private static const MAX_LENGTH:Number = 230; private static const RIGHT_OFFSET:Number = 16; private static const LEFT_OFFSET:Number = -30; private static const DURATION:int = 10; private static const Y_RENDER_OFFSET:Number = -10; private static const GROWTH_RATE:Number = 0.3; private static const Y_OFFSET:Number = 0; private static const DAMAGE_PER_FRAME:Number = 0.1; public function Lightning(){ active = false; sprite = new Sprite(); } public function update(_arg1:Physics, _arg2:Avatar):int{ var _local4:RigidBody; var _local8:Number; var _local9:Number; var _local3:RaycastResult = _arg1.linearRaycast(x0, y, x1, y, _arg2.shape); var _local5:Character = currTarget; var _local6:int; currTarget = null; if (direction == 1){ x0 = (x0 + 20); if (x0 > x1){ x0 = x1; }; } else { x0 = (x0 - 20); if (x0 < x1){ x0 = x1; }; }; x1 = (x1 + (0.2 * (x2 - x1))); if (_local3){ _local4 = _local3.body; if (_local4){ x2 = ((1.05 * (_local3.x - x0)) + x0); if (direction == 1){ if (x1 > x2){ x1 = x2; }; } else { if (x1 < x2){ x1 = x2; }; }; if (_local4.userData.id == "ped"){ currTarget = _local4.userData.owner; if (currTarget.life > 0){ if (currTarget != _local5){ currTarget.initLightning(); }; currTarget.hitLightning(DAMAGE_PER_FRAME); _local6 = 1; }; } else { if (_local4.userData.id == "reaper"){ currTarget = _local4.userData.owner; if (currTarget.life > 0){ if (currTarget != _local5){ currTarget.initLightning(); }; currTarget.hitLightning(DAMAGE_PER_FRAME); _local6 = 2; }; }; }; }; }; if (((_local5) && (!((_local5 == currTarget))))){ _local5.finishLightning(); }; var _local7:Number = numBolts; sprite.graphics.clear(); while (--_local7 > -1) { sprite.graphics.lineStyle(lineThickness, colour, glowAlpha); _local8 = ((20 * Math.random()) - 10); _local9 = ((10 * Math.random()) - 5); drawBolt(x0, (y + Y_RENDER_OFFSET), (x1 + _local8), ((y + Y_RENDER_OFFSET) + _local9), displacement); }; if (--durationCounter == 0){ finish(); }; return (_local6); } public function finish():void{ if (currTarget){ currTarget.finishLightning(); }; active = false; currTarget = null; sprite.graphics.clear(); } public function init(_arg1:Number, _arg2:Number, _arg3:int):void{ this.y = (_arg2 + Y_OFFSET); if (_arg3 == Avatar.LEFT){ x0 = (_arg1 + LEFT_OFFSET); x1 = (x0 - (0.5 * MAX_LENGTH)); x2 = (x0 - MAX_LENGTH); this.direction = -1; } else { x0 = (_arg1 + RIGHT_OFFSET); x1 = (x0 + (0.5 * MAX_LENGTH)); x2 = (x0 + MAX_LENGTH); this.direction = 1; }; var _local4:GlowFilter = new GlowFilter(glowColour, glowAlpha, glowSpread, glowSpread, glowStrength); sprite.filters = [_local4]; durationCounter = DURATION; active = true; } public function get duration():int{ return (durationCounter); } private function drawBolt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{ var _local6:Number; var _local7:Number; var _local8:Graphics = sprite.graphics; if (_arg5 < detail){ _local8.moveTo(_arg1, _arg2); _local8.lineTo(_arg3, _arg4); } else { _local6 = (0.5 * (_arg1 + _arg3)); _local7 = (0.5 * (_arg2 + _arg4)); _local6 = (_local6 + ((Math.random() - 0.5) * _arg5)); _local7 = (_local7 + ((Math.random() - 0.5) * _arg5)); _arg5 = (_arg5 * 0.5); drawBolt(_arg1, _arg2, _local6, _local7, _arg5); drawBolt(_arg3, _arg4, _local6, _local7, _arg5); }; } } }//package com.kerb.infamous.game.weapons
Section 35
//TKBlast (com.kerb.infamous.game.weapons.TKBlast) package com.kerb.infamous.game.weapons { public class TKBlast { public static const RADIUS:Number = 300; public static const ANGLE:Number = 0.17; public static const FORCE:Number = 200000; } }//package com.kerb.infamous.game.weapons
Section 36
//Avatar (com.kerb.infamous.game.Avatar) package com.kerb.infamous.game { import flash.events.*; import flash.display.*; import com.kerb.infamous.*; import com.kerb.infamous.game.targets.*; import com.kerb.infamous.game.render.*; import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import com.kerb.infamous.game.levels.*; import de.polygonal.motor2.collision.shapes.data.*; public class Avatar extends EventDispatcher { public var keyBits:int; public var standTarget:Target; public var landingVelocity:Number; private var animationFinished:Boolean; public var weapon:String; public var hovering:Boolean; private var lockEvent:Event; private var grabFinishX:Number; private var grabFinishY:Number; public var updateStateFunction:Function; private var hoverCount:int; private var onGround:Boolean; private var physics:Physics; public var standing:Boolean; public var karma:Number; private var animations:Array; public var direction:int; private var animation:MovieClip; public var energy:Number; private var fallingVelocity:Number;// = 0 private var runSpeed:Number; private var mc:MovieClip; private var body:RigidBody; private var grabStartY:Number; private var grabStartX:Number; private var renderOffsetX:Number; private var renderOffsetY:Number; private var hoverEvent:Event; private var numConsecutiveStands:int; private var electrocuted:Boolean; private var weaponEvent:Event; public var jumping:Boolean; public var life:Number; public var grabTarget:GrabTarget; public static const EVENT_LOCK_ACTIVATED:String = "onLock"; private static const CROUCH_STOPPING_RATE:Number = 0; public static const LEFT:int = 1; public static const WATER_LIFE_LOST_PER_FRAME:Number = 0.02; private static const ENERGY_LOSS_HEAL:Number = 0.002; public static const EVENT_WEAPON_FIRED:String = "onWeaponFired"; public static const EVENT_HOVER_LAND:String = "onHoverLand"; private static const ENERGY_LOSS_HOVER:Number = 0.002; private static const TARGET_EASING:Number = 0.65; public static const X_PRESSED:int = 128; private static const ENERGY_LOSS_LIGHTNING:Number = 0.001; private static const SPEED:Number = 100000; public static const SPACE_PRESSED:int = 64; public static const UP:int = 4; private static const BODY_DENSITY:Number = 1.2; private static const HARD_LANDING_THRESHOLD:Number = 80; public static const DOWN:int = 8; private static const ENERGY_LOSS_ROCKET:Number = 0.1; private static const ITCHY_ARSE_THRESHOLD:int = 9; private static const STOPPING_RATE:Number = 0; private static const ENERGY_LOSS_TK_BLAST:Number = 0.1; private static const JUMP_IMPULSE:Number = -110000; private static const HOVER_DURATION:int = 50; public static const X:int = 32; public static const UP_PRESSED:int = 0x0100; public static const SPACE:int = 16; private static const HOVER_FORCE:Number = -89000; private static const ENERGY_LOSS_GRENADE:Number = 0.1; public static const DOWN_PRESSED:int = 0x0200; private static const CROUCHING_WIDTH:Number = 20; private static const STANDING_WIDTH:Number = 20; private static const BODY_FRICTION:Number = 0.3; private static const STANDING_HEIGHT:Number = 70; public static const RIGHT:int = 2; private static const CROUCHING_HEIGHT:Number = 44; private static const MAX_VELOCITY:Number = 70; public static var LIFE_GAINED_PER_FRAME:Number = 0.0003; public function Avatar(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Physics, _arg5:Renderer){ init(_arg1, _arg2, _arg3, _arg4, _arg5); } private function updateCrouchTurn():void{ body.vx = (body.vx * CROUCH_STOPPING_RATE); if (animationFinished){ if (direction == LEFT){ direction = RIGHT; runSpeed = SPEED; mc.scaleX = 1; } else { direction = LEFT; runSpeed = -(SPEED); mc.scaleX = -1; }; setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); animation.gotoAndStop(5); } else { if ((keyBits & SPACE)){ if (direction == LEFT){ direction = RIGHT; runSpeed = SPEED; mc.scaleX = 1; } else { direction = LEFT; runSpeed = -(SPEED); mc.scaleX = -1; }; switchToStandingBody(x, y); standing = true; fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ if (direction == LEFT){ direction = RIGHT; runSpeed = SPEED; mc.scaleX = 1; } else { direction = LEFT; runSpeed = -(SPEED); mc.scaleX = -1; }; switchToStandingBody(x, y); standing = true; respondToStandTarget(); }; }; }; } private function updateLightning():void{ var _local1:int = animation.currentFrame; body.vx = (body.vx * STOPPING_RATE); deductEnergy(ENERGY_LOSS_LIGHTNING); if (_local1 == 6){ dispatchEvent(weaponEvent); }; if (_local1 >= 6){ if (((jumping) && (onGround))){ updateJump(); }; if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); standing = false; jumping = true; } else { if (((!((((keyBits & LEFT)) && ((keyBits & RIGHT))))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ if ((keyBits & direction)){ standing = false; setState("runStart", updateRunStart); } else { standing = false; setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; } else { if ((keyBits & DOWN)){ standing = false; switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); }; }; }; }; } private function updateRun():void{ var _local1:int; if (!onGround){ setState("jump", updateJump); jumping = true; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); jumping = true; } else { if ((keyBits & DOWN)){ switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); } else { if ((((keyBits & LEFT)) && ((keyBits & RIGHT)))){ setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); } else { if ((direction & keyBits)){ body.applyForce(runSpeed, 0); _local1 = animation.currentFrame; if (_local1 == 15){ Main.smSFX.getSoundByClassName("LeftLegSound").play(); } else { if (_local1 == 8){ Main.smSFX.getSoundByClassName("RightLegSound").play(); }; }; } else { setState("runFinish", updateRunFinish); modifyRunFinish(); }; }; }; }; }; }; }; } private function updateRocket():void{ var _local1:int = animation.currentFrame; if (_local1 == 1){ deductEnergy(ENERGY_LOSS_GRENADE); dispatchEvent(weaponEvent); } else { if (animationFinished){ setState("stand", updateStand); standing = true; } else { if (((jumping) && (onGround))){ updateJump(); }; }; }; if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); standing = false; jumping = true; } else { if (((!((((keyBits & LEFT)) && ((keyBits & RIGHT))))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ if ((keyBits & direction)){ standing = false; setState("runStart", updateRunStart); } else { standing = false; setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; } else { if ((keyBits & DOWN)){ standing = false; switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); }; }; }; } private function respondToStandTarget():void{ switch (standTarget.type){ case Target.TYPE_ENERGY: if (energy < 1){ setState("charge", updateCharge); }; Main.smSFX.getSoundByClassName("ChargingSound").play(); break; case Target.TYPE_LOCK: setState("unlock", updateUnlock); break; case Target.TYPE_SICK_PED: setState("heal", updateHeal); Main.smSFX.getSoundByClassName("HealingSound").play(0, 999999); break; }; } private function respondToGrabTarget():void{ if (grabTarget.type == Target.TYPE_PULL_UP){ setState("pullUp", updateGrab); } else { if (grabTarget.type == Target.TYPE_SWING_UP){ setState("swingUp", updateGrab); }; }; playRandomSound(); } private function init(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Physics, _arg5:Renderer):void{ var _local7:MovieClip; this.physics = _arg4; mc = Main.assetFactory.createMovieClip("AvatarAsset"); animations = new Array(); var _local6:int = mc.numChildren; while (--_local6 > -1) { _local7 = (mc.getChildAt(_local6) as MovieClip); animations[_local7.name] = _local7; if (_local7.name != "stand"){ mc.removeChild(_local7); }; }; animation = mc["stand"]; switchToStandingBody(_arg1, _arg2); energy = _arg3; life = 1; karma = 0; numConsecutiveStands = 0; hoverCount = 0; direction = RIGHT; runSpeed = SPEED; weapon = BaseLevel.WEAPONS[0]; updateStateFunction = updateStand; keyBits = 0; renderOffsetX = 0; renderOffsetY = 0; standTarget = null; grabTarget = null; standing = true; jumping = false; hovering = false; electrocuted = false; weaponEvent = new Event(EVENT_WEAPON_FIRED); hoverEvent = new Event(EVENT_HOVER_LAND); lockEvent = new Event(EVENT_LOCK_ACTIVATED); _arg5.addAvatar(mc); } private function switchToCrouchingBody(_arg1:Number, _arg2:Number):void{ if (body){ body.world.destroyBody(body); }; _arg2 = (_arg2 + (0.5 * (STANDING_HEIGHT - CROUCHING_HEIGHT))); initRigidBody(_arg1, _arg2, CROUCHING_WIDTH, CROUCHING_HEIGHT); } private function updateJumpLand():void{ body.vx = (body.vx * STOPPING_RATE); if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { if (animationFinished){ setState("stand", updateStand); standing = true; }; }; }; } private function updateCrouchDown():void{ body.vx = (body.vx * CROUCH_STOPPING_RATE); if ((keyBits & SPACE)){ switchToStandingBody(x, y); standing = true; fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ switchToStandingBody(x, y); standing = true; respondToStandTarget(); } else { if (!(keyBits & DOWN)){ setState("crouchUp", updateCrouchUp); Main.smSFX.getSoundByClassName("CrouchUpSound").play(); } else { if (((!((keyBits & direction))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ setState("crouchTurn", updateCrouchTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; }; }; }; } public function deductEnergy(_arg1:Number):void{ energy = (energy - _arg1); if (energy < 0){ energy = 0; }; } private function updateRunFinish():void{ body.vx = (body.vx * STOPPING_RATE); if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); jumping = true; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { if (((!((((keyBits & LEFT)) && ((keyBits & RIGHT))))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ if ((keyBits & direction)){ setState("runStart", updateRunStart); } else { setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; } else { if ((keyBits & DOWN)){ switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); } else { if (animationFinished){ setState("stand", updateStand); standing = true; }; }; }; }; }; }; } public function moveTo(_arg1:Number, _arg2:Number):void{ body.x = _arg1; body.y = _arg2; mc.x = _arg1; mc.y = _arg2; } public function addLife(_arg1:Number):void{ if (life > 0){ life = (life + _arg1); if (life > 1){ life = 1; }; }; } private function playRandomSound():void{ var _local1:int = (Math.random() * 18); Main.smSFX.getSoundByClassName((("Cole" + _local1) + "Sound")).play(); } private function updateGrenade():void{ var _local1:int = animation.currentFrame; if (_local1 == 8){ deductEnergy(ENERGY_LOSS_GRENADE); dispatchEvent(weaponEvent); } else { if (animationFinished){ setState("stand", updateStand); standing = true; }; }; if (_local1 >= 8){ if (((jumping) && (onGround))){ updateJump(); }; if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); standing = false; jumping = true; } else { if (((!((((keyBits & LEFT)) && ((keyBits & RIGHT))))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ if ((keyBits & direction)){ standing = false; setState("runStart", updateRunStart); } else { standing = false; setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; } else { if ((keyBits & DOWN)){ standing = false; switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); }; }; }; }; } public function hide():void{ mc.visible = false; } private function setState(_arg1:String, _arg2:Function):void{ if (_arg1 == "stand"){ jumping = false; }; mc.removeChild(animation); animation = animations[_arg1]; mc.addChild(animation); animation.gotoAndPlay(1); updateStateFunction = _arg2; } private function updateHeal():void{ if ((keyBits & X)){ deductEnergy(ENERGY_LOSS_HEAL); if ((((standTarget as SickPedTarget).heal()) || ((energy == 0)))){ setState("healFinish", updateHealFinish); Main.smSFX.getSoundByClassName("HealingSound").stop(); }; } else { setState("healFinish", updateHealFinish); Main.smSFX.getSoundByClassName("HealingSound").stop(); }; if (direction == LEFT){ body.x = (body.x + (TARGET_EASING * ((standTarget.x - body.x) + 20))); } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { body.x = (body.x + (TARGET_EASING * ((standTarget.x - body.x) - 20))); }; }; }; } private function updateHealFinish():void{ if (animationFinished){ playRandomSound(); setState("stand", updateStand); standing = true; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; }; } public function deductLife(_arg1:Number):Boolean{ if (life > 0){ playRandomSound(); life = (life - _arg1); if ((((life <= 0)) && (!(electrocuted)))){ playRandomSound(); setState("die", updateDie); return (true); }; }; return (false); } private function modifyRunFinish():void{ var _local1:Number = body.vx; var _local2:int = animation.totalFrames; if (_local1 < 0){ _local1 = -(_local1); }; _local1 = (_local1 * (_local2 / 200)); var _local3:int = (_local2 - _local1); if (_local3 < 1){ _local3 = 1; }; animation.gotoAndPlay(_local3); } protected function initRigidBody(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{ var _local5:BoxData = new BoxData(BODY_DENSITY, _arg3, _arg4); _local5.friction = BODY_FRICTION; _local5.clrMaskBit(1); var _local6:RigidBodyData = new RigidBodyData(_arg1, _arg2); _local6.preventRotation = true; _local6.addShapeData(_local5); body = physics.defineAvatar(_local6, (0.5 * _arg4)); mc.x = _arg1; mc.y = _arg2; } private function updateUnlock():void{ if (animation.currentFrame == 9){ Main.smSFX.getSoundByClassName("LockSound").play(); }; if (((animationFinished) || (!(standTarget)))){ dispatchEvent(lockEvent); if (standTarget){ standTarget.value = 0; }; setState("stand", updateStand); standing = true; }; if (direction == LEFT){ body.x = (body.x + (TARGET_EASING * ((standTarget.x - body.x) + 15))); } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { body.x = (body.x + (TARGET_EASING * ((standTarget.x - body.x) - 15))); }; }; }; } public function electrocute():void{ if (!electrocuted){ electrocuted = true; setState("electrocute", updateDie); Main.smSFX.getSoundByClassName("ElectrocutedSound").play(); }; } public function finishLightning():void{ if (updateStateFunction == updateLightning){ setState("stand", updateStand); standing = true; }; } public function get x():Number{ return (body.x); } public function get y():Number{ return (body.y); } private function switchToStandingBody(_arg1:Number, _arg2:Number):void{ if (body){ body.world.destroyBody(body); }; _arg2 = (_arg2 - (0.5 * (STANDING_HEIGHT - CROUCHING_HEIGHT))); initRigidBody(_arg1, _arg2, STANDING_WIDTH, STANDING_HEIGHT); } private function updateHoverLand():void{ body.vx = (body.vx * STOPPING_RATE); if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { if (animationFinished){ setState("stand", updateStand); standing = true; }; }; }; } public function get renderY():Number{ return ((y + renderOffsetY)); } private function updateRunStart():void{ var _local1:int; if (!onGround){ setState("jump", updateJump); jumping = true; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); jumping = true; } else { if ((keyBits & DOWN)){ switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); } else { if ((((keyBits & LEFT)) && ((keyBits & RIGHT)))){ setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); } else { if ((direction & keyBits)){ body.applyForce(runSpeed, 0); _local1 = animation.currentFrame; if ((((_local1 == 25)) || ((_local1 == 49)))){ Main.smSFX.getSoundByClassName("LeftLegSound").play(); } else { if ((((_local1 == 13)) || ((_local1 == 37)))){ Main.smSFX.getSoundByClassName("RightLegSound").play(); }; }; } else { setState("runFinish", updateRunFinish); modifyRunFinish(); }; }; }; }; }; }; }; if (animationFinished){ setState("run", updateRun); }; } public function get renderX():Number{ return ((x + renderOffsetX)); } private function updateStand():void{ if (!onGround){ setState("jump", updateJump); jumping = true; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; }; if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); standing = false; jumping = true; } else { if (((!((((keyBits & LEFT)) && ((keyBits & RIGHT))))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ if ((keyBits & direction)){ standing = false; setState("runStart", updateRunStart); } else { standing = false; setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; } else { if ((keyBits & DOWN)){ standing = false; switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); }; }; }; } public function addEnergy(_arg1:Number):void{ energy = (energy + _arg1); if (energy > 1){ energy = 1; }; } private function updateJump():void{ if (onGround){ if (fallingVelocity < HARD_LANDING_THRESHOLD){ setState("jumpLand", updateJumpLand); Main.smSFX.getSoundByClassName("JumpLandSound").play(); } else { setState("hoverLand", updateHoverLand); landingVelocity = fallingVelocity; dispatchEvent(hoverEvent); Main.smSFX.getSoundByClassName("JumpLandSound").play(); Main.smSFX.getSoundByClassName("FloatLandSound").play(); }; playRandomSound(); fallingVelocity = 0; grabTarget = null; jumping = false; } else { if (((grabTarget) && (!((grabTarget.direction == direction))))){ jumping = false; initGrab(grabTarget); respondToGrabTarget(); } else { if ((((((keyBits & UP_PRESSED)) && ((energy > 0)))) && (!(hovering)))){ setState("hover", updateHover); Main.smSFX.getSoundByClassName("FloatJumpSound").play(); hovering = true; jumping = false; grabTarget = null; body.vy = 0; } else { if ((((keyBits & LEFT)) && ((keyBits & RIGHT)))){ setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); } else { if ((direction & keyBits)){ body.applyForce(runSpeed, 0); } else { if ((keyBits & SPACE)){ fireWeapon(); }; }; }; }; }; if (body.vy > fallingVelocity){ fallingVelocity = body.vy; }; }; } private function initGrab(_arg1:GrabTarget):void{ grabStartX = _arg1.grabStartX; grabStartY = _arg1.grabStartY; grabFinishX = _arg1.grabFinishX; grabFinishY = _arg1.grabFinishY; } public function get shape():ShapeSkeleton{ return (body.shapeList); } private function updateArseScratch():void{ if (!onGround){ setState("jump", updateJump); jumping = true; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; }; if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); standing = false; jumping = true; } else { if (((!((((keyBits & LEFT)) && ((keyBits & RIGHT))))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ if ((keyBits & direction)){ standing = false; setState("runStart", updateRunStart); } else { standing = false; setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; } else { if ((keyBits & DOWN)){ standing = false; switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); } else { if (animationFinished){ numConsecutiveStands = 0; setState("stand", updateStand); standing = true; }; }; }; }; } private function updateRunToSwitch():void{ } private function updateGrab():void{ var _local1:Number; if (animationFinished){ body.x = grabFinishX; body.y = grabFinishY; setState("stand", updateStand); standing = true; mc.x = body.x; mc.y = body.y; renderOffsetX = 0; renderOffsetY = 0; } else { _local1 = (animation.currentFrame / animation.totalFrames); renderOffsetX = ((grabFinishX - grabStartX) * _local1); renderOffsetY = ((grabFinishY - grabStartY) * _local1); mc.x = (mc.x + (0.2 * (grabStartX - mc.x))); if (mc.y < grabStartY){ mc.y = (mc.y + (0.5 * (grabStartY - mc.y))); } else { mc.y = (mc.y + (0.2 * (grabStartY - mc.y))); }; body.vx = 0; body.vy = 0; body.x = grabStartX; body.y = (grabStartY + renderOffsetY); renderOffsetX = (renderOffsetX - (body.x - grabStartX)); renderOffsetY = (renderOffsetY - (body.y - grabStartY)); }; } public function update(_arg1:Boolean):void{ this.onGround = _arg1; if (updateStateFunction != updateGrab){ mc.x = body.x; mc.y = body.y; }; animationFinished = (animation.currentFrame == animation.totalFrames); updateStateFunction(); if (body.vx > MAX_VELOCITY){ body.vx = MAX_VELOCITY; } else { if (body.vx < -(MAX_VELOCITY)){ body.vx = -(MAX_VELOCITY); }; }; } private function updateChargeFinish():void{ if (animationFinished){ playRandomSound(); setState("stand", updateStand); standing = true; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; }; } private function updateTKBlast():void{ var _local1:int = animation.currentFrame; if (_local1 == 10){ deductEnergy(ENERGY_LOSS_TK_BLAST); dispatchEvent(weaponEvent); } else { if (animationFinished){ setState("stand", updateStand); standing = true; }; }; if (_local1 >= 10){ if (((jumping) && (onGround))){ updateJump(); }; if ((keyBits & SPACE_PRESSED)){ fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; if ((((keyBits & UP)) && (!(jumping)))){ if ((((keyBits & LEFT)) && ((direction == RIGHT)))){ mc.scaleX = -1; direction = LEFT; runSpeed = -(SPEED); } else { if ((((keyBits & RIGHT)) && ((direction == LEFT)))){ mc.scaleX = 1; direction = RIGHT; runSpeed = SPEED; }; }; setState("jump", updateJump); body.applyImpulse(0, JUMP_IMPULSE); standing = false; jumping = true; } else { if (((!((((keyBits & LEFT)) && ((keyBits & RIGHT))))) && ((((keyBits & LEFT)) || ((keyBits & RIGHT)))))){ if ((keyBits & direction)){ standing = false; setState("runStart", updateRunStart); } else { standing = false; setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; } else { if ((keyBits & DOWN)){ standing = false; switchToCrouchingBody(x, y); setState("crouchDown", updateCrouchDown); Main.smSFX.getSoundByClassName("CrouchDownSound").play(); }; }; }; }; } public function updateCharge():void{ if ((keyBits & X)){ addEnergy(standTarget.value); addLife(standTarget.value); if ((((energy == 1)) && ((life == 1)))){ setState("chargeFinish", updateChargeFinish); Main.smSFX.getSoundByClassName("ChargingSound").fadeOut(500); }; } else { if ((keyBits & SPACE_PRESSED)){ fireWeapon(); Main.smSFX.getSoundByClassName("ChargingSound").fadeOut(500); } else { setState("chargeFinish", updateChargeFinish); Main.smSFX.getSoundByClassName("ChargingSound").fadeOut(500); }; }; body.x = (body.x + (TARGET_EASING * (standTarget.x - body.x))); } private function updateCrouchUp():void{ if ((keyBits & SPACE)){ switchToStandingBody(x, y); standing = true; fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); } else { if (animationFinished){ switchToStandingBody(x, y); setState("stand", updateStand); standing = true; }; }; }; } public function moveTowardsSwitch():Boolean{ var _local1:Number = Math.abs((body.x - 1668.7)); if ((((body.x > 1668.7)) && ((direction == RIGHT)))){ if (updateStateFunction != updateTurn){ setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); }; return (false); }; if ((((_local1 > 1)) && (!((updateStateFunction == updateRunToSwitch))))){ setState("runStart", updateRunToSwitch); }; body.x = (body.x + (0.3 * (1668.7 - body.x))); if (_local1 < 1){ body.x = 1668.7; if ((((direction == LEFT)) && (!((updateStateFunction == updateTurn))))){ setState("turn", updateTurn); Main.smSFX.getSoundByClassName("TurnSound").play(); } else { if (updateStateFunction == updateRunToSwitch){ setState("stand", updateStand); mc.visible = false; return (true); }; if ((((updateStateFunction == updateTurn)) && ((direction == RIGHT)))){ mc.visible = false; return (true); }; if (updateStateFunction == updateStand){ mc.visible = false; return (true); }; }; }; return (false); } private function updateTurn():void{ if ((keyBits & SPACE)){ if (direction == LEFT){ direction = RIGHT; runSpeed = SPEED; mc.scaleX = 1; } else { direction = LEFT; runSpeed = -(SPEED); mc.scaleX = -1; }; fireWeapon(); } else { if ((((keyBits & X_PRESSED)) && (standTarget))){ respondToStandTarget(); }; }; body.vx = (body.vx * STOPPING_RATE); if (animationFinished){ if (direction == LEFT){ direction = RIGHT; runSpeed = SPEED; mc.scaleX = 1; } else { direction = LEFT; runSpeed = -(SPEED); mc.scaleX = -1; }; setState("stand", updateStand); standing = true; }; } private function fireWeapon():void{ if (energy == 0){ return; }; var _local1:String = weapon; if (_local1 == "rocket"){ _local1 = "lightning"; }; if (jumping){ _local1 = (_local1 + "Jump"); }; if (weapon != "tkBlast"){ _local1 = (_local1 + ((direction)==LEFT) ? "Left" : "Right"); }; switch (weapon){ case "lightning": Main.smSFX.getSoundByClassName("LightningSound").play(); setState(_local1, updateLightning); break; case "grenade": Main.smSFX.getSoundByClassName("GrenadeThrowSound").play(); setState(_local1, updateGrenade); break; case "tkBlast": Main.smSFX.getSoundByClassName("TKBlastSound").play(); setState(_local1, updateTKBlast); break; case "rocket": Main.smSFX.getSoundByClassName("MegawattThrowSound").play(); setState(_local1, updateRocket); break; }; playRandomSound(); } private function updateHover():void{ if (onGround){ Main.smSFX.getSoundByClassName("FloatJumpSound").stop(); playRandomSound(); setState("hoverLand", updateHoverLand); dispatchEvent(hoverEvent); fallingVelocity = 0; hoverCount = 0; } else { body.applyForce(0, HOVER_FORCE); deductEnergy(ENERGY_LOSS_HOVER); if ((((++hoverCount == HOVER_DURATION)) || ((energy == 0)))){ setState("jump", updateJump); hoverCount = 0; hovering = false; } else { if ((keyBits & LEFT)){ body.applyForce(-(SPEED), 0); } else { if ((keyBits & RIGHT)){ body.applyForce(SPEED, 0); } else { if ((keyBits & SPACE)){ standing = true; fireWeapon(); }; }; }; }; if (body.vy > fallingVelocity){ fallingVelocity = body.vy; }; }; } private function updateDie():void{ if (animationFinished){ animation.stop(); }; } } }//package com.kerb.infamous.game
Section 37
//Game (com.kerb.infamous.game.Game) package com.kerb.infamous.game { import flash.events.*; import flash.display.*; import com.kerb.infamous.*; import com.kerb.infamous.game.screens.*; import com.kerb.infamous.game.levels.*; import com.kerb.game.*; import flash.utils.*; import flash.ui.*; public class Game extends AbstractSection { private var level:BaseLevel; private var currScreen:AbstractScreen; private var levelLoseTimer:Timer; private var levels:Array; private var currLevelNum:int; private var udm:UserDataManager; public static const EVENT_WIN_LEVEL:String = "onLevelWin"; public static const EVENT_RETRY_LEVEL:String = "onLevelRetry"; public static const EVENT_NEXT_LEVEL:String = "onLevelNext"; public static const EVENT_LOSE_LEVEL:String = "onLevelLose"; public static var pumaAllowed:Boolean = false; public static var finalScore:int; private function onHelp(_arg1:Event):void{ currScreen = new HelpScreen(); currScreen.addEventListener(Event.COMPLETE, onHelpComplete); addChild(currScreen); setChildIndex(currScreen, (numChildren - 1)); } private function checkPuma():void{ var _local4:String; var _local5:int; var _local1:Date = new Date(); var _local2:Boolean; var _local3:String = Constants.locale.toLocaleLowerCase(); if (_local1.getTime() < Constants.competitionEndDate.getTime()){ _local5 = 0; while (_local5 < Constants.noCompetitionCountries.length) { _local4 = Constants.noCompetitionCountries[_local5].toLowerCase(); if (_local3.indexOf(_local4) != -1){ _local2 = true; break; }; _local5++; }; if (!_local2){ pumaAllowed = true; }; }; } private function onCutSceneComplete(_arg1:Event=null):void{ removeCurrentScreen(); initLevel(currLevelNum); } private function onLevelWin(_arg1:Event=null):void{ Main.smMusic.getSoundByClassName("InGameMusicSound").stop(); level.pause(); if (currLevelNum == 2){ finalScore = udm.getTotalScore(); initFinalCutScene(); } else { initLevelWin(); }; } private function onLevelLoseTimer(_arg1:TimerEvent):void{ levelLoseTimer.removeEventListener(TimerEvent.TIMER, onLevelLoseTimer); level.pause(); currScreen = new LevelLose(udm.getTotalScore()); udm.setScore(0, currLevelNum, true); udm.setKarma(0); currScreen.addEventListener(EVENT_NEXT_LEVEL, onNextLevel); currScreen.addEventListener(EVENT_RETRY_LEVEL, onRetryLevel); addChild(currScreen); setChildIndex(currScreen, (numChildren - 1)); Main.smMusic.getSoundByClassName("InGameMusicSound").stop(); } override protected function init():void{ var debugButtons:MovieClip; checkPuma(); if (Constants.debug){ debugButtons = Main.assetFactory.createMovieClip("DebugButtonsAsset"); debugButtons.name = "debugButtons"; debugButtons.x = 3; debugButtons.y = 35; debugButtons.visible = false; debugButtons.level1_btn.addEventListener(MouseEvent.CLICK, function ():void{ initLevel(0); }); debugButtons.level2_btn.addEventListener(MouseEvent.CLICK, function ():void{ initLevel(1); }); debugButtons.level3_btn.addEventListener(MouseEvent.CLICK, function ():void{ initLevel(2); }); debugButtons.win_btn.addEventListener(MouseEvent.CLICK, onLevelWin); debugButtons.lose_btn.addEventListener(MouseEvent.CLICK, onLevelLose); addChild(debugButtons); stage.addEventListener(KeyboardEvent.KEY_DOWN, function (_arg1:KeyboardEvent):void{ if (_arg1.keyCode == Keyboard.ESCAPE){ debugButtons.visible = !(debugButtons.visible); Avatar.LIFE_GAINED_PER_FRAME = 1; }; }); }; levels = [Level1, Level2, Level3]; udm = new UserDataManager(levels.length, true); initLevel(0); } private function gameComplete():void{ NextSectionClass = GameComplete; gotoNextSection(); } private function initLevel(_arg1:int):void{ removeLevel(); removeCurrentScreen(); currLevelNum = _arg1; level = new levels[_arg1](udm, _arg1); level.addEventListener(EVENT_WIN_LEVEL, onLevelWin); level.addEventListener(EVENT_LOSE_LEVEL, onLevelLose); level.addEventListener(HUD.EVENT_HELP, onHelp); addChild(level); stage.focus = stage; if (Constants.debug){ setChildIndex(getChildByName("debugButtons"), (numChildren - 1)); }; if (!udm.getLevelCompleted(_arg1)){ switch (_arg1){ case 0: Tracking.event((Constants.viral) ? Tracking.LEVEL_1_LOADED_VIRAL : Tracking.LEVEL_1_LOADED_SITE); break; case 1: Tracking.event((Constants.viral) ? Tracking.LEVEL_2_LOADED_VIRAL : Tracking.LEVEL_2_LOADED_SITE); break; case 2: Tracking.event((Constants.viral) ? Tracking.LEVEL_3_LOADED_VIRAL : Tracking.LEVEL_3_LOADED_SITE); break; }; }; } private function initFinalCutScene():void{ if (udm.getTotalScore() >= 0){ currScreen = new FinalCutScene(true); if (Constants.viral){ Tracking.event(Tracking.GAME_COMPLETE_GOOD_VIRAL); } else { Tracking.event(Tracking.GAME_COMPLETE_GOOD_SITE); }; } else { currScreen = new FinalCutScene(false); if (Constants.viral){ Tracking.event(Tracking.GAME_COMPLETE_BAD_VIRAL); } else { Tracking.event(Tracking.GAME_COMPLETE_BAD_SITE); }; }; currScreen.addEventListener(EVENT_NEXT_LEVEL, onFinalCutSceneComplete); addChild(currScreen); setChildIndex(currScreen, (numChildren - 1)); } private function onHelpComplete(_arg1:Event):void{ currScreen.removeEventListener(Event.COMPLETE, onHelpComplete); removeScreen(currScreen); level.start(); } private function onLevelLose(_arg1:Event=null):void{ levelLoseTimer = new Timer(2700); levelLoseTimer.addEventListener(TimerEvent.TIMER, onLevelLoseTimer); levelLoseTimer.start(); } private function removeLevel():void{ removeScreen(level); if (level){ level.removeEventListener(HUD.EVENT_HELP, onHelp); Main.smMusic.getSoundByClassName("InGameMusicSound").stop(); }; level = null; } private function initCutScene():void{ if (currLevelNum == 1){ currScreen = new Level2CutScene(); } else { if (currLevelNum == 2){ currScreen = new Level3CutScene(); }; }; if (currScreen){ currScreen.addEventListener(EVENT_NEXT_LEVEL, onCutSceneComplete); addChild(currScreen); setChildIndex(currScreen, (numChildren - 1)); }; } override public function dispose():void{ removeLevel(); removeCurrentScreen(); super.dispose(); } private function initLevelWin():void{ currScreen = new LevelWin(udm.getLevelScore(currLevelNum), udm.getTotalScore()); currScreen.addEventListener(EVENT_NEXT_LEVEL, onNextLevel); currScreen.addEventListener(EVENT_RETRY_LEVEL, onRetryLevel); addChild(currScreen); setChildIndex(currScreen, (numChildren - 1)); udm.setLevelCompleted(currLevelNum); } private function removeCurrentScreen():void{ removeScreen(currScreen); currScreen = null; } private function onNextLevel(_arg1:Event=null):void{ currLevelNum++; if (currLevelNum == levels.length){ gameComplete(); } else { removeCurrentScreen(); initCutScene(); }; } private function onFinalCutSceneComplete(_arg1:Event=null):void{ removeCurrentScreen(); NextSectionClass = GameComplete; gotoNextSection(); } private function onRetryLevel(_arg1:Event=null):void{ if (Constants.viral){ Tracking.event(Tracking.RETRY_LEVEL_VIRAL); } else { Tracking.event(Tracking.RETRY_LEVEL_SITE); }; initLevel(currLevelNum); } private function removeScreen(_arg1:AbstractScreen):void{ if (_arg1){ _arg1.removeEventListener(EVENT_NEXT_LEVEL, onNextLevel); _arg1.removeEventListener(EVENT_RETRY_LEVEL, onRetryLevel); _arg1.removeEventListener(EVENT_NEXT_LEVEL, onCutSceneComplete); _arg1.removeEventListener(EVENT_NEXT_LEVEL, onFinalCutSceneComplete); _arg1.dispose(); removeChild(_arg1); _arg1 = null; }; } } }//package com.kerb.infamous.game
Section 38
//HUD (com.kerb.infamous.game.HUD) package com.kerb.infamous.game { import flash.events.*; import flash.display.*; import com.kerb.infamous.*; import flash.text.*; import com.kerb.infamous.ui.*; public class HUD extends Sprite { private var websiteButton:WebsiteButton; private var currentAction:String;// = "" private var mc:MovieClip; private static const SCORE_RED:int = 13049374; public static const EVENT_HELP:String = "onHelp"; private static const SCORE_BLUE:int = 615926; public function HUD(_arg1:int, _arg2:Number, _arg3:Number){ mc = Main.assetFactory.createMovieClip("HUDAsset"); addChild(mc); setKarma(_arg2, true, false); setEnergy(_arg3); setLife(1); setWeapon("lightning"); mc.help_btn.addEventListener(MouseEvent.CLICK, onHelpClick, false, 0, true); mc.frame.mouseEnabled = false; websiteButton = new WebsiteButton(mc.website_btn); if (((Constants.debug) && (Constants.debugScore))){ initScoreDisplay(); }; setTotalScore(0); } public function setWeapon(_arg1:String):void{ if (mc.weapon.nextWeapon != _arg1){ mc.weapon.nextWeapon = _arg1; mc.weapon.play(); }; } public function showEnergyArrow():MovieClip{ mc.energyArrow.gotoAndPlay("show"); return (mc.energyArrow); } public function setLife(_arg1:Number):void{ var _local2:int = (100 - (_arg1 * 100)); if (_local2 == 0){ _local2 = 1; }; mc.life.gotoAndStop(_local2); } private function initScoreDisplay():void{ var _local1:TextField; var _local2:TextFormat; _local2 = new TextFormat(); _local2.font = "_sans"; _local2.size = 10; _local1 = new TextField(); _local1.name = "levelScore_txt"; _local1.border = true; _local1.background = true; _local1.width = 105; _local1.height = 15; _local1.text = "LEVEL SCORE:0"; _local1.setTextFormat(_local2); mc.addChild(_local1); _local1 = new TextField(); _local1.name = "totalScore_txt"; _local1.border = true; _local1.background = true; _local1.width = 105; _local1.height = 15; _local1.text = "TOTAL SCORE:0"; _local1.setTextFormat(_local2); _local1.x = 110; mc.addChild(_local1); } private function onHelpClick(_arg1:MouseEvent):void{ dispatchEvent(new Event(EVENT_HELP)); } public function setEnergy(_arg1:Number):void{ var _local2:int = (_arg1 * mc.energy.totalFrames); if (_local2 == 0){ _local2 = 1; }; if (mc.energy.currentFrame != _local2){ mc.energy.gotoAndStop(_local2); }; mc.pulse.scaleX = ((0.5 * _arg1) + 0.5); mc.pulse.scaleY = mc.pulse.scaleX; } public function setKarma(_arg1:Number, _arg2:Boolean, _arg3:Boolean=true):void{ var _local4:int = ((_arg1 * 50) + 51); mc.karma.gotoAndStop(_local4); if (_arg3){ if (_arg2){ mc.goodKarmaFront.gotoAndPlay("show"); mc.goodKarmaBack.gotoAndPlay("show"); } else { mc.badKarmaFront.gotoAndPlay("show"); mc.badKarmaBack.gotoAndPlay("show"); }; mc.pulse.gotoAndPlay("pulse"); }; } public function setLevelScore(_arg1:int):void{ var _local2:TextFormat; if (((Constants.debug) && (Constants.debugScore))){ _local2 = new TextFormat(); _local2.font = "_sans"; _local2.size = 10; (mc.getChildByName("levelScore_txt") as TextField).text = ("LEVEL SCORE:" + _arg1); (mc.getChildByName("levelScore_txt") as TextField).setTextFormat(_local2); }; } public function showAction(_arg1:String):void{ if (currentAction != _arg1){ currentAction = _arg1; mc.action.icon.gotoAndStop(_arg1); mc.action.gotoAndPlay("show"); }; } public function setTotalScore(_arg1:int):void{ var _local2:TextFormat; if (((Constants.debug) && (Constants.debugScore))){ _local2 = new TextFormat(); _local2.font = "_sans"; _local2.size = 10; (mc.getChildByName("totalScore_txt") as TextField).text = ("TOTAL SCORE:" + _arg1); (mc.getChildByName("totalScore_txt") as TextField).setTextFormat(_local2); }; _local2 = mc.score_txt.getTextFormat(); if (_arg1 < 0){ _local2.color = SCORE_RED; } else { _local2.color = SCORE_BLUE; }; mc.score_txt.text = _arg1.toString(); mc.score_txt.setTextFormat(_local2); } public function hideAction():void{ if (currentAction != ""){ currentAction = ""; mc.action.gotoAndPlay("hide"); }; } public function showKarmaArrow():MovieClip{ mc.karmaArrow.gotoAndPlay("show"); return (mc.karmaArrow); } public function showLifeArrow():MovieClip{ mc.lifeArrow.gotoAndPlay("show"); return (mc.lifeArrow); } } }//package com.kerb.infamous.game
Section 39
//Physics (com.kerb.infamous.game.Physics) package com.kerb.infamous.game { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.*; import de.polygonal.motor2.math.*; import flash.geom.*; import de.polygonal.motor2.collision.shapes.data.*; import de.polygonal.motor2.collision.nbody.*; import de.polygonal.motor2.dynamics.contact.*; public class Physics { private var rayAABB:AABB2; private var world:World; private var rayCircle:Circle2; private var avatarBody:RigidBody; private var raycastPoint:Point; private var sourceShapes:Array; private var halfAvatarHeight:Number; public var avatarOnGround:Boolean;// = false private static const AVATAR_IN_AIR_RESTITUTION:Number = -1500; private static const AXIAL_SPACING:Number = 5; private static const RADIAL_SPACING:Number = 0.125663706143592; private static const TIME_STEP:Number = 0.1; private static const GRAVITY:Number = 18; private static const RAD_2_DEG:Number = 57.2957795130823; private static const NUM_ITERATIONS:int = 10; public function Physics(_arg1:Number, _arg2:Number){ sourceShapes = new Array(); raycastPoint = new Point(); rayAABB = new AABB2(); rayCircle = new Circle2(0, 0, 0); super(); init(_arg1, _arg2); } private function checkContacts():void{ var _local2:Manifold; var _local3:Number; var _local1:Contact = world.contactList; avatarOnGround = false; while (_local1) { if (_local1.shape1.body == avatarBody){ _local2 = _local1.manifolds[0]; _local3 = Math.atan2(_local2.nx, -(_local2.ny)); if (_local3 < 0){ _local3 = -(_local3); }; if ((((_local3 > 2.36)) && ((_local3 < 3.142)))){ avatarOnGround = true; break; }; }; _local1 = _local1.next; }; } public function linearRaycast(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:ShapeSkeleton=null):RaycastResult{ var _local7:int; if (_arg1 < _arg3){ rayAABB.xmin = _arg1; rayAABB.xmax = _arg3; } else { rayAABB.xmin = _arg3; rayAABB.xmax = _arg1; }; if (_arg2 < _arg4){ rayAABB.ymin = _arg2; rayAABB.ymax = _arg4; } else { rayAABB.ymin = _arg4; rayAABB.ymax = _arg2; }; sourceShapes.length = 0; world.getBroadPhase().queryAABB(rayAABB, sourceShapes); if (_arg5){ _local7 = sourceShapes.indexOf(_arg5); if (_local7 != -1){ sourceShapes.splice(_local7, 1); }; }; if (sourceShapes.length == 0){ return (null); }; var _local6:RigidBody = raycast(_arg1, _arg2, _arg3, _arg4, sourceShapes, AXIAL_SPACING); return (new RaycastResult(raycastPoint.x, raycastPoint.y, _local6)); } public function step():void{ if (!avatarOnGround){ avatarBody.applyForce((AVATAR_IN_AIR_RESTITUTION * avatarBody.vx), 0); }; world.step(TIME_STEP, NUM_ITERATIONS); world.step(TIME_STEP, NUM_ITERATIONS); world.step(TIME_STEP, NUM_ITERATIONS); checkContacts(); } private function init(_arg1:Number, _arg2:Number):void{ var _local3:Number = 400; var _local4:AABB2 = new AABB2(-(_local3), -(_local3), (_arg1 + _local3), (_arg2 + _local3)); var _local5:Boolean; world = new World(_local4, _local5); world.setGravity(0, GRAVITY); world.setBroadPhase(new SAP()); var _local6:Number = (_local3 * 0.5); var _local7:Number = (_local3 * 0.25); addBox(-(_local7), (0.5 * _arg2), _local6, (_arg2 + _local6)); addBox((_arg1 + _local7), (0.5 * _arg2), _local6, (_arg2 + _local6)); addBox((0.5 * _arg1), -(_local7), (_arg1 + _local6), _local6); addBox((0.5 * _arg1), (_arg2 + _local7), (_arg1 + _local6), _local6); } public function createRigidBody(_arg1:RigidBodyData, _arg2:String=null):RigidBody{ var _local3:RigidBody = world.createBody(_arg1); _local3.userData = {id:_arg2, owner:null}; return (_local3); } public function destroyRigidBody(_arg1:RigidBody):void{ world.destroyBody(_arg1); } public function addCircle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0, _arg5:int=-1, _arg6:String=null):RigidBody{ var _local7:CircleData; var _local8:RigidBodyData; _local7 = new CircleData(_arg4, _arg3); _local7.groupIndex = _arg5; _local8 = new RigidBodyData(_arg1, _arg2); _local8.addShapeData(_local7); return (createRigidBody(_local8, _arg6)); } public function circularRaycast(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:ShapeSkeleton=null):Array{ var _local7:RigidBody; var _local8:int; var _local10:Number; var _local11:Number; var _local12:int; var _local5:Array = new Array(); var _local6:int = ((2 * Math.PI) / RADIAL_SPACING); sourceShapes.length = 0; rayCircle.c.x = _arg1; rayCircle.c.y = _arg2; rayCircle.radius = _arg3; world.getBroadPhase().queryCircle(rayCircle, sourceShapes); if (_arg4){ _local12 = sourceShapes.indexOf(_arg4); if (_local12 != -1){ sourceShapes.splice(_local12, 1); }; }; if (sourceShapes.length == 0){ return (_local5); }; var _local9:Number = 0; _local8 = 0; while (_local8 < _local6) { _local10 = ((_arg3 * Math.cos(_local9)) + _arg1); _local11 = ((_arg3 * Math.sin(_local9)) + _arg2); _local7 = raycast(_arg1, _arg2, _local10, _local11, sourceShapes, AXIAL_SPACING); if (((_local7) && ((_local5.indexOf(_local7) == -1)))){ _local5.push(_local7); }; _local9 = (_local9 + RADIAL_SPACING); _local8++; }; return (_local5); } public function getShapes():Array{ return (world.getShapeList()); } private function raycast(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Array, _arg6:Number):RigidBody{ var _local13:int; var _local14:int; var _local15:int; var _local16:ShapeSkeleton; var _local7:Number = (_arg3 - _arg1); var _local8:Number = (_arg4 - _arg2); var _local9:Number = Math.sqrt(((_local7 * _local7) + (_local8 * _local8))); var _local10:Number = (_arg6 / _local9); var _local11:Number = (_local7 * _local10); var _local12:Number = (_local8 * _local10); var _local17:ShapeSkeleton; if (_local11 != 0){ _local13 = Math.ceil((_local7 / _local11)); } else { if (_local12 != 0){ _local13 = Math.ceil((_local8 / _local12)); } else { return (null); }; }; raycastPoint.x = (_arg1 + _local11); raycastPoint.y = (_arg2 + _local12); _local14 = 1; while (_local14 < _local13) { _local15 = _arg5.length; while (_local15-- > 0) { _local16 = _arg5[_local15]; if (_local16.pointInside(raycastPoint)){ return (_local16.body); }; }; raycastPoint.x = (raycastPoint.x + _local11); raycastPoint.y = (raycastPoint.y + _local12); _local14++; }; return (null); } public function addBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0, _arg7:int=-1, _arg8:String=null):RigidBody{ var _local9:BoxData; var _local10:RigidBodyData; _local9 = new BoxData(_arg5, _arg3, _arg4); _local9.groupIndex = _arg7; _local9.friction = 0.3; _local10 = new RigidBodyData(_arg1, _arg2, _arg6); _local10.addShapeData(_local9); return (createRigidBody(_local10, _arg8)); } public function angularRaycast(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:ShapeSkeleton=null):Array{ var _local9:RigidBody; var _local10:int; var _local12:Number; var _local13:Number; var _local14:int; var _local7:Array = new Array(); var _local8:int = Math.ceil(((_arg4 - _arg3) / RADIAL_SPACING)); sourceShapes.length = 0; rayCircle.c.x = _arg1; rayCircle.c.y = _arg2; rayCircle.radius = _arg5; world.getBroadPhase().queryCircle(rayCircle, sourceShapes); if (_arg6){ _local14 = sourceShapes.indexOf(_arg6); if (_local14 != -1){ sourceShapes.splice(_local14, 1); }; }; if (sourceShapes.length == 0){ return (_local7); }; var _local11:Number = _arg3; _local10 = 0; while (_local10 < _local8) { _local12 = ((_arg5 * Math.cos(_local11)) + _arg1); _local13 = ((_arg5 * Math.sin(_local11)) + _arg2); _local9 = raycast(_arg1, _arg2, _local12, _local13, sourceShapes, AXIAL_SPACING); if (((_local9) && ((_local7.indexOf(_local9) == -1)))){ _local7.push(_local9); }; _local11 = (_local11 + RADIAL_SPACING); _local10++; }; return (_local7); } public function addLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean, _arg6:int=-1, _arg7:String=null):RigidBody{ var _local8:ShapeData; var _local9:RigidBodyData; var _local10:Point = new Point(0, 0); var _local11:Point = new Point((_arg3 - _arg1), (_arg4 - _arg2)); _local8 = new LineData(_local10, _local11, false, _arg5); _local8.groupIndex = _arg6; _local9 = new RigidBodyData(_arg1, _arg2); _local9.addShapeData(_local8); return (createRigidBody(_local9, _arg7)); } public function defineAvatar(_arg1:RigidBodyData, _arg2:Number):RigidBody{ this.halfAvatarHeight = _arg2; avatarBody = createRigidBody(_arg1, "avatar"); avatarBody.allowSleeping(false); return (avatarBody); } } }//package com.kerb.infamous.game
Section 40
//RaycastResult (com.kerb.infamous.game.RaycastResult) package com.kerb.infamous.game { import de.polygonal.motor2.dynamics.*; public class RaycastResult { public var body:RigidBody; public var x:Number; public var y:Number; public function RaycastResult(_arg1:Number, _arg2:Number, _arg3:RigidBody){ this.x = _arg1; this.y = _arg2; this.body = _arg3; } } }//package com.kerb.infamous.game
Section 41
//UserDataManager (com.kerb.infamous.game.UserDataManager) package com.kerb.infamous.game { import flash.net.*; public class UserDataManager { private const USE_SHARED_OBJECT:Boolean = false; private const SALT:String = "1.61803"; private const KEYS:Array; private var levelScores:Array; private var numLevels:int; private var so:SharedObject; private var levelsCompleted:Array; private var karma:Number; public function UserDataManager(_arg1:int=1, _arg2:Boolean=false){ var numLevels = _arg1; var readLocalData = _arg2; KEYS = ["cKdpailJCtMqBz", "MhDUOTpACSiwZu", "TWwenNZQCYmtdz", "eisaGZBxdkYVLr"]; super(); this.numLevels = numLevels; levelScores = new Array(); levelsCompleted = new Array(); var i:int; while (i < numLevels) { levelScores[i] = 0; levelsCompleted[i] = false; i = (i + 1); }; karma = 0; if (USE_SHARED_OBJECT){ try { so = SharedObject.getLocal("game"); } catch(e:Error) { trace(e); }; if (readLocalData){ readData(); }; writeData(); }; } public function writeData():void{ var sum:int; var i:int; if (so){ so.data.a = encrypt(levelScores.toString()); sum = 0; i = 0; while (i < numLevels) { if (levelsCompleted[i]){ sum = (sum + Math.pow(2, i)); }; i = (i + 1); }; so.data.b = encrypt(sum.toString()); try { so.flush(10000); } catch(e:Error) { trace(e); }; }; } private function decrypt(_arg1:String):String{ var _local2:int = parseInt(_arg1.substr(-1)); var _local3 = ""; _arg1 = _arg1.substr(0, (_arg1.length - 1)); var _local4:int; while (_local4 < _arg1.length) { _local3 = (_local3 + String.fromCharCode((KEYS[_local2].indexOf(_arg1.charAt(_local4)) + 44))); _local2 = ((_local2 + 1) % KEYS.length); _local4++; }; if (_local3.substr(-(SALT.length)) != SALT){ return (""); }; return (_local3.substr(0, (_local3.length - SALT.length))); } public function setScore(_arg1:Number, _arg2:int=0, _arg3:Boolean=false):void{ if (inRange(_arg2)){ if (((_arg3) || ((_arg1 > levelScores[_arg2])))){ levelScores[_arg2] = _arg1; }; }; if (USE_SHARED_OBJECT){ writeData(); }; } public function addToKarma(_arg1:Number):void{ karma = (karma + _arg1); if (karma > 1){ karma = 1; } else { if (karma < -1){ karma = -1; }; }; } private function inRange(_arg1:int):Boolean{ return ((((_arg1 >= 0)) && ((_arg1 < numLevels)))); } public function getLevelCompleted(_arg1:int):Boolean{ return (levelsCompleted[_arg1]); } public function getTotalScore():Number{ var _local1:Number = 0; var _local2:int; while (_local2 < numLevels) { _local1 = (_local1 + levelScores[_local2]); _local2++; }; return (_local1); } private function encrypt(_arg1:String):String{ var _local2:int = (Math.random() * KEYS.length); var _local3:int = _local2; var _local4 = ""; _arg1 = (_arg1 + SALT); var _local5:int; while (_local5 < _arg1.length) { _local4 = (_local4 + KEYS[_local3].charAt((_arg1.charCodeAt(_local5) - 44))); _local3 = ((_local3 + 1) % KEYS.length); _local5++; }; _local4 = (_local4 + _local2); return (_local4); } public function getLevelsCompleted():Array{ return (levelsCompleted); } public function readData():void{ var _local1:int; var _local2:int; var _local3:String; var _local4:int; var _local5:Array; if (so){ if (so.data.a){ _local3 = decrypt(so.data.a); _local5 = _local3.split(","); _local1 = 0; while (_local1 < _local5.length) { levelScores[_local1] = parseFloat(_local5[_local1]); if (isNaN(levelScores[_local1])){ levelScores[_local1] = 0; }; _local1++; }; }; if (so.data.b){ _local4 = parseInt(decrypt(so.data.b)); _local1 = 1; _local2 = 0; while (_local1 <= _local4) { levelsCompleted[_local2] = !(((_local4 & _local1) == 0)); _local1 = (_local1 * 2); _local2++; }; }; }; } public function setLevelCompleted(_arg1:int, _arg2:Boolean=true):void{ if (inRange(_arg1)){ levelsCompleted[_arg1] = _arg2; }; if (USE_SHARED_OBJECT){ writeData(); }; } public function getLevelScore(_arg1:int=0):Number{ return (levelScores[_arg1]); } public function setKarma(_arg1:Number):void{ karma = _arg1; if (karma > 1){ karma = 1; } else { if (karma < -1){ karma = -1; }; }; } public function addToScore(_arg1:Number, _arg2:int=0):void{ if (inRange(_arg2)){ levelScores[_arg2] = (levelScores[_arg2] + _arg1); }; if (USE_SHARED_OBJECT){ writeData(); }; } public function getKarma():Number{ return (karma); } public function allLevelsCompleted():Boolean{ var _local1:int; while (_local1 < numLevels) { if (!levelsCompleted[_local1]){ return (false); }; _local1++; }; return (true); } } }//package com.kerb.infamous.game
Section 42
//SoundControl (com.kerb.infamous.ui.SoundControl) package com.kerb.infamous.ui { import flash.events.*; import flash.display.*; import com.kerb.sound.*; public class SoundControl { private var master:Toggle; private var sfxSoundManager:SoundManager; private var music:Toggle; private var musicSoundManager:SoundManager; private var sfx:Toggle; public var mc:MovieClip; private var propagateChange:Boolean; public function SoundControl(_arg1:MovieClip, _arg2:SoundManager, _arg3:SoundManager){ this.mc = _arg1; this.musicSoundManager = _arg2; this.sfxSoundManager = _arg3; init(); } private function setMutes():void{ if (((music.isOn) && (musicSoundManager.muted))){ musicSoundManager.unmute(); } else { if (((!(music.isOn)) && (!(musicSoundManager.muted)))){ musicSoundManager.mute(); }; }; if (((sfx.isOn) && (sfxSoundManager.muted))){ sfxSoundManager.unmute(); } else { if (((!(sfx.isOn)) && (!(sfxSoundManager.muted)))){ sfxSoundManager.mute(); }; }; } private function updateMaster():void{ if (propagateChange){ propagateChange = false; if (((music.isOn) || (sfx.isOn))){ master.isOn = true; } else { if (((!(music.isOn)) && (!(sfx.isOn)))){ master.isOn = false; }; }; propagateChange = true; }; setMutes(); } private function onSFXChange(_arg1:Event=null):void{ updateMaster(); } private function init():void{ mc.mouseEnabled = false; master = new Toggle(mc.master); music = new Toggle(mc.music); sfx = new Toggle(mc.sfx); master.addEventListener(Event.CHANGE, onMasterChange, false, 0, true); music.addEventListener(Event.CHANGE, onMusicChange, false, 0, true); sfx.addEventListener(Event.CHANGE, onSFXChange, false, 0, true); mc.master.addEventListener(MouseEvent.ROLL_OVER, onMasterRollOver, false, 0, true); music.visible = false; sfx.visible = false; propagateChange = true; } private function onMasterChange(_arg1:Event=null):void{ if (propagateChange){ propagateChange = false; music.isOn = master.isOn; sfx.isOn = master.isOn; propagateChange = true; }; setMutes(); } private function onEnterFrame(_arg1:Event=null):void{ var _local2:Boolean = ((((master.mouseIsOver) || (music.mouseIsOver))) || (sfx.mouseIsOver)); if (!_local2){ music.visible = false; sfx.visible = false; mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); }; } private function onMusicChange(_arg1:Event=null):void{ updateMaster(); } private function onMasterRollOver(_arg1:MouseEvent=null):void{ music.visible = true; sfx.visible = true; mc.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); } } }//package com.kerb.infamous.ui
Section 43
//TextBox (com.kerb.infamous.ui.TextBox) package com.kerb.infamous.ui { import flash.display.*; import com.kerb.infamous.*; import flash.text.*; import flash.geom.*; public class TextBox { private var targetAspectRatio:Number; private var styles:StyleSheet; private var dimensions:Array; private var maxTextWidth:Number; public var mc:MovieClip; private static const PADDING_TOP:Number = 2; public static const RULE_CLOSEST_ASPECT_RATIO:int = 1; private static const PADDING_RIGHT:Number = 14; public static const RULE_MIN_LINES:int = 0; private static const DEFAULT_TARGET_ASPECT_RATIO:Number = 1.414; private static const PADDING_LEFT:Number = 10; private static const PADDING_BOTTOM:Number = 8; private static const DEFAULT_MAX_TEXT_WIDTH:Number = 250; private static const REG_EXP:RegExp = new RegExp("[ \\-\n\t\r]"); public function TextBox(_arg1:MovieClip){ this.mc = _arg1; _arg1.label_txt.x = PADDING_LEFT; _arg1.label_txt.y = PADDING_TOP; _arg1.label_txt.wordWrap = true; _arg1.label_txt.multiline = true; _arg1.label_txt.autoSize = TextFieldAutoSize.LEFT; dimensions = new Array(); var _local2:int; while (_local2 < 10) { dimensions.push(new Point()); _local2++; }; maxTextWidth = DEFAULT_MAX_TEXT_WIDTH; targetAspectRatio = DEFAULT_TARGET_ASPECT_RATIO; this.styles = new StyleSheet(); styles.setStyle("font-weight", "bold"); styles.setStyle("font-family", "Impact"); } public function setTargetAspectRatio(_arg1:Number):void{ this.targetAspectRatio = _arg1; } private function setTextFromAspectRatio(_arg1:String):void{ var _local4:int; var _local8:Number; var _local2:Number = 0; var _local3:Array = _arg1.split(REG_EXP); mc.label_txt.htmlText = ""; mc.label_txt.width = 1; _local4 = _local3.length; while (_local4-- > 0) { mc.label_txt.htmlText = _local3[_local4]; InfamousTextManager.getInstance().setText(mc.label_txt); if (mc.label_txt.textWidth > _local2){ _local2 = mc.label_txt.textWidth; }; }; mc.label_txt.htmlText = _arg1; InfamousTextManager.getInstance().setText(mc.label_txt); mc.label_txt.width = (_local2 + 5); var _local5:int = (mc.label_txt.numLines + 1); _local4 = 0; while (_local5 > 1) { if (mc.label_txt.numLines != _local5){ _local5 = mc.label_txt.numLines; var _temp1 = _local4; _local4 = (_local4 + 1); addToDimensions(mc.label_txt.width, mc.label_txt.height, _temp1); }; mc.label_txt.width++; if (mc.label_txt.width > maxTextWidth){ break; }; }; var _local6:Number = 9999; var _local7:int; while (_local4-- > 0) { _local8 = (dimensions[_local4].x / dimensions[_local4].y); _local8 = Math.abs((targetAspectRatio - _local8)); if (_local8 < _local6){ _local6 = _local8; _local7 = _local4; }; }; mc.label_txt.width = dimensions[_local7].x; mc.label_txt.height = dimensions[_local7].y; scaleBackground(); } private function setTextFromMinLines(_arg1:String):void{ var _local3:Number; mc.label_txt.width = maxTextWidth; mc.label_txt.htmlText = _arg1; InfamousTextManager.getInstance().setText(mc.label_txt); var _local2:int = mc.label_txt.numLines; while (mc.label_txt.numLines == _local2) { _local3 = mc.label_txt.width; if (mc.label_txt.width-- == 0){ break; }; }; mc.label_txt.width = (_local3 + 4); mc.label_txt.height = 0; scaleBackground(); } public function setText(_arg1:String, _arg2:int):void{ InfamousTextManager.getInstance().setText(mc.label_txt); if (Constants.useSystemFont){ _arg1 = (("<b>" + _arg1) + "</b>"); }; if (_arg2 == RULE_CLOSEST_ASPECT_RATIO){ setTextFromAspectRatio(_arg1); } else { if (_arg2 == RULE_MIN_LINES){ setTextFromMinLines(_arg1); } else { throw (new Error("invalid rule type supplied")); }; }; } private function addToDimensions(_arg1:Number, _arg2:Number, _arg3:int):void{ while (dimensions.length < (_arg3 + 1)) { dimensions.push(new Point()); }; dimensions[_arg3].x = _arg1; dimensions[_arg3].y = _arg2; } public function setMaxTextWidth(_arg1:Number):void{ this.maxTextWidth = _arg1; } private function scaleBackground():void{ var _local1:Number = ((mc.label_txt.numLines)==1) ? 4 : 0; mc.bg.width = ((PADDING_LEFT + PADDING_RIGHT) + mc.label_txt.width); mc.bg.height = (((PADDING_TOP + PADDING_BOTTOM) + mc.label_txt.height) - _local1); } } }//package com.kerb.infamous.ui
Section 44
//Toggle (com.kerb.infamous.ui.Toggle) package com.kerb.infamous.ui { import flash.events.*; import flash.display.*; public class Toggle extends EventDispatcher { private var mouseOver:Boolean; private var mouseDown:Boolean; private var toggleOn:Boolean; private var mc:MovieClip; public function Toggle(_arg1:MovieClip, _arg2:Boolean=true){ this.mc = _arg1; this.toggleOn = _arg2; init(); } private function onRollOut(_arg1:MouseEvent=null):void{ mouseOver = false; mouseDown = false; setGraphics(); } public function get mouseIsOver():Boolean{ return (mouseOver); } public function set visible(_arg1:Boolean):void{ mc.visible = _arg1; } private function onMouseDown(_arg1:MouseEvent=null):void{ mouseDown = true; setGraphics(); } public function get isOn():Boolean{ return (toggleOn); } private function setGraphics():void{ mc.upOff.visible = ((!(toggleOn)) && (!(mouseOver))); mc.overOff.visible = ((((!(toggleOn)) && (mouseOver))) && (!(mouseDown))); mc.downOff.visible = ((!(toggleOn)) && (mouseDown)); mc.upOn.visible = ((toggleOn) && (!(mouseOver))); mc.overOn.visible = ((((toggleOn) && (mouseOver))) && (!(mouseDown))); mc.downOn.visible = ((toggleOn) && (mouseDown)); } private function init():void{ mc.addEventListener(MouseEvent.ROLL_OVER, onRollOver, false, 0, true); mc.addEventListener(MouseEvent.ROLL_OUT, onRollOut, false, 0, true); mc.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true); mc.addEventListener(MouseEvent.CLICK, onClick, false, 0, true); mc.buttonMode = true; mc.mouseChildren = false; mc.hitArea = mc.hit; mc.hit.visible = false; mouseOver = false; mouseDown = false; setGraphics(); } public function get mouseIsDown():Boolean{ return (mouseDown); } public function set isOn(_arg1:Boolean):void{ toggleOn = _arg1; setGraphics(); dispatchEvent(new Event(Event.CHANGE)); } private function onRollOver(_arg1:MouseEvent=null):void{ mouseOver = true; setGraphics(); } private function onClick(_arg1:MouseEvent=null):void{ mouseDown = false; isOn = !(toggleOn); } } }//package com.kerb.infamous.ui
Section 45
//WebsiteButton (com.kerb.infamous.ui.WebsiteButton) package com.kerb.infamous.ui { import flash.events.*; import flash.display.*; import com.kerb.infamous.*; public class WebsiteButton { private var down:MovieClip; private var up:MovieClip; private var over:MovieClip; private var label:String; private var btn:MovieClip; public function WebsiteButton(_arg1:MovieClip){ this.btn = _arg1; init(); } private function onMouseDown(_arg1:MouseEvent):void{ if (up.parent){ btn.removeChild(up); }; if (over.parent){ btn.removeChild(over); }; if (!down.parent){ btn.addChild(down); }; } private function onEnterFrame(_arg1:Event):void{ } private function onClick(_arg1:MouseEvent):void{ Tracking.click(Tracking.INFAMOUS_WEBSITE_CLICKTHROUGH); } private function init():void{ InfamousTextManager.getInstance().setText(btn.over.label.txt.label_txt, "title.official.website"); InfamousTextManager.getInstance().setText(btn.down.label.label_txt, "title.official.website"); btn.addEventListener(MouseEvent.CLICK, onClick, false, 0, true); btn.addEventListener(MouseEvent.ROLL_OVER, onRollOver, false, 0, true); btn.addEventListener(MouseEvent.ROLL_OUT, onRollOut, false, 0, true); btn.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true); btn.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); btn.buttonMode = true; btn.mouseChildren = false; btn.hitArea = btn.hit; btn.hit.visible = false; btn.hit.mouseEnabled = false; up = btn.up; over = btn.over; down = btn.down; btn.removeChild(over); btn.removeChild(down); } private function onRollOut(_arg1:MouseEvent):void{ if (!up.parent){ btn.addChild(up); }; if (over.parent){ btn.removeChild(over); }; if (down.parent){ btn.removeChild(down); }; } private function onRollOver(_arg1:MouseEvent):void{ if (up.parent){ btn.removeChild(up); }; if (!over.parent){ btn.addChild(over); }; if (down.parent){ btn.removeChild(down); }; } } }//package com.kerb.infamous.ui
Section 46
//ChooseKarma (com.kerb.infamous.ChooseKarma) package com.kerb.infamous { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import flash.text.*; import com.kerb.game.*; import flash.utils.*; public class ChooseKarma extends AbstractSection { private var itm:InfamousTextManager; private var af:AssetFactory; private var mc:MovieClip; public function ChooseKarma(){ itm = InfamousTextManager.getInstance(); af = Main.assetFactory; mc = af.createMovieClip("ChooseKarmaScreenAsset"); addChild(mc); } private function _onBadClicked(_arg1:MouseEvent):void{ var _local2:MovieClip = (mc.getChildByName("bad_mc") as MovieClip); _local2.getChildByName("up").visible = false; _local2.getChildByName("over").visible = false; var _local3:MovieClip = (_local2.getChildByName("down") as MovieClip); _local3.visible = true; _local3.gotoAndStop(2); CurrentKarmaChoice.isGood = false; _choiceMade(); } private function _onBadRolledOver(_arg1:MouseEvent):void{ var _local2:MovieClip = (mc.getChildByName("bad_mc") as MovieClip); _local2.getChildByName("up").visible = false; _local2.getChildByName("over").visible = true; } private function _disableGoodAndBadHitAreas():void{ var _local1:MovieClip; var _local2:MovieClip = (mc.getChildByName("good_mc") as MovieClip); _local1 = (_local2.getChildByName("hitarea") as MovieClip); _local1.removeEventListener(MouseEvent.ROLL_OVER, _onGoodRolledOver); _local1.removeEventListener(MouseEvent.ROLL_OUT, _onGoodRolledOut); _local1.removeEventListener(MouseEvent.CLICK, _onGoodClicked); _local1.mouseChildren = false; _local1.buttonMode = false; _local1.mouseEnabled = false; _local1.useHandCursor = false; var _local3:MovieClip = (mc.getChildByName("bad_mc") as MovieClip); _local1 = (_local3.getChildByName("hitarea") as MovieClip); _local1.removeEventListener(MouseEvent.ROLL_OVER, _onBadRolledOver); _local1.removeEventListener(MouseEvent.ROLL_OUT, _onBadRolledOut); _local1.removeEventListener(MouseEvent.CLICK, _onBadClicked); _local1.mouseChildren = false; _local1.buttonMode = false; _local1.mouseEnabled = false; _local1.useHandCursor = false; } private function _onGoodOverEnterFrame(_arg1:Event):void{ var _local2:MovieClip = (mc.getChildByName("good_mc") as MovieClip); var _local3:TextField = (_local2.over.word_mc.text_txt as TextField); if (_local3 != null){ itm.setText(_local3, "karma.good"); } else { trace("over.word_mc.text_txt missing from timeline"); }; } private function _onTimerComplete(_arg1:TimerEvent):void{ var _local2:Timer = (_arg1.target as Timer); _local2.removeEventListener(TimerEvent.TIMER_COMPLETE, _onTimerComplete); _local2.stop(); gotoNextSection(); } override protected function init():void{ var _local3:MovieClip; NextSectionClass = Level1CutScene; var _local1:TextField = (mc.getChildByName("header_txt") as TextField); if (_local1 != null){ itm.setText(_local1, "karma.choose"); _local1.mouseEnabled = false; } else { trace("\"header_txt\" missing from timeline"); }; var _local2:TextField = (mc.getChildByName("question_txt") as TextField); if (_local2 != null){ itm.setText(_local2, "karma.question"); _local2.mouseEnabled = false; } else { trace("\"question_txt\" missing from timeline"); }; var _local4:MovieClip = (mc.getChildByName("good_mc") as MovieClip); _local3 = (_local4.getChildByName("hitarea") as MovieClip); itm.setText(_local4.up.text_txt, "karma.good"); itm.setText(_local4.down.word_mc.text_txt, "karma.good"); _local4.getChildByName("over").visible = false; (_local4.getChildByName("over") as MovieClip).addEventListener(Event.ENTER_FRAME, _onGoodOverEnterFrame); _local4.getChildByName("down").visible = false; _local3.addEventListener(MouseEvent.ROLL_OVER, _onGoodRolledOver); _local3.addEventListener(MouseEvent.ROLL_OUT, _onGoodRolledOut); _local3.addEventListener(MouseEvent.CLICK, _onGoodClicked); _local3.mouseChildren = false; _local3.buttonMode = true; _local3.mouseEnabled = true; _local3.useHandCursor = true; var _local5:MovieClip = (mc.getChildByName("bad_mc") as MovieClip); _local3 = (_local5.getChildByName("hitarea") as MovieClip); itm.setText(_local5.up.text_txt, "karma.bad"); itm.setText(_local5.down.word_mc.text_txt, "karma.bad"); _local5.getChildByName("over").visible = false; (_local5.getChildByName("over") as MovieClip).addEventListener(Event.ENTER_FRAME, _onBadOverEnterFrame); _local5.getChildByName("down").visible = false; _local3.addEventListener(MouseEvent.ROLL_OVER, _onBadRolledOver); _local3.addEventListener(MouseEvent.ROLL_OUT, _onBadRolledOut); _local3.addEventListener(MouseEvent.CLICK, _onBadClicked); _local3.mouseChildren = false; _local3.buttonMode = true; _local3.mouseEnabled = true; _local3.useHandCursor = true; } private function _onGoodRolledOver(_arg1:MouseEvent):void{ var _local2:MovieClip = (mc.getChildByName("good_mc") as MovieClip); _local2.getChildByName("up").visible = false; _local2.getChildByName("over").visible = true; } private function _choiceMade():void{ _disableGoodAndBadHitAreas(); var _local1:Timer = new Timer(500, 1); _local1.addEventListener(TimerEvent.TIMER_COMPLETE, _onTimerComplete); _local1.start(); } private function _onBadOverEnterFrame(_arg1:Event):void{ var _local2:MovieClip = (mc.getChildByName("bad_mc") as MovieClip); var _local3:TextField = (_local2.over.word_mc.text_txt as TextField); if (_local3 != null){ itm.setText(_local3, "karma.bad"); } else { trace("over.word_mc.text_txt missing from timeline"); }; } private function _onBadRolledOut(_arg1:MouseEvent):void{ var _local2:MovieClip = (mc.getChildByName("bad_mc") as MovieClip); _local2.getChildByName("up").visible = true; _local2.getChildByName("over").visible = false; } private function _onGoodClicked(_arg1:MouseEvent):void{ var _local2:MovieClip = (mc.getChildByName("good_mc") as MovieClip); _local2.getChildByName("up").visible = false; _local2.getChildByName("over").visible = false; var _local3:MovieClip = (_local2.getChildByName("down") as MovieClip); _local3.visible = true; _local3.gotoAndStop(2); CurrentKarmaChoice.isGood = true; _choiceMade(); } private function _onGoodRolledOut(_arg1:MouseEvent):void{ var _local2:MovieClip = (mc.getChildByName("good_mc") as MovieClip); _local2.getChildByName("up").visible = true; _local2.getChildByName("over").visible = false; } } }//package com.kerb.infamous
Section 47
//Constants (com.kerb.infamous.Constants) package com.kerb.infamous { public final class Constants { public static const debugScore:Boolean = false; public static const viral:Boolean = true; public static const debug:Boolean = false; public static const unlockCode:String = "3662"; public static const noCompetitionCountries:Array = ["AU", "BE", "CZ", "EE", "HU", "LV", "NO", "NZ", "RU", "SK", "SI", "SE", "US"]; public static const competitionEndDate:Date = new Date(2009, 9, 31); public static const showIdent:Boolean = false; public static const highScoreURL:String = "savescore.php"; public static var useSystemFont:Boolean = false; public static var basePath:String = "http://www.infamousthegame.com/"; public static var locale:String = "en_GB"; public static var hackFontForDKAndNOLocales:Boolean = false; public static var lifeMessageShown:Boolean = false; public static var useSpecialWeapon:Boolean = false; public static var energyMessageShown:Boolean = false; public static var tutorialComplete:Boolean = false; } }//package com.kerb.infamous
Section 48
//CurrentKarmaChoice (com.kerb.infamous.CurrentKarmaChoice) package com.kerb.infamous { public class CurrentKarmaChoice { public static var isGood:Boolean; public function CurrentKarmaChoice(){ throw (new Error("class is static")); } } }//package com.kerb.infamous
Section 49
//FinalCutScene (com.kerb.infamous.FinalCutScene) package com.kerb.infamous { import flash.events.*; import com.kerb.utils.*; import flash.text.*; import com.kerb.infamous.game.screens.*; import com.kerb.infamous.game.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class FinalCutScene extends AbstractScreen { private var itm:InfamousTextManager; private var af:AssetFactory; private var textID:String; private var websiteButton:WebsiteButton; private var keyboardNavigator:KeyboardNavigator; public function FinalCutScene(_arg1:Boolean){ itm = InfamousTextManager.getInstance(); mc = Main.assetFactory.createMovieClip((_arg1) ? "FinalCutSceneGoodAsset" : "FinalCutSceneBadAsset"); textID = (_arg1) ? "cutscene.end.good." : "cutscene.end.bad."; addChild(mc); } private function onSkipMouseDown(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = true; } private function onSkipRollOut(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = true; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; } private function onSkipRollOver(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = true; mc.skip_btn.down.visible = false; } private function onSkipClick(_arg1:MouseEvent=null):void{ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_NEXT_LEVEL)); } override protected function init():void{ keyboardNavigator = new KeyboardNavigator(stage); keyboardNavigator.setDefaultAction(onSkipClick); keyboardNavigator.addInteractiveObject(mc.skip_btn, onSkipClick, 1); addEventListener(Event.ENTER_FRAME, onEnterFrame); mc.speech1.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech2.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech3.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech1.label_txt.text = " "; mc.speech2.label_txt.text = " "; mc.speech3.label_txt.text = " "; var _local1:Number = (mc.speech1.label_txt.y + mc.speech1.label_txt.textHeight); var _local2:Number = (mc.speech2.label_txt.y + mc.speech2.label_txt.textHeight); var _local3:Number = (mc.speech3.label_txt.y + mc.speech3.label_txt.textHeight); itm.setText(mc.speech1.label_txt, (textID + "1")); itm.setText(mc.speech2.label_txt, (textID + "2")); itm.setText(mc.speech3.label_txt, (textID + "3")); mc.speech1.label_txt.y = (_local1 - mc.speech1.label_txt.textHeight); mc.speech2.label_txt.y = (_local2 - mc.speech2.label_txt.textHeight); mc.speech3.label_txt.y = (_local3 - mc.speech3.label_txt.textHeight); websiteButton = new WebsiteButton(mc.website_btn); mc.skip_btn.addEventListener(MouseEvent.CLICK, onSkipClick, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OVER, onSkipRollOver, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OUT, onSkipRollOut, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSkipMouseDown, false, 0, true); itm.setText(mc.skip_btn.down.label_txt, "cutscene.skip"); mc.skip_btn.hitArea = mc.skip_btn.hit; mc.skip_btn.hit.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; mc.skip_btn.buttonMode = true; mc.skip_btn.mouseChildren = false; Main.smSFX.getSoundByClassName("BoomSound").play(); Main.smMusic.getSoundByClassName("ScreenMusicSound").play(0, 999999); } private function onEnterFrame(_arg1:Event):void{ itm.setText(mc.skip_btn.up.label.label_txt, "cutscene.skip"); itm.setText(mc.skip_btn.over.label.label_txt, "cutscene.skip"); if (mc.currentFrame == mc.totalFrames){ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_NEXT_LEVEL)); }; } override public function dispose():void{ mc.skip_btn.removeEventListener(MouseEvent.CLICK, onSkipClick); removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.infamous
Section 50
//GameComplete (com.kerb.infamous.GameComplete) package com.kerb.infamous { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.infamous.game.*; import flash.geom.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class GameComplete extends AbstractSection { private var playAgainLabel:String; private var score:int; private var mc:MovieClip; private var af:AssetFactory; private var websiteButton:WebsiteButton; private var ct:ColorTransform; private var submitLabel:String; private static const BAD_KARMA_COLOUR:uint = 13049374; private static const GOOD_KARMA_COLOUR:uint = 616959; public function GameComplete(){ score = Game.finalScore; trace(("FINAL SCORE:" + score)); af = Main.assetFactory; mc = af.createMovieClip("GameCompleteSectionAsset"); addChild(mc); Main.smMusic.getSoundByClassName("OutGameMusicSound").play(0, 999999); } private function onSubmitClick(_arg1:MouseEvent=null):void{ SubmitScore.submit(score); } private function onPlayAgainMouseDown(_arg1:MouseEvent):void{ mc.playAgain_btn.up.visible = false; mc.playAgain_btn.over.visible = false; mc.playAgain_btn.down.visible = true; } private function onSubmitMouseDown(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = false; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = true; } private function initSubmitButton():void{ mc.submit_btn.addEventListener(MouseEvent.CLICK, onSubmitClick, false, 0, true); mc.submit_btn.addEventListener(MouseEvent.ROLL_OVER, onSubmitRollOver, false, 0, true); mc.submit_btn.addEventListener(MouseEvent.ROLL_OUT, onSubmitRollOut, false, 0, true); mc.submit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSubmitMouseDown, false, 0, true); mc.submit_btn.buttonMode = true; mc.submit_btn.mouseChildren = false; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = false; mc.submit_btn.hitArea = mc.submit_btn.hit; mc.submit_btn.hit.visible = false; InfamousTextManager.getInstance().setText(mc.submit_btn.up.label_txt, "level.complete.submit"); InfamousTextManager.getInstance().setText(mc.submit_btn.down.label_txt, "level.complete.submit"); InfamousTextManager.getInstance().setText(mc.submit_btn.over.label.label_txt, "level.complete.submit"); mc.puma_logo.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.puma_logo.mouseChildren = false; mc.puma_logo.buttonMode = true; mc.blueSplat.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.blueSplat.mouseChildren = false; mc.blueSplat.buttonMode = true; mc.andWin.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.andWin.mouseChildren = false; mc.andWin.buttonMode = true; mc.shoe.addEventListener(MouseEvent.CLICK, onSubmitClick); mc.shoe.mouseChildren = false; mc.shoe.buttonMode = true; } private function onPlayAgainClick(_arg1:MouseEvent=null):void{ if (Constants.viral){ Tracking.event(Tracking.PLAY_AGAIN_VIRAL); } else { Tracking.event(Tracking.PLAY_AGAIN_SITE); }; Main.smMusic.getSoundByClassName("OutGameMusicSound").stop(); NextSectionClass = Title; gotoNextSection(); } private function initText():void{ var _local1:InfamousTextManager = InfamousTextManager.getInstance(); var _local2:String = _local1.getTextById("game.complete.title").toUpperCase(); var _local3:int = _local2.lastIndexOf(" "); _local1.setText(mc.levelComplete.label_txt); mc.levelComplete.label_txt.text = ((_local2.substring(0, _local3) + "\n") + _local2.substring((_local3 + 1))); _local1.setText(mc.scoreLabel.label_txt, "level.complete.total.score"); _local1.setText(mc.karmaLabel.label_txt, "level.complete.karma"); if (score < 0){ _local1.setText(mc.message.label_txt, "game.complete.bad"); } else { _local1.setText(mc.message.label_txt, "game.complete.good"); }; mc.tandc.btn.addEventListener(MouseEvent.CLICK, onTAndCLinkClick, false, 0, true); _local1.setText(mc.andWin.label_txt, "level.complete.title"); ct = new ColorTransform(); ct.color = ((score)<0) ? BAD_KARMA_COLOUR : GOOD_KARMA_COLOUR; mc.karma.alpha = 0; if (score < 0){ _local1.setText(mc.karma.label_txt, "level.complete.bad"); } else { _local1.setText(mc.karma.label_txt, "level.complete.good"); }; } override public function dispose():void{ mc.puma.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.blueSplat.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.andWin.removeEventListener(MouseEvent.CLICK, onSubmitClick); mc.shoe.removeEventListener(MouseEvent.CLICK, onSubmitClick); } private function onSubmitRollOver(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = false; mc.submit_btn.over.visible = true; mc.submit_btn.down.visible = false; } private function onPlayAgainRollOut(_arg1:MouseEvent):void{ mc.playAgain_btn.up.visible = true; mc.playAgain_btn.over.visible = false; mc.playAgain_btn.down.visible = false; } private function initPlayAgainButton():void{ mc.playAgain_btn.addEventListener(MouseEvent.CLICK, onPlayAgainClick, false, 0, true); mc.playAgain_btn.addEventListener(MouseEvent.ROLL_OVER, onPlayAgainRollOver, false, 0, true); mc.playAgain_btn.addEventListener(MouseEvent.ROLL_OUT, onPlayAgainRollOut, false, 0, true); mc.playAgain_btn.addEventListener(MouseEvent.MOUSE_DOWN, onPlayAgainMouseDown, false, 0, true); mc.playAgain_btn.buttonMode = true; mc.playAgain_btn.mouseChildren = false; mc.playAgain_btn.over.visible = false; mc.playAgain_btn.down.visible = false; mc.playAgain_btn.hitArea = mc.playAgain_btn.hit; mc.playAgain_btn.hit.visible = false; InfamousTextManager.getInstance().setText(mc.playAgain_btn.up.label_txt, "game.complete.play.again"); InfamousTextManager.getInstance().setText(mc.playAgain_btn.down.label_txt, "game.complete.play.again"); InfamousTextManager.getInstance().setText(mc.playAgain_btn.over.label.label_txt, "game.complete.play.again"); } override protected function init():void{ initText(); initSubmitButton(); initPlayAgainButton(); if (Constants.viral){ mc.playAgain_btn.visible = false; mc.playAgainBG.visible = false; } else { mc.tandc.visible = false; }; keyboardNavigator.setDefaultAction(onPlayAgainClick); keyboardNavigator.addInteractiveObject(mc.playAgain_btn, onPlayAgainClick, 1); websiteButton = new WebsiteButton(mc.website_btn); if (!Game.pumaAllowed){ mc.puma_logo.visible = false; mc.andWin.visible = false; mc.blueSplat.visible = false; mc.tandc.visible = false; mc.tandcBG.visible = false; mc.shoe.visible = false; }; if (!Constants.viral){ mc.tandc.visible = false; mc.tandcBG.visible = false; }; new GoodOrBadChoiceEndGame(mc); Main.smSFX.getSoundByClassName("BoomSound").play(); addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onTAndCLinkClick(_arg1:MouseEvent):void{ if (Constants.viral){ Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_VIRAL); } else { Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_SITE); }; } private function onSubmitRollOut(_arg1:MouseEvent):void{ mc.submit_btn.up.visible = true; mc.submit_btn.over.visible = false; mc.submit_btn.down.visible = false; } private function onEnterFrame(_arg1:Event):void{ var _local3:int; var _local2:int = mc.currentFrame; if (_local2 == 85){ score = Math.abs(score); } else { if (_local2 == 132){ mc.score.transform.colorTransform = ct; } else { if ((((_local2 > 200)) && ((_local2 < 215)))){ ct.alphaMultiplier = (ct.alphaMultiplier - 0.15); mc.karma.transform.colorTransform = ct; }; }; }; if (_local2 == 174){ mc.score.label_txt.text = ("0000" + score).substr(-4); } else { if ((((_local2 >= 132)) && ((_local2 < 174)))){ _local3 = (Math.random() * 9999); mc.score.label_txt.text = ("0000" + _local3).substr(-4); }; }; if ((((_local2 >= 175)) && ((_local2 < 200)))){ mc.karma.alpha = 1; mc.karma.transform.colorTransform = ct; }; } private function onPlayAgainRollOver(_arg1:MouseEvent):void{ mc.playAgain_btn.up.visible = false; mc.playAgain_btn.over.visible = true; mc.playAgain_btn.down.visible = false; } } }//package com.kerb.infamous
Section 51
//GoodOrBadChoiceEndGame (com.kerb.infamous.GoodOrBadChoiceEndGame) package com.kerb.infamous { import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class GoodOrBadChoiceEndGame { private var _clip:MovieClip; private static const BAD_KARMA_COLOUR:uint = 13049374; private static const GOOD_KARMA_COLOUR:uint = 616959; public function GoodOrBadChoiceEndGame(_arg1:MovieClip){ _clip = _arg1; _clip.addEventListener(Event.ENTER_FRAME, _onEnterFrame); } private function _initKarma():void{ var _local2:TextField; var _local3:ColorTransform; var _local1:MovieClip = (_clip.getChildByName("yourkarma") as MovieClip); if (_local1 != null){ _local2 = (_local1.getChildByName("label_txt") as TextField); _local3 = new ColorTransform(); if (CurrentKarmaChoice.isGood){ InfamousTextManager.getInstance().setText(_local2, "karma.good"); _local3.color = GOOD_KARMA_COLOUR; _local2.transform.colorTransform = _local3; } else { InfamousTextManager.getInstance().setText(_local2, "karma.bad"); _local3.color = BAD_KARMA_COLOUR; _local2.transform.colorTransform = _local3; }; } else { trace("\"yourkarma\" missing from timeline"); }; } private function _onEnterFrame(_arg1:Event):void{ if (_clip.currentFrame > 80){ _clip.removeEventListener(Event.ENTER_FRAME, _onEnterFrame); _initYouChose(); _initKarma(); }; } private function _initYouChose():void{ var _local1:TextField = (_clip.getChildByName("youChose_txt") as TextField); if (_local1 != null){ InfamousTextManager.getInstance().setText(_local1, "level.complete.chose"); } else { trace("\"youChose_txt\" missing from timeline"); }; } } }//package com.kerb.infamous
Section 52
//InfamousTextManager (com.kerb.infamous.InfamousTextManager) package com.kerb.infamous { import com.kerb.utils.*; import flash.text.*; public class InfamousTextManager extends TextManager { private static const TITLE_TEXTS:Array = new Array("title.title", "title.minigame"); private static var instance:InfamousTextManager; private function _applyPolishAndRussianHack(_arg1:TextField, _arg2:String):void{ var size:Number; var tf = _arg1; var id = _arg2; var fmt:TextFormat = new TextFormat(); try { if (TITLE_TEXTS.indexOf(id) != -1){ size = parseFloat(tf.getTextFormat().size.toString()); if (size > 10){ fmt.size = ((size * 20) / 23); } else { fmt.size = 11; }; }; } catch(err:Error) { trace("Couldn't get the size!"); }; fmt.font = "Impact"; fmt.bold = true; tf.embedFonts = true; tf.defaultTextFormat = fmt; tf.setTextFormat(fmt); } private function _applyNorwegianAndDanishHack(_arg1:TextField, _arg2:String):String{ var _local4:String; var _local5:Array; var _local6:Boolean; var _local7:String; var _local3:TextFormat = _arg1.getTextFormat(); if (((!((_local3.font == null))) && ((_local3.font.toLowerCase() == "cracked")))){ _local4 = ""; _local5 = _arg2.split(""); _local6 = false; for each (_local7 in _local5) { if (_local7.charCodeAt() == 198){ _local4 = (_local4 + String.fromCharCode(230)); _local6 = true; } else { _local4 = (_local4 + _local7); }; }; _arg2 = (_local6) ? _local4.toLowerCase() : _local4; }; return (_arg2); } public function setText(_arg1:TextField, _arg2:String=null, _arg3:Boolean=true):void{ var _local4:String; if (Constants.useSystemFont){ _applyPolishAndRussianHack(_arg1, _arg2); }; if (_arg2 != null){ _local4 = getTextById(_arg2); if (Constants.hackFontForDKAndNOLocales){ _local4 = _applyNorwegianAndDanishHack(_arg1, _local4); _arg1.text = _local4; } else { _arg1.text = (_arg3) ? _local4.toUpperCase() : _local4; }; }; } public static function getInstance():InfamousTextManager{ if (instance == null){ instance = new (InfamousTextManager); }; return (instance); } } }//package com.kerb.infamous
Section 53
//Level1CutScene (com.kerb.infamous.Level1CutScene) package com.kerb.infamous { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import flash.text.*; import com.kerb.infamous.game.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class Level1CutScene extends AbstractSection { private var itm:InfamousTextManager; private var af:AssetFactory; private var websiteButton:WebsiteButton; private var mc:MovieClip; public function Level1CutScene(){ itm = InfamousTextManager.getInstance(); af = Main.assetFactory; mc = af.createMovieClip("Level1CutSceneAsset"); addChild(mc); } override public function dispose():void{ mc.skip_btn.removeEventListener(MouseEvent.CLICK, onSkipClick); removeEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onSkipMouseDown(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = true; } private function onSkipRollOut(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = true; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; } private function onSkipRollOver(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = true; mc.skip_btn.down.visible = false; } override protected function init():void{ keyboardNavigator.setDefaultAction(onSkipClick); keyboardNavigator.addInteractiveObject(mc.skip_btn, onSkipClick, 1); addEventListener(Event.ENTER_FRAME, onEnterFrame); NextSectionClass = Game; mc.speech1.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech2.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech3.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech4.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech2.label_txt.text = " "; mc.speech3.label_txt.text = " "; var _local1:Number = (mc.speech2.label_txt.y + mc.speech2.label_txt.textHeight); var _local2:Number = (mc.speech3.label_txt.y + mc.speech3.label_txt.textHeight); itm.setText(mc.speech1.label_txt, "cutscene.1.1"); itm.setText(mc.speech2.label_txt, "cutscene.1.2"); itm.setText(mc.speech3.label_txt, "cutscene.1.3"); itm.setText(mc.speech4.label_txt, "cutscene.1.4"); mc.speech2.label_txt.y = (_local1 - mc.speech2.label_txt.textHeight); mc.speech3.label_txt.y = (_local2 - mc.speech3.label_txt.textHeight); websiteButton = new WebsiteButton(mc.website_btn); mc.skip_btn.addEventListener(MouseEvent.CLICK, onSkipClick, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OVER, onSkipRollOver, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OUT, onSkipRollOut, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSkipMouseDown, false, 0, true); itm.setText(mc.skip_btn.down.label_txt, "cutscene.skip"); itm.setText(mc.skip_btn.up.label.label_txt, "cutscene.skip"); itm.setText(mc.skip_btn.over.label.label_txt, "cutscene.skip"); mc.skip_btn.hitArea = mc.skip_btn.hit; mc.skip_btn.hit.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; mc.skip_btn.buttonMode = true; mc.skip_btn.mouseChildren = false; Main.smSFX.getSoundByClassName("BoomSound").play(); } private function onSkipClick(_arg1:MouseEvent=null):void{ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); gotoNextSection(); } private function onEnterFrame(_arg1:Event):void{ if (mc.currentFrame == mc.totalFrames){ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); gotoNextSection(); }; } } }//package com.kerb.infamous
Section 54
//Level2CutScene (com.kerb.infamous.Level2CutScene) package com.kerb.infamous { import flash.events.*; import com.kerb.utils.*; import flash.text.*; import com.kerb.infamous.game.screens.*; import com.kerb.infamous.game.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class Level2CutScene extends AbstractScreen { private var itm:InfamousTextManager; private var af:AssetFactory; private var websiteButton:WebsiteButton; private var keyboardNavigator:KeyboardNavigator; public function Level2CutScene(){ itm = InfamousTextManager.getInstance(); af = Main.assetFactory; mc = af.createMovieClip("Level2CutSceneAsset"); addChild(mc); } override public function dispose():void{ mc.skip_btn.removeEventListener(MouseEvent.CLICK, onSkipClick); removeEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onSkipMouseDown(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = true; } private function onSkipRollOut(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = true; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; } private function onSkipRollOver(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = true; mc.skip_btn.down.visible = false; } private function onSkipClick(_arg1:MouseEvent=null):void{ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_NEXT_LEVEL)); } private function onEnterFrame(_arg1:Event):void{ if (mc.currentFrame == mc.totalFrames){ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_NEXT_LEVEL)); }; } override protected function init():void{ keyboardNavigator = new KeyboardNavigator(stage); keyboardNavigator.setDefaultAction(onSkipClick); keyboardNavigator.addInteractiveObject(mc.skip_btn, onSkipClick, 1); addEventListener(Event.ENTER_FRAME, onEnterFrame); mc.speech1.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech2.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech1.label_txt.text = " "; mc.speech2.label_txt.text = " "; var _local1:Number = 270; var _local2:Number = 210; itm.setText(mc.speech1.label_txt, "cutscene.2.1"); itm.setText(mc.speech2.label_txt, "cutscene.2.2"); mc.speech1.label_txt.y = (_local1 - mc.speech1.label_txt.textHeight); mc.speech2.label_txt.y = (_local2 - mc.speech2.label_txt.textHeight); websiteButton = new WebsiteButton(mc.website_btn); mc.skip_btn.addEventListener(MouseEvent.CLICK, onSkipClick, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OVER, onSkipRollOver, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OUT, onSkipRollOut, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSkipMouseDown, false, 0, true); itm.setText(mc.skip_btn.down.label_txt, "cutscene.skip"); itm.setText(mc.skip_btn.up.label.label_txt, "cutscene.skip"); itm.setText(mc.skip_btn.over.label.label_txt, "cutscene.skip"); mc.skip_btn.hitArea = mc.skip_btn.hit; mc.skip_btn.hit.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; mc.skip_btn.buttonMode = true; mc.skip_btn.mouseChildren = false; Main.smSFX.getSoundByClassName("BoomSound").play(); Main.smMusic.getSoundByClassName("ScreenMusicSound").play(0, 999999); } } }//package com.kerb.infamous
Section 55
//Level3CutScene (com.kerb.infamous.Level3CutScene) package com.kerb.infamous { import flash.events.*; import com.kerb.utils.*; import flash.text.*; import com.kerb.infamous.game.screens.*; import com.kerb.infamous.game.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class Level3CutScene extends AbstractScreen { private var itm:InfamousTextManager; private var af:AssetFactory; private var websiteButton:WebsiteButton; private var keyboardNavigator:KeyboardNavigator; public function Level3CutScene(){ itm = InfamousTextManager.getInstance(); af = Main.assetFactory; mc = af.createMovieClip("Level3CutSceneAsset"); addChild(mc); } override public function dispose():void{ mc.skip_btn.removeEventListener(MouseEvent.CLICK, onSkipClick); removeEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onSkipMouseDown(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = true; } private function onSkipRollOut(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = true; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; } private function onSkipRollOver(_arg1:MouseEvent):void{ mc.skip_btn.up.visible = false; mc.skip_btn.over.visible = true; mc.skip_btn.down.visible = false; } private function onSkipClick(_arg1:MouseEvent=null):void{ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_NEXT_LEVEL)); } private function onEnterFrame(_arg1:Event):void{ if (mc.currentFrame == mc.totalFrames){ Main.smMusic.getSoundByClassName("ScreenMusicSound").stop(); dispatchEvent(new Event(Game.EVENT_NEXT_LEVEL)); }; } override protected function init():void{ keyboardNavigator = new KeyboardNavigator(stage); keyboardNavigator.setDefaultAction(onSkipClick); keyboardNavigator.addInteractiveObject(mc.skip_btn, onSkipClick, 1); addEventListener(Event.ENTER_FRAME, onEnterFrame); mc.speech1.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech2.label_txt.autoSize = TextFieldAutoSize.LEFT; mc.speech2.label_txt.text = " "; var _local1:Number = (mc.speech2.label_txt.y + mc.speech2.label_txt.textHeight); itm.setText(mc.speech1.label_txt); mc.speech1.label_txt.text = itm.getTextById("cutscene.3.1").toUpperCase(); mc.speech1.label_txt.text = (mc.speech1.label_txt.text + (" " + itm.getTextById("cutscene.3.2").toUpperCase())); itm.setText(mc.speech2.label_txt); mc.speech2.label_txt.text = itm.getTextById("cutscene.3.3").toUpperCase(); mc.speech2.label_txt.text = (mc.speech2.label_txt.text + (" " + itm.getTextById("cutscene.3.4").toUpperCase())); mc.speech2.label_txt.y = (_local1 - mc.speech2.label_txt.textHeight); websiteButton = new WebsiteButton(mc.website_btn); mc.skip_btn.addEventListener(MouseEvent.CLICK, onSkipClick, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OVER, onSkipRollOver, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.ROLL_OUT, onSkipRollOut, false, 0, true); mc.skip_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSkipMouseDown, false, 0, true); itm.setText(mc.skip_btn.down.label_txt, "cutscene.skip"); itm.setText(mc.skip_btn.up.label.label_txt, "cutscene.skip"); itm.setText(mc.skip_btn.over.label.label_txt, "cutscene.skip"); mc.skip_btn.hitArea = mc.skip_btn.hit; mc.skip_btn.hit.visible = false; mc.skip_btn.over.visible = false; mc.skip_btn.down.visible = false; mc.skip_btn.buttonMode = true; mc.skip_btn.mouseChildren = false; Main.smSFX.getSoundByClassName("BoomSound").play(); Main.smMusic.getSoundByClassName("ScreenMusicSound").play(0, 999999); } } }//package com.kerb.infamous
Section 56
//Main (com.kerb.infamous.Main) package com.kerb.infamous { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.sound.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; public class Main extends AbstractMain { public var text_fr_BE:Class; public var text_fr_FR:Class; public var text_de_AT:Class; public var text_sv_SE:Class; public var text_pl_PL:Class; public var text_en_GB:Class; public var text_it_IT:Class; public var text_pt_PT:Class; private var SWFBytes:Class; public var text_ru_RU:Class; public var text_fr_CH:Class; public var text_fi_FI:Class; public var text_fr_LU:Class; public var text_es_ES:Class; private var soundControl:SoundControl; public var text_de_CH:Class; public var text_nl_NL:Class; public var text_nl_BE:Class; public var text_it_CH:Class; public var text_de_DE:Class; public var text_no_NO:Class; public var text_de_LU:Class; public var text_da_DK:Class; public var text_longest:Class; public static var smSFX:SoundManager; public static var assetFactory:AssetFactory; public static var smMusic:SoundManager; public function Main(_arg1:Class){ text_da_DK = Main_text_da_DK; text_de_AT = Main_text_de_AT; text_de_CH = Main_text_de_CH; text_de_DE = Main_text_de_DE; text_de_LU = Main_text_de_LU; text_en_GB = Main_text_en_GB; text_es_ES = Main_text_es_ES; text_fi_FI = Main_text_fi_FI; text_fr_BE = Main_text_fr_BE; text_fr_CH = Main_text_fr_CH; text_fr_FR = Main_text_fr_FR; text_fr_LU = Main_text_fr_LU; text_it_CH = Main_text_it_CH; text_it_IT = Main_text_it_IT; text_longest = Main_text_longest; text_nl_BE = Main_text_nl_BE; text_nl_NL = Main_text_nl_NL; text_no_NO = Main_text_no_NO; text_pl_PL = Main_text_pl_PL; text_pt_PT = Main_text_pt_PT; text_ru_RU = Main_text_ru_RU; text_sv_SE = Main_text_sv_SE; super(); this.SWFBytes = _arg1; addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } private function init():void{ initTracking(); initText(); initSounds(); } protected function onAssetFactoryReady(_arg1:Event):void{ assetFactory.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); init(); start(); } private function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); assetFactory = new AssetFactory(); assetFactory.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); assetFactory.initialize(SWFBytes); } override protected function onIdentComplete(_arg1:Event):void{ soundControl.mc.visible = true; super.onIdentComplete(_arg1); } private function initText():void{ var _local1:Class; if ((((Constants.locale == "pl_PL")) || ((Constants.locale == "ru_RU")))){ Constants.useSystemFont = true; }; if ((((Constants.locale == "da_DK")) || ((Constants.locale == "no_NO")))){ Constants.hackFontForDKAndNOLocales = true; }; if ((((((((Constants.locale == "en_IE")) || ((Constants.locale == "en_NZ")))) || ((Constants.locale == "en_AU")))) || ((Constants.locale == "en_US")))){ _local1 = this["text_en_GB"]; } else { _local1 = this[("text_" + Constants.locale)]; }; InfamousTextManager.getInstance().initFromClass(_local1); } private function start():void{ var _local1:MovieClip; if (Constants.showIdent){ _local1 = assetFactory.createMovieClip("IdentAsset"); showIdent(_local1, Title); } else { gotoSection(Title); }; } private function initTracking():void{ Tracking.init(root); } private function initSounds():void{ var _local1:int; var _local2:int; smMusic = new SoundManager(); smSFX = new SoundManager(); smMusic.registerSound(assetFactory.createExtendedSound("InGameMusicSound")); smMusic.registerSound(assetFactory.createExtendedSound("OutGameMusicSound")); smMusic.registerSound(assetFactory.createExtendedSound("ScreenMusicSound")); smSFX.registerSound(assetFactory.createExtendedSound("BoomSound")); smSFX.registerSound(assetFactory.createExtendedSound("ChargingSound")); smSFX.registerSound(assetFactory.createExtendedSound("FloatJumpSound")); smSFX.registerSound(assetFactory.createExtendedSound("HealingSound")); smSFX.registerSound(assetFactory.createExtendedSound("LightningSound")); smSFX.registerSound(assetFactory.createExtendedSound("TKBlastSound")); smSFX.registerSound(assetFactory.createExtendedSound("GrenadeThrowSound")); smSFX.registerSound(assetFactory.createExtendedSound("GrenadeExplosionSound")); smSFX.registerSound(assetFactory.createExtendedSound("MegawattThrowSound")); smSFX.registerSound(assetFactory.createExtendedSound("MegawattExplosionSound")); smSFX.registerSound(assetFactory.createExtendedSound("JumpLandSound")); smSFX.registerSound(assetFactory.createExtendedSound("FloatLandSound")); smSFX.registerSound(assetFactory.createExtendedSound("LeftLegSound")); smSFX.registerSound(assetFactory.createExtendedSound("RightLegSound")); smSFX.registerSound(assetFactory.createExtendedSound("CrouchDownSound")); smSFX.registerSound(assetFactory.createExtendedSound("CrouchUpSound")); smSFX.registerSound(assetFactory.createExtendedSound("TurnSound")); smSFX.registerSound(assetFactory.createExtendedSound("ReaperMachineGunSound")); smSFX.registerSound(assetFactory.createExtendedSound("ReaperRifleSound")); smSFX.registerSound(assetFactory.createExtendedSound("DoorOpenSound")); smSFX.registerSound(assetFactory.createExtendedSound("LockSound")); smSFX.registerSound(assetFactory.createExtendedSound("WaterSound")); smSFX.registerSound(assetFactory.createExtendedSound("ElectrocutedSound")); smSFX.registerSound(assetFactory.createExtendedSound("GeneratorSound")); smSFX.registerSound(assetFactory.createExtendedSound("ScreamSound")); _local1 = 0; while (_local1 < 19) { smSFX.registerSound(assetFactory.createExtendedSound((("Cole" + _local1) + "Sound"))); _local1++; }; _local1 = 0; while (_local1 < 7) { smSFX.registerSound(assetFactory.createExtendedSound((("Reaper" + _local1) + "Sound"))); _local1++; }; _local1 = 0; while (_local1 < 3) { _local2 = 1; while (_local2 <= 4) { smSFX.registerSound(assetFactory.createExtendedSound(((("Ped" + _local2) + _local1) + "Sound"))); _local2++; }; _local1++; }; var _local3:MovieClip = assetFactory.createMovieClip("SoundControlAsset"); soundControl = new SoundControl(_local3, smMusic, smSFX); overlaySprite.addChild(_local3); overlaySprite.mouseEnabled = false; _local3.x = 0x0200; _local3.y = 16; } } }//package com.kerb.infamous
Section 57
//Main_text_da_DK (com.kerb.infamous.Main_text_da_DK) package com.kerb.infamous { import mx.core.*; public class Main_text_da_DK extends ByteArrayAsset { } }//package com.kerb.infamous
Section 58
//Main_text_de_AT (com.kerb.infamous.Main_text_de_AT) package com.kerb.infamous { import mx.core.*; public class Main_text_de_AT extends ByteArrayAsset { } }//package com.kerb.infamous
Section 59
//Main_text_de_CH (com.kerb.infamous.Main_text_de_CH) package com.kerb.infamous { import mx.core.*; public class Main_text_de_CH extends ByteArrayAsset { } }//package com.kerb.infamous
Section 60
//Main_text_de_DE (com.kerb.infamous.Main_text_de_DE) package com.kerb.infamous { import mx.core.*; public class Main_text_de_DE extends ByteArrayAsset { } }//package com.kerb.infamous
Section 61
//Main_text_de_LU (com.kerb.infamous.Main_text_de_LU) package com.kerb.infamous { import mx.core.*; public class Main_text_de_LU extends ByteArrayAsset { } }//package com.kerb.infamous
Section 62
//Main_text_en_GB (com.kerb.infamous.Main_text_en_GB) package com.kerb.infamous { import mx.core.*; public class Main_text_en_GB extends ByteArrayAsset { } }//package com.kerb.infamous
Section 63
//Main_text_es_ES (com.kerb.infamous.Main_text_es_ES) package com.kerb.infamous { import mx.core.*; public class Main_text_es_ES extends ByteArrayAsset { } }//package com.kerb.infamous
Section 64
//Main_text_fi_FI (com.kerb.infamous.Main_text_fi_FI) package com.kerb.infamous { import mx.core.*; public class Main_text_fi_FI extends ByteArrayAsset { } }//package com.kerb.infamous
Section 65
//Main_text_fr_BE (com.kerb.infamous.Main_text_fr_BE) package com.kerb.infamous { import mx.core.*; public class Main_text_fr_BE extends ByteArrayAsset { } }//package com.kerb.infamous
Section 66
//Main_text_fr_CH (com.kerb.infamous.Main_text_fr_CH) package com.kerb.infamous { import mx.core.*; public class Main_text_fr_CH extends ByteArrayAsset { } }//package com.kerb.infamous
Section 67
//Main_text_fr_FR (com.kerb.infamous.Main_text_fr_FR) package com.kerb.infamous { import mx.core.*; public class Main_text_fr_FR extends ByteArrayAsset { } }//package com.kerb.infamous
Section 68
//Main_text_fr_LU (com.kerb.infamous.Main_text_fr_LU) package com.kerb.infamous { import mx.core.*; public class Main_text_fr_LU extends ByteArrayAsset { } }//package com.kerb.infamous
Section 69
//Main_text_it_CH (com.kerb.infamous.Main_text_it_CH) package com.kerb.infamous { import mx.core.*; public class Main_text_it_CH extends ByteArrayAsset { } }//package com.kerb.infamous
Section 70
//Main_text_it_IT (com.kerb.infamous.Main_text_it_IT) package com.kerb.infamous { import mx.core.*; public class Main_text_it_IT extends ByteArrayAsset { } }//package com.kerb.infamous
Section 71
//Main_text_longest (com.kerb.infamous.Main_text_longest) package com.kerb.infamous { import mx.core.*; public class Main_text_longest extends ByteArrayAsset { } }//package com.kerb.infamous
Section 72
//Main_text_nl_BE (com.kerb.infamous.Main_text_nl_BE) package com.kerb.infamous { import mx.core.*; public class Main_text_nl_BE extends ByteArrayAsset { } }//package com.kerb.infamous
Section 73
//Main_text_nl_NL (com.kerb.infamous.Main_text_nl_NL) package com.kerb.infamous { import mx.core.*; public class Main_text_nl_NL extends ByteArrayAsset { } }//package com.kerb.infamous
Section 74
//Main_text_no_NO (com.kerb.infamous.Main_text_no_NO) package com.kerb.infamous { import mx.core.*; public class Main_text_no_NO extends ByteArrayAsset { } }//package com.kerb.infamous
Section 75
//Main_text_pl_PL (com.kerb.infamous.Main_text_pl_PL) package com.kerb.infamous { import mx.core.*; public class Main_text_pl_PL extends ByteArrayAsset { } }//package com.kerb.infamous
Section 76
//Main_text_pt_PT (com.kerb.infamous.Main_text_pt_PT) package com.kerb.infamous { import mx.core.*; public class Main_text_pt_PT extends ByteArrayAsset { } }//package com.kerb.infamous
Section 77
//Main_text_ru_RU (com.kerb.infamous.Main_text_ru_RU) package com.kerb.infamous { import mx.core.*; public class Main_text_ru_RU extends ByteArrayAsset { } }//package com.kerb.infamous
Section 78
//Main_text_sv_SE (com.kerb.infamous.Main_text_sv_SE) package com.kerb.infamous { import mx.core.*; public class Main_text_sv_SE extends ByteArrayAsset { } }//package com.kerb.infamous
Section 79
//Preload (com.kerb.infamous.Preload) package com.kerb.infamous { import flash.events.*; import flash.display.*; import com.kerb.game.*; import com.kerb.utils.*; import flash.utils.*; import flash.net.*; public class Preload extends AbstractPreload { private var af:AssetFactory; private var SWFBytes:Class; private var mc:MovieClip; public function Preload(){ SWFBytes = Preload_SWFBytes; super(); stop(); af = new AssetFactory(); af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); af.initialize(SWFBytes); } private function drawLetterbox():void{ var _local1:int = loaderInfo.width; var _local2:int = loaderInfo.height; var _local3:Sprite = new Sprite(); var _local4:Graphics = _local3.graphics; _local4.beginFill(0); _local4.drawRect(-1000, -1000, (2000 + _local1), 1000); _local4.drawRect(-1000, _local2, (2000 + _local1), 1000); _local4.drawRect(-1000, -1000, 1000, (1000 + _local2)); _local4.drawRect(_local1, -1000, 1000, (1000 + _local2)); _local4.endFill(); addChild(_local3); } private function preloadComplete():void{ var _local1:Class; if (currentFrame == 1){ nextFrame(); } else { removeEventListener(Event.ENTER_FRAME, onEnterFrame); _local1 = Class(getDefinitionByName("InFamous")); addChild((new (_local1) as DisplayObject)); removeChild(mc); mc = null; }; } private function onPlaystationClick(_arg1:MouseEvent):void{ navigateToURL(new URLRequest("http://eu.playstation.com"), "_blank"); } private function onAssetFactoryReady(_arg1:Event):void{ af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); mc = (af.createDisplayObject("PreloadAsset") as MovieClip); addChildAt(mc, 0); af = null; if (Constants.viral){ mc.playstation_btn.addEventListener(MouseEvent.CLICK, onPlaystationClick, false, 0, true); mc.playstation_btn.buttonMode = true; } else { mc.playstation_btn.visible = false; mc.legal.visible = false; }; checkFlashvars(); drawLetterbox(); addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function checkFlashvars():void{ if (((root.loaderInfo.parameters.locale) && (!(Constants.viral)))){ Constants.locale = root.loaderInfo.parameters.locale; }; if (root.loaderInfo.parameters.basePath){ Constants.basePath = root.loaderInfo.parameters.basePath; }; } private function onEnterFrame(_arg1:Event):void{ var _local2:int = root.loaderInfo.bytesLoaded; var _local3:int = root.loaderInfo.bytesTotal; var _local4:int = Math.ceil(((100 * _local2) / _local3)); mc.percent_txt.text = _local4; if (mc.currentFrame != _local4){ mc.gotoAndStop(_local4); }; if (_local4 == 100){ preloadComplete(); }; } } }//package com.kerb.infamous
Section 80
//Preload_SWFBytes (com.kerb.infamous.Preload_SWFBytes) package com.kerb.infamous { import mx.core.*; public class Preload_SWFBytes extends ByteArrayAsset { } }//package com.kerb.infamous
Section 81
//SubmitScore (com.kerb.infamous.SubmitScore) package com.kerb.infamous { import flash.events.*; import flash.net.*; public class SubmitScore { private static var loader:URLLoader; public static function submit(_arg1:int):void{ var _local2:URLVariables = new URLVariables(); _local2.score = _arg1; var _local3:URLRequest = new URLRequest((Constants.basePath + Constants.highScoreURL)); _local3.method = URLRequestMethod.POST; _local3.data = _local2; if (Constants.viral){ Tracking.event(Tracking.SUBMIT_HIGH_SCORE_VIRAL); } else { Tracking.event(Tracking.SUBMIT_HIGH_SCORE_SITE); }; navigateToURL(_local3, (Constants.viral) ? "_blank" : "_self"); } private static function onError(_arg1:IOErrorEvent=null):void{ loader.removeEventListener(Event.COMPLETE, onSaved); loader.removeEventListener(IOErrorEvent.IO_ERROR, onError); } private static function onSaved(_arg1:Event):void{ loader.removeEventListener(Event.COMPLETE, onSaved); loader.removeEventListener(IOErrorEvent.IO_ERROR, onError); if (loader.data.id){ }; } } }//package com.kerb.infamous
Section 82
//Title (com.kerb.infamous.Title) package com.kerb.infamous { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import flash.text.*; import com.kerb.game.*; import com.kerb.infamous.ui.*; import flash.ui.*; public class Title extends AbstractSection { private var mc:MovieClip; private var unlockHintShowing:Boolean; private var af:AssetFactory; private var websiteButton:WebsiteButton; public function Title(){ af = Main.assetFactory; mc = af.createMovieClip("TitleSectionAsset"); addChild(mc); } private function onDropDownRollOver(_arg1:MouseEvent):void{ mc.unlock.dropdown.gotoAndPlay("show"); } private function onKeyDown(_arg1:KeyboardEvent):void{ var _local2 = (_arg1.keyCode == Keyboard.ENTER); var _local3 = (_arg1.keyCode == Keyboard.SPACE); if (stage.focus == mc.unlock.input_txt){ if (_local2){ checkUnlockInput(); }; } else { if (((_local2) || (_local3))){ onStartClick(); }; }; } private function onGetCodeMouseDown(_arg1:MouseEvent):void{ _arg1.currentTarget.up.visible = false; _arg1.currentTarget.over.visible = false; _arg1.currentTarget.down.visible = true; } private function initStartButton():void{ mc.start_btn.addEventListener(MouseEvent.CLICK, onStartClick, false, 0, true); mc.start_btn.addEventListener(MouseEvent.ROLL_OVER, onStartRollOver, false, 0, true); mc.start_btn.addEventListener(MouseEvent.ROLL_OUT, onStartRollOut, false, 0, true); mc.start_btn.addEventListener(MouseEvent.MOUSE_DOWN, onStartMouseDown, false, 0, true); mc.start_btn.buttonMode = true; mc.start_btn.mouseChildren = false; mc.start_btn.over.visible = false; mc.start_btn.down.visible = false; mc.start_btn.hitArea = mc.startHitArea; mc.startHitArea.visible = false; mc.startHitArea.mouseEnabled = false; } private function initGetCodeButton():void{ var _local1:MovieClip = mc.unlock.dropdown.panel.unlock_btn; _local1.addEventListener(MouseEvent.CLICK, onGetCodeClick, false, 0, true); _local1.addEventListener(MouseEvent.ROLL_OVER, onGetCodeRollOver, false, 0, true); _local1.addEventListener(MouseEvent.ROLL_OUT, onGetCodeRollOut, false, 0, true); _local1.addEventListener(MouseEvent.MOUSE_DOWN, onGetCodeMouseDown, false, 0, true); _local1.buttonMode = true; _local1.mouseChildren = false; _local1.over.visible = false; _local1.down.visible = false; _local1.hitArea = _local1.hit; _local1.hit.visible = false; _local1.hit.mouseEnabled = false; InfamousTextManager.getInstance().setText(_local1.up.label_txt, "title.unlock.get"); InfamousTextManager.getInstance().setText(_local1.down.label_txt, "title.unlock.get"); } private function onDropDownRollOut(_arg1:MouseEvent):void{ mc.unlock.dropdown.gotoAndPlay("hide"); } private function onForceToUpperCase(_arg1:Event):void{ mc.unlock.input_txt.text = mc.unlock.input_txt.text.toUpperCase(); } private function onEnterFrame(_arg1:Event):void{ var _local2:String; var _local3:InfamousTextManager; if (mc.currentFrame == (mc.totalFrames - 5)){ Main.smSFX.getSoundByClassName("BoomSound").play(); _local3 = InfamousTextManager.getInstance(); _local3.setText(mc.start_btn.up.label.label_txt, "title.start.button"); _local3.setText(mc.start_btn.over.label.label_txt, "title.start.button"); _local3.setText(mc.start_btn.down.label.label_txt, "title.start.button"); _local3.setText(mc.unlock.dropdown.panel.unlock_btn.over.label.label_txt, "title.unlock.get"); }; } private function onUnlockSubmitClick(_arg1:MouseEvent):void{ checkUnlockInput(); } private function onStartRollOut(_arg1:MouseEvent):void{ mc.start_btn.up.visible = true; mc.start_btn.over.visible = false; mc.start_btn.down.visible = false; } override protected function init():void{ stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); addEventListener(Event.ENTER_FRAME, onEnterFrame); initStartButton(); initUnlock(); websiteButton = new WebsiteButton(mc.website_btn); if (Constants.viral){ mc.playstation_btn.addEventListener(MouseEvent.CLICK, onPlaystationClick); mc.playstation_btn.buttonMode = true; } else { mc.playstation_btn.visible = false; mc.legal.visible = false; }; Main.smMusic.getSoundByClassName("ScreenMusicSound").play(0, 999999); } private function onUnlockInputFocus(_arg1:Event):void{ if (unlockHintShowing){ unlockHintShowing = false; mc.unlock.input_txt.text = ""; }; stage.focus = mc.unlock.input_txt; } private function onStartRollOver(_arg1:MouseEvent):void{ mc.start_btn.up.visible = false; mc.start_btn.over.visible = true; mc.start_btn.down.visible = false; } private function onGetCodeRollOver(_arg1:MouseEvent):void{ _arg1.currentTarget.up.visible = false; _arg1.currentTarget.over.visible = true; _arg1.currentTarget.down.visible = false; } private function onStartClick(_arg1:MouseEvent=null):void{ mc.start_btn.removeEventListener(MouseEvent.CLICK, onStartClick); NextSectionClass = ChooseKarma; gotoNextSection(); } override public function dispose():void{ super.dispose(); removeEventListener(Event.ENTER_FRAME, onEnterFrame); stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); mc.unlock.submit_btn.removeEventListener(MouseEvent.CLICK, onUnlockSubmitClick); mc.unlock.input_txt.removeEventListener(FocusEvent.FOCUS_IN, onUnlockInputFocus); mc.unlock.input_txt.removeEventListener(Event.CHANGE, onForceToUpperCase); mc.playstation_btn.removeEventListener(MouseEvent.CLICK, onPlaystationClick); } private function onStartMouseDown(_arg1:MouseEvent):void{ mc.start_btn.up.visible = false; mc.start_btn.over.visible = false; mc.start_btn.down.visible = true; } private function onPlaystationClick(_arg1:MouseEvent):void{ if (Constants.viral){ Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_VIRAL); } else { Tracking.click(Tracking.WEBSITE_CLICKTHROUGH_SITE); }; } private function onGetCodeClick(_arg1:MouseEvent):void{ if (Constants.viral){ Tracking.click(Tracking.GET_POWER_CODE_VIRAL); } else { Tracking.click(Tracking.GET_POWER_CODE_SITE); }; } private function initUnlock():void{ var _local1:InfamousTextManager = InfamousTextManager.getInstance(); _local1.setText(mc.unlock.title_txt, "title.unlock.title"); _local1.setText(mc.unlock.input_txt, "title.unlock.input"); _local1.setText(mc.unlock.success_txt, "title.unlock.success"); _local1.setText(mc.unlock.dropdown.panel.label_txt, "title.unlock.instructions"); mc.titleMask.mouseEnabled = false; mc.titleMask.mouseChildren = false; mc.straplineMask.mouseEnabled = false; mc.straplineMask.mouseChildren = false; var _local2:Number = (mc.titleMask.title_txt as TextField).textHeight; _local1.setText(mc.titleMask.title_txt, "title.title"); _local1.setText(mc.straplineMask.strapline_txt, "title.minigame"); var _local3:Number = (mc.titleMask.title_txt as TextField).textHeight; var _local4:Number = (_local3 - _local2); mc.straplineMask.strapline_txt.y = (mc.straplineMask.strapline_txt.y + _local4); mc.unlock.success.visible = false; mc.unlock.submit_btn.addEventListener(MouseEvent.CLICK, onUnlockSubmitClick, false, 0, true); mc.unlock.input_txt.addEventListener(FocusEvent.FOCUS_IN, onUnlockInputFocus, false, 0, true); mc.unlock.input_txt.addEventListener(Event.CHANGE, onForceToUpperCase, false, 0, true); mc.unlock.dropdown.addEventListener(MouseEvent.ROLL_OVER, onDropDownRollOver, false, 0, true); mc.unlock.dropdown.addEventListener(MouseEvent.ROLL_OUT, onDropDownRollOut, false, 0, true); initGetCodeButton(); unlockHintShowing = true; } private function onGetCodeRollOut(_arg1:MouseEvent):void{ _arg1.currentTarget.up.visible = true; _arg1.currentTarget.over.visible = false; _arg1.currentTarget.down.visible = false; } private function checkUnlockInput():void{ var _local1:String = mc.unlock.input_txt.text; mc.unlock.input_txt.text = ""; if (_local1.toLowerCase() == Constants.unlockCode.toLowerCase()){ mc.unlock.input_txt.selectable = false; mc.unlock.input_txt.type = TextFieldType.DYNAMIC; mc.unlock.title_txt.text = ""; mc.unlock.success.visible = true; mc.unlock.bg.visible = false; mc.unlock.submit_btn.visible = false; Constants.useSpecialWeapon = true; stage.focus = stage; mc.unlock.dropdown.visible = false; if (Constants.viral){ Tracking.event(Tracking.USE_POWER_CODE_VIRAL); } else { Tracking.event(Tracking.USE_POWER_CODE_SITE); }; } else { InfamousTextManager.getInstance().setText(mc.unlock.input_txt, "title.wrong.code"); unlockHintShowing = true; }; } } }//package com.kerb.infamous
Section 83
//Tracking (com.kerb.infamous.Tracking) package com.kerb.infamous { import flash.display.*; import flash.utils.*; import com.kerb.tracking.*; import flash.external.*; public class Tracking { public static const INFAMOUS_WEBSITE_CLICKTHROUGH:int = 340; public static const SUBMIT_HIGH_SCORE_VIRAL:int = 356; public static const SUBMIT_HIGH_SCORE_SITE:int = 357; public static const USE_POWER_CODE_VIRAL:int = 333; public static const INIT_SITE:int = 91; public static const RETRY_LEVEL_VIRAL:int = 336; public static const LEVEL_2_LOADED_SITE:int = 344; public static const LEVEL_3_LOADED_SITE:int = 345; public static const LEVEL_1_LOADED_SITE:int = 343; public static const PLAY_AGAIN_VIRAL:int = 335; public static const GAME_COMPLETE_BAD_SITE:int = 347; public static const USE_POWER_CODE_SITE:int = 348; public static const GET_POWER_CODE_VIRAL:int = 337; public static const WEBSITE_CLICKTHROUGH_VIRAL:int = 390; public static const LEVEL_1_LOADED_VIRAL:int = 328; public static const WEBSITE_CLICKTHROUGH_SITE:int = 391; public static const PLAY_AGAIN_SITE:int = 350; public static const LEVEL_2_LOADED_VIRAL:int = 329; public static const RETRY_LEVEL_SITE:int = 351; public static const GAME_LOADED_VIRAL:int = 327; public static const GAME_COMPLETE_GOOD_VIRAL:int = 331; public static const GAME_COMPLETE_GOOD_SITE:int = 346; public static const GAME_LOADED_SITE:int = 342; public static const GAME_COMPLETE_BAD_VIRAL:int = 332; public static const INIT_VIRAL:int = 89; public static const GET_POWER_CODE_SITE:int = 352; public static const LEVEL_3_LOADED_VIRAL:int = 330; private static var webtrendsHash:Dictionary; public static function click(_arg1:int):void{ DoubleQuick.click(_arg1, (Constants.viral) ? "_blank" : "_self"); webtrends(webtrendsHash[_arg1]); } public static function init(_arg1:DisplayObject):void{ if (Constants.viral){ DoubleQuick.init(_arg1, INIT_VIRAL, false); DoubleQuick.event(GAME_LOADED_VIRAL); } else { DoubleQuick.init(_arg1, INIT_SITE, false); DoubleQuick.event(GAME_LOADED_SITE); }; webtrendsHash = new Dictionary(); webtrendsHash[INIT_SITE] = "init"; webtrendsHash[INIT_VIRAL] = "init"; webtrendsHash[GAME_LOADED_SITE] = "gameLoaded"; webtrendsHash[GAME_LOADED_VIRAL] = "gameLoaded"; webtrendsHash[LEVEL_1_LOADED_SITE] = "level1Loaded"; webtrendsHash[LEVEL_1_LOADED_VIRAL] = "level1Loaded"; webtrendsHash[LEVEL_2_LOADED_SITE] = "level2Loaded"; webtrendsHash[LEVEL_2_LOADED_VIRAL] = "level2Loaded"; webtrendsHash[LEVEL_3_LOADED_SITE] = "level3Loaded"; webtrendsHash[LEVEL_3_LOADED_VIRAL] = "level3Loaded"; webtrendsHash[GAME_COMPLETE_GOOD_SITE] = "gameCompleteGood"; webtrendsHash[GAME_COMPLETE_GOOD_VIRAL] = "gameCompleteGood"; webtrendsHash[GAME_COMPLETE_BAD_SITE] = "gameCompleteBad"; webtrendsHash[GAME_COMPLETE_BAD_VIRAL] = "gameCompleteBad"; webtrendsHash[USE_POWER_CODE_SITE] = "usePowerCode"; webtrendsHash[USE_POWER_CODE_VIRAL] = "usePowerCode"; webtrendsHash[PLAY_AGAIN_SITE] = "playAgain"; webtrendsHash[PLAY_AGAIN_VIRAL] = "playAgain"; webtrendsHash[RETRY_LEVEL_SITE] = "retryLevel"; webtrendsHash[RETRY_LEVEL_VIRAL] = "retryLevel"; webtrendsHash[SUBMIT_HIGH_SCORE_SITE] = "submitHighScore"; webtrendsHash[SUBMIT_HIGH_SCORE_VIRAL] = "submitHighScore"; webtrendsHash[GET_POWER_CODE_SITE] = "getPowerCode"; webtrendsHash[GET_POWER_CODE_VIRAL] = "getPowerCode"; webtrendsHash[WEBSITE_CLICKTHROUGH_SITE] = "websiteClickthrough"; webtrendsHash[WEBSITE_CLICKTHROUGH_VIRAL] = "websiteClickthrough"; } public static function getForumClickWatchIdFromLocale():int{ var _local1 = -1; var _local2:String = Constants.locale; var _local3:Boolean = Constants.viral; switch (_local2.substr(0, 2).toUpperCase()){ case "PL": _local1 = (_local3) ? 388 : 400; break; case "PT": _local1 = (_local3) ? 387 : 399; break; case "EN": case "RU": case "FI": if ((((_local2 == "en_NZ")) || ((_local2 == "en_AU")))){ _local1 = (_local3) ? 389 : 401; } else { _local1 = (_local3) ? 380 : 392; }; break; case "DE": _local1 = (_local3) ? 384 : 396; break; case "NL": _local1 = (_local3) ? 383 : 395; break; case "DA": case "NO": case "SV": _local1 = (_local3) ? 386 : 398; break; case "IT": _local1 = (_local3) ? 385 : 397; break; case "ES": _local1 = (_local3) ? 381 : 393; break; case "FR": _local1 = (_local3) ? 382 : 394; break; }; return (_local1); } public static function event(_arg1:int):void{ DoubleQuick.event(_arg1); webtrends(webtrendsHash[_arg1]); } private static function webtrends(_arg1:String):void{ if (!Constants.viral){ if (ExternalInterface.available){ trace(("Webtrends tracking event " + _arg1)); ExternalInterface.call("dcsMultiTrack", "DCS.dcsuri", ("/flashtrack/patapongame/" + _arg1), "DCSext.locale", Constants.locale, "WT.ti", _arg1); }; }; } } }//package com.kerb.infamous
Section 84
//KeyControl (com.kerb.input.KeyControl) package com.kerb.input { import flash.events.*; import flash.display.*; import com.kerb.utils.*; public class KeyControl extends EventDispatcher implements IDisposable { protected var activeKeys:Array; protected var stage:Stage; private static var allowInstantiation:Boolean = false; private static var instance:KeyControl; public function KeyControl(){ activeKeys = new Array(); super(); if (!allowInstantiation){ throw (new Error("KeyControl is a singleton. Use getInstance() to instantiate.")); }; } public function init(_arg1:Stage):void{ this.stage = _arg1; _arg1.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); _arg1.addEventListener(KeyboardEvent.KEY_UP, onKeyUp); _arg1.focus = _arg1; } protected function onKeyDown(_arg1:KeyboardEvent):void{ if (!activeKeys[_arg1.keyCode]){ activeKeys[_arg1.keyCode] = true; dispatchEvent(_arg1); }; } public function keyIsDown(_arg1:uint):Boolean{ return (activeKeys[_arg1]); } protected function onKeyUp(_arg1:KeyboardEvent):void{ activeKeys[_arg1.keyCode] = false; dispatchEvent(_arg1); } public function dispose():void{ if (stage){ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp); }; } public static function getInstance():KeyControl{ if (instance == null){ allowInstantiation = true; instance = new (KeyControl); allowInstantiation = false; }; return (instance); } } }//package com.kerb.input
Section 85
//ExtendedSound (com.kerb.sound.ExtendedSound) package com.kerb.sound { import flash.events.*; import flash.media.*; import flash.utils.*; public class ExtendedSound extends Sound { protected var fadeStartVolume:Number; protected var panStartPosition:Number; protected var masterVolume:Number;// = 1 protected var panTimer:Timer; protected var fadeTimer:Timer; protected var paused:Boolean; protected var fadeDuration:Number; protected var fadeStartTime:Number; protected var fadeEndVolume:Number; protected var playingLoops:Number; protected var panEndPosition:Number; protected var panStartTime:Number; protected var panDuration:Number; protected var pauseTime:Number; protected var transform:SoundTransform; protected var soundChannel:SoundChannel; private static const TIMER_UPDATE_RATE:Number = 20; public function stop():void{ if (soundChannel != null){ soundChannel.stop(); soundChannel.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete); soundChannel = null; stopFade(); }; } protected function updatePan(_arg1:TimerEvent):void{ var _local2:Number; var _local3:Number = ((getTimer() - panStartTime) / panDuration); if (_local3 >= 1){ stopPan(); _local2 = panEndPosition; } else { if (_local3 > 0){ _local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition); }; }; var _local4:Number = soundChannel.soundTransform.volume; transform = new SoundTransform(_local4, _local2); soundChannel.soundTransform = transform; } public function fadeTo(_arg1:Number, _arg2:Number):void{ if (((soundChannel) && (soundChannel.soundTransform))){ fadeStartTime = getTimer(); fadeDuration = _arg2; fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume); fadeEndVolume = _arg1; startFade(); }; } public function setMasterVolume(_arg1:Number):void{ var _local2:Number; masterVolume = Math.max(0, Math.min(1, _arg1)); if (soundChannel != null){ _local2 = soundChannel.soundTransform.pan; transform = new SoundTransform((_arg1 * masterVolume), _local2); soundChannel.soundTransform = transform; }; } protected function stopFade():void{ if (((!((fadeTimer == null))) && (fadeTimer.running))){ fadeTimer.reset(); }; } public function setVolume(_arg1:Number):void{ var _local2:Number; if (soundChannel != null){ _arg1 = Math.max(0, Math.min(1, _arg1)); _local2 = soundChannel.soundTransform.pan; transform = new SoundTransform((_arg1 * masterVolume), _local2); soundChannel.soundTransform = transform; stopFade(); }; } public function fadeOut(_arg1:Number=0):void{ if ((((((_arg1 > 0)) && (soundChannel))) && (soundChannel.soundTransform))){ fadeStartTime = getTimer(); fadeDuration = _arg1; fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume); fadeEndVolume = 0; startFade(); } else { stop(); }; } override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{ if (_arg3 != null){ _arg3.volume = (_arg3.volume * masterVolume); } else { _arg3 = new SoundTransform(masterVolume); }; soundChannel = super.play(_arg1, _arg2, _arg3); soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete); playingLoops = _arg2; transform = _arg3; paused = false; return (soundChannel); } protected function stopPan():void{ if (((!((panTimer == null))) && (panTimer.running))){ panTimer.reset(); }; } public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{ fadeStartVolume = Math.max(0, Math.min(1, _arg1)); play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume))); if (_arg3 > 0){ fadeStartTime = getTimer(); fadeDuration = _arg3; fadeEndVolume = Math.max(0, Math.min(1, _arg2)); startFade(); }; return (soundChannel); } protected function onSoundComplete(_arg1:Event):void{ dispatchEvent(_arg1); } public function get position():Number{ if (soundChannel == null){ return (0); }; return (soundChannel.position); } protected function startPan():void{ if (panTimer == null){ panTimer = new Timer(TIMER_UPDATE_RATE); panTimer.addEventListener(TimerEvent.TIMER, updatePan); }; stopPan(); panTimer.start(); } public function setPan(_arg1:Number):void{ var _local2:Number; if (soundChannel != null){ _arg1 = Math.max(-1, Math.min(1, _arg1)); _local2 = soundChannel.soundTransform.volume; transform = new SoundTransform(_local2, _arg1); soundChannel.soundTransform = transform; stopPan(); }; } protected function updateFade(_arg1:TimerEvent):void{ var _local2:Number; var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration); if (_local3 >= 1){ stopFade(); _local2 = fadeEndVolume; } else { if (_local3 > 0){ _local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume); }; }; var _local4:Number = soundChannel.soundTransform.pan; transform = new SoundTransform((_local2 * masterVolume), _local4); soundChannel.soundTransform = transform; } public function getSoundChannel():SoundChannel{ return (soundChannel); } override public function toString():String{ var _local1:String = getQualifiedClassName(this); if (soundChannel != null){ _local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]")); _local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]")); }; return (_local1); } public function pause():void{ if (soundChannel == null){ return; }; pauseTime = soundChannel.position; stop(); } public function panTo(_arg1:Number, _arg2:Number):void{ if (_arg2 > 0){ panStartTime = getTimer(); panDuration = _arg2; panStartPosition = soundChannel.soundTransform.pan; panEndPosition = _arg1; startPan(); } else { setPan(_arg1); }; } public function unpause():void{ play(pauseTime, playingLoops, transform); } protected function startFade():void{ if (fadeTimer == null){ fadeTimer = new Timer(TIMER_UPDATE_RATE); fadeTimer.addEventListener(TimerEvent.TIMER, updateFade); }; stopFade(); fadeTimer.start(); } } }//package com.kerb.sound
Section 86
//SoundManager (com.kerb.sound.SoundManager) package com.kerb.sound { import flash.utils.*; public class SoundManager { private var sounds:Array; private var prevMasterVolume:Number; private var muteState:Boolean;// = false private var masterVolume:Number;// = 1 public function SoundManager(){ prevMasterVolume = masterVolume; sounds = new Array(); super(); } public function unregisterSound(_arg1:String):void{ if (sounds[_arg1] != null){ sounds[_arg1].stop(); sounds[_arg1] = null; }; } public function stopAllSounds():void{ var _local1:String; for (_local1 in sounds) { sounds[_local1].stop(); }; } public function setMasterVolume(_arg1:Number):void{ var _local2:String; prevMasterVolume = masterVolume; masterVolume = Math.max(0, Math.min(1, _arg1)); for (_local2 in sounds) { sounds[_local2].setMasterVolume(masterVolume); }; } public function get muted():Boolean{ return (muteState); } public function registerSound(_arg1:ExtendedSound, _arg2:String=null, _arg3:Boolean=false):void{ if (_arg2 == null){ _arg2 = getQualifiedClassName(_arg1); }; if (sounds[_arg2] != null){ if (_arg3){ unregisterSound(_arg2); } else { throw (new Error((("Class name conflict: A sound with the class name [" + _arg2) + "] already exists in SoundManager."))); }; }; sounds[_arg2] = _arg1; _arg1.setMasterVolume(masterVolume); } public function unmute():void{ if (muteState){ muteState = false; setMasterVolume(prevMasterVolume); }; } public function getSoundByClassName(_arg1:String):ExtendedSound{ return (sounds[_arg1]); } public function mute():void{ if (!muteState){ muteState = true; setMasterVolume(0); }; } public function toString():String{ var _local2:String; var _local1 = "====================\n"; _local1 = (_local1 + "SoundManager\n"); _local1 = (_local1 + "--------------------\n"); _local1 = (_local1 + (("master vol[" + masterVolume) + "]\n")); _local1 = (_local1 + "--------------------"); for (_local2 in sounds) { _local1 = (_local1 + ("\n" + sounds[_local2].toString())); }; _local1 = (_local1 + "\n===================="); return (_local1); } } }//package com.kerb.sound
Section 87
//DoubleQuick (com.kerb.tracking.DoubleQuick) package com.kerb.tracking { import flash.events.*; import flash.display.*; import flash.net.*; import flash.utils.*; public class DoubleQuick { private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey"; private static const SO_NAME:String = "doublequick"; private static const TICKER_PERIOD:Number = 30000; private static const TRACKER_SESSION_URL:String = "http://doublequick.kerb.co.uk/tracking/session.htm"; private static const TICKER_URL:String = "http://doublequick.kerb.co.uk/tracking/ticker.htm"; private static const TRACKER_URL:String = "http://doublequick.kerb.co.uk/tracking/trackflash.htm"; private static const SO_EXPIRY_PROPERTY_NAME:String = "expo"; private static var tickerURL:URLRequest = null; private static var initialised:Boolean = false; private static var queue:Array = new Array(); private static var projectId:Number; private static var baseurl:String; private static var dq:DoubleQuick; private static var traceEvents:Boolean; public function startTimer():void{ var _local1:Timer = new Timer(TICKER_PERIOD, 0); _local1.start(); _local1.addEventListener(TimerEvent.TIMER, pingProxy); } public function pingProxy(_arg1:TimerEvent):void{ DoubleQuick.ping(); } private static function doTrace(_arg1:String):void{ if (traceEvents){ trace(_arg1); }; } public static function event(_arg1:Number):void{ var loader:URLLoader; var request:URLRequest; var watchId = _arg1; if (!initialised){ doTrace(("Queueing event " + watchId)); queue.push(watchId); } else { doTrace(("Tracking event " + watchId)); loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener); request = generateURL(watchId); request.method = URLRequestMethod.GET; try { loader.load(request); } catch(error:Error) { }; }; } public static function click(_arg1:Number, _arg2:String=null):void{ doTrace(("Tracking clickThrough " + _arg1)); navigateToURL(generateURL(_arg1), _arg2); } private static function dummyListener(_arg1:Event):void{ } private static function onInit(_arg1:Event):void{ var _local4:Date; var _local2:URLLoader = URLLoader(_arg1.target); var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){ doTrace(("acquired session key " + _local2.data["sessionkey"])); _local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]); _local4 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000))); _local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local4); }; DoubleQuick.initialisationFinished(); } public static function init(_arg1:DisplayObject, _arg2:Number, _arg3:Boolean=true):void{ var loader:URLLoader; var request:URLRequest; var root = _arg1; var _projectId = _arg2; var _traceEvents = _arg3; projectId = _projectId; traceEvents = _traceEvents; baseurl = root.loaderInfo.url; doTrace(((("Tracking initialised with project " + projectId) + " and baseurl ") + baseurl)); var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); var isExpired:Boolean; var currentDate:Date = new Date(); if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){ isExpired = false; }; if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){ doTrace("requesting new session key"); loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(Event.COMPLETE, onInit); loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener); request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId)); request.method = URLRequestMethod.GET; try { loader.load(request); } catch(error:Error) { }; } else { DoubleQuick.initialisationFinished(); }; } public static function initialisationFinished():void{ doTrace("Tracking initialised"); initialised = true; var _local1:int; while (_local1 < queue.length) { event(queue[_local1]); _local1++; }; queue = new Array(); var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); tickerURL = new URLRequest(((((TICKER_URL + "?project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME])); tickerURL.method = URLRequestMethod.GET; dq = new (DoubleQuick); dq.startTimer(); } public static function ping():void{ var loader:URLLoader; if (tickerURL != null){ loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener); doTrace("Tracking ticker"); try { loader.load(tickerURL); } catch(error:Error) { }; }; } private static function generateURL(_arg1:Number):URLRequest{ var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl)); return (new URLRequest(_local3)); } } }//package com.kerb.tracking
Section 88
//AssetFactory (com.kerb.utils.AssetFactory) package com.kerb.utils { import flash.events.*; import flash.display.*; import flash.media.*; import com.kerb.sound.*; public final class AssetFactory extends EventDispatcher { private var _loader:Loader;// = null public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY"; public function initialize(_arg1:Class):void{ _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError); _loader.loadBytes(new (_arg1)); } public function createExtendedSound(_arg1:String):ExtendedSound{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as ExtendedSound)); } public function createDisplayObject(_arg1:String):DisplayObject{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as DisplayObject)); } private function _onLibraryReady(_arg1:Event):void{ _loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady); dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY)); } public function createSound(_arg1:String):Sound{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as Sound)); } public function createMovieClip(_arg1:String):MovieClip{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as MovieClip)); } public function createBitmapDataObject(_arg1:String):BitmapData{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new _local2(0, 0) as BitmapData)); } private function _onIOError(_arg1:Event):void{ } } }//package com.kerb.utils
Section 89
//IDisposable (com.kerb.utils.IDisposable) package com.kerb.utils { public interface IDisposable { function dispose():void; } }//package com.kerb.utils
Section 90
//TextManager (com.kerb.utils.TextManager) package com.kerb.utils { import mx.core.*; public class TextManager { private var _xmlData:XML; private static var instance:TextManager; public function init(_arg1:XML):void{ this._xmlData = _arg1; } public function getTextById(_arg1:String):String{ var result:String; var id = _arg1; if (_xmlData){ result = _xmlData.text.(@id == id); if (result){ return (result); }; return ((("[text key missing : " + id) + "]")); //unresolved jump }; return (id); } public function initFromClass(_arg1:Class):void{ var _local3:XML; var _local2:ByteArrayAsset = ByteArrayAsset(new (_arg1)); var _local4:String = _local2.readUTFBytes(3); if (_local4.length == 1){ this._xmlData = new XML(_local2.readUTFBytes((_local2.length - 3))); } else { this._xmlData = new XML((_local4 + _local2.readUTFBytes((_local2.length - 3)))); }; } public static function getInstance():TextManager{ if (instance == null){ instance = new (TextManager); }; return (instance); } } }//package com.kerb.utils
Section 91
//compareStringCaseInSensitive (de.polygonal.ds.sort.compare.compareStringCaseInSensitive) package de.polygonal.ds.sort.compare { public function compareStringCaseInSensitive(_arg1:String, _arg2:String):int{ var _local3:int; var _local4:int; var _local5:int; _arg1 = _arg1.toLowerCase(); _arg2 = _arg2.toLowerCase(); if ((_arg1.length + _arg2.length) > 2){ _local3 = 0; _local4 = ((_arg1.length > _arg2.length)) ? _arg1.length : _arg2.length; _local5 = 0; while (_local5 < _local4) { _local3 = (_arg1.charCodeAt(_local5) - _arg2.charCodeAt(_local5)); if (_local3 != 0){ break; }; _local5++; }; return (_local3); //unresolved jump }; return ((_arg1.charCodeAt(0) - _arg2.charCodeAt(0))); } }//package de.polygonal.ds.sort.compare
Section 92
//compareStringCaseInSensitiveDesc (de.polygonal.ds.sort.compare.compareStringCaseInSensitiveDesc) package de.polygonal.ds.sort.compare { public function compareStringCaseInSensitiveDesc(_arg1:String, _arg2:String):int{ var _local3:int; var _local4:int; var _local5:int; _arg1 = _arg1.toLowerCase(); _arg2 = _arg2.toLowerCase(); if ((_arg1.length + _arg2.length) > 2){ _local3 = 0; _local4 = ((_arg1.length > _arg2.length)) ? _arg1.length : _arg2.length; _local5 = 0; while (_local5 < _local4) { _local3 = (_arg2.charCodeAt(_local5) - _arg1.charCodeAt(_local5)); if (_local3 != 0){ break; }; _local5++; }; return (_local3); //unresolved jump }; return ((_arg2.charCodeAt(0) - _arg1.charCodeAt(0))); } }//package de.polygonal.ds.sort.compare
Section 93
//compareStringCaseSensitive (de.polygonal.ds.sort.compare.compareStringCaseSensitive) package de.polygonal.ds.sort.compare { public function compareStringCaseSensitive(_arg1:String, _arg2:String):int{ var _local3:int; var _local4:int; var _local5:int; if ((_arg1.length + _arg2.length) > 2){ _local3 = 0; _local4 = ((_arg1.length > _arg2.length)) ? _arg1.length : _arg2.length; _local5 = 0; while (_local5 < _local4) { _local3 = (_arg1.charCodeAt(_local5) - _arg2.charCodeAt(_local5)); if (_local3 != 0){ break; }; _local5++; }; return (_local3); //unresolved jump }; return ((_arg1.charCodeAt(0) - _arg2.charCodeAt(0))); } }//package de.polygonal.ds.sort.compare
Section 94
//compareStringCaseSensitiveDesc (de.polygonal.ds.sort.compare.compareStringCaseSensitiveDesc) package de.polygonal.ds.sort.compare { public function compareStringCaseSensitiveDesc(_arg1:String, _arg2:String):int{ var _local3:int; var _local4:int; var _local5:int; if ((_arg1.length + _arg2.length) > 2){ _local3 = 0; _local4 = ((_arg1.length > _arg2.length)) ? _arg1.length : _arg2.length; _local5 = 0; while (_local5 < _local4) { _local3 = (_arg2.charCodeAt(_local5) - _arg1.charCodeAt(_local5)); if (_local3 != 0){ break; }; _local5++; }; return (_local3); //unresolved jump }; return ((_arg2.charCodeAt(0) - _arg1.charCodeAt(0))); } }//package de.polygonal.ds.sort.compare
Section 95
//sLinkedInsertionSort (de.polygonal.ds.sort.sLinkedInsertionSort) package de.polygonal.ds.sort { import de.polygonal.ds.*; public function sLinkedInsertionSort(_arg1:SListNode, _arg2:Boolean=false):SListNode{ var _local7:int; var _local8:Number; var _local3:Array = []; var _local4:int; var _local5:SListNode = _arg1; var _local6:SListNode = _arg1; while (_local6) { var _temp1 = _local4; _local4 = (_local4 + 1); var _local10 = _temp1; _local3[_local10] = _local6.data; _local6 = _local6.next; }; if (_local4 <= 1){ return (_local5); }; var _local9 = 1; while (_local9 < _local4) { _local8 = _local3[_local9]; _local7 = _local9; while ((((_local7 > 0)) && ((_local3[int((_local7 - 1))] > _local8)))) { _local3[_local7] = _local3[int((_local7 - 1))]; _local7--; }; _local3[_local7] = _local8; _local9++; }; _local6 = _local5; _local9 = 0; while (_local6) { var _temp2 = _local9; _local9 = (_local9 + 1); _local6.data = _local3[_temp2]; _local6 = _local6.next; }; return (_local5); } }//package de.polygonal.ds.sort
Section 96
//sLinkedInsertionSortCmp (de.polygonal.ds.sort.sLinkedInsertionSortCmp) package de.polygonal.ds.sort { import de.polygonal.ds.*; public function sLinkedInsertionSortCmp(_arg1:SListNode, _arg2:Function, _arg3:Boolean=false):SListNode{ var _local8:int; var _local9:int; var _local10:*; var _local4:Array = []; var _local5:int; var _local6:SListNode = _arg1; var _local7:SListNode = _arg1; while (_local7) { var _temp1 = _local5; _local5 = (_local5 + 1); var _local11 = _temp1; _local4[_local11] = _local7.data; _local7 = _local7.next; }; if (_arg3){ if (_local5 <= 1){ return (_local6); }; _local9 = 1; while (_local9 < _local5) { _local10 = _local4[_local9]; _local8 = _local9; while ((((_local8 > 0)) && ((_arg2(_local4[int((_local8 - 1))], _local10) < 0)))) { _local4[_local8] = _local4[int((_local8 - 1))]; _local8--; }; _local4[_local8] = _local10; _local9++; }; } else { if (_local5 <= 1){ return (_local6); }; _local9 = 1; while (_local9 < _local5) { _local10 = _local4[_local9]; _local8 = _local9; while ((((_local8 > 0)) && ((_arg2(_local4[int((_local8 - 1))], _local10) > 0)))) { _local4[_local8] = _local4[int((_local8 - 1))]; _local8--; }; _local4[_local8] = _local10; _local9++; }; }; _local7 = _local6; _local9 = 0; while (_local7) { var _temp2 = _local9; _local9 = (_local9 + 1); _local7.data = _local4[_temp2]; _local7 = _local7.next; }; return (_local6); } }//package de.polygonal.ds.sort
Section 97
//sLinkedMergeSort (de.polygonal.ds.sort.sLinkedMergeSort) package de.polygonal.ds.sort { import de.polygonal.ds.*; public function sLinkedMergeSort(_arg1:SListNode, _arg2:Boolean=false):SListNode{ var _local4:SListNode; var _local5:SListNode; var _local6:SListNode; var _local7:SListNode; var _local9:int; var _local10:int; var _local11:int; var _local12:int; if (!_arg1){ return (null); }; var _local3:SListNode = _arg1; var _local8 = 1; if (_arg2){ while (true) { _local4 = _local3; _local7 = null; _local3 = _local7; _local9 = 0; while (_local4) { _local9++; _local12 = 0; _local10 = 0; _local5 = _local4; while (_local12 < _local8) { _local10++; _local5 = _local5.next; if (!_local5){ break; }; _local12++; }; _local11 = _local8; while ((((_local10 > 0)) || ((((_local11 > 0)) && (_local5))))) { if (_local10 == 0){ _local6 = _local5; _local5 = _local5.next; _local11--; } else { if ((((_local11 == 0)) || (!(_local5)))){ _local6 = _local4; _local4 = _local4.next; _local10--; } else { if ((_local4.data - _local5.data) >= 0){ _local6 = _local4; _local4 = _local4.next; _local10--; } else { _local6 = _local5; _local5 = _local5.next; _local11--; }; }; }; if (_local7){ _local7.next = _local6; } else { _local3 = _local6; }; _local7 = _local6; }; _local4 = _local5; }; _local7.next = null; if (_local9 <= 1){ return (_local3); }; _local8 = (_local8 << 1); }; } else { while (true) { _local4 = _local3; _local7 = null; _local3 = _local7; _local9 = 0; while (_local4) { _local9++; _local12 = 0; _local10 = 0; _local5 = _local4; while (_local12 < _local8) { _local10++; _local5 = _local5.next; if (!_local5){ break; }; _local12++; }; _local11 = _local8; while ((((_local10 > 0)) || ((((_local11 > 0)) && (_local5))))) { if (_local10 == 0){ _local6 = _local5; _local5 = _local5.next; _local11--; } else { if ((((_local11 == 0)) || (!(_local5)))){ _local6 = _local4; _local4 = _local4.next; _local10--; } else { if ((_local4.data - _local5.data) <= 0){ _local6 = _local4; _local4 = _local4.next; _local10--; } else { _local6 = _local5; _local5 = _local5.next; _local11--; }; }; }; if (_local7){ _local7.next = _local6; } else { _local3 = _local6; }; _local7 = _local6; }; _local4 = _local5; }; _local7.next = null; if (_local9 <= 1){ return (_local3); }; _local8 = (_local8 << 1); }; }; return (null); } }//package de.polygonal.ds.sort
Section 98
//sLinkedMergeSortCmp (de.polygonal.ds.sort.sLinkedMergeSortCmp) package de.polygonal.ds.sort { import de.polygonal.ds.*; public function sLinkedMergeSortCmp(_arg1:SListNode, _arg2:Function, _arg3:Boolean=false):SListNode{ var _local5:SListNode; var _local6:SListNode; var _local7:SListNode; var _local8:SListNode; var _local10:int; var _local11:int; var _local12:int; var _local13:int; if (((!(_arg1)) || ((_arg2 == null)))){ return (null); }; var _local4:SListNode = _arg1; var _local9 = 1; if (_arg3){ while (true) { _local5 = _local4; _local8 = null; _local4 = _local8; _local10 = 0; while (_local5) { _local10++; _local13 = 0; _local11 = 0; _local6 = _local5; while (_local13 < _local9) { _local11++; _local6 = _local6.next; if (!_local6){ break; }; _local13++; }; _local12 = _local9; while ((((_local11 > 0)) || ((((_local12 > 0)) && (_local6))))) { if (_local11 == 0){ _local7 = _local6; _local6 = _local6.next; _local12--; } else { if ((((_local12 == 0)) || (!(_local6)))){ _local7 = _local5; _local5 = _local5.next; _local11--; } else { if (_arg2(_local5.data, _local6.data) >= 0){ _local7 = _local5; _local5 = _local5.next; _local11--; } else { _local7 = _local6; _local6 = _local6.next; _local12--; }; }; }; if (_local8){ _local8.next = _local7; } else { _local4 = _local7; }; _local8 = _local7; }; _local5 = _local6; }; _local8.next = null; if (_local10 <= 1){ return (_local4); }; _local9 = (_local9 << 1); }; } else { while (true) { _local5 = _local4; _local8 = null; _local4 = _local8; _local10 = 0; while (_local5) { _local10++; _local13 = 0; _local11 = 0; _local6 = _local5; while (_local13 < _local9) { _local11++; _local6 = _local6.next; if (!_local6){ break; }; _local13++; }; _local12 = _local9; while ((((_local11 > 0)) || ((((_local12 > 0)) && (_local6))))) { if (_local11 == 0){ _local7 = _local6; _local6 = _local6.next; _local12--; } else { if ((((_local12 == 0)) || (!(_local6)))){ _local7 = _local5; _local5 = _local5.next; _local11--; } else { if (_arg2(_local5.data, _local6.data) <= 0){ _local7 = _local5; _local5 = _local5.next; _local11--; } else { _local7 = _local6; _local6 = _local6.next; _local12--; }; }; }; if (_local8){ _local8.next = _local7; } else { _local4 = _local7; }; _local8 = _local7; }; _local5 = _local6; }; _local8.next = null; if (_local10 <= 1){ return (_local4); }; _local9 = (_local9 << 1); }; }; return (null); } }//package de.polygonal.ds.sort
Section 99
//Array2 (de.polygonal.ds.Array2) package de.polygonal.ds { public class Array2 implements Collection { private var _a:Array; private var _h:int; private var _w:int; public function Array2(_arg1:int, _arg2:int){ if ((((_arg1 < 2)) || ((_arg2 < 2)))){ throw (new Error("illegal size")); }; _a = new Array((_w = _arg1), (_h = _arg2)); fill(null); } public function get size():int{ return ((_w * _h)); } public function fill(_arg1):void{ var _local3:int; var _local4:Class; var _local2:int = (_w * _h); if ((_arg1 is Class)){ _local4 = (_arg1 as Class); _local3 = 0; while (_local3 < _local2) { _a[_local3] = new (_local4); _local3++; }; } else { _local3 = 0; while (_local3 < _local2) { _a[_local3] = _arg1; _local3++; }; }; } public function get width():int{ return (_w); } public function getCol(_arg1:int):Array{ var _local2:Array = []; var _local3:int; while (_local3 < _h) { _local2[_local3] = _a[int(((_local3 * _w) + _arg1))]; _local3++; }; return (_local2); } public function shiftDown():void{ if (_h == 1){ return; }; var _local1:int = ((_h - 1) * _w); _a = _a.slice(_local1, (_local1 + _w)).concat(_a); _a.splice((_h * _w), _w); } public function set width(_arg1:int):void{ resize(_arg1, _h); } public function appendCol(_arg1:Array):void{ _arg1.length = _h; var _local2:int; while (_local2 < _h) { _a.splice((((_local2 * _w) + _w) + _local2), 0, _arg1[_local2]); _local2++; }; _w++; } public function set height(_arg1:int):void{ resize(_w, _arg1); } public function clear():void{ _a = new Array(size); } public function get(_arg1:int, _arg2:int){ return (_a[int(((_arg2 * _w) + _arg1))]); } public function setRow(_arg1:uint, _arg2:Array):void{ if ((((_arg1 < 0)) || ((_arg1 > _h)))){ throw (new Error("row index out of bounds")); }; var _local3:int = (_arg1 * _w); var _local4:int; while (_local4 < _w) { _a[int((_local3 + _local4))] = _arg2[_local4]; _local4++; }; } public function prependCol(_arg1:Array):void{ _arg1.length = _h; var _local2:int; while (_local2 < _h) { _a.splice(((_local2 * _w) + _local2), 0, _arg1[_local2]); _local2++; }; _w++; } public function isEmpty():Boolean{ return (false); } public function toArray():Array{ var _local1:Array = _a.concat(); var _local2:int = size; if (_local1.length > _local2){ _local1.length = _local2; }; return (_local1); } public function contains(_arg1):Boolean{ var _local2:int = size; var _local3:int; while (_local3 < _local2) { if (_a[_local3] === _arg1){ return (true); }; _local3++; }; return (false); } public function appendRow(_arg1:Array):void{ _arg1.length = _w; _a = _a.concat(_arg1); _h++; } public function dump():String{ var _local2:int; var _local3:*; var _local5:int; var _local1 = "Array2\n{"; var _local4:int; while (_local4 < _h) { _local1 = (_local1 + ("\n" + "\t")); _local2 = (_local4 * _w); _local5 = 0; while (_local5 < _w) { _local3 = _a[int((_local2 + _local5))]; _local1 = (_local1 + (("[" + ((_local3)!=undefined) ? _local3 : "?") + "]")); _local5++; }; _local4++; }; _local1 = (_local1 + "\n}"); return (_local1); } public function getArray():Array{ return (_a); } public function getRow(_arg1:int):Array{ var _local2:int = (_arg1 * _w); return (_a.slice(_local2, (_local2 + _w))); } public function get height():int{ return (_h); } public function shiftLeft():void{ var _local2:int; if (_w == 1){ return; }; var _local1:int = (_w - 1); var _local3:int; while (_local3 < _h) { _local2 = ((_local3 * _w) + _local1); _a.splice(_local2, 0, _a.splice((_local2 - _local1), 1)); _local3++; }; } public function getIterator():Iterator{ return (new Array2Iterator(this)); } public function prependRow(_arg1:Array):void{ _arg1.length = _w; _a = _arg1.concat(_a); _h++; } public function set(_arg1:int, _arg2:int, _arg3):void{ _a[int(((_arg2 * _w) + _arg1))] = _arg3; } public function resize(_arg1:int, _arg2:int):void{ var _local6:int; var _local7:int; var _local8:int; var _local9:int; if ((((_arg1 < 2)) || ((_arg2 < 2)))){ throw (new Error("illegal size")); }; var _local3:Array = _a.concat(); _a.length = 0; _a.length = (_arg1 * _arg2); var _local4:int = ((_arg1 < _w)) ? _arg1 : _w; var _local5:int = ((_arg2 < _h)) ? _arg2 : _h; _local7 = 0; while (_local7 < _local5) { _local8 = (_local7 * _arg1); _local9 = (_local7 * _w); _local6 = 0; while (_local6 < _local4) { _a[int((_local8 + _local6))] = _local3[int((_local9 + _local6))]; _local6++; }; _local7++; }; _w = _arg1; _h = _arg2; } public function transpose():void{ var _local3:int; var _local1:Array = _a.concat(); var _local2:int; while (_local2 < _h) { _local3 = 0; while (_local3 < _w) { _a[int(((_local3 * _w) + _local2))] = _local1[int(((_local2 * _w) + _local3))]; _local3++; }; _local2++; }; } public function shiftRight():void{ var _local2:int; if (_w == 1){ return; }; var _local1:int = (_w - 1); var _local3:int; while (_local3 < _h) { _local2 = ((_local3 * _w) + _local1); _a.splice((_local2 - _local1), 0, _a.splice(_local2, 1)); _local3++; }; } public function toString():String{ return ((((("[Array2, width=" + width) + ", height=") + height) + "]")); } public function shiftUp():void{ if (_h == 1){ return; }; _a = _a.concat(_a.slice(0, _w)); _a.splice(0, _w); } public function setCol(_arg1:int, _arg2:Array):void{ if ((((_arg1 < 0)) || ((_arg1 > _w)))){ throw (new Error("column index out of bounds")); }; var _local3:int; while (_local3 < _h) { _a[int(((_local3 * _w) + _arg1))] = _arg2[_local3]; _local3++; }; } } }//package de.polygonal.ds class Array2Iterator implements Iterator { private var _xCursor:int; private var _a2:Array2; private var _yCursor:int; private function Array2Iterator(_arg1:Array2){ _a2 = _arg1; _xCursor = (_yCursor = 0); } public function start():void{ _xCursor = (_yCursor = 0); } public function hasNext():Boolean{ return ((((_yCursor * _a2.width) + _xCursor) < _a2.size)); } public function get data(){ return (_a2.get(_xCursor, _yCursor)); } public function set data(_arg1):void{ _a2.set(_xCursor, _yCursor, _arg1); } public function next(){ var _local1:* = data; if (++_xCursor == _a2.width){ _yCursor++; _xCursor = 0; }; return (_local1); } }
Section 100
//ArrayedQueue (de.polygonal.ds.ArrayedQueue) package de.polygonal.ds { public class ArrayedQueue implements Collection { private var _que:Array; private var _count:int; private var _size:int; private var _front:int; private var _divisor:int; public function ArrayedQueue(_arg1:int){ init(_arg1); } public function get size():int{ return (_count); } public function isEmpty():Boolean{ return ((_count == 0)); } public function get maxSize():int{ return (_size); } public function enqueue(_arg1):Boolean{ if (_size != _count){ _que[int(((_count++ + _front) & _divisor))] = _arg1; return (true); }; return (false); } public function clear():void{ _que = new Array(_size); _front = (_count = 0); var _local1:int; while (_local1 < _size) { _que[_local1] = null; _local1++; }; } private function init(_arg1:int):void{ if (!(((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)))){ _arg1 = (_arg1 | (_arg1 >> 1)); _arg1 = (_arg1 | (_arg1 >> 2)); _arg1 = (_arg1 | (_arg1 >> 4)); _arg1 = (_arg1 | (_arg1 >> 8)); _arg1 = (_arg1 | (_arg1 >> 16)); _arg1++; }; _size = _arg1; _divisor = (_arg1 - 1); clear(); } public function peek(){ return (_que[_front]); } public function toArray():Array{ var _local1:Array = new Array(_count); var _local2:int; while (_local2 < _count) { _local1[_local2] = _que[int(((_local2 + _front) & _divisor))]; _local2++; }; return (_local1); } public function contains(_arg1):Boolean{ var _local2:int; while (_local2 < _count) { if (_que[int(((_local2 + _front) & _divisor))] === _arg1){ return (true); }; _local2++; }; return (false); } public function getIterator():Iterator{ return (new ArrayedQueueIterator(this)); } public function dispose():void{ if (!_front){ _que[int((_size - 1))] = null; } else { _que[int((_front - 1))] = null; }; } public function back(){ return (_que[int((((_count - 1) + _front) & _divisor))]); } public function getAt(_arg1:int){ if (_arg1 >= _count){ return (null); }; return (_que[int(((_arg1 + _front) & _divisor))]); } public function toString():String{ return ((("[ArrayedQueue, size=" + size) + "]")); } public function dequeue(){ var _local1:*; if (_count > 0){ _local1 = _que[int(_front++)]; if (_front == _size){ _front = 0; }; _count--; return (_local1); }; return (null); } public function dump():String{ var _local2:int; var _local1 = "[ArrayedQueue]\n"; _local1 = (_local1 + (("\t" + getAt(_local2)) + " -> front\n")); _local2 = 1; while (_local2 < _count) { _local1 = (_local1 + (("\t" + getAt(_local2)) + "\n")); _local2++; }; return (_local1); } public function setAt(_arg1:int, _arg2):void{ if (_arg1 >= _count){ return; }; _que[int(((_arg1 + _front) & _divisor))] = _arg2; } } }//package de.polygonal.ds class ArrayedQueueIterator implements Iterator { private var _que:ArrayedQueue; private var _cursor:int; private function ArrayedQueueIterator(_arg1:ArrayedQueue){ _que = _arg1; _cursor = 0; } public function get data(){ return (_que.getAt(_cursor)); } public function next(){ if (_cursor < _que.size){ return (_que.getAt(_cursor++)); }; return (null); } public function hasNext():Boolean{ return ((_cursor < _que.size)); } public function set data(_arg1):void{ _que.setAt(_cursor, _arg1); } public function start():void{ _cursor = 0; } }
Section 101
//BinaryTreeNode (de.polygonal.ds.BinaryTreeNode) package de.polygonal.ds { public class BinaryTreeNode { public var left:BinaryTreeNode; public var data; public var parent:BinaryTreeNode; public var right:BinaryTreeNode; public function BinaryTreeNode(_arg1){ this.data = _arg1; parent = (left = (right = null)); } public function destroy():void{ if (left){ left.destroy(); }; left = null; if (right){ right.destroy(); }; right = null; } public function setLeft(_arg1):void{ if (!left){ left = new BinaryTreeNode(_arg1); left.parent = this; } else { left.data = data; }; } public function toString():String{ return ((("[BinaryTreeNode, data= " + data) + "]")); } public function getDepth(_arg1:BinaryTreeNode=null):int{ var _local2 = -1; var _local3 = -1; if (_arg1 == null){ _arg1 = this; }; if (_arg1.left){ _local2 = getDepth(_arg1.left); }; if (_arg1.right){ _local3 = getDepth(_arg1.right); }; return ((((_local2 > _local3)) ? _local2 : _local3 + 1)); } public function count():int{ var _local1 = 1; if (left){ _local1 = (_local1 + left.count()); }; if (right){ _local1 = (_local1 + right.count()); }; return (_local1); } public function isLeft():Boolean{ return ((this == parent.left)); } public function isRight():Boolean{ return ((this == parent.right)); } public function setRight(_arg1):void{ if (!right){ right = new BinaryTreeNode(_arg1); right.parent = this; } else { right.data = data; }; } public static function inorder(_arg1:BinaryTreeNode, _arg2:Function):void{ if (_arg1){ if (_arg1.left){ BinaryTreeNode.inorder(_arg1.left, _arg2); }; _arg2(_arg1); if (_arg1.right){ BinaryTreeNode.inorder(_arg1.right, _arg2); }; }; } public static function preorder(_arg1:BinaryTreeNode, _arg2:Function):void{ if (_arg1){ _arg2(_arg1); if (_arg1.left){ BinaryTreeNode.preorder(_arg1.left, _arg2); }; if (_arg1.right){ BinaryTreeNode.preorder(_arg1.right, _arg2); }; }; } public static function postorder(_arg1:BinaryTreeNode, _arg2:Function):void{ if (_arg1){ if (_arg1.left){ BinaryTreeNode.postorder(_arg1.left, _arg2); }; if (_arg1.right){ BinaryTreeNode.postorder(_arg1.right, _arg2); }; _arg2(_arg1); }; } } }//package de.polygonal.ds
Section 102
//Collection (de.polygonal.ds.Collection) package de.polygonal.ds { public interface Collection { function get size():int; function isEmpty():Boolean; function getIterator():Iterator; function clear():void; function toArray():Array; function contains(_arg1):Boolean; } }//package de.polygonal.ds
Section 103
//Iterator (de.polygonal.ds.Iterator) package de.polygonal.ds { public interface Iterator { function start():void; function set data(_arg1):void; function get data(); function next(); function hasNext():Boolean; } }//package de.polygonal.ds
Section 104
//LinkedListNode (de.polygonal.ds.LinkedListNode) package de.polygonal.ds { public interface LinkedListNode { } }//package de.polygonal.ds
Section 105
//SLinkedList (de.polygonal.ds.SLinkedList) package de.polygonal.ds { import de.polygonal.ds.sort.*; import de.polygonal.ds.sort.compare.*; public class SLinkedList implements Collection { private var _count:int; public var tail:SListNode; public var head:SListNode; public static const MERGE_SORT:int = (1 << 2); public static const DESCENDING:int = (1 << 4); public static const NUMERIC:int = (1 << 3); public static const INSERTION_SORT:int = (1 << 1); public function SLinkedList(... _args){ head = (tail = null); _count = 0; if (_args.length > 0){ append.apply(this, _args); }; } public function get size():int{ return (_count); } public function isEmpty():Boolean{ return ((_count == 0)); } public function remove(_arg1:SListIterator):Boolean{ if (((!((_arg1.list == this))) || (!(_arg1.node)))){ return (false); }; var _local2:SListNode = head; if (_arg1.node == head){ _arg1.forth(); removeHead(); return (true); }; while (_local2.next != _arg1.node) { _local2 = _local2.next; }; _arg1.forth(); if (_local2.next == tail){ tail = _local2; }; _local2.next = _arg1.node; _count--; return (true); } public function removeHead(){ var _local1:*; var _local2:SListNode; if (head){ _local1 = head.data; if (head == tail){ head = (tail = null); } else { _local2 = head; head = head.next; _local2.next = null; if (head == null){ tail = null; }; }; _count--; return (_local1); }; return (null); } public function clear():void{ var _local2:SListNode; var _local1:SListNode = head; head = null; while (_local1) { _local2 = _local1.next; _local1.next = null; _local1 = _local2; }; _count = 0; } public function prepend(... _args):SListNode{ var _local4:SListNode; var _local5:int; var _local2:int = _args.length; var _local3:SListNode = new SListNode(_args[int((_local2 - 1))]); if (head){ _local3.next = head; head = _local3; } else { head = (tail = _local3); }; if (_local2 > 1){ _local4 = _local3; _local5 = (_local2 - 2); while (_local5 >= 0) { _local3 = new SListNode(_args[_local5]); _local3.next = head; head = _local3; _local5--; }; _count = (_count + _local2); return (_local4); }; _count++; return (_local3); } public function popDown():void{ var _local2:SListNode; var _local1:SListNode = tail; if (head.next == tail){ tail = head; head = _local1; tail.next = null; head.next = tail; } else { _local2 = head; while (_local2.next != tail) { _local2 = _local2.next; }; tail = _local2; tail.next = null; _local1.next = head; head = _local1; }; } public function concat(... _args):SLinkedList{ var _local3:SLinkedList; var _local4:SListNode; var _local2:SLinkedList = new SLinkedList(); _local4 = head; while (_local4) { _local2.append(_local4.data); _local4 = _local4.next; }; var _local5:int = _args.length; var _local6:int; while (_local6 < _local5) { _local3 = _args[_local6]; _local4 = _local3.head; while (_local4) { _local2.append(_local4.data); _local4 = _local4.next; }; _local6++; }; return (_local2); } public function append(... _args):SListNode{ var _local4:SListNode; var _local5:int; var _local2:int = _args.length; var _local3:SListNode = new SListNode(_args[0]); if (head){ tail.next = _local3; tail = _local3; } else { head = (tail = _local3); }; if (_local2 > 1){ _local4 = _local3; _local5 = 1; while (_local5 < _local2) { _local3 = new SListNode(_args[_local5]); tail.next = _local3; tail = _local3; _local5++; }; _count = (_count + _local2); return (_local4); }; _count++; return (_local3); } public function sort(... _args):void{ var _local2:int; var _local3:Function; var _local4:*; if (_count <= 1){ return; }; if (_args.length > 0){ _local2 = 0; _local3 = null; _local4 = _args[0]; if ((_local4 is Function)){ _local3 = _local4; if (_args.length > 1){ _local4 = _args[1]; if ((_local4 is int)){ _local2 = _local4; }; }; } else { if ((_local4 is int)){ _local2 = _local4; }; }; if (Boolean(_local3)){ if ((_local2 & 2)){ head = sLinkedInsertionSortCmp(head, _local3, (_local2 == 18)); } else { head = sLinkedMergeSortCmp(head, _local3, (_local2 == 16)); }; } else { if ((_local2 & 2)){ if ((_local2 & 4)){ if (_local2 == 22){ head = sLinkedInsertionSortCmp(head, compareStringCaseSensitiveDesc); } else { if (_local2 == 14){ head = sLinkedInsertionSortCmp(head, compareStringCaseInSensitive); } else { if (_local2 == 30){ head = sLinkedInsertionSortCmp(head, compareStringCaseInSensitiveDesc); } else { head = sLinkedInsertionSortCmp(head, compareStringCaseSensitive); }; }; }; } else { head = sLinkedInsertionSort(head, (_local2 == 18)); }; } else { if ((_local2 & 4)){ if (_local2 == 20){ head = sLinkedMergeSortCmp(head, compareStringCaseSensitiveDesc); } else { if (_local2 == 12){ head = sLinkedMergeSortCmp(head, compareStringCaseInSensitive); } else { if (_local2 == 28){ head = sLinkedMergeSortCmp(head, compareStringCaseInSensitiveDesc); } else { head = sLinkedMergeSortCmp(head, compareStringCaseSensitive); }; }; }; } else { if ((_local2 & 16)){ head = sLinkedMergeSort(head, true); }; }; }; }; } else { head = sLinkedMergeSort(head); }; } public function reverse():void{ if (_count == 0){ return; }; var _local1:Array = new Array(_count); var _local2:int; var _local3:SListNode = head; while (_local3) { var _temp1 = _local2; _local2 = (_local2 + 1); var _local4 = _temp1; _local1[_local4] = _local3; _local3 = _local3.next; }; _local1.reverse(); _local3 = (head = _local1[0]); _local2 = 1; while (_local2 < _count) { _local3 = (_local3.next = _local1[_local2]); _local2++; }; _local3.next = null; tail = _local3; _local1 = null; } public function insertAfter(_arg1:SListIterator, _arg2):SListNode{ var _local3:SListNode; if (_arg1.list != this){ return (null); }; if (_arg1.node){ _local3 = new SListNode(_arg2); _arg1.node.insertAfter(_local3); if (_arg1.node == tail){ tail = _arg1.node.next; }; _count++; return (_local3); //unresolved jump }; return (append(_arg2)); } public function getIterator():Iterator{ return (new SListIterator(this, head)); } public function toArray():Array{ var _local1:Array = []; var _local2:SListNode = head; while (_local2) { _local1.push(_local2.data); _local2 = _local2.next; }; return (_local1); } public function contains(_arg1):Boolean{ var _local2:SListNode = head; while (_local2) { if (_local2.data == _arg1){ return (true); }; _local2 = _local2.next; }; return (false); } public function getListIterator():SListIterator{ return (new SListIterator(this, head)); } public function join(_arg1):String{ if (_count == 0){ return (""); }; var _local2 = ""; var _local3:SListNode = head; while (_local3.next) { _local2 = (_local2 + (_local3.data + _arg1)); _local3 = _local3.next; }; _local2 = (_local2 + _local3.data); return (_local2); } public function toString():String{ return ((("[SlinkedList, size=" + size) + "]")); } public function removeTail(){ var _local1:*; var _local2:SListNode; if (tail){ _local1 = tail.data; if (head == tail){ head = (tail = null); } else { _local2 = head; while (_local2.next != tail) { _local2 = _local2.next; }; tail = _local2; _local2.next = null; }; _count--; return (_local1); }; return (null); } public function merge(... _args):void{ var _local2:SLinkedList; if (_args.length == 0){ return; }; _local2 = _args[0]; if (head){ tail.next = _local2.head; tail = _local2.tail; } else { head = _local2.head; tail = _local2.tail; }; _count = (_count + _local2.size); var _local3:int = _args.length; var _local4 = 1; while (_local4 < _local3) { _local2 = _args[_local4]; tail.next = _local2.head; tail = _local2.tail; _count = (_count + _local2.size); _local4++; }; } public function nodeOf(_arg1, _arg2:SListIterator=null):SListIterator{ if (_arg2 != null){ if (_arg2.list != null){ return (null); }; }; var _local3:SListNode = ((_arg2)==null) ? head : _arg2.node; while (_local3) { if (_local3.data === _arg1){ return (new SListIterator(this, _local3)); }; _local3 = _local3.next; }; return (null); } public function dump():String{ if (!head){ return ("SLinkedList: (empty)"); }; var _local1 = (((("SLinkedList: has " + _count) + " node") + ((_count == 1)) ? "" : "s") + "\n|< Head\n"); var _local2:SListIterator = getListIterator(); while (_local2.valid()) { _local1 = (_local1 + (("\t" + _local2.data) + "\n")); _local2.forth(); }; _local1 = (_local1 + "Tail >|"); return (_local1); } public function splice(_arg1:SListIterator, _arg2:uint=4294967295, ... _args):SLinkedList{ var _local4:SListNode; var _local5:SListNode; var _local6:SLinkedList; var _local7:int; var _local8:int; var _local9:SListNode; if (_arg1){ if (_arg1.list != this){ return (null); }; }; if (_arg1.node){ _local4 = _arg1.node; _local5 = head; while (_local5.next != _local4) { _local5 = _local5.next; }; _local6 = new SLinkedList(); if (_arg2 == 4294967295){ if (_arg1.node == tail){ return (_local6); }; while (_arg1.node) { _local6.append(_arg1.node.data); _arg1.remove(); }; _arg1.list = _local6; _arg1.node = _local4; return (_local6); } else { _local7 = 0; while (_local7 < _arg2) { if (_arg1.node){ _local6.append(_arg1.node.data); _arg1.remove(); } else { break; }; _local7++; }; }; _local8 = _args.length; if (_local8 > 0){ if (_count == 0){ _local7 = 0; while (_local7 < _local8) { append(_args[_local7]); _local7++; }; } else { if (_local5 == null){ _local9 = prepend(_args[0]); _local7 = 1; while (_local7 < _local8) { _local9.insertAfter(new SListNode(_args[_local7])); if (_local9 == tail){ tail = _local9.next; }; _local9 = _local9.next; _count++; _local7++; }; } else { _local9 = _local5; _local7 = 0; while (_local7 < _local8) { _local9.insertAfter(new SListNode(_args[_local7])); if (_local9 == tail){ tail = _local9.next; }; _local9 = _local9.next; _count++; _local7++; }; }; }; _arg1.node = _local9; } else { _arg1.node = _local4; }; _arg1.list = _local6; return (_local6); }; return (null); } public function shiftUp():void{ var _local1:SListNode = head; if (head.next == tail){ head = tail; tail = _local1; tail.next = null; head.next = tail; } else { head = head.next; tail.next = _local1; _local1.next = null; tail = _local1; }; } } }//package de.polygonal.ds
Section 106
//SListIterator (de.polygonal.ds.SListIterator) package de.polygonal.ds { public class SListIterator implements Iterator { public var node:SListNode; public var list:SLinkedList; public function SListIterator(_arg1:SLinkedList=null, _arg2:SListNode=null){ this.list = _arg1; this.node = _arg2; } public function remove():Boolean{ return (list.remove(this)); } public function start():void{ if (list){ node = list.head; }; } public function get data(){ if (node){ return (node.data); }; return (null); } public function forth():void{ if (node){ node = node.next; }; } public function toString():String{ return ((("{SListIterator: data=" + node.data) + "}")); } public function hasNext():Boolean{ return (Boolean(node)); } public function valid():Boolean{ return (Boolean(node)); } public function next(){ var _local1:*; if (hasNext()){ _local1 = node.data; node = node.next; return (_local1); }; return (null); } public function set data(_arg1):void{ node.data = _arg1; } public function end():void{ if (list){ node = list.tail; }; } } }//package de.polygonal.ds
Section 107
//SListNode (de.polygonal.ds.SListNode) package de.polygonal.ds { public class SListNode implements LinkedListNode { public var next:SListNode; public var data; public function SListNode(_arg1){ data = _arg1; next = null; } public function insertAfter(_arg1:SListNode):void{ _arg1.next = next; next = _arg1; } public function toString():String{ return ((("[SListNode, data=" + data) + "]")); } } }//package de.polygonal.ds
Section 108
//BroadPhase (de.polygonal.motor2.collision.nbody.BroadPhase) package de.polygonal.motor2.collision.nbody { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; public interface BroadPhase { function findPairs():void; function moveProxy(_arg1:int):void; function setWorldBounds(_arg1:AABB2):void; function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int; function setPairHandler(_arg1:PairCallback):void; function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean; function createProxy(_arg1:ShapeSkeleton):int; function destroyProxy(_arg1:int):void; function deconstruct():void; function getProxy(_arg1:int):Proxy; function getProxyList():Array; function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int; } }//package de.polygonal.motor2.collision.nbody
Section 109
//BufferedPair (de.polygonal.motor2.collision.nbody.BufferedPair) package de.polygonal.motor2.collision.nbody { public class BufferedPair extends UnbufferedPair { public var bits:int; public var next:int; public static const PAIR_FINAL:int = 4; public static const PAIR_BUFFERED:int = 1; public static const PAIR_ACTIVE:int = 8; public static const PAIR_REMOVED:int = 2; public function getFinal():Boolean{ return (((bits & PAIR_FINAL) == PAIR_FINAL)); } public function setBuffered():void{ bits = (bits | PAIR_BUFFERED); } public function clrBuffered():void{ bits = (bits & ~(PAIR_BUFFERED)); } public function getRemoved():Boolean{ return (((bits & PAIR_REMOVED) == PAIR_REMOVED)); } public function setFinal():void{ bits = (bits | PAIR_FINAL); } public function getBuffered():Boolean{ return (((bits & PAIR_BUFFERED) == PAIR_BUFFERED)); } public function clrRemoved():void{ bits = (bits & ~(PAIR_REMOVED)); } public function setRemoved():void{ bits = (bits | PAIR_REMOVED); } } }//package de.polygonal.motor2.collision.nbody
Section 110
//BufferedPairManager (de.polygonal.motor2.collision.nbody.BufferedPairManager) package de.polygonal.motor2.collision.nbody { import flash.utils.*; public class BufferedPairManager { public var _callback:PairCallback; private var _freePair:int; private var _pairTable:Dictionary; private var _pairCount:int; public var _broadPhase:BroadPhase; private var _pairBuffer:Array; private var _pairs:Array; private var _pairBufferCount:int; public static const NULL_PAIR:int = 0xFFFF; public function BufferedPairManager(_arg1:int, _arg2:PairCallback, _arg3:BroadPhase){ var _local4:BufferedPair; var _local5:int; super(); _callback = _arg2; _broadPhase = _arg3; _pairTable = new Dictionary(true); _pairs = new Array((_arg1 + 1), true); _local5 = 1; while (_local5 < (_arg1 + 1)) { _local4 = new BufferedPair(); _local4.proxyId1 = Proxy.NULL_PROXY; _local4.proxyId2 = Proxy.NULL_PROXY; _local4.contact = null; _local4.bits = 0; _local4.next = (_local5 + 1); _pairs[_local5] = _local4; _local5++; }; _pairs[_arg1].next = NULL_PAIR; _freePair = 1; _pairCount = 0; _pairBufferCount = 0; _pairBuffer = new Array(_arg1, true); _local5 = 0; while (_local5 < _arg1) { _pairBuffer[_local5] = new BufferedPair(); _local5++; }; } private function getKey(_arg1:int, _arg2:int):int{ if (_arg1 < _arg2){ return (((_arg1 << 16) | _arg2)); }; return (((_arg2 << 16) | _arg1)); } public function commit():void{ var _local1:BufferedPair; var _local3:int; var _local4:int; var _local5:BufferedPair; var _local7:Proxy; var _local8:Proxy; var _local2:int; var _local6:int; while (_local6 < _pairBufferCount) { _local1 = _pairBuffer[_local6]; _local3 = getKey(_local1.proxyId1, _local1.proxyId2); _local4 = _pairTable[_local3]; _local5 = _pairs[_local4]; _local5.clrBuffered(); _local7 = _broadPhase.getProxy(_local5.proxyId1); _local8 = _broadPhase.getProxy(_local5.proxyId2); if (_local5.getRemoved()){ if (_local5.getFinal()){ _callback.pairRemoved(_local5.contact); }; _local1 = _pairBuffer[_local2]; _local1.proxyId1 = _local5.proxyId1; _local1.proxyId2 = _local5.proxyId2; _local2++; } else { if (!_local5.getFinal()){ _local5.contact = _callback.pairAdded(_local7.shape, _local8.shape); _local5.setFinal(); }; }; _local6++; }; _local6 = 0; while (_local6 < _local2) { _local1 = _pairBuffer[_local6]; _local3 = getKey(_local1.proxyId1, _local1.proxyId2); _local4 = _pairTable[_local3]; delete _pairTable[_local3]; _local5 = _pairs[_local4]; _local5.proxyId1 = Proxy.NULL_PROXY; _local5.proxyId2 = Proxy.NULL_PROXY; _local5.bits = 0; _local5.contact = null; _local5.next = _freePair; _freePair = _local4; _pairCount--; _local6++; }; _pairBufferCount = 0; } public function addPair(_arg1:int, _arg2:int):void{ var _local4:BufferedPair; var _local6:BufferedPair; var _local3:int = getKey(_arg1, _arg2); var _local5:int = _pairTable[_local3]; if (_local5 == 0){ _local5 = _freePair; _pairTable[_local3] = _local5; _local4 = _pairs[_local5]; _local4.proxyId1 = _arg1; _local4.proxyId2 = _arg2; _local4.bits = 0; _local4.contact = null; _freePair = _local4.next; _pairCount++; } else { _local4 = _pairs[_local5]; }; if (!_local4.getBuffered()){ _local4.setBuffered(); _local6 = _pairBuffer[_pairBufferCount]; _local6.proxyId1 = _local4.proxyId1; _local6.proxyId2 = _local4.proxyId2; _pairBufferCount++; }; _local4.clrRemoved(); } public function removePair(_arg1:int, _arg2:int):void{ var _local6:BufferedPair; var _local3:int = getKey(_arg1, _arg2); var _local4:int = _pairTable[_local3]; if (_local4 == 0){ return; }; var _local5:BufferedPair = _pairs[_local4]; if (!_local5.getBuffered()){ _local5.setBuffered(); _local6 = _pairBuffer[_pairBufferCount]; _local6.proxyId1 = _local5.proxyId1; _local6.proxyId2 = _local5.proxyId2; _pairBufferCount++; }; _local5.setRemoved(); } } }//package de.polygonal.motor2.collision.nbody
Section 111
//ExhaustiveSearch (de.polygonal.motor2.collision.nbody.ExhaustiveSearch) package de.polygonal.motor2.collision.nbody { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.*; import de.polygonal.motor2.math.*; import flash.system.*; public class ExhaustiveSearch implements BroadPhase { private var _xmax:Number; private var _ymin:Number; private var _proxyCount:int; private var _freeProxy:int; private var _ymax:Number; private var _proxyPool:Array; private var _proxyList:LinkedProxy; private var _pairManager:UnbufferedPairManager; private var _xmin:Number; public function ExhaustiveSearch(){ var _local3:LinkedProxy; super(); var _local1:uint = System.totalMemory; var _local2:int = Constants.k_maxProxies; _proxyPool = new Array(_local2, true); var _local4:int; while (_local4 < (_local2 - 1)) { _local3 = new LinkedProxy(); _local3.setNext((_local4 + 1)); _local3.id = _local4; _proxyPool[_local4] = _local3; _local4++; }; _local3 = new LinkedProxy(); _local3.setNext(Proxy.NULL_PROXY); _local3.id = (_local2 - 1); _proxyPool[(_local2 - 1)] = _local3; trace("/*////////////////////////////////////////////////////////*"); trace(" * EXHAUSTIVE SEARCH STATISTICS"); trace((" * max proxies = " + _local2)); trace(((" * memory = " + ((System.totalMemory - _local1) >> 10)) + " KiB")); trace(" ////////////////////////////////////////////////////////*/"); trace(""); } public function getProxyList():Array{ var _local2:int; var _local1:Array = new Array(_proxyCount, true); var _local3:LinkedProxy = _proxyList; while (_local3 != null) { var _temp1 = _local2; _local2 = (_local2 + 1); var _local4 = _temp1; _local1[_local4] = _local3; _local3 = _local3.next; }; return (_local1); } public function getProxy(_arg1:int):Proxy{ return (_proxyPool[_arg1]); } public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{ if (_arg1 < _xmin){ return (false); }; if (_arg3 > _xmax){ return (false); }; if (_arg2 < _ymin){ return (false); }; if (_arg4 > _ymax){ return (false); }; return (true); } public function createProxy(_arg1:ShapeSkeleton):int{ var _local2:int = _freeProxy; var _local3:LinkedProxy = _proxyPool[_local2]; _freeProxy = _local3.getNext(); _local3.next = _proxyList; if (_proxyList){ _proxyList.prev = _local3; }; _proxyList = _local3; _local3.shape = _arg1; _proxyCount++; return (_local2); } public function setPairHandler(_arg1:PairCallback):void{ _pairManager = new UnbufferedPairManager(_arg1, this); } public function destroyProxy(_arg1:int):void{ var _local5:ShapeSkeleton; if (_arg1 == Proxy.NULL_PROXY){ return; }; var _local2:LinkedProxy = _proxyPool[_arg1]; var _local3:LinkedProxy = _proxyList; var _local4:ShapeSkeleton = _local2.shape; var _local6:Number = _local4.xmin; var _local7:Number = _local4.xmax; var _local8:Number = _local4.ymin; var _local9:Number = _local4.ymax; while (_local3 != null) { if (_local2 == _local3){ _local3 = _local3.next; } else { _local5 = _local3.shape; if ((((((((_local6 > _local5.xmax)) || ((_local7 < _local5.xmin)))) || ((_local8 > _local5.ymax)))) || ((_local9 < _local5.ymin)))){ _local3 = _local3.next; } else { if (_pairManager.removePair(_arg1, _local3.id)){ _local3.overlapCount--; }; _local3 = _local3.next; }; }; }; if (_local2.prev){ _local2.prev.next = _local2.next; }; if (_local2.next){ _local2.next.prev = _local2.prev; }; if (_local2 == _proxyList){ _proxyList = _local2.next; }; _local2.setNext(_freeProxy); _freeProxy = _arg1; _local2.reset(); _proxyCount--; } public function moveProxy(_arg1:int):void{ } public function setWorldBounds(_arg1:AABB2):void{ _xmin = _arg1.xmin; _ymin = _arg1.ymin; _xmax = _arg1.xmax; _ymax = _arg1.ymax; } public function findPairs():void{ var _local1:LinkedProxy; var _local2:ShapeSkeleton; var _local3:LinkedProxy; var _local4:ShapeSkeleton; _local1 = _proxyList; while (_local1 != null) { _local2 = _local1.shape; _local3 = _local1.next; while (_local3 != null) { _local4 = _local3.shape; if ((((((((_local2.xmin > _local4.xmax)) || ((_local2.xmax < _local4.xmin)))) || ((_local2.ymin > _local4.ymax)))) || ((_local2.ymax < _local4.ymin)))){ if ((_local1.overlapCount * _local3.overlapCount) > 0){ if (_pairManager.removePair(_local1.id, _local3.id)){ _local1.overlapCount++; _local3.overlapCount++; }; }; } else { if (_pairManager.addPair(_local1.id, _local3.id)){ _local1.overlapCount++; _local3.overlapCount++; }; }; _local3 = _local3.next; }; _local1 = _local1.next; }; } public function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int{ var _local9:ShapeSkeleton; if (_arg2.fixed){ _arg3 = _arg2.length; }; var _local4:Number = _arg1.xmin; var _local5:Number = _arg1.xmax; var _local6:Number = _arg1.ymin; var _local7:Number = _arg1.ymax; var _local8:LinkedProxy = _proxyList; var _local10:int; while (_local8 != null) { _local9 = _local8.shape; if ((((((((_local9.xmin > _local5)) || ((_local9.xmax < _local4)))) || ((_local9.ymin > _local7)))) || ((_local9.ymax < _local6)))){ _local8 = _local8.next; } else { var _temp1 = _local10; _local10 = (_local10 + 1); var _local11 = _temp1; _arg2[_local11] = _local9; if (_local10 == _arg3){ break; }; _local8 = _local8.next; }; }; return (_local10); } public function deconstruct():void{ var _local1:LinkedProxy; var _local2:LinkedProxy = _proxyList; while (_local2 != null) { _local1 = _local2; _local2 = _local2.next; _local1.next = null; _local1.prev = null; _local1.shape = null; }; _proxyPool = null; _pairManager = null; } public function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int{ var _local8:ShapeSkeleton; if (_arg2.fixed){ _arg3 = _arg2.length; }; var _local4:Number = _arg1.c.x; var _local5:Number = _arg1.c.y; var _local6:Number = _arg1.radius; var _local7:LinkedProxy = _proxyList; var _local9:int; while (_local7 != null) { _local8 = _local7.shape; if ((((_local8.x - _local4) * (_local8.x - _local4)) + ((_local8.y - _local5) * (_local8.y - _local5))) <= ((_local8.radius + _local6) * (_local8.radius + _local6))){ var _temp1 = _local9; _local9 = (_local9 + 1); var _local10 = _temp1; _arg2[_local10] = _local8; if (_local9 == _arg3){ break; }; }; _local7 = _local7.next; }; return (_local9); } } }//package de.polygonal.motor2.collision.nbody
Section 112
//LinkedProxy (de.polygonal.motor2.collision.nbody.LinkedProxy) package de.polygonal.motor2.collision.nbody { public class LinkedProxy extends Proxy { public var next:LinkedProxy; public var prev:LinkedProxy; override public function reset():void{ next = null; prev = null; super.reset(); } } }//package de.polygonal.motor2.collision.nbody
Section 113
//PairCallback (de.polygonal.motor2.collision.nbody.PairCallback) package de.polygonal.motor2.collision.nbody { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.contact.*; public interface PairCallback { function pairRemoved(_arg1:Contact):void; function pairAdded(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact; } }//package de.polygonal.motor2.collision.nbody
Section 114
//Proxy (de.polygonal.motor2.collision.nbody.Proxy) package de.polygonal.motor2.collision.nbody { import de.polygonal.motor2.collision.shapes.*; public class Proxy { public var shape:ShapeSkeleton; public var overlapCount:int; private var _next:int; public var id:int; public static const NULL_PROXY:int = 0xFFFF; public function getNext():int{ return (_next); } public function reset():void{ overlapCount = 0; shape = null; } public function setNext(_arg1:int):void{ _next = _arg1; } } }//package de.polygonal.motor2.collision.nbody
Section 115
//SAP (de.polygonal.motor2.collision.nbody.SAP) package de.polygonal.motor2.collision.nbody { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.*; import de.polygonal.motor2.math.*; import flash.geom.*; import flash.system.*; public class SAP implements BroadPhase { private var _yQuantizationFactor:Number; private var _xmin0:Number; private var _ymin:Number; private var _ymin1:Number; private var _tempInterval:QueryInterval; private var _maxProxies:int; private var _ymax:Number; private var _proxyPool:Array; private var _ybounds:Array; private var _pairManager:BufferedPairManager; private var _xmin:Number; private var _xmin1:Number; private var _xmax0:Number; private var _ymax1:Number; private var _xQuantizationFactor:Number; private var _xmax:Number; private var _ymax0:Number; private var _ymin0:Number; private var _xmax1:Number; private var _proxyCount:int; private var _freeProxy:int; private var _queryResultCount:int; private var _queryResults:Array; private var _xbounds:Array; private var _timeStamp:int; public function SAP(){ var _local2:SAPProxy; super(); var _local1:uint = System.totalMemory; _maxProxies = Constants.k_maxProxies; _queryResults = new Array(_maxProxies, true); _tempInterval = new QueryInterval(); _proxyPool = new Array(Constants.k_maxPairs, true); var _local3:int; while (_local3 < (_maxProxies - 1)) { _local2 = new SAPProxy(); _proxyPool[_local3] = _local2; _local2.setNext((_local3 + 1)); _local2.reset(); _local3++; }; _local2 = (_proxyPool[(_maxProxies - 1)] = new SAPProxy()); _local2.setNext(Proxy.NULL_PROXY); _local2.reset(); _proxyCount = (_freeProxy = (_queryResultCount = 0)); _timeStamp = 1; _xbounds = new Array((2 * _maxProxies)); _ybounds = new Array((2 * _maxProxies)); _local3 = 0; while (_local3 < (_maxProxies << 1)) { _xbounds[_local3] = new Bound(); _ybounds[_local3] = new Bound(); _local3++; }; } public function getProxyList():Array{ return (null); } private function binarySearch(_arg1:Array, _arg2:int, _arg3:int):int{ var _local6:int; var _local7:Bound; var _local4:int; var _local5:int = (_arg2 - 1); while (_local4 <= _local5) { _local6 = ((_local4 + _local5) >> 1); _local7 = _arg1[_local6]; if (_local7.value > _arg3){ _local5 = (_local6 - 1); } else { if (_local7.value < _arg3){ _local4 = (_local6 + 1); } else { _local4 = _local6; break; }; }; }; return (_local4); } private function rangeQuery(_arg1:QueryInterval, _arg2:int, _arg3:int, _arg4:Array, _arg5:int, _arg6:int):void{ var _local9:int; var _local10:int; var _local11:SAPProxy; var _local7:int = (_arg1.lower = binarySearch(_arg4, _arg5, _arg2)); var _local8:int = (_arg1.upper = binarySearch(_arg4, _arg5, _arg3)); _local9 = _local7; while (_local9 < _local8) { if (_arg4[_local9].isLower()){ incrementOverlapCount(_arg4[_local9].proxyId); }; _local9++; }; if (_local7 > 0){ _local9 = (_local7 - 1); _local10 = _arg4[_local9].stabbingCount; if (_arg6 == 0){ while (_local10 > 0) { if (_arg4[_local9].isLower()){ _local11 = _proxyPool[_arg4[_local9].proxyId]; if (_local7 <= _local11.xmax){ incrementOverlapCount(_arg4[_local9].proxyId); _local10--; }; }; _local9--; }; } else { while (_local10 > 0) { if (_arg4[_local9].isLower()){ _local11 = _proxyPool[_arg4[_local9].proxyId]; if (_local7 <= _local11.ymax){ incrementOverlapCount(_arg4[_local9].proxyId); _local10--; }; }; _local9--; }; }; }; } public function destroyProxy(_arg1:int):void{ var _local2:Bound; var _local3:Bound; var _local5:SAPProxy; var _local7:int; var _local8:int; var _local9:int; var _local10:int; var _local11:int; var _local12:int; if (_arg1 == Proxy.NULL_PROXY){ return; }; var _local4:SAPProxy = _proxyPool[_arg1]; var _local6 = (_proxyCount << 1); _local7 = _local4.xmin; _local9 = _local4.xmax; _local2 = _xbounds[_local7]; _local8 = _local2.value; _local3 = _xbounds[_local9]; _local10 = _local3.value; _xbounds.splice(_local7, 1); _xbounds.splice((_local9 - 1), 1); _local11 = (_local6 - 2); _local12 = _local7; while (_local12 < _local11) { _local2 = _xbounds[_local12]; _local5 = _proxyPool[_local2.proxyId]; if (_local2.isLower()){ _local5.xmin = _local12; } else { _local5.xmax = _local12; }; _local12++; }; _local11 = (_local9 - 1); _local12 = _local7; while (_local12 < _local11) { _local2 = _xbounds[_local12]; _local2.stabbingCount--; _local12++; }; rangeQuery(_tempInterval, _local8, _local10, _xbounds, (_local6 - 2), 0); _local7 = _local4.ymin; _local9 = _local4.ymax; _local2 = _ybounds[_local7]; _local8 = _local2.value; _local3 = _ybounds[_local9]; _local10 = _local3.value; _ybounds.splice(_local7, 1); _ybounds.splice((_local9 - 1), 1); _local11 = (_local6 - 2); _local12 = _local7; while (_local12 < _local11) { _local2 = _ybounds[_local12]; _local5 = _proxyPool[_local2.proxyId]; if (_local2.isLower()){ _local5.ymin = _local12; } else { _local5.ymax = _local12; }; _local12++; }; _local11 = (_local9 - 1); _local12 = _local7; while (_local12 < _local11) { _local2 = _ybounds[_local12]; _local2.stabbingCount--; _local12++; }; rangeQuery(_tempInterval, _local8, _local10, _ybounds, (_local6 - 2), 1); var _local13:int; while (_local13 < _queryResultCount) { _pairManager.removePair(_arg1, _queryResults[_local13]); _local13++; }; _pairManager.commit(); _queryResultCount = 0; incrementTimeStamp(); _local4.shape = null; _local4.overlapCount = Constants.k_invalid; _local4.xmin = Constants.k_invalid; _local4.ymin = Constants.k_invalid; _local4.xmax = Constants.k_invalid; _local4.ymax = Constants.k_invalid; _local4.setNext(_freeProxy); _freeProxy = _arg1; _proxyCount--; } public function moveProxy(_arg1:int):void{ var _local4:int; var _local5:Bound; var _local6:SAPProxy; var _local7:SAPProxy; var _local8:int; var _local9:int; var _local10:Bound; var _local11:Bound; var _local12:int; var _local13:int; var _local14:int; var _local15:int; var _local16:int; var _local17:int; var _local2:SAPProxy = _proxyPool[_arg1]; var _local3 = (_proxyCount << 1); _xmin1 = ((_xQuantizationFactor * (clamp(_local2.shape.xmin, _xmin, _xmax) - _xmin)) & (0xFFFF - 1)); _xmax1 = ((_xQuantizationFactor * (clamp(_local2.shape.xmax, _xmin, _xmax) - _xmin)) | 1); _ymin1 = ((_yQuantizationFactor * (clamp(_local2.shape.ymin, _ymin, _ymax) - _ymin)) & (0xFFFF - 1)); _ymax1 = ((_yQuantizationFactor * (clamp(_local2.shape.ymax, _ymin, _ymax) - _ymin)) | 1); _xmin0 = _xbounds[_local2.xmin].value; _xmax0 = _xbounds[_local2.xmax].value; _ymin0 = _ybounds[_local2.ymin].value; _ymax0 = _ybounds[_local2.ymax].value; _local12 = _local2.xmin; _local15 = _local2.xmax; _local13 = _xmin1; _local16 = _xmax1; _local14 = (_local13 - _xbounds[_local12].value); _local17 = (_local16 - _xbounds[_local15].value); _xbounds[_local12].value = _local13; _xbounds[_local15].value = _local16; if (_local14 < 0){ _local4 = _local12; while ((((_local4 > 0)) && ((_local13 < _xbounds[int((_local4 - 1))].value)))) { _local5 = _xbounds[_local4]; _local10 = _xbounds[int((_local4 - 1))]; _local8 = _local10.proxyId; _local6 = _proxyPool[_local10.proxyId]; _local10.stabbingCount++; if (_local10.isUpper()){ if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local6)){ _pairManager.addPair(_arg1, _local8); }; _local6.xmax++; _local5.stabbingCount++; } else { _local6.xmin++; _local5.stabbingCount--; }; _local2.xmin--; swapBounds(_local5, _local10); _local4--; }; }; if (_local17 > 0){ _local4 = _local15; while ((((_local4 < (_local3 - 1))) && ((_xbounds[int((_local4 + 1))].value <= _local16)))) { _local5 = _xbounds[_local4]; _local11 = _xbounds[int((_local4 + 1))]; _local9 = _local11.proxyId; _local7 = _proxyPool[_local9]; _local11.stabbingCount++; if (_local11.isLower()){ if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local7)){ _pairManager.addPair(_arg1, _local9); }; _local7.xmin--; _local5.stabbingCount++; } else { _local7.xmax--; _local5.stabbingCount--; }; _local2.xmax++; swapBounds(_local5, _local11); _local4++; }; }; if (_local14 > 0){ _local4 = _local12; while ((((_local4 < (_local3 - 1))) && ((_xbounds[int((_local4 + 1))].value <= _local13)))) { _local5 = _xbounds[_local4]; _local11 = _xbounds[int((_local4 + 1))]; _local9 = _local11.proxyId; _local7 = _proxyPool[_local9]; _local11.stabbingCount--; if (_local11.isUpper()){ if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local7)){ _pairManager.removePair(_arg1, _local9); }; _local7.xmax--; _local5.stabbingCount--; } else { _local7.xmin--; _local5.stabbingCount++; }; _local2.xmin++; swapBounds(_local5, _local11); _local4++; }; }; if (_local17 < 0){ _local4 = _local15; while ((((_local4 > 0)) && ((_local16 < _xbounds[int((_local4 - 1))].value)))) { _local5 = _xbounds[_local4]; _local10 = _xbounds[(_local4 - 1)]; _local8 = _local10.proxyId; _local6 = _proxyPool[_local8]; _local10.stabbingCount--; if (_local10.isLower()){ if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local6)){ _pairManager.removePair(_arg1, _local8); }; _local6.xmin++; _local5.stabbingCount--; } else { _local6.xmax++; _local5.stabbingCount++; }; _local2.xmax--; swapBounds(_local5, _local10); _local4--; }; }; _local12 = _local2.ymin; _local15 = _local2.ymax; _local13 = _ymin1; _local16 = _ymax1; _local14 = (_local13 - _ybounds[_local12].value); _local17 = (_local16 - _ybounds[_local15].value); _ybounds[_local12].value = _local13; _ybounds[_local15].value = _local16; if (_local14 < 0){ _local4 = _local12; while ((((_local4 > 0)) && ((_local13 < _ybounds[int((_local4 - 1))].value)))) { _local5 = _ybounds[_local4]; _local10 = _ybounds[int((_local4 - 1))]; _local8 = _local10.proxyId; _local6 = _proxyPool[_local10.proxyId]; _local10.stabbingCount++; if (_local10.isUpper()){ if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local6)){ _pairManager.addPair(_arg1, _local8); }; _local6.ymax++; _local5.stabbingCount++; } else { _local6.ymin++; _local5.stabbingCount--; }; _local2.ymin--; swapBounds(_local5, _local10); _local4--; }; }; if (_local17 > 0){ _local4 = _local15; while ((((_local4 < (_local3 - 1))) && ((_ybounds[int((_local4 + 1))].value <= _local16)))) { _local5 = _ybounds[_local4]; _local11 = _ybounds[int((_local4 + 1))]; _local9 = _local11.proxyId; _local7 = _proxyPool[_local9]; _local11.stabbingCount++; if (_local11.isLower()){ if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local7)){ _pairManager.addPair(_arg1, _local9); }; _local7.ymin--; _local5.stabbingCount++; } else { _local7.ymax--; _local5.stabbingCount--; }; _local2.ymax++; swapBounds(_local5, _local11); _local4++; }; }; if (_local14 > 0){ _local4 = _local12; while ((((_local4 < (_local3 - 1))) && ((_ybounds[int((_local4 + 1))].value <= _local13)))) { _local5 = _ybounds[_local4]; _local11 = _ybounds[int((_local4 + 1))]; _local9 = _local11.proxyId; _local7 = _proxyPool[_local9]; _local11.stabbingCount--; if (_local11.isUpper()){ if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local7)){ _pairManager.removePair(_arg1, _local9); }; _local7.ymax--; _local5.stabbingCount--; } else { _local7.ymin--; _local5.stabbingCount++; }; _local2.ymin++; swapBounds(_local5, _local11); _local4++; }; }; if (_local17 < 0){ _local4 = _local15; while ((((_local4 > 0)) && ((_local16 < _ybounds[int((_local4 - 1))].value)))) { _local5 = _ybounds[_local4]; _local10 = _ybounds[(_local4 - 1)]; _local8 = _local10.proxyId; _local6 = _proxyPool[_local8]; _local10.stabbingCount--; if (_local10.isLower()){ if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local6)){ _pairManager.removePair(_arg1, _local8); }; _local6.ymin++; _local5.stabbingCount--; } else { _local6.ymax++; _local5.stabbingCount++; }; _local2.ymax--; swapBounds(_local5, _local10); _local4--; }; }; } private function incrementOverlapCount(_arg1:int):void{ var _local2:SAPProxy = _proxyPool[_arg1]; if (_local2.timeStamp < _timeStamp){ _local2.timeStamp = _timeStamp; _local2.overlapCount = 1; } else { _local2.overlapCount = 2; _queryResults[_queryResultCount] = _arg1; _queryResultCount++; }; } public function findPairs():void{ _pairManager.commit(); } public function setWorldBounds(_arg1:AABB2):void{ _xmin = _arg1.xmin; _xmax = _arg1.xmax; _ymin = _arg1.ymin; _ymax = _arg1.ymax; var _local2:Number = (_arg1.xmax - _arg1.xmin); var _local3:Number = (_arg1.ymax - _arg1.ymin); _xQuantizationFactor = (0xFFFF / _local2); _yQuantizationFactor = (0xFFFF / _local3); } public function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int{ var _local5:SAPProxy; if (_arg2.fixed){ _arg3 = _arg2.length; }; _xmin0 = ((_xQuantizationFactor * (clamp(_arg1.xmin, _xmin, _xmax) - _xmin)) & (0xFFFF - 1)); _xmax0 = ((_xQuantizationFactor * (clamp(_arg1.xmax, _xmin, _xmax) - _xmin)) | 1); _ymin0 = ((_yQuantizationFactor * (clamp(_arg1.ymin, _ymin, _ymax) - _ymin)) & (0xFFFF - 1)); _ymax0 = ((_yQuantizationFactor * (clamp(_arg1.ymax, _ymin, _ymax) - _ymin)) | 1); rangeQuery(_tempInterval, _xmin0, _xmax0, _xbounds, (_proxyCount << 1), 0); rangeQuery(_tempInterval, _ymin0, _ymax0, _ybounds, (_proxyCount << 1), 1); var _local4:int; while (_local4 < _queryResultCount) { _local5 = _proxyPool[int(_queryResults[_local4])]; _arg2[_local4] = _local5.shape; if (_local4 == _arg3){ break; }; _local4++; }; _queryResultCount = 0; incrementTimeStamp(); return (_local4); } public function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int{ var _local7:ShapeSkeleton; if (_arg2.fixed){ _arg3 = _arg2.length; }; var _local4:Number = _arg1.c.x; var _local5:Number = _arg1.c.y; var _local6:Number = _arg1.radius; var _local8:int; var _local9:int; while (_local9 < _maxProxies) { _local7 = _proxyPool[_local9].shape; if (_local7 == null){ } else { if ((((_local7.x - _local4) * (_local7.x - _local4)) + ((_local7.y - _local5) * (_local7.y - _local5))) <= ((_local7.radius + _local6) * (_local7.radius + _local6))){ var _temp1 = _local8; _local8 = (_local8 + 1); var _local10 = _temp1; _arg2[_local10] = _local7; }; }; _local9++; }; return (_local8); } private function clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{ return (((_arg1)<_arg2) ? _arg2 : ((_arg1)>_arg3) ? _arg3 : _arg1); } public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{ var _local5:Number = (_arg1 - _xmax); var _local6:Number = (_xmin - _arg3); var _local7:Number = (_arg2 - _ymax); var _local8:Number = (_ymin - _arg4); _local5 = ((_local5 > _local6)) ? _local5 : _local6; _local7 = ((_local7 > _local8)) ? _local7 : _local8; return ((((_local5 > _local7)) ? _local5 : _local7 < 0)); } public function createProxy(_arg1:ShapeSkeleton):int{ var _local5:int; var _local6:Bound; var _local7:Bound; var _local8:int; var _local9:Bound; var _local10:int; var _local2:int = _freeProxy; var _local3:SAPProxy = _proxyPool[_local2]; _freeProxy = _local3.getNext(); _local3.overlapCount = 0; _local3.shape = _arg1; _xmin0 = ((_xQuantizationFactor * (clamp(_arg1.xmin, _xmin, _xmax) - _xmin)) & (0xFFFF - 1)); _xmax0 = ((_xQuantizationFactor * (clamp(_arg1.xmax, _xmin, _xmax) - _xmin)) | 1); _ymin0 = ((_yQuantizationFactor * (clamp(_arg1.ymin, _ymin, _ymax) - _ymin)) & (0xFFFF - 1)); _ymax0 = ((_yQuantizationFactor * (clamp(_arg1.ymax, _ymin, _ymax) - _ymin)) | 1); var _local4 = (_proxyCount << 1); rangeQuery(_tempInterval, _xmin0, _xmax0, _xbounds, _local4, 0); _local8 = _tempInterval.lower; _local10 = _tempInterval.upper; _xbounds.splice(_local8, 0, new Bound()); _local10++; _xbounds.splice(_local10, 0, new Bound()); _local7 = _xbounds[_local8]; _local7.value = _xmin0; _local7.proxyId = _local2; _local9 = _xbounds[_local10]; _local9.value = _xmax0; _local9.proxyId = _local2; _local7.stabbingCount = ((_local8)==0) ? 0 : _xbounds[int((_local8 - 1))].stabbingCount; _local9.stabbingCount = _xbounds[int((_local10 - 1))].stabbingCount; _local5 = _local8; while (_local5 < _local10) { _xbounds[_local5].stabbingCount++; _local5++; }; _local5 = _local8; while (_local5 < (_local4 + 2)) { _local6 = _xbounds[_local5]; _local3 = _proxyPool[_local6.proxyId]; if (_local6.isLower()){ _local3.xmin = _local5; } else { _local3.xmax = _local5; }; _local5++; }; rangeQuery(_tempInterval, _ymin0, _ymax0, _ybounds, _local4, 1); _local8 = _tempInterval.lower; _local10 = _tempInterval.upper; _ybounds.splice(_local8, 0, new Bound()); _local10++; _ybounds.splice(_local10, 0, new Bound()); _local7 = _ybounds[_local8]; _local7.value = _ymin0; _local7.proxyId = _local2; _local9 = _ybounds[_local10]; _local9.value = _ymax0; _local9.proxyId = _local2; _local7.stabbingCount = ((_local8)==0) ? 0 : _ybounds[int((_local8 - 1))].stabbingCount; _local9.stabbingCount = _ybounds[int((_local10 - 1))].stabbingCount; _local5 = _local8; while (_local5 < _local10) { _ybounds[_local5].stabbingCount++; _local5++; }; _local5 = _local8; while (_local5 < (_local4 + 2)) { _local6 = _ybounds[_local5]; _local3 = _proxyPool[_local6.proxyId]; if (_local6.isLower()){ _local3.ymin = _local5; } else { _local3.ymax = _local5; }; _local5++; }; _proxyCount++; var _local11:int; while (_local11 < _queryResultCount) { _pairManager.addPair(_local2, _queryResults[_local11]); _local11++; }; _pairManager.commit(); _queryResultCount = 0; incrementTimeStamp(); return (_local2); } public function setPairHandler(_arg1:PairCallback):void{ _pairManager = new BufferedPairManager(Constants.k_maxPairs, _arg1, this); } private function incrementTimeStamp():void{ var _local1:int; if (_timeStamp == 0xFFFF){ _local1 = 0; while (_local1 < _maxProxies) { _proxyPool[_local1].timeStamp = 0; _local1++; }; _timeStamp = 1; } else { _timeStamp++; }; } private function testOverlap(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:SAPProxy):Boolean{ if (_arg1 > _xbounds[_arg5.xmax].value){ return (false); }; if (_arg3 < _xbounds[_arg5.xmin].value){ return (false); }; if (_arg2 > _ybounds[_arg5.ymax].value){ return (false); }; if (_arg4 < _ybounds[_arg5.ymin].value){ return (false); }; return (true); } public function getProxy(_arg1:int):Proxy{ var _local2:SAPProxy = _proxyPool[_arg1]; if (_arg1 == Proxy.NULL_PROXY){ return (null); }; return (_local2); } public function deconstruct():void{ var _local1:int; while (_local1 < _maxProxies) { _proxyPool[_local1].shape = null; _local1++; }; _proxyPool = null; } public function querySegment(_arg1:Point, _arg2:Point, _arg3:Array, _arg4:int=-1):int{ return (0); } private function swapBounds(_arg1:Bound, _arg2:Bound):void{ var _local3:int = _arg2.value; _arg2.value = _arg1.value; _arg1.value = _local3; _local3 = _arg2.proxyId; _arg2.proxyId = _arg1.proxyId; _arg1.proxyId = _local3; _local3 = _arg2.stabbingCount; _arg2.stabbingCount = _arg1.stabbingCount; _arg1.stabbingCount = _local3; } } }//package de.polygonal.motor2.collision.nbody class QueryInterval { public var lower:int; public var upper:int; private function QueryInterval(){ } } class BoundValues { public var ymin:int; public var xmin:int; public var ymax:int; public var xmax:int; private function BoundValues(){ } } class Bound { public var value:int; public var proxyId:int; public var stabbingCount:int; private function Bound(){ } public function swap(_arg1:Bound):void{ var _local2:int; _local2 = value; value = _arg1.value; _arg1.value = _local2; _local2 = proxyId; proxyId = _arg1.proxyId; _arg1.proxyId = _local2; _local2 = stabbingCount; stabbingCount = _arg1.stabbingCount; _arg1.stabbingCount = _local2; } public function isLower():Boolean{ return (((value & 1) == 0)); } public function isUpper():Boolean{ return (((value & 1) == 1)); } }
Section 116
//SAPProxy (de.polygonal.motor2.collision.nbody.SAPProxy) package de.polygonal.motor2.collision.nbody { public class SAPProxy extends Proxy { public var ymax:int; public var xmax:int; public var ymin:int; public var xmin:int; public var timeStamp:int; override public function getNext():int{ return (xmin); } override public function reset():void{ timeStamp = 0; overlapCount = 0xFFFF; shape = null; } override public function setNext(_arg1:int):void{ xmin = _arg1; } } }//package de.polygonal.motor2.collision.nbody
Section 117
//UnbufferedPair (de.polygonal.motor2.collision.nbody.UnbufferedPair) package de.polygonal.motor2.collision.nbody { import de.polygonal.motor2.dynamics.contact.*; public class UnbufferedPair { public var contact:Contact; public var proxyId1:int; public var proxyId2:int; } }//package de.polygonal.motor2.collision.nbody
Section 118
//UnbufferedPairManager (de.polygonal.motor2.collision.nbody.UnbufferedPairManager) package de.polygonal.motor2.collision.nbody { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.*; import de.polygonal.motor2.dynamics.contact.*; import flash.utils.*; public class UnbufferedPairManager { private var _callback:PairCallback; private var _poolMask:int; private var _writeIndex:int; private var _pairTable:Dictionary; private var _pairCount:int; private var _broadPhase:BroadPhase; private var _pairPool:Array; private var _readIndex:int; public function UnbufferedPairManager(_arg1:PairCallback, _arg2:BroadPhase){ _callback = _arg1; _broadPhase = _arg2; _pairTable = new Dictionary(); var _local3:int = Constants.k_maxPairs; _pairPool = new Array(_local3, true); var _local4:int; while (_local4 < _local3) { _pairPool[_local4] = new UnbufferedPair(); _local4++; }; _poolMask = (_local3 - 1); } private function getKey(_arg1:int, _arg2:int):int{ if (_arg1 > _arg2){ return (((_arg2 << 16) | _arg1)); }; return (((_arg1 << 16) | _arg2)); } public function addPair(_arg1:int, _arg2:int):Boolean{ var _local3:int = getKey(_arg1, _arg2); if (_pairTable[_local3]){ return (false); }; var _local4:UnbufferedPair = _pairPool[_readIndex]; _readIndex = ((_readIndex + 1) & _poolMask); var _local5:ShapeSkeleton = _broadPhase.getProxy(_arg1).shape; var _local6:ShapeSkeleton = _broadPhase.getProxy(_arg2).shape; var _local7:Contact = _callback.pairAdded(_local5, _local6); _local4.proxyId1 = _arg1; _local4.proxyId2 = _arg2; _local4.contact = _local7; _pairCount++; _pairTable[_local3] = _local4; return (true); } public function removePair(_arg1:int, _arg2:int):Boolean{ var _local3:int = getKey(_arg1, _arg2); var _local4:UnbufferedPair = _pairTable[_local3]; if (_local4 == null){ return (false); }; _callback.pairRemoved(_local4.contact); _local4.contact = null; _pairPool[_writeIndex] = _local4; _writeIndex = ((_writeIndex + 1) & _poolMask); _pairCount--; delete _pairTable[_local3]; return (true); } } }//package de.polygonal.motor2.collision.nbody
Section 119
//CollideBox (de.polygonal.motor2.collision.pairwise.CollideBox) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollideBox implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:int; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:int; var _local19:int; var _local20:int; var _local21:ShapeSkeleton; var _local22:Number; var _local23:Number; var _local24:Number; var _local25:Number; var _local26:Number; var _local27:Number; var _local28:int; var _local29:int; var _local30:int; var _local31:Number; var _local32:Number; var _local33:Number; var _local34:Number; var _local39:Number; var _local40:Number; var _local41:Number; var _local42:Number; var _local43:Number; var _local44:Number; var _local45:Number; var _local46:ContactPoint; var _local5:BoxContact = BoxContact(_arg4); var _local12:Number = (_arg3.x - _arg2.x); var _local13:Number = (_arg3.y - _arg2.y); _local11 = _local5.sepAxisId; if (_local11 == 0){ _local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21)); if (_local14 < 0){ _local14 = -(_local14); }; _local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22)); if (_local16 < 0){ _local16 = -(_local16); }; _local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = _arg2.r11; _local7 = _arg2.r21; _local18 = 3; } else { _local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = -(_arg2.r11); _local7 = -(_arg2.r21); _local18 = 1; }; _local10 = _local9; _local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22)); if (_local17 < 0){ _local17 = -(_local17); }; _local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21)); if (_local15 < 0){ _local15 = -(_local15); }; _local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 1; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){ _local11 = 1; _local10 = _local9; _local6 = _arg2.r12; _local7 = _arg2.r22; _local18 = 0; }; } else { _local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 1; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){ _local11 = 1; _local10 = _local9; _local6 = -(_arg2.r12); _local7 = -(_arg2.r22); _local18 = 2; }; }; _local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _local5.sepAxisId = 2; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){ _local11 = 2; _local10 = _local9; _local6 = _arg3.r11; _local7 = _arg3.r21; _local18 = 1; }; } else { _local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _local5.sepAxisId = 2; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){ _local11 = 2; _local10 = _local9; _local6 = -(_arg3.r11); _local7 = -(_arg3.r21); _local18 = 3; }; }; _local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _local5.sepAxisId = 3; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){ _local11 = 3; _local10 = _local9; _local6 = _arg3.r12; _local7 = _arg3.r22; _local18 = 2; }; } else { _local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _local5.sepAxisId = 3; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){ _local11 = 3; _local10 = _local9; _local6 = -(_arg3.r12); _local7 = -(_arg3.r22); _local18 = 0; }; }; } else { if (_local11 == 1){ _local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22)); if (_local17 < 0){ _local17 = -(_local17); }; _local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21)); if (_local15 < 0){ _local15 = -(_local15); }; _local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = _arg2.r12; _local7 = _arg2.r22; _local18 = 0; } else { _local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = -(_arg2.r12); _local7 = -(_arg2.r22); _local18 = 2; }; _local10 = _local9; _local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21)); if (_local14 < 0){ _local14 = -(_local14); }; _local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22)); if (_local16 < 0){ _local16 = -(_local16); }; _local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 0; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){ _local11 = 0; _local10 = _local9; _local6 = _arg2.r11; _local7 = _arg2.r21; _local18 = 3; }; } else { _local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 0; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){ _local11 = 0; _local10 = _local9; _local6 = -(_arg2.r11); _local7 = -(_arg2.r21); _local18 = 1; }; }; _local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _local5.sepAxisId = 2; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){ _local11 = 2; _local10 = _local9; _local6 = _arg3.r11; _local7 = _arg3.r21; _local18 = 1; }; } else { _local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _local5.sepAxisId = 2; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){ _local11 = 2; _local10 = _local9; _local6 = -(_arg3.r11); _local7 = -(_arg3.r21); _local18 = 3; }; }; _local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _local5.sepAxisId = 3; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){ _local11 = 3; _local10 = _local9; _local6 = _arg3.r12; _local7 = _arg3.r22; _local18 = 2; }; } else { _local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _local5.sepAxisId = 3; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){ _local11 = 3; _local10 = _local9; _local6 = -(_arg3.r12); _local7 = -(_arg3.r22); _local18 = 0; }; }; } else { if (_local11 == 2){ _local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21)); if (_local14 < 0){ _local14 = -(_local14); }; _local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21)); if (_local15 < 0){ _local15 = -(_local15); }; _local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = _arg3.r11; _local7 = _arg3.r21; _local18 = 1; } else { _local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = -(_arg3.r11); _local7 = -(_arg3.r21); _local18 = 3; }; _local10 = _local9; _local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22)); if (_local16 < 0){ _local16 = -(_local16); }; _local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22)); if (_local17 < 0){ _local17 = -(_local17); }; _local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 0; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){ _local11 = 0; _local10 = _local9; _local6 = _arg2.r11; _local7 = _arg2.r21; _local18 = 3; }; } else { _local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 0; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){ _local11 = 0; _local10 = _local9; _local6 = -(_arg2.r11); _local7 = -(_arg2.r21); _local18 = 1; }; }; _local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 1; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){ _local11 = 1; _local10 = _local9; _local6 = _arg2.r12; _local7 = _arg2.r22; _local18 = 0; }; } else { _local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 1; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){ _local11 = 1; _local10 = _local9; _local6 = -(_arg2.r12); _local7 = -(_arg2.r22); _local18 = 2; }; }; _local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _local5.sepAxisId = 3; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){ _local11 = 3; _local10 = _local9; _local6 = _arg3.r12; _local7 = _arg3.r22; _local18 = 2; }; } else { _local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _local5.sepAxisId = 3; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){ _local11 = 3; _local10 = _local9; _local6 = -(_arg3.r12); _local7 = -(_arg3.r22); _local18 = 0; }; }; } else { if (_local11 == 3){ _local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22)); if (_local16 < 0){ _local16 = -(_local16); }; _local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22)); if (_local17 < 0){ _local17 = -(_local17); }; _local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = _arg3.r12; _local7 = _arg3.r22; _local18 = 2; } else { _local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey); if (_local9 > 0){ _arg1.pointCount = 0; return; }; _local6 = -(_arg3.r12); _local7 = -(_arg3.r22); _local18 = 0; }; _local10 = _local9; _local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21)); if (_local14 < 0){ _local14 = -(_local14); }; _local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21)); if (_local15 < 0){ _local15 = -(_local15); }; _local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 0; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){ _local11 = 0; _local10 = _local9; _local6 = _arg2.r11; _local7 = _arg2.r21; _local18 = 3; }; } else { _local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 0; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){ _local11 = 0; _local10 = _local9; _local6 = -(_arg2.r11); _local7 = -(_arg2.r21); _local18 = 1; }; }; _local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 1; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){ _local11 = 1; _local10 = _local9; _local6 = _arg2.r12; _local7 = _arg2.r22; _local18 = 0; }; } else { _local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey))); if (_local9 > 0){ _local5.sepAxisId = 1; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){ _local11 = 1; _local10 = _local9; _local6 = -(_arg2.r12); _local7 = -(_arg2.r22); _local18 = 2; }; }; _local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13)); if (_local8 > 0){ _local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _local5.sepAxisId = 2; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){ _local11 = 2; _local10 = _local9; _local6 = _arg3.r11; _local7 = _arg3.r21; _local18 = 1; }; } else { _local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex); if (_local9 > 0){ _local5.sepAxisId = 2; _arg1.pointCount = 0; return; }; if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){ _local11 = 2; _local10 = _local9; _local6 = -(_arg3.r11); _local7 = -(_arg3.r21); _local18 = 3; }; }; }; }; }; }; if (_local11 == 0){ _local21 = _arg3; _local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ex); _local26 = _arg2.r12; _local27 = _arg2.r22; _local23 = ((_arg2.x * _local26) + (_arg2.y * _local27)); _local24 = (-(_local23) + _arg2.ey); _local28 = 1; _local25 = (_local23 + _arg2.ey); _local29 = 3; } else { if (_local11 == 1){ _local21 = _arg3; _local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ey); _local26 = _arg2.r11; _local27 = _arg2.r21; _local23 = ((_arg2.x * _local26) + (_arg2.y * _local27)); _local24 = (-(_local23) + _arg2.ex); _local28 = 2; _local25 = (_local23 + _arg2.ex); _local29 = 4; } else { if (_local11 == 2){ _local21 = _arg2; _local30 = 1; _local6 = -(_local6); _local7 = -(_local7); _local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ex); _local26 = _arg3.r12; _local27 = _arg3.r22; _local23 = ((_arg3.x * _local26) + (_arg3.y * _local27)); _local24 = (-(_local23) + _arg3.ey); _local28 = 1; _local25 = (_local23 + _arg3.ey); _local29 = 3; } else { if (_local11 == 3){ _local21 = _arg2; _local30 = 1; _local6 = -(_local6); _local7 = -(_local7); _local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ey); _local26 = _arg3.r11; _local27 = _arg3.r21; _local23 = ((_arg3.x * _local26) + (_arg3.y * _local27)); _local24 = (-(_local23) + _arg3.ex); _local28 = 2; _local25 = (_local23 + _arg3.ex); _local29 = 4; }; }; }; }; var _local35:Number = ((-(_local21.r11) * _local6) - (_local21.r21 * _local7)); var _local36:Number = ((-(_local21.r12) * _local6) - (_local21.r22 * _local7)); if (((_local35 < 0)) ? -(_local35) : _local35 > ((_local36 < 0)) ? -(_local36) : _local36){ if (_local35 > 0){ _local31 = _local21.ex; _local33 = -(_local21.ey); _local32 = _local21.ex; _local34 = _local21.ey; if (_local36 > 0){ _local19 = 0; _local20 = 3; } else { _local19 = 3; _local20 = 0; }; } else { _local31 = -(_local21.ex); _local33 = _local21.ey; _local32 = -(_local21.ex); _local34 = -(_local21.ey); if (_local36 > 0){ _local19 = 1; _local20 = 2; } else { _local19 = 2; _local20 = 1; }; }; } else { if (_local36 > 0){ _local31 = _local21.ex; _local33 = _local21.ey; _local32 = -(_local21.ex); _local34 = _local21.ey; if (_local35 > 0){ _local19 = 0; _local20 = 1; } else { _local19 = 1; _local20 = 0; }; } else { _local31 = -(_local21.ex); _local33 = -(_local21.ey); _local32 = _local21.ex; _local34 = -(_local21.ey); if (_local35 > 0){ _local19 = 3; _local20 = 2; } else { _local19 = 2; _local20 = 3; }; }; }; var _local37:Number = _local31; var _local38:Number = _local33; _local31 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38)); _local33 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38)); _local37 = _local32; _local38 = _local34; _local32 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38)); _local34 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38)); _local43 = (((_local31 * -(_local26)) + (_local33 * -(_local27))) - _local24); _local44 = (((_local32 * -(_local26)) + (_local34 * -(_local27))) - _local24); if ((_local43 * _local44) < 0){ _local45 = (_local43 / (_local43 - _local44)); if (_local43 < 0){ _local39 = _local31; _local41 = _local33; _local40 = (_local39 + (_local45 * (_local32 - _local39))); _local42 = (_local41 + (_local45 * (_local34 - _local41))); } else { _local39 = _local32; _local41 = _local34; _local40 = (_local31 + (_local45 * (_local39 - _local31))); _local42 = (_local33 + (_local45 * (_local41 - _local33))); }; } else { if (_local43 > 0){ _arg1.pointCount = 0; return; }; if (_local43 < _local44){ _local39 = _local31; _local41 = _local33; _local40 = _local32; _local42 = _local34; } else { _local40 = _local31; _local42 = _local33; _local39 = _local32; _local41 = _local34; }; }; _local43 = (((_local39 * _local26) + (_local41 * _local27)) - _local25); _local44 = (((_local40 * _local26) + (_local42 * _local27)) - _local25); if ((_local43 * _local44) < 0){ _local45 = (_local43 / (_local43 - _local44)); _local39 = (_local39 + (_local45 * (_local40 - _local39))); _local41 = (_local41 + (_local45 * (_local42 - _local41))); } else { if (_local43 > 0){ _arg1.pointCount = 0; return; }; }; _local9 = (((_local6 * _local39) + (_local7 * _local41)) - _local22); if (_local9 <= 0){ _arg1.pointCount = 1; if (_local30){ _arg1.nx = -(_local6); _arg1.ny = -(_local7); } else { _arg1.nx = _local6; _arg1.ny = _local7; }; _local46 = _arg1.c0; _local46.sep = _local9; _local46.x = _local39; _local46.y = _local41; _local46.id.flip = _local30; _local46.id.incEdge = _local20; _local46.id.incVert = _local19; _local46.id.refFace = _local18; _local46.id.bake(); _local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22); if (_local9 <= 0){ _arg1.pointCount = 2; _local46 = _arg1.c1; _local46.sep = _local9; _local46.x = _local40; _local46.y = _local42; _local46.id.flip = _local30; _local46.id.incEdge = _local20; _local46.id.incVert = _local19; _local46.id.refFace = _local18; _local46.id.bake(); }; } else { _local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22); if (_local9 <= 0){ _arg1.pointCount = 1; if (_local30){ _arg1.nx = -(_local6); _arg1.ny = -(_local7); } else { _arg1.nx = _local6; _arg1.ny = _local7; }; _local46 = _arg1.c0; _local46.sep = _local9; _local46.x = _local40; _local46.y = _local42; _local46.id.flip = _local30; _local46.id.incEdge = _local20; _local46.id.incVert = _local19; _local46.id.refFace = _local18; _local46.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 120
//CollideBoxCircle (de.polygonal.motor2.collision.pairwise.CollideBoxCircle) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollideBoxCircle implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:Number; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:ContactPoint; var _local11:int; var _local12:int; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; var _local20:V2; var _local21:V2; var _local22:V2; var _local23:V2; var _local24:Number; var _local25:Number; var _local26:Number; var _local27:Number; var _local28:BoxCircleContact; var _local29:Number; var _local30:Number; var _local31:int; var _local32:Number; var _local33:Number; var _local34:Number; var _local35:Number; var _local10:int = ContactID.NULL_FEATURE; if (_arg1.pointCount == 1){ _local11 = _local10; _local12 = _local10; _local13 = _arg2.x; _local14 = _arg2.y; _local15 = (_arg3.x - _arg2.x); _local16 = (_arg3.y - _arg2.y); _local17 = 0; _local18 = 0; _local19 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21)); if (_local19 < -(_arg2.ex)){ _local18 = (_local19 + _arg2.ex); _local19 = -(_arg2.ex); _local12 = (1 + 1); _local11 = _local12; } else { if (_local19 > _arg2.ex){ _local18 = (_local19 - _arg2.ex); _local19 = _arg2.ex; _local12 = (3 + 1); _local11 = _local12; }; }; _local13 = (_local13 + (_arg2.r11 * _local19)); _local14 = (_local14 + (_arg2.r21 * _local19)); _local17 = (_local17 + (_local18 * _local18)); _local18 = 0; _local19 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22)); if (_local19 < -(_arg2.ey)){ _local18 = (_local19 + _arg2.ey); _local19 = -(_arg2.ey); _local12 = _local10; if (_local11 == (1 + 1)){ _local11 = (2 + 1); } else { if (_local11 == _local10){ _local12 = (2 + 1); }; }; } else { if (_local19 > _arg2.ey){ _local18 = (_local19 - _arg2.ey); _local19 = _arg2.ey; _local12 = _local10; if (_local11 == (3 + 1)){ _local11 = (0 + 1); } else { if (_local11 == _local10){ _local12 = (0 + 1); }; }; } else { _local11 = _local10; }; }; _local13 = (_local13 + (_arg2.r12 * _local19)); _local14 = (_local14 + (_arg2.r22 * _local19)); _local5 = (_local17 + (_local18 * _local18)); if (_local5 >= _arg3.radiusSq){ _arg1.pointCount = 0; return; }; _arg1.pointCount = 1; _local9 = _arg1.c0; _local9.id.refFace = _local10; _local9.id.flip = 0; if (_local5 == 0){ _local9.id.incVert = _local10; _local7 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21)); _local8 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22)); if (_local7 > 0){ if (_local8 > 0){ if ((_arg2.ex - _local7) < (_arg2.ey - _local8)){ _arg1.nx = _arg2.r11; _arg1.ny = _arg2.r21; _local9.sep = ((_arg3.radius + _arg2.ex) - _local7); _local9.id.incEdge = 3; } else { _arg1.nx = _arg2.r12; _arg1.ny = _arg2.r22; _local9.sep = ((_arg3.radius + _arg2.ey) - _local8); _local9.id.incEdge = 0; }; } else { if ((_arg2.ex - _local7) < (_arg2.ey + _local8)){ _arg1.nx = _arg2.r11; _arg1.ny = _arg2.r21; _local9.sep = ((_arg3.radius + _arg2.ex) - _local7); _local9.id.incEdge = 3; } else { _arg1.nx = -(_arg2.r12); _arg1.ny = -(_arg2.r22); _local9.sep = ((_arg3.radius + _arg2.ey) + _local8); _local9.id.incEdge = 2; }; }; } else { if (_local8 > 0){ if ((_arg2.ex + _local7) < (_arg2.ey - _local8)){ _arg1.nx = -(_arg2.r11); _arg1.ny = -(_arg2.r21); _local9.sep = ((_arg3.radius + _arg2.ex) + _local7); _local9.id.incEdge = 1; } else { _arg1.nx = _arg2.r12; _arg1.ny = _arg2.r22; _local9.sep = ((_arg3.radius + _arg2.ey) - _local8); _local9.id.incEdge = 0; }; } else { if ((_arg2.ex + _local7) < (_arg2.ey + _local8)){ _arg1.nx = -(_arg2.r11); _arg1.ny = -(_arg2.r21); _local9.sep = ((_arg3.radius + _arg2.ex) + _local7); _local9.id.incEdge = 1; } else { _arg1.nx = -(_arg2.r12); _arg1.ny = -(_arg2.r22); _local9.sep = ((_arg3.radius + _arg2.ey) + _local8); _local9.id.incEdge = 2; }; }; }; _local9.sep = -(_local9.sep); } else { _local7 = (_arg3.x - _local13); _local8 = (_arg3.y - _local14); _local6 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8))); _arg1.nx = (_local7 / _local6); _arg1.ny = (_local8 / _local6); _local9.id.incVert = _local11; _local9.id.incEdge = _local12; _local9.sep = -((_arg3.radius - Math.sqrt(_local5))); }; _local9.x = (_arg3.x - (_arg3.radius * _arg1.nx)); _local9.y = (_arg3.y - (_arg3.radius * _arg1.ny)); _local9.id.bake(); } else { _local24 = _arg3.x; _local25 = _arg3.y; _local27 = _arg3.radius; _local5 = -2147483648; _local28 = BoxCircleContact(_arg4); _local20 = _local28.p; _local21 = _local28.d; _local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y))); if (_local26 > _local27){ _arg1.pointCount = 0; _local28.p = _local20; _local28.d = _local21; return; }; if (_local26 > _local5){ _local5 = _local26; _local22 = _local21; _local23 = _local20; }; _local20 = _local20.next; _local21 = _local21.next; _local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y))); if (_local26 > _local27){ _local28.p = _local20; _local28.d = _local21; _arg1.pointCount = 0; return; }; if (_local26 > _local5){ _local5 = _local26; _local22 = _local21; _local23 = _local20; }; _local20 = _local20.next; _local21 = _local21.next; _local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y))); if (_local26 > _local27){ _local28.p = _local20; _local28.d = _local21; _arg1.pointCount = 0; return; }; if (_local26 > _local5){ _local5 = _local26; _local22 = _local21; _local23 = _local20; }; _local20 = _local20.next; _local21 = _local21.next; _local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y))); if (_local26 > _local27){ _local28.p = _local20; _local28.d = _local21; _arg1.pointCount = 0; return; }; if (_local26 > _local5){ _local5 = _local26; _local22 = _local21; _local23 = _local20; }; if (_local5 < 1E-6){ _arg1.pointCount = 1; _arg1.nx = _local22.x; _arg1.ny = _local22.y; _local9 = _arg1.c0; _local9.id.incEdge = _local22.index; _local9.id.incVert = _local10; _local9.id.refFace = _local10; _local9.id.flip = 0; _local9.id.bake(); _local9.x = (_local24 - (_local27 * _arg1.nx)); _local9.y = (_local25 - (_local27 * _arg1.ny)); _local9.sep = (_local5 - _local27); return; }; _local31 = _local23.index; if (_local31 == 0){ _local6 = (_arg2.ex * 2); _local29 = -(_arg2.r11); _local30 = -(_arg2.r21); } else { if (_local31 == 1){ _local29 = -(_arg2.r12); _local30 = -(_arg2.r22); _local6 = (_arg2.ey * 2); } else { if (_local31 == 2){ _local29 = _arg2.r11; _local30 = _arg2.r21; _local6 = (_arg2.ex * 2); } else { if (_local31 == 3){ _local29 = _arg2.r12; _local30 = _arg2.r22; _local6 = (_arg2.ey * 2); }; }; }; }; if (_local6 < 1E-6){ _local7 = (_local24 - _local23.x); _local8 = (_local25 - _local23.y); _local32 = ((_local7 * _local7) + (_local8 * _local8)); if (_local32 > _arg3.radiusSq){ _arg1.pointCount = 0; return; }; _local32 = Math.sqrt(_local32); _local7 = (_local7 / _local32); _local8 = (_local8 / _local32); _arg1.pointCount = 1; _arg1.nx = _local7; _arg1.ny = _local8; _local9 = _arg1.c0; _local9.id.incVert = (_local31 + 1); _local9.id.incEdge = _local10; _local9.id.refFace = _local10; _local9.id.flip = 0; _local9.id.bake(); _local9.x = (_local24 - (_arg3.radius * _local7)); _local9.y = (_local25 - (_arg3.radius * _local8)); _local9.sep = (_local32 - _local27); return; }; _local9 = _arg1.c0; _local9.id.flip = 0; _local9.id.refFace = _local10; _local35 = (((_local24 - _local23.x) * _local29) + ((_local25 - _local23.y) * _local30)); if (_local35 <= 0){ _local33 = _local23.x; _local34 = _local23.y; _local9.id.incVert = _local23.index; _local9.id.incEdge = _local10; } else { if (_local35 >= _local6){ _local33 = _local23.next.x; _local34 = _local23.next.y; _local9.id.incVert = _local23.next.index; _local9.id.incEdge = _local10; } else { _local33 = ((_local29 * _local35) + _local23.x); _local34 = ((_local30 * _local35) + _local23.y); _local9.id.incVert = _local10; _local9.id.incEdge = _local23.index; }; }; _local7 = (_local24 - _local33); _local8 = (_local25 - _local34); _local32 = ((_local7 * _local7) + (_local8 * _local8)); if (_local32 > _arg3.radiusSq){ _arg1.pointCount = 0; return; }; _local32 = Math.sqrt(_local32); _local7 = (_local7 / _local32); _local8 = (_local8 / _local32); _arg1.pointCount = 1; _arg1.nx = _local7; _arg1.ny = _local8; _local9.x = (_local24 - (_local27 * _local7)); _local9.y = (_local25 - (_local27 * _local8)); _local9.sep = (_local32 - _local27); _local9.id.bake(); }; } } }//package de.polygonal.motor2.collision.pairwise
Section 121
//CollideBoxLineDoubleSided (de.polygonal.motor2.collision.pairwise.CollideBoxLineDoubleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideBoxLineDoubleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:V2; var _local6:V2; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:Number; var _local16:Number; var _local28:int; var _local32:Number; var _local34:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:Number; var _local41:ContactPoint; var _local42:V2; var _local12:Number = -2147483648; var _local13:int; _local8 = _arg3.worldVertexChain; _local7 = _arg3.worldNormalChain; _local5 = _arg2.worldVertexChain; var _local14:V2 = _local5; var _local15:Number = ((_local5.x * _local7.x) + (_local5.y * _local7.y)); _local5 = _local5.next; _local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y)); if (_local16 < _local15){ _local15 = _local16; _local14 = _local5; }; _local5 = _local5.next; _local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y)); if (_local16 < _local15){ _local15 = _local16; _local14 = _local5; }; _local5 = _local5.next; _local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y)); if (_local16 < _local15){ _local15 = _local16; _local14 = _local5; }; _local5 = _local14; _local11 = ((_local7.x * (_local5.x - _local8.x)) + (_local7.y * (_local5.y - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local5; _local13 = 1; }; _local8 = _local8.next; _local7 = _local7.next; _local5 = _local5.next.next; _local11 = ((_local7.x * (_local5.x - _local8.x)) + (_local7.y * (_local5.y - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local5; _local13 = 1; }; var _local17:V2 = _arg3.worldVertexChain; var _local18:V2 = _local17.next; var _local19:Number = _local17.x; var _local20:Number = _local18.x; var _local21:Number = _local17.y; var _local22:Number = _local18.y; _local8 = _arg2.worldVertexChain.next; _local7 = _arg2.worldNormalChain.next; if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){ _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; } else { _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; }; _local8 = _arg2.worldVertexChain; _local7 = _arg2.worldNormalChain; if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){ _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; } else { _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local6 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; }; var _local23:ShapeSkeleton = _arg2; var _local24:Number = _local6.x; var _local25:Number = _local6.y; var _local26:int = _local9.index; var _local27:int = _local10.index; var _local29:V2 = _local10.edge.n; var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25)); if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){ _local10 = _local10.prev; _local28 = _local29.prev.index; } else { if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){ _local10 = _local10.next; _local28 = _local29.next.index; }; }; var _local31:Number = (((_local23.x * _local24) + (_local23.y * _local25)) + (((_local9.x - _local23.x) * _local24) + ((_local9.y - _local23.y) * _local25))); if (_local23.regularShape){ _local32 = ((_local23.y * _local24) - (_local23.x * _local25)); } else { _local42 = _local23.offsets[_local9.index]; _local32 = ((((_local23.y + (_local23.r21 * _local42.x)) + (_local23.r22 * _local42.y)) * _local24) - (((_local23.x + (_local23.r11 * _local42.x)) + (_local23.r12 * _local42.y)) * _local25)); }; var _local33:Number = (_local9.edge.mag / 2); _local38 = ((((_local10.x * _local25) - (_local10.y * _local24)) + _local32) - _local33); _local39 = ((((_local10.next.x * _local25) - (_local10.next.y * _local24)) + _local32) - _local33); if ((_local38 * _local39) < 0){ _local40 = (_local38 / (_local38 - _local39)); if (_local38 < 0){ _local34 = _local10.x; _local36 = _local10.y; _local35 = (_local34 + (_local40 * (_local10.next.x - _local34))); _local37 = (_local36 + (_local40 * (_local10.next.y - _local36))); } else { _local34 = _local10.next.x; _local36 = _local10.next.y; _local35 = (_local10.x + (_local40 * (_local34 - _local10.x))); _local37 = (_local10.y + (_local40 * (_local36 - _local10.y))); }; } else { if (_local38 > 0){ _arg1.pointCount = 0; return; }; if (_local38 < _local39){ _local34 = _local10.x; _local36 = _local10.y; _local35 = _local10.next.x; _local37 = _local10.next.y; } else { _local35 = _local10.x; _local37 = _local10.y; _local34 = _local10.next.x; _local36 = _local10.next.y; }; }; _local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25)); _local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25)); if ((_local38 * _local39) < 0){ _local40 = (_local38 / (_local38 - _local39)); _local34 = (_local34 + (_local40 * (_local35 - _local34))); _local36 = (_local36 + (_local40 * (_local37 - _local36))); } else { if (_local38 > 0){ _arg1.pointCount = 0; return; }; }; _local12 = (((_local24 * _local34) + (_local25 * _local36)) - _local31); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local13){ _arg1.nx = -(_local24); _arg1.ny = -(_local25); } else { _arg1.nx = _local24; _arg1.ny = _local25; }; _local41 = _arg1.c0; _local41.sep = _local12; _local41.x = _local34; _local41.y = _local36; _local41.id.flip = _local13; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); _local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31); if (_local12 <= 0){ _arg1.pointCount = 2; _local41 = _arg1.c1; _local41.sep = _local12; _local41.x = _local35; _local41.y = _local37; _local41.id.flip = _local13; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); }; } else { _local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local13){ _arg1.nx = -(_local24); _arg1.ny = -(_local25); } else { _arg1.nx = _local24; _arg1.ny = _local25; }; _local41 = _arg1.c0; _local41.sep = _local12; _local41.x = _local35; _local41.y = _local37; _local41.id.flip = _local13; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 122
//CollideBoxLineSingleSided (de.polygonal.motor2.collision.pairwise.CollideBoxLineSingleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideBoxLineSingleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:V2; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:Number; var _local16:Number; var _local28:int; var _local32:Number; var _local34:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:Number; var _local41:ContactPoint; var _local42:V2; var _local5:V2 = _arg3.worldNormalChain; if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){ _arg4.disabled = true; _arg1.pointCount = 0; return; }; var _local12:Number = -2147483648; var _local13:int; _local8 = _arg3.worldVertexChain; _local7 = _arg3.worldNormalChain; _local6 = _arg2.worldVertexChain; var _local14:V2 = _local6; var _local15:Number = ((_local6.x * _local7.x) + (_local6.y * _local7.y)); _local6 = _local6.next; _local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y)); if (_local16 < _local15){ _local15 = _local16; _local14 = _local6; }; _local6 = _local6.next; _local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y)); if (_local16 < _local15){ _local15 = _local16; _local14 = _local6; }; _local6 = _local6.next; _local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y)); if (_local16 < _local15){ _local15 = _local16; _local14 = _local6; }; _local6 = _local14; _local11 = ((_local7.x * (_local6.x - _local8.x)) + (_local7.y * (_local6.y - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local6; _local13 = 1; }; _local8 = _local8.next; _local7 = _local7.next; _local6 = _local6.next.next; _local11 = ((_local7.x * (_local6.x - _local8.x)) + (_local7.y * (_local6.y - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local6; _local13 = 1; }; var _local17:V2 = _arg3.worldVertexChain; var _local18:V2 = _local17.next; var _local19:Number = _local17.x; var _local20:Number = _local18.x; var _local21:Number = _local17.y; var _local22:Number = _local18.y; _local8 = _arg2.worldVertexChain.next; _local7 = _arg2.worldNormalChain.next; if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){ _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; } else { _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; }; _local8 = _arg2.worldVertexChain; _local7 = _arg2.worldNormalChain; if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){ _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; } else { _local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local18; _local13 = 0; }; _local8 = _local8.next.next; _local7 = _local7.next.next; _local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y))); if (_local11 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local11 * 0.95) + 0.01) > _local12){ _local12 = _local11; _local5 = _local7; _local9 = _local8; _local10 = _local17; _local13 = 0; }; }; if (_arg4.disabled){ _arg1.pointCount = 0; return; }; var _local23:ShapeSkeleton = _arg2; var _local24:Number = _local5.x; var _local25:Number = _local5.y; var _local26:int = _local9.index; var _local27:int = _local10.index; var _local29:V2 = _local10.edge.n; var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25)); if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){ _local10 = _local10.prev; _local28 = _local29.prev.index; } else { if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){ _local10 = _local10.next; _local28 = _local29.next.index; }; }; var _local31:Number = (((_local23.x * _local24) + (_local23.y * _local25)) + (((_local9.x - _local23.x) * _local24) + ((_local9.y - _local23.y) * _local25))); if (_local23.regularShape){ _local32 = ((_local23.y * _local24) - (_local23.x * _local25)); } else { _local42 = _local23.offsets[_local9.index]; _local32 = ((((_local23.y + (_local23.r21 * _local42.x)) + (_local23.r22 * _local42.y)) * _local24) - (((_local23.x + (_local23.r11 * _local42.x)) + (_local23.r12 * _local42.y)) * _local25)); }; var _local33:Number = (_local9.edge.mag / 2); _local38 = ((((_local10.x * _local25) - (_local10.y * _local24)) + _local32) - _local33); _local39 = ((((_local10.next.x * _local25) - (_local10.next.y * _local24)) + _local32) - _local33); if ((_local38 * _local39) < 0){ _local40 = (_local38 / (_local38 - _local39)); if (_local38 < 0){ _local34 = _local10.x; _local36 = _local10.y; _local35 = (_local34 + (_local40 * (_local10.next.x - _local34))); _local37 = (_local36 + (_local40 * (_local10.next.y - _local36))); } else { _local34 = _local10.next.x; _local36 = _local10.next.y; _local35 = (_local10.x + (_local40 * (_local34 - _local10.x))); _local37 = (_local10.y + (_local40 * (_local36 - _local10.y))); }; } else { if (_local38 > 0){ _arg1.pointCount = 0; return; }; if (_local38 < _local39){ _local34 = _local10.x; _local36 = _local10.y; _local35 = _local10.next.x; _local37 = _local10.next.y; } else { _local35 = _local10.x; _local37 = _local10.y; _local34 = _local10.next.x; _local36 = _local10.next.y; }; }; _local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25)); _local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25)); if ((_local38 * _local39) < 0){ _local40 = (_local38 / (_local38 - _local39)); _local34 = (_local34 + (_local40 * (_local35 - _local34))); _local36 = (_local36 + (_local40 * (_local37 - _local36))); } else { if (_local38 > 0){ _arg1.pointCount = 0; return; }; }; _local12 = (((_local24 * _local34) + (_local25 * _local36)) - _local31); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local13){ _arg1.nx = -(_local24); _arg1.ny = -(_local25); } else { _arg1.nx = _local24; _arg1.ny = _local25; }; _local41 = _arg1.c0; _local41.sep = _local12; _local41.x = _local34; _local41.y = _local36; _local41.id.flip = _local13; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); _local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31); if (_local12 <= 0){ _arg1.pointCount = 2; _local41 = _arg1.c1; _local41.sep = _local12; _local41.x = _local35; _local41.y = _local37; _local41.id.flip = _local13; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); }; } else { _local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local13){ _arg1.nx = -(_local24); _arg1.ny = -(_local25); } else { _arg1.nx = _local24; _arg1.ny = _local25; }; _local41 = _arg1.c0; _local41.sep = _local12; _local41.x = _local35; _local41.y = _local37; _local41.id.flip = _local13; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 123
//CollideBoxPlaneDoubleSided (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneDoubleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideBoxPlaneDoubleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local15:Number; var _local18:int; var _local19:int; var _local5:Number = _arg3.worldNormalChain.x; var _local6:Number = _arg3.worldNormalChain.y; var _local7:Number = ((_local5 * _arg2.r11) + (_local6 * _arg2.r21)); var _local8:Number = ((_local5 * _arg2.r12) + (_local6 * _arg2.r22)); var _local9:Number = ((_arg2.ex * ((_local7 < 0)) ? -(_local7) : _local7) + (_arg2.ey * ((_local8 < 0)) ? -(_local8) : _local8)); var _local10:Number = _arg3.d; var _local11:Number = (((_local5 * _arg2.x) + (_local6 * _arg2.y)) - _local10); if (_local11 > 0){ if (_local11 > _local9){ _arg1.pointCount = 0; return; }; } else { if (_local11 < -(_local9)){ _arg1.pointCount = 0; return; }; _local5 = -(_local5); _local6 = -(_local6); _local10 = -(_local10); }; var _local12:V2 = _arg2.worldVertexChain; var _local13:V2 = _local12; var _local14:Number = ((_local12.x * _local5) + (_local12.y * _local6)); _local12 = _local12.next; _local15 = ((_local12.x * _local5) + (_local12.y * _local6)); if (_local15 < _local14){ _local14 = _local15; _local13 = _local12; }; _local12 = _local12.next; _local15 = ((_local12.x * _local5) + (_local12.y * _local6)); if (_local15 < _local14){ _local14 = _local15; _local13 = _local12; }; _local12 = _local12.next; _local15 = ((_local12.x * _local5) + (_local12.y * _local6)); if (_local15 < _local14){ _local14 = _local15; _local13 = _local12; }; _local12 = _local13; _arg1.nx = -(_local5); _arg1.ny = -(_local6); _arg1.pointCount = 1; var _local16:ContactPoint = _arg1.c0; _local16.sep = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10); _local16.x = _local12.x; _local16.y = _local12.y; var _local17:V2 = _local12.edge.n; var _local20:Number = ((_local17.x * _local5) + (_local17.y * _local6)); if (((_local17.prev.x * _local5) + (_local17.prev.y * _local6)) < _local20){ _local18 = _local17.prev.index; _local16.id.flip = 0; _local16.id.incEdge = _local18; _local16.id.incVert = _local19; _local16.id.refFace = 0; _local16.id.bake(); _local12 = _local12.prev; _local11 = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10); if (_local11 < 0){ _local16 = _arg1.c1; _local16.sep = _local11; _local16.x = _local12.x; _local16.y = _local12.y; _local16.id.flip = 0; _local16.id.incEdge = _local18; _local16.id.incVert = _local19; _local16.id.refFace = 0; _local16.id.bake(); _arg1.pointCount++; }; } else { _local18 = _local17.next.index; _local16.id.flip = 0; _local16.id.incEdge = _local18; _local16.id.incVert = _local19; _local16.id.refFace = 0; _local16.id.bake(); _local12 = _local12.next; _local11 = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10); if (_local11 < 0){ _local16 = _arg1.c1; _local16.sep = _local11; _local16.x = _local12.x; _local16.y = _local12.y; _local16.id.flip = 0; _local16.id.incEdge = _local18; _local16.id.incVert = _local19; _local16.id.refFace = 0; _local16.id.bake(); _arg1.pointCount++; }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 124
//CollideBoxPlaneSingleSided (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneSingleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideBoxPlaneSingleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:Number; var _local7:V2; var _local8:V2; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:ContactPoint; var _local14:Number; var _local15:Number; var _local16:Number; var _local5:Number = _arg3.worldNormalChain.x; _local6 = _arg3.worldNormalChain.y; if (_arg1.pointCount > 0){ _local8 = _arg2.worldVertexChain; _local7 = _local8; _local9 = ((_local7.x * _local5) + (_local7.y * _local6)); _local7 = _local7.next; _local10 = ((_local7.x * _local5) + (_local7.y * _local6)); if (_local10 < _local9){ _local9 = _local10; _local8 = _local7; }; _local7 = _local7.next; _local10 = ((_local7.x * _local5) + (_local7.y * _local6)); if (_local10 < _local9){ _local9 = _local10; _local8 = _local7; }; _local7 = _local7.next; _local10 = ((_local7.x * _local5) + (_local7.y * _local6)); if (_local10 < _local9){ _local9 = _local10; _local8 = _local7; }; _local7 = _local8; _local11 = _arg3.d; _local12 = (((_local7.x * _local5) + (_local7.y * _local6)) - _local11); if (_local12 > 0){ _arg1.pointCount = 0; return; }; _arg1.pointCount = 1; _arg1.nx = -(_local5); _arg1.ny = -(_local6); _local13 = _arg1.c0; _local13.sep = _local12; _local13.x = _local7.x; _local13.y = _local7.y; _local13.id.key = 0; _local12 = (((_local7.prev.x * _local5) + (_local7.prev.y * _local6)) - _local11); if (_local12 < 0){ _local13.id.key = 1; _local13 = _arg1.c1; _local13.sep = _local12; _local13.x = _local7.prev.x; _local13.y = _local7.prev.y; _local13.id.key = 1; _arg1.pointCount++; } else { _local12 = (((_local7.next.x * _local5) + (_local7.next.y * _local6)) - _local11); if (_local12 < 0){ _local13.id.key = 1; _local13 = _arg1.c1; _local13.sep = _local12; _local13.x = _local7.next.x; _local13.y = _local7.next.y; _local13.id.key = 1; _arg1.pointCount++; }; }; } else { _local14 = ((_local5 * _arg2.r11) + (_local6 * _arg2.r21)); _local15 = ((_local5 * _arg2.r12) + (_local6 * _arg2.r22)); _local16 = ((_arg2.ex * ((_local14 < 0)) ? -(_local14) : _local14) + (_arg2.ey * ((_local15 < 0)) ? -(_local15) : _local15)); if ((((_local5 * _arg2.x) + (_local6 * _arg2.y)) - _arg3.d) > _local16){ _arg1.pointCount = 0; return; }; _local11 = _arg3.d; _local8 = _arg2.worldVertexChain; _local7 = _local8; _local9 = ((_local7.x * _local5) + (_local7.y * _local6)); _local7 = _local7.next; _local10 = ((_local7.x * _local5) + (_local7.y * _local6)); if (_local10 < _local9){ _local9 = _local10; _local8 = _local7; }; _local7 = _local7.next; _local10 = ((_local7.x * _local5) + (_local7.y * _local6)); if (_local10 < _local9){ _local9 = _local10; _local8 = _local7; }; _local7 = _local7.next; _local10 = ((_local7.x * _local5) + (_local7.y * _local6)); if (_local10 < _local9){ _local9 = _local10; _local8 = _local7; }; _local7 = _local8; _local12 = (((_local7.x * _local5) + (_local7.y * _local6)) - _local11); _arg1.pointCount = 1; _arg1.nx = -(_local5); _arg1.ny = -(_local6); _local13 = _arg1.c0; _local13.sep = _local12; _local13.x = _local7.x; _local13.y = _local7.y; _local13.id.key = 0; _local12 = (((_local7.prev.x * _local5) + (_local7.prev.y * _local6)) - _local11); if (_local12 < 0){ _local13.id.key = 1; _local13 = _arg1.c1; _local13.sep = _local12; _local13.x = _local7.prev.x; _local13.y = _local7.prev.y; _local13.id.key = 1; _arg1.pointCount++; } else { _local12 = (((_local7.next.x * _local5) + (_local7.next.y * _local6)) - _local11); if (_local12 < 0){ _local13.id.key = 1; _local13 = _arg1.c1; _local13.sep = _local12; _local13.x = _local7.next.x; _local13.y = _local7.next.y; _local13.id.key = 1; _arg1.pointCount++; }; }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 125
//CollideCircle (de.polygonal.motor2.collision.pairwise.CollideCircle) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideCircle implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:Number; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; _local5 = (_arg3.x - _arg2.x); _local6 = (_arg3.y - _arg2.y); _local7 = ((_local5 * _local5) + (_local6 * _local6)); _local8 = (_arg2.radius + _arg3.radius); if (_local7 > (_local8 * _local8)){ _arg1.pointCount = 0; return; }; if (_local7 < 1E-8){ _arg1.c0.sep = -(_local8); _arg1.nx = 0; _arg1.ny = 1; _arg1.c0.x = _arg3.x; _arg1.c0.y = (_arg3.y - _arg3.radius); } else { _local9 = Math.sqrt(_local7); _arg1.c0.sep = (_local9 - _local8); _arg1.c0.x = (_arg3.x - (_arg3.radius * (_arg1.nx = ((1 / _local9) * _local5)))); _arg1.c0.y = (_arg3.y - (_arg3.radius * (_arg1.ny = ((1 / _local9) * _local6)))); }; _arg1.pointCount = 1; _arg1.c0.id.key = 0; } } }//package de.polygonal.motor2.collision.pairwise
Section 126
//CollideCircleLineDoubleSided (de.polygonal.motor2.collision.pairwise.CollideCircleLineDoubleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideCircleLineDoubleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:ContactPoint; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local25:Number; var _local26:Number; var _local27:Number; var _local28:Number; var _local6:V2 = _arg3.worldVertexChain; var _local7:V2 = _local6.next; var _local8:Number = _arg2.radiusSq; var _local9:Number = _local6.x; var _local10:Number = _local7.x; var _local11:Number = _arg2.x; var _local12:Number = _local6.y; var _local13:Number = _local7.y; var _local14:Number = _arg2.y; var _local15:Number = (_local10 - _local9); var _local16:Number = (_local13 - _local12); var _local17:Number = (_local11 - _local9); var _local18:Number = (_local14 - _local12); var _local23:Number = ((_local17 * _local15) + (_local18 * _local16)); if (_local23 < 0){ _local19 = ((_local17 * _local17) + (_local18 * _local18)); if (_local19 > _local8){ _arg1.pointCount = 0; return; }; _local20 = Math.sqrt(_local19); _local21 = (_local17 / _local20); _local22 = (_local18 / _local20); _local5 = _arg1.c0; _local5.id.incEdge = _local6.index; _local5.id.incVert = _local6.index; } else { _local25 = (_local10 - _local11); _local26 = (_local13 - _local14); _local23 = ((_local25 * _local15) + (_local26 * _local16)); if (_local23 < 0){ _local19 = ((_local25 * _local25) + (_local26 * _local26)); if (_local19 > _local8){ _arg1.pointCount = 0; return; }; _local20 = Math.sqrt(_local19); _local21 = (-(_local25) / _local20); _local22 = (-(_local26) / _local20); _local5 = _arg1.c0; _local5.id.incEdge = _local7.index; _local5.id.incVert = _local7.index; } else { _local27 = ((_local18 * _local15) - (_local17 * _local16)); _local19 = ((((_local18 * _local15) - (_local17 * _local16)) * _local27) / ((_local15 * _local15) + (_local16 * _local16))); if (_local19 > _local8){ _arg1.pointCount = 0; return; }; _local20 = Math.sqrt(_local19); _local21 = (-(_local13) + _local12); _local22 = (_local10 - _local9); _local28 = (Math.sqrt(((_local21 * _local21) + (_local22 * _local22))) * ((((_local21 * _local17) + (_local22 * _local18)) < 0)) ? -1 : 1); _local21 = (_local21 / _local28); _local22 = (_local22 / _local28); _local5 = _arg1.c0; _local5.id.incEdge = _local6.index; _local5.id.incVert = _local7.index; }; }; _arg1.pointCount = 1; _arg1.nx = -(_local21); _arg1.ny = -(_local22); _local5.id.refFace = ContactID.NULL_FEATURE; _local5.id.flip = 0; _local5.id.bake(); var _local24:Number = _arg2.radius; _local5.x = (_local11 - (_local24 * _local21)); _local5.y = (_local14 - (_local24 * _local22)); _local5.sep = (_local20 - _local24); } } }//package de.polygonal.motor2.collision.pairwise
Section 127
//CollideCircleLineSingleSided (de.polygonal.motor2.collision.pairwise.CollideCircleLineSingleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideCircleLineSingleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:ContactPoint; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:Number; var _local26:Number; var _local27:Number; var _local28:Number; var _local29:Number; var _local6:V2 = _arg3.worldNormalChain; if ((((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d) < 0){ _arg4.disabled = true; _arg1.pointCount = 0; return; }; var _local7:V2 = _arg3.worldVertexChain; var _local8:V2 = _local7.next; var _local9:Number = _arg2.radiusSq; var _local10:Number = _local7.x; var _local11:Number = _local8.x; var _local12:Number = _arg2.x; var _local13:Number = _local7.y; var _local14:Number = _local8.y; var _local15:Number = _arg2.y; var _local16:Number = (_local11 - _local10); var _local17:Number = (_local14 - _local13); var _local18:Number = (_local12 - _local10); var _local19:Number = (_local15 - _local13); var _local24:Number = ((_local18 * _local16) + (_local19 * _local17)); if (_local24 < 0){ _local22 = _arg3.worldNormalChain.x; _local23 = _arg3.worldNormalChain.y; if (((_local22 * _local18) + (_local23 * _local19)) < 0){ _arg1.pointCount = 0; return; }; _local20 = ((_local18 * _local18) + (_local19 * _local19)); if (_local20 > _local9){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (_arg4.disabled){ _arg1.pointCount = 0; return; }; _local21 = Math.sqrt(_local20); _local22 = (_local18 / _local21); _local23 = (_local19 / _local21); _local5 = _arg1.c0; _local5.id.incEdge = _local7.index; _local5.id.incVert = _local7.index; } else { _local26 = (_local11 - _local12); _local27 = (_local14 - _local15); _local24 = ((_local26 * _local16) + (_local27 * _local17)); _local22 = _arg3.worldNormalChain.x; _local23 = _arg3.worldNormalChain.y; if (((_local22 * _local26) + (_local23 * _local27)) > 0){ _arg1.pointCount = 0; return; }; if (_local24 < 0){ _local20 = ((_local26 * _local26) + (_local27 * _local27)); if (_local20 > _local9){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (_arg4.disabled){ _arg1.pointCount = 0; return; }; _local21 = Math.sqrt(_local20); _local22 = (-(_local26) / _local21); _local23 = (-(_local27) / _local21); _local5 = _arg1.c0; _local5.id.incEdge = _local8.index; _local5.id.incVert = _local8.index; } else { _local28 = ((_local19 * _local16) - (_local18 * _local17)); if (_local28 > 0){ _arg1.pointCount = 0; return; }; _local20 = ((_local28 * _local28) / ((_local16 * _local16) + (_local17 * _local17))); if (_local20 > _local9){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (_arg4.disabled){ _arg1.pointCount = 0; return; }; _local21 = Math.sqrt(_local20); _local22 = (-(_local14) + _local13); _local23 = (_local11 - _local10); _local29 = (Math.sqrt(((_local22 * _local22) + (_local23 * _local23))) * ((((_local22 * _local18) + (_local23 * _local19)) < 0)) ? -1 : 1); _local22 = (_local22 / _local29); _local23 = (_local23 / _local29); _local5 = _arg1.c0; _local5.id.incEdge = _local7.index; _local5.id.incVert = _local8.index; }; }; _arg1.pointCount = 1; _arg1.nx = -(_local22); _arg1.ny = -(_local23); _local5.id.refFace = ContactID.NULL_FEATURE; _local5.id.flip = 0; _local5.id.bake(); var _local25:Number = _arg2.radius; _local5.x = (_local12 - (_local25 * _local22)); _local5.y = (_local15 - (_local25 * _local23)); _local5.sep = (_local21 - _local25); } } }//package de.polygonal.motor2.collision.pairwise
Section 128
//CollideCirclePlaneDoubleSided (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneDoubleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideCirclePlaneDoubleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:ContactPoint; var _local7:Number; var _local6:V2 = _arg3.worldNormalChain; _local7 = _arg2.radius; var _local8:Number = (((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d); if (_local8 > 0){ if (_local8 <= _local7){ _arg1.pointCount = 1; _arg1.nx = -(_local6.x); _arg1.ny = -(_local6.y); _local5 = _arg1.c0; _local5.id.key = 0; _local5.sep = (_local8 - _local7); _local5.x = (_arg2.x - (_local7 * _local6.x)); _local5.y = (_arg2.y - (_local7 * _local6.y)); return; }; } else { if (-(_local8) <= _local7){ _arg1.pointCount = 1; _arg1.nx = _local6.x; _arg1.ny = _local6.y; _local5 = _arg1.c0; _local5.id.key = 1; _local5.sep = (-(_local7) - _local8); _local5.x = (_arg2.x + (_local7 * _local6.x)); _local5.y = (_arg2.y + (_local7 * _local6.y)); return; }; }; _arg1.pointCount = 0; } } }//package de.polygonal.motor2.collision.pairwise
Section 129
//CollideCirclePlaneSingleSided (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneSingleSided) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollideCirclePlaneSingleSided implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local7:Number; var _local8:ContactPoint; var _local5:V2 = _arg3.worldNormalChain; var _local6:Number = _arg2.radius; _local7 = (((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d); if (_local7 <= _local6){ _arg1.pointCount = 1; _arg1.nx = -(_local5.x); _arg1.ny = -(_local5.y); _local8 = _arg1.c0; _local8.x = (_arg2.x - (_local6 * _local5.x)); _local8.y = (_arg2.y - (_local6 * _local5.y)); _local8.sep = (_local7 - _local6); return; }; _arg1.pointCount = 0; } } }//package de.polygonal.motor2.collision.pairwise
Section 130
//CollidePolyBSP (de.polygonal.motor2.collision.pairwise.CollidePolyBSP) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollidePolyBSP implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:V2; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:V2; var _local13:Number; var _local14:int; var _local15:ConvexBSPNode; var _local21:int; var _local25:Number; var _local27:Number; var _local28:Number; var _local29:Number; var _local30:Number; var _local31:Number; var _local32:Number; var _local33:Number; var _local34:ContactPoint; var _local35:V2; var _local5:PolyContact = PolyContact(_arg4); var _local12:Number = -2147483648; _local6 = _local5.p; _local7 = _local5.d; if (_local5.firstOut){ while (true) { _local15 = _arg3.BSPNode; while (_local15.R) { _local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L; }; _local8 = _local15.V; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; _local6 = _arg3.worldVertexChain; _local7 = _arg3.worldNormalChain; while (true) { _local15 = _arg2.BSPNode; while (_local15.R) { _local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L; }; _local8 = _local15.V; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = false; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; } else { while (true) { _local15 = _arg2.BSPNode; while (_local15.R) { _local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L; }; _local8 = _local15.V; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; _local6 = _arg2.worldVertexChain; _local7 = _arg2.worldNormalChain; while (true) { _local15 = _arg3.BSPNode; while (_local15.R) { _local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L; }; _local8 = _local15.V; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = true; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 0; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; }; var _local16:ShapeSkeleton = (_local14) ? _arg3 : _arg2; var _local17:Number = _local9.x; var _local18:Number = _local9.y; var _local19:int = _local11.index; var _local20:int = _local10.index; var _local22:V2 = _local10.edge.n; var _local23:Number = ((_local22.x * _local17) + (_local22.y * _local18)); if (((_local22.prev.x * _local17) + (_local22.prev.y * _local18)) < _local23){ _local10 = _local10.prev; _local21 = _local22.prev.index; } else { if (((_local22.next.x * _local17) + (_local22.next.y * _local18)) < _local23){ _local10 = _local10.next; _local21 = _local22.next.index; }; }; var _local24:Number = (((_local16.x * _local17) + (_local16.y * _local18)) + (((_local11.x - _local16.x) * _local17) + ((_local11.y - _local16.y) * _local18))); if (_local16.regularShape){ _local25 = ((_local16.y * _local17) - (_local16.x * _local18)); } else { _local35 = _local16.offsets[_local11.index]; _local25 = ((((_local16.y + (_local16.r21 * _local35.x)) + (_local16.r22 * _local35.y)) * _local17) - (((_local16.x + (_local16.r11 * _local35.x)) + (_local16.r12 * _local35.y)) * _local18)); }; var _local26:Number = (_local11.edge.mag / 2); _local31 = ((((_local10.x * _local18) - (_local10.y * _local17)) + _local25) - _local26); _local32 = ((((_local10.next.x * _local18) - (_local10.next.y * _local17)) + _local25) - _local26); if ((_local31 * _local32) < 0){ _local33 = (_local31 / (_local31 - _local32)); if (_local31 < 0){ _local27 = _local10.x; _local29 = _local10.y; _local28 = (_local27 + (_local33 * (_local10.next.x - _local27))); _local30 = (_local29 + (_local33 * (_local10.next.y - _local29))); } else { _local27 = _local10.next.x; _local29 = _local10.next.y; _local28 = (_local10.x + (_local33 * (_local27 - _local10.x))); _local30 = (_local10.y + (_local33 * (_local29 - _local10.y))); }; } else { if (_local31 > 0){ _arg1.pointCount = 0; return; }; if (_local31 < _local32){ _local27 = _local10.x; _local29 = _local10.y; _local28 = _local10.next.x; _local30 = _local10.next.y; } else { _local28 = _local10.x; _local30 = _local10.y; _local27 = _local10.next.x; _local29 = _local10.next.y; }; }; _local31 = ((((_local29 * _local17) - _local25) - _local26) - (_local27 * _local18)); _local32 = ((((_local30 * _local17) - _local25) - _local26) - (_local28 * _local18)); if ((_local31 * _local32) < 0){ _local33 = (_local31 / (_local31 - _local32)); _local27 = (_local27 + (_local33 * (_local28 - _local27))); _local29 = (_local29 + (_local33 * (_local30 - _local29))); } else { if (_local31 > 0){ _arg1.pointCount = 0; return; }; }; _local12 = (((_local17 * _local27) + (_local18 * _local29)) - _local24); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local17); _arg1.ny = -(_local18); } else { _arg1.nx = _local17; _arg1.ny = _local18; }; _local34 = _arg1.c0; _local34.sep = _local12; _local34.x = _local27; _local34.y = _local29; _local34.id.flip = _local14; _local34.id.incEdge = _local21; _local34.id.incVert = _local20; _local34.id.refFace = _local19; _local34.id.bake(); _local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24); if (_local12 <= 0){ _arg1.pointCount = 2; _local34 = _arg1.c1; _local34.sep = _local12; _local34.x = _local28; _local34.y = _local30; _local34.id.flip = _local14; _local34.id.incEdge = _local21; _local34.id.incVert = _local20; _local34.id.refFace = _local19; _local34.id.bake(); }; } else { _local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local17); _arg1.ny = -(_local18); } else { _arg1.nx = _local17; _arg1.ny = _local18; }; _local34 = _arg1.c0; _local34.sep = _local12; _local34.x = _local28; _local34.y = _local30; _local34.id.flip = _local14; _local34.id.incEdge = _local21; _local34.id.incVert = _local20; _local34.id.refFace = _local19; _local34.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 131
//CollidePolyCHC (de.polygonal.motor2.collision.pairwise.CollidePolyCHC) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import flash.utils.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollidePolyCHC implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:V2; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:V2; var _local13:Number; var _local14:int; var _local16:Number; var _local17:Number; var _local23:int; var _local27:Number; var _local29:Number; var _local30:Number; var _local31:Number; var _local32:Number; var _local33:Number; var _local34:Number; var _local35:Number; var _local36:ContactPoint; var _local37:V2; var _local5:PolyContact = PolyContact(_arg4); var _local12:Number = -2147483648; var _local15:Dictionary = _local5.hc; _local6 = _local5.p; _local7 = _local5.d; if (_local5.firstOut){ while (true) { _local8 = ((_local15[_local7]) || (_arg3.worldVertexChain)); _local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); while (true) { _local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.prev; _local17 = _local16; } else { _local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.next; _local17 = _local16; } else { break; }; }; }; _local15[_local7] = _local8; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; _local6 = _arg3.worldVertexChain; _local7 = _arg3.worldNormalChain; while (true) { _local8 = ((_local15[_local7]) || (_arg2.worldVertexChain)); _local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); while (true) { _local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.prev; _local17 = _local16; } else { _local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.next; _local17 = _local16; } else { break; }; }; }; _local15[_local7] = _local8; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = false; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; } else { while (true) { _local8 = ((_local15[_local7]) || (_arg2.worldVertexChain)); _local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); while (true) { _local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.prev; _local17 = _local16; } else { _local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.next; _local17 = _local16; } else { break; }; }; }; _local15[_local7] = _local8; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; _local6 = _arg2.worldVertexChain; _local7 = _arg2.worldNormalChain; while (true) { _local8 = ((_local15[_local7]) || (_arg3.worldVertexChain)); _local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); while (true) { _local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.prev; _local17 = _local16; } else { _local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)); if (_local16 < _local17){ _local8 = _local8.next; _local17 = _local16; } else { break; }; }; }; _local15[_local7] = _local8; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = true; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 0; }; if (_local6.isTail){ break; }; _local6 = _local6.next; _local7 = _local7.next; }; }; var _local18:ShapeSkeleton = (_local14) ? _arg3 : _arg2; var _local19:Number = _local9.x; var _local20:Number = _local9.y; var _local21:int = _local11.index; var _local22:int = _local10.index; var _local24:V2 = _local10.edge.n; var _local25:Number = ((_local24.x * _local19) + (_local24.y * _local20)); if (((_local24.prev.x * _local19) + (_local24.prev.y * _local20)) < _local25){ _local10 = _local10.prev; _local23 = _local24.prev.index; } else { if (((_local24.next.x * _local19) + (_local24.next.y * _local20)) < _local25){ _local10 = _local10.next; _local23 = _local24.next.index; }; }; var _local26:Number = (((_local18.x * _local19) + (_local18.y * _local20)) + (((_local11.x - _local18.x) * _local19) + ((_local11.y - _local18.y) * _local20))); if (_local18.regularShape){ _local27 = ((_local18.y * _local19) - (_local18.x * _local20)); } else { _local37 = _local18.offsets[_local11.index]; _local27 = ((((_local18.y + (_local18.r21 * _local37.x)) + (_local18.r22 * _local37.y)) * _local19) - (((_local18.x + (_local18.r11 * _local37.x)) + (_local18.r12 * _local37.y)) * _local20)); }; var _local28:Number = (_local11.edge.mag / 2); _local33 = ((((_local10.x * _local20) - (_local10.y * _local19)) + _local27) - _local28); _local34 = ((((_local10.next.x * _local20) - (_local10.next.y * _local19)) + _local27) - _local28); if ((_local33 * _local34) < 0){ _local35 = (_local33 / (_local33 - _local34)); if (_local33 < 0){ _local29 = _local10.x; _local31 = _local10.y; _local30 = (_local29 + (_local35 * (_local10.next.x - _local29))); _local32 = (_local31 + (_local35 * (_local10.next.y - _local31))); } else { _local29 = _local10.next.x; _local31 = _local10.next.y; _local30 = (_local10.x + (_local35 * (_local29 - _local10.x))); _local32 = (_local10.y + (_local35 * (_local31 - _local10.y))); }; } else { if (_local33 > 0){ _arg1.pointCount = 0; return; }; if (_local33 < _local34){ _local29 = _local10.x; _local31 = _local10.y; _local30 = _local10.next.x; _local32 = _local10.next.y; } else { _local30 = _local10.x; _local32 = _local10.y; _local29 = _local10.next.x; _local31 = _local10.next.y; }; }; _local33 = ((((_local31 * _local19) - _local27) - _local28) - (_local29 * _local20)); _local34 = ((((_local32 * _local19) - _local27) - _local28) - (_local30 * _local20)); if ((_local33 * _local34) < 0){ _local35 = (_local33 / (_local33 - _local34)); _local29 = (_local29 + (_local35 * (_local30 - _local29))); _local31 = (_local31 + (_local35 * (_local32 - _local31))); } else { if (_local33 > 0){ _arg1.pointCount = 0; return; }; }; _local12 = (((_local19 * _local29) + (_local20 * _local31)) - _local26); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local19); _arg1.ny = -(_local20); } else { _arg1.nx = _local19; _arg1.ny = _local20; }; _local36 = _arg1.c0; _local36.sep = _local12; _local36.x = _local29; _local36.y = _local31; _local36.id.flip = _local14; _local36.id.incEdge = _local23; _local36.id.incVert = _local22; _local36.id.refFace = _local21; _local36.id.bake(); _local12 = (((_local19 * _local30) + (_local20 * _local32)) - _local26); if (_local12 <= 0){ _arg1.pointCount = 2; _local36 = _arg1.c1; _local36.sep = _local12; _local36.x = _local30; _local36.y = _local32; _local36.id.flip = _local14; _local36.id.incEdge = _local23; _local36.id.incVert = _local22; _local36.id.refFace = _local21; _local36.id.bake(); }; } else { _local12 = (((_local19 * _local30) + (_local20 * _local32)) - _local26); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local19); _arg1.ny = -(_local20); } else { _arg1.nx = _local19; _arg1.ny = _local20; }; _local36 = _arg1.c0; _local36.sep = _local12; _local36.x = _local30; _local36.y = _local32; _local36.id.flip = _local14; _local36.id.incEdge = _local23; _local36.id.incVert = _local22; _local36.id.refFace = _local21; _local36.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 132
//CollidePolyCircle (de.polygonal.motor2.collision.pairwise.CollidePolyCircle) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollidePolyCircle implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:V2; var _local6:V2; var _local7:V2; var _local8:V2; var _local11:Number; var _local12:Number; var _local17:Number; var _local19:Number; var _local21:Number; var _local22:ContactPoint; var _local24:Number; var _local25:Number; var _local9:Number = _arg3.x; var _local10:Number = _arg3.y; _local12 = _arg3.radius; var _local13:Number = -2147483648; var _local14:ConvexCircleContact = ConvexCircleContact(_arg4); _local5 = _local14.p; _local6 = _local14.d; var _local15:int = _local5.prev.index; while (true) { _local11 = ((_local6.x * (_local9 - _local5.x)) + (_local6.y * (_local10 - _local5.y))); if (_local11 > _local12){ _arg1.pointCount = 0; _local14.p = _local5; _local14.d = _local6; return; }; if (_local11 > _local13){ _local13 = _local11; _local7 = _local6; _local8 = _local5; }; if (_local5.index == _local15){ break; }; _local5 = _local5.next; _local6 = _local6.next; }; if (_local13 < 1E-6){ _arg1.pointCount = 1; _arg1.nx = _local7.x; _arg1.ny = _local7.y; _local22 = _arg1.c0; _local22.id.incEdge = (_local7.index + 1); _local22.id.incVert = 254; _local22.id.refFace = 254; _local22.id.flip = 0; _local22.id.bake(); _local22.x = (_local9 - (_local12 * _arg1.nx)); _local22.y = (_local10 - (_local12 * _arg1.ny)); _local22.sep = (_local13 - _local12); return; }; var _local16:E2 = _local8.edge; var _local18:Number = ((_arg2.r11 * _local16.d.x) + (_arg2.r12 * _local16.d.y)); var _local20:Number = ((_arg2.r21 * _local16.d.x) + (_arg2.r22 * _local16.d.y)); if (_local16.mag < 1E-6){ _local17 = (_local9 - _local8.x); _local19 = (_local10 - _local8.y); _local21 = ((_local17 * _local17) + (_local19 * _local19)); if (_local21 > _arg3.radiusSq){ }; _arg1.pointCount = 0; return; }; var _local23:Number = (((_local9 - _local8.x) * _local18) + ((_local10 - _local8.y) * _local20)); _local22 = _arg1.c0; _local22.id.refFace = 254; _local22.id.flip = 0; if (_local23 <= 0){ _local24 = _local8.x; _local25 = _local8.y; _local22.id.incVert = (_local8.index + 1); _local22.id.incEdge = 254; } else { if (_local23 >= _local16.mag){ _local24 = _local8.next.x; _local25 = _local8.next.y; _local22.id.incVert = (_local8.next.index + 1); _local22.id.incEdge = 254; } else { _local24 = ((_local18 * _local23) + _local8.x); _local25 = ((_local20 * _local23) + _local8.y); _local22.id.incVert = 254; _local22.id.incEdge = (_local8.index + 1); }; }; _local17 = (_local9 - _local24); _local19 = (_local10 - _local25); _local21 = ((_local17 * _local17) + (_local19 * _local19)); if (_local21 > _arg3.radiusSq){ _arg1.pointCount = 0; return; }; _local21 = Math.sqrt(_local21); _local17 = (_local17 / _local21); _local19 = (_local19 / _local21); _arg1.pointCount = 1; _arg1.nx = _local17; _arg1.ny = _local19; _local22.x = (_local9 - (_arg3.radius * _local17)); _local22.y = (_local10 - (_arg3.radius * _local19)); _local22.sep = (_local21 - _local12); _local22.id.bake(); } } }//package de.polygonal.motor2.collision.pairwise
Section 133
//CollidePolyLineDoubleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyLineDoubleSidedBSP) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollidePolyLineDoubleSidedBSP implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:ConvexBSPNode; var _local6:V2; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:V2; var _local12:V2; var _local13:Number; var _local22:ShapeSkeleton; var _local23:ShapeSkeleton; var _local28:int; var _local32:Number; var _local34:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:Number; var _local41:ContactPoint; var _local42:V2; var _local14:Number = -2147483648; var _local15:int; _local10 = _arg3.worldVertexChain; _local9 = _arg3.worldNormalChain; _local5 = _arg2.BSPNode; while (_local5.R) { _local6 = _local5.N; _local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L; }; _local7 = _local5.V; _local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y))); if (_local13 > 0){ _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local14){ _local14 = _local13; _local8 = _local9; _local11 = _local10; _local12 = _local7; _local15 = 1; }; _local10 = _local10.next; _local9 = _local9.next; _local5 = _arg2.BSPNode; while (_local5.R) { _local6 = _local5.N; _local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L; }; _local7 = _local5.V; _local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y))); if (_local13 > 0){ _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local14){ _local14 = _local13; _local8 = _local9; _local11 = _local10; _local12 = _local7; _local15 = 1; }; var _local16:V2 = _arg3.worldVertexChain; var _local17:V2 = _local16.next; var _local18:Number = _local16.x; var _local19:Number = _local17.x; var _local20:Number = _local16.y; var _local21:Number = _local17.y; _local10 = _arg2.worldVertexChain; _local9 = _arg2.worldNormalChain; while (true) { if (((_local18 * _local9.x) + (_local20 * _local9.y)) < ((_local19 * _local9.x) + (_local21 * _local9.y))){ _local13 = ((_local9.x * (_local18 - _local10.x)) + (_local9.y * (_local20 - _local10.y))); if (_local13 > 0){ _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local14){ _local14 = _local13; _local8 = _local9; _local11 = _local10; _local12 = _local16; _local15 = 0; }; } else { _local13 = ((_local9.x * (_local19 - _local10.x)) + (_local9.y * (_local21 - _local10.y))); if (_local13 > 0){ _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local14){ _local14 = _local13; _local8 = _local9; _local11 = _local10; _local12 = _local17; _local15 = 0; }; }; if (_local10.isTail){ break; }; _local10 = _local10.next; _local9 = _local9.next; }; if (_local15){ _local22 = _arg3; _local23 = _arg2; } else { _local22 = _arg2; _local23 = _arg3; }; var _local24:Number = _local8.x; var _local25:Number = _local8.y; var _local26:int = _local11.index; var _local27:int = _local12.index; var _local29:V2 = _local12.edge.n; var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25)); if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){ _local12 = _local12.prev; _local28 = _local29.prev.index; } else { if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){ _local12 = _local12.next; _local28 = _local29.next.index; }; }; var _local31:Number = (((_local22.x * _local24) + (_local22.y * _local25)) + (((_local11.x - _local22.x) * _local24) + ((_local11.y - _local22.y) * _local25))); if (_local22.regularShape){ _local32 = ((_local22.y * _local24) - (_local22.x * _local25)); } else { _local42 = _local22.offsets[_local11.index]; _local32 = ((((_local22.y + (_local22.r21 * _local42.x)) + (_local22.r22 * _local42.y)) * _local24) - (((_local22.x + (_local22.r11 * _local42.x)) + (_local22.r12 * _local42.y)) * _local25)); }; var _local33:Number = (_local11.edge.mag / 2); _local38 = ((((_local12.x * _local25) - (_local12.y * _local24)) + _local32) - _local33); _local39 = ((((_local12.next.x * _local25) - (_local12.next.y * _local24)) + _local32) - _local33); if ((_local38 * _local39) < 0){ _local40 = (_local38 / (_local38 - _local39)); if (_local38 < 0){ _local34 = _local12.x; _local36 = _local12.y; _local35 = (_local34 + (_local40 * (_local12.next.x - _local34))); _local37 = (_local36 + (_local40 * (_local12.next.y - _local36))); } else { _local34 = _local12.next.x; _local36 = _local12.next.y; _local35 = (_local12.x + (_local40 * (_local34 - _local12.x))); _local37 = (_local12.y + (_local40 * (_local36 - _local12.y))); }; } else { if (_local38 > 0){ _arg1.pointCount = 0; return; }; if (_local38 < _local39){ _local34 = _local12.x; _local36 = _local12.y; _local35 = _local12.next.x; _local37 = _local12.next.y; } else { _local35 = _local12.x; _local37 = _local12.y; _local34 = _local12.next.x; _local36 = _local12.next.y; }; }; _local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25)); _local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25)); if ((_local38 * _local39) < 0){ _local40 = (_local38 / (_local38 - _local39)); _local34 = (_local34 + (_local40 * (_local35 - _local34))); _local36 = (_local36 + (_local40 * (_local37 - _local36))); } else { if (_local38 > 0){ _arg1.pointCount = 0; return; }; }; _local14 = (((_local24 * _local34) + (_local25 * _local36)) - _local31); if (_local14 <= 0){ _arg1.pointCount = 1; if (_local15){ _arg1.nx = -(_local24); _arg1.ny = -(_local25); } else { _arg1.nx = _local24; _arg1.ny = _local25; }; _local41 = _arg1.c0; _local41.sep = _local14; _local41.x = _local34; _local41.y = _local36; _local41.id.flip = _local15; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); _local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31); if (_local14 <= 0){ _arg1.pointCount = 2; _local41 = _arg1.c1; _local41.sep = _local14; _local41.x = _local35; _local41.y = _local37; _local41.id.flip = _local15; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); }; } else { _local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31); if (_local14 <= 0){ _arg1.pointCount = 1; if (_local15){ _arg1.nx = -(_local24); _arg1.ny = -(_local25); } else { _arg1.nx = _local24; _arg1.ny = _local25; }; _local41 = _arg1.c0; _local41.sep = _local14; _local41.x = _local35; _local41.y = _local37; _local41.id.flip = _local15; _local41.id.incEdge = _local28; _local41.id.incVert = _local27; _local41.id.refFace = _local26; _local41.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 134
//CollidePolyLineDoubleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyLineDoubleSidedCHC) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollidePolyLineDoubleSidedCHC implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:V2; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:V2; var _local12:Number; var _local14:Number; var _local15:Number; var _local23:ShapeSkeleton; var _local24:ShapeSkeleton; var _local29:int; var _local33:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:Number; var _local41:Number; var _local42:ContactPoint; var _local43:V2; var _local5:PolyLineContact = PolyLineContact(_arg4); var _local13:Number = -2147483648; var _local16:int; _local9 = _arg3.worldVertexChain; _local8 = _arg3.worldNormalChain; _local6 = _local5.hint1; _local15 = ((_local6.x * _local8.x) + (_local6.y * _local8.y)); while (true) { _local14 = ((_local6.prev.x * _local8.x) + (_local6.prev.y * _local8.y)); if (_local14 < _local15){ _local6 = _local6.prev; _local15 = _local14; } else { _local14 = ((_local6.next.x * _local8.x) + (_local6.next.y * _local8.y)); if (_local14 < _local15){ _local6 = _local6.next; _local15 = _local14; } else { break; }; }; }; _local5.hint1 = _local6; _local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y))); if (_local12 > 0){ _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local7 = _local8; _local10 = _local9; _local11 = _local6; _local16 = 1; }; _local9 = _local9.next; _local8 = _local8.next; _local6 = _local5.hint2; _local15 = ((_local6.x * _local8.x) + (_local6.y * _local8.y)); while (true) { _local14 = ((_local6.prev.x * _local8.x) + (_local6.prev.y * _local8.y)); if (_local14 < _local15){ _local6 = _local6.prev; _local15 = _local14; } else { _local14 = ((_local6.next.x * _local8.x) + (_local6.next.y * _local8.y)); if (_local14 < _local15){ _local6 = _local6.next; _local15 = _local14; } else { break; }; }; }; _local5.hint2 = _local6; _local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y))); if (_local12 > 0){ _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local7 = _local8; _local10 = _local9; _local11 = _local6; _local16 = 1; }; var _local17:V2 = _arg3.worldVertexChain; var _local18:V2 = _local17.next; var _local19:Number = _local17.x; var _local20:Number = _local18.x; var _local21:Number = _local17.y; var _local22:Number = _local18.y; _local9 = _arg2.worldVertexChain; _local8 = _arg2.worldNormalChain; while (true) { if (((_local19 * _local8.x) + (_local21 * _local8.y)) < ((_local20 * _local8.x) + (_local22 * _local8.y))){ _local12 = ((_local8.x * (_local19 - _local9.x)) + (_local8.y * (_local21 - _local9.y))); if (_local12 > 0){ _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local7 = _local8; _local10 = _local9; _local11 = _local17; _local16 = 0; }; } else { _local12 = ((_local8.x * (_local20 - _local9.x)) + (_local8.y * (_local22 - _local9.y))); if (_local12 > 0){ _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local7 = _local8; _local10 = _local9; _local11 = _local18; _local16 = 0; }; }; if (_local9.isTail){ break; }; _local9 = _local9.next; _local8 = _local8.next; }; if (_local16){ _local23 = _arg3; _local24 = _arg2; } else { _local23 = _arg2; _local24 = _arg3; }; var _local25:Number = _local7.x; var _local26:Number = _local7.y; var _local27:int = _local10.index; var _local28:int = _local11.index; var _local30:V2 = _local11.edge.n; var _local31:Number = ((_local30.x * _local25) + (_local30.y * _local26)); if (((_local30.prev.x * _local25) + (_local30.prev.y * _local26)) < _local31){ _local11 = _local11.prev; _local29 = _local30.prev.index; } else { if (((_local30.next.x * _local25) + (_local30.next.y * _local26)) < _local31){ _local11 = _local11.next; _local29 = _local30.next.index; }; }; var _local32:Number = (((_local23.x * _local25) + (_local23.y * _local26)) + (((_local10.x - _local23.x) * _local25) + ((_local10.y - _local23.y) * _local26))); if (_local23.regularShape){ _local33 = ((_local23.y * _local25) - (_local23.x * _local26)); } else { _local43 = _local23.offsets[_local10.index]; _local33 = ((((_local23.y + (_local23.r21 * _local43.x)) + (_local23.r22 * _local43.y)) * _local25) - (((_local23.x + (_local23.r11 * _local43.x)) + (_local23.r12 * _local43.y)) * _local26)); }; var _local34:Number = (_local10.edge.mag / 2); _local39 = ((((_local11.x * _local26) - (_local11.y * _local25)) + _local33) - _local34); _local40 = ((((_local11.next.x * _local26) - (_local11.next.y * _local25)) + _local33) - _local34); if ((_local39 * _local40) < 0){ _local41 = (_local39 / (_local39 - _local40)); if (_local39 < 0){ _local35 = _local11.x; _local37 = _local11.y; _local36 = (_local35 + (_local41 * (_local11.next.x - _local35))); _local38 = (_local37 + (_local41 * (_local11.next.y - _local37))); } else { _local35 = _local11.next.x; _local37 = _local11.next.y; _local36 = (_local11.x + (_local41 * (_local35 - _local11.x))); _local38 = (_local11.y + (_local41 * (_local37 - _local11.y))); }; } else { if (_local39 > 0){ _arg1.pointCount = 0; return; }; if (_local39 < _local40){ _local35 = _local11.x; _local37 = _local11.y; _local36 = _local11.next.x; _local38 = _local11.next.y; } else { _local36 = _local11.x; _local38 = _local11.y; _local35 = _local11.next.x; _local37 = _local11.next.y; }; }; _local39 = ((((_local37 * _local25) - _local33) - _local34) - (_local35 * _local26)); _local40 = ((((_local38 * _local25) - _local33) - _local34) - (_local36 * _local26)); if ((_local39 * _local40) < 0){ _local41 = (_local39 / (_local39 - _local40)); _local35 = (_local35 + (_local41 * (_local36 - _local35))); _local37 = (_local37 + (_local41 * (_local38 - _local37))); } else { if (_local39 > 0){ _arg1.pointCount = 0; return; }; }; _local13 = (((_local25 * _local35) + (_local26 * _local37)) - _local32); if (_local13 <= 0){ _arg1.pointCount = 1; if (_local16){ _arg1.nx = -(_local25); _arg1.ny = -(_local26); } else { _arg1.nx = _local25; _arg1.ny = _local26; }; _local42 = _arg1.c0; _local42.sep = _local13; _local42.x = _local35; _local42.y = _local37; _local42.id.flip = _local16; _local42.id.incEdge = _local29; _local42.id.incVert = _local28; _local42.id.refFace = _local27; _local42.id.bake(); _local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32); if (_local13 <= 0){ _arg1.pointCount = 2; _local42 = _arg1.c1; _local42.sep = _local13; _local42.x = _local36; _local42.y = _local38; _local42.id.flip = _local16; _local42.id.incEdge = _local29; _local42.id.incVert = _local28; _local42.id.refFace = _local27; _local42.id.bake(); }; } else { _local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32); if (_local13 <= 0){ _arg1.pointCount = 1; if (_local16){ _arg1.nx = -(_local25); _arg1.ny = -(_local26); } else { _arg1.nx = _local25; _arg1.ny = _local26; }; _local42 = _arg1.c0; _local42.sep = _local13; _local42.x = _local36; _local42.y = _local38; _local42.id.flip = _local16; _local42.id.incEdge = _local29; _local42.id.incVert = _local28; _local42.id.refFace = _local27; _local42.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 135
//CollidePolyLineSingleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyLineSingleSidedBSP) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollidePolyLineSingleSidedBSP implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:ConvexBSPNode; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:V2; var _local12:Number; var _local21:ShapeSkeleton; var _local22:ShapeSkeleton; var _local27:int; var _local31:Number; var _local33:Number; var _local34:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:ContactPoint; var _local41:V2; var _local5:V2 = _arg3.worldNormalChain; if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){ _arg4.disabled = true; _arg1.pointCount = 0; return; }; var _local13:Number = -2147483648; var _local14:int; _local9 = _arg3.worldVertexChain; _local8 = _arg3.worldNormalChain; _local6 = _arg2.BSPNode; while (_local6.R) { _local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L; }; _local7 = _local6.V; _local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local7; _local14 = 1; }; _local9 = _local9.next; _local8 = _local8.next; _local6 = _arg2.BSPNode; while (_local6.R) { _local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L; }; _local7 = _local6.V; _local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local7; _local14 = 1; }; var _local15:V2 = _arg3.worldVertexChain; var _local16:V2 = _local15.next; var _local17:Number = _local15.x; var _local18:Number = _local16.x; var _local19:Number = _local15.y; var _local20:Number = _local16.y; _local9 = _arg2.worldVertexChain; _local8 = _arg2.worldNormalChain; while (true) { if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){ _local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local15; _local14 = 0; }; } else { _local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local16; _local14 = 0; }; }; if (_local9.isTail){ break; }; _local9 = _local9.next; _local8 = _local8.next; }; if (_arg4.disabled){ _arg1.pointCount = 0; return; }; if (_local14){ _local21 = _arg3; _local22 = _arg2; } else { _local21 = _arg2; _local22 = _arg3; }; var _local23:Number = _local5.x; var _local24:Number = _local5.y; var _local25:int = _local10.index; var _local26:int = _local11.index; var _local28:V2 = _local11.edge.n; var _local29:Number = ((_local28.x * _local23) + (_local28.y * _local24)); if (((_local28.prev.x * _local23) + (_local28.prev.y * _local24)) < _local29){ _local11 = _local11.prev; _local27 = _local28.prev.index; } else { if (((_local28.next.x * _local23) + (_local28.next.y * _local24)) < _local29){ _local11 = _local11.next; _local27 = _local28.next.index; }; }; var _local30:Number = (((_local21.x * _local23) + (_local21.y * _local24)) + (((_local10.x - _local21.x) * _local23) + ((_local10.y - _local21.y) * _local24))); if (_local21.regularShape){ _local31 = ((_local21.y * _local23) - (_local21.x * _local24)); } else { _local41 = _local21.offsets[_local10.index]; _local31 = ((((_local21.y + (_local21.r21 * _local41.x)) + (_local21.r22 * _local41.y)) * _local23) - (((_local21.x + (_local21.r11 * _local41.x)) + (_local21.r12 * _local41.y)) * _local24)); }; var _local32:Number = (_local10.edge.mag / 2); _local37 = ((((_local11.x * _local24) - (_local11.y * _local23)) + _local31) - _local32); _local38 = ((((_local11.next.x * _local24) - (_local11.next.y * _local23)) + _local31) - _local32); if ((_local37 * _local38) < 0){ _local39 = (_local37 / (_local37 - _local38)); if (_local37 < 0){ _local33 = _local11.x; _local35 = _local11.y; _local34 = (_local33 + (_local39 * (_local11.next.x - _local33))); _local36 = (_local35 + (_local39 * (_local11.next.y - _local35))); } else { _local33 = _local11.next.x; _local35 = _local11.next.y; _local34 = (_local11.x + (_local39 * (_local33 - _local11.x))); _local36 = (_local11.y + (_local39 * (_local35 - _local11.y))); }; } else { if (_local37 > 0){ _arg1.pointCount = 0; return; }; if (_local37 < _local38){ _local33 = _local11.x; _local35 = _local11.y; _local34 = _local11.next.x; _local36 = _local11.next.y; } else { _local34 = _local11.x; _local36 = _local11.y; _local33 = _local11.next.x; _local35 = _local11.next.y; }; }; _local37 = ((((_local35 * _local23) - _local31) - _local32) - (_local33 * _local24)); _local38 = ((((_local36 * _local23) - _local31) - _local32) - (_local34 * _local24)); if ((_local37 * _local38) < 0){ _local39 = (_local37 / (_local37 - _local38)); _local33 = (_local33 + (_local39 * (_local34 - _local33))); _local35 = (_local35 + (_local39 * (_local36 - _local35))); } else { if (_local37 > 0){ _arg1.pointCount = 0; return; }; }; _local13 = (((_local23 * _local33) + (_local24 * _local35)) - _local30); if (_local13 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local23); _arg1.ny = -(_local24); } else { _arg1.nx = _local23; _arg1.ny = _local24; }; _local40 = _arg1.c0; _local40.sep = _local13; _local40.x = _local33; _local40.y = _local35; _local40.id.flip = _local14; _local40.id.incEdge = _local27; _local40.id.incVert = _local26; _local40.id.refFace = _local25; _local40.id.bake(); _local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30); if (_local13 <= 0){ _arg1.pointCount = 2; _local40 = _arg1.c1; _local40.sep = _local13; _local40.x = _local34; _local40.y = _local36; _local40.id.flip = _local14; _local40.id.incEdge = _local27; _local40.id.incVert = _local26; _local40.id.refFace = _local25; _local40.id.bake(); }; } else { _local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30); if (_local13 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local23); _arg1.ny = -(_local24); } else { _arg1.nx = _local23; _arg1.ny = _local24; }; _local40 = _arg1.c0; _local40.sep = _local13; _local40.x = _local34; _local40.y = _local36; _local40.id.flip = _local14; _local40.id.incEdge = _local27; _local40.id.incVert = _local26; _local40.id.refFace = _local25; _local40.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 136
//CollidePolyLineSingleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyLineSingleSidedCHC) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollidePolyLineSingleSidedCHC implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:V2; var _local12:Number; var _local14:Number; var _local15:Number; var _local23:ShapeSkeleton; var _local24:ShapeSkeleton; var _local29:int; var _local33:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:Number; var _local41:Number; var _local42:ContactPoint; var _local43:V2; var _local5:V2 = _arg3.worldNormalChain; if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){ _arg4.disabled = true; _arg1.pointCount = 0; return; }; var _local6:PolyLineContact = PolyLineContact(_arg4); var _local13:Number = -2147483648; var _local16:int; _local9 = _arg3.worldVertexChain; _local8 = _arg3.worldNormalChain; _local7 = _local6.hint1; _local15 = ((_local7.x * _local8.x) + (_local7.y * _local8.y)); while (true) { _local14 = ((_local7.prev.x * _local8.x) + (_local7.prev.y * _local8.y)); if (_local14 < _local15){ _local7 = _local7.prev; _local15 = _local14; } else { _local14 = ((_local7.next.x * _local8.x) + (_local7.next.y * _local8.y)); if (_local14 < _local15){ _local7 = _local7.next; _local15 = _local14; } else { break; }; }; }; _local6.hint1 = _local7; _local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local7; _local16 = 1; }; _local9 = _local9.next; _local8 = _local8.next; _local7 = _local6.hint2; _local15 = ((_local7.x * _local8.x) + (_local7.y * _local8.y)); while (true) { _local14 = ((_local7.prev.x * _local8.x) + (_local7.prev.y * _local8.y)); if (_local14 < _local15){ _local7 = _local7.prev; _local15 = _local14; } else { _local14 = ((_local7.next.x * _local8.x) + (_local7.next.y * _local8.y)); if (_local14 < _local15){ _local7 = _local7.next; _local15 = _local14; } else { break; }; }; }; _local6.hint2 = _local7; _local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local7; _local16 = 1; }; var _local17:V2 = _arg3.worldVertexChain; var _local18:V2 = _local17.next; var _local19:Number = _local17.x; var _local20:Number = _local18.x; var _local21:Number = _local17.y; var _local22:Number = _local18.y; _local9 = _arg2.worldVertexChain; _local8 = _arg2.worldNormalChain; while (true) { if (((_local19 * _local8.x) + (_local21 * _local8.y)) < ((_local20 * _local8.x) + (_local22 * _local8.y))){ _local12 = ((_local8.x * (_local19 - _local9.x)) + (_local8.y * (_local21 - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local17; _local16 = 0; }; } else { _local12 = ((_local8.x * (_local20 - _local9.x)) + (_local8.y * (_local22 - _local9.y))); if (_local12 > 0){ _arg4.disabled = false; _arg1.pointCount = 0; return; }; if (((_local12 * 0.95) + 0.01) > _local13){ _local13 = _local12; _local5 = _local8; _local10 = _local9; _local11 = _local18; _local16 = 0; }; }; if (_local9.isTail){ break; }; _local9 = _local9.next; _local8 = _local8.next; }; if (_arg4.disabled){ _arg1.pointCount = 0; return; }; if (_local16){ _local23 = _arg3; _local24 = _arg2; } else { _local23 = _arg2; _local24 = _arg3; }; var _local25:Number = _local5.x; var _local26:Number = _local5.y; var _local27:int = _local10.index; var _local28:int = _local11.index; var _local30:V2 = _local11.edge.n; var _local31:Number = ((_local30.x * _local25) + (_local30.y * _local26)); if (((_local30.prev.x * _local25) + (_local30.prev.y * _local26)) < _local31){ _local11 = _local11.prev; _local29 = _local30.prev.index; } else { if (((_local30.next.x * _local25) + (_local30.next.y * _local26)) < _local31){ _local11 = _local11.next; _local29 = _local30.next.index; }; }; var _local32:Number = (((_local23.x * _local25) + (_local23.y * _local26)) + (((_local10.x - _local23.x) * _local25) + ((_local10.y - _local23.y) * _local26))); if (_local23.regularShape){ _local33 = ((_local23.y * _local25) - (_local23.x * _local26)); } else { _local43 = _local23.offsets[_local10.index]; _local33 = ((((_local23.y + (_local23.r21 * _local43.x)) + (_local23.r22 * _local43.y)) * _local25) - (((_local23.x + (_local23.r11 * _local43.x)) + (_local23.r12 * _local43.y)) * _local26)); }; var _local34:Number = (_local10.edge.mag / 2); _local39 = ((((_local11.x * _local26) - (_local11.y * _local25)) + _local33) - _local34); _local40 = ((((_local11.next.x * _local26) - (_local11.next.y * _local25)) + _local33) - _local34); if ((_local39 * _local40) < 0){ _local41 = (_local39 / (_local39 - _local40)); if (_local39 < 0){ _local35 = _local11.x; _local37 = _local11.y; _local36 = (_local35 + (_local41 * (_local11.next.x - _local35))); _local38 = (_local37 + (_local41 * (_local11.next.y - _local37))); } else { _local35 = _local11.next.x; _local37 = _local11.next.y; _local36 = (_local11.x + (_local41 * (_local35 - _local11.x))); _local38 = (_local11.y + (_local41 * (_local37 - _local11.y))); }; } else { if (_local39 > 0){ _arg1.pointCount = 0; return; }; if (_local39 < _local40){ _local35 = _local11.x; _local37 = _local11.y; _local36 = _local11.next.x; _local38 = _local11.next.y; } else { _local36 = _local11.x; _local38 = _local11.y; _local35 = _local11.next.x; _local37 = _local11.next.y; }; }; _local39 = ((((_local37 * _local25) - _local33) - _local34) - (_local35 * _local26)); _local40 = ((((_local38 * _local25) - _local33) - _local34) - (_local36 * _local26)); if ((_local39 * _local40) < 0){ _local41 = (_local39 / (_local39 - _local40)); _local35 = (_local35 + (_local41 * (_local36 - _local35))); _local37 = (_local37 + (_local41 * (_local38 - _local37))); } else { if (_local39 > 0){ _arg1.pointCount = 0; return; }; }; _local13 = (((_local25 * _local35) + (_local26 * _local37)) - _local32); if (_local13 <= 0){ _arg1.pointCount = 1; if (_local16){ _arg1.nx = -(_local25); _arg1.ny = -(_local26); } else { _arg1.nx = _local25; _arg1.ny = _local26; }; _local42 = _arg1.c0; _local42.sep = _local13; _local42.x = _local35; _local42.y = _local37; _local42.id.flip = _local16; _local42.id.incEdge = _local29; _local42.id.incVert = _local28; _local42.id.refFace = _local27; _local42.id.bake(); _local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32); if (_local13 <= 0){ _arg1.pointCount = 2; _local42 = _arg1.c1; _local42.sep = _local13; _local42.x = _local36; _local42.y = _local38; _local42.id.flip = _local16; _local42.id.incEdge = _local29; _local42.id.incVert = _local28; _local42.id.refFace = _local27; _local42.id.bake(); }; } else { _local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32); if (_local13 <= 0){ _arg1.pointCount = 1; if (_local16){ _arg1.nx = -(_local25); _arg1.ny = -(_local26); } else { _arg1.nx = _local25; _arg1.ny = _local26; }; _local42 = _arg1.c0; _local42.sep = _local13; _local42.x = _local36; _local42.y = _local38; _local42.id.flip = _local16; _local42.id.incEdge = _local29; _local42.id.incVert = _local28; _local42.id.refFace = _local27; _local42.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 137
//CollidePolyPlaneDoubleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDoubleSidedBSP) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollidePolyPlaneDoubleSidedBSP implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:ConvexBSPNode; var _local9:V2; var _local10:int; var _local11:ContactPoint; var _local12:Number; var _local6:Number = _arg3.worldNormalChain.x; var _local7:Number = _arg3.worldNormalChain.y; var _local8:Number = _arg3.d; if ((((_arg2.x * _local6) + (_arg2.y * _local7)) - _local8) > 0){ _local5 = _arg2.BSPNode; while (_local5.R) { _local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L; }; _local9 = _local5.V; _local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8); if (_local12 > 0){ _arg1.pointCount = 0; return; }; } else { _local6 = -(_local6); _local7 = -(_local7); _local8 = -(_local8); _local10 = 1; _local5 = _arg2.BSPNode; while (_local5.R) { _local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L; }; _local9 = _local5.V; _local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8); if (_local12 > 0){ _arg1.pointCount = 0; return; }; }; _arg1.pointCount = 1; _arg1.nx = -(_local6); _arg1.ny = -(_local7); _local11 = _arg1.c0; _local11.sep = _local12; _local11.x = _local9.x; _local11.y = _local9.y; _local11.id.key = _local10; _local12 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8); if (_local12 < 0){ _local11.id.key = -(~(_local10)); _local11 = _arg1.c1; _local11.sep = _local12; _local11.x = _local9.prev.x; _local11.y = _local9.prev.y; _local11.id.key = -(~(_local10)); _arg1.pointCount++; } else { _local12 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8); if (_local12 < 0){ _local11.id.key = -(~(_local10)); _local11 = _arg1.c1; _local11.sep = _local12; _local11.x = _local9.next.x; _local11.y = _local9.next.y; _local11.id.key = -(~(_local10)); _arg1.pointCount++; }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 138
//CollidePolyPlaneDoubleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDoubleSidedCHC) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollidePolyPlaneDoubleSidedCHC implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local8:Number; var _local9:Number; var _local11:V2; var _local12:int; var _local13:ContactPoint; var _local14:Number; var _local5:PolyLineContact = PolyLineContact(_arg4); var _local6:Number = _arg3.worldNormalChain.x; var _local7:Number = _arg3.worldNormalChain.y; var _local10:Number = _arg3.d; if ((((_arg2.x * _local6) + (_arg2.y * _local7)) - _local10) > 0){ _local11 = _local5.hint1; _local9 = ((_local11.x * _local6) + (_local11.y * _local7)); while (true) { _local8 = ((_local11.prev.x * _local6) + (_local11.prev.y * _local7)); if (_local8 < _local9){ _local11 = _local11.prev; _local9 = _local8; } else { _local8 = ((_local11.next.x * _local6) + (_local11.next.y * _local7)); if (_local8 < _local9){ _local11 = _local11.next; _local9 = _local8; } else { break; }; }; }; _local5.hint1 = _local11; _local14 = (((_local11.x * _local6) + (_local11.y * _local7)) - _local10); if (_local14 > 0){ _arg1.pointCount = 0; return; }; } else { _local6 = -(_local6); _local7 = -(_local7); _local10 = -(_local10); _local12 = 1; _local11 = _local5.hint2; _local9 = ((_local11.x * _local6) + (_local11.y * _local7)); while (true) { _local8 = ((_local11.prev.x * _local6) + (_local11.prev.y * _local7)); if (_local8 < _local9){ _local11 = _local11.prev; _local9 = _local8; } else { _local8 = ((_local11.next.x * _local6) + (_local11.next.y * _local7)); if (_local8 < _local9){ _local11 = _local11.next; _local9 = _local8; } else { break; }; }; }; _local5.hint2 = _local11; _local14 = (((_local11.x * _local6) + (_local11.y * _local7)) - _local10); if (_local14 > 0){ _arg1.pointCount = 0; return; }; }; _arg1.pointCount = 1; _arg1.nx = -(_local6); _arg1.ny = -(_local7); _local13 = _arg1.c0; _local13.sep = _local14; _local13.x = _local11.x; _local13.y = _local11.y; _local13.id.key = _local12; _local14 = (((_local11.prev.x * _local6) + (_local11.prev.y * _local7)) - _local10); if (_local14 < 0){ _local13.id.key = -(~(_local12)); _local13 = _arg1.c1; _local13.sep = _local14; _local13.x = _local11.prev.x; _local13.y = _local11.prev.y; _local13.id.key = -(~(_local12)); _arg1.pointCount++; } else { _local14 = (((_local11.next.x * _local6) + (_local11.next.y * _local7)) - _local10); if (_local14 < 0){ _local13.id.key = -(~(_local12)); _local13 = _arg1.c1; _local13.sep = _local14; _local13.x = _local11.next.x; _local13.y = _local11.next.y; _local13.id.key = -(~(_local12)); _arg1.pointCount++; }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 139
//CollidePolyPlaneSingleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSingleSidedBSP) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class CollidePolyPlaneSingleSidedBSP implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local5:ConvexBSPNode; var _local7:Number; var _local8:Number; var _local6:Number = _arg3.worldNormalChain.x; _local7 = _arg3.worldNormalChain.y; _local8 = _arg3.d; _local5 = _arg2.BSPNode; while (_local5.R) { _local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L; }; var _local9:V2 = _local5.V; var _local10:Number = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8); if (_local10 > 0){ _arg1.pointCount = 0; return; }; _arg1.nx = -(_local6); _arg1.ny = -(_local7); _arg1.pointCount = 1; var _local11:ContactPoint = _arg1.c0; _local11.sep = _local10; _local11.x = _local9.x; _local11.y = _local9.y; _local11.id.key = 0; _local10 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8); if (_local10 < 0){ _local11.id.key = 1; _local11 = _arg1.c1; _local11.sep = _local10; _local11.x = _local9.prev.x; _local11.y = _local9.prev.y; _local11.id.key = 1; _arg1.pointCount++; } else { _local10 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8); if (_local10 < 0){ _local11.id.key = 1; _local11 = _arg1.c1; _local11.sep = _local10; _local11.x = _local9.next.x; _local11.y = _local9.next.y; _local11.id.key = 1; _arg1.pointCount++; }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 140
//CollidePolyPlaneSingleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSingleSidedCHC) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollidePolyPlaneSingleSidedCHC implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:Number; var _local7:Number; var _local10:Number; var _local5:Number = _arg3.worldNormalChain.x; _local6 = _arg3.worldNormalChain.y; _local7 = _arg3.d; var _local8:PolyLineContact = PolyLineContact(_arg4); var _local9:V2 = _local8.hint1; var _local11:Number = ((_local9.x * _local5) + (_local9.y * _local6)); while (true) { _local10 = ((_local9.prev.x * _local5) + (_local9.prev.y * _local6)); if (_local10 < _local11){ _local9 = _local9.prev; _local11 = _local10; } else { _local10 = ((_local9.next.x * _local5) + (_local9.next.y * _local6)); if (_local10 < _local11){ _local9 = _local9.next; _local11 = _local10; } else { break; }; }; }; _local8.hint1 = _local9; var _local12:Number = (((_local9.x * _local5) + (_local9.y * _local6)) - _local7); if (_local12 > 0){ _arg1.pointCount = 0; return; }; _arg1.nx = -(_local5); _arg1.ny = -(_local6); _arg1.pointCount = 1; var _local13:ContactPoint = _arg1.c0; _local13.sep = _local12; _local13.x = _local9.x; _local13.y = _local9.y; _local13.id.key = 0; _local12 = (((_local9.prev.x * _local5) + (_local9.prev.y * _local6)) - _local7); if (_local12 < 0){ _local13.id.key = 1; _local13 = _arg1.c1; _local13.sep = _local12; _local13.x = _local9.prev.x; _local13.y = _local9.prev.y; _local13.id.key = 1; _arg1.pointCount++; } else { _local12 = (((_local9.next.x * _local5) + (_local9.next.y * _local6)) - _local7); if (_local12 < 0){ _local13.id.key = 1; _local13 = _arg1.c1; _local13.sep = _local12; _local13.x = _local9.next.x; _local13.y = _local9.next.y; _local13.id.key = 1; _arg1.pointCount++; }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 141
//Collider (de.polygonal.motor2.collision.pairwise.Collider) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.contact.*; public interface Collider { function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void; } }//package de.polygonal.motor2.collision.pairwise
Section 142
//CollideTriangleHC (de.polygonal.motor2.collision.pairwise.CollideTriangleHC) package de.polygonal.motor2.collision.pairwise { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class CollideTriangleHC implements Collider { public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{ var _local6:V2; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; var _local11:V2; var _local13:Number; var _local14:int; var _local15:Number; var _local16:Number; var _local22:int; var _local26:Number; var _local28:Number; var _local29:Number; var _local30:Number; var _local31:Number; var _local32:Number; var _local33:Number; var _local34:Number; var _local35:ContactPoint; var _local36:V2; var _local5:PolyContact = PolyContact(_arg4); var _local12:Number = -2147483648; _local6 = _local5.p; _local7 = _local5.d; if (_local5.firstOut){ _local8 = _arg3.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg3.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg3.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; }; _local6 = _arg3.worldVertexChain; _local7 = _arg3.worldNormalChain; _local8 = _arg2.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = false; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg2.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = false; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg2.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = false; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; } else { _local8 = _arg2.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg2.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg2.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 1; }; _local6 = _arg2.worldVertexChain; _local7 = _arg2.worldNormalChain; _local8 = _arg3.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = true; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 0; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg3.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = true; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 0; }; _local6 = _local6.next; _local7 = _local7.next; _local8 = _arg3.worldVertexChain; _local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); _local8 = _local8.next; _local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y)); if (_local16 < _local15){ _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8; } else { _local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev; }; _local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y))); if (_local13 > 0){ _local5.p = _local6; _local5.d = _local7; _local5.firstOut = true; _arg1.pointCount = 0; return; }; if (((_local13 * 0.95) + 0.01) > _local12){ _local12 = _local13; _local9 = _local7; _local11 = _local6; _local10 = _local8; _local14 = 0; }; }; var _local17:ShapeSkeleton = (_local14) ? _arg3 : _arg2; var _local18:Number = _local9.x; var _local19:Number = _local9.y; var _local20:int = _local11.index; var _local21:int = _local10.index; var _local23:V2 = _local10.edge.n; var _local24:Number = ((_local23.x * _local18) + (_local23.y * _local19)); if (((_local23.prev.x * _local18) + (_local23.prev.y * _local19)) < _local24){ _local10 = _local10.prev; _local22 = _local23.prev.index; } else { if (((_local23.next.x * _local18) + (_local23.next.y * _local19)) < _local24){ _local10 = _local10.next; _local22 = _local23.next.index; }; }; var _local25:Number = (((_local17.x * _local18) + (_local17.y * _local19)) + (((_local11.x - _local17.x) * _local18) + ((_local11.y - _local17.y) * _local19))); if (_local17.regularShape){ _local26 = ((_local17.y * _local18) - (_local17.x * _local19)); } else { _local36 = _local17.offsets[_local11.index]; _local26 = ((((_local17.y + (_local17.r21 * _local36.x)) + (_local17.r22 * _local36.y)) * _local18) - (((_local17.x + (_local17.r11 * _local36.x)) + (_local17.r12 * _local36.y)) * _local19)); }; var _local27:Number = (_local11.edge.mag / 2); _local32 = ((((_local10.x * _local19) - (_local10.y * _local18)) + _local26) - _local27); _local33 = ((((_local10.next.x * _local19) - (_local10.next.y * _local18)) + _local26) - _local27); if ((_local32 * _local33) < 0){ _local34 = (_local32 / (_local32 - _local33)); if (_local32 < 0){ _local28 = _local10.x; _local30 = _local10.y; _local29 = (_local28 + (_local34 * (_local10.next.x - _local28))); _local31 = (_local30 + (_local34 * (_local10.next.y - _local30))); } else { _local28 = _local10.next.x; _local30 = _local10.next.y; _local29 = (_local10.x + (_local34 * (_local28 - _local10.x))); _local31 = (_local10.y + (_local34 * (_local30 - _local10.y))); }; } else { if (_local32 > 0){ _arg1.pointCount = 0; return; }; if (_local32 < _local33){ _local28 = _local10.x; _local30 = _local10.y; _local29 = _local10.next.x; _local31 = _local10.next.y; } else { _local29 = _local10.x; _local31 = _local10.y; _local28 = _local10.next.x; _local30 = _local10.next.y; }; }; _local32 = ((((_local30 * _local18) - _local26) - _local27) - (_local28 * _local19)); _local33 = ((((_local31 * _local18) - _local26) - _local27) - (_local29 * _local19)); if ((_local32 * _local33) < 0){ _local34 = (_local32 / (_local32 - _local33)); _local28 = (_local28 + (_local34 * (_local29 - _local28))); _local30 = (_local30 + (_local34 * (_local31 - _local30))); } else { if (_local32 > 0){ _arg1.pointCount = 0; return; }; }; _local12 = (((_local18 * _local28) + (_local19 * _local30)) - _local25); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local18); _arg1.ny = -(_local19); } else { _arg1.nx = _local18; _arg1.ny = _local19; }; _local35 = _arg1.c0; _local35.sep = _local12; _local35.x = _local28; _local35.y = _local30; _local35.id.flip = _local14; _local35.id.incEdge = _local22; _local35.id.incVert = _local21; _local35.id.refFace = _local20; _local35.id.bake(); _local12 = (((_local18 * _local29) + (_local19 * _local31)) - _local25); if (_local12 <= 0){ _arg1.pointCount = 2; _local35 = _arg1.c1; _local35.sep = _local12; _local35.x = _local29; _local35.y = _local31; _local35.id.flip = _local14; _local35.id.incEdge = _local22; _local35.id.incVert = _local21; _local35.id.refFace = _local20; _local35.id.bake(); }; } else { _local12 = (((_local18 * _local29) + (_local19 * _local31)) - _local25); if (_local12 <= 0){ _arg1.pointCount = 1; if (_local14){ _arg1.nx = -(_local18); _arg1.ny = -(_local19); } else { _arg1.nx = _local18; _arg1.ny = _local19; }; _local35 = _arg1.c0; _local35.sep = _local12; _local35.x = _local29; _local35.y = _local31; _local35.id.flip = _local14; _local35.id.incEdge = _local22; _local35.id.incVert = _local21; _local35.id.refFace = _local20; _local35.id.bake(); }; }; } } }//package de.polygonal.motor2.collision.pairwise
Section 143
//BoxData (de.polygonal.motor2.collision.shapes.data.BoxData) package de.polygonal.motor2.collision.shapes.data { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; public class BoxData extends ShapeData { private var _h:Number; private var _w:Number; public function BoxData(_arg1:Number, _arg2:Number, _arg3:Number){ super(_arg1); this.width = _arg2; this.height = _arg3; } public function get width():Number{ return (_w); } public function get height():Number{ return (_h); } override protected function computeMass():void{ _mass = ((_density * _w) * _h); _I = ((_mass / 12) * ((_w * _w) + (_h * _h))); _cm = new V2(); } public function set width(_arg1:Number):void{ _w = _arg1; invalidate(); } override public function getShapeClass():Class{ return (BoxShape); } public function set height(_arg1:Number):void{ _h = _arg1; invalidate(); } override public function get area():Number{ return ((_w * _h)); } override protected function setType():void{ type = ShapeTypes.BOX; } } }//package de.polygonal.motor2.collision.shapes.data
Section 144
//CircleData (de.polygonal.motor2.collision.shapes.data.CircleData) package de.polygonal.motor2.collision.shapes.data { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; public class CircleData extends ShapeData { private var _radius:Number; public function CircleData(_arg1:Number, _arg2:Number){ super(_arg1); this.radius = Math.abs(_arg2); } public function set radius(_arg1:Number):void{ _radius = _arg1; invalidate(); } public function get radius():Number{ return (_radius); } override protected function computeMass():void{ _mass = (((_density * Math.PI) * radius) * radius); _I = (((0.5 * _mass) * radius) * radius); _cm = new V2(); } override public function getShapeClass():Class{ return (CircleShape); } override public function get area():Number{ return (((Math.PI * _radius) * _radius)); } override protected function setType():void{ type = ShapeTypes.CIRCLE; } } }//package de.polygonal.motor2.collision.shapes.data
Section 145
//LineData (de.polygonal.motor2.collision.shapes.data.LineData) package de.polygonal.motor2.collision.shapes.data { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import flash.geom.*; public class LineData extends ShapeData { public const a:Point; public const b:Point; public var infinite:Boolean; public var doubleSided:Boolean; public function LineData(_arg1:Point, _arg2:Point, _arg3:Boolean=false, _arg4:Boolean=true){ a = new Point(); b = new Point(); super(0); var _local5:Number = (_arg2.x - _arg1.x); var _local6:Number = (_arg2.y - _arg1.y); if (Math.sqrt((((_local5 * _local5) + _local6) + _local6)) <= 1E-6){ throw (new Error("overlapping vertices detected")); }; var _local7:Number = (_arg1.x + ((_arg2.x - _arg1.x) * 0.5)); var _local8:Number = (_arg1.y + ((_arg2.y - _arg1.y) * 0.5)); this.a.x = (_arg1.x - _local7); this.b.x = (_arg2.x - _local7); this.a.y = (_arg1.y - _local8); this.b.y = (_arg2.y - _local8); this.infinite = _arg3; this.doubleSided = _arg4; } override protected function setType():void{ type = ShapeTypes.LINE; } override public function getShapeClass():Class{ return (LineShape); } override public function get density():Number{ return (0); } override protected function computeMass():void{ _mass = 0; _I = 0; _cm = new V2((a.x + (0.5 * (b.x - a.x))), (a.y + (0.5 * (b.y - a.y)))); } override public function get area():Number{ return (0); } override public function set density(_arg1:Number):void{ super.density = 0; } } }//package de.polygonal.motor2.collision.shapes.data
Section 146
//ShapeData (de.polygonal.motor2.collision.shapes.data.ShapeData) package de.polygonal.motor2.collision.shapes.data { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; public class ShapeData { public var isSensor:Boolean; protected var _cm:V2; public var groupIndex:int; public var userData; public var maskBits:int; public var categoryBits:int; public var mr:Number; protected var _density:Number; private var _restitution:Number; public var my:Number; public var mx:Number; public var type:int; protected var _I:Number; protected var _mass:Number; private var _friction:Number; public var next:ShapeData; public function ShapeData(_arg1:Number){ this.density = _arg1; init(); } public function getInertia():Number{ if (_density == 0){ return (0); }; if (isNaN(_I)){ computeMass(); }; return (_I); } public function get area():Number{ return (NaN); } private function init():void{ setType(); mx = (my = (mr = 0)); friction = 0.2; restitution = 0; categoryBits = 1; maskBits = 0xFFFF; groupIndex = 0; } public function clrMaskBit(_arg1:int):void{ maskBits = (maskBits & ~((1 << _arg1))); } public function invalidate():void{ _mass = Number.NaN; _I = Number.NaN; _cm = null; } public function setMaskBit(_arg1:int):void{ maskBits = (maskBits | (1 << _arg1)); } public function getCM():V2{ if (_cm == null){ computeMass(); }; return (_cm); } protected function setType():void{ type = ShapeTypes.UNKNOWN; } public function clrCategoryBit(_arg1:int):void{ categoryBits = (categoryBits & ~((1 << _arg1))); } protected function computeMass():void{ } public function getShapeClass():Class{ return (null); } public function set density(_arg1:Number):void{ _density = _arg1; invalidate(); } public function set restitution(_arg1:Number):void{ _restitution = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1; } public function get density():Number{ return (_density); } public function get restitution():Number{ return (_restitution); } public function setCategoryBit(_arg1:int):void{ categoryBits = (categoryBits | (1 << _arg1)); } public function getMass():Number{ if (_density == 0){ return (0); }; if (isNaN(_mass)){ computeMass(); }; return (_mass); } public function set friction(_arg1:Number):void{ _friction = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1; } public function get friction():Number{ return (_friction); } } }//package de.polygonal.motor2.collision.shapes.data
Section 147
//BoxShape (de.polygonal.motor2.collision.shapes.BoxShape) package de.polygonal.motor2.collision.shapes { import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.math.*; import flash.geom.*; import de.polygonal.motor2.collision.shapes.data.*; public class BoxShape extends ShapeSkeleton { private var _r22:Number; private var _mr:Number; private var _r21:Number; private var _r11:Number; private var _r12:Number; public function BoxShape(_arg1:BoxData, _arg2:RigidBody){ super(_arg1, _arg2); setup(_arg1, _arg2); } override public function update():Boolean{ synced = false; if (_mr == 0){ r11 = body.r11; r12 = body.r12; r21 = body.r21; r22 = body.r22; } else { r11 = ((_r11 * body.r11) + (_r12 * body.r21)); r21 = ((_r21 * body.r11) + (_r22 * body.r21)); r12 = ((_r11 * body.r12) + (_r12 * body.r22)); r22 = ((_r21 * body.r12) + (_r22 * body.r22)); }; x = ((body.x + (body.r11 * mx)) + (body.r12 * my)); y = ((body.y + (body.r21 * mx)) + (body.r22 * my)); xmin = (xmax = x); ymin = (ymax = y); if (r11 > 0){ xmin = (xmin - (r11 * ex)); xmax = (xmax + (r11 * ex)); } else { xmin = (xmin + (r11 * ex)); xmax = (xmax - (r11 * ex)); }; if (r12 > 0){ xmin = (xmin - (r12 * ey)); xmax = (xmax + (r12 * ey)); } else { xmin = (xmin + (r12 * ey)); xmax = (xmax - (r12 * ey)); }; if (r21 > 0){ ymin = (ymin - (r21 * ex)); ymax = (ymax + (r21 * ex)); } else { ymin = (ymin + (r21 * ex)); ymax = (ymax - (r21 * ex)); }; if (r22 > 0){ ymin = (ymin - (r22 * ey)); ymax = (ymax + (r22 * ey)); } else { ymin = (ymin + (r22 * ey)); ymax = (ymax - (r22 * ey)); }; return (super.update()); } override public function pointInside(_arg1:Point):Boolean{ var _local2:Number; var _local3:Number; var _local4:Number; _local2 = (_arg1.x - x); _local3 = (_arg1.y - y); _local4 = ((_local2 * r11) + (_local3 * r21)); if (_local4 > ex){ return (false); }; if (_local4 < -(ex)){ return (false); }; _local4 = ((_local2 * r12) + (_local3 * r22)); if (_local4 > ey){ return (false); }; if (_local4 < -(ey)){ return (false); }; return (true); } override public function toWorldSpace():void{ if (synced){ return; }; synced = true; var _local1:Number = (r11 * ex); var _local2:Number = (r12 * ey); var _local3:Number = (r21 * ex); var _local4:Number = (r22 * ey); v0.x = ((x + _local1) + _local2); n0.x = r12; v0.y = ((y + _local3) + _local4); n0.y = r22; v1.x = ((x - _local1) + _local2); n1.x = -(r11); v1.y = ((y - _local3) + _local4); n1.y = -(r21); v2.x = ((x - _local1) - _local2); n2.x = -(r12); v2.y = ((y - _local3) - _local4); n2.y = -(r22); v3.x = ((x + _local1) - _local2); n3.x = r11; v3.y = ((y + _local3) - _local4); n3.y = r21; } override public function closestPoint(_arg1:Point, _arg2:Point=null):void{ var _local3:Number; var _local4:Number; var _local5:Number; if (_arg2){ _local3 = (_arg1.x - (_arg2.x = x)); _local4 = (_arg1.y - (_arg2.y = y)); _local5 = ((_local3 * r11) + (_local4 * r21)); if (_local5 > ex){ _local5 = ex; } else { if (_local5 < -(ex)){ _local5 = -(ex); }; }; _arg2.x = (_arg2.x + (r11 * _local5)); _arg2.y = (_arg2.y + (r21 * _local5)); _local5 = ((_local3 * r12) + (_local4 * r22)); if (_local5 > ey){ _local5 = ey; } else { if (_local5 < -(ey)){ _local5 = -(ey); }; }; _arg2.x = (_arg2.x + (r12 * _local5)); _arg2.y = (_arg2.y + (r22 * _local5)); } else { _local3 = (_arg1.x - (_arg1.x = x)); _local4 = (_arg1.y - (_arg1.y = y)); _local5 = ((_local3 * r11) + (_local4 * r21)); if (_local5 > ex){ _local5 = ex; } else { if (_local5 < -(ex)){ _local5 = -(ex); }; }; _arg1.x = (_arg1.x + (r11 * _local5)); _arg1.y = (_arg1.y + (r21 * _local5)); _local5 = ((_local3 * r12) + (_local4 * r22)); if (_local5 > ey){ _local5 = ey; } else { if (_local5 < -(ey)){ _local5 = -(ey); }; }; _arg1.x = (_arg1.x + (r12 * _local5)); _arg1.y = (_arg1.y + (r22 * _local5)); }; } override public function triangulate():void{ triangleList = new Tri2(v0, v1, v3); triangleList.next = new Tri2(v3, v1, v2); } override protected function setType():void{ type = ShapeTypes.BOX; } private function setup(_arg1:BoxData, _arg2:RigidBody):void{ var _local3:Number; var _local4:Number; var _local5:Number; var _local6:Number; var _local7:Array; var _local8:V2; _local3 = _arg2.cx; _local5 = _arg2.cy; mx = (_arg1.mx - _local3); my = (_arg1.my - _local5); _local4 = Math.sin(_arg1.mr); _local6 = Math.cos(_arg1.mr); _r11 = _local6; _r12 = -(_local4); _r21 = _local4; _r22 = _local6; _mr = _arg1.mr; ex = (_arg1.width * 0.5); ey = (_arg1.height * 0.5); xmin = -(ex); xmax = ex; xmin = -(ey); ymax = ey; radiusSq = ((ex * ex) + (ey * ey)); radius = Math.sqrt(radiusSq); vertexCount = 4; _local7 = new Array(vertexCount, true); _local8 = (_local7[0] = new V2()); _local8.x = ((mx + (_r11 * ex)) + (_r12 * ey)); _local8.y = ((my + (_r21 * ex)) + (_r22 * ey)); _local8 = (_local7[1] = new V2()); _local8.x = ((mx + (_r11 * -(ex))) + (_r12 * ey)); _local8.y = ((my + (_r21 * -(ex))) + (_r22 * ey)); _local8 = (_local7[2] = new V2()); _local8.x = ((mx + (_r11 * -(ex))) + (_r12 * -(ey))); _local8.y = ((my + (_r21 * -(ex))) + (_r22 * -(ey))); _local8 = (_local7[3] = new V2()); _local8.x = ((mx + (_r11 * ex)) + (_r12 * -(ey))); _local8.y = ((my + (_r21 * ex)) + (_r22 * -(ey))); initPoly(_local7, vertexCount, true, mx, my); _local8 = worldVertexChain; v0 = _local8; _local8 = _local8.next; v1 = _local8; _local8 = _local8.next; v2 = _local8; _local8 = _local8.next; v3 = _local8; _local8 = worldNormalChain; n0 = _local8; _local8 = _local8.next; n1 = _local8; _local8 = _local8.next; n2 = _local8; _local8 = _local8.next; n3 = _local8; var _local9:ConvexBSPNode = new ConvexBSPNode(); _local9.N = n0; _local9.I = 0; _local9.L = new ConvexBSPNode(); _local9.L.N = n3; _local9.L.I = 3; _local9.L.L = new ConvexBSPNode(); _local9.L.L.V = v3; _local9.L.L.I = 3; _local9.L.R = new ConvexBSPNode(); _local9.L.R.V = v0; _local9.L.R.I = 0; _local9.R = new ConvexBSPNode(); _local9.R.N = n1; _local9.R.I = 1; _local9.R.L = new ConvexBSPNode(); _local9.R.L.V = v1; _local9.R.L.I = 1; _local9.R.R = new ConvexBSPNode(); _local9.R.R.V = v2; _local9.R.R.I = 2; BSPNode = _local9; update(); createProxy(); } override public function getShapeOffset(_arg1:Point):void{ _arg1.x = ((mx * _r11) + (my * _r12)); _arg1.y = ((mx * _r21) + (my * _r22)); } } }//package de.polygonal.motor2.collision.shapes
Section 148
//CircleShape (de.polygonal.motor2.collision.shapes.CircleShape) package de.polygonal.motor2.collision.shapes { import de.polygonal.motor2.dynamics.*; import flash.geom.*; import de.polygonal.motor2.collision.shapes.data.*; public class CircleShape extends ShapeSkeleton { public function CircleShape(_arg1:CircleData, _arg2:RigidBody){ super(_arg1, _arg2); setup(_arg1, _arg2); } override public function update():Boolean{ synced = false; x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my))); y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my))); xmin = (x - radius); ymin = (y - radius); xmax = (x + radius); ymax = (y + radius); return (super.update()); } override public function pointInside(_arg1:Point):Boolean{ return (((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))) <= radiusSq)); } private function setup(_arg1:CircleData, _arg2:RigidBody):void{ var _local3:Number = _arg2.cx; var _local4:Number = _arg2.cy; mx = (_arg1.mx - _local3); my = (_arg1.my - _local4); x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my))); y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my))); radius = _arg1.radius; radiusSq = (radius * radius); ex = radius; ey = radius; xmin = -(ex); xmax = ex; xmin = -(ey); ymax = ey; vertexCount = 0; update(); createProxy(); } override protected function setType():void{ type = ShapeTypes.CIRCLE; } override public function closestPoint(_arg1:Point, _arg2:Point=null):void{ var _local3:Number = (_arg1.x - x); var _local4:Number = (_arg1.y - y); var _local5:Number = Math.sqrt(((_local3 * _local3) + (_local4 * _local4))); if (_local5 > 1E-6){ if (_arg2){ _arg2.x = (x + ((_local3 / _local5) * radius)); _arg2.y = (y + ((_local4 / _local5) * radius)); } else { _arg1.x = (x + ((_local3 / _local5) * radius)); _arg1.y = (y + ((_local4 / _local5) * radius)); }; } else { if (_arg2){ _arg2.x = x; _arg2.y = y; } else { _arg1.x = x; _arg1.y = y; }; }; } } }//package de.polygonal.motor2.collision.shapes
Section 149
//LineShape (de.polygonal.motor2.collision.shapes.LineShape) package de.polygonal.motor2.collision.shapes { import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.collision.shapes.data.*; public class LineShape extends ShapeSkeleton { public var infinite:Boolean; public var doubleSided:Boolean; public function LineShape(_arg1:LineData, _arg2:RigidBody){ super(_arg1, _arg2); setup(_arg1, _arg2); } private function clip(_arg1:V2, _arg2:V2):Boolean{ var _local7:Number; var _local8:Number; var _local9:Number; var _local3:V2 = worldVertexChain.edge.d; var _local4:AABB2 = body.world.getWorldBounds(); var _local5:Number = -2147483647; var _local6:Number = 2147483647; if (((_local3.x < 0)) ? -(_local3.x) : _local3.x < 1E-6){ if (x < _local4.xmin){ return (false); }; if (x > _local4.xmax){ return (false); }; } else { _local7 = ((_local4.xmin - x) / _local3.x); _local8 = ((_local4.xmax - x) / _local3.x); if (_local7 > _local8){ _local9 = _local7; _local7 = _local8; _local8 = _local9; }; if (_local7 > _local5){ _local5 = _local7; }; if (_local8 < _local6){ _local6 = _local8; }; if (_local5 > _local6){ return (false); }; }; if (((_local3.y < 0)) ? -(_local3.y) : _local3.y < 1E-6){ if (y < _local4.ymin){ return (false); }; if (y > _local4.ymax){ return (false); }; } else { _local7 = ((_local4.ymin - y) / _local3.y); _local8 = ((_local4.ymax - y) / _local3.y); if (_local7 > _local8){ _local9 = _local7; _local7 = _local8; _local8 = _local9; }; if (_local7 > _local5){ _local5 = _local7; }; if (_local8 < _local6){ _local6 = _local8; }; if (_local5 > _local6){ return (false); }; }; _arg1.x = (x + (_local3.x * _local5)); _arg1.y = (y + (_local3.y * _local5)); _arg2.x = (x + (_local3.x * _local6)); _arg2.y = (y + (_local3.y * _local6)); return (true); } override public function toWorldSpace():void{ var _local1:V2 = worldVertexChain; var _local2:V2 = modelVertexChain; var _local3:V2 = worldNormalChain; var _local4:V2 = modelNormalChain; var _local5:Number = body.x; var _local6:Number = body.y; _local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5); _local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6); _local3.x = ((r11 * _local4.x) + (r12 * _local4.y)); _local3.y = ((r21 * _local4.x) + (r22 * _local4.y)); _local1 = _local1.next; _local3 = _local3.next; _local2 = _local2.next; _local4 = _local4.next; _local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5); _local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6); _local3.x = ((r11 * _local4.x) + (r12 * _local4.y)); _local3.y = ((r21 * _local4.x) + (r22 * _local4.y)); } override public function update():Boolean{ var _local1:V2; var _local2:V2; var _local3:Number; var _local4:Number; synced = false; x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my))); y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my))); if (infinite){ _local1 = new V2(); _local2 = new V2(); if (clip(_local1, _local2)){ if (_local1.x < _local2.x){ xmin = _local1.x; xmax = _local2.x; } else { xmin = _local2.x; xmax = _local1.x; }; if (_local1.y < _local2.y){ ymin = _local1.y; ymax = _local2.y; } else { ymin = _local2.y; ymax = _local1.y; }; if ((xmax - xmin) < Constants.k_minLineAABBThickness){ _local3 = (xmax - xmin); xmin = (xmin - ((Constants.k_minLineAABBThickness * 0.5) - _local3)); xmax = (xmax + ((Constants.k_minLineAABBThickness * 0.5) - _local3)); }; if ((ymax - ymin) < Constants.k_minLineAABBThickness){ _local4 = (ymax - ymin); ymin = (ymin - ((Constants.k_minLineAABBThickness * 0.5) - _local4)); ymax = (ymax + ((Constants.k_minLineAABBThickness * 0.5) - _local4)); }; xmin = int((xmin + 0.5)); ymin = int((ymin + 0.5)); xmax = int(xmax); ymax = int(ymax); } else { xmin = (body.world.getWorldBounds().xmin - 1); }; } else { xmin = (x - ex); ymin = (y - ey); xmax = (x + ex); ymax = (y + ey); }; return (super.update()); } override protected function setType():void{ type = ShapeTypes.LINE; } private function setup(_arg1:LineData, _arg2:RigidBody):void{ var _local3:Number; var _local4:Number; var _local5:Number; var _local6:Number; var _local7:Array; var _local8:V2; infinite = _arg1.infinite; doubleSided = _arg1.doubleSided; _local3 = _arg2.cx; _local5 = _arg2.cy; mx = (_arg1.mx - _local3); my = (_arg1.my - _local5); x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my))); y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my))); _local4 = (_arg1.b.x - _arg1.a.x); _local6 = (_arg1.b.y - _arg1.a.y); var _local9:Number = Math.sqrt(((_local4 * _local4) + (_local6 * _local6))); vertexCount = 2; _local7 = new Array(vertexCount); _local8 = (_local7[0] = new V2()); _local8.x = ((mx + (r11 * _arg1.a.x)) + (r12 * _arg1.a.y)); _local8.y = ((my + (r21 * _arg1.a.x)) + (r22 * _arg1.a.y)); _local8 = (_local7[1] = new V2()); _local8.x = ((mx + (r11 * _arg1.b.x)) + (r12 * _arg1.b.y)); _local8.y = ((my + (r21 * _arg1.b.x)) + (r22 * _arg1.b.y)); initPoly(_local7, vertexCount, true); radius = (_local9 / 2); radiusSq = (radius * radius); toWorldSpace(); if (!infinite){ _local8 = worldVertexChain; xmin = Math.min(_local8.x, _local8.next.x); xmax = Math.max(_local8.x, _local8.next.x); ymin = Math.min(_local8.y, _local8.next.y); ymax = Math.max(_local8.y, _local8.next.y); xmin = int((xmin + 0.5)); ymin = int((ymin + 0.5)); xmax = int(xmax); ymax = int(ymax); ex = ((xmax - xmin) / 2); ey = ((ymax - ymin) / 2); if ((ex * 2) < Constants.k_minLineAABBThickness){ ex = (ex + ((Constants.k_minLineAABBThickness * 0.5) - ex)); }; if (ey < Constants.k_minLineAABBThickness){ ey = (ey + ((Constants.k_minLineAABBThickness * 0.5) - ey)); }; } else { ex = NaN; ey = NaN; }; _local4 = (worldVertexChain.next.x - worldVertexChain.x); _local6 = (worldVertexChain.next.y - worldVertexChain.y); _local9 = Math.sqrt(((_local4 * _local4) + (_local6 * _local6))); _local4 = (_local4 / _local9); _local6 = (_local6 / _local9); d = ((worldNormalChain.x * worldVertexChain.x) + (worldNormalChain.y * worldVertexChain.y)); update(); createProxy(); } } }//package de.polygonal.motor2.collision.shapes
Section 150
//ShapeSkeleton (de.polygonal.motor2.collision.shapes.ShapeSkeleton) package de.polygonal.motor2.collision.shapes { import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.math.*; import flash.geom.*; import de.polygonal.motor2.collision.shapes.data.*; import de.polygonal.motor2.collision.nbody.*; public class ShapeSkeleton { public var maskBits:int; public var r12:Number; public var userData; public var broadPhase:BroadPhase; public var r11:Number; public var proxyId:int; public var worldNormalChain:V2; public var r21:Number; public var categoryBits:int; public var modelNormalChain:V2; public var r22:Number; public var type:int; public var ymin:Number; public var offsets:Array; public var ymax:Number; public var regularShape:Boolean; public var restitution:Number; public var d:Number; public var x:Number; public var y:Number; public var synced:Boolean;// = false public var v1:V2; public var v2:V2; public var v3:V2; public var v0:V2; public var n0:V2; public var n1:V2; public var n2:V2; public var n3:V2; public var worldVertexChain:V2; public var area:Number; public var radiusSq:Number; public var radius:Number; public var groupIndex:int; public var modelVertexChain:V2; public var body:RigidBody; public var mx:Number; public var my:Number; public var ex:Number; public var ey:Number; public var BSPNode:ConvexBSPNode; public var triangleList:Tri2; public var vertexCount:int; public var xmin:Number; public var xmax:Number; public var next:ShapeSkeleton; public var friction:Number; public function ShapeSkeleton(_arg1:ShapeData, _arg2:RigidBody){ friction = _arg1.friction; restitution = _arg1.restitution; area = _arg1.area; body = _arg2; groupIndex = _arg1.groupIndex; categoryBits = _arg1.categoryBits; maskBits = _arg1.maskBits; setType(); broadPhase = body.world.getBroadPhase(); proxyId = Proxy.NULL_PROXY; } public function refreshProxy():void{ if (proxyId != Proxy.NULL_PROXY){ broadPhase.destroyProxy(proxyId); createProxy(); }; } public function getShapeOffset(_arg1:Point):void{ _arg1.x = mx; _arg1.y = my; } public function toWorldSpace():void{ } public function deconstruct():void{ BSPNode = null; modelVertexChain = (modelNormalChain = (worldVertexChain = (worldNormalChain = null))); offsets = null; triangleList = null; if (proxyId != Proxy.NULL_PROXY){ broadPhase.destroyProxy(proxyId); proxyId = Proxy.NULL_PROXY; }; broadPhase = null; } public function extractEdgeList(_arg1:V2):Array{ var _local2:V2 = _arg1; var _local3:Array = new Array(vertexCount, true); var _local4:int; while (_local4 < vertexCount) { _local3[_local4] = _local2.edge.d; _local2 = _local2.next; _local4++; }; return (_local3); } public function closestPoint(_arg1:Point, _arg2:Point=null):void{ } protected function setType():void{ type = ShapeTypes.UNKNOWN; } public function pointInside(_arg1:Point):Boolean{ return (false); } public function update():Boolean{ if (proxyId == Proxy.NULL_PROXY){ return (false); }; if (broadPhase.insideBounds(xmin, ymin, xmax, ymax)){ broadPhase.moveProxy(proxyId); return (true); }; return (false); } protected function computeMinAreaRect(_arg1:V2, _arg2:V2):Number{ var _local4:Number; var _local5:Number; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:Number; var _local24:Number; var _local25:Number; var _local26:Number; var _local27:Number; var _local28:Number; var _local29:V2; var _local30:V2; var _local31:V2; var _local32:V2; var _local33:int; var _local34:Number; var _local3:Number = Number.MAX_VALUE; _local29 = modelVertexChain; _local30 = modelVertexChain.next; _local31 = modelVertexChain; _local33 = 0; while (_local33 < vertexCount) { _local17 = (_local30.x - _local29.x); _local20 = (_local30.y - _local29.y); _local28 = Math.sqrt(((_local17 * _local17) + (_local20 * _local20))); _local17 = (_local17 / _local28); _local20 = (_local20 / _local28); _local18 = -(_local20); _local21 = _local17; _local15 = ((_local31.x * _local17) + (_local31.y * _local20)); _local13 = _local15; _local16 = ((_local31.x * _local18) + (_local31.y * _local21)); _local14 = _local16; _local32 = modelVertexChain.next; while (true) { _local27 = ((_local32.x * _local17) + (_local32.y * _local20)); if (_local27 < _local13){ _local13 = _local27; } else { if (_local27 > _local15){ _local15 = _local27; }; }; _local27 = ((_local32.x * _local18) + (_local32.y * _local21)); if (_local27 < _local14){ _local14 = _local27; } else { if (_local27 > _local16){ _local16 = _local27; }; }; if (_local32.isTail){ break; }; _local32 = _local32.next; }; _local4 = ((_local15 - _local13) * (_local16 - _local14)); if (_local4 < _local3){ _local3 = _local4; _local5 = (_local17 * _local13); _local6 = (_local20 * _local13); _local7 = (_local17 * _local15); _local8 = (_local20 * _local15); _local9 = (_local18 * _local14); _local10 = (_local21 * _local14); _local11 = (_local18 * _local16); _local12 = (_local21 * _local16); }; _local29 = _local30; _local30 = _local30.next; _local33++; }; _local19 = (_local7 - _local5); _local22 = (_local8 - _local6); _local25 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22))); _local23 = Math.atan2(_local22, _local19); _local19 = (_local11 - _local9); _local22 = (_local12 - _local10); _local26 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22))); _local24 = Math.atan2(_local22, _local19); if (((_local24 < 0)) ? -(_local24) : _local24 < ((_local23 < 0)) ? -(_local23) : _local23){ _local34 = _local24; _arg2.x = (_local26 / 2); _arg2.y = (_local25 / 2); } else { _local34 = _local23; _arg2.x = (_local25 / 2); _arg2.y = (_local26 / 2); }; _arg1.x = ((_local5 + _local9) + (((_local7 + _local11) - (_local5 + _local9)) / 2)); _arg1.y = ((_local6 + _local10) + (((_local8 + _local12) - (_local6 + _local10)) / 2)); return (_local34); } public function triangulate():void{ } protected function createProxy():void{ if (((broadPhase) && (broadPhase.insideBounds(xmin, ymin, xmax, ymax)))){ proxyId = broadPhase.createProxy(this); } else { proxyId = Proxy.NULL_PROXY; body.freeze(); }; } protected function initPoly(_arg1:Array, _arg2:int, _arg3:Boolean, _arg4:Number=0, _arg5:Number=0):void{ var _local6:int; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:V2; var _local13:V2; var _local14:V2; var _local15:V2; var _local16:V2; var _local17:V2; var _local18:V2; var _local19:E2; var _local21:Number; var _local22:Number; var _local23:Number; regularShape = _arg3; _local15 = _arg1[0]; modelVertexChain = _local15; _local16 = new V2(); worldVertexChain = _local16; _local15.index = 0; _local16.index = 0; _local15.isHead = true; _local16.isHead = true; _local17 = new V2(); modelNormalChain = _local17; _local18 = new V2(); worldNormalChain = _local18; _local17.index = 0; _local18.index = 0; _local17.isHead = true; _local18.isHead = true; _local6 = 1; while (_local6 < _arg2) { _local12 = _arg1[_local6]; _local13 = _local15; _local14 = _local12; _local14.index = _local6; _local13.next = _local14; _local14.prev = _local13; _local15 = _local15.next; _local13 = _local16; _local14 = new V2(); _local14.index = _local6; _local13.next = _local14; _local14.prev = _local13; _local16 = _local16.next; _local13 = _local17; _local14 = new V2(); _local14.index = _local6; _local13.next = _local14; _local14.prev = _local13; _local17 = _local17.next; _local13 = _local18; _local14 = new V2(); _local14.index = _local6; _local13.next = _local14; _local14.prev = _local13; _local18 = _local18.next; _local6++; }; _local15.isTail = true; _local15.next = modelVertexChain; modelVertexChain.prev = _local15; _local16.isTail = true; _local16.next = worldVertexChain; worldVertexChain.prev = _local16; _local17.isTail = true; _local17.next = modelNormalChain; modelNormalChain.prev = _local17; _local18.isTail = true; _local18.next = worldNormalChain; worldNormalChain.prev = _local18; var _local20:Array = new Array(_arg2, true); offsets = new Array(_arg2, true); _local18 = worldNormalChain; _local16 = worldVertexChain; _local17 = modelNormalChain; _local13 = modelVertexChain; _local14 = _local13.next; _local6 = 0; while (_local6 < _arg2) { _local7 = (_local14.x - _local13.x); _local8 = (_local14.y - _local13.y); _local11 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8))); _local7 = (_local7 / _local11); _local8 = (_local8 / _local11); _local20[_local6] = new V2(_local7, _local8); _local9 = _local8; _local10 = -(_local7); _local17.x = _local9; _local17.y = _local10; _local17 = _local17.next; _local21 = ((body.cx + _local13.x) + ((_local14.x - _local13.x) * 0.5)); _local22 = ((body.cy + _local13.y) + ((_local14.y - _local13.y) * 0.5)); _local23 = (((_local21 - _arg4) * _local9) + ((_local22 - _arg5) * _local10)); if (!_arg3){ offsets[_local6] = new V2((_local21 + (-(_local9) * _local23)), (_local22 + (-(_local10) * _local23))); }; _local19 = new E2(); _local19.v = _local13; _local19.w = _local13.next; _local19.n = _local17; _local19.d = _local20[_local6]; _local19.mag = _local11; _local13.edge = _local19; _local13 = _local14; _local14 = _local13.next; _local19 = new E2(); _local19.v = _local16; _local19.w = _local16.next; _local19.n = _local18; _local19.d = _local20[_local6]; _local19.mag = _local11; _local16.edge = _local19; _local16 = _local16.next; _local18 = _local18.next; _local6++; }; _local12 = modelVertexChain; _local6 = 0; while (_local6 < _arg2) { _local12.edge.next = _local12.next.edge; _local12.edge.prev = _local12.prev.edge; _local12 = _local12.next; _local6++; }; _local12 = worldVertexChain; _local6 = 0; while (_local6 < _arg2) { _local12.edge.next = _local12.next.edge; _local12.edge.prev = _local12.prev.edge; _local12 = _local12.next; _local6++; }; } } }//package de.polygonal.motor2.collision.shapes
Section 151
//ShapeTypes (de.polygonal.motor2.collision.shapes.ShapeTypes) package de.polygonal.motor2.collision.shapes { public class ShapeTypes { public static const UNKNOWN:int = 0; public static const BOX:int = 2; public static const POLY:int = 3; public static const CIRCLE:int = 1; public static const SHAPE_COUNT:int = 5; public static const LINE:int = 4; public static function getName(_arg1:int):String{ switch (_arg1){ case 1: return ("CIRCLE"); case 2: return ("BOX"); case 3: return ("POLY"); case 4: return ("LINE"); }; return ("UNKNOWN"); } } }//package de.polygonal.motor2.collision.shapes
Section 152
//BoxCircleContact (de.polygonal.motor2.dynamics.contact.generator.BoxCircleContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.collision.pairwise.*; public class BoxCircleContact extends ConvexCircleContact { private static const COLLIDE_BOX_CIRCLE:CollideBoxCircle = new CollideBoxCircle(); public function BoxCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); } override protected function getCollider():Collider{ return (COLLIDE_BOX_CIRCLE); } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 153
//BoxContact (de.polygonal.motor2.dynamics.contact.generator.BoxContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.collision.pairwise.*; public class BoxContact extends ConvexContact { public var sepAxisId:int; private static const COLLIDE_BOX:CollideBox = new CollideBox(); public function BoxContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); } override protected function getCollider():Collider{ return (COLLIDE_BOX); } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 154
//BoxLineContact (de.polygonal.motor2.dynamics.contact.generator.BoxLineContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.collision.pairwise.*; public class BoxLineContact extends ConvexContact { public var sid:int;// = -1 private static const COLLIDE_BOX_LINE_DS:CollideBoxLineDoubleSided = new CollideBoxLineDoubleSided(); private static const COLLIDE_BOX_LINE_SS:CollideBoxLineSingleSided = new CollideBoxLineSingleSided(); private static const COLLIDE_BOX_PLANE_DS:CollideBoxPlaneDoubleSided = new CollideBoxPlaneDoubleSided(); private static const COLLIDE_BOX_PLANE_SS:CollideBoxPlaneSingleSided = new CollideBoxPlaneSingleSided(); public function BoxLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); } override protected function getCollider():Collider{ var _local1:LineShape = LineShape(shape2); if (_local1.infinite){ if (_local1.doubleSided){ return (COLLIDE_BOX_PLANE_DS); }; return (COLLIDE_BOX_PLANE_SS); }; if (_local1.doubleSided){ return (COLLIDE_BOX_LINE_DS); }; return (COLLIDE_BOX_LINE_SS); } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 155
//CircleContact (de.polygonal.motor2.dynamics.contact.generator.CircleContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.collision.pairwise.*; import de.polygonal.motor2.dynamics.contact.*; public class CircleContact extends Contact { public var manifold:Manifold; private static const COLLIDE_CIRCLE:CollideCircle = new CollideCircle(); public function CircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); manifold = (manifolds[0] = new Manifold()); manifold.c0.Pn = 0; manifold.c0.Pt = 0; } override public function evaluate():void{ _collider.collide(manifold, shape1, shape2, null); manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0; } override protected function getCollider():Collider{ return (COLLIDE_CIRCLE); } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 156
//CircleLineContact (de.polygonal.motor2.dynamics.contact.generator.CircleLineContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.*; import de.polygonal.motor2.collision.pairwise.*; import de.polygonal.motor2.dynamics.contact.*; public class CircleLineContact extends Contact { private var _m1Cp1:ContactPoint; private var _Pt0:Number; public var manifold:Manifold; private var _Pn0:Number; private var _id0:uint; private static const COLLIDE_CIRCLE_PLANE_DS:CollideCirclePlaneDoubleSided = new CollideCirclePlaneDoubleSided(); private static const COLLIDE_CIRCLE_PLANE_SS:CollideCirclePlaneSingleSided = new CollideCirclePlaneSingleSided(); private static const COLLIDE_CIRCLE_LINE_DS:CollideCircleLineDoubleSided = new CollideCircleLineDoubleSided(); private static const COLLIDE_CIRCLE_LINE_SS:CollideCircleLineSingleSided = new CollideCircleLineSingleSided(); public function CircleLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); manifold = (manifolds[0] = new Manifold()); _m1Cp1 = manifold.c0; manifold.c0.Pn = 0; manifold.c0.Pt = 0; } override protected function getCollider():Collider{ var _local1:LineShape = LineShape(shape2); if (_local1.infinite){ if (_local1.doubleSided){ return (COLLIDE_CIRCLE_PLANE_DS); }; return (COLLIDE_CIRCLE_PLANE_SS); }; if (_local1.doubleSided){ return (COLLIDE_CIRCLE_LINE_DS); }; return (COLLIDE_CIRCLE_LINE_SS); } override public function evaluate():void{ var _local1:int; var _local2:int; if (World.doWarmStarting){ _m1Cp1.matched = false; _local1 = manifold.pointCount; if (_local1 > 0){ _id0 = _m1Cp1.id.key; _Pn0 = _m1Cp1.Pn; _Pt0 = _m1Cp1.Pt; }; _collider.collide(manifold, shape1, shape2, this); _local2 = manifold.pointCount; if (_local2 > 0){ manifoldCount = 1; } else { manifoldCount = 0; return; }; _m1Cp1.Pn = 0; _m1Cp1.Pt = 0; if ((((_local1 == 1)) && ((_local2 == 1)))){ if (_m1Cp1.id.key == _id0){ _m1Cp1.Pn = _Pn0; _m1Cp1.Pt = _Pt0; _m1Cp1.matched = true; }; }; } else { _collider.collide(manifold, shape1, shape2, this); manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0; }; } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 157
//ConvexCircleContact (de.polygonal.motor2.dynamics.contact.generator.ConvexCircleContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.dynamics.contact.*; public class ConvexCircleContact extends Contact { private var _m1Cp1:ContactPoint; public var d:V2; private var _Pt0:Number; public var manifold:Manifold; private var _Pn0:Number; private var _id0:uint; public var p:V2; public function ConvexCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); manifold = (manifolds[0] = new Manifold()); _m1Cp1 = manifold.c0; p = _arg1.worldVertexChain; d = _arg1.worldNormalChain; } override public function evaluate():void{ var _local1:int; var _local2:int; if (!shape1.synced){ shape1.toWorldSpace(); }; if (World.doWarmStarting){ _m1Cp1.matched = false; _local1 = manifold.pointCount; if (_local1 > 0){ _id0 = _m1Cp1.id.key; _Pn0 = _m1Cp1.Pn; _Pt0 = _m1Cp1.Pt; }; _collider.collide(manifold, shape1, shape2, this); _local2 = manifold.pointCount; if (_local2 > 0){ manifoldCount = 1; } else { manifoldCount = 0; return; }; _m1Cp1.Pn = 0; _m1Cp1.Pt = 0; if ((((_local1 == 1)) && ((_local2 == 1)))){ if (_m1Cp1.id.key == _id0){ _m1Cp1.Pn = _Pn0; _m1Cp1.Pt = _Pt0; _m1Cp1.matched = true; }; }; } else { _collider.collide(manifold, shape1, shape2, this); if (manifold.pointCount > 0){ manifoldCount = 1; } else { manifoldCount = 0; return; }; }; } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 158
//ConvexContact (de.polygonal.motor2.dynamics.contact.generator.ConvexContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.*; import de.polygonal.motor2.dynamics.contact.*; public class ConvexContact extends Contact { private var _m1Cp1:ContactPoint; private var _Pn0_1:Number; private var _Pn0_2:Number; private var _Pt0_2:Number; private var _id0_1:uint; private var _m1Cp2:ContactPoint; public var manifold:Manifold; private var _id0_2:uint; private var _Pt0_1:Number; public function ConvexContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); manifold = (manifolds[0] = new Manifold()); _m1Cp1 = manifold.c0; _m1Cp2 = manifold.c1; } override public function evaluate():void{ var _local1:int; var _local2:int; var _local3:int; if (!shape1.synced){ shape1.toWorldSpace(); }; if (!shape2.synced){ shape2.toWorldSpace(); }; if (World.doWarmStarting){ _m1Cp1.matched = false; _m1Cp2.matched = false; _local1 = manifold.pointCount; if (_local1 > 0){ _id0_1 = _m1Cp1.id.key; _Pn0_1 = _m1Cp1.Pn; _Pt0_1 = _m1Cp1.Pt; if (_local1 > 1){ _id0_2 = _m1Cp2.id.key; _Pn0_2 = _m1Cp2.Pn; _Pt0_2 = _m1Cp2.Pt; }; }; _collider.collide(manifold, shape1, shape2, this); _local2 = manifold.pointCount; if (_local2 > 0){ manifoldCount = 1; } else { manifoldCount = 0; return; }; _m1Cp1.Pn = 0; _m1Cp1.Pt = 0; _m1Cp2.Pn = 0; _m1Cp2.Pt = 0; if (_local2 == 1){ if (_local1 == 1){ if (_m1Cp1.id.key == _id0_1){ _m1Cp1.Pn = _Pn0_1; _m1Cp1.Pt = _Pt0_1; _m1Cp1.matched = true; }; } else { if (_local1 == 2){ _local3 = _m1Cp1.id.key; if (_local3 == _id0_1){ _m1Cp1.Pn = _Pn0_1; _m1Cp1.Pt = _Pt0_1; _m1Cp1.matched = true; } else { if (_local3 == _id0_2){ }; }; _m1Cp1.Pn = _Pn0_2; _m1Cp1.Pt = _Pn0_2; _m1Cp1.matched = true; }; }; } else { if (_local2 == 2){ if (_local1 == 1){ if (_m1Cp1.id.key == _id0_1){ _m1Cp1.Pn = _Pn0_1; _m1Cp1.Pt = _Pt0_1; _m1Cp1.matched = true; } else { if (_m1Cp2.id.key == _id0_1){ _m1Cp2.Pn = _Pn0_1; _m1Cp2.Pt = _Pt0_1; _m1Cp2.matched = true; }; }; } else { if (_local1 == 2){ if (_m1Cp1.id.key == _id0_1){ _m1Cp1.Pn = _Pn0_1; _m1Cp1.Pt = _Pt0_1; _m1Cp1.matched = true; if (_m1Cp2.id.key == _id0_2){ _m1Cp2.Pn = _Pn0_2; _m1Cp2.Pt = _Pt0_2; _m1Cp2.matched = true; return; }; } else { if (_m1Cp1.id.key == _id0_2){ _m1Cp1.Pn = _Pn0_2; _m1Cp1.Pt = _Pt0_2; _m1Cp1.matched = true; if (_m1Cp2.id.key == _id0_1){ _m1Cp2.Pn = _Pn0_1; _m1Cp2.Pt = _Pt0_1; _m1Cp2.matched = true; return; }; }; }; if (_m1Cp2.id.key == _id0_1){ _m1Cp2.Pn = _Pn0_1; _m1Cp2.Pt = _Pt0_1; _m1Cp2.matched = true; } else { if (_m1Cp2.id.key == _id0_2){ _m1Cp2.Pn = _Pn0_2; _m1Cp2.Pt = _Pt0_2; _m1Cp2.matched = true; }; }; }; }; }; }; } else { _collider.collide(manifold, shape1, shape2, this); manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0; }; } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 159
//PolyCircleContact (de.polygonal.motor2.dynamics.contact.generator.PolyCircleContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.collision.pairwise.*; public class PolyCircleContact extends ConvexCircleContact { private static const COLLIDE_POLY_CIRCLE:CollidePolyCircle = new CollidePolyCircle(); public function PolyCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); } override protected function getCollider():Collider{ return (COLLIDE_POLY_CIRCLE); } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 160
//PolyContact (de.polygonal.motor2.dynamics.contact.generator.PolyContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.collision.pairwise.*; import flash.utils.*; public class PolyContact extends ConvexContact { public var p:V2; public var d:V2; public var hc:Dictionary; public var firstOut:Boolean; private static const COLLIDE_TRIANGLE_HC:CollideTriangleHC = new CollideTriangleHC(); private static const COLLIDE_POLY_CHC:CollidePolyCHC = new CollidePolyCHC(); private static const COLLIDE_POLY_BSP:CollidePolyBSP = new CollidePolyBSP(); public function PolyContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); firstOut = true; p = _arg1.worldVertexChain; d = _arg1.worldNormalChain; if ((_arg1.vertexCount + _arg2.vertexCount) > 10){ hc = new Dictionary(true); }; } override public function flush():void{ hc = null; } override protected function getCollider():Collider{ if ((shape1.vertexCount + shape2.vertexCount) > 10){ return (COLLIDE_POLY_CHC); }; if ((((shape1.vertexCount == 3)) && ((shape2.vertexCount == 3)))){ return (COLLIDE_TRIANGLE_HC); }; return (COLLIDE_POLY_BSP); } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 161
//PolyLineContact (de.polygonal.motor2.dynamics.contact.generator.PolyLineContact) package de.polygonal.motor2.dynamics.contact.generator { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.math.*; import de.polygonal.motor2.collision.pairwise.*; public class PolyLineContact extends ConvexContact { public var hint1:V2; public var hint2:V2; private static const COLLIDE_POLY_PLANE_DS_CHC:CollidePolyPlaneDoubleSidedCHC = new CollidePolyPlaneDoubleSidedCHC(); private static const COLLIDE_POLY_PLANE_DS_BSP:CollidePolyPlaneDoubleSidedBSP = new CollidePolyPlaneDoubleSidedBSP(); private static const COLLIDE_POLY_LINE_DS_CHC:CollidePolyLineDoubleSidedCHC = new CollidePolyLineDoubleSidedCHC(); private static const COLLIDE_POLY_PLANE_SS_CHC:CollidePolyPlaneSingleSidedCHC = new CollidePolyPlaneSingleSidedCHC(); private static const COLLIDE_POLY_PLANE_SS_BSP:CollidePolyPlaneSingleSidedBSP = new CollidePolyPlaneSingleSidedBSP(); private static const COLLIDE_POLY_LINE_DS_BSP:CollidePolyLineDoubleSidedBSP = new CollidePolyLineDoubleSidedBSP(); private static const COLLIDE_POLY_LINE_SS_CHC:CollidePolyLineSingleSidedCHC = new CollidePolyLineSingleSidedCHC(); private static const COLLIDE_POLY_LINE_SS_BSP:CollidePolyLineSingleSidedBSP = new CollidePolyLineSingleSidedBSP(); public function PolyLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ super(_arg1, _arg2); var _local3 = (_arg1.vertexCount > 10); if (_local3){ hint1 = _arg1.worldVertexChain; hint2 = hint1; }; } override protected function getCollider():Collider{ var _local1 = (shape1.vertexCount > 10); var _local2:LineShape = LineShape(shape2); if (_local2.infinite){ if (_local2.doubleSided){ if (_local1){ return (COLLIDE_POLY_PLANE_DS_CHC); }; return (COLLIDE_POLY_PLANE_DS_BSP); }; if (_local1){ return (COLLIDE_POLY_PLANE_SS_CHC); }; return (COLLIDE_POLY_PLANE_SS_BSP); }; if (_local2.doubleSided){ if (_local1){ return (COLLIDE_POLY_LINE_DS_CHC); }; return (COLLIDE_POLY_LINE_DS_BSP); }; if (_local1){ return (COLLIDE_POLY_LINE_SS_CHC); }; return (COLLIDE_POLY_LINE_SS_BSP); } } }//package de.polygonal.motor2.dynamics.contact.generator
Section 162
//SIContactSolver (de.polygonal.motor2.dynamics.contact.solver.SIContactSolver) package de.polygonal.motor2.dynamics.contact.solver { import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.*; import de.polygonal.motor2.dynamics.contact.*; public class SIContactSolver { private var _maxLinCorrection:Number; private var _linSlop:Number; private var _velThreshold:Number; public var contactCount:int; public var contacts:Array; public function SIContactSolver():void{ _linSlop = Constants.k_linSlop; _velThreshold = Constants.k_velocityThreshold; _maxLinCorrection = Constants.k_maxLinCorrection; } public function solvePosConstraints(_arg1:Number):Boolean{ var _local2:int; var _local3:int; var _local4:int; var _local5:Contact; var _local6:Manifold; var _local7:ContactPoint; var _local8:RigidBody; var _local9:RigidBody; var _local10: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 _local11:Number = 0; _local2 = 0; while (_local2 < contactCount) { _local5 = contacts[_local2]; _local8 = _local5.body1; _local9 = _local5.body2; _local3 = 0; while (_local3 < _local5.manifoldCount) { _local6 = _local5.manifolds[_local3]; _local12 = _local6.nx; _local17 = _local6.ny; _local4 = 0; while (_local4 < _local6.pointCount) { _local7 = _local6.points[_local4]; _local15 = ((_local8.r11 * _local7.l_r1x) + (_local8.r12 * _local7.l_r1y)); _local20 = ((_local8.r21 * _local7.l_r1x) + (_local8.r22 * _local7.l_r1y)); _local16 = ((_local9.r11 * _local7.l_r2x) + (_local9.r12 * _local7.l_r2y)); _local21 = ((_local9.r21 * _local7.l_r2x) + (_local9.r22 * _local7.l_r2y)); _local14 = ((_local9.x + _local16) - (_local8.x + _local15)); _local19 = ((_local9.y + _local21) - (_local8.y + _local20)); _local10 = (((_local14 * _local12) + (_local19 * _local17)) + _local7.sep); _local11 = ((_local11 < _local10)) ? _local11 : _local10; _local24 = (_local10 + _linSlop); _local25 = -(_maxLinCorrection); _local26 = 0; _local27 = (_arg1 * ((_local24)<_local25) ? _local25 : ((_local24)>_local26) ? _local26 : _local24); _local28 = (-(_local7.nMass) * _local27); _local29 = _local7.Pp; _local7.Pp = (_local29 + _local28); if (_local7.Pp < 0){ _local7.Pp = 0; }; _local28 = (_local7.Pp - _local29); _local13 = (_local28 * _local12); _local18 = (_local28 * _local17); _local8.x = (_local8.x - (_local8.invMass * _local13)); _local8.y = (_local8.y - (_local8.invMass * _local18)); _local8.r = (_local8.r - (_local8.invI * ((_local15 * _local18) - (_local20 * _local13)))); _local22 = Math.cos(_local8.r); _local23 = Math.sin(_local8.r); _local8.r11 = _local22; _local8.r12 = -(_local23); _local8.r21 = _local23; _local8.r22 = _local22; _local9.x = (_local9.x + (_local9.invMass * _local13)); _local9.y = (_local9.y + (_local9.invMass * _local18)); _local9.r = (_local9.r + (_local9.invI * ((_local16 * _local18) - (_local21 * _local13)))); _local22 = Math.cos(_local9.r); _local23 = Math.sin(_local9.r); _local9.r11 = _local22; _local9.r12 = -(_local23); _local9.r21 = _local23; _local9.r22 = _local22; _local4++; }; _local3++; }; _local2++; }; return ((_local11 >= -(_linSlop))); } public function setContacts(_arg1:Array, _arg2:int):void{ this.contacts = _arg1; this.contactCount = _arg2; } public function preStep():void{ var _local1:int; var _local2:int; var _local3:int; var _local4:RigidBody; var _local5:RigidBody; 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:Contact; var _local18:Manifold; var _local19:ContactPoint; _local1 = 0; while (_local1 < contactCount) { _local17 = contacts[_local1]; _local4 = (contacts[_local1].body1 = _local17.shape1.body); _local5 = (_local17.body2 = _local17.shape2.body); _local2 = 0; while (_local2 < _local17.manifoldCount) { _local18 = _local17.manifolds[_local2]; _local6 = _local18.nx; _local10 = _local18.ny; _local3 = 0; while (_local3 < _local18.pointCount) { _local19 = _local18.points[_local3]; _local8 = (_local19.x - _local4.x); _local12 = (_local19.y - _local4.y); _local9 = (_local19.x - _local5.x); _local13 = (_local19.y - _local5.y); if (World.doPositionCorrection){ _local19.l_r1x = ((_local4.r11 * _local8) + (_local4.r21 * _local12)); _local19.l_r1y = ((_local4.r12 * _local8) + (_local4.r22 * _local12)); _local19.l_r2x = ((_local5.r11 * _local9) + (_local5.r21 * _local13)); _local19.l_r2y = ((_local5.r12 * _local9) + (_local5.r22 * _local13)); }; _local19.w_r1x = _local8; _local19.w_r1y = _local12; _local19.w_r2x = _local9; _local19.w_r2y = _local13; _local14 = ((_local8 * _local10) - (_local12 * _local6)); _local15 = ((_local9 * _local10) - (_local13 * _local6)); _local19.nMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15))); _local14 = ((_local8 * -(_local6)) - (_local12 * _local10)); _local15 = ((_local9 * -(_local6)) - (_local13 * _local10)); _local19.tMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15))); _local16 = ((_local6 * (((_local5.vx - (_local5.w * _local13)) - _local4.vx) + (_local4.w * _local12))) + (_local10 * (((_local5.vy + (_local5.w * _local9)) - _local4.vy) - (_local4.w * _local8)))); _local19.velBias = ((_local16 < -(_velThreshold))) ? (-(_local17.restitution) * _local16) : 0; if (World.doWarmStarting){ _local7 = ((_local19.Pn * _local6) + (_local19.Pt * _local10)); _local11 = ((_local19.Pn * _local10) + (_local19.Pt * -(_local6))); _local4.vx = (_local4.vx - (_local4.invMass * _local7)); _local4.vy = (_local4.vy - (_local4.invMass * _local11)); _local4.w = (_local4.w - (_local4.invI * ((_local8 * _local11) - (_local12 * _local7)))); _local5.vx = (_local5.vx + (_local5.invMass * _local7)); _local5.vy = (_local5.vy + (_local5.invMass * _local11)); _local5.w = (_local5.w + (_local5.invI * ((_local9 * _local11) - (_local13 * _local7)))); } else { _local19.Pn = (_local19.Pt = 0); }; _local19.Pp = 0; _local3++; }; _local2++; }; _local1++; }; } public function solveVelConstraints():void{ var _local1:int; var _local2:int; var _local3:int; var _local4:Contact; var _local5:Manifold; var _local6:ContactPoint; var _local7:RigidBody; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:RigidBody; 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; _local1 = 0; while (_local1 < contactCount) { _local4 = contacts[_local1]; _local7 = _local4.body1; _local13 = _local4.body2; _local8 = _local7.invMass; _local9 = _local7.invI; _local14 = _local13.invMass; _local15 = _local13.invI; _local10 = _local7.vx; _local11 = _local7.vy; _local12 = _local7.w; _local16 = _local13.vx; _local17 = _local13.vy; _local18 = _local13.w; _local2 = 0; while (_local2 < _local4.manifoldCount) { _local5 = _local4.manifolds[_local2]; _local19 = _local5.nx; _local22 = _local5.ny; _local3 = 0; while (_local3 < _local5.pointCount) { _local6 = _local5.points[_local3]; _local25 = _local6.w_r1x; _local26 = _local6.w_r1y; _local27 = _local6.w_r2x; _local28 = _local6.w_r2y; _local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26)); _local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25)); _local30 = (-(_local6.nMass) * (((_local21 * _local19) + (_local24 * _local22)) - _local6.velBias)); _local29 = (_local6.Pn + _local30); if (_local29 < 0){ _local29 = 0; }; _local30 = (_local29 - _local6.Pn); _local20 = (_local30 * _local19); _local23 = (_local30 * _local22); _local10 = (_local10 - (_local8 * _local20)); _local11 = (_local11 - (_local8 * _local23)); _local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20)))); _local16 = (_local16 + (_local14 * _local20)); _local17 = (_local17 + (_local14 * _local23)); _local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20)))); _local6.Pn = _local29; _local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26)); _local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25)); _local30 = (((_local6.tMass * -(_local22)) * _local21) + (_local19 * _local24)); _local31 = (_local4.friction * _local6.Pn); _local29 = (_local6.Pt + _local30); _local29 = ((_local29)<-(_local31)) ? -(_local31) : ((_local29)>_local31) ? _local31 : _local29; _local30 = (_local29 - _local6.Pt); _local20 = (_local30 * _local22); _local23 = (_local30 * -(_local19)); _local10 = (_local10 - (_local8 * _local20)); _local11 = (_local11 - (_local8 * _local23)); _local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20)))); _local16 = (_local16 + (_local14 * _local20)); _local17 = (_local17 + (_local14 * _local23)); _local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20)))); _local6.Pt = _local29; _local3++; }; _local2++; }; _local7.vx = _local10; _local7.vy = _local11; _local7.w = _local12; _local13.vx = _local16; _local13.vy = _local17; _local13.w = _local18; _local1++; }; } } }//package de.polygonal.motor2.dynamics.contact.solver
Section 163
//Contact (de.polygonal.motor2.dynamics.contact.Contact) package de.polygonal.motor2.dynamics.contact { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.collision.pairwise.*; public class Contact { public var next:Contact; public var body1:RigidBody; public var body2:RigidBody; protected var _collider:Collider; public var stateBits:int; public var manifoldCount:int; public var manifolds:Array; public var restitution:Number; public var node1:ContactNode; public var node2:ContactNode; public var shape2:ShapeSkeleton; public var prev:Contact; public var shape1:ShapeSkeleton; public var friction:Number; public var secondary:Boolean; public var disabled:Boolean; public static const k_bitIsland:int = 32; public function Contact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){ init(_arg1, _arg2); } public function flush():void{ } public function evaluate():void{ } protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{ shape1 = _arg1; shape2 = _arg2; manifoldCount = 0; manifolds = new Array(2, true); friction = Math.sqrt((_arg1.friction * _arg2.friction)); restitution = ((_arg1.restitution > _arg2.restitution)) ? _arg1.restitution : _arg2.restitution; _collider = getCollider(); node1 = new ContactNode(); node2 = new ContactNode(); } protected function getCollider():Collider{ return (null); } } }//package de.polygonal.motor2.dynamics.contact
Section 164
//ContactFactory (de.polygonal.motor2.dynamics.contact.ContactFactory) package de.polygonal.motor2.dynamics.contact { import de.polygonal.ds.*; import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.contact.generator.*; public class ContactFactory { private static var _contactMatrix:Array2; public function ContactFactory(){ initializeContactMatrix(); } private function initializeContactMatrix():void{ _contactMatrix = new Array2(ShapeTypes.SHAPE_COUNT, ShapeTypes.SHAPE_COUNT); _contactMatrix.fill(ContactRegister); registerContactHandler(BoxContact, ShapeTypes.BOX, ShapeTypes.BOX); registerContactHandler(PolyContact, ShapeTypes.BOX, ShapeTypes.POLY); registerContactHandler(BoxCircleContact, ShapeTypes.BOX, ShapeTypes.CIRCLE); registerContactHandler(BoxLineContact, ShapeTypes.BOX, ShapeTypes.LINE); registerContactHandler(PolyContact, ShapeTypes.POLY, ShapeTypes.POLY); registerContactHandler(PolyCircleContact, ShapeTypes.POLY, ShapeTypes.CIRCLE); registerContactHandler(PolyLineContact, ShapeTypes.POLY, ShapeTypes.LINE); registerContactHandler(CircleContact, ShapeTypes.CIRCLE, ShapeTypes.CIRCLE); registerContactHandler(CircleLineContact, ShapeTypes.CIRCLE, ShapeTypes.LINE); } public function destroy(_arg1:Contact):void{ if (_arg1.manifoldCount > 0){ _arg1.shape1.body.wakeUp(); _arg1.shape2.body.wakeUp(); }; _contactMatrix.get(_arg1.shape1.type, _arg1.shape2.type).deconstruct(_arg1); } public function create(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact{ var _local5:Contact; var _local6:int; var _local7:Manifold; var _local3:ContactRegister = _contactMatrix.get(_arg1.type, _arg2.type); var _local4:Class = _local3.constructor; if (_local4){ if (_local3.primary){ return (new _local4(_arg1, _arg2)); }; _local5 = new _local4(_arg2, _arg1); _local5.secondary = true; _local6 = 0; while (_local6 < _local5.manifoldCount) { _local7 = _local5.manifolds[_local6]; _local5.manifolds[_local6].nx = -(_local7.nx); _local7.ny = -(_local7.ny); _local6++; }; return (_local5); }; return (null); } private function registerContactHandler(_arg1:Class, _arg2:int, _arg3:int):void{ ContactRegister(_contactMatrix.get(_arg2, _arg3)).constructor = _arg1; ContactRegister(_contactMatrix.get(_arg2, _arg3)).primary = true; if (_arg2 != _arg3){ ContactRegister(_contactMatrix.get(_arg3, _arg2)).constructor = _arg1; ContactRegister(_contactMatrix.get(_arg3, _arg2)).primary = false; }; } } }//package de.polygonal.motor2.dynamics.contact class ContactRegister { public var primary:Boolean; public var deconstruct:Function; public var constructor:Class; private function ContactRegister(){ } }
Section 165
//ContactFilter (de.polygonal.motor2.dynamics.contact.ContactFilter) package de.polygonal.motor2.dynamics.contact { import de.polygonal.motor2.collision.shapes.*; public class ContactFilter { public function shouldCollide(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Boolean{ if (_arg1.groupIndex == _arg2.groupIndex){ if (_arg1.groupIndex != 0){ return ((_arg1.groupIndex > 0)); }; }; return (((!(((_arg1.maskBits & _arg2.categoryBits) == 0))) && (!(((_arg1.categoryBits & _arg2.maskBits) == 0))))); } } }//package de.polygonal.motor2.dynamics.contact
Section 166
//ContactID (de.polygonal.motor2.dynamics.contact.ContactID) package de.polygonal.motor2.dynamics.contact { public class ContactID { public var flip:int; public var incVert:int; public var refFace:int; public var incEdge:int; public var key:uint; public static const NULL_FEATURE:int = 254; public function toString():String{ return (((((((((refFace + "|") + incEdge) + "|") + incVert) + "|") + flip) + " -> ") + key)); } public function bake():void{ key = ((((-(~(refFace)) << 24) | (-(~(incEdge)) << 16)) | (-(~(incVert)) << 8)) | -(~(flip))); } } }//package de.polygonal.motor2.dynamics.contact
Section 167
//ContactManager (de.polygonal.motor2.dynamics.contact.ContactManager) package de.polygonal.motor2.dynamics.contact { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.*; import de.polygonal.motor2.collision.nbody.*; public class ContactManager implements PairCallback { private var _contactFilter:ContactFilter; private var _callback:ContactCallback; private var _contactFactory:ContactFactory; public var statsContactCount:int; private var _world:World; private static const NULL_CONTACT:NullContact = new NullContact(); public function ContactManager(_arg1:World){ _world = _arg1; _contactFactory = new ContactFactory(); setCallback(new NullCallback()); } public function collide():void{ var _local2:RigidBody; var _local3:RigidBody; var _local4:int; var _local5:int; var _local6:ContactNode; var _local1:Contact = _world.contactList; while (_local1) { _local2 = _local1.shape1.body; _local3 = _local1.shape2.body; if (((_local2.stateBits & _local3.stateBits) & RigidBody.k_bitSleep)){ _local1 = _local1.next; } else { _local4 = _local1.manifoldCount; _local1.evaluate(); _local5 = _local1.manifoldCount; if ((((_local4 == 0)) && ((_local5 > 0)))){ _local6 = _local1.node1; _local6.contact = _local1; _local6.other = _local3; _local6.prev = null; _local6.next = _local2.contactList; if (_local6.next){ _local6.next.prev = _local6; }; _local2.contactList = _local6; _local6 = _local1.node2; _local6.contact = _local1; _local6.other = _local2; _local6.prev = null; _local6.next = _local3.contactList; if (_local6.next){ _local6.next.prev = _local6; }; _local3.contactList = _local6; } else { if ((((_local4 > 0)) && ((_local5 == 0)))){ _local6 = _local1.node1; if (_local6.next){ _local6.next.prev = _local6.prev; }; if (_local6.prev){ _local6.prev.next = _local6.next; }; if (_local6 == _local2.contactList){ _local2.contactList = _local6.next; }; _local6.next = (_local6.prev = null); _local6 = _local1.node2; if (_local6.next){ _local6.next.prev = _local6.prev; }; if (_local6.prev){ _local6.prev.next = _local6.next; }; if (_local6 == _local3.contactList){ _local3.contactList = _local6.next; }; _local6.next = (_local6.prev = null); }; }; _local1 = _local1.next; }; }; } public function setCallback(_arg1:ContactCallback):void{ _callback = _arg1; } private function destroyContact(_arg1:Contact):void{ var _local2:RigidBody; var _local3:RigidBody; var _local4:ContactNode; if (_world.contactCount == 0){ return; }; if (_arg1.prev){ _arg1.prev.next = _arg1.next; }; if (_arg1.next){ _arg1.next.prev = _arg1.prev; }; if (_arg1 == _world.contactList){ _world.contactList = _arg1.next; }; _arg1.flush(); if (_arg1.manifoldCount > 0){ _local2 = _arg1.shape1.body; _local2.stateBits = (_local2.stateBits & ~(RigidBody.k_bitSleep)); _local2.sleepTime = 0; _local3 = _arg1.shape2.body; _local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep)); _local3.sleepTime = 0; _local4 = _arg1.node1; if (_local4.next){ _local4.next.prev = _local4.prev; }; if (_local4.prev){ _local4.prev.next = _local4.next; }; if (_local4 == _local2.contactList){ _local2.contactList = _local4.next; }; _local4.next = (_local4.prev = null); _local4 = _arg1.node2; if (_local4.next){ _local4.next.prev = _local4.prev; }; if (_local4.prev){ _local4.prev.next = _local4.next; }; if (_local4 == _local3.contactList){ _local3.contactList = _local4.next; }; _local4.next = (_local4.prev = null); }; _world.contactCount--; } public function pairAdded(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact{ statsContactCount++; var _local3:RigidBody = _arg1.body; var _local4:RigidBody = _arg2.body; if (((_local3.stateBits & _local4.stateBits) & RigidBody.k_bitStatic)){ return (NULL_CONTACT); }; if (_local3 == _local4){ return (NULL_CONTACT); }; if (_local4.isConnected(_local3)){ return (NULL_CONTACT); }; if (!_contactFilter.shouldCollide(_arg1, _arg2)){ return (NULL_CONTACT); }; var _local5:Contact = _contactFactory.create(_arg1, _arg2); if (_local5 == null){ return (NULL_CONTACT); }; _local5.prev = null; _local5.next = _world.contactList; if (_world.contactList){ _world.contactList.prev = _local5; }; _world.contactList = _local5; _world.contactCount++; _callback.onContactAdded(_local5); return (_local5); } public function setFilter(_arg1:ContactFilter):void{ _contactFilter = _arg1; } public function pairRemoved(_arg1:Contact):void{ statsContactCount++; if ((((_arg1 == null)) || ((_arg1 == NULL_CONTACT)))){ return; }; _callback.onContactRemoved(_arg1); destroyContact(_arg1); } } }//package de.polygonal.motor2.dynamics.contact import de.polygonal.motor2.*; class NullCallback implements ContactCallback { private function NullCallback(){ } public function onContactRemoved(_arg1:Contact):void{ } public function onContactAdded(_arg1:Contact):void{ } }
Section 168
//ContactNode (de.polygonal.motor2.dynamics.contact.ContactNode) package de.polygonal.motor2.dynamics.contact { import de.polygonal.motor2.dynamics.*; public class ContactNode { public var other:RigidBody; public var prev:ContactNode; public var contact:Contact; public var next:ContactNode; public function ContactNode(){ init(); } private function init():void{ prev = (next = null); other = null; contact = null; } } }//package de.polygonal.motor2.dynamics.contact
Section 169
//ContactPoint (de.polygonal.motor2.dynamics.contact.ContactPoint) package de.polygonal.motor2.dynamics.contact { public class ContactPoint { public var nMass:Number; public var l_r1x:Number; public var l_r1y:Number; public var w_r1x:Number; public var w_r1y:Number; public var tMass:Number; public var id:ContactID; public var Pn:Number; public var Pp:Number; public var matched:Boolean;// = false public var sep:Number; public var l_r2y:Number; public var Pt:Number; public var w_r2y:Number; public var l_r2x:Number; public var w_r2x:Number; public var x:Number; public var y:Number; public var velBias:Number; public function ContactPoint():void{ init(); } public function init():void{ id = new ContactID(); x = (y = (sep = (velBias = (Pn = (Pt = (Pp = (nMass = (tMass = 0)))))))); } } }//package de.polygonal.motor2.dynamics.contact
Section 170
//Manifold (de.polygonal.motor2.dynamics.contact.Manifold) package de.polygonal.motor2.dynamics.contact { public class Manifold { public var points:Array; public var nx:Number; public var ny:Number; public var c0:ContactPoint; public var c1:ContactPoint; public var pointCount:int; public function Manifold(){ init(); } public function init():void{ c0 = new ContactPoint(); c1 = new ContactPoint(); points = new Array(2, true); points[0] = c0; points[1] = c1; pointCount = 0; } } }//package de.polygonal.motor2.dynamics.contact
Section 171
//NullContact (de.polygonal.motor2.dynamics.contact.NullContact) package de.polygonal.motor2.dynamics.contact { import de.polygonal.motor2.collision.shapes.*; public class NullContact extends Contact { public function NullContact(){ super(null, null); } override protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{ } override public function evaluate():void{ } } }//package de.polygonal.motor2.dynamics.contact
Section 172
//Buoyancy (de.polygonal.motor2.dynamics.forces.Buoyancy) package de.polygonal.motor2.dynamics.forces { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.math.*; public class Buoyancy extends ForceGenerator { public var planeNormal:V2; private var _cp0:V2; public var linDrag:Number; public var density:Number; private var _cp1:V2; public var angDrag:Number; public var planeOffset:Number; private var _clipTri0:ClipTriangle; private var _clipTri1:ClipTriangle; public var velocity:V2; public function Buoyancy(_arg1:Number, _arg2:V2, _arg3:Number, _arg4:Number=5, _arg5:Number=0.5, _arg6:V2=null){ _clipTri0 = new ClipTriangle(); _clipTri1 = new ClipTriangle(); _cp0 = new V2(); _cp1 = new V2(); super(); this.planeOffset = _arg1; this.planeNormal = _arg2; this.density = _arg3; this.linDrag = _arg4; this.angDrag = _arg5; this.velocity = (_arg6) ? _arg6 : new V2(); } private function clipTriangle(_arg1:Tri2, _arg2:Number, _arg3:ClipTriangle, _arg4:ClipTriangle):int{ var _local11:V2; var _local12:V2; var _local13:V2; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local5:int; var _local6:int; var _local7:V2; var _local8:V2; var _local9:V2; var _local10:V2; if (_arg1.a.y > _arg2){ _local6++; _local8 = _arg1.a; } else { _local5++; _local7 = _arg1.a; }; if (_arg1.b.y > _arg2){ _local6++; if (_local8){ _local10 = _arg1.b; } else { _local8 = _arg1.b; }; } else { _local5++; if (_local7){ _local9 = _arg1.b; } else { _local7 = _arg1.b; }; }; if (_arg1.c.y > _arg2){ _local6++; if (_local8){ _local10 = _arg1.c; } else { _local8 = _arg1.c; }; } else { _local5++; if (_local7){ _local9 = _arg1.c; } else { _local7 = _arg1.c; }; }; if (_local5 == 0){ _arg3.a = _arg1.a; _arg3.b = _arg1.b; _arg3.c = _arg1.c; return (1); }; if (_local6 == 0){ return (-1); }; if (_local5 == 1){ _local11 = _local7; _local12 = _local8; _local14 = (_local11.y - _arg2); _local15 = (_local12.y - _arg2); _local16 = (_local14 / (_local14 - _local15)); _cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x))); _cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y))); _local12 = _local10; _local15 = (_local12.y - _arg2); _local16 = (_local14 / (_local14 - _local15)); _cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x))); _cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y))); if (_cp0.x > _cp1.x){ _local13 = _cp0; _cp0 = _cp1; _cp1 = _local13; }; _local17 = (((_local8.x - _local11.x) * (_local10.y - _local11.y)) - ((_local8.y - _local11.y) * (_local10.x - _local11.x))); if (_local8.x > _cp1.x){ _arg3.a = _local10; _arg3.b = _cp1; _arg3.c = _local8; if (_local17 > 0){ _arg4.a = _local10; _arg4.b = _cp1; _arg4.c = _cp0; } else { _arg4.a = _local8; _arg4.b = _cp1; _arg4.c = _cp0; }; return (2); } else { if (_local10.x < _cp0.x){ _arg3.a = _local10; _arg3.b = _cp0; _arg3.c = _local8; if (_local17 > 0){ _arg4.a = _local8; _arg4.b = _cp1; _arg4.c = _cp0; } else { _arg4.a = _local10; _arg4.b = _cp1; _arg4.c = _cp0; }; return (2); } else { _arg3.a = _local8; _arg3.b = _local10; _arg3.c = _cp0; _arg4.a = _cp0; _arg4.b = _local10; _arg4.c = _cp1; return (2); }; }; } else { if (_local5 == 2){ _local11 = _local8; _local12 = _local7; _local14 = (_local11.y - _arg2); _local15 = (_local12.y - _arg2); _local16 = (_local14 / (_local14 - _local15)); _cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x))); _cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y))); _local12 = _local9; _local15 = (_local12.y - _arg2); _local16 = (_local14 / (_local14 - _local15)); _cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x))); _cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y))); if (_cp0.x > _cp1.x){ _local13 = _cp0; _cp0 = _cp1; _cp1 = _local13; }; _arg3.a = _cp1; _arg3.b = _cp0; _arg3.c = _local8; return (1); }; }; return (-1); } override public function evaluate(_arg1:RigidBody):void{ var _local8:int; var _local9:V2; var _local10:V2; var _local11:V2; var _local12:Number; var _local13:ShapeSkeleton; var _local14:Tri2; var _local21:Number; var _local22:Number; var _local23:Number; var _local24:Number; var _local2:Number = 0; var _local3:Number = 0; var _local4:Number = 2147483648; var _local5:Number = -2147483648; var _local6:Number = 0; var _local7:Number = 0; _local13 = _arg1.shapeList; while (_local13) { _local2 = (_local2 + _local13.area); if (_local13.ymax < planeOffset){ } else { if (_local13.ymin >= planeOffset){ _local12 = _local13.area; _local6 = (_local6 + (_local12 * _local13.x)); _local7 = (_local7 + (_local12 * _local13.y)); _local3 = (_local3 + _local12); if (_local13.xmin < _local4){ _local4 = _local13.xmin; }; if (_local13.xmax > _local5){ _local5 = _local13.xmax; }; } else { if (_local13.type == ShapeTypes.CIRCLE){ _local21 = _local13.radius; _local22 = (_local13.ymax - planeOffset); _local12 = (((_local21 * _local21) * Math.acos(((_local21 - _local22) / _local21))) - ((_local21 - _local22) * Math.sqrt((((2 * _local21) * _local22) - (_local22 * _local22))))); _local23 = ((2 * _local21) - _local22); _local24 = ((3 * (_local23 * _local23)) / (4 * ((3 * _local21) - _local22))); _local6 = (_local6 + (_local13.x * _local12)); _local7 = (_local7 + ((_local13.y + _local24) * _local12)); _local3 = (_local3 + _local12); if (_local13.xmin < _local4){ _local4 = _local13.xmin; }; if (_local13.xmax > _local5){ _local5 = _local13.xmax; }; } else { if (!_local13.synced){ _local13.toWorldSpace(); }; _local14 = _local13.triangleList; while (_local14) { _local8 = clipTriangle(_local14, planeOffset, _clipTri0, _clipTri1); if (_local8 > 0){ _local9 = _clipTri0.a; _local10 = _clipTri0.b; _local11 = _clipTri0.c; _local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2); if (_local12 < 0){ _local12 = -(_local12); }; if (_local12 > 1E-5){ _local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3)); _local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3)); _local3 = (_local3 + _local12); }; }; if (_local8 > 1){ _local9 = _clipTri1.a; _local10 = _clipTri1.b; _local11 = _clipTri1.c; _local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2); if (_local12 < 0){ _local12 = -(_local12); }; if (_local12 > 1E-5){ _local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3)); _local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3)); _local3 = (_local3 + _local12); }; }; if (_local13.xmin < _local4){ _local4 = _local13.xmin; }; if (_local13.xmax > _local5){ _local5 = _local13.xmax; }; _local14 = _local14.next; }; }; }; }; _local13 = _local13.next; }; _local6 = (_local6 / _local3); _local7 = (_local7 / _local3); if (_local3 <= 1E-5){ return; }; var _local15:Number = ((density * _local3) * _arg1.world.gravity.y); var _local16:Number = ((_arg1.mass * _local3) / _local2); var _local17:Number = (_local6 - _arg1.x); var _local18:Number = (_local7 - _arg1.y); var _local19:Number = ((planeNormal.x * _local15) + ((_local16 * linDrag) * (velocity.x - (_arg1.vx - (_arg1.w * _local18))))); var _local20:Number = ((planeNormal.y * _local15) + ((_local16 * linDrag) * (velocity.y - (_arg1.vy + (_arg1.w * _local17))))); _arg1.fx = (_arg1.fx + _local19); _arg1.fy = (_arg1.fy + _local20); _arg1.t = (_arg1.t + (((_local17 * _local20) - (_local18 * _local19)) + (((-(_local16) * angDrag) * ((_local5 - _local4) * (_local5 - _local4))) * _arg1.w))); } } }//package de.polygonal.motor2.dynamics.forces import de.polygonal.motor2.math.*; class Plane2 { public var d:Number;// = 0 public var n:V2; private function Plane2(){ n = new V2(); super(); } } class ClipTriangle { public var a:V2; public var c:V2; public var b:V2; private function ClipTriangle(){ a = new V2(); b = new V2(); c = new V2(); super(); } }
Section 173
//ForceGenerator (de.polygonal.motor2.dynamics.forces.ForceGenerator) package de.polygonal.motor2.dynamics.forces { import de.polygonal.motor2.dynamics.*; public class ForceGenerator { public var isActive:Boolean; public function ForceGenerator(){ init(); } public function evaluate(_arg1:RigidBody):void{ } public function init():void{ isActive = true; } } }//package de.polygonal.motor2.dynamics.forces
Section 174
//ForceRegistry (de.polygonal.motor2.dynamics.forces.ForceRegistry) package de.polygonal.motor2.dynamics.forces { import de.polygonal.ds.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.*; public class ForceRegistry { private var _idQue:ArrayedQueue; private var _registration:ForceNode; public function ForceRegistry(){ init(); } public function init():void{ _registration = null; var _local1:int = Constants.k_maxForceGenerators; _idQue = new ArrayedQueue(_local1); var _local2:int; while (_local2 < _local1) { _idQue.enqueue(_local2); _local2++; }; } public function add(_arg1:RigidBody, _arg2:ForceGenerator):int{ var _local3:int = _idQue.dequeue(); var _local4:ForceNode = new ForceNode(_arg1, _arg2); _local4.next = _registration; if (_registration){ _registration.prev = _local4; }; _registration = _local4; return (_local3); } public function remove(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{ var _local3:ForceNode = _registration; while (_local3) { if ((((_local3.force == _arg2)) && ((_local3.body == _arg1)))){ if (_local3.prev){ _local3.prev.next = _local3.next; }; if (_local3.next){ _local3.next.prev = _local3.prev; }; if (_local3 == _registration){ _registration = _local3.next; }; return (true); }; _local3 = _local3.next; }; return (false); } public function evaluate():void{ var _local2:ForceGenerator; var _local1:ForceNode = _registration; while (_local1) { _local2 = _local1.force; if (_local2.isActive){ _local2.evaluate(_local1.body); }; _local1 = _local1.next; }; } public function clear():void{ var _local2:ForceNode; var _local1:ForceNode = _registration; _registration = null; while (_local1) { _local2 = _local1.next; _local1.next = (_local1.prev = null); _local1 = _local2; }; } } }//package de.polygonal.motor2.dynamics.forces import de.polygonal.motor2.dynamics.*; class ForceNode { public var body:RigidBody; public var prev:ForceNode; public var next:ForceNode; public var force:ForceGenerator; private function ForceNode(_arg1:RigidBody, _arg2:ForceGenerator){ this.body = _arg1; this.force = _arg2; init(); } public function init():void{ prev = (next = null); } }
Section 175
//JointData (de.polygonal.motor2.dynamics.joints.data.JointData) package de.polygonal.motor2.dynamics.joints.data { import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.dynamics.joints.*; public class JointData { public var collideConnected:Boolean; public var body1:RigidBody; public var body2:RigidBody; public var userData; public var type:int; public function JointData(_arg1:RigidBody, _arg2:RigidBody){ this.body1 = _arg1; this.body2 = _arg2; setType(); userData = null; } public function getJointClass():Class{ return (null); } protected function setType():void{ type = JointTypes.UNKNOWN; } } }//package de.polygonal.motor2.dynamics.joints.data
Section 176
//Joint (de.polygonal.motor2.dynamics.joints.Joint) package de.polygonal.motor2.dynamics.joints { import de.polygonal.motor2.dynamics.*; import flash.geom.*; import de.polygonal.motor2.dynamics.joints.data.*; public class Joint { protected const _anchor2:Point; protected const _reactionForce:Point; protected const _anchor1:Point; public var next:Joint; public var body1:RigidBody; public var body2:RigidBody; protected var _invdt:Number; public var userData; public var la1x:Number; public var la1y:Number; public var collideConnected:Boolean; public var node1:JointNode; public var node2:JointNode; public var prev:Joint; public var stateBits:int; public var type:int; public var la2x:Number; public var la2y:Number; protected var _dt:Number; public static const k_bitIsland:int = 32; public function Joint(_arg1:JointData){ _reactionForce = new Point(); _anchor1 = new Point(); _anchor2 = new Point(); super(); type = _arg1.type; body1 = _arg1.body1; body2 = _arg1.body2; collideConnected = _arg1.collideConnected; userData = _arg1.userData; node1 = new JointNode(); node2 = new JointNode(); } public function preparePosSolver():void{ } public function getReactionForce():Point{ return (null); } public function getAnchor2():Point{ _anchor2.x = ((body2.x + (body2.r11 * la2x)) + (body2.r12 * la2y)); _anchor2.y = ((body2.y + (body2.r21 * la2x)) + (body2.r22 * la2y)); return (_anchor2); } public function getReactionTorque():Number{ return (0); } public function solveVelConstraints(_arg1:Number, _arg2:int):void{ } public function solvePosConstraints():Boolean{ return (true); } protected function setType(_arg1:int):void{ this.type = _arg1; } public function preStep(_arg1:Number):void{ _dt = _arg1; _invdt = (1 / _arg1); } public function getAnchor1():Point{ _anchor1.x = ((body1.x + (body1.r11 * la1x)) + (body1.r12 * la1y)); _anchor1.y = ((body1.y + (body1.r21 * la1x)) + (body1.r22 * la1y)); return (_anchor1); } } }//package de.polygonal.motor2.dynamics.joints
Section 177
//JointNode (de.polygonal.motor2.dynamics.joints.JointNode) package de.polygonal.motor2.dynamics.joints { import de.polygonal.motor2.dynamics.*; public class JointNode { public var other:RigidBody; public var next:JointNode; public var prev:JointNode; public var joint:Joint; } }//package de.polygonal.motor2.dynamics.joints
Section 178
//JointTypes (de.polygonal.motor2.dynamics.joints.JointTypes) package de.polygonal.motor2.dynamics.joints { public class JointTypes { public static const MOUSE:int = 2; public static const REVOLUTE:int = 3; public static const PRISMATIC:int = 6; public static const GEAR:int = 5; public static const DISTANCE:int = 1; public static const UNKNOWN:int = 0; public static const PULLEY:int = 4; } }//package de.polygonal.motor2.dynamics.joints
Section 179
//Island (de.polygonal.motor2.dynamics.Island) package de.polygonal.motor2.dynamics { import de.polygonal.motor2.*; import de.polygonal.motor2.dynamics.contact.solver.*; public class Island { public var bodies:Array; public var contactSolver:SIContactSolver; public var jointCount:int; public var joints:Array; public var bodyCount:int; public var positionError:Number; public var contacts:Array; public var contactCount:int; public var bodyList:RigidBody; public var positionIterations:int; public function Island(){ bodyCount = 0; contactCount = 0; jointCount = 0; bodyList = null; bodies = new Array(); contacts = new Array(); joints = new Array(); contactSolver = new SIContactSolver(); } public function solve(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Number):void{ var _local5:int; var _local6:int; var _local7:RigidBody; var _local8:Number; var _local9:Number; var _local10:Boolean; var _local11:Boolean; _local5 = 0; while (_local5 < bodyCount) { _local7 = bodies[_local5]; if (_local7.invMass == 0){ } else { _local7.vx = ((_local7.vx + (_arg4 * (_arg1 + (_local7.invMass * _local7.fx)))) * _local7.linDamping); _local7.vy = ((_local7.vy + (_arg4 * (_arg2 + (_local7.invMass * _local7.fy)))) * _local7.linDamping); _local7.w = ((_local7.w + (_arg4 * (_local7.invI * _local7.t))) * _local7.angDamping); }; _local5++; }; contactSolver.setContacts(contacts, contactCount); contactSolver.preStep(); _local6 = 0; while (_local6 < jointCount) { joints[_local6].preStep(_arg4); _local6++; }; _local5 = 0; while (_local5 < _arg3) { contactSolver.solveVelConstraints(); _local6 = 0; while (_local6 < jointCount) { joints[_local6].solveVelConstraints(_arg4, _arg3); _local6++; }; _local5++; }; _local5 = 0; while (_local5 < bodyCount) { _local7 = bodies[_local5]; if (_local7.invMass == 0){ } else { _local7.x = (_local7.x + (_arg4 * _local7.vx)); _local7.y = (_local7.y + (_arg4 * _local7.vy)); _local7.r = (_local7.r + (_arg4 * _local7.w)); _local9 = Math.cos(_local7.r); _local8 = Math.sin(_local7.r); _local7.r11 = _local9; _local7.r12 = -(_local8); _local7.r21 = _local8; _local7.r22 = _local9; }; _local5++; }; if (World.doPositionCorrection){ _local5 = 0; while (_local5 < _arg3) { _local10 = contactSolver.solvePosConstraints(Constants.k_contactBaumgarte); _local11 = true; _local6 = 0; while (_local6 < jointCount) { _local11 = joints[_local6].solvePosConstraints(); _local11 = ((_local11) && (_local11)); _local6++; }; if (((_local10) && (_local11))){ break; }; _local5++; }; }; } public function updateSleep(_arg1:Number):void{ var _local5:RigidBody; var _local6:int; var _local2:Number = 2147483648; var _local3:Number = Constants.k_linSleepToleranceSq; var _local4:Number = Constants.k_angSleepToleranceSq; _local6 = 0; while (_local6 < bodyCount) { _local5 = bodies[_local6]; if (_local5.invMass == 0){ } else { if ((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0){ _local5.sleepTime = 0; _local2 = 0; }; if (((((((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0)) || (((_local5.w * _local5.w) > _local4)))) || ((((_local5.vx * _local5.vx) + (_local5.vy * _local5.vy)) > _local3)))){ _local5.sleepTime = 0; _local2 = 0; } else { _local5.sleepTime = (_local5.sleepTime + _arg1); _local2 = ((_local2 < _local5.sleepTime)) ? _local2 : _local5.sleepTime; }; }; _local6++; }; if (_local2 >= Constants.k_timeToSleep){ _local6 = 0; while (_local6 < bodyCount) { _local5 = bodies[_local6]; bodies[_local6].stateBits = (_local5.stateBits | RigidBody.k_bitSleep); _local6++; }; }; } } }//package de.polygonal.motor2.dynamics
Section 180
//RigidBody (de.polygonal.motor2.dynamics.RigidBody) package de.polygonal.motor2.dynamics { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.*; import de.polygonal.motor2.math.*; import flash.geom.*; import de.polygonal.motor2.collision.shapes.data.*; import de.polygonal.motor2.collision.nbody.*; import de.polygonal.motor2.dynamics.joints.*; import de.polygonal.motor2.dynamics.contact.*; public class RigidBody { public var r:Number; public var invMass:Number; public var world:World; public var r12:Number; public var userData; public var r11:Number; public var linDamping:Number; public var r22:Number; public var prev:RigidBody; public var stateBits:int; public var r21:Number; public var vx:Number; public var vy:Number; public var sleepTime:Number; public var angDamping:Number; public var I:Number; public var jointList:JointNode; public var fx:Number; public var fy:Number; public var contactList:ContactNode; public var shapeList:ShapeSkeleton; public var next:RigidBody; public var mass:Number; public var cx:Number; public var cy:Number; public var x:Number; public var y:Number; public var t:Number; public var shapeCount:int; public var w:Number; public var invI:Number; public static const k_bitDestroy:int = 16; public static const k_bitAllowSleep:int = 8; public static const k_bitIsland:int = 32; public static const k_bitStatic:int = 1; public static const k_bitFrozen:int = 2; public static const k_bitSleep:int = 4; public function RigidBody(_arg1:World, _arg2:RigidBodyData){ init(_arg1, _arg2); } public function refreshProxy():void{ var _local1:ShapeSkeleton = shapeList; while (_local1) { _local1.refreshProxy(); _local1 = _local1.next; }; } public function getWorldDirection(_arg1:Point, _arg2:Point=null):void{ var _local3:Number; if (_arg2){ _arg2.x = ((r11 * _arg1.x) + (r12 * _arg1.y)); _arg2.y = ((r21 * _arg1.x) + (r22 * _arg1.y)); } else { _local3 = _arg1.x; _arg1.x = ((r11 * _local3) + (r12 * _arg1.y)); _arg1.y = ((r21 * _local3) + (r22 * _arg1.y)); }; } public function wakeUp():void{ stateBits = (stateBits & ~(k_bitSleep)); sleepTime = 0; } public function putToSleep():void{ stateBits = (stateBits | k_bitSleep); sleepTime = 0; vx = (vy = (w = (fx = (fy = (t = 0))))); } public function deconstruct():void{ var _local2:ShapeSkeleton; prev = (next = null); var _local1:ShapeSkeleton = shapeList; while (_local1) { _local2 = _local1; _local1 = _local1.next; _local2.deconstruct(); }; } public function getWorldPoint(_arg1:Point, _arg2:Point=null):void{ var _local3:Number; if (_arg2){ _arg2.x = (x + ((r11 * _arg1.x) + (r12 * _arg1.y))); _arg2.y = (y + ((r21 * _arg1.x) + (r22 * _arg1.y))); } else { _local3 = _arg1.x; _arg1.x = (x + ((r11 * _local3) + (r12 * _arg1.y))); _arg1.y = (y + ((r21 * _local3) + (r22 * _arg1.y))); }; } public function applyTorque(_arg1:Number):void{ if ((stateBits & k_bitSleep) == 0){ t = (t + _arg1); }; } public function getOrigin(_arg1:V2):void{ _arg1.x = (x - ((r11 * cx) + (r12 * cy))); _arg1.y = (y - ((r21 * cx) + (r22 * cy))); } public function applyForce(_arg1:Number, _arg2:Number):void{ if ((stateBits & k_bitSleep) == 0){ this.fx = (this.fx + _arg1); this.fy = (this.fy + _arg2); }; } public function freeze():void{ stateBits = (stateBits | k_bitFrozen); vx = (vy = (w = 0)); } private function init(_arg1:World, _arg2:RigidBodyData):void{ var _local3:Number; var _local4:Number; var _local5:Number; var _local6:Number; var _local7:Number; var _local8:ShapeData; var _local9:ShapeSkeleton; var _local10:Class; this.world = _arg1; x = _arg2.x; y = _arg2.y; r = _arg2.r; _local3 = Math.cos(r); _local4 = Math.sin(r); r11 = _local3; r12 = -(_local4); r21 = _local4; r22 = _local3; vx = (vy = (w = 0)); fx = (fy = (t = 0)); mass = (invMass = (I = (invI = 0))); cx = (cy = 0); linDamping = (1 - _arg2.linDamping); linDamping = ((linDamping)<0) ? 0 : ((linDamping)>1) ? 1 : linDamping; angDamping = (1 - _arg2.angDamping); angDamping = ((angDamping)<0) ? 0 : ((angDamping)>1) ? 1 : angDamping; shapeCount = 0; stateBits = 0; sleepTime = 0; if (_arg2.allowSleep){ stateBits = (stateBits | k_bitAllowSleep); }; if (_arg2.isSleeping){ stateBits = (stateBits | k_bitSleep); }; jointList = null; contactList = null; next = (prev = null); _local8 = _arg2.shapeDataList; while (_local8) { _local5 = _local8.getMass(); mass = (mass + _local5); cx = (cx + (_local5 * (_local8.mx + _local8.getCM().x))); cy = (cy + (_local5 * (_local8.my + _local8.getCM().y))); shapeCount++; _local8 = _local8.next; }; if (mass > 0){ cx = (cx / mass); cy = (cy / mass); x = (x + ((r11 * cx) + (r12 * cy))); y = (y + ((r21 * cx) + (r22 * cy))); } else { stateBits = (stateBits | k_bitStatic); }; if (!_arg2.preventRotation){ _local8 = _arg2.shapeDataList; while (_local8) { I = (I + _local8.getInertia()); _local6 = ((_local8.mx + _local8.getCM().x) - cx); _local7 = ((_local8.my + _local8.getCM().y) - cy); I = (I + (_local8.getMass() * ((_local6 * _local6) + (_local7 * _local7)))); _local8 = _local8.next; }; if (I > 0){ invI = (1 / I); }; }; invMass = ((mass)>0) ? (1 / mass) : 0; if (((!(_arg2.isSleeping)) && ((invMass > 0)))){ vx = (_arg2.vx + (-(_arg2.w) * cy)); vy = (_arg2.vy + (_arg2.w * cy)); w = _arg2.w; }; _local8 = _arg2.shapeDataList; while (_local8) { _local10 = _local8.getShapeClass(); _local9 = new _local10(_local8, this); _local9.next = shapeList; shapeList = _local9; _local8 = _local8.next; }; } public function updateShapes(_arg1:Boolean=false):Boolean{ var _local2:Number = Math.cos(r); var _local3:Number = Math.sin(r); r11 = _local2; r12 = -(_local3); r21 = _local3; r22 = _local2; var _local4:Boolean; var _local5:ShapeSkeleton = shapeList; while (_local5) { if (!_local5.update()){ _local4 = false; break; }; if (_arg1){ _local5.toWorldSpace(); }; _local5 = _local5.next; }; if (!_local4){ freeze(); _local5 = shapeList; while (_local5) { if (_local5.proxyId != Proxy.NULL_PROXY){ world.getBroadPhase().destroyProxy(_local5.proxyId); _local5.proxyId = Proxy.NULL_PROXY; }; _local5 = _local5.next; }; return (false); }; return (true); } public function allowSleeping(_arg1:Boolean):void{ if (_arg1){ stateBits = (stateBits | k_bitAllowSleep); } else { stateBits = (stateBits & ~(k_bitAllowSleep)); wakeUp(); }; } public function applyImpulse(_arg1:Number, _arg2:Number):void{ if ((stateBits & k_bitSleep) == 0){ vx = (vx + (invMass * _arg1)); vy = (vy + (invMass * _arg2)); }; } public function setOrigin(_arg1:Number, _arg2:Number, _arg3:Number):void{ var _local4:Number; var _local5:Number; var _local6:ShapeSkeleton; if ((stateBits & k_bitFrozen) == 0){ r = _arg3; _local4 = Math.cos(r); _local5 = Math.sin(r); r11 = _local4; r12 = -(_local5); r21 = _local5; r22 = _local4; this.x = (_arg1 + ((r11 * cx) + (r12 * cy))); this.y = (_arg2 + ((r21 * cx) + (r22 * cy))); _local6 = shapeList; while (_local6) { _local6.update(); _local6 = _local6.next; }; }; } public function isConnected(_arg1:RigidBody):Boolean{ var _local2:JointNode = jointList; while (_local2) { if (_local2.other == _arg1){ return ((_local2.joint.collideConnected == false)); }; _local2 = _local2.next; }; return (false); } public function applyForceAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{ if ((stateBits & k_bitSleep) == 0){ this.fx = (this.fx + _arg1); this.fy = (this.fy + _arg2); t = (t + (((_arg3 - x) * _arg2) - ((_arg4 - y) * _arg1))); }; } public function isStatic():Boolean{ return (((stateBits & k_bitStatic) == k_bitStatic)); } public function applyImpulseAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{ if ((stateBits & k_bitSleep) == 0){ vx = (vx + (invMass * _arg1)); vy = (vy + (invMass * _arg2)); w = (w + (((invI * (_arg3 - x)) * _arg2) - ((invI * (_arg4 - y)) * _arg1))); }; } public function getModelDirection(_arg1:Point, _arg2:Point=null):void{ var _local3:Number; if (_arg2){ _arg2.x = ((r11 * _arg1.x) + (r21 * _arg1.y)); _arg2.y = ((r12 * _arg1.x) + (r22 * _arg1.y)); } else { _local3 = _arg1.x; _arg1.x = ((r11 * _local3) + (r21 * _arg1.y)); _arg1.y = ((r12 * _local3) + (r22 * _arg1.y)); }; } public function setCenter(_arg1:Number, _arg2:Number, _arg3:Number):void{ var _local4:Number; var _local5:Number; var _local6:ShapeSkeleton; if ((stateBits & k_bitFrozen) == 0){ r = _arg3; _local4 = Math.cos(r); _local5 = Math.sin(r); r11 = _local4; r12 = -(_local5); r21 = _local5; r22 = _local4; this.x = _arg1; this.y = _arg2; _local6 = shapeList; while (_local6) { _local6.update(); _local6 = _local6.next; }; }; } public function getCenter(_arg1:V2):void{ _arg1.x = x; _arg1.y = y; } public function rotate(_arg1:Number):void{ if (_arg1 < 0){ _arg1 = (_arg1 + 360); } else { if (_arg1 > 360){ _arg1 = (_arg1 - 360); }; }; r = (_arg1 * (Math.PI / 180)); updateShapes(); } public function getModelPoint(_arg1:Point, _arg2:Point=null):void{ var _local3:Number; if (_arg2){ _arg2.x = ((r11 * (_arg1.x - x)) + (r21 * (_arg1.y - y))); _arg2.y = ((r12 * (_arg1.x - x)) + (r22 * (_arg1.y - y))); } else { _local3 = _arg1.x; _arg1.x = ((r11 * (_local3 - x)) + (r21 * (_arg1.y - y))); _arg1.y = ((r12 * (_local3 - x)) + (r22 * (_arg1.y - y))); }; } public function isFrozen():Boolean{ return (((stateBits & k_bitFrozen) == k_bitFrozen)); } public function isSleeping():Boolean{ return (((stateBits & k_bitSleep) == k_bitSleep)); } } }//package de.polygonal.motor2.dynamics
Section 181
//RigidBodyData (de.polygonal.motor2.dynamics.RigidBodyData) package de.polygonal.motor2.dynamics { import de.polygonal.motor2.collision.shapes.data.*; public class RigidBodyData { public var y:Number; public var vx:Number; public var vy:Number; public var angDamping:Number; public var allowSleep:Boolean; public var shapeDataList:ShapeData; public var linDamping:Number; public var r:Number; public var isSleeping:Boolean; public var preventRotation:Boolean; public var w:Number; public var x:Number; public function RigidBodyData(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){ init(); this.x = _arg1; this.y = _arg2; this.r = _arg3; } public function addShapeData(_arg1:ShapeData):void{ if (_arg1 == null){ return; }; _arg1.next = shapeDataList; shapeDataList = _arg1; } public function move(_arg1:Number, _arg2:Number):void{ this.x = _arg1; this.y = _arg2; } public function init():void{ x = (y = (r = (vx = (vy = (w = 0))))); allowSleep = true; isSleeping = false; linDamping = 0; angDamping = 0; preventRotation = false; shapeDataList = null; } public function rotate(_arg1:Number):void{ if (_arg1 < 0){ _arg1 = (_arg1 + 360); } else { if (_arg1 > 360){ _arg1 = (_arg1 - 360); }; }; r = (_arg1 * (Math.PI / 180)); } } }//package de.polygonal.motor2.dynamics
Section 182
//AABB2 (de.polygonal.motor2.math.AABB2) package de.polygonal.motor2.math { public class AABB2 { public var ymax:Number; public var xmax:Number; public var ymin:Number; public var xmin:Number; public function AABB2(_arg1:Number=1.79769313486232E308, _arg2:Number=1.79769313486232E308, _arg3:Number=4.94065645841247E-324, _arg4:Number=4.94065645841247E-324){ this.xmin = _arg1; this.ymin = _arg2; this.xmax = _arg3; this.ymax = _arg4; } public function isEmpty():Boolean{ return ((((xmin > xmax)) || ((ymin > ymax)))); } public function empty():void{ xmin = (ymin = 2147483647); xmax = (ymax = -2147483648); } public function addPoint(_arg1:Number, _arg2:Number):void{ if (_arg1 < xmin){ xmin = _arg1; }; if (_arg1 > xmax){ xmax = _arg1; }; if (_arg2 < ymin){ ymin = _arg2; }; if (_arg2 > ymax){ ymax = _arg2; }; } public function copy():AABB2{ return (new AABB2(xmin, ymin, xmax, ymax)); } } }//package de.polygonal.motor2.math
Section 183
//Circle2 (de.polygonal.motor2.math.Circle2) package de.polygonal.motor2.math { import flash.geom.*; public class Circle2 { public const c:Point; public var radius:Number; public function Circle2(_arg1:Number, _arg2:Number, _arg3:Number){ c = new Point(); super(); c.x = _arg1; c.y = _arg2; radius = _arg3; } public function copy():Circle2{ return (new Circle2(c.x, c.y, radius)); } } }//package de.polygonal.motor2.math
Section 184
//ConvexBSPNode (de.polygonal.motor2.math.ConvexBSPNode) package de.polygonal.motor2.math { import de.polygonal.ds.*; public class ConvexBSPNode extends BinaryTreeNode { public var R:ConvexBSPNode; public var V:V2; public var I:int; public var L:ConvexBSPNode; public var N:V2; public function ConvexBSPNode(){ super(null); init(); } private function init():void{ L = (R = null); N = (V = null); I = -1; } } }//package de.polygonal.motor2.math
Section 185
//E2 (de.polygonal.motor2.math.E2) package de.polygonal.motor2.math { public class E2 { public var mag:Number;// = 0 public var d:V2; public var n:V2; public var prev:E2; public var v:V2; public var w:V2; public var next:E2; } }//package de.polygonal.motor2.math
Section 186
//Tri2 (de.polygonal.motor2.math.Tri2) package de.polygonal.motor2.math { public class Tri2 { public var a:V2; public var c:V2; public var b:V2; public var cm:V2; public var area:Number; public var next:Tri2; public function Tri2(_arg1:V2, _arg2:V2, _arg3:V2){ this.a = _arg1; this.b = _arg2; this.c = _arg3; area = ((((_arg2.x - _arg1.x) * (_arg3.y - _arg1.y)) - ((_arg2.y - _arg1.y) * (_arg3.x - _arg1.x))) / 2); cm = new V2((((_arg1.x + _arg2.x) + _arg3.x) / 3), (((_arg1.y + _arg2.y) + _arg3.y) / 3)); } } }//package de.polygonal.motor2.math
Section 187
//V2 (de.polygonal.motor2.math.V2) package de.polygonal.motor2.math { import flash.geom.*; public class V2 extends Point { public var isTail:Boolean; public var next:V2; public var isHead:Boolean; public var index:int; public var prev:V2; public var edge:E2; public function V2(_arg1:Number=0, _arg2:Number=0){ super(_arg1, _arg2); index = -1; } public function getAt(_arg1:int):V2{ var _local2:V2 = this; while (_local2) { if (_local2.index == _arg1){ return (_local2); }; if (_local2.isTail){ break; }; _local2 = _local2.next; }; return (null); } override public function toString():String{ return ((((((((((("{V2, index=" + index) + ", head=") + int(isHead)) + ", tail=") + int(isTail)) + ", x=") + x.toFixed(2)) + ", y=") + y.toFixed(2)) + "}")); } public function copy():V2{ return (new V2(x, y)); } public function deconstruct():void{ var _local2:V2; var _local1:V2 = this; while (_local1) { _local2 = _local1.next; _local1 = null; _local1 = _local2; }; } public function toArray():Array{ var _local1:int = (index + 1); var _local2:V2 = next; while (!(_local2.isHead)) { _local1++; _local2 = _local2.next; }; var _local3:Array = new Array(_local1, true); _local2 = this; var _local4:int; while (_local4 < _local1) { _local3[_local4] = _local2; _local2 = _local2.next; _local4++; }; return (_local3); } } }//package de.polygonal.motor2.math
Section 188
//Constants (de.polygonal.motor2.Constants) package de.polygonal.motor2 { public class Constants { public static const k_timeUnitsPerSecond:Number = 1; public static const k_angSleepTolerance:Number = 0; public static const k_maxManifoldPoints:int = 2; public static const k_minLineAABBThickness:Number = 20; public static const k_linSleepToleranceSq:Number = 0.25; public static const k_linSleepTolerance:Number = 0.5; public static const k_linSlopSq:Number = 0.0625; public static const k_linSlop:Number = 0.25; public static const k_angSleepToleranceSq:Number = 0; public static const k_maxForceGenerators:int = (1 << 9); public static const k_maxShapesPerBody:int = 64; public static const k_maxLinCorrection:Number = 10; public static const k_angSlop:Number = 0; public static const k_lengthUnitsPerMeter:Number = 50; public static const k_invalid:int = 4095; public static const k_maxPolyVertices:int = 8; public static const k_contactBaumgarte:Number = 0.2; public static const k_maxAngCorrection:Number = 0.139626340159546; public static const k_maxPairs:int = (k_maxProxies << 3); public static const k_maxProxies:int = (1 << 9); public static const k_massUnitsPerKilogram:Number = 1; public static const k_velocityThreshold:Number = 50; public static const k_timeToSleep:Number = 0.5; } }//package de.polygonal.motor2
Section 189
//ContactCallback (de.polygonal.motor2.ContactCallback) package de.polygonal.motor2 { import de.polygonal.motor2.dynamics.contact.*; public interface ContactCallback { function onContactRemoved(_arg1:Contact):void; function onContactAdded(_arg1:Contact):void; } }//package de.polygonal.motor2
Section 190
//World (de.polygonal.motor2.World) package de.polygonal.motor2 { import flash.events.*; import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.math.*; import flash.geom.*; import de.polygonal.motor2.collision.shapes.data.*; import de.polygonal.motor2.collision.nbody.*; import de.polygonal.motor2.dynamics.joints.*; import de.polygonal.motor2.dynamics.contact.*; import de.polygonal.motor2.dynamics.joints.data.*; import de.polygonal.motor2.dynamics.forces.*; public class World extends EventDispatcher { public var doSleep:Boolean; private var _shapeCount:int; private var _bodyCount:int; private var _contactManager:ContactManager; private var _callback:WorldCallback; private var _worldBounds:AABB2; private var _island:Island; public var bodyDestroyList:RigidBody; private var _broadPhase:BroadPhase; private var _jointCount:int; public var jointList:Joint; private var _forceRegistry:ForceRegistry; public var gravity:Point; public var contactCount:int; public var contactList:Contact; public var bodyList:RigidBody; private var _groundBody:RigidBody; public static var doWarmStarting:Boolean = true; public static var doPositionCorrection:Boolean = true; public static var stats_timeSimStep:int = 0; public static var stats_SepAxisQueryCount:int = 0; public function World(_arg1:AABB2, _arg2:Boolean=true){ if (_arg1.isEmpty()){ throw (new Error("invalid world bounds")); }; _worldBounds = _arg1.copy(); _worldBounds.xmin = int(_worldBounds.xmin); _worldBounds.ymin = int(_worldBounds.ymin); _worldBounds.xmax = int(_worldBounds.xmax); _worldBounds.ymax = int(_worldBounds.ymax); this.doSleep = _arg2; setGravity(0, 100); setCallback(new NullCallback()); _contactManager = new ContactManager(this); _contactManager.setFilter(new ContactFilter()); _groundBody = new RigidBody(this, new RigidBodyData()); _forceRegistry = new ForceRegistry(); _island = new Island(); } public function getBroadPhase():BroadPhase{ return (_broadPhase); } public function setGravity(_arg1:Number, _arg2:Number):void{ if (gravity == null){ gravity = new Point(); }; gravity.x = _arg1; gravity.y = _arg2; } public function setBroadPhase(_arg1:BroadPhase):void{ var _local2:Array; var _local3:ShapeSkeleton; var _local4:int; if (_bodyCount == 0){ _broadPhase = _arg1; _broadPhase.setWorldBounds(_worldBounds); _broadPhase.setPairHandler(_contactManager); } else { _local2 = getShapeList(); _local4 = 0; while (_local4 < _local2.length) { _local3 = _local2[_local4]; _broadPhase.destroyProxy(_local3.proxyId); _local3.proxyId = Proxy.NULL_PROXY; _local3.broadPhase = null; _local4++; }; _broadPhase.deconstruct(); _broadPhase = _arg1; _broadPhase.setWorldBounds(_worldBounds); _broadPhase.setPairHandler(_contactManager); _local4 = 0; while (_local4 < _local2.length) { _local3 = _local2[_local4]; _local3.broadPhase = _broadPhase; _local3.proxyId = _broadPhase.createProxy(_local3); _local4++; }; }; } public function getShapeList():Array{ var _local1:Array = new Array(_shapeCount, true); var _local2:int; var _local3:RigidBody = bodyList; if (_local3 == null){ return (_local1); }; var _local4:ShapeSkeleton = _local3.shapeList; while (true) { if (_local4 != null){ var _temp1 = _local2; _local2 = (_local2 + 1); var _local5 = _temp1; _local1[_local5] = _local4; _local4 = _local4.next; } else { _local3 = _local3.next; if (_local3 != null){ _local4 = _local3.shapeList; var _temp2 = _local2; _local2 = (_local2 + 1); _local5 = _temp2; _local1[_local5] = _local4; _local4 = _local4.next; } else { break; }; }; }; return (_local1); } public function destroyJoint(_arg1:Joint):void{ var _local5:RigidBody; var _local6:ShapeSkeleton; var _local2:Boolean = _arg1.collideConnected; if (_arg1.prev){ _arg1.prev.next = _arg1.next; }; if (_arg1.next){ _arg1.next.prev = _arg1.prev; }; if (_arg1 == jointList){ jointList = _arg1.next; }; var _local3:RigidBody = _arg1.body1; var _local4:RigidBody = _arg1.body2; _local3.wakeUp(); _local4.wakeUp(); if (_arg1.node1.prev){ _arg1.node1.prev.next = _arg1.node1.next; }; if (_arg1.node1.next){ _arg1.node1.next.prev = _arg1.node1.prev; }; if (_arg1.node1 == _local3.jointList){ _local3.jointList = _arg1.node1.next; }; _arg1.node1.prev = null; _arg1.node1.next = null; if (_arg1.node2.prev){ _arg1.node2.prev.next = _arg1.node2.next; }; if (_arg1.node2.next){ _arg1.node2.next.prev = _arg1.node2.prev; }; if (_arg1.node2 == _local4.jointList){ _local4.jointList = _arg1.node2.next; }; _arg1.node2.prev = null; _arg1.node2.next = null; _jointCount--; if (!_local2){ _local5 = ((_local3.shapeCount < _local4.shapeCount)) ? _local3 : _local4; _local6 = _local5.shapeList; while (_local6) { _local6.refreshProxy(); _local6 = _local6.next; }; }; } public function getWorldBounds():AABB2{ return (_worldBounds); } public function createBody(_arg1:RigidBodyData):RigidBody{ if (_broadPhase == null){ setBroadPhase(new ExhaustiveSearch()); }; var _local2:RigidBody = new RigidBody(this, _arg1); _local2.next = bodyList; if (bodyList){ bodyList.prev = _local2; }; bodyList = _local2; _bodyCount++; var _local3:ShapeData = _arg1.shapeDataList; while (_local3 != null) { _shapeCount++; _local3 = _local3.next; }; return (_local2); } public function getGroundBody():RigidBody{ return (_groundBody); } public function setContactCallback(_arg1:ContactCallback):void{ _contactManager.setCallback(_arg1); } public function setCallback(_arg1:WorldCallback):void{ _callback = _arg1; } public function addForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{ var _local3:ShapeSkeleton; if (_arg1 == null){ return (false); }; if ((_arg2 is Buoyancy)){ _local3 = _arg1.shapeList; while (_local3) { _local3.triangulate(); _local3 = _local3.next; }; }; _forceRegistry.add(_arg1, _arg2); return (true); } public function destroyBody(_arg1:RigidBody):Boolean{ var _local3:JointNode; var _local5:ShapeSkeleton; if (_bodyCount == 0){ return (false); }; if ((_arg1.stateBits & RigidBody.k_bitDestroy)){ return (false); }; var _local2:JointNode = _arg1.jointList; while (_local2) { _local3 = _local2; _local2 = _local2.next; _callback.onJointDestroyed(_local3.joint); destroyJoint(_local3.joint); }; var _local4:ShapeSkeleton = _arg1.shapeList; while (_local4) { _local5 = _local4; _local4 = _local4.next; _shapeCount--; _callback.onShapeDestroyed(_local5); }; if (_arg1.prev){ _arg1.prev.next = _arg1.next; }; if (_arg1.next){ _arg1.next.prev = _arg1.prev; }; if (_arg1 == bodyList){ bodyList = _arg1.next; }; _arg1.stateBits = (_arg1.stateBits | RigidBody.k_bitDestroy); if (_bodyCount > 0){ _bodyCount--; }; _arg1.deconstruct(); _callback.onBodyDestroyed(_arg1); return (true); } public function step(_arg1:Number, _arg2:int):void{ var _local3:RigidBody; var _local4:Contact; var _local5:Joint; var _local6:int; var _local8:int; var _local9:RigidBody; var _local10:ContactNode; var _local11:JointNode; var _local12:RigidBody; var _local14:Joint; _contactManager.collide(); _forceRegistry.evaluate(); _local3 = bodyList; while (_local3) { _local3.stateBits = (_local3.stateBits & ~(32)); _local3 = _local3.next; }; _local4 = contactList; while (_local4) { _local4.stateBits = (_local4.stateBits & ~(Contact.k_bitIsland)); _local4 = _local4.next; }; _local5 = jointList; while (_local5) { _local5.stateBits = (_local5.stateBits & ~(32)); _local5 = _local5.next; }; var _local7:Array = []; var _local13 = (((RigidBody.k_bitStatic | RigidBody.k_bitSleep) | RigidBody.k_bitFrozen) | RigidBody.k_bitIsland); _local12 = bodyList; while (_local12 != null) { if ((_local12.stateBits & _local13)){ } else { _island.bodyCount = 0; _island.contactCount = 0; _island.jointCount = 0; _local7[0] = _local12; _local8 = 1; _local12.stateBits = (_local12.stateBits | 32); while (_local8 > 0) { --_local8; _local3 = _local7[_local8]; _island.bodies[int(_island.bodyCount++)] = _local3; _local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep)); if ((_local3.stateBits & RigidBody.k_bitStatic)){ } else { _local10 = _local3.contactList; while (_local10) { if ((_local10.contact.stateBits & Contact.k_bitIsland)){ } else { _island.contacts[int(_island.contactCount++)] = _local10.contact; _local10.contact.stateBits = (_local10.contact.stateBits | Contact.k_bitIsland); _local9 = _local10.other; if ((_local9.stateBits & 32)){ } else { var _temp1 = _local8; _local8 = (_local8 + 1); var _local15 = _temp1; _local7[_local15] = _local9; _local9.stateBits = (_local9.stateBits | 32); }; }; _local10 = _local10.next; }; _local11 = _local3.jointList; while (_local11) { _local14 = _local11.joint; if ((_local14.stateBits & 32)){ } else { _island.joints[int(_island.jointCount++)] = _local14; _local14.stateBits = (_local14.stateBits | 32); _local9 = _local11.other; if ((_local9.stateBits & 32)){ } else { var _temp2 = _local8; _local8 = (_local8 + 1); _local15 = _temp2; _local7[_local15] = _local9; _local9.stateBits = (_local9.stateBits | 32); }; }; _local11 = _local11.next; }; }; }; _island.solve(gravity.x, gravity.y, _arg2, _arg1); if (doSleep){ _island.updateSleep(_arg1); }; _local6 = 0; while (_local6 < _island.bodyCount) { _local3 = _island.bodies[_local6]; if ((_local3.stateBits & RigidBody.k_bitStatic)){ _local3.stateBits = (_local3.stateBits & ~(32)); }; _local6++; }; }; _local12 = _local12.next; }; _local13 = (_local13 & ~(RigidBody.k_bitIsland)); _local3 = bodyList; while (_local3 != null) { if ((_local3.stateBits & _local13) > 0){ _local3 = _local3.next; } else { _local3.fx = (_local3.fy = (_local3.t = 0)); if (!_local3.updateShapes()){ _callback.onBodyLeftWorld(_local3); }; _local3 = _local3.next; }; }; _broadPhase.findPairs(); } public function getBodyList():Array{ var _local1:Array = new Array(_bodyCount, true); var _local2:int; var _local3:RigidBody = bodyList; if (_local3 == null){ return (_local1); }; while (_local3 != null) { var _temp1 = _local2; _local2 = (_local2 + 1); var _local4 = _temp1; _local1[_local4] = _local3; _local3 = _local3.next; }; return (_local1); } public function removeForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{ return (_forceRegistry.remove(_arg1, _arg2)); } public function getShapeCount():int{ return (_shapeCount); } public function getBodyCount():int{ return (_bodyCount); } public function createJoint(_arg1:JointData):Joint{ var _local4:RigidBody; var _local5:ShapeSkeleton; var _local2:Class = _arg1.getJointClass(); var _local3:Joint = (new _local2(_arg1) as Joint); _local3.prev = null; _local3.next = jointList; if (jointList){ jointList.prev = _local3; }; jointList = _local3; _jointCount++; _local3.node1.joint = _local3; _local3.node1.other = _local3.body2; _local3.node1.prev = null; _local3.node1.next = _local3.body1.jointList; if (_local3.body1.jointList){ _local3.body1.jointList.prev = _local3.node1; }; _local3.body1.jointList = _local3.node1; _local3.node2.joint = _local3; _local3.node2.other = _local3.body1; _local3.node2.prev = null; _local3.node2.next = _local3.body2.jointList; if (_local3.body2.jointList){ _local3.body2.jointList.prev = _local3.node2; }; _local3.body2.jointList = _local3.node2; if (!_arg1.collideConnected){ _local4 = ((_arg1.body1.shapeCount < _arg1.body2.shapeCount)) ? _arg1.body1 : _arg1.body2; _local5 = _local4.shapeList; while (_local5) { _local5.refreshProxy(); _local5 = _local5.next; }; }; return (_local3); } public function setContactFilter(_arg1:ContactFilter):void{ _contactManager.setFilter(_arg1); } public function deconstruct():void{ destroyBody(_groundBody); _broadPhase = null; } } }//package de.polygonal.motor2 import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.dynamics.joints.*; class NullCallback implements WorldCallback { private function NullCallback(){ } public function onBodyLeftWorld(_arg1:RigidBody):void{ } public function onJointDestroyed(_arg1:Joint):void{ } public function onBodyDestroyed(_arg1:RigidBody):void{ } public function onShapeDestroyed(_arg1:ShapeSkeleton):void{ } }
Section 191
//WorldCallback (de.polygonal.motor2.WorldCallback) package de.polygonal.motor2 { import de.polygonal.motor2.collision.shapes.*; import de.polygonal.motor2.dynamics.*; import de.polygonal.motor2.dynamics.joints.*; public interface WorldCallback { function onBodyDestroyed(_arg1:RigidBody):void; function onBodyLeftWorld(_arg1:RigidBody):void; function onJointDestroyed(_arg1:Joint):void; function onShapeDestroyed(_arg1:ShapeSkeleton):void; } }//package de.polygonal.motor2
Section 192
//ByteArrayAsset (mx.core.ByteArrayAsset) package mx.core { import flash.utils.*; public class ByteArrayAsset extends ByteArray implements IFlexAsset { mx_internal static const VERSION:String = "3.0.0.0"; } }//package mx.core
Section 193
//IFlexAsset (mx.core.IFlexAsset) package mx.core { public interface IFlexAsset { } }//package mx.core
Section 194
//mx_internal (mx.core.mx_internal) package mx.core { public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal"; }//package mx.core
Section 195
//InFamous (InFamous) package { import flash.events.*; import flash.display.*; import com.kerb.infamous.*; public class InFamous extends Sprite { private var SWFBytes:Class; public function InFamous(){ SWFBytes = InFamous_SWFBytes; super(); addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } private function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); var _local2:int = loaderInfo.width; var _local3:int = loaderInfo.height; var _local4:Sprite = new Sprite(); var _local5:Graphics = _local4.graphics; _local5.beginFill(0); _local5.drawRect(-1000, -1000, (2000 + _local2), 1000); _local5.drawRect(-1000, _local3, (2000 + _local2), 1000); _local5.drawRect(-1000, -1000, 1000, (1000 + _local3)); _local5.drawRect(_local2, -1000, 1000, (1000 + _local3)); _local5.endFill(); addChild(_local4); addChildAt(new Main(SWFBytes), 0); } } }//package
Section 196
//InFamous_SWFBytes (InFamous_SWFBytes) package { import mx.core.*; public class InFamous_SWFBytes extends ByteArrayAsset { } }//package

Library Items

Symbol 1 BinaryData {com.kerb.infamous.Preload_SWFBytes}
Symbol 2 BinaryData {com.kerb.infamous.Main_text_fr_BE}
Symbol 3 BinaryData {com.kerb.infamous.Main_text_pl_PL}
Symbol 4 BinaryData {com.kerb.infamous.Main_text_pt_PT}
Symbol 5 BinaryData {com.kerb.infamous.Main_text_fi_FI}
Symbol 6 BinaryData {com.kerb.infamous.Main_text_de_CH}
Symbol 7 BinaryData {com.kerb.infamous.Main_text_da_DK}
Symbol 8 BinaryData {com.kerb.infamous.Main_text_longest}
Symbol 9 BinaryData {com.kerb.infamous.Main_text_es_ES}
Symbol 10 BinaryData {com.kerb.infamous.Main_text_en_GB}
Symbol 11 BinaryData {com.kerb.infamous.Main_text_sv_SE}
Symbol 12 BinaryData {InFamous_SWFBytes}
Symbol 13 BinaryData {com.kerb.infamous.Main_text_ru_RU}
Symbol 14 BinaryData {com.kerb.infamous.Main_text_nl_BE}
Symbol 15 BinaryData {com.kerb.infamous.game.levels.Level2_XMLData}
Symbol 16 BinaryData {com.kerb.infamous.Main_text_it_IT}
Symbol 17 BinaryData {com.kerb.infamous.Main_text_no_NO}
Symbol 18 BinaryData {com.kerb.infamous.game.levels.Level3_XMLData}
Symbol 19 BinaryData {com.kerb.infamous.game.levels.Level1_XMLData}

Special Tags

FileAttributes (69)Timeline Frame 1Access network only, Metadata present, AS3.
SWFMetaData (77)Timeline Frame 1458 bytes "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'><rdf:Description rdf:about='' xmlns ..."
ScriptLimits (65)Timeline Frame 1MaxRecursionDepth: 1000, ScriptTimeout: 60 seconds
SerialNumber (41)Timeline Frame 1

Labels

"com_kerb_infamous_Preload"Frame 1
"InFamous"Frame 2




http://swfchan.com/15/74587/info.shtml
Created: 7/4 -2019 01:24:54 Last modified: 7/4 -2019 01:24:54 Server time: 22/12 -2024 19:48:52